]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
drm/amdgpu: fix eviction fence and userq manager shutdown
authorChristian König <christian.koenig@amd.com>
Fri, 30 Jan 2026 15:46:36 +0000 (16:46 +0100)
committerAlex Deucher <alexander.deucher@amd.com>
Tue, 17 Mar 2026 21:46:21 +0000 (17:46 -0400)
That is a really complicated dance and wasn't implemented fully correct.

Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Sunil Khatri <sunil.khatri@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
drivers/gpu/drm/amd/amdgpu/amdgpu_eviction_fence.c
drivers/gpu/drm/amd/amdgpu/amdgpu_eviction_fence.h
drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c
drivers/gpu/drm/amd/amdgpu/amdgpu_userq.h

index bc0c62c312ff64b3575b47eb816252351a6d9ab2..a44baa9ee78dcbe500f51dae830aa6546f5ea504 100644 (file)
@@ -2953,6 +2953,8 @@ static int amdgpu_drm_release(struct inode *inode, struct file *filp)
 
        if (fpriv && drm_dev_enter(dev, &idx)) {
                amdgpu_evf_mgr_shutdown(&fpriv->evf_mgr);
+               amdgpu_userq_mgr_cancel_resume(&fpriv->userq_mgr);
+               amdgpu_evf_mgr_flush_suspend(&fpriv->evf_mgr);
                amdgpu_userq_mgr_fini(&fpriv->userq_mgr);
                amdgpu_evf_mgr_fini(&fpriv->evf_mgr);
                drm_dev_exit(idx);
index 78737dda3f6ba095f58b798194aee662c41d3d24..72df5368a9e6d340a42aa50e8585fd22d660a051 100644 (file)
@@ -143,13 +143,19 @@ void amdgpu_evf_mgr_init(struct amdgpu_eviction_fence_mgr *evf_mgr)
 void amdgpu_evf_mgr_shutdown(struct amdgpu_eviction_fence_mgr *evf_mgr)
 {
        evf_mgr->shutdown = true;
+       /* Make sure that the shutdown is visible to the suspend work */
        flush_work(&evf_mgr->suspend_work);
 }
 
-void amdgpu_evf_mgr_fini(struct amdgpu_eviction_fence_mgr *evf_mgr)
+void amdgpu_evf_mgr_flush_suspend(struct amdgpu_eviction_fence_mgr *evf_mgr)
 {
        dma_fence_wait(rcu_dereference_protected(evf_mgr->ev_fence, true),
                       false);
+       /* Make sure that we are done with the last suspend work */
        flush_work(&evf_mgr->suspend_work);
+}
+
+void amdgpu_evf_mgr_fini(struct amdgpu_eviction_fence_mgr *evf_mgr)
+{
        dma_fence_put(evf_mgr->ev_fence);
 }
index 527de3a2358371910e5da89049fe967ef1620094..132a13a5dc1c1b26a2bd0d9b4902f1ca0e9f88c1 100644 (file)
@@ -66,6 +66,7 @@ void amdgpu_evf_mgr_detach_fence(struct amdgpu_eviction_fence_mgr *evf_mgr,
                                 struct amdgpu_bo *bo);
 void amdgpu_evf_mgr_init(struct amdgpu_eviction_fence_mgr *evf_mgr);
 void amdgpu_evf_mgr_shutdown(struct amdgpu_eviction_fence_mgr *evf_mgr);
+void amdgpu_evf_mgr_flush_suspend(struct amdgpu_eviction_fence_mgr *evf_mgr);
 void amdgpu_evf_mgr_fini(struct amdgpu_eviction_fence_mgr *evf_mgr);
 
 #endif
index 8f8e7c9253171aa21446f3a43f00f64498e1a6df..b63e17fc73d73ce0fa6f2280c73df0bf18b56900 100644 (file)
@@ -1345,6 +1345,11 @@ int amdgpu_userq_mgr_init(struct amdgpu_userq_mgr *userq_mgr, struct drm_file *f
        return 0;
 }
 
+void amdgpu_userq_mgr_cancel_resume(struct amdgpu_userq_mgr *userq_mgr)
+{
+       cancel_delayed_work_sync(&userq_mgr->resume_work);
+}
+
 void amdgpu_userq_mgr_fini(struct amdgpu_userq_mgr *userq_mgr)
 {
        struct amdgpu_usermode_queue *queue;
index 82306d48906463fe59346ab78ba7181e7b7bcc72..f0abc16d02cce0ef7dbf23332230da87c68ec626 100644 (file)
@@ -123,6 +123,7 @@ int amdgpu_userq_ioctl(struct drm_device *dev, void *data, struct drm_file *filp
 int amdgpu_userq_mgr_init(struct amdgpu_userq_mgr *userq_mgr, struct drm_file *file_priv,
                          struct amdgpu_device *adev);
 
+void amdgpu_userq_mgr_cancel_resume(struct amdgpu_userq_mgr *userq_mgr);
 void amdgpu_userq_mgr_fini(struct amdgpu_userq_mgr *userq_mgr);
 
 int amdgpu_userq_create_object(struct amdgpu_userq_mgr *uq_mgr,