[PATCH 2/2] drm/amdgpu/navi10: add thermal sensor support for navi10

Wang, Kevin(Yang) Kevin1.Wang at amd.com
Thu Jul 4 03:08:40 UTC 2019


From: amd-gfx <amd-gfx-bounces at lists.freedesktop.org> on behalf of Alex Deucher <alexdeucher at gmail.com>
Sent: Thursday, July 4, 2019 10:58:22 AM
To: amd-gfx at lists.freedesktop.org
Cc: Deucher, Alexander
Subject: [PATCH 2/2] drm/amdgpu/navi10: add thermal sensor support for navi10

This was dropped when the code was refactored.  Re-add it
for navi10.

Signed-off-by: Alex Deucher <alexander.deucher at amd.com>
---
 drivers/gpu/drm/amd/powerplay/navi10_ppt.c | 42 ++++++++++++++++++++++
 1 file changed, 42 insertions(+)

diff --git a/drivers/gpu/drm/amd/powerplay/navi10_ppt.c b/drivers/gpu/drm/amd/powerplay/navi10_ppt.c
index 5794f7cef1c8..34fbc4be224c 100644
--- a/drivers/gpu/drm/amd/powerplay/navi10_ppt.c
+++ b/drivers/gpu/drm/amd/powerplay/navi10_ppt.c
@@ -900,6 +900,42 @@ static int navi10_get_current_activity_percent(struct smu_context *smu,
         return 0;
 }

+static int navi10_thermal_get_temperature(struct smu_context *smu,
+                                         enum amd_pp_sensors sensor,
+                                         uint32_t *value)
+{
+       int ret = 0;
+       SmuMetrics_t metrics;
+
+       if (!value)
+               return -EINVAL;
+
+       ret = smu_update_table(smu, SMU_TABLE_SMU_METRICS, (void *)&metrics,
+                              false);
+       if (ret)
+               return ret;
+
+       switch (sensor) {
+       case AMDGPU_PP_SENSOR_HOTSPOT_TEMP:
+               *value = metrics.TemperatureHotspot *
+                       SMU_TEMPERATURE_UNITS_PER_CENTIGRADES;
+               break;
+       case AMDGPU_PP_SENSOR_EDGE_TEMP:
+               *value = metrics.TemperatureEdge *
+                       SMU_TEMPERATURE_UNITS_PER_CENTIGRADES;
+               break;
+       case AMDGPU_PP_SENSOR_MEM_TEMP:
+               *value = metrics.TemperatureMem *
+                       SMU_TEMPERATURE_UNITS_PER_CENTIGRADES;
[kevin]:
the TemperatureMem is not valid for navi10, (it always return 0, it maybe work on HBM type of Memmory, but navi10 is DDR6),
and we can use TemperatureVrMem0 to replace it , and it is verify on my local side.

Reviewed-by: Kevin Wang <kevin1.wang at amd.com>

+               break;
+       default:
+               pr_err("Invalid sensor for retrieving temp\n");
+               return -EINVAL;
+       }
+
+       return 0;
+}
+
 static bool navi10_is_dpm_running(struct smu_context *smu)
 {
         int ret = 0;
@@ -1280,6 +1316,12 @@ static int navi10_read_sensor(struct smu_context *smu,
                 ret = navi10_get_gpu_power(smu, (uint32_t *)data);
                 *size = 4;
                 break;
+       case AMDGPU_PP_SENSOR_HOTSPOT_TEMP:
+       case AMDGPU_PP_SENSOR_EDGE_TEMP:
+       case AMDGPU_PP_SENSOR_MEM_TEMP:
+               ret = navi10_thermal_get_temperature(smu, sensor, (uint32_t *)data);
+               *size = 4;
+               break;
         default:
                 return -EINVAL;
         }
--
2.20.1

_______________________________________________
amd-gfx mailing list
amd-gfx at lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
amd-gfx Info Page - freedesktop.org<https://lists.freedesktop.org/mailman/listinfo/amd-gfx>
lists.freedesktop.org
To see the collection of prior postings to the list, visit the amd-gfx Archives.. Using amd-gfx: To post a message to all the list members, send email to amd-gfx at lists.freedesktop.org. You can subscribe to the list, or change your existing subscription, in the sections below.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/amd-gfx/attachments/20190704/2a5fe5c5/attachment-0001.html>


More information about the amd-gfx mailing list