On Fri, Sep 19, 2025 at 4:19 AM Prike Liang <[email protected]> wrote:
>
> It requires validating the userq VA whether is mapped before
> trying to resume the queue.
>
> Signed-off-by: Prike Liang <[email protected]>
> Reviewed-by: Christian König <[email protected]>
> Reviewed-by: Alex Deucher <[email protected]>
> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c | 29 ++++++++++++++++++++++-
>  1 file changed, 28 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c 
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c
> index 9cdb82c13a34..402145d64714 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c
> @@ -116,8 +116,27 @@ static bool amdgpu_userq_buffer_va_mapped(struct 
> amdgpu_vm *vm, u64 addr)
>         return r;
>  }
>
> +static bool amdgpu_userq_buffer_vas_mapped(struct amdgpu_usermode_queue 
> *queue)
> +{
> +       struct amdgpu_userq_va_cursor *va_cursor, *tmp;
> +       int r;
> +
> +       list_for_each_entry_safe(va_cursor, tmp, &queue->userq_va_list, list) 
> {
> +               r += amdgpu_userq_buffer_va_mapped(queue->vm, 
> va_cursor->gpu_addr);
> +               dev_dbg(queue->userq_mgr->adev->dev,
> +                       "validate the userq mapping:%p va:%llx r:%d\n",
> +                       queue, va_cursor->gpu_addr, r);
> +       }
> +
> +       if (r != 0)
> +               return true;
> +
> +       return false;
> +}
> +
>  static void amdgpu_userq_buffer_va_list_del(struct amdgpu_bo_va_mapping 
> *mapping,
>                                            struct amdgpu_userq_va_cursor 
> *va_cursor)
> +
>  {
>         atomic_set(&mapping->bo_va->userq_va_mapped, 0);
>         list_del(&va_cursor->list);
> @@ -778,7 +797,15 @@ amdgpu_userq_restore_all(struct amdgpu_userq_mgr *uq_mgr)
>
>         /* Resume all the queues for this process */
>         idr_for_each_entry(&uq_mgr->userq_idr, queue, queue_id) {
> -               r = amdgpu_userq_restore_helper(uq_mgr, queue);
> +
> +               if (!amdgpu_userq_buffer_vas_mapped(queue)) {
> +                       drm_file_err(uq_mgr->file,
> +                                    "trying restore queue without va 
> mapping\n");
> +                       queue->state = AMDGPU_USERQ_STATE_INVALID_VA;
> +                       continue;
> +               }
> +
> +               r = amdgpu_userq_map_helper(uq_mgr, queue);

Looks like a rebasing issue here.  This should be
amdgpu_userq_restore_helper().  WIth that fixed:
Reviewed-by: Alex Deucher <[email protected]>


Alex

>                 if (r)
>                         ret = r;
>         }
> --
> 2.34.1
>

Reply via email to