[PATCH] drm/amd/powerplay: Protect backend resource when unload driver

Quan, Evan Evan.Quan at amd.com
Wed Nov 6 09:13:12 UTC 2019


I kind of feeling the changes of VCE and UVD(of vega10_hwmgr.c) are not needed as there is already lock protection in pp_dpm_powergate_uvd/vce.
Can you help to confirm that?

Regards,
Evan
> -----Original Message-----
> From: amd-gfx <amd-gfx-bounces at lists.freedesktop.org> On Behalf Of Jesse
> Zhang
> Sent: Wednesday, November 6, 2019 2:31 PM
> To: amd-gfx at lists.freedesktop.org
> Cc: Zhang, Zhexi (Jesse) <Zhexi.Zhang at amd.com>
> Subject: [PATCH] drm/amd/powerplay: Protect backend resource when unload
> driver
> 
> Guest driver can be unloaded while engines still using some backend resources
> which whould lead to guest driver unload failure.
> 
> Need to add mutex lock to protect backend resources from concurrent
> operations
> 
> Before entering powergating mode, VCE and UVD need to check if backend
> resources are still available.
> 
> Change-Id: Icc34f93818743856c4efbbbf9480e4d9f2e0d1e1
> Signed-off-by: Jesse Zhang <zhexi.zhang at amd.com>
> ---
>  drivers/gpu/drm/amd/powerplay/amd_powerplay.c      | 4 ++++
>  drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c | 6 ++++++
>  2 files changed, 10 insertions(+)
> 
> diff --git a/drivers/gpu/drm/amd/powerplay/amd_powerplay.c
> b/drivers/gpu/drm/amd/powerplay/amd_powerplay.c
> index 0314476..c82570b 100644
> --- a/drivers/gpu/drm/amd/powerplay/amd_powerplay.c
> +++ b/drivers/gpu/drm/amd/powerplay/amd_powerplay.c
> @@ -134,7 +134,9 @@ static int pp_hw_fini(void *handle)
>  	struct amdgpu_device *adev = handle;
>  	struct pp_hwmgr *hwmgr = adev->powerplay.pp_handle;
> 
> +	mutex_lock(&hwmgr->smu_lock);
>  	hwmgr_hw_fini(hwmgr);
> +	mutex_unlock(&hwmgr->smu_lock);
> 
>  	return 0;
>  }
> @@ -662,7 +664,9 @@ static int amd_powerplay_reset(void *handle)
>  	struct pp_hwmgr *hwmgr = handle;
>  	int ret;
> 
> +	mutex_lock(&hwmgr->smu_lock);
>  	ret = hwmgr_hw_fini(hwmgr);
> +	mutex_unlock(&hwmgr->smu_lock);
>  	if (ret)
>  		return ret;
> 
> diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c
> b/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c
> index 46538233..f72ba70 100644
> --- a/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c
> +++ b/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c
> @@ -4616,6 +4616,9 @@ static void vega10_power_gate_vce(struct
> pp_hwmgr *hwmgr, bool bgate)
>  {
>  	struct vega10_hwmgr *data = hwmgr->backend;
> 
> +	if (!data)
> +		return;
> +
>  	data->vce_power_gated = bgate;
>  	vega10_enable_disable_vce_dpm(hwmgr, !bgate);
>  }
> @@ -4624,6 +4627,9 @@ static void vega10_power_gate_uvd(struct
> pp_hwmgr *hwmgr, bool bgate)
>  {
>  	struct vega10_hwmgr *data = hwmgr->backend;
> 
> +	if (!data)
> +		return;
> +
>  	data->uvd_power_gated = bgate;
>  	vega10_enable_disable_uvd_dpm(hwmgr, !bgate);
>  }
> --
> 2.7.4
> 
> _______________________________________________
> 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