[PATCH 2/3] drm/amd/powerplay: revise the calling chain on sensor reading

Alex Deucher alexdeucher at gmail.com
Tue Jun 9 19:54:20 UTC 2020


On Tue, Jun 9, 2020 at 6:21 AM Evan Quan <evan.quan at amd.com> wrote:
>
> 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.
>
> Change-Id: I95beba6c117b0cd3b0acea6158bf62240c6eac5a
> Signed-off-by: Evan Quan <evan.quan at amd.com>

Reviewed-by: Alex Deucher <alexander.deucher at amd.com>

> ---
>  drivers/gpu/drm/amd/powerplay/amdgpu_smu.c    | 81 ++++++++-----------
>  .../gpu/drm/amd/powerplay/inc/amdgpu_smu.h    |  2 -
>  drivers/gpu/drm/amd/powerplay/smu_v11_0.c     |  2 +-
>  drivers/gpu/drm/amd/powerplay/smu_v12_0.c     |  2 +-
>  4 files changed, 35 insertions(+), 52 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c b/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c
> index 78263de02678..c032680c52b0 100644
> --- a/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c
> +++ b/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c
> @@ -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);
>
> diff --git a/drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h b/drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h
> index 0d1429fc791b..41164a8fbe8a 100644
> --- a/drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h
> +++ b/drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h
> @@ -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);
> diff --git a/drivers/gpu/drm/amd/powerplay/smu_v11_0.c b/drivers/gpu/drm/amd/powerplay/smu_v11_0.c
> index d10d15fc7492..1a17d853afbd 100644
> --- a/drivers/gpu/drm/amd/powerplay/smu_v11_0.c
> +++ b/drivers/gpu/drm/amd/powerplay/smu_v11_0.c
> @@ -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;
>         }
>
> diff --git a/drivers/gpu/drm/amd/powerplay/smu_v12_0.c b/drivers/gpu/drm/amd/powerplay/smu_v12_0.c
> index 5b56e7579ff4..ae1035575808 100644
> --- a/drivers/gpu/drm/amd/powerplay/smu_v12_0.c
> +++ b/drivers/gpu/drm/amd/powerplay/smu_v12_0.c
> @@ -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;
>         }
>
> --
> 2.27.0
>
> _______________________________________________
> amd-gfx mailing list
> amd-gfx at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/amd-gfx


More information about the amd-gfx mailing list