]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm/amdgpu: Wait for GFX idle before PTL state transition
authorPerry Yuan <perry.yuan@amd.com>
Sun, 8 Feb 2026 16:42:12 +0000 (00:42 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Mon, 11 May 2026 19:55:56 +0000 (15:55 -0400)
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>
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c

index 5bea583732cbb98ccd1de48c3352efff38cf813e..a719399bcdd5d2ff24545898975717fb54e15aa5 100644 (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,