drm/amd/pm: Use emit_clk_levels in yellow carp

Move to emit_clk_levels from print_clk_levels

Signed-off-by: Lijo Lazar <lijo.lazar@amd.com>
Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
This commit is contained in:
Lijo Lazar 2025-11-26 13:20:50 +05:30 committed by Alex Deucher
parent 8456b756e5
commit 5478777fd7

View File

@ -1038,17 +1038,15 @@ static uint32_t yellow_carp_get_umd_pstate_clk_default(struct smu_context *smu,
return clk_limit;
}
static int yellow_carp_print_clk_levels(struct smu_context *smu,
enum smu_clk_type clk_type, char *buf)
static int yellow_carp_emit_clk_levels(struct smu_context *smu,
enum smu_clk_type clk_type, char *buf,
int *offset)
{
int i, idx, size = 0, ret = 0, start_offset = 0;
int i, idx, size = *offset, ret = 0, start_offset = *offset;
uint32_t cur_value = 0, value = 0, count = 0;
uint32_t min, max;
uint32_t clk_limit = 0;
smu_cmn_get_sysfs_buf(&buf, &size);
start_offset = size;
switch (clk_type) {
case SMU_OD_SCLK:
size += sysfs_emit_at(buf, size, "%s:\n", "OD_SCLK");
@ -1069,17 +1067,17 @@ static int yellow_carp_print_clk_levels(struct smu_context *smu,
case SMU_FCLK:
ret = yellow_carp_get_current_clk_freq(smu, clk_type, &cur_value);
if (ret)
goto print_clk_out;
return ret;
ret = yellow_carp_get_dpm_level_count(smu, clk_type, &count);
if (ret)
goto print_clk_out;
return ret;
for (i = 0; i < count; i++) {
idx = (clk_type == SMU_FCLK || clk_type == SMU_MCLK) ? (count - i - 1) : i;
ret = yellow_carp_get_dpm_freq_by_index(smu, clk_type, idx, &value);
if (ret)
goto print_clk_out;
return ret;
size += sysfs_emit_at(buf, size, "%d: %uMhz %s\n", i, value,
cur_value == value ? "*" : "");
@ -1090,7 +1088,7 @@ static int yellow_carp_print_clk_levels(struct smu_context *smu,
clk_limit = yellow_carp_get_umd_pstate_clk_default(smu, clk_type);
ret = yellow_carp_get_current_clk_freq(smu, clk_type, &cur_value);
if (ret)
goto print_clk_out;
return ret;
min = (smu->gfx_actual_hard_min_freq > 0) ? smu->gfx_actual_hard_min_freq : smu->gfx_default_hard_min_freq;
max = (smu->gfx_actual_soft_max_freq > 0) ? smu->gfx_actual_soft_max_freq : smu->gfx_default_soft_max_freq;
if (cur_value == max)
@ -1111,8 +1109,9 @@ static int yellow_carp_print_clk_levels(struct smu_context *smu,
break;
}
print_clk_out:
return size - start_offset;
*offset += size - start_offset;
return 0;
}
static int yellow_carp_force_clk_levels(struct smu_context *smu,
@ -1349,7 +1348,7 @@ static const struct pptable_funcs yellow_carp_ppt_funcs = {
.mode2_reset = yellow_carp_mode2_reset,
.get_dpm_ultimate_freq = yellow_carp_get_dpm_ultimate_freq,
.od_edit_dpm_table = yellow_carp_od_edit_dpm_table,
.print_clk_levels = yellow_carp_print_clk_levels,
.emit_clk_levels = yellow_carp_emit_clk_levels,
.force_clk_levels = yellow_carp_force_clk_levels,
.set_performance_level = yellow_carp_set_performance_level,
.set_fine_grain_gfx_freq_parameters = yellow_carp_set_fine_grain_gfx_freq_parameters,