From d508526af7e3c04744e73e888482b90051e5f003 Mon Sep 17 00:00:00 2001 From: Charis Poag Date: Sun, 14 Jan 2024 19:22:31 -0600 Subject: [PATCH 1/5] Fix AMD-SMI test segmentation fault TestGpuMetricsRead Issue: need to return on any failure. The nullptr check test would segfault without- all values in struct are not initialized. Signed-off-by: Charis Poag Change-Id: I4987fb73ba9bcb182de7a439a4286333a41bf7eb (cherry picked from commit d74be3120e09b5b4c456b311b37aa5c86438115f) [ROCm/amdsmi commit: c3b5d0a77a2add505b2fce718934a7c7d34e02e4] --- projects/amdsmi/src/amd_smi/amd_smi.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/projects/amdsmi/src/amd_smi/amd_smi.cc b/projects/amdsmi/src/amd_smi/amd_smi.cc index ae4b5af69b..aff25228b2 100644 --- a/projects/amdsmi/src/amd_smi/amd_smi.cc +++ b/projects/amdsmi/src/amd_smi/amd_smi.cc @@ -1084,6 +1084,9 @@ amdsmi_status_t amdsmi_get_gpu_metrics_info( amdsmi_status_t ret = rsmi_wrapper(rsmi_dev_gpu_metrics_info_get, processor_handle, reinterpret_cast(pgpu_metrics)); + if (ret != AMDSMI_STATUS_SUCCESS) { + return ret; + } // WARNING: TEMPORARY - awaiting 1.5 update from amdgpu driver/firmware // intended to be removed later // START: REMOVE WHATS BELOW ME From 4032f8a9a6660502ce4d512fcf789b8faec0cfec Mon Sep 17 00:00:00 2001 From: Maisam Arif Date: Sun, 21 Jan 2024 02:44:44 -0600 Subject: [PATCH 2/5] SWDEV-440462: Fixed metric functionality to Linux Guest Change-Id: Ia69d01251d1e9bb3717bda3a7d0f752c739393a6 Signed-off-by: Maisam Arif (cherry picked from commit 6292ac513cb1c9917d02ad3f9173f44734b3db2b) [ROCm/amdsmi commit: 422b9631b08ee0ce005c72e2bfc773d4972b47bf] --- projects/amdsmi/README.md | 2 +- projects/amdsmi/amdsmi_cli/amdsmi_commands.py | 67 ++++++++++++++++--- projects/amdsmi/amdsmi_cli/amdsmi_parser.py | 4 +- 3 files changed, 61 insertions(+), 12 deletions(-) diff --git a/projects/amdsmi/README.md b/projects/amdsmi/README.md index b18de60af8..6aa5c2199d 100755 --- a/projects/amdsmi/README.md +++ b/projects/amdsmi/README.md @@ -35,7 +35,7 @@ installed to query firmware information and hardware IPs. ``` bash apt install amd-smi-lib # if installed with rocm ignore the export -export PATH="$PATH:/opt/rocm/bin" +export PATH="${PATH:+${PATH}:}~/opt/rocm/bin" amd-smi --help ``` diff --git a/projects/amdsmi/amdsmi_cli/amdsmi_commands.py b/projects/amdsmi/amdsmi_cli/amdsmi_commands.py index 369ce0497d..a1f6eb13b0 100644 --- a/projects/amdsmi/amdsmi_cli/amdsmi_commands.py +++ b/projects/amdsmi/amdsmi_cli/amdsmi_commands.py @@ -94,7 +94,7 @@ class AMDSMICommands(): try: amdsmi_lib_version = amdsmi_interface.amdsmi_get_lib_version() amdsmi_lib_version_str = f"{amdsmi_lib_version['year']}.{amdsmi_lib_version['major']}.{amdsmi_lib_version['minor']}.{amdsmi_lib_version['release']}" - rocm_version_str = get_rocm_version(); + rocm_version_str = get_rocm_version() except amdsmi_exception.AmdSmiLibraryException as e: amdsmi_lib_version_str = e.get_error_info() @@ -1016,7 +1016,7 @@ class AMDSMICommands(): current_platform_args += ["mem_usage"] current_platform_values += [args.mem_usage] - if self.helpers.is_hypervisor() or self.helpers.is_baremetal(): + if self.helpers.is_hypervisor() or self.helpers.is_baremetal() or self.helpers.is_linux(): if usage: args.usage = usage if power: @@ -2262,10 +2262,56 @@ class AMDSMICommands(): gpus = args.gpu cpus= args.cpu cores = args.core - gpu_options = any([args.gpu, args.usage,args.watch, args.watch_time, args.iterations, - args.power, args.clock, args.temperature, args.ecc, args.ecc_block, - args.pcie, args.fan, args.voltage_curve, args.overdrive, args.perf_level, - args.xgmi_err, args.energy, args.mem_usage]) + + # GPU Options check against each attribute + gpu_options = False + if hasattr(args, 'gpu'): + gpu_options |= bool(args.gpu) + if hasattr(args, 'usage'): + gpu_options |= bool(args.usage) + if hasattr(args, 'watch'): + gpu_options |= bool(args.watch) + if hasattr(args, 'watch_time'): + gpu_options |= bool(args.watch_time) + if hasattr(args, 'iterations'): + gpu_options |= bool(args.iterations) + if hasattr(args, 'power'): + gpu_options |= bool(args.power) + if hasattr(args, 'clock'): + gpu_options |= bool(args.clock) + if hasattr(args, 'temperature'): + gpu_options |= bool(args.temperature) + if hasattr(args, 'ecc'): + gpu_options |= bool(args.ecc) + if hasattr(args, 'ecc_block'): + gpu_options |= bool(args.ecc_block) + if hasattr(args, 'pcie'): + gpu_options |= bool(args.pcie) + if hasattr(args, 'fan'): + gpu_options |= bool(args.fan) + if hasattr(args, 'voltage_curve'): + gpu_options |= bool(args.voltage_curve) + if hasattr(args, 'overdrive'): + gpu_options |= bool(args.overdrive) + if hasattr(args, 'perf_level'): + gpu_options |= bool(args.perf_level) + if hasattr(args, 'xgmi_err'): + gpu_options |= bool(args.xgmi_err) + if hasattr(args, 'energy'): + gpu_options |= bool(args.energy) + if hasattr(args, 'mem_usage'): + gpu_options |= bool(args.mem_usage) + if hasattr(args, 'schedule'): + gpu_options |= bool(args.schedule) + if hasattr(args, 'guard'): + gpu_options |= bool(args.guard) + if hasattr(args, 'guest_data'): + gpu_options |= bool(args.guest_data) + if hasattr(args, 'fb_usage'): + gpu_options |= bool(args.fb_usage) + if hasattr(args, 'xgmi'): + gpu_options |= bool(args.xgmi) + cpu_options = any([args.cpu, args.cpu_power_metrics, args.cpu_prochot, args.cpu_freq_metrics, args.cpu_c0_res, args.cpu_lclk_dpm_level, args.cpu_pwr_svi_telemtry_rails, args.cpu_io_bandwidth, args.cpu_xgmi_bandwidth, @@ -2279,6 +2325,12 @@ class AMDSMICommands(): core_options = any([args.core_boost_limit, args.core_curr_active_freq_core_limit, args.set_core_boost_limit, args.core_energy]) + + if gpu_options and len(self.device_handles) == 0: + logging.error("No GPU devices present") + sys.exit(-1) + + if ((len(self.device_handles) and ((((not gpus) and (not cpus) and (not cores)) or gpus) and not cpu_options and not core_options))): self.metric_gpu( args, multiple_devices, watching_output, gpu, @@ -2288,9 +2340,6 @@ class AMDSMICommands(): xgmi_err, energy, mem_usage, schedule, guard, guest_data, fb_usage, xgmi) - if (gpu_options and (len(self.device_handles) == 0)): - logging.error("No GPU devices present") - sys.exit(-1) if ((len(self.cpu_handles) and ((((not gpus) and (not cpus) and (not cores)) or cpus) and not gpu_options and not core_options))): diff --git a/projects/amdsmi/amdsmi_cli/amdsmi_parser.py b/projects/amdsmi/amdsmi_cli/amdsmi_parser.py index f419b724f2..f92e7e7de7 100644 --- a/projects/amdsmi/amdsmi_cli/amdsmi_parser.py +++ b/projects/amdsmi/amdsmi_cli/amdsmi_parser.py @@ -79,7 +79,7 @@ class AMDSMIParser(argparse.ArgumentParser): version_string = f"Version: {__version__}" platform_string = f"Platform: {self.helpers.os_info()}" - rocm_version = get_rocm_version(); + rocm_version = get_rocm_version() rocm_version_string = f"ROCm version: {rocm_version}" program_name = 'amd-smi' @@ -623,7 +623,7 @@ core limit value" metric_parser.add_argument('-m', '--mem-usage', action='store_true', required=False, help=mem_usage_help) # Optional Args for Hypervisors and Baremetal systems - if self.helpers.is_hypervisor() or self.helpers.is_baremetal(): + if self.helpers.is_hypervisor() or self.helpers.is_baremetal() or self.helpers.is_linux(): metric_parser.add_argument('-u', '--usage', action='store_true', required=False, help=usage_help) metric_parser.add_argument('-p', '--power', action='store_true', required=False, help=power_help) metric_parser.add_argument('-c', '--clock', action='store_true', required=False, help=clock_help) From cc50414c9caef325ac6c8b48f9e13e61ca57e090 Mon Sep 17 00:00:00 2001 From: Maisam Arif Date: Mon, 2 Dec 2024 16:30:06 -0600 Subject: [PATCH 3/5] [SWDEV-502001] Fix link for amd_hsmp.h Signed-off-by: Maisam Arif Change-Id: I402ee539cdd4c896acd7ccc83f3090c3a5eeba12 (cherry picked from commit 835b43818696f5d572f439d51ebb665e06149607) [ROCm/amdsmi commit: a4574a7d13e1dea0f0960a6bf2e097332a16d6c1] --- projects/amdsmi/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/amdsmi/CMakeLists.txt b/projects/amdsmi/CMakeLists.txt index 85821c49ad..d2c118b072 100644 --- a/projects/amdsmi/CMakeLists.txt +++ b/projects/amdsmi/CMakeLists.txt @@ -129,7 +129,7 @@ if(ENABLE_ESMI_LIB) endif() if(NOT EXISTS ${PROJECT_SOURCE_DIR}/esmi_ib_library/include/asm/amd_hsmp.h) file(DOWNLOAD - https://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86.git/plain/arch/x86/include/uapi/asm/amd_hsmp.h?h=review-ilpo + https://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86.git/plain/arch/x86/include/uapi/asm/amd_hsmp.h ${PROJECT_SOURCE_DIR}/esmi_ib_library/include/asm/amd_hsmp.h) endif() add_definitions("-DENABLE_ESMI_LIB=1") From 2560faa31bfdaed207403167fe7c270c666aa778 Mon Sep 17 00:00:00 2001 From: Maisam Arif Date: Fri, 13 Dec 2024 12:00:56 -0600 Subject: [PATCH 4/5] Revert "[SWDEV-502001] Fix link for amd_hsmp.h" This reverts commit cc50414c9caef325ac6c8b48f9e13e61ca57e090. Change-Id: I583e3e49989955f03adea84c965503288c0934ee Signed-off-by: Maisam Arif [ROCm/amdsmi commit: 41561ec3a07676c1bf0db17fe5d331a1b35b5466] --- projects/amdsmi/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/amdsmi/CMakeLists.txt b/projects/amdsmi/CMakeLists.txt index d2c118b072..85821c49ad 100644 --- a/projects/amdsmi/CMakeLists.txt +++ b/projects/amdsmi/CMakeLists.txt @@ -129,7 +129,7 @@ if(ENABLE_ESMI_LIB) endif() if(NOT EXISTS ${PROJECT_SOURCE_DIR}/esmi_ib_library/include/asm/amd_hsmp.h) file(DOWNLOAD - https://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86.git/plain/arch/x86/include/uapi/asm/amd_hsmp.h + https://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86.git/plain/arch/x86/include/uapi/asm/amd_hsmp.h?h=review-ilpo ${PROJECT_SOURCE_DIR}/esmi_ib_library/include/asm/amd_hsmp.h) endif() add_definitions("-DENABLE_ESMI_LIB=1") From 72f4eac675dcd034c5aa4e2945a656678ed8051c Mon Sep 17 00:00:00 2001 From: "Choudhary, Rahul" Date: Tue, 17 Dec 2024 12:21:17 -0800 Subject: [PATCH 5/5] Create rocm_ci_caller.yml enabling OSDB for push on mainline [ROCm/amdsmi commit: 30e08eed1c42ae49c909666e280a4e61b586455e] --- .../.github/workflows/rocm_ci_caller.yml | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 projects/amdsmi/.github/workflows/rocm_ci_caller.yml diff --git a/projects/amdsmi/.github/workflows/rocm_ci_caller.yml b/projects/amdsmi/.github/workflows/rocm_ci_caller.yml new file mode 100644 index 0000000000..8251503094 --- /dev/null +++ b/projects/amdsmi/.github/workflows/rocm_ci_caller.yml @@ -0,0 +1,22 @@ +name: ROCm CI Caller +on: + # Commenting below to avoid re-runs of amd smi for trivial rebases + # pull_request: + # branches: [amd-staging] + # types: [opened, reopened, synchronize] + push: + branches: [amd-staging, amd-mainline] + workflow_dispatch: + +jobs: + call-workflow: + uses: AMD-ROCm-Internal/rocm_ci_infra/.github/workflows/rocm_ci.yml@mainline + secrets: inherit + with: + input_sha: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }} + input_pr_num: ${{ github.event_name == 'pull_request' && github.event.pull_request.number || 0 }} + input_pr_url: ${{ github.event_name == 'pull_request' && github.event.pull_request.html_url || '' }} + input_pr_title: ${{ github.event_name == 'pull_request' && github.event.pull_request.title || '' }} + repository_name: ${{ github.repository }} + base_ref: ${{ github.event_name == 'pull_request' && github.base_ref || github.ref }} + trigger_event_type: ${{ github.event_name }}