]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
drm/amdgpu/swsmu/arcturus: simplify sensor handling
authorAlex Deucher <alexander.deucher@amd.com>
Tue, 1 Dec 2020 18:31:31 +0000 (13:31 -0500)
committerAlex Deucher <alexander.deucher@amd.com>
Wed, 2 Dec 2020 22:37:17 +0000 (17:37 -0500)
Just query the metrics table directly rather than going through
an extra level of functions.

Reviewed-by: Evan Quan <evan.quan@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/pm/swsmu/smu11/arcturus_ppt.c

index 4fd850e58004a459905f5ccdff7f441b3931cea3..cd7b411457ffac308882acf71fa7ba045e82eb2d 100644 (file)
@@ -1000,77 +1000,6 @@ static int arcturus_get_thermal_temperature_range(struct smu_context *smu,
        return 0;
 }
 
-static int arcturus_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 = arcturus_get_smu_metrics_data(smu,
-                                                   METRICS_AVERAGE_GFXACTIVITY,
-                                                   value);
-               break;
-       case AMDGPU_PP_SENSOR_MEM_LOAD:
-               ret = arcturus_get_smu_metrics_data(smu,
-                                                   METRICS_AVERAGE_MEMACTIVITY,
-                                                   value);
-               break;
-       default:
-               dev_err(smu->adev->dev, "Invalid sensor for retrieving clock activity\n");
-               return -EINVAL;
-       }
-
-       return ret;
-}
-
-static int arcturus_get_gpu_power(struct smu_context *smu, uint32_t *value)
-{
-       if (!value)
-               return -EINVAL;
-
-       return arcturus_get_smu_metrics_data(smu,
-                                            METRICS_AVERAGE_SOCKETPOWER,
-                                            value);
-}
-
-static int arcturus_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 = arcturus_get_smu_metrics_data(smu,
-                                                   METRICS_TEMPERATURE_HOTSPOT,
-                                                   value);
-               break;
-       case AMDGPU_PP_SENSOR_EDGE_TEMP:
-               ret = arcturus_get_smu_metrics_data(smu,
-                                                   METRICS_TEMPERATURE_EDGE,
-                                                   value);
-               break;
-       case AMDGPU_PP_SENSOR_MEM_TEMP:
-               ret = arcturus_get_smu_metrics_data(smu,
-                                                   METRICS_TEMPERATURE_MEM,
-                                                   value);
-               break;
-       default:
-               dev_err(smu->adev->dev, "Invalid sensor for retrieving temp\n");
-               return -EINVAL;
-       }
-
-       return ret;
-}
-
 static int arcturus_read_sensor(struct smu_context *smu,
                                enum amd_pp_sensors sensor,
                                void *data, uint32_t *size)
@@ -1092,21 +1021,39 @@ static int arcturus_read_sensor(struct smu_context *smu,
                *size = 4;
                break;
        case AMDGPU_PP_SENSOR_MEM_LOAD:
+               ret = arcturus_get_smu_metrics_data(smu,
+                                                   METRICS_AVERAGE_MEMACTIVITY,
+                                                   (uint32_t *)data);
+               *size = 4;
+               break;
        case AMDGPU_PP_SENSOR_GPU_LOAD:
-               ret = arcturus_get_current_activity_percent(smu,
-                                                           sensor,
-                                               (uint32_t *)data);
+               ret = arcturus_get_smu_metrics_data(smu,
+                                                   METRICS_AVERAGE_GFXACTIVITY,
+                                                   (uint32_t *)data);
                *size = 4;
                break;
        case AMDGPU_PP_SENSOR_GPU_POWER:
-               ret = arcturus_get_gpu_power(smu, (uint32_t *)data);
+               ret = arcturus_get_smu_metrics_data(smu,
+                                                   METRICS_AVERAGE_SOCKETPOWER,
+                                                   (uint32_t *)data);
                *size = 4;
                break;
        case AMDGPU_PP_SENSOR_HOTSPOT_TEMP:
+               ret = arcturus_get_smu_metrics_data(smu,
+                                                   METRICS_TEMPERATURE_HOTSPOT,
+                                                   (uint32_t *)data);
+               *size = 4;
+               break;
        case AMDGPU_PP_SENSOR_EDGE_TEMP:
+               ret = arcturus_get_smu_metrics_data(smu,
+                                                   METRICS_TEMPERATURE_EDGE,
+                                                   (uint32_t *)data);
+               *size = 4;
+               break;
        case AMDGPU_PP_SENSOR_MEM_TEMP:
-               ret = arcturus_thermal_get_temperature(smu, sensor,
-                                               (uint32_t *)data);
+               ret = arcturus_get_smu_metrics_data(smu,
+                                                   METRICS_TEMPERATURE_MEM,
+                                                   (uint32_t *)data);
                *size = 4;
                break;
        case AMDGPU_PP_SENSOR_GFX_MCLK: