Validated the patch for any regressions.
Reviewed-by: Sunil Khatri <[email protected]>

On 11-03-2026 05:56 pm, Khatri, Sunil wrote:

On 11-03-2026 12:43 am, Christian König wrote:
That is a really complicated dance and wasn't implemented fully correct.

Signed-off-by: Christian König <[email protected]>
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c            | 2 ++
  drivers/gpu/drm/amd/amdgpu/amdgpu_eviction_fence.c | 8 +++++++-
  drivers/gpu/drm/amd/amdgpu/amdgpu_eviction_fence.h | 1 +
  drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c          | 5 +++++
  drivers/gpu/drm/amd/amdgpu/amdgpu_userq.h          | 1 +
  5 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
index 67b8c33d5ee3..d99e80aa3204 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
@@ -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);
since we are doing flush of the suspend work in amdgpu_evf_mgr_flush_suspend, we could get away with the shutdown totally. add the flag of shutdown im flush_suspend or something like that in one function itself.
+ amdgpu_userq_mgr_cancel_resume(&fpriv->userq_mgr);

Should this be the first thing we do even before evf_mgr_shutdown?

Regards
Sunil Khatri

+ 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);
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_eviction_fence.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_eviction_fence.c
index 8fe9f91f9551..ef4da6f2e2a3 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_eviction_fence.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_eviction_fence.c
@@ -146,13 +146,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);
  }
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_eviction_fence.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_eviction_fence.h
index 527de3a23583..132a13a5dc1c 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_eviction_fence.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_eviction_fence.h
@@ -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
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c
index 67ba46851c2b..23e4c5f99f67 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c
@@ -1344,6 +1344,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;
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.h
index 82306d489064..f0abc16d02cc 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.h
@@ -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,

Reply via email to