答复: [PATCH] drm/amd/pp: Implement force_clock_level for RV

Quan, Evan Evan.Quan at amd.com
Tue May 8 07:57:25 UTC 2018


Reviewed-by: Evan Quan <evan.quan at amd.com>

________________________________
发件人: amd-gfx <amd-gfx-bounces at lists.freedesktop.org> 代表 Rex Zhu <Rex.Zhu at amd.com>
发送时间: 2018年5月8日 14:23:35
收件人: amd-gfx at lists.freedesktop.org
抄送: Zhu, Rex
主题: [PATCH] drm/amd/pp: Implement force_clock_level for RV

under manual dpm mode, user can set gfx/mem clock
through sysfs pp_dpm_sclk/mclk on Rv.

Signed-off-by: Rex Zhu <Rex.Zhu at amd.com>
---
 drivers/gpu/drm/amd/powerplay/hwmgr/smu10_hwmgr.c | 47 ++++++++++++++++++++++-
 1 file changed, 46 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/smu10_hwmgr.c b/drivers/gpu/drm/amd/powerplay/hwmgr/smu10_hwmgr.c
index 68e78256..2152cf4 100644
--- a/drivers/gpu/drm/amd/powerplay/hwmgr/smu10_hwmgr.c
+++ b/drivers/gpu/drm/amd/powerplay/hwmgr/smu10_hwmgr.c
@@ -404,7 +404,7 @@ static int smu10_populate_clock_table(struct pp_hwmgr *hwmgr)
                         "Attempt to copy clock table from smc failed",
                         return result);

-       if (0 == result && table->DcefClocks[0].Freq != 0) {
+       if (table->DcefClocks[0].Freq != 0) {
                 smu10_get_clock_voltage_dependency_table(hwmgr, &pinfo->vdd_dep_on_dcefclk,
                                                 NUM_DCEFCLK_DPM_LEVELS,
                                                 &smu10_data->clock_table.DcefClocks[0]);
@@ -775,6 +775,51 @@ static int smu10_get_dal_power_level(struct pp_hwmgr *hwmgr,
 static int smu10_force_clock_level(struct pp_hwmgr *hwmgr,
                 enum pp_clock_type type, uint32_t mask)
 {
+       struct smu10_hwmgr *data = hwmgr->backend;
+       struct smu10_voltage_dependency_table *mclk_table =
+                                       data->clock_vol_info.vdd_dep_on_fclk;
+       uint32_t low, high;
+
+       low = mask ? (ffs(mask) - 1) : 0;
+       high = mask ? (fls(mask) - 1) : 0;
+
+       switch (type) {
+       case PP_SCLK:
+               if (low > 2 || high > 2) {
+                       pr_info("Currently sclk only support 3 levels on RV\n");
+                       return -EINVAL;
+               }
+
+               smum_send_msg_to_smc_with_parameter(hwmgr,
+                                               PPSMC_MSG_SetHardMinGfxClk,
+                                               low == 2 ? data->gfx_max_freq_limit/100 :
+                                               low == 1 ? SMU10_UMD_PSTATE_GFXCLK :
+                                               data->gfx_min_freq_limit/100);
+
+               smum_send_msg_to_smc_with_parameter(hwmgr,
+                                               PPSMC_MSG_SetSoftMaxGfxClk,
+                                               high == 0 ? data->gfx_min_freq_limit/100 :
+                                               high == 1 ? SMU10_UMD_PSTATE_GFXCLK :
+                                               data->gfx_max_freq_limit/100);
+               break;
+
+       case PP_MCLK:
+               if (low > mclk_table->count - 1 || high > mclk_table->count - 1)
+                       return -EINVAL;
+
+               smum_send_msg_to_smc_with_parameter(hwmgr,
+                                               PPSMC_MSG_SetHardMinFclkByFreq,
+                                               mclk_table->entries[low].clk/100);
+
+               smum_send_msg_to_smc_with_parameter(hwmgr,
+                                               PPSMC_MSG_SetSoftMaxFclkByFreq,
+                                               mclk_table->entries[high].clk/100);
+               break;
+
+       case PP_PCIE:
+       default:
+               break;
+       }
         return 0;
 }

--
1.9.1

_______________________________________________
amd-gfx mailing list
amd-gfx at lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/amd-gfx/attachments/20180508/904df1cf/attachment-0001.html>


More information about the amd-gfx mailing list