From: Jesse Zhang <Zhexi.Zhang@xxxxxxx> Guest driver can be unloaded while engines still using some backend resources. That would lead to use after free and then cause guest driver failed. Need to add mutex lock before backend resources free to make sure nobody is using it. Need to check backend data availablility before VCE/UVD enter powergating mode, if backend resources have been free, then skip entering powergating. Change-Id: If7f93221ddecc578884dc9e99a52f22a43e16b07 Signed-off-by: Jesse Zhang <zhexi.zhang@xxxxxxx> --- drivers/gpu/drm/amd/powerplay/amd_powerplay.c | 2 ++ drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/drivers/gpu/drm/amd/powerplay/amd_powerplay.c b/drivers/gpu/drm/amd/powerplay/amd_powerplay.c index fa8ad7d..c32b2dd 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(&pp_hwmgr->smu_lock); return 0; } diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c b/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c index d08493b..e51ffdd 100644 --- a/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c +++ b/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c @@ -4619,6 +4619,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); } @@ -4627,6 +4630,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