From ea2583f48c856be047f885430a9177446a19f2d6 Mon Sep 17 00:00:00 2001 From: "Bill(Shuzhou) Liu" Date: Thu, 29 Jun 2023 14:33:47 -0500 Subject: [PATCH] amdsmi_init() fail when miss voltage sysfs Fix the error handling when voltage sysfs is missing. Change-Id: I457289eb4fd45bb05af83a67289b056f7e2ad966 [ROCm/amdsmi commit: 3b1e2f0817790464af56ae4617b0bc53068b7b0b] --- projects/amdsmi/rocm_smi/src/rocm_smi_monitor.cc | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/projects/amdsmi/rocm_smi/src/rocm_smi_monitor.cc b/projects/amdsmi/rocm_smi/src/rocm_smi_monitor.cc index 15c995ebae..4adffdd50f 100755 --- a/projects/amdsmi/rocm_smi/src/rocm_smi_monitor.cc +++ b/projects/amdsmi/rocm_smi/src/rocm_smi_monitor.cc @@ -367,17 +367,19 @@ 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; };