<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
</head>
<body dir="ltr">
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;font-family:Calibri,Helvetica,sans-serif;" dir="ltr">
<p style="margin-top:0;margin-bottom:0"><span>Reviewed-by: Evan Quan <evan.quan@amd.com></span><br>
</p>
</div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>发件人:</b> amd-gfx <amd-gfx-bounces@lists.freedesktop.org> 代表 Rex Zhu <Rex.Zhu@amd.com><br>
<b>发送时间:</b> 2018年5月8日 14:23:35<br>
<b>收件人:</b> amd-gfx@lists.freedesktop.org<br>
<b>抄送:</b> Zhu, Rex<br>
<b>主题:</b> [PATCH] drm/amd/pp: Implement force_clock_level for RV</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt;">
<div class="PlainText">under manual dpm mode, user can set gfx/mem clock<br>
through sysfs pp_dpm_sclk/mclk on Rv.<br>
<br>
Signed-off-by: Rex Zhu <Rex.Zhu@amd.com><br>
---<br>
 drivers/gpu/drm/amd/powerplay/hwmgr/smu10_hwmgr.c | 47 ++++++++++++++++++++++-<br>
 1 file changed, 46 insertions(+), 1 deletion(-)<br>
<br>
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/smu10_hwmgr.c b/drivers/gpu/drm/amd/powerplay/hwmgr/smu10_hwmgr.c<br>
index 68e78256..2152cf4 100644<br>
--- a/drivers/gpu/drm/amd/powerplay/hwmgr/smu10_hwmgr.c<br>
+++ b/drivers/gpu/drm/amd/powerplay/hwmgr/smu10_hwmgr.c<br>
@@ -404,7 +404,7 @@ static int smu10_populate_clock_table(struct pp_hwmgr *hwmgr)<br>
                         "Attempt to copy clock table from smc failed",<br>
                         return result);<br>
 <br>
-       if (0 == result && table->DcefClocks[0].Freq != 0) {<br>
+       if (table->DcefClocks[0].Freq != 0) {<br>
                 smu10_get_clock_voltage_dependency_table(hwmgr, &pinfo->vdd_dep_on_dcefclk,<br>
                                                 NUM_DCEFCLK_DPM_LEVELS,<br>
                                                 &smu10_data->clock_table.DcefClocks[0]);<br>
@@ -775,6 +775,51 @@ static int smu10_get_dal_power_level(struct pp_hwmgr *hwmgr,<br>
 static int smu10_force_clock_level(struct pp_hwmgr *hwmgr,<br>
                 enum pp_clock_type type, uint32_t mask)<br>
 {<br>
+       struct smu10_hwmgr *data = hwmgr->backend;<br>
+       struct smu10_voltage_dependency_table *mclk_table =<br>
+                                       data->clock_vol_info.vdd_dep_on_fclk;<br>
+       uint32_t low, high;<br>
+<br>
+       low = mask ? (ffs(mask) - 1) : 0;<br>
+       high = mask ? (fls(mask) - 1) : 0;<br>
+<br>
+       switch (type) {<br>
+       case PP_SCLK:<br>
+               if (low > 2 || high > 2) {<br>
+                       pr_info("Currently sclk only support 3 levels on RV\n");<br>
+                       return -EINVAL;<br>
+               }<br>
+<br>
+               smum_send_msg_to_smc_with_parameter(hwmgr,<br>
+                                               PPSMC_MSG_SetHardMinGfxClk,<br>
+                                               low == 2 ? data->gfx_max_freq_limit/100 :<br>
+                                               low == 1 ? SMU10_UMD_PSTATE_GFXCLK :<br>
+                                               data->gfx_min_freq_limit/100);<br>
+<br>
+               smum_send_msg_to_smc_with_parameter(hwmgr,<br>
+                                               PPSMC_MSG_SetSoftMaxGfxClk,<br>
+                                               high == 0 ? data->gfx_min_freq_limit/100 :<br>
+                                               high == 1 ? SMU10_UMD_PSTATE_GFXCLK :<br>
+                                               data->gfx_max_freq_limit/100);<br>
+               break;<br>
+<br>
+       case PP_MCLK:<br>
+               if (low > mclk_table->count - 1 || high > mclk_table->count - 1)<br>
+                       return -EINVAL;<br>
+<br>
+               smum_send_msg_to_smc_with_parameter(hwmgr,<br>
+                                               PPSMC_MSG_SetHardMinFclkByFreq,<br>
+                                               mclk_table->entries[low].clk/100);<br>
+<br>
+               smum_send_msg_to_smc_with_parameter(hwmgr,<br>
+                                               PPSMC_MSG_SetSoftMaxFclkByFreq,<br>
+                                               mclk_table->entries[high].clk/100);<br>
+               break;<br>
+<br>
+       case PP_PCIE:<br>
+       default:<br>
+               break;<br>
+       }<br>
         return 0;<br>
 }<br>
 <br>
-- <br>
1.9.1<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><br>
</div>
</span></font></div>
</body>
</html>