[PATCH 3/5] drm/amdgpu/swsmu/vangogh: simplify sensor handling

Quan, Evan Evan.Quan at amd.com
Wed Dec 2 02:09:23 UTC 2020


[AMD Official Use Only - Internal Distribution Only]

Reviewed-by: Evan Quan <evan.quan at amd.com>

-----Original Message-----
From: amd-gfx <amd-gfx-bounces at lists.freedesktop.org> On Behalf Of Alex Deucher
Sent: Wednesday, December 2, 2020 1:44 AM
To: amd-gfx at lists.freedesktop.org
Cc: Deucher, Alexander <Alexander.Deucher at amd.com>
Subject: [PATCH 3/5] drm/amdgpu/swsmu/vangogh: simplify sensor handling

Just query the metrics table directly rather than going through an extra level of functions.

Signed-off-by: Alex Deucher <alexander.deucher at amd.com>
---
 .../gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c  | 114 +++---------------
 1 file changed, 20 insertions(+), 94 deletions(-)

diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c b/drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c
index 56704181c5a9..1645509cdab8 100644
--- a/drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c
+++ b/drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c
@@ -396,95 +396,6 @@ static bool vangogh_is_dpm_running(struct smu_context *smu)
 return !!(feature_enabled & SMC_DPM_FEATURE);  }

-static int vangogh_get_current_activity_percent(struct smu_context *smu,
-       enum amd_pp_sensors sensor,
-       uint32_t *value)
-{
-int ret = 0;
-
-if (!value)
-return -EINVAL;
-
-switch (sensor) {
-case AMDGPU_PP_SENSOR_GPU_LOAD:
-ret = vangogh_get_smu_metrics_data(smu,
-  METRICS_AVERAGE_GFXACTIVITY,
-  value);
-if (ret)
-return ret;
-break;
-default:
-dev_err(smu->adev->dev, "Invalid sensor for retrieving clock activity\n");
-return -EINVAL;
-}
-
-return 0;
-}
-
-static int vangogh_get_gpu_power(struct smu_context *smu, uint32_t *value) -{
-if (!value)
-return -EINVAL;
-
-return vangogh_get_smu_metrics_data(smu,
-   METRICS_AVERAGE_SOCKETPOWER,
-   value);
-}
-
-static int vangogh_thermal_get_temperature(struct smu_context *smu,
-     enum amd_pp_sensors sensor,
-     uint32_t *value)
-{
-int ret = 0;
-
-if (!value)
-return -EINVAL;
-
-switch (sensor) {
-case AMDGPU_PP_SENSOR_HOTSPOT_TEMP:
-ret = vangogh_get_smu_metrics_data(smu,
-  METRICS_TEMPERATURE_HOTSPOT,
-  value);
-break;
-case AMDGPU_PP_SENSOR_EDGE_TEMP:
-ret = vangogh_get_smu_metrics_data(smu,
-  METRICS_TEMPERATURE_EDGE,
-  value);
-break;
-default:
-dev_err(smu->adev->dev, "Invalid sensor for retrieving temp\n");
-return -EINVAL;
-}
-
-return ret;
-}
-
-static int vangogh_get_current_clk_freq_by_table(struct smu_context *smu,
-       enum smu_clk_type clk_type,
-       uint32_t *value)
-{
-MetricsMember_t member_type;
-
-switch (clk_type) {
-case SMU_GFXCLK:
-member_type = METRICS_AVERAGE_GFXCLK;
-break;
-case SMU_MCLK:
-case SMU_UCLK:
-member_type = METRICS_AVERAGE_UCLK;
-break;
-case SMU_SOCCLK:
-member_type = METRICS_AVERAGE_SOCCLK;
-break;
-default:
-return -EINVAL;
-}
-
-return vangogh_get_smu_metrics_data(smu,
-   member_type,
-   value);
-}
-
 static int vangogh_print_fine_grain_clk(struct smu_context *smu,
 enum smu_clk_type clk_type, char *buf)  { @@ -526,25 +437,40 @@ static int vangogh_read_sensor(struct smu_context *smu,
 mutex_lock(&smu->sensor_lock);
 switch (sensor) {
 case AMDGPU_PP_SENSOR_GPU_LOAD:
-ret = vangogh_get_current_activity_percent(smu, sensor, (uint32_t *)data);
+ret = vangogh_get_smu_metrics_data(smu,
+   METRICS_AVERAGE_GFXACTIVITY,
+   (uint32_t *)data);
 *size = 4;
 break;
 case AMDGPU_PP_SENSOR_GPU_POWER:
-ret = vangogh_get_gpu_power(smu, (uint32_t *)data);
+ret = vangogh_get_smu_metrics_data(smu,
+   METRICS_AVERAGE_SOCKETPOWER,
+   (uint32_t *)data);
 *size = 4;
 break;
 case AMDGPU_PP_SENSOR_EDGE_TEMP:
+ret = vangogh_get_smu_metrics_data(smu,
+   METRICS_TEMPERATURE_EDGE,
+   (uint32_t *)data);
+*size = 4;
+break;
 case AMDGPU_PP_SENSOR_HOTSPOT_TEMP:
-ret = vangogh_thermal_get_temperature(smu, sensor, (uint32_t *)data);
+ret = vangogh_get_smu_metrics_data(smu,
+   METRICS_TEMPERATURE_HOTSPOT,
+   (uint32_t *)data);
 *size = 4;
 break;
 case AMDGPU_PP_SENSOR_GFX_MCLK:
-ret = vangogh_get_current_clk_freq_by_table(smu, SMU_UCLK, (uint32_t *)data);
+ret = vangogh_get_smu_metrics_data(smu,
+   METRICS_AVERAGE_UCLK,
+   (uint32_t *)data);
 *(uint32_t *)data *= 100;
 *size = 4;
 break;
 case AMDGPU_PP_SENSOR_GFX_SCLK:
-ret = vangogh_get_current_clk_freq_by_table(smu, SMU_GFXCLK, (uint32_t *)data);
+ret = vangogh_get_smu_metrics_data(smu,
+    METRICS_AVERAGE_GFXCLK,
+    (uint32_t *)data);
 *(uint32_t *)data *= 100;
 *size = 4;
 break;
--
2.25.4

_______________________________________________
amd-gfx mailing list
amd-gfx at lists.freedesktop.org
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freedesktop.org%2Fmailman%2Flistinfo%2Famd-gfx&data=04%7C01%7Cevan.quan%40amd.com%7C5f115dcc956a4de6e39b08d89620c005%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637424414689469422%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=fCDZnzOSHhcDw4Um2KZ%2ByK%2B8CInYTywSZBLSgYwa8YQ%3D&reserved=0


More information about the amd-gfx mailing list