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@xxxxxxx> --- 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@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/amd-gfx