Crash if no hwmon sysfs

Return NOT_SUPPORTED if no hwmon sysfs.

Change-Id: I8f4bea0d74619150aee7dfc21fe62d24018e2994


[ROCm/amdsmi commit: b39a56fc52]
此提交包含在:
Bill(Shuzhou) Liu
2023-04-13 12:34:30 -05:00
提交者 Cedomir Dimic
父節點 29a981ecab
當前提交 a1c2a246b1
共有 3 個檔案被更改,包括 22 行新增8 行删除
+1 -1
查看文件
@@ -4,7 +4,7 @@ The AMD System Management Interface Library, or AMD SMI library, is a C library
## Supported platforms
At initial release, the AMD SMI library will support Linux bear metal and Linux virtual machine guest for AMD GPUs. In the future release, the library will be extended to support AMD EPYC™ CPUs.
At initial release, the AMD SMI library will support Linux bare metal and Linux virtual machine guest for AMD GPUs. In the future release, the library will be extended to support AMD EPYC™ CPUs.
AMD SMI library can run on AMD ROCm supported platforms, please refer to [List of Supported Operating Systems and GPUs](https://docs.amd.com/bundle/ROCm-Getting-Started-Guide-v5.3/page/Introduction_to_ROCm_Getting_Started_Guide_for_Linux.html)
+18 -7
查看文件
@@ -336,7 +336,9 @@ static rsmi_status_t get_dev_mon_value(amd::smi::MonitorTypes type,
}
GET_DEV_FROM_INDX
assert(dev->monitor() != nullptr);
if (dev->monitor() == nullptr) {
return RSMI_STATUS_NOT_SUPPORTED;
}
std::string val_str;
@@ -364,7 +366,9 @@ static rsmi_status_t get_dev_mon_value(amd::smi::MonitorTypes type,
}
GET_DEV_FROM_INDX
assert(dev->monitor() != nullptr);
if (dev->monitor() == nullptr) {
return RSMI_STATUS_NOT_SUPPORTED;
}
std::string val_str;
@@ -389,7 +393,9 @@ static rsmi_status_t set_dev_mon_value(amd::smi::MonitorTypes type,
uint32_t dv_ind, uint32_t sensor_ind, T val) {
GET_DEV_FROM_INDX
assert(dev->monitor() != nullptr);
if (dev->monitor() == nullptr) {
return RSMI_STATUS_NOT_SUPPORTED;
}
int ret = dev->monitor()->writeMonitor(type, sensor_ind,
std::to_string(val));
@@ -411,8 +417,9 @@ static rsmi_status_t get_power_mon_value(amd::smi::PowerMonTypes type,
}
std::shared_ptr<amd::smi::Device> dev = smi.devices()[dv_ind];
assert(dev != nullptr);
assert(dev->monitor() != nullptr);
if (dev == nullptr || dev->monitor() == nullptr) {
return RSMI_STATUS_NOT_SUPPORTED;
}
ret = dev->power_monitor()->readPowerValue(type, val);
@@ -2223,7 +2230,9 @@ rsmi_dev_temp_metric_get(uint32_t dv_ind, uint32_t sensor_type,
GET_DEV_FROM_INDX
assert(dev->monitor() != nullptr);
if (dev->monitor() == nullptr) {
return RSMI_STATUS_NOT_SUPPORTED;
}
std::shared_ptr<amd::smi::Monitor> m = dev->monitor();
// getTempSensorIndex will throw an out of range exception if sensor_type is
@@ -2281,7 +2290,9 @@ rsmi_dev_volt_metric_get(uint32_t dv_ind, rsmi_voltage_type_t sensor_type,
GET_DEV_FROM_INDX
assert(dev->monitor() != nullptr);
if (dev->monitor() == nullptr) {
return RSMI_STATUS_NOT_SUPPORTED;
}
std::shared_ptr<amd::smi::Monitor> m = dev->monitor();
// getVoltSensorIndex will throw an out of range exception if sensor_type is
+3
查看文件
@@ -974,6 +974,9 @@ void Device::fillSupportedFuncs(void) {
if (supported_funcs_.size() != 0) {
return;
}
if (monitor() == nullptr) {
return;
}
std::map<const char *, dev_depends_t>::const_iterator it =
kDevFuncDependsMap.begin();