Skip to contentSkip to conversation

lib/amdgpu: Use correct GFX doorbell offset for userqueues

PATCH In review Jesse Zhang 2 participants 2 messages Jun 5

lore
Share & tools
lore
#0 lore raw

PATCH 2/3 lib/amdgpu: Use correct GFX doorbell offset for userqueues

GFX UMQ doorbell writes target the per-page sub-aperture starting at dword 0x11A within any 4K doorbell page (see AMDGPU_NAVI10_DOORBELL_GFX_USERQUEUE_START in drivers/gpu/drm/amd/amdgpu/amdgpu_doorbell.h). In qword units that is 0x08D, the canonical slot for a GFX user-mode queue.

---
 lib/amdgpu/amd_ip_blocks.c | 14 ++++++++++----
 lib/amdgpu/amd_ip_blocks.h |  3 +++
 2 files changed, 13 insertions(+), 4 deletions(-)
lib/amdgpu/amd_ip_blocks.c +10 -4
index b44441d0d..b56fb68b8 100644
@@ -748,11 +748,17 @@ user_queue_submit(amdgpu_device_handle device, struct amdgpu_ring_context *ring_
 #if DETECT_CC_GCC && (DETECT_ARCH_X86 || DETECT_ARCH_X86_64)
 	asm volatile ("mfence" : : : "memory");
 #endif
-	if (ip_type == AMD_IP_DMA) {
-		/* Ring the SDMA doorbell at the page-modulo SDMA sub-aperture. */
+	/* Ring at the engine's per-page UMQ sub-aperture (see amd_ip_blocks.h). */
+	switch (ip_type) {
+	case AMD_IP_DMA:
 		ring_context->doorbell_cpu[SDMA_DOORBELL_INDEX] = *ring_context->wptr_cpu;
-	} else {
+		break;
+	case AMD_IP_GFX:
+		ring_context->doorbell_cpu[GFX_DOORBELL_INDEX] = *ring_context->wptr_cpu;
+		break;
+	default:
 		ring_context->doorbell_cpu[DOORBELL_INDEX] = *ring_context->wptr_cpu;
+		break;
 	}
 
 	switch (ring_context->submit_mode) {
@@ -994,7 +1000,7 @@ user_queue_create(amdgpu_device_handle device_handle, struct amdgpu_ring_context
 	switch (type) {
 	case AMD_IP_GFX:
 		r = amdgpu_create_userqueue(device_handle, AMDGPU_HW_IP_GFX,
-					    ctxt->db_handle, DOORBELL_INDEX,
+					    ctxt->db_handle, GFX_DOORBELL_INDEX,
 					    ctxt->queue.mc_addr, USERMODE_QUEUE_SIZE,
 					    ctxt->wptr.mc_addr, ctxt->rptr.mc_addr,
 					    mqd, queue_flags, &ctxt->queue_id);
lib/amdgpu/amd_ip_blocks.h +3 -0
index e26ee68a9..2adea2f58 100644
@@ -63,6 +63,9 @@
 /* SDMA per-page sub-aperture starts at dword 0x200 within any 4K page.
  * In qword units (USERQ doorbell_offset is qword-indexed): 0x100. */
 #define SDMA_DOORBELL_INDEX		0x100
+/* GFX UMQ per-page sub-aperture starts at dword 0x11A within any 4K page
+ * (gfx_userqueue_start in amdgpu_doorbell.h). In qword units: 0x08D. */
+#define GFX_DOORBELL_INDEX		0x08D
 #define USERMODE_QUEUE_SIZE_DW		(USERMODE_QUEUE_SIZE >> 2)
 #define USERMODE_QUEUE_SIZE_DW_MASK	(USERMODE_QUEUE_SIZE_DW - 1)
 
Signature · 1 line
2.49.0
#1 lore raw

LGTM, Reviewed-by: Vitaly Prosyak <[email protected]>

Quoted 60 lines · Jesse Zhang

GFX UMQ doorbell writes target the per-page sub-aperture starting at dword 0x11A within any 4K doorbell page (see AMDGPU_NAVI10_DOORBELL_GFX_USERQUEUE_START in drivers/gpu/drm/amd/amdgpu/amdgpu_doorbell.h). In qword units that is 0x08D, the canonical slot for a GFX user-mode queue.

---
 lib/amdgpu/amd_ip_blocks.c | 14 ++++++++++----
 lib/amdgpu/amd_ip_blocks.h |  3 +++
 2 files changed, 13 insertions(+), 4 deletions(-)
lib/amdgpu/amd_ip_blocks.c +10 -4
index b44441d0d..b56fb68b8 100644
@@ -748,11 +748,17 @@ user_queue_submit(amdgpu_device_handle device, struct amdgpu_ring_context *ring_
 #if DETECT_CC_GCC && (DETECT_ARCH_X86 || DETECT_ARCH_X86_64)
 	asm volatile ("mfence" : : : "memory");
 #endif
-	if (ip_type == AMD_IP_DMA) {
-		/* Ring the SDMA doorbell at the page-modulo SDMA sub-aperture. */
+	/* Ring at the engine's per-page UMQ sub-aperture (see amd_ip_blocks.h). */
+	switch (ip_type) {
+	case AMD_IP_DMA:
 		ring_context->doorbell_cpu[SDMA_DOORBELL_INDEX] = *ring_context->wptr_cpu;
-	} else {
+		break;
+	case AMD_IP_GFX:
+		ring_context->doorbell_cpu[GFX_DOORBELL_INDEX] = *ring_context->wptr_cpu;
+		break;
+	default:
 		ring_context->doorbell_cpu[DOORBELL_INDEX] = *ring_context->wptr_cpu;
+		break;
 	}
 
 	switch (ring_context->submit_mode) {
@@ -994,7 +1000,7 @@ user_queue_create(amdgpu_device_handle device_handle, struct amdgpu_ring_context
 	switch (type) {
 	case AMD_IP_GFX:
 		r = amdgpu_create_userqueue(device_handle, AMDGPU_HW_IP_GFX,
-					    ctxt->db_handle, DOORBELL_INDEX,
+					    ctxt->db_handle, GFX_DOORBELL_INDEX,
 					    ctxt->queue.mc_addr, USERMODE_QUEUE_SIZE,
 					    ctxt->wptr.mc_addr, ctxt->rptr.mc_addr,
 					    mqd, queue_flags, &ctxt->queue_id);
lib/amdgpu/amd_ip_blocks.h +3 -0
index e26ee68a9..2adea2f58 100644
@@ -63,6 +63,9 @@
 /* SDMA per-page sub-aperture starts at dword 0x200 within any 4K page.
  * In qword units (USERQ doorbell_offset is qword-indexed): 0x100. */
 #define SDMA_DOORBELL_INDEX		0x100
+/* GFX UMQ per-page sub-aperture starts at dword 0x11A within any 4K page
+ * (gfx_userqueue_start in amdgpu_doorbell.h). In qword units: 0x08D. */
+#define GFX_DOORBELL_INDEX		0x08D
 #define USERMODE_QUEUE_SIZE_DW		(USERMODE_QUEUE_SIZE >> 2)
 #define USERMODE_QUEUE_SIZE_DW_MASK	(USERMODE_QUEUE_SIZE_DW - 1)