drm/amdgpu: lock the eviction fence for wq signals it
authorPrike Liang <Prike.Liang@amd.com>
Wed, 30 Apr 2025 02:34:14 +0000 (10:34 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Thu, 22 May 2025 16:00:44 +0000 (12:00 -0400)
Lock and refer to the eviction fence before the eviction fence
schedules work queue tries to signal it.

Suggested-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Prike Liang <Prike.Liang@amd.com>
Acked-by: Alex Deucher <alexander.deucher@amd.com>
Reviewed-by: Arvind Yadav <Arvind.Yadav@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu_eviction_fence.c

index 73b629b..8b919ad 100644 (file)
@@ -108,13 +108,22 @@ amdgpu_eviction_fence_suspend_worker(struct work_struct *work)
        struct amdgpu_eviction_fence *ev_fence;
 
        mutex_lock(&uq_mgr->userq_mutex);
+       spin_lock(&evf_mgr->ev_fence_lock);
        ev_fence = evf_mgr->ev_fence;
-       if (!ev_fence)
+       if (ev_fence)
+               dma_fence_get(&ev_fence->base);
+       else
                goto unlock;
+       spin_unlock(&evf_mgr->ev_fence_lock);
 
        amdgpu_userq_evict(uq_mgr, ev_fence);
 
+       mutex_unlock(&uq_mgr->userq_mutex);
+       dma_fence_put(&ev_fence->base);
+       return;
+
 unlock:
+       spin_unlock(&evf_mgr->ev_fence_lock);
        mutex_unlock(&uq_mgr->userq_mutex);
 }