[SWDEV-523794] Update to fix MIN_CLK and MAX_CLK incorrect values

(#280)

- Fixed potential issue with min/max values when only one frequency is available
- Improve error handling in GPU frequency range detection
- Refactor clock frequency range detection for better readability
- Added special handling for current frequency indicator (*) in DPM output
- Added comments explaining special case handling for current frequency
- Cleaned up incorrect definitions in hsmp metric table definition

---------

Signed-off-by: Juan Castillo <juan.castillo@amd.com>
Signed-off-by: Maisam Arif <Maisam.Arif@amd.com>
Co-authored-by: Maisam Arif <Maisam.Arif@amd.com>

[ROCm/amdsmi commit: 4d92dea079]
Этот коммит содержится в:
Castillo, JuanиMaisam Arif authored and GitHub committed 2025-04-17 17:46:04 -05:00
1 родитель a0ce11135d
Коммит 21e32ffe4a
5 files changed
+99 -108

No files matched your search

+1 -1
Просмотреть файл
@@ -1178,7 +1178,7 @@ amdsmi_status_t amdsmi_get_violation_status(amdsmi_processor_handle processor_ha
violation_status->active_gfx_clk_below_host_limit = 0;
}
ss << __PRETTY_FUNCTION__ << " | "
<< "ENTERED gfx_clk_below_host_residency_acc | per_gfx_clk_below_host_limit: " << std::dec
<< "ENTERED gfx_below_host_limit_acc | per_gfx_clk_below_host_limit: " << std::dec
<< violation_status->per_gfx_clk_below_host_limit
<< "%; active_ppt_pwr = " << std::dec
<< violation_status->active_gfx_clk_below_host_limit << "\n";
+26 -8
Просмотреть файл
@@ -313,13 +313,14 @@ amdsmi_status_t smi_amdgpu_get_ranges(amd::smi::AMDSmiGPUDevice* device, amdsmi_
return AMDSMI_STATUS_NOT_SUPPORTED;
}
unsigned int max, min, dpm, sleep_freq;
unsigned int max, min, dpm, sleep_freq, current_freq;
char str[10];
char single_char;
max = 0;
min = UINT_MAX;
dpm = 0;
sleep_freq = UINT_MAX;
current_freq = 0;
for (std::string line; getline(ranges, line);) {
unsigned int dpm_level, freq;
@@ -331,21 +332,38 @@ amdsmi_status_t smi_amdgpu_get_ranges(amd::smi::AMDSmiGPUDevice* device, amdsmi_
return AMDSMI_STATUS_NO_DATA;
}
} else {
// skip this line if it contains a * which indicates the current level
const char *current_indicator = strstr(line.c_str(), "*");
if (current_indicator != nullptr){
continue;
}
/**
* if the first line contains '*', then
* we are saving that value as current_freq then checking
* for other dpm levels if none are found then we
* set min and max to current_freq as per Driver
* We then skip to the next line to avoid getting
* incorrect min value.
*/
if (sscanf(line.c_str(), "%u: %d%c", &dpm_level, &freq, str) <= 2){
ranges.close();
return AMDSMI_STATUS_IO;
}
char lastChar = line.back();
if (lastChar == '*'){
current_freq = freq;
continue;
}
// not * was detected so check for the min max
max = freq > max ? freq : max;
min = freq < min ? freq: min;
min = freq < min ? freq : min;
dpm = dpm_level > dpm ? dpm_level : dpm;
}
}
if (dpm == 0 && current_freq > 0) {
// if the dpm level is 0, then the current frequency is the min/max frequency
max = current_freq;
min = current_freq;
}
if (num_dpm)
*num_dpm = dpm;
if (max_freq)