[AMD Official Use Only - AMD Internal Distribution Only] > From: Koenig, Christian <christian.koe...@amd.com> > Sent: Wednesday, May 14, 2025 3:02 PM > To: Liang, Prike <prike.li...@amd.com>; amd-gfx@lists.freedesktop.org > Cc: Deucher, Alexander <alexander.deuc...@amd.com> > Subject: Re: [PATCH] drm/amdgpu: fix userq resource double freed > > On 5/12/25 09:30, Prike Liang wrote: > > 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. > > 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?
> > Regards, > Christian. > > > > > Signed-off-by: Prike Liang <prike.li...@amd.com> > > --- > > drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 9 +++++---- > > 1 file changed, 5 insertions(+), 4 deletions(-) > > > > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c > > b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c > > index 8d4a2aed7231..cf0f35a7daee 100644 > > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c > > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c > > @@ -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); > >