[PATCH] drm/amd/powerplay: refine code to support no-dpm case

Alex Deucher alexdeucher at gmail.com
Sat Jan 4 16:56:04 UTC 2020


On Fri, Jan 3, 2020 at 4:48 AM Evan Quan <evan.quan at amd.com> wrote:
>
> With "dpm=0", there will be no DPM enabled. The code
> needs to be refined to support this.
>
> Change-Id: Ief1561e69a24472135e0499073a27ea5fd8174e2
> Signed-off-by: Evan Quan <evan.quan at amd.com>

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

> ---
>  drivers/gpu/drm/amd/powerplay/amd_powerplay.c |  5 ++++-
>  drivers/gpu/drm/amd/powerplay/amdgpu_smu.c    |  6 ++++++
>  drivers/gpu/drm/amd/powerplay/arcturus_ppt.c  | 10 ++++++++++
>  3 files changed, 20 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/amd/powerplay/amd_powerplay.c b/drivers/gpu/drm/amd/powerplay/amd_powerplay.c
> index 7293763d524c..c195575366a3 100644
> --- a/drivers/gpu/drm/amd/powerplay/amd_powerplay.c
> +++ b/drivers/gpu/drm/amd/powerplay/amd_powerplay.c
> @@ -927,9 +927,12 @@ static int pp_dpm_set_mp1_state(void *handle, enum pp_mp1_state mp1_state)
>  {
>         struct pp_hwmgr *hwmgr = handle;
>
> -       if (!hwmgr || !hwmgr->pm_en)
> +       if (!hwmgr)
>                 return -EINVAL;
>
> +       if (!hwmgr->pm_en)
> +               return 0;
> +
>         if (hwmgr->hwmgr_func->set_mp1_state)
>                 return hwmgr->hwmgr_func->set_mp1_state(hwmgr, mp1_state);
>
> diff --git a/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c b/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c
> index 96e3f0ee64d8..a56ebcc4e3c7 100644
> --- a/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c
> +++ b/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c
> @@ -1364,6 +1364,9 @@ static int smu_hw_fini(void *handle)
>                 smu_powergate_jpeg(&adev->smu, true);
>         }
>
> +       if (!smu->pm_enabled)
> +               return 0;
> +
>         if (!amdgpu_sriov_vf(adev)){
>                 ret = smu_stop_thermal_control(smu);
>                 if (ret) {
> @@ -1448,6 +1451,9 @@ static int smu_suspend(void *handle)
>         struct smu_context *smu = &adev->smu;
>         bool baco_feature_is_enabled = false;
>
> +       if (!smu->pm_enabled)
> +               return 0;
> +
>         if(!smu->is_apu)
>                 baco_feature_is_enabled = smu_feature_is_enabled(smu, SMU_FEATURE_BACO_BIT);
>
> diff --git a/drivers/gpu/drm/amd/powerplay/arcturus_ppt.c b/drivers/gpu/drm/amd/powerplay/arcturus_ppt.c
> index 064b5201a8a7..1c15c6fbe3b9 100644
> --- a/drivers/gpu/drm/amd/powerplay/arcturus_ppt.c
> +++ b/drivers/gpu/drm/amd/powerplay/arcturus_ppt.c
> @@ -2176,8 +2176,12 @@ static const struct i2c_algorithm arcturus_i2c_eeprom_i2c_algo = {
>  static int arcturus_i2c_eeprom_control_init(struct i2c_adapter *control)
>  {
>         struct amdgpu_device *adev = to_amdgpu_device(control);
> +       struct smu_context *smu = &adev->smu;
>         int res;
>
> +       if (!smu->pm_enabled)
> +               return -EOPNOTSUPP;
> +
>         control->owner = THIS_MODULE;
>         control->class = I2C_CLASS_SPD;
>         control->dev.parent = &adev->pdev->dev;
> @@ -2193,6 +2197,12 @@ static int arcturus_i2c_eeprom_control_init(struct i2c_adapter *control)
>
>  static void arcturus_i2c_eeprom_control_fini(struct i2c_adapter *control)
>  {
> +       struct amdgpu_device *adev = to_amdgpu_device(control);
> +       struct smu_context *smu = &adev->smu;
> +
> +       if (!smu->pm_enabled)
> +               return;
> +
>         i2c_del_adapter(control);
>  }
>
> --
> 2.24.1
>
> _______________________________________________
> 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