<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Hi Evan,</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
the temperature min value should be 0, not -273 on smu11.</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
you can refrence window driver code or register spec.</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<i><span>        output_ptr->operating_temperature_min_Limit = 0;                                                                                                                                      
<br>
</span><span>        output_ptr->operating_temperature_max_Limit = ppt_info->software_shutdown_temp;</span></i><br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
and in smu11, the thermal control has a 8bit register to set min and max value, and th<span>e unit is temperature.</span></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span>so there is something wrong with this patch.</span></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span></span>
<div><br>
</div>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Best Regards,<br>
Kevin</div>
<div id="appendonsend"></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>From:</b> amd-gfx <amd-gfx-bounces@lists.freedesktop.org> on behalf of Evan Quan <evan.quan@amd.com><br>
<b>Sent:</b> Friday, August 16, 2019 5:31 PM<br>
<b>To:</b> amd-gfx@lists.freedesktop.org <amd-gfx@lists.freedesktop.org><br>
<b>Cc:</b> Quan, Evan <Evan.Quan@amd.com><br>
<b>Subject:</b> [PATCH] drm/amd/powerplay: correct SW smu11 thermal range settings</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt;">
<div class="PlainText">Problems with current settings:<br>
1. The min value was overrided to 0 on Vega20 & Navi10. While<br>
   the expected should be -273.15 C.<br>
2. The thermal min/max threshold was output in wrong unit on<br>
   Navi10 & Arcturus. As TEMP_RANGE_MIN/MAX is already in<br>
   millicelsius. And "*1000" in smu_v11_0_start_thermal_control<br>
   makes the output wrongly.<br>
<br>
Change-Id: I2f1866edd1baf264f521310343f492eaede26c33<br>
Signed-off-by: Evan Quan <evan.quan@amd.com><br>
---<br>
 drivers/gpu/drm/amd/powerplay/arcturus_ppt.c  | 10 ----<br>
 drivers/gpu/drm/amd/powerplay/inc/smu_v11_0.h |  6 +++<br>
 drivers/gpu/drm/amd/powerplay/navi10_ppt.c    |  5 +-<br>
 drivers/gpu/drm/amd/powerplay/smu_v11_0.c     | 51 +++++++------------<br>
 drivers/gpu/drm/amd/powerplay/vega20_ppt.c    | 20 +++++---<br>
 5 files changed, 38 insertions(+), 54 deletions(-)<br>
<br>
diff --git a/drivers/gpu/drm/amd/powerplay/arcturus_ppt.c b/drivers/gpu/drm/amd/powerplay/arcturus_ppt.c<br>
index 4060607fbb35..1a1f64a9e1e0 100644<br>
--- a/drivers/gpu/drm/amd/powerplay/arcturus_ppt.c<br>
+++ b/drivers/gpu/drm/amd/powerplay/arcturus_ppt.c<br>
@@ -880,23 +880,14 @@ static int arcturus_force_clk_levels(struct smu_context *smu,<br>
         return ret;<br>
 }<br>
 <br>
