<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=us-ascii">
<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: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;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:12.0pt;
font-family:"Times New Roman",serif;}
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.MsoPlainText, li.MsoPlainText, div.MsoPlainText
{mso-style-priority:99;
mso-style-link:"Plain Text Char";
margin:0in;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri",sans-serif;}
p
{mso-style-priority:99;
margin:0in;
margin-bottom:.0001pt;
font-size:12.0pt;
font-family:"Times New Roman",serif;}
span.EmailStyle18
{mso-style-type:personal-reply;
font-family:"Calibri",sans-serif;
color:#1F497D;}
span.PlainTextChar
{mso-style-name:"Plain Text Char";
mso-style-priority:99;
mso-style-link:"Plain Text";
font-family:"Calibri",sans-serif;}
.MsoChpDefault
{mso-style-type:export-only;
font-size:10.0pt;}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.25in 1.0in 1.25in;}
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="MsoPlainText">Reviewed-by: Kenneth Feng <<a href="mailto:kenneth.feng@amd.com">kenneth.feng@amd.com</a>><o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"><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"> Wang, Kevin(Yang)
<br>
<b>Sent:</b> Tuesday, July 23, 2019 5:36 PM<br>
<b>To:</b> amd-gfx@lists.freedesktop.org; Feng, Kenneth <Kenneth.Feng@amd.com><br>
<b>Cc:</b> Huang, Ray <Ray.Huang@amd.com><br>
<b>Subject:</b> Re: [PATCH] drm/amd/powerplay: add callback function of get_thermal_temperature_range<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div id="divtagdefaultwrapper">
<p><span style="font-family:"Calibri",sans-serif;color:black"><a href="mailto:Kenneth.Feng@amd.com">@Feng, Kenneth</a><o:p></o:p></span></p>
<p><span style="font-family:"Calibri",sans-serif;color:black"><o:p> </o:p></span></p>
<p><span style="font-family:"Calibri",sans-serif;color:black">please help me review this patch, this patch is reveiwed before.<o:p></o:p></span></p>
<p><span style="font-family:"Calibri",sans-serif;color:black">but this patch is missed from navi10 topic branch.<o:p></o:p></span></p>
<p><span style="font-family:"Calibri",sans-serif;color:black"><o:p> </o:p></span></p>
<p><span style="font-family:"Calibri",sans-serif;color:black">Best Regards,<br>
Kevin<o:p></o:p></span></p>
</div>
<div class="MsoNormal" align="center" style="text-align:center">
<hr size="2" width="98%" align="center">
</div>
<div id="divRplyFwdMsg">
<p class="MsoNormal"><b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:black">From:</span></b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:black"> Wang, Kevin(Yang) <<a href="mailto:Kevin1.Wang@amd.com">Kevin1.Wang@amd.com</a>><br>
<b>Sent:</b> Tuesday, July 23, 2019 5:31:47 PM<br>
<b>To:</b> <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>
<b>Cc:</b> Feng, Kenneth <<a href="mailto:Kenneth.Feng@amd.com">Kenneth.Feng@amd.com</a>>; Huang, Ray <<a href="mailto:Ray.Huang@amd.com">Ray.Huang@amd.com</a>>; Wang, Kevin(Yang) <<a href="mailto:Kevin1.Wang@amd.com">Kevin1.Wang@amd.com</a>>; Feng, Kenneth
<<a href="mailto:Kenneth.Feng@amd.com">Kenneth.Feng@amd.com</a>><br>
<b>Subject:</b> [PATCH] drm/amd/powerplay: add callback function of get_thermal_temperature_range</span>
<o:p></o:p></p>
<div>
<p class="MsoNormal"> <o:p></o:p></p>
</div>
</div>
<div>
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt"><span style="font-size:11.0pt">1. the thermal temperature is asic related data, move the code logic to<br>
xxx_ppt.c.<br>
2. replace data structure PP_TemperatureRange with<br>
smu_temperature_range.<br>
3. change temperature uint from temp*1000 to temp (temperature uint).<br>
<br>
Signed-off-by: Kevin Wang <<a href="mailto:kevin1.wang@amd.com">kevin1.wang@amd.com</a>><br>
Signed-off-by: Kenneth Feng <<a href="mailto:kenneth.feng@amd.com">kenneth.feng@amd.com</a>><br>
Acked-by: Huang Rui <<a href="mailto:ray.huang@amd.com">ray.huang@amd.com</a>><br>
---<br>
.../gpu/drm/amd/powerplay/inc/amdgpu_smu.h | 1 -<br>
drivers/gpu/drm/amd/powerplay/navi10_ppt.c | 17 ++++++++++<br>
drivers/gpu/drm/amd/powerplay/smu_v11_0.c | 18 ++++++----<br>
drivers/gpu/drm/amd/powerplay/vega20_ppt.c | 34 ++++++-------------<br>
4 files changed, 40 insertions(+), 30 deletions(-)<br>
<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 34093ddca105..7105f8041088 100644<br>
--- a/drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h<br>
+++ b/drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h<br>
@@ -439,7 +439,6 @@ struct smu_table_context<br>
struct smu_table *tables;<br>
uint32_t table_count;<br>
struct smu_table memory_pool;<br>
- uint16_t software_shutdown_temp;<br>
uint8_t thermal_controller_type;<br>
uint16_t TDPODLimit;<br>
<br>
diff --git a/drivers/gpu/drm/amd/powerplay/navi10_ppt.c b/drivers/gpu/drm/amd/powerplay/navi10_ppt.c<br>
index 46e2913e4af4..a4c4d4997189 100644<br>
--- a/drivers/gpu/drm/amd/powerplay/navi10_ppt.c<br>
+++ b/drivers/gpu/drm/amd/powerplay/navi10_ppt.c<br>
@@ -1638,6 +1638,22 @@ static int navi10_set_performance_level(struct smu_context *smu, enum amd_dpm_fo<br>
return ret;<br>
}<br>
<br>
+static int navi10_get_thermal_temperature_range(struct smu_context *smu,<br>
+ struct smu_temperature_range *range)<br>
+{<br>
+ struct smu_table_context *table_context = &smu->smu_table;<br>
+ struct smu_11_0_powerplay_table *powerplay_table = table_context->power_play_table;<br>
+<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>
+<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>
@@ -1674,6 +1690,7 @@ static const struct pptable_funcs navi10_ppt_funcs = {<br>
.get_ppfeature_status = navi10_get_ppfeature_status,<br>
.set_ppfeature_status = navi10_set_ppfeature_status,<br>
.set_performance_level = navi10_set_performance_level,<br>
+ .get_thermal_temperature_range = navi10_get_thermal_temperature_range,<br>
};<br>
<br>
void navi10_set_ppt_funcs(struct smu_context *smu)<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 76bc157525d0..4ad9e0c5a637 100644<br>
--- a/drivers/gpu/drm/amd/powerplay/smu_v11_0.c<br>
+++ b/drivers/gpu/drm/amd/powerplay/smu_v11_0.c<br>
@@ -1147,10 +1147,8 @@ static int smu_v11_0_set_thermal_range(struct smu_context *smu,<br>
struct smu_temperature_range *range)<br>
{<br>
struct amdgpu_device *adev = smu->adev;<br>
- int low = SMU_THERMAL_MINIMUM_ALERT_TEMP *<br>
- SMU_TEMPERATURE_UNITS_PER_CENTIGRADES;<br>
- int high = SMU_THERMAL_MAXIMUM_ALERT_TEMP *<br>
- SMU_TEMPERATURE_UNITS_PER_CENTIGRADES;<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>
@@ -1161,6 +1159,9 @@ static int smu_v11_0_set_thermal_range(struct smu_context *smu,<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>
+<br>
if (low > high)<br>
return -EINVAL;<br>
<br>
@@ -1169,8 +1170,8 @@ static int smu_v11_0_set_thermal_range(struct smu_context *smu,<br>
val = REG_SET_FIELD(val, THM_THERMAL_INT_CTRL, THERM_IH_HW_ENA, 1);<br>
val = REG_SET_FIELD(val, THM_THERMAL_INT_CTRL, THERM_INTH_MASK, 0);<br>
val = REG_SET_FIELD(val, THM_THERMAL_INT_CTRL, THERM_INTL_MASK, 0);<br>
- val = REG_SET_FIELD(val, THM_THERMAL_INT_CTRL, DIG_THERM_INTH, (high / SMU_TEMPERATURE_UNITS_PER_CENTIGRADES));<br>
- val = REG_SET_FIELD(val, THM_THERMAL_INT_CTRL, DIG_THERM_INTL, (low / SMU_TEMPERATURE_UNITS_PER_CENTIGRADES));<br>
+ val = REG_SET_FIELD(val, THM_THERMAL_INT_CTRL, DIG_THERM_INTH, (high & 0xff));<br>
+ val = REG_SET_FIELD(val, THM_THERMAL_INT_CTRL, DIG_THERM_INTL, (low & 0xff));<br>
val = val & (~THM_THERMAL_INT_CTRL__THERM_TRIGGER_MASK_MASK);<br>
<br>
WREG32_SOC15(THM, 0, mmTHM_THERMAL_INT_CTRL, val);<br>
@@ -1209,7 +1210,10 @@ static int smu_v11_0_start_thermal_control(struct smu_context *smu)<br>
<br>
if (!smu->pm_enabled)<br>
return ret;<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>
@@ -1234,6 +1238,8 @@ static int smu_v11_0_start_thermal_control(struct smu_context *smu)<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>
+ 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>
<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 bcd0efaf7bbd..deb102ffedc2 100644<br>
--- a/drivers/gpu/drm/amd/powerplay/vega20_ppt.c<br>
+++ b/drivers/gpu/drm/amd/powerplay/vega20_ppt.c<br>
@@ -463,7 +463,6 @@ static int vega20_store_powerplay_table(struct smu_context *smu)<br>
memcpy(table_context->driver_pptable, &powerplay_table->smcPPTable,<br>
sizeof(PPTable_t));<br>
<br>
- table_context->software_shutdown_temp = powerplay_table->usSoftwareShutdownTemp;<br>
table_context->thermal_controller_type = powerplay_table->ucThermalControllerType;<br>
table_context->TDPODLimit = le32_to_cpu(powerplay_table->OverDrive8Table.ODSettingsMax[ATOM_VEGA20_ODSETTING_POWERPERCENTAGE]);<br>
<br>
@@ -3235,35 +3234,24 @@ static int vega20_set_watermarks_table(struct smu_context *smu,<br>
return 0;<br>
}<br>
<br>
-static const struct smu_temperature_range vega20_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 vega20_get_thermal_temperature_range(struct smu_context *smu,<br>
struct smu_temperature_range*range)<br>
{<br>
-<br>
+ struct smu_table_context *table_context = &smu->smu_table;<br>
+ ATOM_Vega20_POWERPLAYTABLE *powerplay_table = table_context->power_play_table;<br>
PPTable_t *pptable = smu->smu_table.driver_pptable;<br>
<br>
- if (!range)<br>
+ if (!range || !powerplay_table)<br>
return -EINVAL;<br>
<br>
- memcpy(range, &vega20_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>
- 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>
+ /* 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>
<br>
<br>
return 0;<br>
-- <br>
2.22.0<o:p></o:p></span></p>
</div>
</div>
</div>
</body>
</html>