drm/amd/pm: fix the issue of size calculation error for smu 13.0.6

v1:
the driver should handle return value of smu_v13_0_6_printk_clk_levels()
to return the correct size for sysfs reads.

v2:
fix the issue of size calculation error in smu_v13_0_6_print_clks()

Fixes: cdfdec6f16 ("drm/amd/pm: Avoid writing nulls into `pp_od_clk_voltage`")
Signed-off-by: Yang Wang <kevinyang.wang@amd.com>
Reviewed-by: Lijo Lazar <lijo.lazar@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
This commit is contained in:
Yang Wang
2025-10-27 15:22:54 +08:00
committed by Alex Deucher
parent 87208c1068
commit 8f94d5d0d7

View File

@@ -1394,7 +1394,7 @@ static int smu_v13_0_6_print_clks(struct smu_context *smu, char *buf, int size,
return -EINVAL;
if (curr_clk < SMU_13_0_6_DSCLK_THRESHOLD) {
size = sysfs_emit_at(buf, size, "S: %uMhz *\n", curr_clk);
size += sysfs_emit_at(buf, size, "S: %uMhz *\n", curr_clk);
for (i = 0; i < clocks.num_levels; i++)
size += sysfs_emit_at(buf, size, "%d: %uMhz\n", i,
clocks.data[i].clocks_in_khz /
@@ -1514,9 +1514,13 @@ static int smu_v13_0_6_print_clk_levels(struct smu_context *smu,
single_dpm_table = &(dpm_context->dpm_tables.uclk_table);
return smu_v13_0_6_print_clks(smu, buf, size, single_dpm_table,
now, "mclk");
ret = smu_v13_0_6_print_clks(smu, buf, size, single_dpm_table,
now, "mclk");
if (ret < 0)
return ret;
size += ret;
break;
case SMU_SOCCLK:
ret = smu_v13_0_6_get_current_clk_freq_by_table(smu, SMU_SOCCLK,
&now);
@@ -1528,9 +1532,13 @@ static int smu_v13_0_6_print_clk_levels(struct smu_context *smu,
single_dpm_table = &(dpm_context->dpm_tables.soc_table);
return smu_v13_0_6_print_clks(smu, buf, size, single_dpm_table,
now, "socclk");
ret = smu_v13_0_6_print_clks(smu, buf, size, single_dpm_table,
now, "socclk");
if (ret < 0)
return ret;
size += ret;
break;
case SMU_FCLK:
ret = smu_v13_0_6_get_current_clk_freq_by_table(smu, SMU_FCLK,
&now);
@@ -1542,9 +1550,13 @@ static int smu_v13_0_6_print_clk_levels(struct smu_context *smu,
single_dpm_table = &(dpm_context->dpm_tables.fclk_table);
return smu_v13_0_6_print_clks(smu, buf, size, single_dpm_table,
now, "fclk");
ret = smu_v13_0_6_print_clks(smu, buf, size, single_dpm_table,
now, "fclk");
if (ret < 0)
return ret;
size += ret;
break;
case SMU_VCLK:
ret = smu_v13_0_6_get_current_clk_freq_by_table(smu, SMU_VCLK,
&now);
@@ -1556,9 +1568,13 @@ static int smu_v13_0_6_print_clk_levels(struct smu_context *smu,
single_dpm_table = &(dpm_context->dpm_tables.vclk_table);
return smu_v13_0_6_print_clks(smu, buf, size, single_dpm_table,
now, "vclk");
ret = smu_v13_0_6_print_clks(smu, buf, size, single_dpm_table,
now, "vclk");
if (ret < 0)
return ret;
size += ret;
break;
case SMU_DCLK:
ret = smu_v13_0_6_get_current_clk_freq_by_table(smu, SMU_DCLK,
&now);
@@ -1570,9 +1586,13 @@ static int smu_v13_0_6_print_clk_levels(struct smu_context *smu,
single_dpm_table = &(dpm_context->dpm_tables.dclk_table);
return smu_v13_0_6_print_clks(smu, buf, size, single_dpm_table,
now, "dclk");
ret = smu_v13_0_6_print_clks(smu, buf, size, single_dpm_table,
now, "dclk");
if (ret < 0)
return ret;
size += ret;
break;
default:
break;
}