[AMD Official Use Only - AMD Internal Distribution Only]

Reviewed-by: Asad Kamal <[email protected]>

Thanks & Regards
Asad

-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Monday, October 27, 2025 2:29 PM
To: Wang, Yang(Kevin) <[email protected]>; [email protected]
Cc: Zhang, Hawking <[email protected]>; Deucher, Alexander 
<[email protected]>; Kamal, Asad <[email protected]>
Subject: Re: [PATCH v2] drm/amd/pm: fix the issue of size calculation error for 
smu 13.0.6



On 10/27/2025 2:09 PM, Yang Wang wrote:
> 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: 0354cd650daa ("drm/amd/pm: Avoid writing nulls into
> `pp_od_clk_voltage`")
>
> Signed-off-by: Yang Wang <[email protected]>

Reviewed-by: Lijo Lazar <[email protected]>

Thanks,
Lijo

> ---
>   .../drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c  | 42 ++++++++++++++-----
>   1 file changed, 31 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c
> b/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c
> index 39ae6701147c..1d9cc384fc30 100644
> --- a/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c
> +++ b/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c
> @@ -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;
>       }

Reply via email to