drm/amdgpu: fix userq resource double freed
Subsystems (2)
PATCH 1/1 drm/amdgpu: fix userq resource double freed
As the userq resource was already freed at the drm_release early phase, it should avoid freeing userq resource again at the later kms postclose callback.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +5 -4
@@ -1502,10 +1502,11 @@ 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); - +if (!fpriv->evf_mgr.fd_closing) { + 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);
Signature · 1 line
2.34.1
[AMD Official Use Only - AMD Internal Distribution Only]
This patch fixed a similar problem for me.
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Prike Liang
Sent: Monday, May 12, 2025 3:30 PM
To: [email protected]
Cc: Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>; Liang, Prike <[email protected]>
Subject: [PATCH] drm/amdgpu: fix userq resource double freed
As the userq resource was already freed at the drm_release early phase, it should avoid freeing userq resource again at the later kms postclose callback.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +5 -4
@@ -1502,10 +1502,11 @@ 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); - +if (!fpriv->evf_mgr.fd_closing) { + 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
Christian König
maintainerQuoted 3 lines · Prike Liang
As the userq resource was already freed at the
drm_releaseearly phase, it should avoid freeing userq resource again at the later kms postclose callback.
Clear NAK. You are just hiding a bug.
The userq resources should always be only cleaned up here and that function can't be called twice.
Regards,
Christian.
Quoted 26 lines
Signed-off-by Prike Liang <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +5
-4@@ -1502,10 +1502,11 @@ 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); - +if (!fpriv->evf_mgr.fd_closing) { + 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);
[AMD Official Use Only - AMD Internal Distribution Only]
Quoted 7 lines
From: Koenig, Christian <[email protected]>
Sent: Wednesday, May 14, 2025 3:02 PM
To: Liang, Prike <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>
Subject: Re: [PATCH] drm/amdgpu: fix userq resource double freedOn 5/12/25 09:30, Prike Liang wrote:
Quoted 8 lines
Quoted 3 lines
As the userq resource was already freed at the
drm_releaseearly phase, it should avoid freeing userq resource again at the later kms postclose callback.Clear NAK. You are just hiding a bug.
The userq resources should always be only cleaned up here and that function can't be called twice.
The original issue is that the userq resource is freed first at amdgpu_drm_release(), and then second freed at amdgpu_driver_postclose_km(). At this point, it's more reasonable to remove the userq resource cleanup at drm file release phase and just keep freeing the userq resource at postclose moment?
Quoted 32 lines
Regards,
Christian.drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c void amdgpu_driver_postclose_kms(struct
Quoted 12 lines
Signed-off-by Prike Liang <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +0
-0@@ -1502,10 +1502,11 @@ void amdgpu_driver_postclose_kms(struct
drm_device*dev,Quoted 15 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +5
-4amdgpu_bo_unreserve (pd); } - fpriv->evf_mgr.fd_closing = true; -amdgpu_userq_mgr_fini (&fpriv->userq_mgr); -amdgpu_eviction_fence_destroy (&fpriv->evf_mgr); - +if (!fpriv->evf_mgr.fd_closing) { + 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);
Christian König
maintainerQuoted 13 lines · Prike
[AMD Official Use Only - AMD Internal Distribution Only]
Quoted 11 lines
From: Koenig, Christian <[email protected]>
Sent: Wednesday, May 14, 2025 3:02 PM
To: Liang, Prike <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>
Subject: Re: [PATCH] drm/amdgpu: fix userq resource double freedQuoted 3 lines · Prike Liang
As the userq resource was already freed at the
drm_releaseearly phase, it should avoid freeing userq resource again at the later kms postclose callback.
Quoted 6 lines
Quoted 4 lines
Clear NAK. You are just hiding a bug.
The userq resources should always be only cleaned up here and that function can't be called twice.
The original issue is that the userq resource is freed first at
amdgpu_drm_release(), and then second freed atamdgpu_driver_postclose_km(). At this point, it's more reasonable to remove the userq resource cleanup at drm file release phase and just keep freeing the userq resource at postclose moment?
Ah! In that case this code here should just be removed.
Regards,
Christian.
Quoted 34 lines
Quoted 33 lines
Regards,
Christian.drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c void amdgpu_driver_postclose_kms(struct
Quoted 12 lines
Signed-off-by Prike Liang <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +0
-0@@ -1502,10 +1502,11 @@ void amdgpu_driver_postclose_kms(struct
drm_device*dev,Quoted 15 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +5
-4amdgpu_bo_unreserve (pd); } - fpriv->evf_mgr.fd_closing = true; -amdgpu_userq_mgr_fini (&fpriv->userq_mgr); -amdgpu_eviction_fence_destroy (&fpriv->evf_mgr); - +if (!fpriv->evf_mgr.fd_closing) { + 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);