-static const struct smu_temperature_range arcturus_thermal_policy[] =<br>
-{<br>
-       {-273150,  99000, 99000, -273150, 99000, 99000, -273150, 99000, 99000},<br>
-       { 120000, 120000, 120000, 120000, 120000, 120000, 120000, 120000, 120000},<br>
-};<br>
-<br>
 static int arcturus_get_thermal_temperature_range(struct smu_context *smu,<br>
                                                 struct smu_temperature_range *range)<br>
 {<br>
-<br>
         PPTable_t *pptable = smu->smu_table.driver_pptable;<br>
 <br>
         if (!range)<br>
                 return -EINVAL;<br>
 <br>
-       memcpy(range, &arcturus_thermal_policy[0], sizeof(struct smu_temperature_range));<br>
-<br>
         range->max = pptable->TedgeLimit *<br>
                 SMU_TEMPERATURE_UNITS_PER_CENTIGRADES;<br>
         range->edge_emergency_max = (pptable->TedgeLimit + CTF_OFFSET_EDGE) *<br>
@@ -910,7 +901,6 @@ static int arcturus_get_thermal_temperature_range(struct smu_context *smu,<br>
         range->mem_emergency_max = (pptable->TmemLimit + CTF_OFFSET_HBM)*<br>
                 SMU_TEMPERATURE_UNITS_PER_CENTIGRADES;<br>
 <br>
-<br>
         return 0;<br>
 }<br>
 <br>
diff --git a/drivers/gpu/drm/amd/powerplay/inc/smu_v11_0.h b/drivers/gpu/drm/amd/powerplay/inc/smu_v11_0.h<br>
index 0a22fa48ff5a..59b2045e37e4 100644<br>
--- a/drivers/gpu/drm/amd/powerplay/inc/smu_v11_0.h<br>
+++ b/drivers/gpu/drm/amd/powerplay/inc/smu_v11_0.h<br>
@@ -64,6 +64,12 @@<br>
 #define WORKLOAD_MAP(profile, workload) \<br>
         [profile] = {1, (workload)}<br>
 <br>
+static const struct smu_temperature_range smu11_thermal_policy[] =<br>
+{<br>
+       {-273150,  99000, 99000, -273150, 99000, 99000, -273150, 99000, 99000},<br>
+       { 120000, 120000, 120000, 120000, 120000, 120000, 120000, 120000, 120000},<br>
+};<br>
+<br>
 struct smu_11_0_cmn2aisc_mapping {<br>
         int     valid_mapping;<br>
         int     map_to;<br>
diff --git a/drivers/gpu/drm/amd/powerplay/navi10_ppt.c b/drivers/gpu/drm/amd/powerplay/navi10_ppt.c<br>
index d7d4186b762f..e804d18f61d0 100644<br>
--- a/drivers/gpu/drm/amd/powerplay/navi10_ppt.c<br>
+++ b/drivers/gpu/drm/amd/powerplay/navi10_ppt.c<br>
@@ -1505,9 +1505,8 @@ static int navi10_get_thermal_temperature_range(struct smu_context *smu,<br>
         if (!range || !powerplay_table)<br>
                 return -EINVAL;<br>
 <br>
-       /* The unit is temperature */<br>
-       range->min = 0;<br>
-       range->max = powerplay_table->software_shutdown_temp;<br>
+       range->max = powerplay_table->software_shutdown_temp *<br>
+               SMU_TEMPERATURE_UNITS_PER_CENTIGRADES;<br>
 <br>
         return 0;<br>
 }<br>
diff --git a/drivers/gpu/drm/amd/powerplay/smu_v11_0.c b/drivers/gpu/drm/amd/powerplay/smu_v11_0.c<br>
index df7b65360ac7..5f5fd3a88e48 100644<br>
--- a/drivers/gpu/drm/amd/powerplay/smu_v11_0.c<br>
+++ b/drivers/gpu/drm/amd/powerplay/smu_v11_0.c<br>
@@ -1125,23 +1125,17 @@ static int smu_v11_0_get_current_clk_freq(struct smu_context *smu,<br>
 }<br>
 <br>
 static int smu_v11_0_set_thermal_range(struct smu_context *smu,<br>
-                                      struct smu_temperature_range *range)<br>
+                                      struct smu_temperature_range range)<br>
 {<br>
         struct amdgpu_device *adev = smu->adev;<br>
         int low = SMU_THERMAL_MINIMUM_ALERT_TEMP;<br>
         int high = SMU_THERMAL_MAXIMUM_ALERT_TEMP;<br>
         uint32_t val;<br>
 <br>
-       if (!range)<br>
-               return -EINVAL;<br>
-<br>
-       if (low < range->min)<br>
-               low = range->min;<br>
-       if (high > range->max)<br>
-               high = range->max;<br>
-<br>
-       low = max(SMU_THERMAL_MINIMUM_ALERT_TEMP, range->min);<br>
-       high = min(SMU_THERMAL_MAXIMUM_ALERT_TEMP, range->max);<br>
+       low = max(SMU_THERMAL_MINIMUM_ALERT_TEMP,<br>
+                       range.min / SMU_TEMPERATURE_UNITS_PER_CENTIGRADES);<br>
+       high = min(SMU_THERMAL_MAXIMUM_ALERT_TEMP,<br>
+                       range.max / SMU_TEMPERATURE_UNITS_PER_CENTIGRADES);<br>
 <br>
         if (low > high)<br>
                 return -EINVAL;<br>
@@ -1177,27 +1171,20 @@ static int smu_v11_0_enable_thermal_alert(struct smu_context *smu)<br>
 static int smu_v11_0_start_thermal_control(struct smu_context *smu)<br>
 {<br>
         int ret = 0;<br>
-       struct smu_temperature_range range = {<br>
-               TEMP_RANGE_MIN,<br>
-               TEMP_RANGE_MAX,<br>
-               TEMP_RANGE_MAX,<br>
-               TEMP_RANGE_MIN,<br>
-               TEMP_RANGE_MAX,<br>
-               TEMP_RANGE_MAX,<br>
-               TEMP_RANGE_MIN,<br>
-               TEMP_RANGE_MAX,<br>
-               TEMP_RANGE_MAX};<br>
+       struct smu_temperature_range range;<br>
         struct amdgpu_device *adev = smu->adev;<br>
 <br>
         if (!smu->pm_enabled)<br>
                 return ret;<br>
 <br>
+       memcpy(&range, &smu11_thermal_policy[0], sizeof(struct smu_temperature_range));<br>
+<br>
         ret = smu_get_thermal_temperature_range(smu, &range);<br>
         if (ret)<br>
                 return ret;<br>
 <br>
         if (smu->smu_table.thermal_controller_type) {<br>
-               ret = smu_v11_0_set_thermal_range(smu, &range);<br>
+               ret = smu_v11_0_set_thermal_range(smu, range);<br>
                 if (ret)<br>
                         return ret;<br>
 <br>
@@ -1210,17 +1197,15 @@ static int smu_v11_0_start_thermal_control(struct smu_context *smu)<br>
                         return ret;<br>
         }<br>
 <br>
-       adev->pm.dpm.thermal.min_temp = range.min * SMU_TEMPERATURE_UNITS_PER_CENTIGRADES;<br>
-       adev->pm.dpm.thermal.max_temp = range.max * SMU_TEMPERATURE_UNITS_PER_CENTIGRADES;<br>
-       adev->pm.dpm.thermal.max_edge_emergency_temp = range.edge_emergency_max * SMU_TEMPERATURE_UNITS_PER_CENTIGRADES;<br>
-       adev->pm.dpm.thermal.min_hotspot_temp = range.hotspot_min * SMU_TEMPERATURE_UNITS_PER_CENTIGRADES;<br>
-       adev->pm.dpm.thermal.max_hotspot_crit_temp = range.hotspot_crit_max * SMU_TEMPERATURE_UNITS_PER_CENTIGRADES;<br>
-       adev->pm.dpm.thermal.max_hotspot_emergency_temp = range.hotspot_emergency_max * SMU_TEMPERATURE_UNITS_PER_CENTIGRADES;<br>
-       adev->pm.dpm.thermal.min_mem_temp = range.mem_min * SMU_TEMPERATURE_UNITS_PER_CENTIGRADES;<br>
-       adev->pm.dpm.thermal.max_mem_crit_temp = range.mem_crit_max * SMU_TEMPERATURE_UNITS_PER_CENTIGRADES;<br>
-       adev->pm.dpm.thermal.max_mem_emergency_temp = range.mem_emergency_max * SMU_TEMPERATURE_UNITS_PER_CENTIGRADES;<br>
-       adev->pm.dpm.thermal.min_temp = range.min * SMU_TEMPERATURE_UNITS_PER_CENTIGRADES;<br>
-       adev->pm.dpm.thermal.max_temp = range.max * SMU_TEMPERATURE_UNITS_PER_CENTIGRADES;<br>
+       adev->pm.dpm.thermal.min_temp = range.min;<br>
+       adev->pm.dpm.thermal.max_temp = range.max;<br>
+       adev->pm.dpm.thermal.max_edge_emergency_temp = range.edge_emergency_max;<br>
+       adev->pm.dpm.thermal.min_hotspot_temp = range.hotspot_min;<br>
+       adev->pm.dpm.thermal.max_hotspot_crit_temp = range.hotspot_crit_max;<br>
+       adev->pm.dpm.thermal.max_hotspot_emergency_temp = range.hotspot_emergency_max;<br>
+       adev->pm.dpm.thermal.min_mem_temp = range.mem_min;<br>
+       adev->pm.dpm.thermal.max_mem_crit_temp = range.mem_crit_max;<br>
+       adev->pm.dpm.thermal.max_mem_emergency_temp = range.mem_emergency_max;<br>
 <br>
         return ret;<br>
 }<br>
diff --git a/drivers/gpu/drm/amd/powerplay/vega20_ppt.c b/drivers/gpu/drm/amd/powerplay/vega20_ppt.c<br>
index acf075393c13..e14363182691 100644<br>
--- a/drivers/gpu/drm/amd/powerplay/vega20_ppt.c<br>
+++ b/drivers/gpu/drm/amd/powerplay/vega20_ppt.c<br>
@@ -3113,14 +3113,18 @@ static int vega20_get_thermal_temperature_range(struct smu_context *smu,<br>
         if (!range || !powerplay_table)<br>
                 return -EINVAL;<br>
 <br>
-       /* The unit is temperature */<br>
-       range->min = 0;<br>
-       range->max = powerplay_table->usSoftwareShutdownTemp;<br>
-       range->edge_emergency_max = (pptable->TedgeLimit + CTF_OFFSET_EDGE);<br>
-       range->hotspot_crit_max = pptable->ThotspotLimit;<br>
-       range->hotspot_emergency_max = (pptable->ThotspotLimit + CTF_OFFSET_HOTSPOT);<br>
-       range->mem_crit_max = pptable->ThbmLimit;<br>
-       range->mem_emergency_max = (pptable->ThbmLimit + CTF_OFFSET_HBM);<br>
+       range->max = powerplay_table->usSoftwareShutdownTemp *<br>
+               SMU_TEMPERATURE_UNITS_PER_CENTIGRADES;<br>
+       range->edge_emergency_max = (pptable->TedgeLimit + CTF_OFFSET_EDGE) *<br>
+               SMU_TEMPERATURE_UNITS_PER_CENTIGRADES;<br>
+       range->hotspot_crit_max = pptable->ThotspotLimit *<br>
+               SMU_TEMPERATURE_UNITS_PER_CENTIGRADES;<br>
+       range->hotspot_emergency_max = (pptable->ThotspotLimit + CTF_OFFSET_HOTSPOT) *<br>
+               SMU_TEMPERATURE_UNITS_PER_CENTIGRADES;<br>
+       range->mem_crit_max = pptable->ThbmLimit *<br>
+               SMU_TEMPERATURE_UNITS_PER_CENTIGRADES;<br>
+       range->mem_emergency_max = (pptable->ThbmLimit + CTF_OFFSET_HBM) *<br>
+               SMU_TEMPERATURE_UNITS_PER_CENTIGRADES;<br>
 <br>
 <br>
         return 0;<br>
-- <br>
2.22.0<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></div>
</body>
</html>