Re: [PATCH v2] drm/amdgpu: Fix Illegal opcode in command stream Error

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



[AMD Official Use Only - AMD Internal Distribution Only]


Please feel free to use:
Reviewed-by: Shashank Sharma <shashank.sharma@xxxxxxx>

Regards
Shashank

From: Yadav, Arvind <Arvind.Yadav@xxxxxxx>
Sent: Monday, December 23, 2024 4:34 PM
To: Koenig, Christian <Christian.Koenig@xxxxxxx>; Sharma, Shashank <Shashank.Sharma@xxxxxxx>; Deucher, Alexander <Alexander.Deucher@xxxxxxx>
Cc: amd-gfx@xxxxxxxxxxxxxxxxxxxxx <amd-gfx@xxxxxxxxxxxxxxxxxxxxx>; Yadav, Arvind <Arvind.Yadav@xxxxxxx>; Koenig, Christian <Christian.Koenig@xxxxxxx>; Yadav, Arvind <Arvind.Yadav@xxxxxxx>
Subject: [PATCH v2] drm/amdgpu: Fix Illegal opcode in command stream Error
 
When applications closes, it triggers the drm_file_free
function which subsequently releases all allocated buffer
objects. Concurrently, the resume_worker thread will attempt
to map the usermode queue. However, since the wptr buffer
object has already been deallocated, this will result in
an Illegal opcode error being raised in the command stream.

Now replacing drm_release() with a new function
amdgpu_drm_release(). This function will set the flag to
prevent the scheduling of any new queue resume/map, stop
all queues and then call drm_release().

V2:
  - Replace drm_release with amdgpu_drm_release(Christian).

Cc: Alex Deucher <alexander.deucher@xxxxxxx>
Cc: Christian Koenig <christian.koenig@xxxxxxx>
Cc: Shashank Sharma <shashank.sharma@xxxxxxx>
Signed-off-by: Arvind Yadav <arvind.yadav@xxxxxxx>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 16 +++++++++++++++-
 drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c |  4 ----
 2 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
index 62de668e9ff8..acb9dc3705ac 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
@@ -2794,6 +2794,20 @@ static int amdgpu_pmops_runtime_idle(struct device *dev)
         return ret;
 }
 
+static int amdgpu_drm_release(struct inode *inode, struct file *filp)
+{
+       struct drm_file *file_priv = filp->private_data;
+       struct amdgpu_fpriv *fpriv = file_priv->driver_priv;
+
+       if (fpriv) {
+               fpriv->evf_mgr.fd_closing = true;
+               amdgpu_userq_mgr_fini(&fpriv->userq_mgr);
+               amdgpu_eviction_fence_destroy(&fpriv->evf_mgr);
+       }
+
+       return drm_release(inode, filp);
+}
+
 long amdgpu_drm_ioctl(struct file *filp,
                       unsigned int cmd, unsigned long arg)
 {
@@ -2845,7 +2859,7 @@ static const struct file_operations amdgpu_driver_kms_fops = {
         .owner = THIS_MODULE,
         .open = drm_open,
         .flush = amdgpu_flush,
-       .release = drm_release,
+       .release = amdgpu_drm_release,
         .unlocked_ioctl = amdgpu_drm_ioctl,
         .mmap = drm_gem_mmap,
         .poll = drm_poll,
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
index d2a046736edd..f908355df07c 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
@@ -1478,10 +1478,6 @@ void amdgpu_driver_postclose_kms(struct drm_device *dev,
                 amdgpu_bo_unreserve(pd);
         }
 
-       fpriv->evf_mgr.fd_closing = true;
-       amdgpu_userq_mgr_fini(&fpriv->userq_mgr);
-       amdgpu_eviction_fence_destroy(&fpriv->evf_mgr);
-
         amdgpu_ctx_mgr_fini(&fpriv->ctx_mgr);
         amdgpu_vm_fini(adev, &fpriv->vm);
 
--
2.34.1


[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux