From: Wang, Kevin(Yang) <[email protected]>
Sent: Monday, September 23, 2019 5:25 PM
To: Liang, Prike <[email protected]>; [email protected]
Cc: [email protected]; Huang, Ray <[email protected]>; Quan, Evan 
<[email protected]>; Feng, Kenneth <[email protected]>
Subject: Re: [PATCH 2/5] drm/amd/powerplay: add interface for forcing and 
unforcing dpm limit value

comment inline.
________________________________
From: amd-gfx 
<[email protected]<mailto:[email protected]>>
 on behalf of Liang, Prike <[email protected]<mailto:[email protected]>>
Sent: Monday, September 23, 2019 4:43 PM
To: [email protected]<mailto:[email protected]> 
<[email protected]<mailto:[email protected]>>
Cc: [email protected]<mailto:[email protected]> 
<[email protected]<mailto:[email protected]>>; Huang, Ray 
<[email protected]<mailto:[email protected]>>; Liang, Prike 
<[email protected]<mailto:[email protected]>>; Quan, Evan 
<[email protected]<mailto:[email protected]>>; Feng, Kenneth 
<[email protected]<mailto:[email protected]>>
Subject: [PATCH 2/5] drm/amd/powerplay: add interface for forcing and unforcing 
dpm limit value

That's base function for forcing and unforcing dpm limit value.

Signed-off-by: Prike Liang <[email protected]<mailto:[email protected]>>
---
 drivers/gpu/drm/amd/powerplay/renoir_ppt.c | 62 ++++++++++++++++++++++++++++++
 1 file changed, 62 insertions(+)

diff --git a/drivers/gpu/drm/amd/powerplay/renoir_ppt.c 
b/drivers/gpu/drm/amd/powerplay/renoir_ppt.c
index 9311b6a..4bb7e1c 100644
--- a/drivers/gpu/drm/amd/powerplay/renoir_ppt.c
+++ b/drivers/gpu/drm/amd/powerplay/renoir_ppt.c
@@ -304,6 +304,66 @@ static int renoir_dpm_set_uvd_enable(struct smu_context 
*smu, bool enable)
         return ret;
 }

+static int renoir_force_dpm_limit_value(struct smu_context *smu, bool highest)
+{
+       int ret = 0, i = 0;
+       uint32_t min_freq, max_freq, force_freq;
+       enum smu_clk_type clk_type;
+
+       enum smu_clk_type clks[] = {
+               SMU_GFXCLK,
+               SMU_MCLK,
+               SMU_SOCCLK,
+       };
+
+       for (i = 0; i < ARRAY_SIZE(clks); i++) {
+               clk_type = clks[i];
+               ret = smu_get_dpm_freq_range(smu, clk_type, &min_freq, 
&max_freq);
+               if (ret)
+                       return ret;
+
+               force_freq = highest ? max_freq : min_freq;
+               ret = smu_set_soft_freq_range(smu, clk_type, force_freq, 
force_freq);
[kevin]:
this api is depend on message "SetSoftMaxByFreq" and "SetSoftMinByFreq".
the apu has this message? and have you verify it?
[Prike]:
Seems APU hasn't export the message and need send the related clock such as 
PPSMC_MSG_SetSoftMaxGfxClk
for this case.
+               if (ret)
+                       return ret;
+       }
+
+       return ret;
+}
+
+static int renoir_unforce_dpm_levels(struct smu_context *smu) {
+
+       int ret = 0, i = 0;
+       uint32_t min_freq, max_freq;
+       enum smu_clk_type clk_type;
+
+       struct clk_feature_map {
+               enum smu_clk_type clk_type;
+               uint32_t        feature;
+       } clk_feature_map[] = {
+               {SMU_GFXCLK, SMU_FEATURE_DPM_GFXCLK_BIT},
+               {SMU_MCLK,   SMU_FEATURE_DPM_UCLK_BIT},
+               {SMU_SOCCLK, SMU_FEATURE_DPM_SOCCLK_BIT},
+       };
+
+       for (i = 0; i < ARRAY_SIZE(clk_feature_map); i++) {
+               if (!smu_feature_is_enabled(smu, clk_feature_map[i].feature))
+                   continue;
+
+               clk_type = clk_feature_map[i].clk_type;
+
+               ret = smu_get_dpm_freq_range(smu, clk_type, &min_freq, 
&max_freq);
+               if (ret)
+                       return ret;
+
+               ret = smu_set_soft_freq_range(smu, clk_type, min_freq, 
max_freq);
+               if (ret)
+                       return ret;
+       }
+
+       return ret;
+}
+
 static const struct pptable_funcs renoir_ppt_funcs = {
         .get_smu_msg_index = renoir_get_smu_msg_index,
         .get_smu_table_index = renoir_get_smu_table_index,
@@ -313,6 +373,8 @@ static const struct pptable_funcs renoir_ppt_funcs = {
         .print_clk_levels = renoir_print_clk_levels,
         .get_current_power_state = renoir_get_current_power_state,
         .dpm_set_uvd_enable = renoir_dpm_set_uvd_enable,
+       .force_dpm_limit_value = renoir_force_dpm_limit_value,
+       .unforce_dpm_levels = renoir_unforce_dpm_levels,
 };

 void renoir_set_ppt_funcs(struct smu_context *smu)
--
2.7.4

_______________________________________________
amd-gfx mailing list
[email protected]<mailto:[email protected]>
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

Reply via email to