<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);">
Series is:</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Reviewed-by: Alex Deucher <alexander.deucher@amd.com><br>
</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> Tuesday, May 14, 2019 7:19 AM<br>
<b>To:</b> amd-gfx@lists.freedesktop.org<br>
<b>Cc:</b> Quan, Evan<br>
<b>Subject:</b> [PATCH 2/2] drm/amd/powerplay: support sw smu hotspot and memory temperature retrieval</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt;">
<div class="PlainText">[CAUTION: External Email]<br>
<br>
Support hotspot and memory temperature retrieval on sw smu routine.<br>
<br>
Change-Id: If2ed1e2835f4b158a4a6d93aee8b358af18b9bfc<br>
Signed-off-by: Evan Quan <evan.quan@amd.com><br>
---<br>
drivers/gpu/drm/amd/powerplay/inc/smu_v11_0.h | 3 +<br>
drivers/gpu/drm/amd/powerplay/smu_v11_0.c | 74 ++++++++++++++++---<br>
2 files changed, 66 insertions(+), 11 deletions(-)<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 aa8d81f4111e..02c965d64256 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>
@@ -36,6 +36,9 @@<br>
#define smnMP0_FW_INTF 0x30101c0<br>
#define smnMP1_PUB_CTRL 0x3010b14<br>
<br>
+#define TEMP_RANGE_MIN (0)<br>
+#define TEMP_RANGE_MAX (80 * 1000)<br>
+<br>
struct smu_11_0_max_sustainable_clocks {<br>
uint32_t display_clock;<br>
uint32_t phy_clock;<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 738ae1d2ef17..0eea93c8dff7 100644<br>
--- a/drivers/gpu/drm/amd/powerplay/smu_v11_0.c<br>
+++ b/drivers/gpu/drm/amd/powerplay/smu_v11_0.c<br>
@@ -1011,9 +1011,20 @@ static int smu_v11_0_get_current_clk_freq(struct smu_context *smu, uint32_t clk_<br>
static int smu_v11_0_get_thermal_range(struct smu_context *smu,<br>
struct PP_TemperatureRange *range)<br>
{<br>
+ PPTable_t *pptable = smu->smu_table.driver_pptable;<br>
memcpy(range, &SMU7ThermalWithDelayPolicy[0], sizeof(struct PP_TemperatureRange));<br>
<br>
- range->max = smu->smu_table.software_shutdown_temp *<br>
+ range->max = pptable->TedgeLimit *<br>
+ PP_TEMPERATURE_UNITS_PER_CENTIGRADES;<br>
+ range->edge_emergency_max = (pptable->TedgeLimit + CTF_OFFSET_EDGE) *<br>
+ PP_TEMPERATURE_UNITS_PER_CENTIGRADES;<br>
+ range->hotspot_crit_max = pptable->ThotspotLimit *<br>
+ PP_TEMPERATURE_UNITS_PER_CENTIGRADES;<br>
+ range->hotspot_emergency_max = (pptable->ThotspotLimit + CTF_OFFSET_HOTSPOT) *<br>
+ PP_TEMPERATURE_UNITS_PER_CENTIGRADES;<br>
+ range->mem_crit_max = pptable->ThbmLimit *<br>
+ PP_TEMPERATURE_UNITS_PER_CENTIGRADES;<br>
+ range->mem_emergency_max = (pptable->ThbmLimit + CTF_OFFSET_HBM)*<br>
PP_TEMPERATURE_UNITS_PER_CENTIGRADES;<br>
<br>
return 0;<br>
@@ -1078,7 +1089,16 @@ static int smu_v11_0_set_thermal_fan_table(struct smu_context *smu)<br>
static int smu_v11_0_start_thermal_control(struct smu_context *smu)<br>
{<br>
int ret = 0;<br>
- struct PP_TemperatureRange range;<br>
+ struct PP_TemperatureRange 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 amdgpu_device *adev = smu->adev;<br>
<br>
smu_v11_0_get_thermal_range(smu, &range);<br>
@@ -1098,6 +1118,13 @@ static int smu_v11_0_start_thermal_control(struct smu_context *smu)<br>
<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>
@@ -1151,22 +1178,45 @@ static int smu_v11_0_get_current_activity_percent(struct smu_context *smu,<br>
return 0;<br>
}<br>
<br>
-static int smu_v11_0_thermal_get_temperature(struct smu_context *smu, uint32_t *value)<br>
+static int smu_v11_0_thermal_get_temperature(struct smu_context *smu,<br>
+ enum amd_pp_sensors sensor,<br>
+ uint32_t *value)<br>
{<br>
struct amdgpu_device *adev = smu->adev;<br>
+ SmuMetrics_t metrics;<br>
uint32_t temp = 0;<br>
+ int ret = 0;<br>
<br>
if (!value)<br>
return -EINVAL;<br>
<br>
- temp = RREG32_SOC15(THM, 0, mmCG_MULT_THERMAL_STATUS);<br>
- temp = (temp & CG_MULT_THERMAL_STATUS__CTF_TEMP_MASK) >><br>
- CG_MULT_THERMAL_STATUS__CTF_TEMP__SHIFT;<br>
+ ret = smu_v11_0_get_metrics_table(smu, &metrics);<br>
+ if (ret)<br>
+ return ret;<br>
+<br>
+ switch (sensor) {<br>
+ case AMDGPU_PP_SENSOR_HOTSPOT_TEMP:<br>
+ temp = RREG32_SOC15(THM, 0, mmCG_MULT_THERMAL_STATUS);<br>
+ temp = (temp & CG_MULT_THERMAL_STATUS__CTF_TEMP_MASK) >><br>
+ CG_MULT_THERMAL_STATUS__CTF_TEMP__SHIFT;<br>
<br>
- temp = temp & 0x1ff;<br>
- temp *= SMU11_TEMPERATURE_UNITS_PER_CENTIGRADES;<br>
+ temp = temp & 0x1ff;<br>
+ temp *= SMU11_TEMPERATURE_UNITS_PER_CENTIGRADES;<br>
<br>
- *value = temp;<br>
+ *value = temp;<br>
+ break;<br>
+ case AMDGPU_PP_SENSOR_EDGE_TEMP:<br>
+ *value = metrics.TemperatureEdge *<br>
+ PP_TEMPERATURE_UNITS_PER_CENTIGRADES;<br>
+ break;<br>
+ case AMDGPU_PP_SENSOR_MEM_TEMP:<br>
+ *value = metrics.TemperatureHBM *<br>
+ PP_TEMPERATURE_UNITS_PER_CENTIGRADES;<br>
+ break;<br>
+ default:<br>
+ pr_err("Invalid sensor for retrieving temp\n");<br>
+ return -EINVAL;<br>
+ }<br>
<br>
return 0;<br>
}<br>
@@ -1235,8 +1285,10 @@ static int smu_v11_0_read_sensor(struct smu_context *smu,<br>
ret = smu_get_current_clk_freq(smu, PPCLK_GFXCLK, (uint32_t *)data);<br>
*size = 4;<br>
break;<br>
- case AMDGPU_PP_SENSOR_GPU_TEMP:<br>
- ret = smu_v11_0_thermal_get_temperature(smu, (uint32_t *)data);<br>
+ case AMDGPU_PP_SENSOR_HOTSPOT_TEMP:<br>
+ case AMDGPU_PP_SENSOR_EDGE_TEMP:<br>
+ case AMDGPU_PP_SENSOR_MEM_TEMP:<br>
+ ret = smu_v11_0_thermal_get_temperature(smu, sensor, (uint32_t *)data);<br>
*size = 4;<br>
break;<br>
case AMDGPU_PP_SENSOR_GPU_POWER:<br>
--<br>
2.21.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>