<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
comment inline.</div>
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>From:</b> amd-gfx <amd-gfx-bounces@lists.freedesktop.org> on behalf of Liang, Prike <Prike.Liang@amd.com><br>
<b>Sent:</b> Monday, September 23, 2019 4:43 PM<br>
<b>To:</b> amd-gfx@lists.freedesktop.org <amd-gfx@lists.freedesktop.org><br>
<b>Cc:</b> arron.liu@amd.com <arron.liu@amd.com>; Huang, Ray <Ray.Huang@amd.com>; Liang, Prike <Prike.Liang@amd.com>; Quan, Evan <Evan.Quan@amd.com>; Feng, Kenneth <Kenneth.Feng@amd.com><br>
<b>Subject:</b> [PATCH 2/5] drm/amd/powerplay: add interface for forcing and unforcing dpm limit value</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt">
<div class="PlainText">That's base function for forcing and unforcing dpm limit value.<br>
<br>
Signed-off-by: Prike Liang <Prike.Liang@amd.com><br>
---<br>
 drivers/gpu/drm/amd/powerplay/renoir_ppt.c | 62 ++++++++++++++++++++++++++++++<br>
 1 file changed, 62 insertions(+)<br>
<br>
diff --git a/drivers/gpu/drm/amd/powerplay/renoir_ppt.c b/drivers/gpu/drm/amd/powerplay/renoir_ppt.c<br>
index 9311b6a..4bb7e1c 100644<br>
--- a/drivers/gpu/drm/amd/powerplay/renoir_ppt.c<br>
+++ b/drivers/gpu/drm/amd/powerplay/renoir_ppt.c<br>
@@ -304,6 +304,66 @@ static int renoir_dpm_set_uvd_enable(struct smu_context *smu, bool enable)<br>
         return ret;<br>
 }<br>
 <br>
+static int renoir_force_dpm_limit_value(struct smu_context *smu, bool highest)<br>
+{<br>
+       int ret = 0, i = 0;<br>
+       uint32_t min_freq, max_freq, force_freq;<br>
+       enum smu_clk_type clk_type;<br>
+<br>
+       enum smu_clk_type clks[] = {<br>
+               SMU_GFXCLK,<br>
+               SMU_MCLK,<br>
+               SMU_SOCCLK,<br>
+       };<br>
+<br>
+       for (i = 0; i < ARRAY_SIZE(clks); i++) {<br>
+               clk_type = clks[i];<br>
+               ret = smu_get_dpm_freq_range(smu, clk_type, &min_freq, &max_freq);<br>
+               if (ret)<br>
+                       return ret;<br>
+<br>
+               force_freq = highest ? max_freq : min_freq;<br>
+               ret = smu_set_soft_freq_range(smu, clk_type, force_freq, force_freq);</div>
<div class="PlainText">[kevin]:</div>
<div class="PlainText">this api is depend on message "SetSoftMaxByFreq" and "SetSoftMinByFreq".</div>
<div class="PlainText">the apu has this message? and have you verify it?</div>
<div class="PlainText">+               if (ret)<br>
+                       return ret;<br>
+       }<br>
+<br>
+       return ret;<br>
+}<br>
+<br>
+static int renoir_unforce_dpm_levels(struct smu_context *smu) {<br>
+<br>
+       int ret = 0, i = 0;<br>
+       uint32_t min_freq, max_freq;<br>
+       enum smu_clk_type clk_type;<br>
+<br>
+       struct clk_feature_map {<br>
+               enum smu_clk_type clk_type;<br>
+               uint32_t        feature;<br>
+       } clk_feature_map[] = {<br>
+               {SMU_GFXCLK, SMU_FEATURE_DPM_GFXCLK_BIT},<br>
+               {SMU_MCLK,   SMU_FEATURE_DPM_UCLK_BIT},<br>
+               {SMU_SOCCLK, SMU_FEATURE_DPM_SOCCLK_BIT},<br>
+       };<br>
+<br>
+       for (i = 0; i < ARRAY_SIZE(clk_feature_map); i++) {<br>
+               if (!smu_feature_is_enabled(smu, clk_feature_map[i].feature))<br>
+                   continue;<br>
+<br>
+               clk_type = clk_feature_map[i].clk_type;<br>
+<br>
+               ret = smu_get_dpm_freq_range(smu, clk_type, &min_freq, &max_freq);<br>
+               if (ret)<br>
+                       return ret;<br>
+<br>
+               ret = smu_set_soft_freq_range(smu, clk_type, min_freq, max_freq);<br>
+               if (ret)<br>
+                       return ret;<br>
+       }<br>
+<br>
+       return ret;<br>
+}<br>
+<br>
 static const struct pptable_funcs renoir_ppt_funcs = {<br>
         .get_smu_msg_index = renoir_get_smu_msg_index,<br>
         .get_smu_table_index = renoir_get_smu_table_index,<br>
@@ -313,6 +373,8 @@ static const struct pptable_funcs renoir_ppt_funcs = {<br>
         .print_clk_levels = renoir_print_clk_levels,<br>
         .get_current_power_state = renoir_get_current_power_state,<br>
         .dpm_set_uvd_enable = renoir_dpm_set_uvd_enable,<br>
+       .force_dpm_limit_value = renoir_force_dpm_limit_value,<br>
+       .unforce_dpm_levels = renoir_unforce_dpm_levels,<br>
 };<br>
 <br>
 void renoir_set_ppt_funcs(struct smu_context *smu)<br>
-- <br>
2.7.4<br>
<br>
_______________________________________________<br>
amd-gfx mailing list<br>
amd-gfx@lists.freedesktop.org<br>
<a href="https://lists.freedesktop.org/mailman/listinfo/amd-gfx">https://lists.freedesktop.org/mailman/listinfo/amd-gfx</a></div>
</span></font></div>
</body>
</html>