drm/amd/powerplay: revise the calling chain on sensor reading
authorEvan Quan <evan.quan@amd.com>
Tue, 9 Jun 2020 04:16:56 +0000 (12:16 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Wed, 1 Jul 2020 05:59:19 +0000 (01:59 -0400)
Update the calling chain from "amdgpu_smu.c -> ${asic}_ppt.c ->
smu_v11/12_0.c -> amdgpu_smu.c (smu_common_read_sensor())" to "
"amdgpu_smu.c -> ${asic}_ppt.c -> smu_v11/12_0.c". This can help
to maintain clear code layers. More similar changes will be coming.

Signed-off-by: Evan Quan <evan.quan@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/powerplay/amdgpu_smu.c
drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h
drivers/gpu/drm/amd/powerplay/smu_v11_0.c
drivers/gpu/drm/amd/powerplay/smu_v12_0.c

index 78263de..c032680 100644 (file)
@@ -506,52 +506,6 @@ int smu_get_power_num_states(struct smu_context *smu,
        return 0;
 }
 
-int smu_common_read_sensor(struct smu_context *smu, enum amd_pp_sensors sensor,
-                          void *data, uint32_t *size)
-{
-       struct smu_power_context *smu_power = &smu->smu_power;
-       struct smu_power_gate *power_gate = &smu_power->power_gate;
-       int ret = 0;
-
-       if(!data || !size)
-               return -EINVAL;
-
-       switch (sensor) {
-       case AMDGPU_PP_SENSOR_STABLE_PSTATE_SCLK:
-               *((uint32_t *)data) = smu->pstate_sclk;
-               *size = 4;
-               break;
-       case AMDGPU_PP_SENSOR_STABLE_PSTATE_MCLK:
-               *((uint32_t *)data) = smu->pstate_mclk;
-               *size = 4;
-               break;
-       case AMDGPU_PP_SENSOR_ENABLED_SMC_FEATURES_MASK:
-               ret = smu_feature_get_enabled_mask(smu, (uint32_t *)data, 2);
-               *size = 8;
-               break;
-       case AMDGPU_PP_SENSOR_UVD_POWER:
-               *(uint32_t *)data = smu_feature_is_enabled(smu, SMU_FEATURE_DPM_UVD_BIT) ? 1 : 0;
-               *size = 4;
-               break;
-       case AMDGPU_PP_SENSOR_VCE_POWER:
-               *(uint32_t *)data = smu_feature_is_enabled(smu, SMU_FEATURE_DPM_VCE_BIT) ? 1 : 0;
-               *size = 4;
-               break;
-       case AMDGPU_PP_SENSOR_VCN_POWER_STATE:
-               *(uint32_t *)data = power_gate->vcn_gated ? 0 : 1;
-               *size = 4;
-               break;
-       default:
-               ret = -EINVAL;
-               break;
-       }
-
-       if (ret)
-               *size = 0;
-
-       return ret;
-}
-
 int smu_update_table(struct smu_context *smu, enum smu_table_id table_index, int argument,
                     void *table_data, bool drv2smu)
 {
@@ -2338,10 +2292,41 @@ int smu_read_sensor(struct smu_context *smu,
        if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)
                return -EOPNOTSUPP;
 
+       if (!data || !size)
+               return -EINVAL;
+
        mutex_lock(&smu->mutex);
 
-       if (smu->ppt_funcs->read_sensor)
-               ret = smu->ppt_funcs->read_sensor(smu, sensor, data, size);
+       switch (sensor) {
+       case AMDGPU_PP_SENSOR_STABLE_PSTATE_SCLK:
+               *((uint32_t *)data) = smu->pstate_sclk;
+               *size = 4;
+               break;
+       case AMDGPU_PP_SENSOR_STABLE_PSTATE_MCLK:
+               *((uint32_t *)data) = smu->pstate_mclk;
+               *size = 4;
+               break;
+       case AMDGPU_PP_SENSOR_ENABLED_SMC_FEATURES_MASK:
+               ret = smu_feature_get_enabled_mask(smu, (uint32_t *)data, 2);
+               *size = 8;
+               break;
+       case AMDGPU_PP_SENSOR_UVD_POWER:
+               *(uint32_t *)data = smu_feature_is_enabled(smu, SMU_FEATURE_DPM_UVD_BIT) ? 1 : 0;
+               *size = 4;
+               break;
+       case AMDGPU_PP_SENSOR_VCE_POWER:
+               *(uint32_t *)data = smu_feature_is_enabled(smu, SMU_FEATURE_DPM_VCE_BIT) ? 1 : 0;
+               *size = 4;
+               break;
+       case AMDGPU_PP_SENSOR_VCN_POWER_STATE:
+               *(uint32_t *)data = smu->smu_power.power_gate.vcn_gated ? 0 : 1;
+               *size = 4;
+               break;
+       default:
+               if (smu->ppt_funcs->read_sensor)
+                       ret = smu->ppt_funcs->read_sensor(smu, sensor, data, size);
+               break;
+       }
 
        mutex_unlock(&smu->mutex);
 
index a28d6b0..01afc8f 100644 (file)
@@ -695,8 +695,6 @@ int smu_update_table(struct smu_context *smu, enum smu_table_id table_index, int
 
 bool is_support_sw_smu(struct amdgpu_device *adev);
 int smu_reset(struct smu_context *smu);
-int smu_common_read_sensor(struct smu_context *smu, enum amd_pp_sensors sensor,
-                          void *data, uint32_t *size);
 int smu_sys_get_pp_table(struct smu_context *smu, void **table);
 int smu_sys_set_pp_table(struct smu_context *smu,  void *buf, size_t size);
 int smu_get_power_num_states(struct smu_context *smu, struct pp_states_info *state_info);
index 1420426..9dcb0a3 100644 (file)
@@ -1198,7 +1198,7 @@ int smu_v11_0_read_sensor(struct smu_context *smu,
                *size = 4;
                break;
        default:
-               ret = smu_common_read_sensor(smu, sensor, data, size);
+               ret = -EOPNOTSUPP;
                break;
        }
 
index 5b56e75..ae10355 100644 (file)
@@ -226,7 +226,7 @@ int smu_v12_0_read_sensor(struct smu_context *smu,
                *size = 4;
                break;
        default:
-               ret = smu_common_read_sensor(smu, sensor, data, size);
+               ret = -EOPNOTSUPP;
                break;
        }