RE: [PATCH] drm/amdgpu/userq: skip unmapped queues in amdgpu_userq_wait_for_signal

"Liang, Prike" <[email protected]>
Newsgroups org.freedesktop.lists.amd-gfx
Message-ID <DS7PR12MB60059BF47B5F67E3D576E8F8FBA52@DS7PR12MB6005.namprd12.prod.outlook.com>
AMD General

A dereferenced queue may remain in the XArray. To avoid retrieving an unmapped queue, amdgpu_userq_destroy() should remove the queue from the process's queue XArray first. If there are any other paths that fail to remove dereferenced queues from the XArray, amdgpu_userq_wait_for_last_fence() should also skip those stale entries as a defensive safeguard.

Regards,
      Prike

> -----Original Message-----
> From: Jesse Zhang <[email protected]>
> Sent: Tuesday, August 18, 2026 3:29 PM
> To: [email protected]
> Cc: Deucher, Alexander <[email protected]>; Koenig, Christian
> <[email protected]>; Liang, Prike <[email protected]>; Khatri, Sunil
> <[email protected]>; Zhang, Jesse(Jie) <[email protected]>
> Subject: [PATCH] drm/amdgpu/userq: skip unmapped queues in
> amdgpu_userq_wait_for_signal
>
> amdgpu_userq_wait_for_signal() does an unbounded dma_fence_wait() on every
> queue's last_fence before eviction. A queue disabled via MODIFY with
> queue_percentage == 0 is unmapped but stays in the xarray, and its pending fence
> never signals because the work will not run while the queue is unmapped. Eviction
> then blocks forever, hanging the task and wedging the GPU on a forced reset.
>
> Only wait on fences of queues that are still mapped.
>
> Signed-off-by: Jesse Zhang <[email protected]>
> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c | 10 ++++++++++
>  1 file changed, 10 insertions(+)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c
> index feffebb210ea..cfbfecb05768 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c
> @@ -1302,6 +1302,16 @@ amdgpu_userq_wait_for_signal(struct
> amdgpu_userq_mgr *uq_mgr)
>               if (!f)
>                       continue;
>
> +             /*
> +              * Only a mapped queue can make progress on its fences. A queue
> +              * that has been unmapped (e.g. disabled through a MODIFY with
> +              * queue_percentage == 0) will never execute its pending work,
> +              * so its last_fence would never signal. Waiting on it here would
> +              * block the eviction path forever, so skip such queues.
> +              */
> +             if (queue->state != AMDGPU_USERQ_STATE_MAPPED)
> +                     continue;
> +
>               dma_fence_wait(f, false);
>       }
>  }
> --
> 2.49.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.