From e264bf6c020eb4c11c7b1725e8dd9e10bed2b7fc Mon Sep 17 00:00:00 2001 From: Charis Poag Date: Fri, 17 Mar 2023 15:04:34 -0500 Subject: [PATCH] [SWDEV-387906] Fix rocm-smi initialize crash Fix was needed due to hwmon updates. Several voltage sensors (ex. vddgfx/vddnb) are unsupported or not applicable to upcoming hardware. This was not the case for previous hardware sensors, resulting in the rocm-smi crash observed. Change-Id: Ib8593e10811638def26fc7a1eda29309e328db09 Signed-off-by: Charis Poag [ROCm/rocm_smi_lib commit: f44d1ea8bcfc55ad662b80ef715df274f341679d] --- projects/rocm-smi-lib/include/rocm_smi/rocm_smi_monitor.h | 2 +- projects/rocm-smi-lib/src/rocm_smi_monitor.cc | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/projects/rocm-smi-lib/include/rocm_smi/rocm_smi_monitor.h b/projects/rocm-smi-lib/include/rocm_smi/rocm_smi_monitor.h index c6bba27a60..648e159b65 100755 --- a/projects/rocm-smi-lib/include/rocm_smi/rocm_smi_monitor.h +++ b/projects/rocm-smi-lib/include/rocm_smi/rocm_smi_monitor.h @@ -115,6 +115,7 @@ class Monitor { std::string path_; const RocmSMI_env_vars *env_; std::map temp_type_index_map_; + std::map volt_type_index_map_; // This map uses a 64b index instead of 32b (unlike temp_type_index_map_) // for flexibility and simplicity. Currently, some parts of the @@ -124,7 +125,6 @@ class Monitor { // a 64b value. Also, if we need to encode anything else, 64b will give // us more room to do so, without excessive changes. std::map index_temp_type_map_; - std::map volt_type_index_map_; std::map index_volt_type_map_; }; diff --git a/projects/rocm-smi-lib/src/rocm_smi_monitor.cc b/projects/rocm-smi-lib/src/rocm_smi_monitor.cc index 15c995ebae..b493113a54 100755 --- a/projects/rocm-smi-lib/src/rocm_smi_monitor.cc +++ b/projects/rocm-smi-lib/src/rocm_smi_monitor.cc @@ -367,15 +367,16 @@ Monitor::setVoltSensorLabelMap(void) { } auto add_volt_sensor_entry = [&](uint32_t file_index) { ret = readMonitor(kMonVoltLabel, file_index, &type_str); - rsmi_voltage_type_t t_type = kVoltSensorNameMap.at(type_str); + rsmi_voltage_type_t t_type; + // If readMonitor fails, there is no label file for the file_index. // In that case, map the type to file index 0, which is not supported // and will fail appropriately later when we check for support. if (ret) { - volt_type_index_map_.insert({t_type, 0}); index_volt_type_map_.insert({file_index, RSMI_VOLT_TYPE_INVALID}); } else { - volt_type_index_map_.insert({t_type, file_index}); + t_type = kVoltSensorNameMap.at(type_str); + volt_type_index_map_[t_type] = file_index; index_volt_type_map_.insert({file_index, t_type}); } return 0;