[SWDEV-524147] Patch for handling new ras filenames (#34)

Signed-off-by: Maisam Arif <Maisam.Arif@amd.com>

[ROCm/rocm_smi_lib commit: 847ac53444]
이 커밋은 다음에 포함됨:
Arif, Maisam
2025-03-27 22:14:28 -05:00
커밋한 사람 GitHub
부모 2ae703fed6
커밋 5e3b10bf8c
+36 -2
파일 보기
@@ -661,6 +661,17 @@ int Device::openDebugFileStream(DevInfoTypes type, T *fs, const char *str) {
return 0;
}
// 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_;
@@ -680,6 +691,28 @@ int Device::openSysfsFileStream(DevInfoTypes type, T *fs, const char *str) {
bool reg_file;
int ret = isRegularFile(sysfs_path, &reg_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, &reg_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
@@ -688,6 +721,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 ("
@@ -703,7 +737,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);
@@ -712,7 +746,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;