<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="Generator" content="Microsoft Exchange Server">
<!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; padding-left: 4pt; border-left: #800000 2px solid; } --></style>
</head>
<body>
<div>
<div>
<div>
<div style="direction:ltr">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.</div>
<div style="direction:ltr">2. can you help me to understand why the change in apply_clock_rules is needed?</div>
</div>
<div><br>
</div>
<div class="x_ms-outlook-ios-signature"></div>
</div>
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="x_divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>发件人:</b> amd-gfx <amd-gfx-bounces@lists.freedesktop.org> 代表 Chengming Gui <Jack.Gui@amd.com><br>
<b>发送时间:</b> Thursday, July 18, 2019 6:02:17 PM<br>
<b>收件人:</b> amd-gfx@lists.freedesktop.org <amd-gfx@lists.freedesktop.org><br>
<b>抄送:</b> Gui, Jack <Jack.Gui@amd.com><br>
<b>主题:</b> [PATCH 2/3] drm/amd/powerplay: force sclk limit for peak profile</font>
<div> </div>
</div>
</div>
<font size="2"><span style="font-size:11pt;">
<div class="PlainText">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 <Jack.Gui@amd.com><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>
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>
</body>
</html>