<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 4/5] drm/amd/powerplay: add the interfaces for getting and setting profiling dpm clock level</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt">
<div class="PlainText">implement get_profiling_clk_mask and force_clk_levels for forcing dpm clk to limit value.<br>
<br>
Signed-off-by: Prike Liang <Prike.Liang@amd.com><br>
---<br>
drivers/gpu/drm/amd/powerplay/renoir_ppt.c | 83 ++++++++++++++++++++++++++++++<br>
1 file changed, 83 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 f87aa56..c6aae1c 100644<br>
--- a/drivers/gpu/drm/amd/powerplay/renoir_ppt.c<br>
+++ b/drivers/gpu/drm/amd/powerplay/renoir_ppt.c<br>
@@ -392,6 +392,87 @@ static int renoir_get_workload_type(struct smu_context *smu, uint32_t profile)<br>
return pplib_workload;<br>
}<br>
<br>
+static int renoir_get_profiling_clk_mask(struct smu_context *smu,<br>
+ enum amd_dpm_forced_level level,<br>
+ uint32_t *sclk_mask,<br>
+ uint32_t *mclk_mask,<br>
+ uint32_t *soc_mask)<br>
+{<br>
+<br>
+ if (level == AMD_DPM_FORCED_LEVEL_PROFILE_MIN_SCLK) {<br>
+ if (sclk_mask)<br>
+ *sclk_mask = 0;<br>
+ } else if (level == AMD_DPM_FORCED_LEVEL_PROFILE_MIN_MCLK) {<br>
+ if (mclk_mask)<br>
+ *mclk_mask = 0;<br>
+ } else if (level == AMD_DPM_FORCED_LEVEL_PROFILE_PEAK) {<br>
+ if(sclk_mask)<br>
+ /* The sclk as gfxclk and has three level about max/min/current */<br>
+ *sclk_mask = 3 - 1;</div>
<div class="PlainText">[kevin]:</div>
<div class="PlainText">you should return the max level not current level.</div>
<div class="PlainText">+<br>
+ if(mclk_mask)<br>
+ *mclk_mask = NUM_MEMCLK_DPM_LEVELS - 1;<br>
+<br>
+ if(soc_mask)<br>
+ *soc_mask = NUM_SOCCLK_DPM_LEVELS - 1;<br>
+ }<br>
+<br>
+ return 0;<br>
+}<br>
+<br>
+static int renoir_force_clk_levels(struct smu_context *smu,<br>
+ enum smu_clk_type clk_type, uint32_t mask)<br>
+{<br>
+<br>
+ int ret = 0 ;<br>
+ uint32_t soft_min_level = 0, soft_max_level = 0, min_freq = 0, max_freq = 0;<br>
+ DpmClocks_t *clk_table = smu->smu_table.clocks_table;<br>
+<br>
+ soft_min_level = mask ? (ffs(mask) - 1) : 0;<br>
+ soft_max_level = mask ? (fls(mask) - 1) : 0;<br>
+<br>
+ switch (clk_type) {<br>
+ case SMU_GFXCLK:<br>
+ case SMU_SCLK:<br>
+ ret = smu_get_dpm_freq_range(smu, SMU_GFXCLK, &min_freq, &max_freq);<br>
+ if (ret)<br>
+ return ret;<br>
+ ret = smu_send_smc_msg_with_param(smu, SMU_MSG_SetSoftMaxGfxClk, max_freq);<br>
+ if (ret)<br>
+ return ret;<br>
+ ret = smu_send_smc_msg_with_param(smu, SMU_MSG_SetHardMinGfxClk, min_freq);<br>
+ if (ret)<br>
+ return ret;<br>
+ break;<br>
+ case SMU_SOCCLK:<br>
+ GET_DPM_CUR_FREQ(clk_table, clk_type, soft_min_level, min_freq);<br>
+ GET_DPM_CUR_FREQ(clk_table, clk_type, soft_max_level, max_freq);<br>
+ ret = smu_send_smc_msg_with_param(smu, SMU_MSG_SetSoftMaxSocclkByFreq, max_freq);<br>
+ if (ret)<br>
+ return ret;<br>
+ ret = smu_send_smc_msg_with_param(smu, SMU_MSG_SetHardMinSocclkByFreq, min_freq);<br>
+ if (ret)<br>
+ return ret;<br>
+ break;<br>
+ case SMU_MCLK:<br>
+ case SMU_FCLK:<br>
+ GET_DPM_CUR_FREQ(clk_table, clk_type, soft_min_level, min_freq);<br>
+ GET_DPM_CUR_FREQ(clk_table, clk_type, soft_max_level, max_freq);<br>
+ ret = smu_send_smc_msg_with_param(smu, SMU_MSG_SetSoftMaxFclkByFreq, max_freq);<br>
+ if (ret)<br>
+ return ret;<br>
+ ret = smu_send_smc_msg_with_param(smu, SMU_MSG_SetHardMinFclkByFreq, min_freq);<br>
+ if (ret)<br>
+ return ret;<br>
+</div>
<div class="PlainText">[kevin]:</div>
<div class="PlainText">after remove this blank line,</div>
<div class="PlainText">Reviewed-by: Kevin Wang <kevin1.wang@amd.com></div>
<div class="PlainText">+ break;<br>
+ default:<br>
+ break;<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>
@@ -404,6 +485,8 @@ static const struct pptable_funcs renoir_ppt_funcs = {<br>
.force_dpm_limit_value = renoir_force_dpm_limit_value,<br>
.unforce_dpm_levels = renoir_unforce_dpm_levels,<br>
.get_workload_type = renoir_get_workload_type,<br>
+ .get_profiling_clk_mask = renoir_get_profiling_clk_mask,<br>
+ .force_clk_levels = renoir_force_clk_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>