rocm_smi_lib: Fix rocm-smi --showfan shows 'unable to detect fan'
Code changes related to the following: * Reverts earlier fix for the same issue * Check for existence of files before reading Change-Id: I175b20c3343c414b12b79dc3fc404f53fbaabf3a Signed-off-by: Oliveira, Daniel <daniel.oliveira@amd.com>
This commit is contained in:
@@ -785,12 +785,8 @@ def resetFans(deviceList):
|
||||
for device in deviceList:
|
||||
sensor_ind = c_uint32(0)
|
||||
ret = rocmsmi.rsmi_dev_fan_reset(device, sensor_ind)
|
||||
if (ret == rsmi_status_t.RSMI_STATUS_NOT_SUPPORTED) or (ret == rsmi_status_t.RSMI_STATUS_PERMISSION):
|
||||
if not rsmi_ret_ok(rsmi_status_t.RSMI_STATUS_NOT_SUPPORTED, device, 'reset_fan'):
|
||||
continue
|
||||
else:
|
||||
if rsmi_ret_ok(ret, device, 'reset_fan'):
|
||||
printLog(device, 'Successfully reset fan speed to driver control', None)
|
||||
if rsmi_ret_ok(ret, device, 'reset_fan'):
|
||||
printLog(device, 'Successfully reset fan speed to driver control', None)
|
||||
printLogSpacer()
|
||||
|
||||
|
||||
|
||||
@@ -593,7 +593,6 @@ int Device::openSysfsFileStream(DevInfoTypes type, T *fs, const char *str) {
|
||||
bool reg_file;
|
||||
|
||||
int ret = isRegularFile(sysfs_path, ®_file);
|
||||
|
||||
if (ret != 0) {
|
||||
ss << "File did not exist - SYSFS file (" << sysfs_path
|
||||
<< ") for DevInfoInfoType (" << RocmSMI::devInfoTypesStrings.at(type)
|
||||
@@ -804,7 +803,8 @@ int Device::readDevInfoBinary(DevInfoTypes type, std::size_t b_size,
|
||||
FILE *ptr;
|
||||
sysfs_path += "/device/";
|
||||
sysfs_path += kDevAttribNameMap.at(type);
|
||||
ptr = fopen(sysfs_path.c_str(), "rb");
|
||||
|
||||
ptr = fopen(sysfs_path.c_str(), "rb");
|
||||
if (!ptr) {
|
||||
ss << "Could not read DevInfoBinary for DevInfoType ("
|
||||
<< RocmSMI::devInfoTypesStrings.at(type) << ")"
|
||||
|
||||
+12
-3
@@ -158,13 +158,15 @@ int isRegularFile(std::string fname, bool *is_reg) {
|
||||
struct stat file_stat;
|
||||
int ret;
|
||||
|
||||
assert(is_reg != nullptr);
|
||||
|
||||
ret = stat(fname.c_str(), &file_stat);
|
||||
if (ret) {
|
||||
return errno;
|
||||
}
|
||||
*is_reg = S_ISREG(file_stat.st_mode);
|
||||
|
||||
if (is_reg != nullptr) {
|
||||
*is_reg = S_ISREG(file_stat.st_mode);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -192,6 +194,13 @@ int WriteSysfsStr(std::string path, std::string val) {
|
||||
}
|
||||
|
||||
int ReadSysfsStr(std::string path, std::string *retStr) {
|
||||
// On success, zero is returned. On error, -1 is returned, and
|
||||
// errno is set to indicate the error.
|
||||
auto is_regular_file_result = isRegularFile(path, nullptr);
|
||||
if (is_regular_file_result != 0) {
|
||||
return ENOENT;
|
||||
}
|
||||
|
||||
std::stringstream ss;
|
||||
int ret = 0;
|
||||
std::ostringstream oss;
|
||||
|
||||
Reference in New Issue
Block a user