<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 id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;font-family:Calibri,Helvetica,sans-serif;" dir="ltr">
<p style="margin-top:0;margin-bottom:0">sure, i know it, this patch is from navi10 topic branch. </p>
<p style="margin-top:0;margin-bottom:0">the final result don't change the temperature granularity.<span style="color: rgb(33, 33, 33); font-family: wf_segoe-ui_normal, "Segoe UI", "Segoe WP", Tahoma, Arial, sans-serif, serif, EmojiFont; font-size: 14.6667px;"></span></p>
<p style="margin-top:0;margin-bottom:0">please see below code.</p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0">but it seems miss other temperature type in this patch,</p>
<p style="margin-top:0;margin-bottom:0">i will submit a new patch to fix it.</p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0">#define <span style="color: rgb(33, 33, 33); font-family: wf_segoe-ui_normal, "Segoe UI", "Segoe WP", Tahoma, Arial, sans-serif, serif, EmojiFont; font-size: 14.6667px;"><b>SMU_TEMPERATURE_UNITS_PER_CENTIGRADES</b> (1000)</span></p>
<p style="margin-top:0;margin-bottom:0"><span style="color: rgb(33, 33, 33); font-family: wf_segoe-ui_normal, "Segoe UI", "Segoe WP", Tahoma, Arial, sans-serif, serif, EmojiFont; font-size: 14.6667px;">> + adev->pm.dpm.thermal.min_temp = range.min *</span><br style="color: rgb(33, 33, 33); font-family: wf_segoe-ui_normal, "Segoe UI", "Segoe WP", Tahoma, Arial, sans-serif, serif, EmojiFont; font-size: 14.6667px;">
<span style="color: rgb(33, 33, 33); font-family: wf_segoe-ui_normal, "Segoe UI", "Segoe WP", Tahoma, Arial, sans-serif, serif, EmojiFont; font-size: 14.6667px;">>
<b>SMU_TEMPERATURE_UNITS_PER_CENTIGRADES</b>;</span><br style="color: rgb(33, 33, 33); font-family: wf_segoe-ui_normal, "Segoe UI", "Segoe WP", Tahoma, Arial, sans-serif, serif, EmojiFont; font-size: 14.6667px;">
<span style="color: rgb(33, 33, 33); font-family: wf_segoe-ui_normal, "Segoe UI", "Segoe WP", Tahoma, Arial, sans-serif, serif, EmojiFont; font-size: 14.6667px;">> + adev->pm.dpm.thermal.max_temp = range.max *</span><br style="color: rgb(33, 33, 33); font-family: wf_segoe-ui_normal, "Segoe UI", "Segoe WP", Tahoma, Arial, sans-serif, serif, EmojiFont; font-size: 14.6667px;">
<span style="color: rgb(33, 33, 33); font-family: wf_segoe-ui_normal, "Segoe UI", "Segoe WP", Tahoma, Arial, sans-serif, serif, EmojiFont; font-size: 14.6667px;">> +<b>SMU_TEMPERATURE_UNITS_PER_CENTIGRADES</b>;</span><br style="color: rgb(33, 33, 33); font-family: wf_segoe-ui_normal, "Segoe UI", "Segoe WP", Tahoma, Arial, sans-serif, serif, EmojiFont; font-size: 14.6667px;">
<span style="color: rgb(33, 33, 33); font-family: wf_segoe-ui_normal, "Segoe UI", "Segoe WP", Tahoma, Arial, sans-serif, serif, EmojiFont; font-size: 14.6667px;">> </span><br>
</p>
<p style="margin-top:0;margin-bottom:0"><span style="color: rgb(33, 33, 33); font-family: wf_segoe-ui_normal, "Segoe UI", "Segoe WP", Tahoma, Arial, sans-serif, serif, EmojiFont; font-size: 14.6667px;"><br>
</span></p>
<p style="margin-top:0;margin-bottom:0"><span style="color: rgb(33, 33, 33); font-family: wf_segoe-ui_normal, "Segoe UI", "Segoe WP", Tahoma, Arial, sans-serif, serif, EmojiFont; font-size: 14.6667px;">Thanks.</span></p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0">Best Regards,</p>
<p style="margin-top:0;margin-bottom:0">Kevin</p>
</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> Quan, Evan <Evan.Quan@amd.com><br>
<b>Sent:</b> Tuesday, July 23, 2019 7:15:59 PM<br>
<b>To:</b> Wang, Kevin(Yang) <Kevin1.Wang@amd.com>; amd-gfx@lists.freedesktop.org <amd-gfx@lists.freedesktop.org>; Deucher, Alexander <Alexander.Deucher@amd.com><br>
<b>Cc:</b> Huang, Ray <Ray.Huang@amd.com>; Feng, Kenneth <Kenneth.Feng@amd.com>; Wang, Kevin(Yang) <Kevin1.Wang@amd.com><br>
<b>Subject:</b> RE: [PATCH] drm/amd/powerplay: add callback function of get_thermal_temperature_range</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt;">
<div class="PlainText">Please do not change the output temperature granularity.<br>
Although it seems a little weird. It's required by hwmon interfaces design and has to be in millidegrees Celsius (@Deucher, Alexander, right?).<br>
<br>
* hwmon interfaces for GPU temperature:<br>
*<br>
* - temp[1-3]_input: the on die GPU temperature in millidegrees Celsius<br>
* - temp2_input and temp3_input are supported on SOC15 dGPUs only<br>
*<br>
* - temp[1-3]_label: temperature channel label<br>
* - temp2_label and temp3_label are supported on SOC15 dGPUs only<br>
*<br>
* - temp[1-3]_crit: temperature critical max value in millidegrees Celsius<br>
* - temp2_crit and temp3_crit are supported on SOC15 dGPUs only<br>
*<br>
* - temp[1-3]_crit_hyst: temperature hysteresis for critical limit in millidegrees Celsius<br>
* - temp2_crit_hyst and temp3_crit_hyst are supported on SOC15 dGPUs only<br>
*<br>
* - temp[1-3]_emergency: temperature emergency max value(asic shutdown) in millidegrees Celsius<br>
* - these are supported on SOC15 dGPUs only<br>
<br>
Regards,<br>
Evan<br>
> -----Original Message-----<br>
> From: amd-gfx <amd-gfx-bounces@lists.freedesktop.org> On Behalf Of<br>
> Wang, Kevin(Yang)<br>
> Sent: Tuesday, July 23, 2019 5:32 PM<br>
> To: amd-gfx@lists.freedesktop.org<br>
> Cc: Huang, Ray <Ray.Huang@amd.com>; Feng, Kenneth<br>
> <Kenneth.Feng@amd.com>; Wang, Kevin(Yang) <Kevin1.Wang@amd.com><br>
> Subject: [PATCH] drm/amd/powerplay: add callback function of<br>
> get_thermal_temperature_range<br>
> <br>
> 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 <kevin1.wang@amd.com><br>
> Signed-off-by: Kenneth Feng <kenneth.feng@amd.com><br>
> Acked-by: Huang Rui <ray.huang@amd.com><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<br>
> 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<br>
> 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<br>
> smu_context *smu, enum amd_dpm_fo<br>
> return ret;<br>
> }<br>
> <br>
> +static int navi10_get_thermal_temperature_range(struct smu_context<br>
> *smu,<br>
> + struct<br>
> smu_temperature_range *range) {<br>
> + struct smu_table_context *table_context = &smu->smu_table;<br>
> + struct smu_11_0_powerplay_table *powerplay_table =<br>
> +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, @@ -1674,6<br>
> +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 =<br>
> navi10_get_thermal_temperature_range,<br>
> };<br>
> <br>
> void navi10_set_ppt_funcs(struct smu_context *smu) diff --git<br>
> a/drivers/gpu/drm/amd/powerplay/smu_v11_0.c<br>
> 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<br>
> smu_context *smu,<br>
> struct smu_temperature_range *range) {<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<br>
> 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<br>
> smu_context *smu,<br>
> val = REG_SET_FIELD(val, THM_THERMAL_INT_CTRL,<br>
> THERM_IH_HW_ENA, 1);<br>
> val = REG_SET_FIELD(val, THM_THERMAL_INT_CTRL,<br>
> THERM_INTH_MASK, 0);<br>
> val = REG_SET_FIELD(val, THM_THERMAL_INT_CTRL,<br>
> THERM_INTL_MASK, 0);<br>
> - val = REG_SET_FIELD(val, THM_THERMAL_INT_CTRL,<br>
> DIG_THERM_INTH, (high /<br>
> SMU_TEMPERATURE_UNITS_PER_CENTIGRADES));<br>
> - val = REG_SET_FIELD(val, THM_THERMAL_INT_CTRL,<br>
> DIG_THERM_INTL, (low / SMU_TEMPERATURE_UNITS_PER_CENTIGRADES));<br>
> + val = REG_SET_FIELD(val, THM_THERMAL_INT_CTRL,<br>
> DIG_THERM_INTH, (high & 0xff));<br>
> + val = REG_SET_FIELD(val, THM_THERMAL_INT_CTRL,<br>
> DIG_THERM_INTL, (low &<br>
> +0xff));<br>
> val = val &<br>
> (~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<br>
> 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<br>
> smu_context *smu)<br>
> adev->pm.dpm.thermal.min_mem_temp = range.mem_min;<br>
> adev->pm.dpm.thermal.max_mem_crit_temp =<br>
> range.mem_crit_max;<br>
> adev->pm.dpm.thermal.max_mem_emergency_temp =<br>
> range.mem_emergency_max;<br>
> + adev->pm.dpm.thermal.min_temp = range.min *<br>
> SMU_TEMPERATURE_UNITS_PER_CENTIGRADES;<br>
> + adev->pm.dpm.thermal.max_temp = range.max *<br>
> +SMU_TEMPERATURE_UNITS_PER_CENTIGRADES;<br>
> <br>
> return ret;<br>
> }<br>
> diff --git a/drivers/gpu/drm/amd/powerplay/vega20_ppt.c<br>
> 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<br>
> smu_context *smu)<br>
> memcpy(table_context->driver_pptable, &powerplay_table-<br>
> >smcPPTable,<br>
> sizeof(PPTable_t));<br>
> <br>
> - table_context->software_shutdown_temp = powerplay_table-<br>
> >usSoftwareShutdownTemp;<br>
> table_context->thermal_controller_type = powerplay_table-<br>
> >ucThermalControllerType;<br>
> table_context->TDPODLimit = le32_to_cpu(powerplay_table-<br>
> >OverDrive8Table.ODSettingsMax[ATOM_VEGA20_ODSETTING_POWERPER<br>
> CENTAGE]);<br>
> <br>
> @@ -3235,35 +3234,24 @@ static int vega20_set_watermarks_table(struct<br>
> smu_context *smu,<br>
> return 0;<br>
> }<br>
> <br>
> -static const struct smu_temperature_range vega20_thermal_policy[] = -{<br>
> - {-273150, 99000, 99000, -273150, 99000, 99000, -273150, 99000, 99000},<br>
> - { 120000, 120000, 120000, 120000, 120000, 120000, 120000, 120000,<br>
> 120000},<br>
> -};<br>
> -<br>
> static int vega20_get_thermal_temperature_range(struct smu_context<br>
> *smu,<br>
> struct<br>
> smu_temperature_range*range) {<br>
> -<br>
> + struct smu_table_context *table_context = &smu->smu_table;<br>
> + ATOM_Vega20_POWERPLAYTABLE *powerplay_table =<br>
> +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<br>
> smu_temperature_range));<br>
> -<br>
> - range->max = pptable->TedgeLimit *<br>
> - SMU_TEMPERATURE_UNITS_PER_CENTIGRADES;<br>
> - range->edge_emergency_max = (pptable->TedgeLimit +<br>
> 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 +<br>
> 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 +<br>
> 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 +<br>
> CTF_OFFSET_EDGE);<br>
> + range->hotspot_crit_max = pptable->ThotspotLimit;<br>
> + range->hotspot_emergency_max = (pptable->ThotspotLimit +<br>
> CTF_OFFSET_HOTSPOT);<br>
> + range->mem_crit_max = pptable->ThbmLimit;<br>
> + range->mem_emergency_max = (pptable->ThbmLimit +<br>
> CTF_OFFSET_HBM);<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><br>
</div>
</span></font></div>
</body>
</html>