<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">
<p style="font-family:Arial;font-size:10pt;color:#0000FF;margin:5pt;" align="Left">
[AMD Official Use Only - General]<br>
</p>
<br>
<div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);" class="elementToProof">
Hi Shikai,</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);" class="elementToProof">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);" class="elementToProof">
Comments inline.</div>
<div id="appendonsend"></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
<br>
</div>
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size: 11pt; color: rgb(0, 0, 0);"><b>From:</b> Guo, Shikai <Shikai.Guo@amd.com><br>
<b>Sent:</b> Wednesday, June 7, 2023 7:07 PM<br>
<b>To:</b> amd-gfx@lists.freedesktop.org <amd-gfx@lists.freedesktop.org><br>
<b>Cc:</b> Liang, Prike <Prike.Liang@amd.com>; Liu, Aaron <Aaron.Liu@amd.com>; Huang, Tim <Tim.Huang@amd.com>; Guo, Shikai <Shikai.Guo@amd.com><br>
<b>Subject:</b> [PATCH] drm/amd/pm: enable more Pstates profile levels for yellow_carp</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt">
<div class="PlainText elementToProof">This patch enables following UMD stable Pstates profile levels for power_dpm_force_performance_level interface.<br>
<br>
- profile_peak<br>
- profile_min_mclk<br>
- profile_min_sclk<br>
- profile_standard<br>
<br>
Signed-off-by: shikaguo <shikai.guo@amd.com><br>
---<br>
.../drm/amd/pm/swsmu/smu13/yellow_carp_ppt.c | 94 ++++++++++++++++++-<br>
.../drm/amd/pm/swsmu/smu13/yellow_carp_ppt.h | 8 +-<br>
2 files changed, 98 insertions(+), 4 deletions(-)<br>
<br>
diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu13/yellow_carp_ppt.c b/drivers/gpu/drm/amd/pm/swsmu/smu13/yellow_carp_ppt.c<br>
index a92da336ecec..5c968ab2ea8d 100644<br>
--- a/drivers/gpu/drm/amd/pm/swsmu/smu13/yellow_carp_ppt.c<br>
+++ b/drivers/gpu/drm/amd/pm/swsmu/smu13/yellow_carp_ppt.c<br>
@@ -957,6 +957,9 @@ static int yellow_carp_set_soft_freq_limited_range(struct smu_context *smu,<br>
uint32_t max)<br>
{<br>
enum smu_message_type msg_set_min, msg_set_max;<br>
+ uint32_t min_clk = min;<br>
+ uint32_t max_clk = max;<br>
+<br>
int ret = 0;<br>
<br>
if (!yellow_carp_clk_dpm_is_enabled(smu, clk_type))<br>
@@ -985,11 +988,17 @@ static int yellow_carp_set_soft_freq_limited_range(struct smu_context *smu,<br>
return -EINVAL;<br>
}<br>
<br>
- ret = smu_cmn_send_smc_msg_with_param(smu, msg_set_min, min, NULL);<br>
+ if (clk_type == SMU_VCLK) {<br>
+ min_clk = min << SMU_13_VCLK_SHIFT;<br>
+ max_clk = max << SMU_13_VCLK_SHIFT;<br>
+ }<br>
+<br>
+ ret = smu_cmn_send_smc_msg_with_param(smu, msg_set_min, min_clk, NULL);<br>
+<br>
if (ret)<br>
goto out;<br>
<br>
- ret = smu_cmn_send_smc_msg_with_param(smu, msg_set_max, max, NULL);<br>
+ ret = smu_cmn_send_smc_msg_with_param(smu, msg_set_max, max_clk, NULL);<br>
if (ret)<br>
goto out;<br>
<br>
@@ -1107,6 +1116,50 @@ static int yellow_carp_force_clk_levels(struct smu_context *smu,<br>
return ret;<br>
}<br>
<br>
+static int yellow_carp_get_dpm_profile_freq(struct smu_context *smu,<br>
+ enum amd_dpm_forced_level level,<br>
+ enum smu_clk_type clk_type,<br>
+ uint32_t *min_clk,<br>
+ uint32_t *max_clk)<br>
+{<br>
+ int ret = 0;<br>
+ uint32_t clk_limit = 0;<br>
+<br>
+ switch (clk_type) {<br>
+ case SMU_GFXCLK:<br>
+ case SMU_SCLK:<br>
+ clk_limit = YELLOW_CARP_UMD_PSTATE_GFXCLK;<br>
+ if (level == AMD_DPM_FORCED_LEVEL_PROFILE_PEAK)<br>
+ yellow_carp_get_dpm_ultimate_freq(smu, SMU_SCLK, NULL, &clk_limit);<br>
+ else if (level == AMD_DPM_FORCED_LEVEL_PROFILE_MIN_SCLK)<br>
+ yellow_carp_get_dpm_ultimate_freq(smu, SMU_SCLK, &clk_limit, NULL);<br>
+ break;<br>
+ case SMU_SOCCLK:<br>
+ clk_limit = YELLOW_CARP_UMD_PSTATE_SOCCLK;<br>
+ if (level == AMD_DPM_FORCED_LEVEL_PROFILE_PEAK)<br>
+ yellow_carp_get_dpm_ultimate_freq(smu, SMU_SOCCLK, NULL, &clk_limit);<br>
+ break;<br>
+ case SMU_FCLK:<br>
+ clk_limit = YELLOW_CARP_UMD_PSTATE_FCLK;<br>
+ if (level == AMD_DPM_FORCED_LEVEL_PROFILE_PEAK)<br>
+ yellow_carp_get_dpm_ultimate_freq(smu, SMU_FCLK, NULL, &clk_limit);<br>
+ else if (level == AMD_DPM_FORCED_LEVEL_PROFILE_MIN_MCLK)<br>
+ yellow_carp_get_dpm_ultimate_freq(smu, SMU_FCLK, &clk_limit, NULL);<br>
+ break;<br>
+ case SMU_VCLK:<br>
+ yellow_carp_get_dpm_ultimate_freq(smu, SMU_VCLK, NULL, &clk_limit);<br>
+ break;<br>
+ case SMU_DCLK:<br>
+ yellow_carp_get_dpm_ultimate_freq(smu, SMU_DCLK, NULL, &clk_limit);<br>
+ break;<br>
+ default:<br>
+ ret = -EINVAL;<br>
+ break;<br>
+ }<br>
+ *min_clk = *max_clk = clk_limit;<br>
+ return ret;<br>
+}<br>
+<br>
static int yellow_carp_set_performance_level(struct smu_context *smu,<br>
enum amd_dpm_forced_level level)<br>
{<br>
@@ -1114,6 +1167,9 @@ static int yellow_carp_set_performance_level(struct smu_context *smu,<br>
uint32_t sclk_min = 0, sclk_max = 0;<br>
uint32_t fclk_min = 0, fclk_max = 0;<br>
uint32_t socclk_min = 0, socclk_max = 0;<br>
+ uint32_t vclk_min = 0, vclk_max = 0;<br>
+ uint32_t dclk_min = 0, dclk_max = 0;<br>
+<br>
int ret = 0;<br>
<br>
switch (level) {<br>
@@ -1121,28 +1177,42 @@ static int yellow_carp_set_performance_level(struct smu_context *smu,<br>
yellow_carp_get_dpm_ultimate_freq(smu, SMU_SCLK, NULL, &sclk_max);<br>
yellow_carp_get_dpm_ultimate_freq(smu, SMU_FCLK, NULL, &fclk_max);<br>
yellow_carp_get_dpm_ultimate_freq(smu, SMU_SOCCLK, NULL, &socclk_max);<br>
+ yellow_carp_get_dpm_ultimate_freq(smu, SMU_VCLK, NULL, &vclk_max);<br>
+ yellow_carp_get_dpm_ultimate_freq(smu, SMU_DCLK, NULL, &dclk_max);<br>
sclk_min = sclk_max;<br>
fclk_min = fclk_max;<br>
socclk_min = socclk_max;<br>
+ vclk_min = vclk_max;<br>
+ dclk_min = dclk_max;<br>
break;<br>
case AMD_DPM_FORCED_LEVEL_LOW:<br>
yellow_carp_get_dpm_ultimate_freq(smu, SMU_SCLK, &sclk_min, NULL);<br>
yellow_carp_get_dpm_ultimate_freq(smu, SMU_FCLK, &fclk_min, NULL);<br>
yellow_carp_get_dpm_ultimate_freq(smu, SMU_SOCCLK, &socclk_min, NULL);<br>
+ yellow_carp_get_dpm_ultimate_freq(smu, SMU_VCLK, &vclk_min, NULL);<br>
+ yellow_carp_get_dpm_ultimate_freq(smu, SMU_DCLK, &dclk_min, NULL);<br>
sclk_max = sclk_min;<br>
fclk_max = fclk_min;<br>
socclk_max = socclk_min;<br>
+ vclk_max = vclk_min;<br>
+ dclk_max = dclk_min;<br>
break;<br>
case AMD_DPM_FORCED_LEVEL_AUTO:<br>
yellow_carp_get_dpm_ultimate_freq(smu, SMU_SCLK, &sclk_min, &sclk_max);<br>
yellow_carp_get_dpm_ultimate_freq(smu, SMU_FCLK, &fclk_min, &fclk_max);<br>
yellow_carp_get_dpm_ultimate_freq(smu, SMU_SOCCLK, &socclk_min, &socclk_max);<br>
+ yellow_carp_get_dpm_ultimate_freq(smu, SMU_VCLK, &vclk_min, &vclk_max);<br>
+ yellow_carp_get_dpm_ultimate_freq(smu, SMU_DCLK, &dclk_min, &dclk_max);<br>
break;<br>
case AMD_DPM_FORCED_LEVEL_PROFILE_STANDARD:<br>
case AMD_DPM_FORCED_LEVEL_PROFILE_MIN_SCLK:<br>
case AMD_DPM_FORCED_LEVEL_PROFILE_MIN_MCLK:<br>
case AMD_DPM_FORCED_LEVEL_PROFILE_PEAK:<br>
- /* Temporarily do nothing since the optimal clocks haven't been provided yet */<br>
+ yellow_carp_get_dpm_profile_freq(smu, level, SMU_SCLK, &sclk_min, &sclk_max);<br>
+ yellow_carp_get_dpm_profile_freq(smu, level, SMU_FCLK, &fclk_min, &fclk_max);<br>
+ yellow_carp_get_dpm_profile_freq(smu, level, SMU_SOCCLK, &socclk_min, &socclk_max);<br>
+ yellow_carp_get_dpm_profile_freq(smu, level, SMU_VCLK, &vclk_min, &vclk_max);<br>
+ yellow_carp_get_dpm_profile_freq(smu, level, SMU_DCLK, &dclk_min, &dclk_max);<br>
break;<br>
case AMD_DPM_FORCED_LEVEL_MANUAL:<br>
case AMD_DPM_FORCED_LEVEL_PROFILE_EXIT:<br>
@@ -1182,6 +1252,24 @@ static int yellow_carp_set_performance_level(struct smu_context *smu,<br>
return ret;<br>
}<br>
<br>
+ if (vclk_min && vclk_max) {<br>
+ ret = yellow_carp_set_soft_freq_limited_range(smu,<br>
+ SMU_VCLK,<br>
+ vclk_min,<br>
+ vclk_max);<br>
+ if (ret)<br>
+ return ret;<br>
+ }<br>
+<br>
+ if (dclk_min && dclk_max) {<br>
+ ret = yellow_carp_set_soft_freq_limited_range(smu,<br>
+ SMU_DCLK,<br>
+ dclk_min,<br>
+ dclk_max);<br>
+ if (ret)<br>
+ return ret;<br>
+ }<br>
+<br>
return ret;<br>
}<br>
<br>
diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu13/yellow_carp_ppt.h b/drivers/gpu/drm/amd/pm/swsmu/smu13/yellow_carp_ppt.h<br>
index a9205a8ea3ad..59257bbd66e0 100644<br>
--- a/drivers/gpu/drm/amd/pm/swsmu/smu13/yellow_carp_ppt.h<br>
+++ b/drivers/gpu/drm/amd/pm/swsmu/smu13/yellow_carp_ppt.h<br>
@@ -24,6 +24,12 @@<br>
#define __YELLOW_CARP_PPT_H__<br>
<br>
extern void yellow_carp_set_ppt_funcs(struct smu_context *smu);<br>
-#define YELLOW_CARP_UMD_PSTATE_GFXCLK 1100<br>
+<br>
+#define SMU_13_VCLK_SHIFT 16</div>
<div class="PlainText elementToProof"><br>
</div>
<div class="PlainText elementToProof"><br>
</div>
<div class="PlainText elementToProof"><span style="font-family: "Segoe UI Web (West European)", "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", sans-serif; display: inline !important; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);" class="ContentPasted0 ContentPasted1">The
macro 'SMU_13_VCLK_SHIFT' can be shared by SMU13 APUs and is defined in smu_v13_0.h in the patch for SMU v13.0.4.</span><br>
</div>
<div class="PlainText elementToProof"><font face="Segoe UI Web (West European), Segoe UI, -apple-system, BlinkMacSystemFont, Roboto, Helvetica Neue, sans-serif" style="color: rgb(0, 0, 0);">So, it should not need this definition again. thanks. </font></div>
<div class="PlainText elementToProof"><font face="Segoe UI Web (West European), Segoe UI, -apple-system, BlinkMacSystemFont, Roboto, Helvetica Neue, sans-serif" style="color: rgb(0, 0, 0);"><br>
</font></div>
<div class="PlainText elementToProof"><font face="Segoe UI Web (West European), Segoe UI, -apple-system, BlinkMacSystemFont, Roboto, Helvetica Neue, sans-serif" style="color: rgb(0, 0, 0);">Tim</font></div>
<div class="PlainText elementToProof"><br>
+<br>
+//UMD PState Rembrandt Msg Parameters in MHz<br>
+#define YELLOW_CARP_UMD_PSTATE_GFXCLK 700<br>
+#define YELLOW_CARP_UMD_PSTATE_SOCCLK 678<br>
+#define YELLOW_CARP_UMD_PSTATE_FCLK 800<br>
<br>
#endif<br>
-- <br>
2.25.1<br>
<br>
</div>
</span></font></div>
</div>
</body>
</html>