drm/amdgpu: Wait for GFX idle before PTL state transition

Ensure GFX engine is idle before switching PTL state to prevent
register access violations and CP hang. This addresses the race
condition where in-flight GPU commands could conflict with PTL
state changes.

Signed-off-by: Perry Yuan <perry.yuan@amd.com>
Reviewed-by: Yifan Zhang <yifan1.zhang@amd.com>
Acked-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
This commit is contained in:
Perry Yuan 2026-02-09 00:42:12 +08:00 committed by Alex Deucher
parent d31098cb31
commit 82cfe59ba4

View File

@ -1792,6 +1792,11 @@ static int kfd_ptl_control(struct kfd_process_device *pdd, bool enable)
if (adev->kfd.init_complete)
amdgpu_amdkfd_stop_sched(adev, pdd->dev->node_id);
/* Wait for GFX to be idle before PTL operation */
ret = amdgpu_device_ip_wait_for_idle(adev, AMD_IP_BLOCK_TYPE_GFX);
if (ret)
return -ETIMEDOUT;
ret = pdd->dev->kfd2kgd->ptl_ctrl(adev, PSP_PTL_PERF_MON_SET,
&ptl_state,
&pref_format1,