drm/amd/pm: Fix clock reporting for SMUv13.0.6
Subsystems (3)
PATCH 1/3 drm/amd/pm: Fix clock reporting for SMUv13.0.6
On SMU v13.0.6, effective clocks are reported by FW which won't exactly match with DPM level. Report the current clock based on the values matching closest to the effective clock. Also, when deep sleep is applied to a clock, report it with a special level "S:" as in sample clock levels below
S: 19Mhz *
0: 615Mhz
1: 800Mhz
2: 888Mhz
3: 1000Mhz
--- .../drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c | 159 +++++++----------- 1 file changed, 62 insertions(+), 97 deletions(-)
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c +62 -97
@@ -91,6 +91,8 @@#define PCIE_LC_SPEED_CNTL__LC_CURRENT_DATA_RATE__SHIFT 0x5#define LINK_SPEED_MAX 4 +#define SMU_13_0_6_DSCLK_THRESHOLD 100 +static const struct cmn2asic_msg_mapping smu_v13_0_6_message_map[SMU_MSG_MAX_COUNT ] = {MSG_MAP (TestMessage, PPSMC_MSG_TestMessage,0 ),MSG_MAP (GetSmuVersion, PPSMC_MSG_GetSmuVersion,1 ),
@@ -782,13 +784,61 @@ 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, +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 ; +uint32_t clk1, clk2; + + ret =smu_v13_0_6_get_clk_table (smu, &clocks, single_dpm_table); +if (ret) { +dev_err (smu->adev->dev,"Attempt to get %s clk levels failed!" , + clk_name); +return ret; + } + +if (!clocks.num_levels) +return -EINVAL ; + +if (curr_clk <SMU_13_0_6_DSCLK_THRESHOLD ) { + 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 / +1000 ); + + }else { +if ((clocks.num_levels ==1 ) || + (curr_clk < (clocks.data[0 ].clocks_in_khz /1000 ))) + level =0 ; +for (i =0 ; i < clocks.num_levels; i++) { + clk1 = clocks.data[i].clocks_in_khz /1000 ; + +if (i < (clocks.num_levels -1 )) + clk2 = clocks.data[i +1 ].clocks_in_khz /1000 ; + +if (curr_clk >= clk1 && curr_clk < clk2) { + level = (curr_clk - clk1) <= (clk2 - curr_clk) ? + i : + i +1 ; + } + + size +=sysfs_emit_at (buf, size,"%d: %uMhz %s\n" , i, + clk1, (level == i) ?"*" :"" ); + } + } + +return size; +} +static int smu_v13_0_6_print_clk_levels (struct smu_context *smu,enum smu_clk_type type,char *buf) { -int i, now, size =0 ; +int now, size =0 ;int ret =0 ;struct smu_umd_pstate_table *pstate_table = &smu->pstate_table; -struct pp_clock_levels_with_latency clocks;struct smu_13_0_dpm_table *single_dpm_table;struct smu_dpm_context *smu_dpm = &smu->smu_dpm;struct smu_13_0_dpm_context *dpm_context =NULL ;
@@ -851,26 +901,9 @@ static int smu_v13_0_6_print_clk_levels(struct smu_context *smu, } single_dpm_table = &(dpm_context->dpm_tables.uclk_table); - ret =smu_v13_0_6_get_clk_table (smu, &clocks, single_dpm_table); -if (ret) { -dev_err (smu->adev->dev, -"Attempt to get memory clk levels Failed!" ); -return ret; - } -for (i =0 ; i < clocks.num_levels; i++) - size +=sysfs_emit_at ( - buf, size,"%d: %uMhz %s\n" , i, - clocks.data[i].clocks_in_khz /1000 , - (clocks.num_levels ==1 ) ? -"*" : - (smu_v13_0_6_freqs_in_same_level ( - clocks.data[i].clocks_in_khz / -1000 , - now) ? -"*" : -"" )); -break ; +return smu_v13_0_6_print_clks (smu, buf, single_dpm_table, now, +"mclk" );case SMU_SOCCLK : ret = smu_v13_0_6_get_current_clk_freq_by_table(smu, SMU_SOCCLK,
@@ -882,26 +915,9 @@ static int smu_v13_0_6_print_clk_levels(struct smu_context *smu, } single_dpm_table = &(dpm_context->dpm_tables.soc_table); - ret =smu_v13_0_6_get_clk_table (smu, &clocks, single_dpm_table); -if (ret) { -dev_err (smu->adev->dev, -"Attempt to get socclk levels Failed!" ); -return ret; - } -for (i =0 ; i < clocks.num_levels; i++) - size +=sysfs_emit_at ( - buf, size,"%d: %uMhz %s\n" , i, - clocks.data[i].clocks_in_khz /1000 , - (clocks.num_levels ==1 ) ? -"*" : - (smu_v13_0_6_freqs_in_same_level ( - clocks.data[i].clocks_in_khz / -1000 , - now) ? -"*" : -"" )); -break ; +return smu_v13_0_6_print_clks (smu, buf, single_dpm_table, now, +"socclk" );case SMU_FCLK : ret = smu_v13_0_6_get_current_clk_freq_by_table(smu, SMU_FCLK,
@@ -913,26 +929,9 @@ static int smu_v13_0_6_print_clk_levels(struct smu_context *smu, } single_dpm_table = &(dpm_context->dpm_tables.fclk_table); - ret =smu_v13_0_6_get_clk_table (smu, &clocks, single_dpm_table); -if (ret) { -dev_err (smu->adev->dev, -"Attempt to get fclk levels Failed!" ); -return ret; - } -for (i =0 ; i < single_dpm_table->count; i++) - size +=sysfs_emit_at ( - buf, size,"%d: %uMhz %s\n" , i, - single_dpm_table->dpm_levels[i].value, - (clocks.num_levels ==1 ) ? -"*" : - (smu_v13_0_6_freqs_in_same_level ( - clocks.data[i].clocks_in_khz / -1000 , - now) ? -"*" : -"" )); -break ; +return smu_v13_0_6_print_clks (smu, buf, single_dpm_table, now, +"fclk" );case SMU_VCLK : ret = smu_v13_0_6_get_current_clk_freq_by_table(smu, SMU_VCLK,
@@ -944,26 +943,9 @@ static int smu_v13_0_6_print_clk_levels(struct smu_context *smu, } single_dpm_table = &(dpm_context->dpm_tables.vclk_table); - ret =smu_v13_0_6_get_clk_table (smu, &clocks, single_dpm_table); -if (ret) { -dev_err (smu->adev->dev, -"Attempt to get vclk levels Failed!" ); -return ret; - } -for (i =0 ; i < single_dpm_table->count; i++) - size +=sysfs_emit_at ( - buf, size,"%d: %uMhz %s\n" , i, - single_dpm_table->dpm_levels[i].value, - (clocks.num_levels ==1 ) ? -"*" : - (smu_v13_0_6_freqs_in_same_level ( - clocks.data[i].clocks_in_khz / -1000 , - now) ? -"*" : -"" )); -break ; +return smu_v13_0_6_print_clks (smu, buf, single_dpm_table, now, +"vclk" );case SMU_DCLK : ret = smu_v13_0_6_get_current_clk_freq_by_table(smu, SMU_DCLK,
@@ -975,26 +957,9 @@ static int smu_v13_0_6_print_clk_levels(struct smu_context *smu, } single_dpm_table = &(dpm_context->dpm_tables.dclk_table); - ret =smu_v13_0_6_get_clk_table (smu, &clocks, single_dpm_table); -if (ret) { -dev_err (smu->adev->dev, -"Attempt to get dclk levels Failed!" ); -return ret; - } -for (i =0 ; i < single_dpm_table->count; i++) - size +=sysfs_emit_at ( - buf, size,"%d: %uMhz %s\n" , i, - single_dpm_table->dpm_levels[i].value, - (clocks.num_levels ==1 ) ? -"*" : - (smu_v13_0_6_freqs_in_same_level ( - clocks.data[i].clocks_in_khz / -1000 , - now) ? -"*" : -"" )); -break ; +return smu_v13_0_6_print_clks (smu, buf, single_dpm_table, now, +"dclk" );default :break ;
Signature · 1 line
2.25.1
PATCH 2/3 drm/amd/pm:Fix GFX deep sleep clock reporting
For SMU v13.0.6, keep GFX deep sleep clock reporting style consistent with that of other clocks. Sample format below.
S: 78Mhz *
0: 600Mhz
1: 800Mhz
--- drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c +9 -1
@@ -869,7 +869,15 @@ static int smu_v13_0_6_print_clk_levels(struct smu_context *smu, min_clk = pstate_table->gfxclk_pstate.curr.min; max_clk = pstate_table->gfxclk_pstate.curr.max; -if (!smu_v13_0_6_freqs_in_same_level (now, min_clk) && +if (now <SMU_13_0_6_DSCLK_THRESHOLD ) { + size +=sysfs_emit_at (buf, size,"S: %uMhz *\n" , + now); + size +=sysfs_emit_at (buf, size,"0: %uMhz\n" , + min_clk); + size +=sysfs_emit_at (buf, size,"1: %uMhz\n" , + max_clk); + + }else if (!smu_v13_0_6_freqs_in_same_level (now, min_clk) && !smu_v13_0_6_freqs_in_same_level (now, max_clk)) { size +=sysfs_emit_at (buf, size,"0: %uMhz\n" , min_clk);
Signature · 1 line
2.25.1
PATCH 3/3 Documentation/amdgpu: Modify pp_dpm_*clk details
In reply to Lijo Lazarpp_dpm_*clk nodes also could show the frequencies when a clock is in 'sleep' state. Add documentation related to that.
--- drivers/gpu/drm/amd/pm/amdgpu_pm.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/pm/amdgpu_pm.c +9 -1
@@ -983,7 +983,15 @@ static ssize_t amdgpu_get_pp_features(struct device *dev,* pp_dpm_fclk interface is only available for Vega20 and later ASICs. * * Reading back the files will show you the available power levels within -* the power state and the clock information for those levels. +* the power state and the clock information for those levels. If deep sleep is +* applied to a clock, the level will be denoted by a special level 'S:' +* E.g., +* S: 19Mhz * +* 0: 615Mhz +* 1: 800Mhz +* 2: 888Mhz +* 3: 1000Mhz +* * * To manually adjust these states, first select manual using * power_dpm_force_performance_level.
Signature · 1 line
2.25.1
Re: [PATCH 3/3] Documentation/amdgpu: Modify pp_dpm_*clk details
Quoted 20 lines · Lijo Lazar
pp_dpm_*clk nodes also could show the frequencies when a clock is in 'sleep' state. Add documentation related to that.
Signed-off-by Lijo Lazar <[email protected]>--- drivers/gpu/drm/amd/pm/amdgpu_pm.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)drivers/gpu/drm/amd/pm/amdgpu_pm.c +2
-1@@ -983,7 +983,15 @@ static ssize_t amdgpu_get_pp_features(struct device *dev,* pp_dpm_fclk interface is only available for Vega20 and later ASICs. * * Reading back the files will show you the available power levels within -* the power state and the clock information for those levels. +* the power state and the clock information for those levels. If deep sleep is +* applied to a clock, the level will be denoted by a special level 'S:'
drivers/gpu/drm/amd/pm/amdgpu_pm.c static ssize_t amdgpu_get_pp_features(struct device *dev, · line 997
Quoted 10 lines
drivers/gpu/drm/amd/pm/amdgpu_pm.c +7
-0+* E.g., +* S: 19Mhz * +* 0: 615Mhz +* 1: 800Mhz +* 2: 888Mhz +* 3: 1000Mhz +* * * To manually adjust these states, first select manual using * power_dpm_force_performance_level.
Might be nice to update older asics to follow this model as well at some point.
Alex
Quoted 3 lines
--
2.25.1
Re: [PATCH 3/3] Documentation/amdgpu: Modify pp_dpm_*clk details
Quoted 25 lines · Alex Deucher
Quoted 24 lines · Lijo Lazar
pp_dpm_*clk nodes also could show the frequencies when a clock is in 'sleep' state. Add documentation related to that.
Signed-off-by Lijo Lazar <[email protected]>--- drivers/gpu/drm/amd/pm/amdgpu_pm.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)drivers/gpu/drm/amd/pm/amdgpu_pm.c +6
-1@@ -983,7 +983,15 @@ static ssize_t amdgpu_get_pp_features(struct device *dev,* pp_dpm_fclk interface is only available for Vega20 and later ASICs. * * Reading back the files will show you the available power levels within -* the power state and the clock information for those levels. +* the power state and the clock information for those levels. If deep sleep is +* applied to a clock, the level will be denoted by a special level 'S:' +* E.g., +* S: 19Mhz * +* 0: 615Mhz +* 1: 800Mhz
Quoted 9 lines
drivers/gpu/drm/amd/pm/amdgpu_pm.c static ssize_t amdgpu_get_pp_features(struct device *dev, · line 997
Quoted 6 lines
drivers/gpu/drm/amd/pm/amdgpu_pm.c +3
-0+* 2: 888Mhz +* 3: 1000Mhz +* * * To manually adjust these states, first select manual using * power_dpm_force_performance_level. Might be nice to update older asics to follow this model as well at some point.
Hi Alex,
Can I go ahead with this doc update, or you want to hold till other ASICs support this type of reporting (with the patches, only SMU v13.0.6 SOCs have this behavior)?
Thanks,
Lijo
Quoted 5 lines
Alex
Quoted 3 lines
--
2.25.1
Re: [PATCH 3/3] Documentation/amdgpu: Modify pp_dpm_*clk details
Quoted 39 lines · Lijo
Quoted 25 lines · Alex Deucher
Quoted 24 lines · Lijo Lazar
pp_dpm_*clk nodes also could show the frequencies when a clock is in 'sleep' state. Add documentation related to that.
Signed-off-by Lijo Lazar <[email protected]>--- drivers/gpu/drm/amd/pm/amdgpu_pm.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)drivers/gpu/drm/amd/pm/amdgpu_pm.c +6
-1@@ -983,7 +983,15 @@ static ssize_t amdgpu_get_pp_features(struct device *dev,* pp_dpm_fclk interface is only available for Vega20 and later ASICs. * * Reading back the files will show you the available power levels within -* the power state and the clock information for those levels. +* the power state and the clock information for those levels. If deep sleep is +* applied to a clock, the level will be denoted by a special level 'S:' +* E.g., +* S: 19Mhz * +* 0: 615Mhz +* 1: 800Mhz Quoted 9 lines
drivers/gpu/drm/amd/pm/amdgpu_pm.c static ssize_t amdgpu_get_pp_features(struct device *dev, · line 997
Quoted 6 lines
drivers/gpu/drm/amd/pm/amdgpu_pm.c +3
-0+* 2: 888Mhz +* 3: 1000Mhz +* * * To manually adjust these states, first select manual using * power_dpm_force_performance_level. Might be nice to update older asics to follow this model as well at some point.
Quoted 5 lines
Hi Alex,
Can I go ahead with this doc update, or you want to hold till other ASICs support this type of reporting (with the patches, only SMU v13.0.6 SOCs have this behavior)?
Yes, please go ahead. It was just a suggestion for a future clean up on older chips.
Alex
Quoted 9 lines
Thanks,
LijoQuoted 5 lines
Alex
Quoted 3 lines
--
2.25.1