drm/amd/pm: fix the print_clk_levels issue for SMU v13.0.6
Subsystems (3)
PATCH 1/1 drm/amd/pm: fix the print_clk_levels issue for SMU v13.0.6
Pass the correct size to smu_v13_0_6_print_clks, otherwise the same place in buf will be re-written.
--- .../drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-)
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c +12 -12
@@ -821,12 +821,12 @@ static int smu_v13_0_6_get_current_clk_freq_by_table(struct smu_context *smu,return smu_v13_0_6_get_smu_metrics_data (smu, member_type, value); } -static int smu_v13_0_6_print_clks (struct smu_context *smu,char *buf, +static int smu_v13_0_6_print_clks (struct smu_context *smu,char *buf,int size,struct smu_13_0_dpm_table *single_dpm_table,uint32_t curr_clk,const char *clk_name) {struct pp_clock_levels_with_latency clocks; -int i, ret, size =0 , level =-1 ; +int i, ret, level =-1 ;uint32_t clk1, clk2; ret =smu_v13_0_6_get_clk_table (smu, &clocks, single_dpm_table);
@@ -947,8 +947,8 @@ 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, single_dpm_table, now, -"mclk" ); +return smu_v13_0_6_print_clks (smu, buf, size, single_dpm_table, + now,"mclk" );case SMU_SOCCLK : ret = smu_v13_0_6_get_current_clk_freq_by_table(smu, SMU_SOCCLK,
@@ -961,8 +961,8 @@ 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, single_dpm_table, now, -"socclk" ); +return smu_v13_0_6_print_clks (smu, buf, size, single_dpm_table, + now,"socclk" );case SMU_FCLK : ret = smu_v13_0_6_get_current_clk_freq_by_table(smu, SMU_FCLK,
@@ -975,8 +975,8 @@ 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, single_dpm_table, now, -"fclk" ); +return smu_v13_0_6_print_clks (smu, buf, size, single_dpm_table, + now,"fclk" );case SMU_VCLK : ret = smu_v13_0_6_get_current_clk_freq_by_table(smu, SMU_VCLK,
@@ -989,8 +989,8 @@ 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, single_dpm_table, now, -"vclk" ); +return smu_v13_0_6_print_clks (smu, buf, size, single_dpm_table, + now,"vclk" );case SMU_DCLK : ret = smu_v13_0_6_get_current_clk_freq_by_table(smu, SMU_DCLK,
@@ -1003,8 +1003,8 @@ 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, single_dpm_table, now, -"dclk" ); +return smu_v13_0_6_print_clks (smu, buf, size, single_dpm_table, + now,"dclk" );default :break ;
Signature · 1 line
2.38.1
Quoted 3 lines · On 9/26/2023 4:32 PM, Le Ma wrote:
Pass the correct size to
smu_v13_0_6_print_clks, otherwise the same place in buf will be re-written.
Where is this getting affected? As far as I see, there are no multiple emits to the same buffer in this code path.
Thanks,
Lijo
Quoted 80 lines
Change-Id Ia0e12430d01146a11490204c1bab4b4f06cd17eaSigned-off-by Le Ma <[email protected]>--- .../drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-)drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c +12
-12@@ -821,12 +821,12 @@ static int smu_v13_0_6_get_current_clk_freq_by_table(struct smu_context *smu,return smu_v13_0_6_get_smu_metrics_data (smu, member_type, value); } -static int smu_v13_0_6_print_clks (struct smu_context *smu,char *buf, +static int smu_v13_0_6_print_clks (struct smu_context *smu,char *buf,int size,struct smu_13_0_dpm_table *single_dpm_table,uint32_t curr_clk,const char *clk_name) {struct pp_clock_levels_with_latency clocks; -int i, ret, size =0 , level =-1 ; +int i, ret, level =-1 ;uint32_t clk1, clk2; ret =smu_v13_0_6_get_clk_table (smu, &clocks, single_dpm_table);@@ -947,8 +947,8 @@ 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, single_dpm_table, now, -"mclk" ); +return smu_v13_0_6_print_clks (smu, buf, size, single_dpm_table, + now,"mclk" );case SMU_SOCCLK : ret = smu_v13_0_6_get_current_clk_freq_by_table(smu, SMU_SOCCLK,@@ -961,8 +961,8 @@ 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, single_dpm_table, now, -"socclk" ); +return smu_v13_0_6_print_clks (smu, buf, size, single_dpm_table, + now,"socclk" );case SMU_FCLK : ret = smu_v13_0_6_get_current_clk_freq_by_table(smu, SMU_FCLK,@@ -975,8 +975,8 @@ 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, single_dpm_table, now, -"fclk" ); +return smu_v13_0_6_print_clks (smu, buf, size, single_dpm_table, + now,"fclk" );case SMU_VCLK : ret = smu_v13_0_6_get_current_clk_freq_by_table(smu, SMU_VCLK,@@ -989,8 +989,8 @@ 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, single_dpm_table, now, -"vclk" ); +return smu_v13_0_6_print_clks (smu, buf, size, single_dpm_table, + now,"vclk" );case SMU_DCLK : ret = smu_v13_0_6_get_current_clk_freq_by_table(smu, SMU_DCLK,@@ -1003,8 +1003,8 @@ 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, single_dpm_table, now, -"dclk" ); +return smu_v13_0_6_print_clks (smu, buf, size, single_dpm_table, + now,"dclk" );default :break ;
Lazar, Lijo
Reviewed-byQuoted 9 lines · Lijo
Quoted 3 lines · On 9/26/2023 4:32 PM, Le Ma wrote:
Pass the correct size to
smu_v13_0_6_print_clks, otherwise the same place in buf will be re-written.Where is this getting affected? As far as I see, there are no multiple emits to the same buffer in this code path.
Never mind, found one for OD_MCLK.
Thanks,
Lijo
Quoted 73 lines
Thanks,
LijoQuoted 70 lines
Change-Id Ia0e12430d01146a11490204c1bab4b4f06cd17eaSigned-off-by Le Ma <[email protected]>---
.../drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c | 24 +++++++++----------1 file changed, 12 insertions(+), 12 deletions(-)drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c +4
-4@@ -821,12 +821,12 @@ static int smu_v13_0_6_get_current_clk_freq_by_table(struct smu_context *smu, return smu_v13_0_6_get_smu_metrics_data(smu, member_type, value); } -static int smu_v13_0_6_print_clks (struct smu_context *smu,char *buf, +static int smu_v13_0_6_print_clks (struct smu_context *smu,char *buf,int size, struct smu_13_0_dpm_table *single_dpm_table, uint32_t curr_clk, const char *clk_name) { struct pp_clock_levels_with_latency clocks; - int i, ret, size = 0, level = -1; + int i, ret, level = -1; uint32_t clk1, clk2; ret = smu_v13_0_6_get_clk_table(smu, &clocks, single_dpm_table);@@ -947,8 +947,8 @@ static int smu_v13_0_6_print_clk_levels(structsmu_context *smu, single_dpm_table = &(dpm_context->dpm_tables.uclk_table); - return smu_v13_0_6_print_clks(smu, buf, single_dpm_table, now, - "mclk"); + return smu_v13_0_6_print_clks(smu, buf, size, single_dpm_table, + now, "mclk");case
SMU_SOCCLK:
ret = smu_v13_0_6_get_current_clk_freq_by_table(smu,SMU_SOCCLK,drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c +2
-2@@ -961,8 +961,8 @@ static int smu_v13_0_6_print_clk_levels(structsmu_context *smu, single_dpm_table = &(dpm_context->dpm_tables.soc_table); - return smu_v13_0_6_print_clks(smu, buf, single_dpm_table, now, - "socclk"); + return smu_v13_0_6_print_clks(smu, buf, size, single_dpm_table, + now, "socclk");case
SMU_FCLK:
ret = smu_v13_0_6_get_current_clk_freq_by_table(smu,SMU_FCLK,drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c +2
-2@@ -975,8 +975,8 @@ static int smu_v13_0_6_print_clk_levels(structsmu_context *smu, single_dpm_table = &(dpm_context->dpm_tables.fclk_table); - return smu_v13_0_6_print_clks(smu, buf, single_dpm_table, now, - "fclk"); + return smu_v13_0_6_print_clks(smu, buf, size, single_dpm_table, + now, "fclk");case
SMU_VCLK:
ret = smu_v13_0_6_get_current_clk_freq_by_table(smu,SMU_VCLK,drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c +2
-2@@ -989,8 +989,8 @@ static int smu_v13_0_6_print_clk_levels(structsmu_context *smu, single_dpm_table = &(dpm_context->dpm_tables.vclk_table); - return smu_v13_0_6_print_clks(smu, buf, single_dpm_table, now, - "vclk"); + return smu_v13_0_6_print_clks(smu, buf, size, single_dpm_table, + now, "vclk");case
SMU_DCLK:
ret = smu_v13_0_6_get_current_clk_freq_by_table(smu,SMU_DCLK,drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c +2
-2@@ -1003,8 +1003,8 @@ static int smu_v13_0_6_print_clk_levels(structsmu_context *smu, single_dpm_table = &(dpm_context->dpm_tables.dclk_table); - return smu_v13_0_6_print_clks(smu, buf, single_dpm_table, now, - "dclk"); + return smu_v13_0_6_print_clks(smu, buf, size, single_dpm_table, + now, "dclk");default:
break;