<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<p style="font-family:Calibri;font-size:10pt;color:#0000FF;margin:5pt;font-style:normal;font-weight:normal;text-decoration:none;" align="Left">
[AMD Official Use Only - AMD Internal Distribution Only]<br>
</p>
<br>
<div>
<div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
Please feel free to use:</div>
<div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
Reviewed-by: Shashank Sharma <shashank.sharma@amd.com></div>
<div id="appendonsend" style="color: inherit;"></div>
<div style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
<br>
</div>
<div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
Regards</div>
<div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
Shashank</div>
<hr style="display: inline-block; width: 98%;">
<div dir="ltr" id="divRplyFwdMsg" style="color: inherit;"><span style="font-family: Calibri, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);"><b>From:</b> Yadav, Arvind <Arvind.Yadav@amd.com><br>
<b>Sent:</b> Monday, December 23, 2024 4:34 PM<br>
<b>To:</b> Koenig, Christian <Christian.Koenig@amd.com>; Sharma, Shashank <Shashank.Sharma@amd.com>; Deucher, Alexander <Alexander.Deucher@amd.com><br>
<b>Cc:</b> amd-gfx@lists.freedesktop.org <amd-gfx@lists.freedesktop.org>; Yadav, Arvind <Arvind.Yadav@amd.com>; Koenig, Christian <Christian.Koenig@amd.com>; Yadav, Arvind <Arvind.Yadav@amd.com><br>
<b>Subject:</b> [PATCH v2] drm/amdgpu: Fix Illegal opcode in command stream Error</span>
<div> </div>
</div>
<div style="font-size: 11pt;">When applications closes, it triggers the drm_file_free<br>
function which subsequently releases all allocated buffer<br>
objects. Concurrently, the resume_worker thread will attempt<br>
to map the usermode queue. However, since the wptr buffer<br>
object has already been deallocated, this will result in<br>
an Illegal opcode error being raised in the command stream.<br>
<br>
Now replacing drm_release() with a new function<br>
amdgpu_drm_release(). This function will set the flag to<br>
prevent the scheduling of any new queue resume/map, stop<br>
all queues and then call drm_release().<br>
<br>
V2:<br>
- Replace drm_release with amdgpu_drm_release(Christian).<br>
<br>
Cc: Alex Deucher <alexander.deucher@amd.com><br>
Cc: Christian Koenig <christian.koenig@amd.com><br>
Cc: Shashank Sharma <shashank.sharma@amd.com><br>
Signed-off-by: Arvind Yadav <arvind.yadav@amd.com><br>
---<br>
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 16 +++++++++++++++-<br>
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 4 ----<br>
2 files changed, 15 insertions(+), 5 deletions(-)<br>
<br>
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c<br>
index 62de668e9ff8..acb9dc3705ac 100644<br>
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c<br>
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c<br>
@@ -2794,6 +2794,20 @@ static int amdgpu_pmops_runtime_idle(struct device *dev)<br>
return ret;<br>
}<br>
<br>
+static int amdgpu_drm_release(struct inode *inode, struct file *filp)<br>
+{<br>
+ struct drm_file *file_priv = filp->private_data;<br>
+ struct amdgpu_fpriv *fpriv = file_priv->driver_priv;<br>
+<br>
+ if (fpriv) {<br>
+ fpriv->evf_mgr.fd_closing = true;<br>
+ amdgpu_userq_mgr_fini(&fpriv->userq_mgr);<br>
+ amdgpu_eviction_fence_destroy(&fpriv->evf_mgr);<br>
+ }<br>
+<br>
+ return drm_release(inode, filp);<br>
+}<br>
+<br>
long amdgpu_drm_ioctl(struct file *filp,<br>
unsigned int cmd, unsigned long arg)<br>
{<br>
@@ -2845,7 +2859,7 @@ static const struct file_operations amdgpu_driver_kms_fops = {<br>
.owner = THIS_MODULE,<br>
.open = drm_open,<br>
.flush = amdgpu_flush,<br>
- .release = drm_release,<br>
+ .release = amdgpu_drm_release,<br>
.unlocked_ioctl = amdgpu_drm_ioctl,<br>
.mmap = drm_gem_mmap,<br>
.poll = drm_poll,<br>
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c<br>
index d2a046736edd..f908355df07c 100644<br>
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c<br>
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c<br>
@@ -1478,10 +1478,6 @@ void amdgpu_driver_postclose_kms(struct drm_device *dev,<br>
amdgpu_bo_unreserve(pd);<br>
}<br>
<br>
- fpriv->evf_mgr.fd_closing = true;<br>
- amdgpu_userq_mgr_fini(&fpriv->userq_mgr);<br>
- amdgpu_eviction_fence_destroy(&fpriv->evf_mgr);<br>
-<br>
amdgpu_ctx_mgr_fini(&fpriv->ctx_mgr);<br>
amdgpu_vm_fini(adev, &fpriv->vm);<br>
<br>
--<br>
2.34.1<br>
<br>
</div>
</div>
</body>
</html>