On 21-Sep-26 11:23 AM, SRINIVASAN SHANMUGAM wrote:

On 9/19/2026 1:34 AM, James Zhu wrote:
amdgpu_userq_input_trap_params_validate() ends up in
amdgpu_userq_input_va_validate(), which walks the VM mapping tree and
updates bo_va->userq_va_mapped, so it requires the caller to hold the
vm->root.bo reservation. The CWSR branch of mes_userq_mqd_create() called
it without that reservation, tripping the dma_resv_assert_held() on every
compute queue creation when trap handling is enabled:

  WARNING: drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c:232 at
  amdgpu_userq_input_va_validate+0xb9/0xd0 [amdgpu]
  Call Trace:
   mes_userq_mqd_create+0x49c/0x9e0 [amdgpu]
   amdgpu_userq_ioctl+0x935/0x1070 [amdgpu]
   drm_ioctl_kernel+0xb3/0x110 [drm]

Bracket the call with amdgpu_bo_reserve()/amdgpu_bo_unreserve() like the
other input VA validations in the same function.

Signed-off-by: James Zhu<[email protected]>
---
  drivers/gpu/drm/amd/amdgpu/mes_userqueue.c | 7 +++++++
  1 file changed, 7 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/mes_userqueue.c 
b/drivers/gpu/drm/amd/amdgpu/mes_userqueue.c
index 2150973b947d..16aa22b25098 100644
--- a/drivers/gpu/drm/amd/amdgpu/mes_userqueue.c
+++ b/drivers/gpu/drm/amd/amdgpu/mes_userqueue.c
@@ -508,7 +508,14 @@ static int mes_userq_mqd_create(struct 
amdgpu_usermode_queue *queue,
                        trap_params.ctx_save_area_address =
                                compute_mqd->ctx_save_area_va;
                        trap_params.cwsr_sz = compute_mqd->ctx_save_area_size;
+
+                       r = amdgpu_bo_reserve(queue->vm->root.bo, false);
+                       if (r) {
+                               kfree(compute_mqd);
+                               goto free_mqd;
+                       }
                        r = amdgpu_userq_input_trap_params_validate(queue, 
&trap_params);
+                       amdgpu_bo_unreserve(queue->vm->root.bo);
                        if (r) {
                                kfree(compute_mqd);
                                goto free_mqd;

The CWSR VA validation accesses shared VM mapping information, so the VM root BO needs to be reserved while doing this. This change adds the missing reservation and avoids the warning during compute queue creation.

Could we also add the corresponding |Fixes:| tag?

|Fixes: 7ca9abf4ac38 ("drm/amdgpu: Add user save area params to mqd input")|

That change happened later
85653fe2e52e drm/amdgpu/userq: hold root bo lock in caller of input_va_validate

But the user save area patch was not available in drm-next that time and probably that's how it missed.

Thanks,
Lijo



Separately, the repeated |vm->root.bo| reserve/unreserve operations in | mes_userq_mqd_create()| could be considered for a follow-up cleanup.

Reviewed-by: Srinivasan Shanmugam <[email protected]>


Reply via email to