<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<!--[if !mso]><style>v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style><![endif]--><style><!--
/* Font Definitions */
@font-face
        {font-family:SimSun;
        panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:DengXian;
        panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:"\@SimSun";
        panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
        {font-family:"\@DengXian";
        panose-1:2 1 6 0 3 1 1 1 1 1;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:SimSun;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p.msonormal0, li.msonormal0, div.msonormal0
        {mso-style-name:msonormal;
        mso-margin-top-alt:auto;
        margin-right:0in;
        mso-margin-bottom-alt:auto;
        margin-left:0in;
        font-size:12.0pt;
        font-family:SimSun;}
p.emailquote, li.emailquote, div.emailquote
        {mso-style-name:emailquote;
        mso-margin-top-alt:auto;
        margin-right:0in;
        mso-margin-bottom-alt:auto;
        margin-left:1.0pt;
        border:none;
        padding:0in;
        font-size:12.0pt;
        font-family:SimSun;}
span.EmailStyle20
        {mso-style-type:personal-reply;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">Hi Evan,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">1, The hack hard code was just served for profile_peak mode and (max_count - 1) level always used for GFX clock, we just force the limit value with data from tool team.
<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">2, The requirement from tool team is to force GFX clock limit value with different SKU’s clocks when enter profile peak mode, so the hack code was added when  clock adjust
 rules was applied. <o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif"><o:p> </o:p></span></p>
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">From:</span></b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif"> Quan, Evan <Evan.Quan@amd.com>
<br>
<b>Sent:</b> Thursday, July 18, 2019 6:32 PM<br>
<b>To:</b> Gui, Jack <Jack.Gui@amd.com>; amd-gfx@lists.freedesktop.org<br>
<b>Cc:</b> Gui, Jack <Jack.Gui@amd.com><br>
<b>Subject:</b> Re: [PATCH 2/3] drm/amd/powerplay: force sclk limit for peak profile<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div>
<div>
<div>
<p class="MsoNormal">1. In navi10_force_clk_levels, i think you need to compare the max level user requested with the peak limit and set the smaller one.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">2. can you help me to understand why the change in apply_clock_rules is needed?<o:p></o:p></p>
</div>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</div>
<div class="MsoNormal" align="center" style="text-align:center">
<hr size="2" width="98%" align="center">
</div>
<div id="x_divRplyFwdMsg">
<p class="MsoNormal"><b><span lang="ZH-CN" style="font-size:11.0pt;color:black">发件人</span></b><b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:black">:</span></b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:black">
 amd-gfx <<a href="mailto:amd-gfx-bounces@lists.freedesktop.org">amd-gfx-bounces@lists.freedesktop.org</a>>
</span><span lang="ZH-CN" style="font-size:11.0pt;color:black">代表</span><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:black"> Chengming Gui <<a href="mailto:Jack.Gui@amd.com">Jack.Gui@amd.com</a>><br>
</span><b><span lang="ZH-CN" style="font-size:11.0pt;color:black">发送时间</span></b><b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:black">:</span></b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:black"> Thursday,
 July 18, 2019 6:02:17 PM<br>
</span><b><span lang="ZH-CN" style="font-size:11.0pt;color:black">收件人</span></b><b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:black">:</span></b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:black">
<a href="mailto:amd-gfx@lists.freedesktop.org">amd-gfx@lists.freedesktop.org</a> <<a href="mailto:amd-gfx@lists.freedesktop.org">amd-gfx@lists.freedesktop.org</a>><br>
</span><b><span lang="ZH-CN" style="font-size:11.0pt;color:black">抄送</span></b><b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:black">:</span></b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:black"> Gui, Jack
 <<a href="mailto:Jack.Gui@amd.com">Jack.Gui@amd.com</a>><br>
</span><b><span lang="ZH-CN" style="font-size:11.0pt;color:black">主题</span></b><b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:black">:</span></b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:black"> [PATCH 2/3]
 drm/amd/powerplay: force sclk limit for peak profile</span> <o:p></o:p></p>
<div>
<p class="MsoNormal"> <o:p></o:p></p>
</div>
</div>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt">force different GFX clocks with different SKUs for navi10:<br>
XL  (other rev_id):  1625MHz<br>
XT         (F1/C1):  1755MHz<br>
XTX        (F0/C0):  1830MHz<br>
<br>
Signed-off-by: Chengming Gui <<a href="mailto:Jack.Gui@amd.com">Jack.Gui@amd.com</a>><br>
---<br>
 drivers/gpu/drm/amd/powerplay/amdgpu_smu.c     |  2 +<br>
 drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h |  2 +<br>
 drivers/gpu/drm/amd/powerplay/navi10_ppt.c     | 66 +++++++++++++++++++++++++-<br>
 3 files changed, 68 insertions(+), 2 deletions(-)<br>
<br>
diff --git a/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c b/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c<br>
index 122985c..693414f 100644<br>
--- a/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c<br>
+++ b/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c<br>
@@ -664,6 +664,8 @@ static int smu_sw_init(void *handle)<br>
         smu->watermarks_bitmap = 0;<br>
         smu->power_profile_mode = PP_SMC_POWER_PROFILE_BOOTUP_DEFAULT;<br>
         smu->default_power_profile_mode = PP_SMC_POWER_PROFILE_BOOTUP_DEFAULT;<br>
+       smu->smu_dpm.default_sclk_limit = 0;<br>
+       smu->smu_dpm.peak_sclk_limit = 0;<br>
 <br>
         smu->workload_mask = 1 << smu->workload_prority[PP_SMC_POWER_PROFILE_BOOTUP_DEFAULT];<br>
         smu->workload_prority[PP_SMC_POWER_PROFILE_BOOTUP_DEFAULT] = 0;<br>
diff --git a/drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h b/drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h<br>
index 135a323..acb522b 100644<br>
--- a/drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h<br>
+++ b/drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h<br>
@@ -441,6 +441,8 @@ struct smu_dpm_context {<br>
         void *dpm_context;<br>
         void *golden_dpm_context;<br>
         bool enable_umd_pstate;<br>
+       uint32_t default_sclk_limit;<br>
+       uint32_t peak_sclk_limit;<br>
         enum amd_dpm_forced_level dpm_level;<br>
         enum amd_dpm_forced_level saved_dpm_level;<br>
         enum amd_dpm_forced_level requested_dpm_level;<br>
diff --git a/drivers/gpu/drm/amd/powerplay/navi10_ppt.c b/drivers/gpu/drm/amd/powerplay/navi10_ppt.c<br>
index 895a4e5..b4deb9e 100644<br>
--- a/drivers/gpu/drm/amd/powerplay/navi10_ppt.c<br>
+++ b/drivers/gpu/drm/amd/powerplay/navi10_ppt.c<br>
@@ -37,6 +37,15 @@<br>
 <br>
 #include "asic_reg/mp/mp_11_0_sh_mask.h"<br>
 <br>
+#define NV_NV10_F0 0xF0<br>
+#define NV_NV10_C0 0xC0<br>
+#define NV_NV10_F1 0xF1<br>
+#define NV_NV10_C1 0xC1<br>
+<br>
+#define NV_NV10_PEAK_SCLK_XTX 1830<br>
+#define NV_NV10_PEAK_SCLK_XT  1755<br>
+#define NV_NV10_PEAK_SCLK_XL  1625<br>
+<br>
 #define FEATURE_MASK(feature) (1ULL << feature)<br>
 #define SMC_DPM_FEATURE ( \<br>
         FEATURE_MASK(FEATURE_DPM_PREFETCHER_BIT) | \<br>
@@ -675,6 +684,7 @@ static int navi10_force_clk_levels(struct smu_context *smu,<br>
 <br>
         int ret = 0, size = 0;<br>
         uint32_t soft_min_level = 0, soft_max_level = 0, min_freq = 0, max_freq = 0;<br>
+       struct smu_dpm_context *smu_dpm_ctx = &(smu->smu_dpm);<br>
 <br>
         soft_min_level = mask ? (ffs(mask) - 1) : 0;<br>
         soft_max_level = mask ? (fls(mask) - 1) : 0;<br>
@@ -682,6 +692,23 @@ static int navi10_force_clk_levels(struct smu_context *smu,<br>
         switch (clk_type) {<br>
         case SMU_GFXCLK:<br>
         case SMU_SCLK:<br>
+               if (smu_dpm_ctx->peak_sclk_limit) {<br>
+                       max_freq = smu_dpm_ctx->peak_sclk_limit;<br>
+                       ret = smu_get_dpm_freq_by_index(smu, clk_type, soft_min_level, &min_freq);<br>
+                       if (ret)<br>
+                               return size;<br>
+               } else {<br>
+                       ret = smu_get_dpm_freq_by_index(smu, clk_type, soft_min_level, &min_freq);<br>
+                       if (ret)<br>
+                               return size;<br>
+                       ret = smu_get_dpm_freq_by_index(smu, clk_type, soft_max_level, &max_freq);<br>
+                       if (ret)<br>
+                               return size;<br>
+               }<br>
+               ret = smu_set_soft_freq_range(smu, clk_type, min_freq, max_freq);<br>
+               if (ret)<br>
+                       return size;<br>
+               break;<br>
         case SMU_SOCCLK:<br>
         case SMU_MCLK:<br>
         case SMU_UCLK:<br>
@@ -690,11 +717,9 @@ static int navi10_force_clk_levels(struct smu_context *smu,<br>
                 ret = smu_get_dpm_freq_by_index(smu, clk_type, soft_min_level, &min_freq);<br>
                 if (ret)<br>
                         return size;<br>
-<br>
                 ret = smu_get_dpm_freq_by_index(smu, clk_type, soft_max_level, &max_freq);<br>
                 if (ret)<br>
                         return size;<br>
-<br>
                 ret = smu_set_soft_freq_range(smu, clk_type, min_freq, max_freq);<br>
                 if (ret)<br>
                         return size;<br>
@@ -838,6 +863,7 @@ static int navi10_unforce_dpm_levels(struct smu_context *smu)<br>
         int ret = 0, i = 0;<br>
         uint32_t min_freq, max_freq;<br>
         enum smu_clk_type clk_type;<br>
+       struct smu_dpm_context *smu_dpm_ctx = &(smu->smu_dpm);<br>
 <br>
         enum smu_clk_type clks[] = {<br>
                 SMU_GFXCLK,<br>
@@ -851,10 +877,18 @@ static int navi10_unforce_dpm_levels(struct smu_context *smu)<br>
                 if (ret)<br>
                         return ret;<br>
 <br>
+               if (clk_type == SMU_GFXCLK && smu_dpm_ctx->default_sclk_limit != 0) {<br>
+                       max_freq = smu_dpm_ctx->default_sclk_limit;<br>
+                       ret = smu_get_dpm_freq_range(smu, SMU_GFXCLK,<br>
+                                                    &min_freq, NULL);<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>
+       smu_dpm_ctx->peak_sclk_limit = 0;<br>
 <br>
         return ret;<br>
 }<br>
@@ -1531,6 +1565,33 @@ static int navi10_set_ppfeature_status(struct smu_context *smu,<br>
         return 0;<br>
 }<br>
 <br>
+static int navi10_apply_clocks_adjust_rules(struct smu_context *smu)<br>
+{<br>
+       int ret = 0;<br>
+       struct smu_dpm_context *smu_dpm_ctx = &(smu->smu_dpm);<br>
+       struct amdgpu_device *adev = smu->adev;<br>
+<br>
+       if (smu_dpm_ctx->default_sclk_limit == 0) {<br>
+               ret = smu_get_dpm_freq_range(smu, SMU_SCLK, NULL,<br>
+                                            &smu_dpm_ctx->default_sclk_limit);<br>
+               return ret;<br>
+       }<br>
+<br>
+       if (smu_dpm_ctx->dpm_level == AMD_DPM_FORCED_LEVEL_PROFILE_PEAK &&<br>
+           smu_dpm_ctx->dpm_level != smu_dpm_ctx->saved_dpm_level) {<br>
+               if (adev->rev_id == NV_NV10_F0 || adev->rev_id == NV_NV10_C0)<br>
+                       smu_dpm_ctx->peak_sclk_limit = NV_NV10_PEAK_SCLK_XTX;<br>
+               else if (adev->rev_id == NV_NV10_F1 || adev->rev_id == NV_NV10_C1)<br>
+                       smu_dpm_ctx->peak_sclk_limit = NV_NV10_PEAK_SCLK_XT;<br>
+               else<br>
+                       smu_dpm_ctx->peak_sclk_limit = NV_NV10_PEAK_SCLK_XL;<br>
+       } else if (smu_dpm_ctx->dpm_level != AMD_DPM_FORCED_LEVEL_PROFILE_PEAK && smu_dpm_ctx->peak_sclk_limit != 0) {<br>
+               smu_dpm_ctx->peak_sclk_limit = 0;<br>
+       }<br>
+<br>
+       return 0;<br>
+}<br>
+<br>
 static const struct pptable_funcs navi10_ppt_funcs = {<br>
         .tables_init = navi10_tables_init,<br>
         .alloc_dpm_context = navi10_allocate_dpm_context,<br>
@@ -1566,6 +1627,7 @@ static const struct pptable_funcs navi10_ppt_funcs = {<br>
         .get_uclk_dpm_states = navi10_get_uclk_dpm_states,<br>
         .get_ppfeature_status = navi10_get_ppfeature_status,<br>
         .set_ppfeature_status = navi10_set_ppfeature_status,<br>
+       .apply_clocks_adjust_rules = navi10_apply_clocks_adjust_rules,<br>
 };<br>
 <br>
 void navi10_set_ppt_funcs(struct smu_context *smu)<br>
-- <br>
2.7.4<br>
<br>
_______________________________________________<br>
amd-gfx mailing list<br>
<a href="mailto:amd-gfx@lists.freedesktop.org">amd-gfx@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/amd-gfx">https://lists.freedesktop.org/mailman/listinfo/amd-gfx</a><o:p></o:p></span></p>
</div>
</div>
</body>
</html>