drm/amd/powerplay: simplify the interface of get_current_activity_percent
authorKevin Wang <kevin1.wang@amd.com>
Fri, 21 Jun 2019 16:25:00 +0000 (11:25 -0500)
committerAlex Deucher <alexander.deucher@amd.com>
Fri, 21 Jun 2019 23:59:30 +0000 (18:59 -0500)
this callback function is only call in read_sensor in smu_v11_0.c,
so move this code to {asic}_ppt.c to implement as asic related function.

Signed-off-by: Kevin Wang <kevin1.wang@amd.com>
Reviewed-by: Huang Rui <ray.huang@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h
drivers/gpu/drm/amd/powerplay/navi10_ppt.c
drivers/gpu/drm/amd/powerplay/smu_v11_0.c
drivers/gpu/drm/amd/powerplay/vega20_ppt.c

index a4812c05c09c15b923bf6c3c9bc160edcc21841c..635837b79d94246e3afe858fe7a2680f1ee5bb6a 100644 (file)
@@ -595,9 +595,6 @@ struct pptable_funcs {
        int (*set_thermal_fan_table)(struct smu_context *smu);
        int (*get_fan_speed_percent)(struct smu_context *smu, uint32_t *speed);
        int (*get_gpu_power)(struct smu_context *smu, uint32_t *value);
-       int (*get_current_activity_percent)(struct smu_context *smu,
-                                           enum amd_pp_sensors sensor,
-                                           uint32_t *value);
        int (*set_watermarks_table)(struct smu_context *smu, void *watermarks,
                                    struct dm_pp_wm_sets_with_clock_ranges_soc15 *clock_ranges);
        int (*get_current_clk_freq_by_table)(struct smu_context *smu,
@@ -830,8 +827,6 @@ struct smu_funcs
        ((smu)->ppt_funcs->get_fan_speed_percent ? (smu)->ppt_funcs->get_fan_speed_percent((smu), (speed)) : 0)
 #define smu_get_gpu_power(smu, val) \
        ((smu)->ppt_funcs->get_gpu_power ? (smu)->ppt_funcs->get_gpu_power((smu), (val)) : 0)
-#define smu_get_current_activity_percent(smu, val) \
-       ((smu)->ppt_funcs->get_current_activity_percent ? (smu)->ppt_funcs->get_current_activity_percent((smu), (sensor), (val)) : 0)
 #define smu_set_fan_speed_percent(smu, speed) \
        ((smu)->funcs->set_fan_speed_percent ? (smu)->funcs->set_fan_speed_percent((smu), (speed)) : 0)
 
index 7df9d3c1509459fded225471fa746e61740abfa4..376ea528964667b481b469f6247fd2f9b239a98a 100644 (file)
@@ -1191,6 +1191,10 @@ static int navi10_read_sensor(struct smu_context *smu,
                *(uint32_t *)data = pptable->FanMaximumRpm;
                *size = 4;
                break;
+       case AMDGPU_PP_SENSOR_GPU_LOAD:
+               ret = navi10_get_current_activity_percent(smu, (uint32_t *)data);
+               *size = 4;
+               break;
        default:
                return -EINVAL;
        }
@@ -1224,7 +1228,6 @@ static const struct pptable_funcs navi10_ppt_funcs = {
        .force_dpm_limit_value = navi10_force_dpm_limit_value,
        .unforce_dpm_levels = navi10_unforce_dpm_levels,
        .get_gpu_power = navi10_get_gpu_power,
-       .get_current_activity_percent = navi10_get_current_activity_percent,
        .is_dpm_running = navi10_is_dpm_running,
        .set_thermal_fan_table = navi10_set_thermal_fan_table,
        .get_fan_speed_percent = navi10_get_fan_speed_percent,
index 29f868f0ef3cabdf29a476d9b6affbb8f03fcdc9..c37fcd5eb45b828ed819e657656293736465e22a 100644 (file)
@@ -1320,13 +1320,6 @@ static int smu_v11_0_read_sensor(struct smu_context *smu,
 {
        int ret = 0;
        switch (sensor) {
-       case AMDGPU_PP_SENSOR_GPU_LOAD:
-       case AMDGPU_PP_SENSOR_MEM_LOAD:
-               ret = smu_get_current_activity_percent(smu,
-                                                      sensor,
-                                                      (uint32_t *)data);
-               *size = 4;
-               break;
        case AMDGPU_PP_SENSOR_GFX_MCLK:
                ret = smu_get_current_clk_freq(smu, SMU_UCLK, (uint32_t *)data);
                *size = 4;
index 55d6be88744b1565b99ab91b45658b9743d411d0..93c6545ec4e89d3b5ee400c0738089cddbb17ca6 100644 (file)
@@ -2927,26 +2927,6 @@ static int vega20_set_ppfeature_status(struct smu_context *smu, uint64_t new_ppf
        return 0;
 }
 
-static int vega20_read_sensor(struct smu_context *smu,
-                             enum amd_pp_sensors sensor,
-                             void *data, uint32_t *size)
-{
-       int ret = 0;
-       struct smu_table_context *table_context = &smu->smu_table;
-       PPTable_t *pptable = table_context->driver_pptable;
-
-       switch (sensor) {
-       case AMDGPU_PP_SENSOR_MAX_FAN_RPM:
-               *(uint32_t *)data = pptable->FanMaximumRpm;
-               *size = 4;
-               break;
-       default:
-               return -EINVAL;
-       }
-
-       return ret;
-}
-
 static bool vega20_is_dpm_running(struct smu_context *smu)
 {
        int ret = 0;
@@ -3033,6 +3013,33 @@ static int vega20_get_current_activity_percent(struct smu_context *smu,
        return 0;
 }
 
+static int vega20_read_sensor(struct smu_context *smu,
+                                enum amd_pp_sensors sensor,
+                                void *data, uint32_t *size)
+{
+       int ret = 0;
+       struct smu_table_context *table_context = &smu->smu_table;
+       PPTable_t *pptable = table_context->driver_pptable;
+
+       switch (sensor) {
+       case AMDGPU_PP_SENSOR_MAX_FAN_RPM:
+               *(uint32_t *)data = pptable->FanMaximumRpm;
+               *size = 4;
+               break;
+       case AMDGPU_PP_SENSOR_MEM_LOAD:
+       case AMDGPU_PP_SENSOR_GPU_LOAD:
+               ret = vega20_get_current_activity_percent(smu,
+                                               sensor,
+                                               (uint32_t *)data);
+               *size = 4;
+               break;
+       default:
+               return -EINVAL;
+       }
+
+       return ret;
+}
+
 static int vega20_set_watermarks_table(struct smu_context *smu,
                                       void *watermarks, struct
                                       dm_pp_wm_sets_with_clock_ranges_soc15
@@ -3139,7 +3146,6 @@ static const struct pptable_funcs vega20_ppt_funcs = {
        .set_thermal_fan_table = vega20_set_thermal_fan_table,
        .get_fan_speed_percent = vega20_get_fan_speed_percent,
        .get_gpu_power = vega20_get_gpu_power,
-       .get_current_activity_percent = vega20_get_current_activity_percent,
        .set_watermarks_table = vega20_set_watermarks_table,
 };