Skip to contentSkip to conversation

drm/amdgpu/userq: commit seq64 BO mapping at queue creation

PATCH In review Sunil Khatri 3 participants 4 messages Oct 15 – Oct 16

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/amdgpu/userq: commit seq64 BO mapping at queue creation

The seq64 sync BO's PTE update only ran from the legacy CS path, so userqueue-only clients never got it mapped and their fence_drv could never signal completion. Add support for userqueues too.

Fixes ae05e3f3d02b812c ("drm/amdgpu: move amdgpu_vm_bo_update() call into correct location")
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c +21 -0
index 4dca1ab48410a..44cf25946a21c 100644
@@ -720,6 +720,27 @@ amdgpu_userq_create(struct drm_file *filp, union drm_amdgpu_userq *args)
 	if (r)
 		goto free_fence_drv;
 
+	/* Update the seq64 BO mapping in VM for User Queues */
+	if (fpriv->seq64_va) {
+		struct amdgpu_bo *seq64_bo = fpriv->seq64_va->base.bo;
+
+		r = amdgpu_bo_reserve(seq64_bo, false);
+		if (r) {
+			amdgpu_bo_unreserve(fpriv->vm.root.bo);
+			goto free_fence_drv;
+		}
+
+		r = amdgpu_vm_bo_update(adev, fpriv->seq64_va, false);
+		if (r) {
+			amdgpu_bo_unreserve(seq64_bo);
+			amdgpu_bo_unreserve(fpriv->vm.root.bo);
+			goto free_fence_drv;
+		}
+
+		dma_fence_wait(fpriv->seq64_va->last_pt_update, false);
+		amdgpu_bo_unreserve(seq64_bo);
+	}
+
 	if (amdgpu_userq_input_va_validate(adev, queue, args->in.queue_va,
 					   args->in.queue_size,
 					   &queue->userq_vas.va.queue_rb) ||
Signature · 1 line
2.34.1
#1 lore raw

Ignore please. Sent new patch.

Quoted 42 lines · Sunil Khatri

The seq64 sync BO's PTE update only ran from the legacy CS path, so userqueue-only clients never got it mapped and their fence_drv could never signal completion. Add support for userqueues too.

Fixes ae05e3f3d02b812c ("drm/amdgpu: move amdgpu_vm_bo_update() call into correct location")
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c | 21 +++++++++++++++++++++
  1 file changed, 21 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c +21 -0
index 4dca1ab48410a..44cf25946a21c 100644
@@ -720,6 +720,27 @@ amdgpu_userq_create(struct drm_file *filp, union drm_amdgpu_userq *args)
  	if (r)
  		goto free_fence_drv;
 
+	/* Update the seq64 BO mapping in VM for User Queues */
+	if (fpriv->seq64_va) {
+		struct amdgpu_bo *seq64_bo = fpriv->seq64_va->base.bo;
+
+		r = amdgpu_bo_reserve(seq64_bo, false);
+		if (r) {
+			amdgpu_bo_unreserve(fpriv->vm.root.bo);
+			goto free_fence_drv;
+		}
+
+		r = amdgpu_vm_bo_update(adev, fpriv->seq64_va, false);
+		if (r) {
+			amdgpu_bo_unreserve(seq64_bo);
+			amdgpu_bo_unreserve(fpriv->vm.root.bo);
+			goto free_fence_drv;
+		}
+
+		dma_fence_wait(fpriv->seq64_va->last_pt_update, false);
+		amdgpu_bo_unreserve(seq64_bo);
+	}
+
  	if (amdgpu_userq_input_va_validate(adev, queue, args->in.queue_va,
  					   args->in.queue_size,
  					   &queue->userq_vas.va.queue_rb) ||
#2 lore raw

AMD General

Quoted 50 lines

-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Khatri, Sunil
Sent: Friday, October 16, 2026 10:59 AM
To: Khatri, Sunil <[email protected]>; Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>
Cc: [email protected]
Subject: Re: [PATCH v1] drm/amdgpu/userq: commit seq64 BO mapping at queue creation

Ignore please. Sent new patch.

Quoted 5 lines · Sunil Khatri

The seq64 sync BO's PTE update only ran from the legacy CS path, so userqueue-only clients never got it mapped and their fence_drv could never signal completion. Add support for userqueues too.

Fixes ae05e3f3d02b812c ("drm/amdgpu: move amdgpu_vm_bo_update()

call

Quoted 4 lines

into correct location")

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c | 21

+++++++++++++++++++++

drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c amdgpu_userq_create(struct drm_file *filp, union

Quoted 8 lines
  1 file changed, 21 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c +0 -0
index 4dca1ab48410a..44cf25946a21c 100644
@@ -720,6 +720,27 @@ amdgpu_userq_create(struct drm_file *filp, union

drm_amdgpu_userq *args)

Quoted 16 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c +13 -0
    if (r)
            goto free_fence_drv;
 
+   /* Update the seq64 BO mapping in VM for User Queues */
+   if (fpriv->seq64_va) {
+           struct amdgpu_bo *seq64_bo = fpriv->seq64_va->base.bo;
+
+           r = amdgpu_bo_reserve(seq64_bo, false);
+           if (r) {
+                   amdgpu_bo_unreserve(fpriv->vm.root.bo);
+                   goto free_fence_drv;
+           }
+
+           r = amdgpu_vm_bo_update(adev, fpriv->seq64_va, false);
+           if (r) {
+                   amdgpu_bo_unreserve(seq64_bo);
Quoted 8 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c amdgpu_userq_create(struct drm_file *filp, union drm_amdgpu_userq *args) · line 743

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c +8 -0
+                   amdgpu_bo_unreserve(fpriv->vm.root.bo);
+                   goto free_fence_drv;
+           }
+
+           dma_fence_wait(fpriv->seq64_va->last_pt_update, false);
+           amdgpu_bo_unreserve(seq64_bo);
+   }
+

Hi Sunil,

I noticed two issues in the earlier version that are worth checking in the replacement patch.

The update runs before VM validation. If the VM page tables were evicted before the first USERQ_CREATE, amdgpu_vm_bo_update() can return -EBUSY because vm->evicting is still set. CREATE then exits before reaching amdgpu_userq_ensure_ev_fence(), which would otherwise trigger VM validation and restore.

Also, the root PD is already reserved here. Reserving the seq64 BO with another amdgpu_bo_reserve() uses no shared ww ticket, so it can deadlock against a drm_exec retry that holds seq64 and is waiting for the PD.

Could we update seq64 in amdgpu_userq_vm_validate_and_restore_queue(), after VM validation, with the BO reserved through the existing drm_exec, and wait for its PTE update before restoring the queues? please try the patch: "map the seq64 memory when restoring user queues"
https://lists.freedesktop.org/archives/amd-gfx/2026-October/155022.html

Thanks,
Jesse

Quoted 4 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c amdgpu_userq_create(struct drm_file *filp, union drm_amdgpu_userq *args)

Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c +0 -0
    if (amdgpu_userq_input_va_validate(adev, queue, args->in.queue_va,
                                       args->in.queue_size,
                                       &queue->userq_vas.va.queue_rb)

||

#3 lore raw

AMD General

Yes, I realised that and updated the patch in restore path and pushed it already.

Thanks for pointing.

Regards
Sunil khatri
________________________________
From: Zhang, Jesse(Jie) <[email protected]>
Sent: Friday, 16 October 2026 08:45:34
To: Khatri, Sunil <[email protected]>; Khatri, Sunil <[email protected]>; Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>
Cc: [email protected] <[email protected]>
Subject: RE: [PATCH v1] drm/amdgpu/userq: commit seq64 BO mapping at queue creation

AMD General

Quoted 50 lines

-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Khatri, Sunil
Sent: Friday, October 16, 2026 10:59 AM
To: Khatri, Sunil <[email protected]>; Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>
Cc: [email protected]
Subject: Re: [PATCH v1] drm/amdgpu/userq: commit seq64 BO mapping at queue creation

Ignore please. Sent new patch.

Quoted 5 lines · Sunil Khatri

The seq64 sync BO's PTE update only ran from the legacy CS path, so userqueue-only clients never got it mapped and their fence_drv could never signal completion. Add support for userqueues too.

Fixes ae05e3f3d02b812c ("drm/amdgpu: move amdgpu_vm_bo_update()

call

Quoted 4 lines

into correct location")

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c | 21

+++++++++++++++++++++

drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c amdgpu_userq_create(struct drm_file *filp, union

Quoted 8 lines
  1 file changed, 21 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c +0 -0
index 4dca1ab48410a..44cf25946a21c 100644
@@ -720,6 +720,27 @@ amdgpu_userq_create(struct drm_file *filp, union

drm_amdgpu_userq *args)

Quoted 16 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c +13 -0
    if (r)
            goto free_fence_drv;
 
+   /* Update the seq64 BO mapping in VM for User Queues */
+   if (fpriv->seq64_va) {
+           struct amdgpu_bo *seq64_bo = fpriv->seq64_va->base.bo;
+
+           r = amdgpu_bo_reserve(seq64_bo, false);
+           if (r) {
+                   amdgpu_bo_unreserve(fpriv->vm.root.bo);
+                   goto free_fence_drv;
+           }
+
+           r = amdgpu_vm_bo_update(adev, fpriv->seq64_va, false);
+           if (r) {
+                   amdgpu_bo_unreserve(seq64_bo);
Quoted 8 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c amdgpu_userq_create(struct drm_file *filp, union drm_amdgpu_userq *args) · line 743

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c +8 -0
+                   amdgpu_bo_unreserve(fpriv->vm.root.bo);
+                   goto free_fence_drv;
+           }
+
+           dma_fence_wait(fpriv->seq64_va->last_pt_update, false);
+           amdgpu_bo_unreserve(seq64_bo);
+   }
+

Hi Sunil,

I noticed two issues in the earlier version that are worth checking in the replacement patch.

The update runs before VM validation. If the VM page tables were evicted before the first USERQ_CREATE, amdgpu_vm_bo_update() can return -EBUSY because vm->evicting is still set. CREATE then exits before reaching amdgpu_userq_ensure_ev_fence(), which would otherwise trigger VM validation and restore.

Also, the root PD is already reserved here. Reserving the seq64 BO with another amdgpu_bo_reserve() uses no shared ww ticket, so it can deadlock against a drm_exec retry that holds seq64 and is waiting for the PD.

Could we update seq64 in amdgpu_userq_vm_validate_and_restore_queue(), after VM validation, with the BO reserved through the existing drm_exec, and wait for its PTE update before restoring the queues? please try the patch: "map the seq64 memory when restoring user queues"
https://lists.freedesktop.org/archives/amd-gfx/2026-October/155022.html

Thanks,
Jesse

Quoted 4 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c amdgpu_userq_create(struct drm_file *filp, union drm_amdgpu_userq *args)

Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c +0 -0
    if (amdgpu_userq_input_va_validate(adev, queue, args->in.queue_va,
                                       args->in.queue_size,
                                       &queue->userq_vas.va.queue_rb)

||