[SWDEV-524147] Patch for handling new ras filenames (#205)
The code is changed to handle both original and ACA based ECC counters
for backward compatibilities.
Signed-off-by: Maisam Arif <Maisam.Arif@amd.com>
Co-authored-by: Maisam Arif <Maisam.Arif@amd.com>
[ROCm/amdsmi commit: 9b6e0432b2]
Цей коміт міститься в:
зафіксовано
GitHub
джерело
a5f5da8b90
коміт
c3a0ec4f9a
@@ -736,6 +736,17 @@ std::string Device::get_sys_file_path_by_type(DevInfoTypes type) const {
|
||||
return sysfs_path;
|
||||
}
|
||||
|
||||
// The fallback sysfs to handle backward compatibilities
|
||||
static const std::map<DevInfoTypes, std::string> kDevFallbackFile = {
|
||||
{kDevErrCntGFX, "ras/aca_gfx"},
|
||||
{kDevErrCntSDMA, "ras/aca_sdma"},
|
||||
{kDevErrCntUMC, "ras/aca_umc"},
|
||||
{kDevErrCntMMHUB, "ras/aca_mmhub"},
|
||||
{kDevErrCntPCIEBIF, "ras/aca_pcie_bif"},
|
||||
{kDevErrCntHDP, "ras/aca_hdp"},
|
||||
{kDevErrCntXGMIWAFL, "ras/aca_xgmi_wafl"},
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
int Device::openSysfsFileStream(DevInfoTypes type, T *fs, const char *str) {
|
||||
auto sysfs_path = path_;
|
||||
@@ -769,6 +780,28 @@ int Device::openSysfsFileStream(DevInfoTypes type, T *fs, const char *str) {
|
||||
bool reg_file;
|
||||
|
||||
int ret = isRegularFile(sysfs_path, ®_file);
|
||||
|
||||
if (ret != 0 || !reg_file) {
|
||||
// Handle specific types if the file does not exist
|
||||
if (kDevFallbackFile.find(type) != kDevFallbackFile.end()) {
|
||||
|
||||
sysfs_path = path_ + "/device/" + kDevFallbackFile.at(type);
|
||||
DBG_FILE_ERROR(sysfs_path, str);
|
||||
|
||||
// Recheck the adjusted path
|
||||
ret = isRegularFile(sysfs_path, ®_file);
|
||||
if (ret != 0 || !reg_file) {
|
||||
ss << __PRETTY_FUNCTION__
|
||||
<< " | Adjusted file path also does not exist - SYSFS file ("
|
||||
<< sysfs_path
|
||||
<< ") for DevInfoInfoType (" << get_type_string(type)
|
||||
<< "), returning " << std::to_string(ret);
|
||||
LOG_ERROR(ss);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (ret != 0) {
|
||||
ss << __PRETTY_FUNCTION__ << " | Issue: File did not exist - SYSFS file ("
|
||||
<< sysfs_path
|
||||
@@ -777,6 +810,7 @@ int Device::openSysfsFileStream(DevInfoTypes type, T *fs, const char *str) {
|
||||
LOG_ERROR(ss);
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (!reg_file) {
|
||||
ss << __PRETTY_FUNCTION__
|
||||
<< " | Issue: File is not a regular file - SYSFS file ("
|
||||
@@ -792,7 +826,7 @@ int Device::openSysfsFileStream(DevInfoTypes type, T *fs, const char *str) {
|
||||
if (!fs->is_open()) {
|
||||
ss << __PRETTY_FUNCTION__
|
||||
<< " | Issue: Could not open - SYSFS file (" << sysfs_path << ") for "
|
||||
<< "DevInfoInfoType (" << get_type_string(type) << "), "
|
||||
<< "DevInfoTypes (" << get_type_string(type) << "), "
|
||||
<< ", returning " << std::to_string(errno) << " ("
|
||||
<< std::strerror(errno) << ")";
|
||||
LOG_ERROR(ss);
|
||||
@@ -801,7 +835,7 @@ int Device::openSysfsFileStream(DevInfoTypes type, T *fs, const char *str) {
|
||||
|
||||
ss << __PRETTY_FUNCTION__ << " | Successfully opened SYSFS file ("
|
||||
<< sysfs_path
|
||||
<< ") for DevInfoInfoType (" << get_type_string(type)
|
||||
<< ") for DevInfoTypes (" << get_type_string(type)
|
||||
<< ")";
|
||||
LOG_INFO(ss);
|
||||
return 0;
|
||||
|
||||
@@ -503,7 +503,12 @@ amdsmi_status_t smi_amdgpu_get_ecc_error_count(amd::smi::AMDSmiGPUDevice* device
|
||||
std::ifstream f(fullpath.c_str());
|
||||
|
||||
if (f.fail()) {
|
||||
return AMDSMI_STATUS_NOT_SUPPORTED;
|
||||
//fall back to aca file
|
||||
fullpath = "/sys/class/drm/" + device->get_gpu_path() + std::string("/device/ras/aca_umc");
|
||||
f.open(fullpath.c_str());
|
||||
if (f.fail()) {
|
||||
return AMDSMI_STATUS_NOT_SUPPORTED;
|
||||
}
|
||||
}
|
||||
|
||||
std::string line;
|
||||
|
||||
Посилання в новій задачі
Заблокувати користувача