On 11/12/26 22:12, Erhan Bilgili wrote:
> USERQ_WAIT adds the driver to fence_drv_xa before taking its
> reference. Once the lock is dropped, USERQ_SIGNAL can remove the
> entry and put the driver before WAIT gets its reference. This can
> free the driver while WAIT is still using it.

The fence is holding the reference to the fence driver so that is completely 
unnecessary.

> 
> Take the reference before dropping fence_drv_lock.
> 

That just unnecessarily complicates the code.

It could be that we change the userq fence so that it doesn't hold the fence 
driver reference in the future, but that would require a completely different 
approach here. 

Regards,
Christian.

> Fixes: a292fdecd728 ("drm/amdgpu: Implement userqueue signal/wait IOCTL")
> Signed-off-by: Erhan Bilgili <[email protected]>
> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c 
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c
> index dd976a50e053..13a339918ee3 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c
> @@ -912,12 +912,12 @@ amdgpu_userq_wait_return_fence_info(struct drm_device 
> *dev, struct drm_file *fil
>               mutex_lock(&waitq->fence_drv_lock);
>               r = xa_alloc(&waitq->fence_drv_xa, &index, fence_drv,
>                            xa_limit_32b, GFP_KERNEL);
> +             if (!r)
> +                     amdgpu_userq_fence_driver_get(fence_drv);
>               mutex_unlock(&waitq->fence_drv_lock);
>               if (r)
>                       goto put_waitq;
>  
> -             amdgpu_userq_fence_driver_get(fence_drv);
> -
>               trace_amdgpu_userq_wait_deps(dev->dev, waitq, userq_fence);
>  
>               /* Store drm syncobj's gpu va address and value */

Reply via email to