Skip to contentSkip to conversation

drm/amdgpu/gfx12: assign all KCQs to pipe0 MES slots at ring init

PATCH New Jesse Zhang 1 participant 2 messages Mar 27

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

PATCH v2 1/2 drm/amdgpu/gfx12: assign all KCQs to pipe0 MES slots at ring init

when suspend_all_gangs is issued to pipe0 MES during
system suspend or runtime PM, pipe0 can only suspend and resume queues it has tracked. KCQs registered with a non-zero pipe slot may not be correctly handled, leaving them in an inconsistent state after resume.

---
 drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c | 22 +++++++++++++++++++---
 1 file changed, 19 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c +19 -3
index a418ae609c36..d99757e06738 100644
@@ -1007,8 +1007,19 @@ static int gfx_v12_0_compute_ring_init(struct amdgpu_device *adev, int ring_id,
 
 	/* mec0 is me1 */
 	ring->me = mec + 1;
-	ring->pipe = pipe;
-	ring->queue = queue;
+
+	/*
+	 * Assign all KCQs to pipe0 slots sequentially by ring_id so there
+	 * are no slot conflicts and pipe0 MES can correctly suspend and
+	 * resume all KCQs via suspend_all_gangs.
+	 */
+	if (ring_id < adev->gfx.mec.num_queue_per_pipe) {
+		ring->pipe  = AMDGPU_MES_SCHED_PIPE;
+		ring->queue = ring_id;
+	} else {
+		ring->pipe = pipe;
+		ring->queue = queue;
+	}
 
 	ring->ring_obj = NULL;
 	ring->use_doorbell = true;
@@ -1018,9 +1029,14 @@ static int gfx_v12_0_compute_ring_init(struct amdgpu_device *adev, int ring_id,
 	ring->vm_hub = AMDGPU_GFXHUB(0);
 	sprintf(ring->name, "comp_%d.%d.%d", ring->me, ring->pipe, ring->queue);
 
+	/*
+	 * The EOP interrupt is wired to the physical hardware pipe, not the
+	 * MES pipe slot. Use the original 'pipe' argument for irq_type, as
+	 * ring->pipe may have been remapped to AMDGPU_MES_SCHED_PIPE above.
+	 */
 	irq_type = AMDGPU_CP_IRQ_COMPUTE_MEC1_PIPE0_EOP
 		+ ((ring->me - 1) * adev->gfx.mec.num_pipe_per_mec)
-		+ ring->pipe;
+		+ pipe;
 	hw_prio = amdgpu_gfx_is_high_priority_compute_queue(adev, ring) ?
 			AMDGPU_GFX_PIPE_PRIO_HIGH : AMDGPU_GFX_PIPE_PRIO_NORMAL;
 	/* type-2 packets are deprecated on MEC, use type-3 instead */
Signature · 1 line
2.49.0
#1 lore raw

PATCH v2 2/2 drm/amdgpu/gfx12_1: assign all KCQs to pipe0 MES slots at ring init

when suspend_all_gangs is issued to pipe0 MES during
system suspend or runtime PM, pipe0 can only suspend and resume queues it has tracked. KCQs registered with a non-zero pipe slot may not be correctly handled, leaving them in an inconsistent state after resume.

---
 drivers/gpu/drm/amd/amdgpu/gfx_v12_1.c | 22 +++++++++++++++++++---
 1 file changed, 19 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v12_1.c +19 -3
index db49582a211f..2df83e06cb31 100644
@@ -777,8 +777,19 @@ static int gfx_v12_1_compute_ring_init(struct amdgpu_device *adev, int ring_id,
 	/* mec0 is me1 */
 	ring->xcc_id = xcc_id;
 	ring->me = mec + 1;
-	ring->pipe = pipe;
-	ring->queue = queue;
+
+	/*
+	 * Assign all KCQs to pipe0 slots sequentially by ring_id so there
+	 * are no slot conflicts and pipe0 MES can correctly suspend and
+	 * resume all KCQs via suspend_all_gangs.
+	 */
+	if (ring_id < adev->gfx.mec.num_queue_per_pipe) {
+		ring->pipe  = AMDGPU_MES_SCHED_PIPE;
+		ring->queue = ring_id;
+	} else {
+		ring->pipe  = pipe;
+		ring->queue = queue;
+	}
 
 	ring->ring_obj = NULL;
 	ring->use_doorbell = true;
@@ -792,9 +803,14 @@ static int gfx_v12_1_compute_ring_init(struct amdgpu_device *adev, int ring_id,
 	sprintf(ring->name, "comp_%d.%d.%d.%d",
 			ring->xcc_id, ring->me, ring->pipe, ring->queue);
 
+	/*
+	 * The EOP interrupt is wired to the physical hardware pipe, not the
+	 * MES pipe slot. Use the original 'pipe' argument for irq_type, as
+	 * ring->pipe may have been remapped to AMDGPU_MES_SCHED_PIPE above.
+	 */
 	irq_type = AMDGPU_CP_IRQ_COMPUTE_MEC1_PIPE0_EOP
 		+ ((ring->me - 1) * adev->gfx.mec.num_pipe_per_mec)
-		+ ring->pipe;
+		+ pipe;
 	hw_prio = amdgpu_gfx_is_high_priority_compute_queue(adev, ring) ?
 			AMDGPU_GFX_PIPE_PRIO_HIGH : AMDGPU_GFX_PIPE_PRIO_NORMAL;
 	/* type-2 packets are deprecated on MEC, use type-3 instead */
Signature · 1 line
2.49.0