Skip to contentSkip to conversation

drm/amdgpu/gfx11: Implement the GFX11 KGQ pipe reset

PATCH Superseded Prike Liang 2 participants 10 messages Jan 26, 2025 – Feb 21, 2025

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/4 drm/amdgpu/gfx11: Implement the GFX11 KGQ pipe reset

Implement the kernel graphics queue pipe reset,and the driver will fallback to pipe reset when the queue reset fails. However, the ME FW hasn't fully supported pipe reset yet so disable the KGQ pipe reset temporarily.

---
 drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c | 76 +++++++++++++++++++++++++-
 1 file changed, 74 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +74 -2
index 89d17750af04..395872bb1401 100644
@@ -65,6 +65,8 @@
 #define regPC_CONFIG_CNTL_1		0x194d
 #define regPC_CONFIG_CNTL_1_BASE_IDX	1
 
+static uint32_t me_fw_start_pc;
+
 MODULE_FIRMWARE("amdgpu/gc_11_0_0_pfp.bin");
 MODULE_FIRMWARE("amdgpu/gc_11_0_0_me.bin");
 MODULE_FIRMWARE("amdgpu/gc_11_0_0_mec.bin");
@@ -2932,6 +2934,9 @@ static void gfx_v11_0_config_gfx_rs64(struct amdgpu_device *adev)
 	tmp = REG_SET_FIELD(tmp, CP_MEC_RS64_CNTL, MEC_PIPE2_RESET, 0);
 	tmp = REG_SET_FIELD(tmp, CP_MEC_RS64_CNTL, MEC_PIPE3_RESET, 0);
 	WREG32_SOC15(GC, 0, regCP_MEC_RS64_CNTL, tmp);
+
+	/* cache the firmware start PC */
+	me_fw_start_pc = RREG32(SOC15_REG_OFFSET(GC, 0, regCP_GFX_RS64_INSTR_PNTR1));
 }
 
 static int gfx_v11_0_wait_for_rlc_autoload_complete(struct amdgpu_device *adev)
@@ -6654,6 +6659,68 @@ static void gfx_v11_0_emit_mem_sync(struct amdgpu_ring *ring)
 	amdgpu_ring_write(ring, gcr_cntl); /* GCR_CNTL */
 }
 
+static bool gfx_v11_pipe_reset_support(struct amdgpu_device *adev)
+{
+	/* Disable the pipe reset until the CPFW fully support it.*/
+	dev_warn_once(adev->dev, "The CPFW hasn't support pipe reset yet.\n");
+	return false;
+}
+
+
+static int gfx_v11_reset_gfx_pipe(struct amdgpu_ring *ring)
+{
+	struct amdgpu_device *adev = ring->adev;
+	uint32_t reset_pipe = 0, clean_pipe = 0;
+	int r;
+
+	if (!gfx_v11_pipe_reset_support(adev))
+		return -EOPNOTSUPP;
+
+	gfx_v11_0_set_safe_mode(adev, 0);
+	mutex_lock(&adev->srbm_mutex);
+	soc21_grbm_select(adev, ring->me, ring->pipe, ring->queue, 0);
+
+	switch (ring->pipe) {
+	case 0:
+		reset_pipe = REG_SET_FIELD(reset_pipe, CP_ME_CNTL,
+					   PFP_PIPE0_RESET, 1);
+		reset_pipe = REG_SET_FIELD(reset_pipe, CP_ME_CNTL,
+					   ME_PIPE0_RESET, 1);
+		clean_pipe = REG_SET_FIELD(clean_pipe, CP_ME_CNTL,
+					   PFP_PIPE0_RESET, 0);
+		clean_pipe = REG_SET_FIELD(clean_pipe, CP_ME_CNTL,
+					   ME_PIPE0_RESET, 0);
+		break;
+	case 1:
+		reset_pipe = REG_SET_FIELD(reset_pipe, CP_ME_CNTL,
+					   PFP_PIPE1_RESET, 1);
+		reset_pipe = REG_SET_FIELD(reset_pipe, CP_ME_CNTL,
+					   ME_PIPE1_RESET, 1);
+		clean_pipe = REG_SET_FIELD(clean_pipe, CP_ME_CNTL,
+					   PFP_PIPE1_RESET, 0);
+		clean_pipe = REG_SET_FIELD(clean_pipe, CP_ME_CNTL,
+					   ME_PIPE1_RESET, 0);
+		break;
+	default:
+		break;
+	}
+
+	WREG32_SOC15(GC, 0, regCP_ME_CNTL, reset_pipe);
+	WREG32_SOC15(GC, 0, regCP_ME_CNTL, clean_pipe);
+
+	r = RREG32(SOC15_REG_OFFSET(GC, 0, regCP_GFX_RS64_INSTR_PNTR1)) - me_fw_start_pc;
+	soc21_grbm_select(adev, 0, 0, 0, 0);
+	mutex_unlock(&adev->srbm_mutex);
+	gfx_v11_0_unset_safe_mode(adev, 0);
+
+	dev_info(adev->dev,"The ring %s pipe reset to the ME firmware start PC: %s\n", ring->name,
+			r == 0 ? "successfuly" : "failed");
+	/* FIXME: Sometimes driver can't cache the ME firmware start PC correctly, so the pipe reset status
+	 * relies on the later gfx ring test result.
+	 */
+	return 0;
+}
+
 static int gfx_v11_0_reset_kgq(struct amdgpu_ring *ring, unsigned int vmid)
 {
 	struct amdgpu_device *adev = ring->adev;
@@ -6663,8 +6730,13 @@ static int gfx_v11_0_reset_kgq(struct amdgpu_ring *ring, unsigned int vmid)
 		return -EINVAL;
 
 	r = amdgpu_mes_reset_legacy_queue(ring->adev, ring, vmid, false);
-	if (r)
-		return r;
+	if (r) {
+
+		dev_warn(adev->dev,"reset via MES failed and try pipe reset %d\n", r);
+		r = gfx_v11_reset_gfx_pipe(ring);
+		if (r)
+			return r;
+	}
 
 	r = amdgpu_bo_reserve(ring->mqd_obj, false);
 	if (unlikely(r != 0)) {
Signature · 1 line
2.34.1
#1 lore raw

PATCH 2/4 drm/amdgpu/gfx11: Implement the GFX11 KCQ pipe reset

Implement the GFX11 compute pipe reset. As the GFX11 CPFW still hasn't fully supported pipe reset yet, therefore disable the KCQ pipe reset temporarily.

---
 drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c | 139 ++++++++++++++++++++++++-
 1 file changed, 136 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +136 -3
index 395872bb1401..39fd3ce67ec9 100644
@@ -66,6 +66,7 @@
 #define regPC_CONFIG_CNTL_1_BASE_IDX	1
 
 static uint32_t me_fw_start_pc;
+static uint32_t mec_fw_start_pc;
 
 MODULE_FIRMWARE("amdgpu/gc_11_0_0_pfp.bin");
 MODULE_FIRMWARE("amdgpu/gc_11_0_0_me.bin");
@@ -2937,6 +2938,7 @@ static void gfx_v11_0_config_gfx_rs64(struct amdgpu_device *adev)
 
 	/* cache the firmware start PC */
 	me_fw_start_pc = RREG32(SOC15_REG_OFFSET(GC, 0, regCP_GFX_RS64_INSTR_PNTR1));
+	mec_fw_start_pc = RREG32(SOC15_REG_OFFSET(GC, 0, regCP_MEC_RS64_INSTR_PNTR));
 }
 
 static int gfx_v11_0_wait_for_rlc_autoload_complete(struct amdgpu_device *adev)
@@ -3812,7 +3814,7 @@ static int gfx_v11_0_cp_compute_load_microcode(struct amdgpu_device *adev)
 			     le32_to_cpup(fw_data + mec_hdr->jt_offset + i));
 
 	WREG32_SOC15(GC, 0, regCP_MEC_ME1_UCODE_ADDR, adev->gfx.mec_fw_version);
-
+	mec_fw_start_pc = RREG32(SOC15_REG_OFFSET(GC, 0, regCP_MEC1_INSTR_PNTR));
 	return 0;
 }
 
@@ -6764,6 +6766,135 @@ static int gfx_v11_0_reset_kgq(struct amdgpu_ring *ring, unsigned int vmid)
 	return amdgpu_ring_test_ring(ring);
 }
 
+static int gfx_v11_0_reset_compute_pipe(struct amdgpu_ring *ring)
+{
+
+	struct amdgpu_device *adev = ring->adev;
+	uint32_t reset_pipe = 0, clean_pipe = 0;
+	int r;
+
+	if (!gfx_v11_pipe_reset_support(adev))
+		return -EOPNOTSUPP;
+
+	gfx_v11_0_set_safe_mode(adev, 0);
+	mutex_lock(&adev->srbm_mutex);
+	soc21_grbm_select(adev, ring->me, ring->pipe, ring->queue, 0);
+
+	reset_pipe = RREG32_SOC15(GC, 0, regCP_MEC_RS64_CNTL);
+	clean_pipe = reset_pipe;
+
+	if (adev->gfx.rs64_enable) {
+
+		switch (ring->pipe) {
+		case 0:
+			reset_pipe = REG_SET_FIELD(reset_pipe, CP_MEC_RS64_CNTL,
+						   MEC_PIPE0_RESET, 1);
+			clean_pipe = REG_SET_FIELD(clean_pipe, CP_MEC_RS64_CNTL,
+						   MEC_PIPE0_RESET, 0);
+			break;
+		case 1:
+			reset_pipe = REG_SET_FIELD(reset_pipe, CP_MEC_RS64_CNTL,
+						   MEC_PIPE1_RESET, 1);
+			clean_pipe = REG_SET_FIELD(clean_pipe, CP_MEC_RS64_CNTL,
+						   MEC_PIPE1_RESET, 0);
+			break;
+		case 2:
+			reset_pipe = REG_SET_FIELD(reset_pipe, CP_MEC_RS64_CNTL,
+						   MEC_PIPE2_RESET, 1);
+			clean_pipe = REG_SET_FIELD(clean_pipe, CP_MEC_RS64_CNTL,
+						   MEC_PIPE2_RESET, 0);
+			break;
+		case 3:
+			reset_pipe = REG_SET_FIELD(reset_pipe, CP_MEC_RS64_CNTL,
+						   MEC_PIPE3_RESET, 1);
+			clean_pipe = REG_SET_FIELD(clean_pipe, CP_MEC_RS64_CNTL,
+						   MEC_PIPE3_RESET, 0);
+			break;
+		default:
+			break;
+		}
+		WREG32_SOC15(GC, 0, regCP_MEC_RS64_CNTL, reset_pipe);
+		WREG32_SOC15(GC, 0, regCP_MEC_RS64_CNTL, clean_pipe);
+		r = RREG32_SOC15(GC, 0, regCP_MEC_RS64_INSTR_PNTR) - mec_fw_start_pc;
+	} else {
+		if (ring->me == 1) {
+			switch (ring->pipe) {
+			case 0:
+				reset_pipe = REG_SET_FIELD(reset_pipe, CP_MEC_CNTL,
+							   MEC_ME1_PIPE0_RESET, 1);
+				clean_pipe = REG_SET_FIELD(clean_pipe, CP_MEC_CNTL,
+							   MEC_ME1_PIPE0_RESET, 0);
+				break;
+			case 1:
+				reset_pipe = REG_SET_FIELD(reset_pipe, CP_MEC_CNTL,
+							   MEC_ME1_PIPE1_RESET, 1);
+				clean_pipe = REG_SET_FIELD(clean_pipe, CP_MEC_CNTL,
+							   MEC_ME1_PIPE1_RESET, 0);
+				break;
+			case 2:
+				reset_pipe = REG_SET_FIELD(reset_pipe, CP_MEC_CNTL,
+							   MEC_ME1_PIPE2_RESET, 1);
+				clean_pipe = REG_SET_FIELD(clean_pipe, CP_MEC_CNTL,
+							   MEC_ME1_PIPE2_RESET, 0);
+				break;
+			case 3:
+				reset_pipe = REG_SET_FIELD(reset_pipe, CP_MEC_CNTL,
+							   MEC_ME1_PIPE3_RESET, 1);
+				clean_pipe = REG_SET_FIELD(clean_pipe, CP_MEC_CNTL,
+							   MEC_ME1_PIPE3_RESET, 0);
+				break;
+			default:
+				break;
+			}
+			/* mec1 fw pc: CP_MEC1_INSTR_PNTR */
+		} else {
+			switch (ring->pipe) {
+			case 0:
+				reset_pipe = REG_SET_FIELD(reset_pipe, CP_MEC_CNTL,
+							   MEC_ME2_PIPE0_RESET, 1);
+				clean_pipe = REG_SET_FIELD(clean_pipe, CP_MEC_CNTL,
+							   MEC_ME2_PIPE0_RESET, 0);
+				break;
+			case 1:
+				reset_pipe = REG_SET_FIELD(reset_pipe, CP_MEC_CNTL,
+							   MEC_ME2_PIPE1_RESET, 1);
+				clean_pipe = REG_SET_FIELD(clean_pipe, CP_MEC_CNTL,
+							   MEC_ME2_PIPE1_RESET, 0);
+				break;
+			case 2:
+				reset_pipe = REG_SET_FIELD(reset_pipe, CP_MEC_CNTL,
+							   MEC_ME2_PIPE2_RESET, 1);
+				clean_pipe = REG_SET_FIELD(clean_pipe, CP_MEC_CNTL,
+							   MEC_ME2_PIPE2_RESET, 0);
+				break;
+			case 3:
+				reset_pipe = REG_SET_FIELD(reset_pipe, CP_MEC_CNTL,
+							   MEC_ME2_PIPE3_RESET, 1);
+				clean_pipe = REG_SET_FIELD(clean_pipe, CP_MEC_CNTL,
+							   MEC_ME2_PIPE3_RESET, 0);
+				break;
+			default:
+				break;
+			}
+			/* mec2 fw pc: CP:CP_MEC2_INSTR_PNTR */
+		}
+		WREG32_SOC15(GC, 0, regCP_MEC_CNTL, reset_pipe);
+		WREG32_SOC15(GC, 0, regCP_MEC_CNTL, clean_pipe);
+		r = RREG32(SOC15_REG_OFFSET(GC, 0, regCP_MEC1_INSTR_PNTR)) - mec_fw_start_pc;
+	}
+
+	soc21_grbm_select(adev, 0, 0, 0, 0);
+	mutex_unlock(&adev->srbm_mutex);
+	gfx_v11_0_unset_safe_mode(adev, 0);
+
+	dev_info(adev->dev,"The ring %s pipe resets to MEC FW start PC: %s\n", ring->name,
+			r == 0 ? "successfully" : "failed");
+	/*FIXME:Sometimes driver can't cache the MEC firmware start PC correctly, so the pipe
+	 * reset status relies on the compute ring test result.
+	 */
+	return 0;
+}
+
 static int gfx_v11_0_reset_kcq(struct amdgpu_ring *ring, unsigned int vmid)
 {
 	struct amdgpu_device *adev = ring->adev;
@@ -6774,8 +6905,10 @@ static int gfx_v11_0_reset_kcq(struct amdgpu_ring *ring, unsigned int vmid)
 
 	r = amdgpu_mes_reset_legacy_queue(ring->adev, ring, vmid, true);
 	if (r) {
-		dev_err(adev->dev, "reset via MMIO failed %d\n", r);
-		return r;
+		dev_warn(adev->dev,"fail(%d) to reset kcq and try pipe reset\n", r);
+		r = gfx_v11_0_reset_compute_pipe(ring);
+		if (r)
+			return r;
 	}
 
 	r = amdgpu_bo_reserve(ring->mqd_obj, false);
Signature · 1 line
2.34.1
#2 lore raw

Re: [PATCH 2/4] drm/amdgpu/gfx11: Implement the GFX11 KCQ pipe reset

Quoted 15 lines · Prike Liang

Implement the GFX11 compute pipe reset. As the GFX11 CPFW still hasn't fully supported pipe reset yet, therefore disable the KCQ pipe reset temporarily.

---
 drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c | 139 ++++++++++++++++++++++++-
 1 file changed, 136 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +0 -0
index 395872bb1401..39fd3ce67ec9 100644

drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c line 69

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +1 -0
@@ -66,6 +66,7 @@
 #define regPC_CONFIG_CNTL_1_BASE_IDX   1
 
 static uint32_t me_fw_start_pc;
+static uint32_t mec_fw_start_pc;

Same comment here as on patch 1.

Alex

Quoted 172 lines
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +135 -4
 MODULE_FIRMWARE("amdgpu/gc_11_0_0_pfp.bin");
 MODULE_FIRMWARE("amdgpu/gc_11_0_0_me.bin");
@@ -2937,6 +2938,7 @@ static void gfx_v11_0_config_gfx_rs64(struct amdgpu_device *adev)
 
        /* cache the firmware start PC */
        me_fw_start_pc = RREG32(SOC15_REG_OFFSET(GC, 0, regCP_GFX_RS64_INSTR_PNTR1));
+       mec_fw_start_pc = RREG32(SOC15_REG_OFFSET(GC, 0, regCP_MEC_RS64_INSTR_PNTR));
 }
 
 static int gfx_v11_0_wait_for_rlc_autoload_complete(struct amdgpu_device *adev)
@@ -3812,7 +3814,7 @@ static int gfx_v11_0_cp_compute_load_microcode(struct amdgpu_device *adev)
                             le32_to_cpup(fw_data + mec_hdr->jt_offset + i));
 
        WREG32_SOC15(GC, 0, regCP_MEC_ME1_UCODE_ADDR, adev->gfx.mec_fw_version);
-
+       mec_fw_start_pc = RREG32(SOC15_REG_OFFSET(GC, 0, regCP_MEC1_INSTR_PNTR));
        return 0;
 }
 
@@ -6764,6 +6766,135 @@ static int gfx_v11_0_reset_kgq(struct amdgpu_ring *ring, unsigned int vmid)
        return amdgpu_ring_test_ring(ring);
 }
 
+static int gfx_v11_0_reset_compute_pipe(struct amdgpu_ring *ring)
+{
+
+       struct amdgpu_device *adev = ring->adev;
+       uint32_t reset_pipe = 0, clean_pipe = 0;
+       int r;
+
+       if (!gfx_v11_pipe_reset_support(adev))
+               return -EOPNOTSUPP;
+
+       gfx_v11_0_set_safe_mode(adev, 0);
+       mutex_lock(&adev->srbm_mutex);
+       soc21_grbm_select(adev, ring->me, ring->pipe, ring->queue, 0);
+
+       reset_pipe = RREG32_SOC15(GC, 0, regCP_MEC_RS64_CNTL);
+       clean_pipe = reset_pipe;
+
+       if (adev->gfx.rs64_enable) {
+
+               switch (ring->pipe) {
+               case 0:
+                       reset_pipe = REG_SET_FIELD(reset_pipe, CP_MEC_RS64_CNTL,
+                                                  MEC_PIPE0_RESET, 1);
+                       clean_pipe = REG_SET_FIELD(clean_pipe, CP_MEC_RS64_CNTL,
+                                                  MEC_PIPE0_RESET, 0);
+                       break;
+               case 1:
+                       reset_pipe = REG_SET_FIELD(reset_pipe, CP_MEC_RS64_CNTL,
+                                                  MEC_PIPE1_RESET, 1);
+                       clean_pipe = REG_SET_FIELD(clean_pipe, CP_MEC_RS64_CNTL,
+                                                  MEC_PIPE1_RESET, 0);
+                       break;
+               case 2:
+                       reset_pipe = REG_SET_FIELD(reset_pipe, CP_MEC_RS64_CNTL,
+                                                  MEC_PIPE2_RESET, 1);
+                       clean_pipe = REG_SET_FIELD(clean_pipe, CP_MEC_RS64_CNTL,
+                                                  MEC_PIPE2_RESET, 0);
+                       break;
+               case 3:
+                       reset_pipe = REG_SET_FIELD(reset_pipe, CP_MEC_RS64_CNTL,
+                                                  MEC_PIPE3_RESET, 1);
+                       clean_pipe = REG_SET_FIELD(clean_pipe, CP_MEC_RS64_CNTL,
+                                                  MEC_PIPE3_RESET, 0);
+                       break;
+               default:
+                       break;
+               }
+               WREG32_SOC15(GC, 0, regCP_MEC_RS64_CNTL, reset_pipe);
+               WREG32_SOC15(GC, 0, regCP_MEC_RS64_CNTL, clean_pipe);
+               r = RREG32_SOC15(GC, 0, regCP_MEC_RS64_INSTR_PNTR) - mec_fw_start_pc;
+       } else {
+               if (ring->me == 1) {
+                       switch (ring->pipe) {
+                       case 0:
+                               reset_pipe = REG_SET_FIELD(reset_pipe, CP_MEC_CNTL,
+                                                          MEC_ME1_PIPE0_RESET, 1);
+                               clean_pipe = REG_SET_FIELD(clean_pipe, CP_MEC_CNTL,
+                                                          MEC_ME1_PIPE0_RESET, 0);
+                               break;
+                       case 1:
+                               reset_pipe = REG_SET_FIELD(reset_pipe, CP_MEC_CNTL,
+                                                          MEC_ME1_PIPE1_RESET, 1);
+                               clean_pipe = REG_SET_FIELD(clean_pipe, CP_MEC_CNTL,
+                                                          MEC_ME1_PIPE1_RESET, 0);
+                               break;
+                       case 2:
+                               reset_pipe = REG_SET_FIELD(reset_pipe, CP_MEC_CNTL,
+                                                          MEC_ME1_PIPE2_RESET, 1);
+                               clean_pipe = REG_SET_FIELD(clean_pipe, CP_MEC_CNTL,
+                                                          MEC_ME1_PIPE2_RESET, 0);
+                               break;
+                       case 3:
+                               reset_pipe = REG_SET_FIELD(reset_pipe, CP_MEC_CNTL,
+                                                          MEC_ME1_PIPE3_RESET, 1);
+                               clean_pipe = REG_SET_FIELD(clean_pipe, CP_MEC_CNTL,
+                                                          MEC_ME1_PIPE3_RESET, 0);
+                               break;
+                       default:
+                               break;
+                       }
+                       /* mec1 fw pc: CP_MEC1_INSTR_PNTR */
+               } else {
+                       switch (ring->pipe) {
+                       case 0:
+                               reset_pipe = REG_SET_FIELD(reset_pipe, CP_MEC_CNTL,
+                                                          MEC_ME2_PIPE0_RESET, 1);
+                               clean_pipe = REG_SET_FIELD(clean_pipe, CP_MEC_CNTL,
+                                                          MEC_ME2_PIPE0_RESET, 0);
+                               break;
+                       case 1:
+                               reset_pipe = REG_SET_FIELD(reset_pipe, CP_MEC_CNTL,
+                                                          MEC_ME2_PIPE1_RESET, 1);
+                               clean_pipe = REG_SET_FIELD(clean_pipe, CP_MEC_CNTL,
+                                                          MEC_ME2_PIPE1_RESET, 0);
+                               break;
+                       case 2:
+                               reset_pipe = REG_SET_FIELD(reset_pipe, CP_MEC_CNTL,
+                                                          MEC_ME2_PIPE2_RESET, 1);
+                               clean_pipe = REG_SET_FIELD(clean_pipe, CP_MEC_CNTL,
+                                                          MEC_ME2_PIPE2_RESET, 0);
+                               break;
+                       case 3:
+                               reset_pipe = REG_SET_FIELD(reset_pipe, CP_MEC_CNTL,
+                                                          MEC_ME2_PIPE3_RESET, 1);
+                               clean_pipe = REG_SET_FIELD(clean_pipe, CP_MEC_CNTL,
+                                                          MEC_ME2_PIPE3_RESET, 0);
+                               break;
+                       default:
+                               break;
+                       }
+                       /* mec2 fw pc: CP:CP_MEC2_INSTR_PNTR */
+               }
+               WREG32_SOC15(GC, 0, regCP_MEC_CNTL, reset_pipe);
+               WREG32_SOC15(GC, 0, regCP_MEC_CNTL, clean_pipe);
+               r = RREG32(SOC15_REG_OFFSET(GC, 0, regCP_MEC1_INSTR_PNTR)) - mec_fw_start_pc;
+       }
+
+       soc21_grbm_select(adev, 0, 0, 0, 0);
+       mutex_unlock(&adev->srbm_mutex);
+       gfx_v11_0_unset_safe_mode(adev, 0);
+
+       dev_info(adev->dev,"The ring %s pipe resets to MEC FW start PC: %s\n", ring->name,
+                       r == 0 ? "successfully" : "failed");
+       /*FIXME:Sometimes driver can't cache the MEC firmware start PC correctly, so the pipe
+        * reset status relies on the compute ring test result.
+        */
+       return 0;
+}
+
 static int gfx_v11_0_reset_kcq(struct amdgpu_ring *ring, unsigned int vmid)
 {
        struct amdgpu_device *adev = ring->adev;
@@ -6774,8 +6905,10 @@ static int gfx_v11_0_reset_kcq(struct amdgpu_ring *ring, unsigned int vmid)
 
        r = amdgpu_mes_reset_legacy_queue(ring->adev, ring, vmid, true);
        if (r) {
-               dev_err(adev->dev, "reset via MMIO failed %d\n", r);
-               return r;
+               dev_warn(adev->dev,"fail(%d) to reset kcq and try pipe reset\n", r);
+               r = gfx_v11_0_reset_compute_pipe(ring);
+               if (r)
+                       return r;
        }
 
        r = amdgpu_bo_reserve(ring->mqd_obj, false);
--

2.34.1

#3 lore raw

PATCH 3/4 drm/amdgpu/gfx12: Implement the gfx12 kgq pipe reset

In reply to Prike Liang

Implement the GFX12 kgq pipe reset, temporarily disable the GFX12 pipe reset untill the CPFW fully support it.

---
 drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c | 71 +++++++++++++++++++++++++-
 1 file changed, 69 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c +69 -2
index db5cc060de85..14ea7c1e827e 100644
@@ -52,6 +52,7 @@
 #define GFX12_MEC_HPD_SIZE	2048
 
 #define RLCG_UCODE_LOADING_START_ADDRESS	0x00002000L
+static uint32_t me_fw_start_pc;
 
 MODULE_FIRMWARE("amdgpu/gc_12_0_0_pfp.bin");
 MODULE_FIRMWARE("amdgpu/gc_12_0_0_me.bin");
@@ -2210,6 +2211,8 @@ static void gfx_v12_0_set_me_ucode_start_addr(struct amdgpu_device *adev)
 	}
 	soc24_grbm_select(adev, 0, 0, 0, 0);
 	mutex_unlock(&adev->srbm_mutex);
+	/* cache the firmware start PC */
+	me_fw_start_pc = RREG32(SOC15_REG_OFFSET(GC, 0, regCP_GFX_RS64_INSTR_PNTR1));
 }
 
 static void gfx_v12_0_set_mec_ucode_start_addr(struct amdgpu_device *adev)
@@ -5249,6 +5252,68 @@ static void gfx_v12_ip_dump(struct amdgpu_ip_block *ip_block)
 	amdgpu_gfx_off_ctrl(adev, true);
 }
 
+static bool gfx_v12_pipe_reset_support(struct amdgpu_device *adev)
+{
+	/* Disable the pipe reset until the CPFW fully support it.*/
+	dev_warn_once(adev->dev, "The CPFW hasn't support pipe reset yet.\n");
+	return false;
+}
+
+static int gfx_v12_reset_gfx_pipe(struct amdgpu_ring *ring)
+{
+	struct amdgpu_device *adev = ring->adev;
+	uint32_t reset_pipe = 0, clean_pipe = 0;
+	int r;
+
+	if (!gfx_v12_pipe_reset_support(adev))
+		return -EOPNOTSUPP;
+
+	gfx_v12_0_set_safe_mode(adev, 0);
+	mutex_lock(&adev->srbm_mutex);
+	soc24_grbm_select(adev, ring->me, ring->pipe, ring->queue, 0);
+
+	switch (ring->pipe) {
+	case 0:
+		reset_pipe = REG_SET_FIELD(reset_pipe, CP_ME_CNTL,
+					   PFP_PIPE0_RESET, 1);
+		reset_pipe = REG_SET_FIELD(reset_pipe, CP_ME_CNTL,
+					   ME_PIPE0_RESET, 1);
+		clean_pipe = REG_SET_FIELD(clean_pipe, CP_ME_CNTL,
+					   PFP_PIPE0_RESET, 0);
+		clean_pipe = REG_SET_FIELD(clean_pipe, CP_ME_CNTL,
+					   ME_PIPE0_RESET, 0);
+		break;
+	case 1:
+		reset_pipe = REG_SET_FIELD(reset_pipe, CP_ME_CNTL,
+					   PFP_PIPE1_RESET, 1);
+		reset_pipe = REG_SET_FIELD(reset_pipe, CP_ME_CNTL,
+					   ME_PIPE1_RESET, 1);
+		clean_pipe = REG_SET_FIELD(clean_pipe, CP_ME_CNTL,
+					   PFP_PIPE1_RESET, 0);
+		clean_pipe = REG_SET_FIELD(clean_pipe, CP_ME_CNTL,
+					   ME_PIPE1_RESET, 0);
+		break;
+	default:
+		break;
+	}
+
+	WREG32_SOC15(GC, 0, regCP_ME_CNTL, reset_pipe);
+	WREG32_SOC15(GC, 0, regCP_ME_CNTL, clean_pipe);
+
+	r = RREG32(SOC15_REG_OFFSET(GC, 0, regCP_GFX_RS64_INSTR_PNTR1)) - me_fw_start_pc;
+	soc24_grbm_select(adev, 0, 0, 0, 0);
+	mutex_unlock(&adev->srbm_mutex);
+	gfx_v12_0_unset_safe_mode(adev, 0);
+
+	dev_info(adev->dev,"The ring %s pipe reset: %s\n", ring->name,
+			r == 0 ? "successfuly" : "failed");
+	/* Sometimes the ME start pc counter can't cache correctly, so the
+	 * PC check only as a reference and pipe reset result rely on the
+	 * later ring test.
+	 */
+	return 0;
+}
+
 static int gfx_v12_0_reset_kgq(struct amdgpu_ring *ring, unsigned int vmid)
 {
 	struct amdgpu_device *adev = ring->adev;
@@ -5259,8 +5324,10 @@ static int gfx_v12_0_reset_kgq(struct amdgpu_ring *ring, unsigned int vmid)
 
 	r = amdgpu_mes_reset_legacy_queue(ring->adev, ring, vmid, false);
 	if (r) {
-		dev_err(adev->dev, "reset via MES failed %d\n", r);
-		return r;
+		dev_warn(adev->dev,"reset via MES failed and try pipe reset %d\n", r);
+		r = gfx_v12_reset_gfx_pipe(ring);
+		if (r)
+			return r;
 	}
 
 	r = amdgpu_bo_reserve(ring->mqd_obj, false);
Signature · 1 line
2.34.1
#4 lore raw

PATCH 4/4 drm/amdgpu/gfx12: Implement the GFX12 KCQ pipe reset

In reply to Prike Liang

Implement the GFX12 KCQ pipe reset, disable the GFX12 kernel compute queue until the CPFW fully supports it.

---
 drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c | 89 +++++++++++++++++++++++++-
 1 file changed, 87 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c +87 -2
index 14ea7c1e827e..c5d07d5aa495 100644
@@ -53,6 +53,7 @@
 
 #define RLCG_UCODE_LOADING_START_ADDRESS	0x00002000L
 static uint32_t me_fw_start_pc;
+static uint32_t mec_fw_start_pc;
 
 MODULE_FIRMWARE("amdgpu/gc_12_0_0_pfp.bin");
 MODULE_FIRMWARE("amdgpu/gc_12_0_0_me.bin");
@@ -2127,6 +2128,7 @@ static void gfx_v12_0_config_gfx_rs64(struct amdgpu_device *adev)
 	tmp = REG_SET_FIELD(tmp, CP_MEC_RS64_CNTL, MEC_PIPE2_RESET, 0);
 	tmp = REG_SET_FIELD(tmp, CP_MEC_RS64_CNTL, MEC_PIPE3_RESET, 0);
 	WREG32_SOC15(GC, 0, regCP_MEC_RS64_CNTL, tmp);
+	mec_fw_start_pc = RREG32(SOC15_REG_OFFSET(GC, 0, regCP_MEC_RS64_INSTR_PNTR));
 }
 
 static void gfx_v12_0_set_pfp_ucode_start_addr(struct amdgpu_device *adev)
@@ -5356,6 +5358,87 @@ static int gfx_v12_0_reset_kgq(struct amdgpu_ring *ring, unsigned int vmid)
 	return amdgpu_ring_test_ring(ring);
 }
 
+static int gfx_v12_0_reset_compute_pipe(struct amdgpu_ring *ring)
+{
+
+	struct amdgpu_device *adev = ring->adev;
+	uint32_t reset_pipe = 0, clean_pipe = 0;
+	int r;
+
+	if (!gfx_v12_pipe_reset_support(adev))
+		return -EOPNOTSUPP;
+
+	gfx_v12_0_set_safe_mode(adev, 0);
+	mutex_lock(&adev->srbm_mutex);
+	soc24_grbm_select(adev, ring->me, ring->pipe, ring->queue, 0);
+
+	reset_pipe = RREG32_SOC15(GC, 0, regCP_MEC_RS64_CNTL);
+	clean_pipe = reset_pipe;
+
+	if (adev->gfx.rs64_enable) {
+
+		switch (ring->pipe) {
+		case 0:
+			reset_pipe = REG_SET_FIELD(reset_pipe, CP_MEC_RS64_CNTL,
+						   MEC_PIPE0_RESET, 1);
+			clean_pipe = REG_SET_FIELD(clean_pipe, CP_MEC_RS64_CNTL,
+						   MEC_PIPE0_RESET, 0);
+			break;
+		case 1:
+			reset_pipe = REG_SET_FIELD(reset_pipe, CP_MEC_RS64_CNTL,
+						   MEC_PIPE1_RESET, 1);
+			clean_pipe = REG_SET_FIELD(clean_pipe, CP_MEC_RS64_CNTL,
+						   MEC_PIPE1_RESET, 0);
+			break;
+		case 2:
+			reset_pipe = REG_SET_FIELD(reset_pipe, CP_MEC_RS64_CNTL,
+						   MEC_PIPE2_RESET, 1);
+			clean_pipe = REG_SET_FIELD(clean_pipe, CP_MEC_RS64_CNTL,
+						   MEC_PIPE2_RESET, 0);
+			break;
+		case 3:
+			reset_pipe = REG_SET_FIELD(reset_pipe, CP_MEC_RS64_CNTL,
+						   MEC_PIPE3_RESET, 1);
+			clean_pipe = REG_SET_FIELD(clean_pipe, CP_MEC_RS64_CNTL,
+						   MEC_PIPE3_RESET, 0);
+			break;
+		default:
+			break;
+		}
+		WREG32_SOC15(GC, 0, regCP_MEC_RS64_CNTL, reset_pipe);
+		WREG32_SOC15(GC, 0, regCP_MEC_RS64_CNTL, clean_pipe);
+		r = RREG32_SOC15(GC, 0, regCP_MEC_RS64_INSTR_PNTR) - mec_fw_start_pc;
+	} else {
+		switch (ring->pipe) {
+		case 0:
+			reset_pipe = REG_SET_FIELD(reset_pipe, CP_MEC_CNTL,
+							   MEC_ME1_PIPE0_RESET, 1);
+			clean_pipe = REG_SET_FIELD(clean_pipe, CP_MEC_CNTL,
+							   MEC_ME1_PIPE0_RESET, 0);
+			break;
+		case 1:
+			reset_pipe = REG_SET_FIELD(reset_pipe, CP_MEC_CNTL,
+							   MEC_ME1_PIPE1_RESET, 1);
+			clean_pipe = REG_SET_FIELD(clean_pipe, CP_MEC_CNTL,
+							   MEC_ME1_PIPE1_RESET, 0);
+			break;
+		default:
+		break;
+		}
+		WREG32_SOC15(GC, 0, regCP_MEC_CNTL, reset_pipe);
+		WREG32_SOC15(GC, 0, regCP_MEC_CNTL, clean_pipe);
+	}
+
+	soc24_grbm_select(adev, 0, 0, 0, 0);
+	mutex_unlock(&adev->srbm_mutex);
+	gfx_v12_0_unset_safe_mode(adev, 0);
+
+	dev_info(adev->dev,"The ring %s pipe resets: %s\n", ring->name,
+			r == 0 ? "successfully" : "failed");
+	/* Need the ring test to verify the pipe reset result.*/
+	return 0;
+
+}
 static int gfx_v12_0_reset_kcq(struct amdgpu_ring *ring, unsigned int vmid)
 {
 	struct amdgpu_device *adev = ring->adev;
@@ -5366,8 +5449,10 @@ static int gfx_v12_0_reset_kcq(struct amdgpu_ring *ring, unsigned int vmid)
 
 	r = amdgpu_mes_reset_legacy_queue(ring->adev, ring, vmid, true);
 	if (r) {
-		dev_err(adev->dev, "reset via MMIO failed %d\n", r);
-		return r;
+		dev_warn(adev->dev,"fail(%d) to reset kcq  and try pipe reset\n", r);
+		r = gfx_v12_0_reset_compute_pipe(ring);
+		if (r)
+			return r;
 	}
 
 	r = amdgpu_bo_reserve(ring->mqd_obj, false);
Signature · 1 line
2.34.1
#5 lore raw

RE: [PATCH 4/4] drm/amdgpu/gfx12: Implement the GFX12 KCQ pipe reset

[Public]

The implementation of the gfx11/gfx12 pipe reset is derived from the gfx9 pipe reset sequence. Consequently, the driver sequence may not undergo significant changes except for incorporating gfx11/gfx12 firmware support for the pipe reset. To reduce the effort needed to address merge conflicts, could these series implementations be advanced to upstream?

Regards,
Prike

Quoted 159 lines

-----Original Message-----
From: Liang, Prike <[email protected]>
Sent: Sunday, January 26, 2025 4:38 PM
To: [email protected]
Cc: Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>; Lazar, Lijo <[email protected]>; Liang, Prike <[email protected]>
Subject: [PATCH 4/4] drm/amdgpu/gfx12: Implement the GFX12 KCQ pipe reset

Implement the GFX12 KCQ pipe reset, disable the GFX12 kernel compute queue until the CPFW fully supports it.

---
 drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c | 89 +++++++++++++++++++++++++-
 1 file changed, 87 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c +30 -0
index 14ea7c1e827e..c5d07d5aa495 100644
@@ -53,6 +53,7 @@
 
 #define RLCG_UCODE_LOADING_START_ADDRESS     0x00002000L
 static uint32_t me_fw_start_pc;
+static uint32_t mec_fw_start_pc;
 
 MODULE_FIRMWARE("amdgpu/gc_12_0_0_pfp.bin");
 MODULE_FIRMWARE("amdgpu/gc_12_0_0_me.bin");
@@ -2127,6 +2128,7 @@ static void gfx_v12_0_config_gfx_rs64(struct
 amdgpu_device *adev)
      tmp = REG_SET_FIELD(tmp, CP_MEC_RS64_CNTL,
 MEC_PIPE2_RESET, 0);
      tmp = REG_SET_FIELD(tmp, CP_MEC_RS64_CNTL,
 MEC_PIPE3_RESET, 0);
      WREG32_SOC15(GC, 0, regCP_MEC_RS64_CNTL, tmp);
+     mec_fw_start_pc = RREG32(SOC15_REG_OFFSET(GC, 0,
+regCP_MEC_RS64_INSTR_PNTR));
 }
 
 static void gfx_v12_0_set_pfp_ucode_start_addr(struct amdgpu_device *adev)
@@ -5356,6 +5358,87 @@ static int gfx_v12_0_reset_kgq(struct amdgpu_ring
 *ring, unsigned int vmid)
      return amdgpu_ring_test_ring(ring);
 }
 
+static int gfx_v12_0_reset_compute_pipe(struct amdgpu_ring *ring) {
+
+     struct amdgpu_device *adev = ring->adev;
+     uint32_t reset_pipe = 0, clean_pipe = 0;
+     int r;
+
+     if (!gfx_v12_pipe_reset_support(adev))
+             return -EOPNOTSUPP;
+
+     gfx_v12_0_set_safe_mode(adev, 0);
+     mutex_lock(&adev->srbm_mutex);
+     soc24_grbm_select(adev, ring->me, ring->pipe, ring->queue, 0);
+
+     reset_pipe = RREG32_SOC15(GC, 0, regCP_MEC_RS64_CNTL);
+     clean_pipe = reset_pipe;
+
+     if (adev->gfx.rs64_enable) {
+
+             switch (ring->pipe) {
+             case 0:
+                     reset_pipe = REG_SET_FIELD(reset_pipe,
 CP_MEC_RS64_CNTL,
+                                                MEC_PIPE0_RESET, 1);
+                     clean_pipe = REG_SET_FIELD(clean_pipe,
 CP_MEC_RS64_CNTL,
+                                                MEC_PIPE0_RESET, 0);
+                     break;
+             case 1:
+                     reset_pipe = REG_SET_FIELD(reset_pipe,

CP_MEC_RS64_CNTL,

drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c +2 -0
+                                                MEC_PIPE1_RESET, 1);
+                     clean_pipe = REG_SET_FIELD(clean_pipe,

CP_MEC_RS64_CNTL,

drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c +4 -0
+                                                MEC_PIPE1_RESET, 0);
+                     break;
+             case 2:
+                     reset_pipe = REG_SET_FIELD(reset_pipe,

CP_MEC_RS64_CNTL,

drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c +2 -0
+                                                MEC_PIPE2_RESET, 1);
+                     clean_pipe = REG_SET_FIELD(clean_pipe,

CP_MEC_RS64_CNTL,

drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c +4 -0
+                                                MEC_PIPE2_RESET, 0);
+                     break;
+             case 3:
+                     reset_pipe = REG_SET_FIELD(reset_pipe,

CP_MEC_RS64_CNTL,

drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c +2 -0
+                                                MEC_PIPE3_RESET, 1);
+                     clean_pipe = REG_SET_FIELD(clean_pipe,

CP_MEC_RS64_CNTL,

drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c +8 -0
+                                                MEC_PIPE3_RESET, 0);
+                     break;
+             default:
+                     break;
+             }
+             WREG32_SOC15(GC, 0, regCP_MEC_RS64_CNTL, reset_pipe);
+             WREG32_SOC15(GC, 0, regCP_MEC_RS64_CNTL, clean_pipe);
+             r = RREG32_SOC15(GC, 0, regCP_MEC_RS64_INSTR_PNTR) -

mec_fw_start_pc;

drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c +5 -0
+     } else {
+             switch (ring->pipe) {
+             case 0:
+                     reset_pipe = REG_SET_FIELD(reset_pipe, CP_MEC_CNTL,
+                                                        MEC_ME1_PIPE0_RESET,

1);
+ clean_pipe = REG_SET_FIELD(clean_pipe,
CP_MEC_CNTL,
+ MEC_ME1_PIPE0_RESET,
0);

drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c +4 -0
+                     break;
+             case 1:
+                     reset_pipe = REG_SET_FIELD(reset_pipe, CP_MEC_CNTL,
+                                                        MEC_ME1_PIPE1_RESET,

1);
+ clean_pipe = REG_SET_FIELD(clean_pipe,
CP_MEC_CNTL,
+ MEC_ME1_PIPE1_RESET,
0);

drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c +18 -0
+                     break;
+             default:
+             break;
+             }
+             WREG32_SOC15(GC, 0, regCP_MEC_CNTL, reset_pipe);
+             WREG32_SOC15(GC, 0, regCP_MEC_CNTL, clean_pipe);
+     }
+
+     soc24_grbm_select(adev, 0, 0, 0, 0);
+     mutex_unlock(&adev->srbm_mutex);
+     gfx_v12_0_unset_safe_mode(adev, 0);
+
+     dev_info(adev->dev,"The ring %s pipe resets: %s\n", ring->name,
+                     r == 0 ? "successfully" : "failed");
+     /* Need the ring test to verify the pipe reset result.*/
+     return 0;
+
+}
 static int gfx_v12_0_reset_kcq(struct amdgpu_ring *ring, unsigned int vmid)  {
      struct amdgpu_device *adev = ring->adev; @@ -5366,8 +5449,10 @@

static int gfx_v12_0_reset_kcq(struct amdgpu_ring *ring, unsigned int vmid)

      r = amdgpu_mes_reset_legacy_queue(ring->adev, ring, vmid, true);
      if (r) {
drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c +4 -3
-             dev_err(adev->dev, "reset via MMIO failed %d\n", r);
-             return r;
+             dev_warn(adev->dev,"fail(%d) to reset kcq  and try pipe reset\n", r);
+             r = gfx_v12_0_reset_compute_pipe(ring);
+             if (r)
+                     return r;
      }
 
      r = amdgpu_bo_reserve(ring->mqd_obj, false);
--

2.34.1

#6 lore raw
In reply to Prike Liang
Quoted 25 lines · Prike Liang

Implement the kernel graphics queue pipe reset,and the driver will fallback to pipe reset when the queue reset fails. However, the ME FW hasn't fully supported pipe reset yet so disable the KGQ pipe reset temporarily.

---
 drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c | 76 +++++++++++++++++++++++++-
 1 file changed, 74 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +2 -0
index 89d17750af04..395872bb1401 100644
@@ -65,6 +65,8 @@
 #define regPC_CONFIG_CNTL_1            0x194d
 #define regPC_CONFIG_CNTL_1_BASE_IDX   1
 
+static uint32_t me_fw_start_pc;
+
 MODULE_FIRMWARE("amdgpu/gc_11_0_0_pfp.bin");
 MODULE_FIRMWARE("amdgpu/gc_11_0_0_me.bin");
 MODULE_FIRMWARE("amdgpu/gc_11_0_0_mec.bin");

drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c static void gfx_v11_0_config_gfx_rs64(struct amdgpu_device *adev) · line 2939

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +3 -0
@@ -2932,6 +2934,9 @@ static void gfx_v11_0_config_gfx_rs64(struct amdgpu_device *adev)
        tmp = REG_SET_FIELD(tmp, CP_MEC_RS64_CNTL, MEC_PIPE2_RESET, 0);
        tmp = REG_SET_FIELD(tmp, CP_MEC_RS64_CNTL, MEC_PIPE3_RESET, 0);
        WREG32_SOC15(GC, 0, regCP_MEC_RS64_CNTL, tmp);
+
+       /* cache the firmware start PC */
+       me_fw_start_pc = RREG32(SOC15_REG_OFFSET(GC, 0, regCP_GFX_RS64_INSTR_PNTR1));

You can't use a global variable. It won't work if you have multiple GPUs in the system.

Alex

Quoted 91 lines
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +69 -3
 }
 
 static int gfx_v11_0_wait_for_rlc_autoload_complete(struct amdgpu_device *adev)
@@ -6654,6 +6659,68 @@ static void gfx_v11_0_emit_mem_sync(struct amdgpu_ring *ring)
        amdgpu_ring_write(ring, gcr_cntl); /* GCR_CNTL */
 }
 
+static bool gfx_v11_pipe_reset_support(struct amdgpu_device *adev)
+{
+       /* Disable the pipe reset until the CPFW fully support it.*/
+       dev_warn_once(adev->dev, "The CPFW hasn't support pipe reset yet.\n");
+       return false;
+}
+
+
+static int gfx_v11_reset_gfx_pipe(struct amdgpu_ring *ring)
+{
+       struct amdgpu_device *adev = ring->adev;
+       uint32_t reset_pipe = 0, clean_pipe = 0;
+       int r;
+
+       if (!gfx_v11_pipe_reset_support(adev))
+               return -EOPNOTSUPP;
+
+       gfx_v11_0_set_safe_mode(adev, 0);
+       mutex_lock(&adev->srbm_mutex);
+       soc21_grbm_select(adev, ring->me, ring->pipe, ring->queue, 0);
+
+       switch (ring->pipe) {
+       case 0:
+               reset_pipe = REG_SET_FIELD(reset_pipe, CP_ME_CNTL,
+                                          PFP_PIPE0_RESET, 1);
+               reset_pipe = REG_SET_FIELD(reset_pipe, CP_ME_CNTL,
+                                          ME_PIPE0_RESET, 1);
+               clean_pipe = REG_SET_FIELD(clean_pipe, CP_ME_CNTL,
+                                          PFP_PIPE0_RESET, 0);
+               clean_pipe = REG_SET_FIELD(clean_pipe, CP_ME_CNTL,
+                                          ME_PIPE0_RESET, 0);
+               break;
+       case 1:
+               reset_pipe = REG_SET_FIELD(reset_pipe, CP_ME_CNTL,
+                                          PFP_PIPE1_RESET, 1);
+               reset_pipe = REG_SET_FIELD(reset_pipe, CP_ME_CNTL,
+                                          ME_PIPE1_RESET, 1);
+               clean_pipe = REG_SET_FIELD(clean_pipe, CP_ME_CNTL,
+                                          PFP_PIPE1_RESET, 0);
+               clean_pipe = REG_SET_FIELD(clean_pipe, CP_ME_CNTL,
+                                          ME_PIPE1_RESET, 0);
+               break;
+       default:
+               break;
+       }
+
+       WREG32_SOC15(GC, 0, regCP_ME_CNTL, reset_pipe);
+       WREG32_SOC15(GC, 0, regCP_ME_CNTL, clean_pipe);
+
+       r = RREG32(SOC15_REG_OFFSET(GC, 0, regCP_GFX_RS64_INSTR_PNTR1)) - me_fw_start_pc;
+       soc21_grbm_select(adev, 0, 0, 0, 0);
+       mutex_unlock(&adev->srbm_mutex);
+       gfx_v11_0_unset_safe_mode(adev, 0);
+
+       dev_info(adev->dev,"The ring %s pipe reset to the ME firmware start PC: %s\n", ring->name,
+                       r == 0 ? "successfuly" : "failed");
+       /* FIXME: Sometimes driver can't cache the ME firmware start PC correctly, so the pipe reset status
+        * relies on the later gfx ring test result.
+        */
+       return 0;
+}
+
 static int gfx_v11_0_reset_kgq(struct amdgpu_ring *ring, unsigned int vmid)
 {
        struct amdgpu_device *adev = ring->adev;
@@ -6663,8 +6730,13 @@ static int gfx_v11_0_reset_kgq(struct amdgpu_ring *ring, unsigned int vmid)
                return -EINVAL;
 
        r = amdgpu_mes_reset_legacy_queue(ring->adev, ring, vmid, false);
-       if (r)
-               return r;
+       if (r) {
+
+               dev_warn(adev->dev,"reset via MES failed and try pipe reset %d\n", r);
+               r = gfx_v11_reset_gfx_pipe(ring);
+               if (r)
+                       return r;
+       }
 
        r = amdgpu_bo_reserve(ring->mqd_obj, false);
        if (unlikely(r != 0)) {
--

2.34.1

#7 lore raw

[Public]

The various gfx11/gfx12 systems share the same start PC value, but it seems better to use the specific register CP_ME_PRGRM_CNTR_START to get the start PC value.

Regards,
Prike

Quoted 147 lines

-----Original Message-----
From: Alex Deucher <[email protected]>
Sent: Thursday, February 20, 2025 3:56 AM
To: Liang, Prike <[email protected]>
Cc: [email protected]; Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>; Lazar, Lijo <[email protected]>
Subject: Re: [PATCH 1/4] drm/amdgpu/gfx11: Implement the GFX11 KGQ pipe reset

drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c static void gfx_v11_0_config_gfx_rs64(struct

Quoted 27 lines · Prike Liang

Implement the kernel graphics queue pipe reset,and the driver will fallback to pipe reset when the queue reset fails. However, the ME FW hasn't fully supported pipe reset yet so disable the KGQ pipe reset temporarily.

---
 drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c | 76
+++++++++++++++++++++++++-
 1 file changed, 74 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +2 -0
index 89d17750af04..395872bb1401 100644
@@ -65,6 +65,8 @@
 #define regPC_CONFIG_CNTL_1            0x194d
 #define regPC_CONFIG_CNTL_1_BASE_IDX   1
 
+static uint32_t me_fw_start_pc;
+
 MODULE_FIRMWARE("amdgpu/gc_11_0_0_pfp.bin");
 MODULE_FIRMWARE("amdgpu/gc_11_0_0_me.bin");
 MODULE_FIRMWARE("amdgpu/gc_11_0_0_mec.bin");
@@ -2932,6 +2934,9 @@ static void gfx_v11_0_config_gfx_rs64(struct

amdgpu_device *adev)

drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c static void gfx_v11_0_config_gfx_rs64(struct · line 2934

Quoted 1 line
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +0 -0
        tmp = REG_SET_FIELD(tmp, CP_MEC_RS64_CNTL,

MEC_PIPE2_RESET, 0);

drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c static void gfx_v11_0_config_gfx_rs64(struct · line 2935

Quoted 1 line
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +0 -0
        tmp = REG_SET_FIELD(tmp, CP_MEC_RS64_CNTL,

MEC_PIPE3_RESET, 0);

drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c static void gfx_v11_0_config_gfx_rs64(struct amdgpu_device *adev)

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +4 -0
        WREG32_SOC15(GC, 0, regCP_MEC_RS64_CNTL, tmp);
+
+       /* cache the firmware start PC */
+       me_fw_start_pc = RREG32(SOC15_REG_OFFSET(GC, 0,
+ regCP_GFX_RS64_INSTR_PNTR1));

You can't use a global variable. It won't work if you have multiple GPUs in the system.

Alex

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +0 -0
 }
 
 static int gfx_v11_0_wait_for_rlc_autoload_complete(struct

amdgpu_device *adev) @@ -6654,6 +6659,68 @@ static void

gfx_v11_0_emit_mem_sync(struct amdgpu_ring *ring)

Quoted 40 lines
        amdgpu_ring_write(ring, gcr_cntl); /* GCR_CNTL */  }
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +38 -0
+static bool gfx_v11_pipe_reset_support(struct amdgpu_device *adev) {
+       /* Disable the pipe reset until the CPFW fully support it.*/
+       dev_warn_once(adev->dev, "The CPFW hasn't support pipe reset yet.\n");
+       return false;
+}
+
+
+static int gfx_v11_reset_gfx_pipe(struct amdgpu_ring *ring) {
+       struct amdgpu_device *adev = ring->adev;
+       uint32_t reset_pipe = 0, clean_pipe = 0;
+       int r;
+
+       if (!gfx_v11_pipe_reset_support(adev))
+               return -EOPNOTSUPP;
+
+       gfx_v11_0_set_safe_mode(adev, 0);
+       mutex_lock(&adev->srbm_mutex);
+       soc21_grbm_select(adev, ring->me, ring->pipe, ring->queue, 0);
+
+       switch (ring->pipe) {
+       case 0:
+               reset_pipe = REG_SET_FIELD(reset_pipe, CP_ME_CNTL,
+                                          PFP_PIPE0_RESET, 1);
+               reset_pipe = REG_SET_FIELD(reset_pipe, CP_ME_CNTL,
+                                          ME_PIPE0_RESET, 1);
+               clean_pipe = REG_SET_FIELD(clean_pipe, CP_ME_CNTL,
+                                          PFP_PIPE0_RESET, 0);
+               clean_pipe = REG_SET_FIELD(clean_pipe, CP_ME_CNTL,
+                                          ME_PIPE0_RESET, 0);
+               break;
+       case 1:
+               reset_pipe = REG_SET_FIELD(reset_pipe, CP_ME_CNTL,
+                                          PFP_PIPE1_RESET, 1);
+               reset_pipe = REG_SET_FIELD(reset_pipe, CP_ME_CNTL,
+                                          ME_PIPE1_RESET, 1);
+               clean_pipe = REG_SET_FIELD(clean_pipe, CP_ME_CNTL,
+                                          PFP_PIPE1_RESET, 0);
+               clean_pipe = REG_SET_FIELD(clean_pipe, CP_ME_CNTL,

drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c static void gfx_v11_0_emit_mem_sync(struct amdgpu_ring *ring)

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +10 -0
+                                          ME_PIPE1_RESET, 0);
+               break;
+       default:
+               break;
+       }
+
+       WREG32_SOC15(GC, 0, regCP_ME_CNTL, reset_pipe);
+       WREG32_SOC15(GC, 0, regCP_ME_CNTL, clean_pipe);
+
+       r = RREG32(SOC15_REG_OFFSET(GC, 0,

regCP_GFX_RS64_INSTR_PNTR1)) - me_fw_start_pc;

drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c static void gfx_v11_0_emit_mem_sync(struct amdgpu_ring *ring)

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +5 -0
+       soc21_grbm_select(adev, 0, 0, 0, 0);
+       mutex_unlock(&adev->srbm_mutex);
+       gfx_v11_0_unset_safe_mode(adev, 0);
+
+       dev_info(adev->dev,"The ring %s pipe reset to the ME firmware start

PC: %s\n", ring->name,

drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c

Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +2 -0
+                       r == 0 ? "successfuly" : "failed");
+       /* FIXME: Sometimes driver can't cache the ME firmware start PC

correctly, so the pipe reset status

Quoted 12 lines
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +5 -0
+        * relies on the later gfx ring test result.
+        */
+       return 0;
+}
+
 static int gfx_v11_0_reset_kgq(struct amdgpu_ring *ring, unsigned int
vmid)  {
        struct amdgpu_device *adev = ring->adev; @@ -6663,8 +6730,13
@@ static int gfx_v11_0_reset_kgq(struct amdgpu_ring *ring, unsigned int vmid)
                return -EINVAL;

        r = amdgpu_mes_reset_legacy_queue(ring->adev, ring, vmid, false);

drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c static int gfx_v11_0_reset_kgq(struct amdgpu_ring *ring, unsigned int vmid)

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +3 -2
-       if (r)
-               return r;
+       if (r) {
+
+               dev_warn(adev->dev,"reset via MES failed and try pipe reset %d\n",

r);

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +4 -1
+               r = gfx_v11_reset_gfx_pipe(ring);
+               if (r)
+                       return r;
+       }
 
        r = amdgpu_bo_reserve(ring->mqd_obj, false);
        if (unlikely(r != 0)) {
--

2.34.1

#8 lore raw
Quoted 4 lines · Prike

[Public]

The various gfx11/gfx12 systems share the same start PC value, but it seems better to use the specific register CP_ME_PRGRM_CNTR_START to get the start PC value.

Why not store the value per device? Or if it's always the same, just use a macro.

Alex

Quoted 151 lines

Regards,
Prike

Quoted 147 lines

-----Original Message-----
From: Alex Deucher <[email protected]>
Sent: Thursday, February 20, 2025 3:56 AM
To: Liang, Prike <[email protected]>
Cc: [email protected]; Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>; Lazar, Lijo <[email protected]>
Subject: Re: [PATCH 1/4] drm/amdgpu/gfx11: Implement the GFX11 KGQ pipe reset

drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c static void gfx_v11_0_config_gfx_rs64(struct

Quoted 27 lines · Prike Liang

Implement the kernel graphics queue pipe reset,and the driver will fallback to pipe reset when the queue reset fails. However, the ME FW hasn't fully supported pipe reset yet so disable the KGQ pipe reset temporarily.

---
 drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c | 76
+++++++++++++++++++++++++-
 1 file changed, 74 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +2 -0
index 89d17750af04..395872bb1401 100644
@@ -65,6 +65,8 @@
 #define regPC_CONFIG_CNTL_1            0x194d
 #define regPC_CONFIG_CNTL_1_BASE_IDX   1
 
+static uint32_t me_fw_start_pc;
+
 MODULE_FIRMWARE("amdgpu/gc_11_0_0_pfp.bin");
 MODULE_FIRMWARE("amdgpu/gc_11_0_0_me.bin");
 MODULE_FIRMWARE("amdgpu/gc_11_0_0_mec.bin");
@@ -2932,6 +2934,9 @@ static void gfx_v11_0_config_gfx_rs64(struct

amdgpu_device *adev)

drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c static void gfx_v11_0_config_gfx_rs64(struct · line 2934

Quoted 1 line
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +0 -0
        tmp = REG_SET_FIELD(tmp, CP_MEC_RS64_CNTL,

MEC_PIPE2_RESET, 0);

drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c static void gfx_v11_0_config_gfx_rs64(struct · line 2935

Quoted 1 line
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +0 -0
        tmp = REG_SET_FIELD(tmp, CP_MEC_RS64_CNTL,

MEC_PIPE3_RESET, 0);

drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c static void gfx_v11_0_config_gfx_rs64(struct amdgpu_device *adev)

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +4 -0
        WREG32_SOC15(GC, 0, regCP_MEC_RS64_CNTL, tmp);
+
+       /* cache the firmware start PC */
+       me_fw_start_pc = RREG32(SOC15_REG_OFFSET(GC, 0,
+ regCP_GFX_RS64_INSTR_PNTR1));

You can't use a global variable. It won't work if you have multiple GPUs in the system.

Alex

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +0 -0
 }
 
 static int gfx_v11_0_wait_for_rlc_autoload_complete(struct

amdgpu_device *adev) @@ -6654,6 +6659,68 @@ static void

gfx_v11_0_emit_mem_sync(struct amdgpu_ring *ring)

Quoted 40 lines
        amdgpu_ring_write(ring, gcr_cntl); /* GCR_CNTL */  }
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +38 -0
+static bool gfx_v11_pipe_reset_support(struct amdgpu_device *adev) {
+       /* Disable the pipe reset until the CPFW fully support it.*/
+       dev_warn_once(adev->dev, "The CPFW hasn't support pipe reset yet.\n");
+       return false;
+}
+
+
+static int gfx_v11_reset_gfx_pipe(struct amdgpu_ring *ring) {
+       struct amdgpu_device *adev = ring->adev;
+       uint32_t reset_pipe = 0, clean_pipe = 0;
+       int r;
+
+       if (!gfx_v11_pipe_reset_support(adev))
+               return -EOPNOTSUPP;
+
+       gfx_v11_0_set_safe_mode(adev, 0);
+       mutex_lock(&adev->srbm_mutex);
+       soc21_grbm_select(adev, ring->me, ring->pipe, ring->queue, 0);
+
+       switch (ring->pipe) {
+       case 0:
+               reset_pipe = REG_SET_FIELD(reset_pipe, CP_ME_CNTL,
+                                          PFP_PIPE0_RESET, 1);
+               reset_pipe = REG_SET_FIELD(reset_pipe, CP_ME_CNTL,
+                                          ME_PIPE0_RESET, 1);
+               clean_pipe = REG_SET_FIELD(clean_pipe, CP_ME_CNTL,
+                                          PFP_PIPE0_RESET, 0);
+               clean_pipe = REG_SET_FIELD(clean_pipe, CP_ME_CNTL,
+                                          ME_PIPE0_RESET, 0);
+               break;
+       case 1:
+               reset_pipe = REG_SET_FIELD(reset_pipe, CP_ME_CNTL,
+                                          PFP_PIPE1_RESET, 1);
+               reset_pipe = REG_SET_FIELD(reset_pipe, CP_ME_CNTL,
+                                          ME_PIPE1_RESET, 1);
+               clean_pipe = REG_SET_FIELD(clean_pipe, CP_ME_CNTL,
+                                          PFP_PIPE1_RESET, 0);
+               clean_pipe = REG_SET_FIELD(clean_pipe, CP_ME_CNTL,

drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c static void gfx_v11_0_emit_mem_sync(struct amdgpu_ring *ring)

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +10 -0
+                                          ME_PIPE1_RESET, 0);
+               break;
+       default:
+               break;
+       }
+
+       WREG32_SOC15(GC, 0, regCP_ME_CNTL, reset_pipe);
+       WREG32_SOC15(GC, 0, regCP_ME_CNTL, clean_pipe);
+
+       r = RREG32(SOC15_REG_OFFSET(GC, 0,

regCP_GFX_RS64_INSTR_PNTR1)) - me_fw_start_pc;

drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c static void gfx_v11_0_emit_mem_sync(struct amdgpu_ring *ring)

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +5 -0
+       soc21_grbm_select(adev, 0, 0, 0, 0);
+       mutex_unlock(&adev->srbm_mutex);
+       gfx_v11_0_unset_safe_mode(adev, 0);
+
+       dev_info(adev->dev,"The ring %s pipe reset to the ME firmware start

PC: %s\n", ring->name,

drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c

Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +2 -0
+                       r == 0 ? "successfuly" : "failed");
+       /* FIXME: Sometimes driver can't cache the ME firmware start PC

correctly, so the pipe reset status

Quoted 12 lines
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +5 -0
+        * relies on the later gfx ring test result.
+        */
+       return 0;
+}
+
 static int gfx_v11_0_reset_kgq(struct amdgpu_ring *ring, unsigned int
vmid)  {
        struct amdgpu_device *adev = ring->adev; @@ -6663,8 +6730,13
@@ static int gfx_v11_0_reset_kgq(struct amdgpu_ring *ring, unsigned int vmid)
                return -EINVAL;

        r = amdgpu_mes_reset_legacy_queue(ring->adev, ring, vmid, false);

drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c static int gfx_v11_0_reset_kgq(struct amdgpu_ring *ring, unsigned int vmid)

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +3 -2
-       if (r)
-               return r;
+       if (r) {
+
+               dev_warn(adev->dev,"reset via MES failed and try pipe reset %d\n",

r);

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +4 -1
+               r = gfx_v11_reset_gfx_pipe(ring);
+               if (r)
+                       return r;
+       }
 
        r = amdgpu_bo_reserve(ring->mqd_obj, false);
        if (unlikely(r != 0)) {
--

2.34.1

#9 lore raw

[Public]

Quoted 11 lines

From: Alex Deucher <[email protected]>
Sent: Thursday, February 20, 2025 10:18 PM
To: Liang, Prike <[email protected]>
Cc: [email protected]; Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>; Lazar, Lijo <[email protected]>
Subject: Re: [PATCH 1/4] drm/amdgpu/gfx11: Implement the GFX11 KGQ pipe reset

Quoted 1 line · Prike
Quoted 8 lines
Quoted 3 lines

[Public]

The various gfx11/gfx12 systems share the same start PC value, but it seems

better to use the specific register CP_ME_PRGRM_CNTR_START to get the start PC value.

Why not store the value per device? Or if it's always the same, just use a macro.

Thank you for the input, the firmware assigns the _start PC using the macro as well.
It will be more efficient to retrieve the _start PC from the macro instead of accessing the MMIO register each time.

Thanks,
Prike

Quoted 161 lines

Alex

Quoted 68 lines

Regards,
Prike

Quoted 64 lines

-----Original Message-----
From: Alex Deucher <[email protected]>
Sent: Thursday, February 20, 2025 3:56 AM
To: Liang, Prike <[email protected]>
Cc: [email protected]; Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>; Lazar, Lijo <[email protected]>
Subject: Re: [PATCH 1/4] drm/amdgpu/gfx11: Implement the GFX11 KGQ pipe reset

drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c static void gfx_v11_0_config_gfx_rs64(struct

Quoted 27 lines · Prike Liang

Implement the kernel graphics queue pipe reset,and the driver will fallback to pipe reset when the queue reset fails. However, the ME FW hasn't fully supported pipe reset yet so disable the KGQ pipe reset temporarily.

---
 drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c | 76
+++++++++++++++++++++++++-
 1 file changed, 74 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +2 -0
index 89d17750af04..395872bb1401 100644
@@ -65,6 +65,8 @@
 #define regPC_CONFIG_CNTL_1            0x194d
 #define regPC_CONFIG_CNTL_1_BASE_IDX   1
 
+static uint32_t me_fw_start_pc;
+
 MODULE_FIRMWARE("amdgpu/gc_11_0_0_pfp.bin");
 MODULE_FIRMWARE("amdgpu/gc_11_0_0_me.bin");
 MODULE_FIRMWARE("amdgpu/gc_11_0_0_mec.bin");
@@ -2932,6 +2934,9 @@ static void gfx_v11_0_config_gfx_rs64(struct

amdgpu_device *adev)

drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c static void gfx_v11_0_config_gfx_rs64(struct · line 2934

Quoted 1 line
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +0 -0
        tmp = REG_SET_FIELD(tmp, CP_MEC_RS64_CNTL,

MEC_PIPE2_RESET, 0);

drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c static void gfx_v11_0_config_gfx_rs64(struct · line 2935

Quoted 1 line
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +0 -0
        tmp = REG_SET_FIELD(tmp, CP_MEC_RS64_CNTL,

MEC_PIPE3_RESET, 0);

drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c static void gfx_v11_0_config_gfx_rs64(struct amdgpu_device *adev)

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +4 -0
        WREG32_SOC15(GC, 0, regCP_MEC_RS64_CNTL, tmp);
+
+       /* cache the firmware start PC */
+       me_fw_start_pc = RREG32(SOC15_REG_OFFSET(GC, 0,
+ regCP_GFX_RS64_INSTR_PNTR1));

You can't use a global variable. It won't work if you have multiple GPUs in the system.

Alex

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +0 -0
 }
 
 static int gfx_v11_0_wait_for_rlc_autoload_complete(struct

amdgpu_device *adev) @@ -6654,6 +6659,68 @@ static void

gfx_v11_0_emit_mem_sync(struct amdgpu_ring *ring)

Quoted 5 lines
        amdgpu_ring_write(ring, gcr_cntl); /* GCR_CNTL */  }
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +3 -0
+static bool gfx_v11_pipe_reset_support(struct amdgpu_device *adev) {
+       /* Disable the pipe reset until the CPFW fully support it.*/
+       dev_warn_once(adev->dev, "The CPFW hasn't support pipe reset

yet.\n");

Quoted 58 lines
Quoted 58 lines
Quoted 36 lines
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +36 -0
+       return false;
+}
+
+
+static int gfx_v11_reset_gfx_pipe(struct amdgpu_ring *ring) {
+       struct amdgpu_device *adev = ring->adev;
+       uint32_t reset_pipe = 0, clean_pipe = 0;
+       int r;
+
+       if (!gfx_v11_pipe_reset_support(adev))
+               return -EOPNOTSUPP;
+
+       gfx_v11_0_set_safe_mode(adev, 0);
+       mutex_lock(&adev->srbm_mutex);
+       soc21_grbm_select(adev, ring->me, ring->pipe, ring->queue,
+ 0);
+
+       switch (ring->pipe) {
+       case 0:
+               reset_pipe = REG_SET_FIELD(reset_pipe, CP_ME_CNTL,
+                                          PFP_PIPE0_RESET, 1);
+               reset_pipe = REG_SET_FIELD(reset_pipe, CP_ME_CNTL,
+                                          ME_PIPE0_RESET, 1);
+               clean_pipe = REG_SET_FIELD(clean_pipe, CP_ME_CNTL,
+                                          PFP_PIPE0_RESET, 0);
+               clean_pipe = REG_SET_FIELD(clean_pipe, CP_ME_CNTL,
+                                          ME_PIPE0_RESET, 0);
+               break;
+       case 1:
+               reset_pipe = REG_SET_FIELD(reset_pipe, CP_ME_CNTL,
+                                          PFP_PIPE1_RESET, 1);
+               reset_pipe = REG_SET_FIELD(reset_pipe, CP_ME_CNTL,
+                                          ME_PIPE1_RESET, 1);
+               clean_pipe = REG_SET_FIELD(clean_pipe, CP_ME_CNTL,
+                                          PFP_PIPE1_RESET, 0);
+               clean_pipe = REG_SET_FIELD(clean_pipe, CP_ME_CNTL,

drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c static void gfx_v11_0_emit_mem_sync(struct amdgpu_ring *ring)

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +10 -0
+                                          ME_PIPE1_RESET, 0);
+               break;
+       default:
+               break;
+       }
+
+       WREG32_SOC15(GC, 0, regCP_ME_CNTL, reset_pipe);
+       WREG32_SOC15(GC, 0, regCP_ME_CNTL, clean_pipe);
+
+       r = RREG32(SOC15_REG_OFFSET(GC, 0,

regCP_GFX_RS64_INSTR_PNTR1)) - me_fw_start_pc;

drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c static void gfx_v11_0_emit_mem_sync(struct amdgpu_ring *ring)

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +6 -0
+       soc21_grbm_select(adev, 0, 0, 0, 0);
+       mutex_unlock(&adev->srbm_mutex);
+       gfx_v11_0_unset_safe_mode(adev, 0);
+
+       dev_info(adev->dev,"The ring %s pipe reset to the ME
+ firmware start

PC: %s\n", ring->name,

drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c

Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +3 -0
+                       r == 0 ? "successfuly" : "failed");
+       /* FIXME: Sometimes driver can't cache the ME firmware
+ start PC

correctly, so the pipe reset status

Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +5 -0
+        * relies on the later gfx ring test result.
+        */
+       return 0;
+}
+
 static int gfx_v11_0_reset_kgq(struct amdgpu_ring *ring, unsigned

int

vmid)  {
        struct amdgpu_device *adev = ring->adev; @@ -6663,8

+6730,13 @@ static int gfx_v11_0_reset_kgq(struct amdgpu_ring *ring,

unsigned int vmid)

Quoted 20 lines
Quoted 20 lines

drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c static int gfx_v11_0_reset_kgq(struct amdgpu_ring *ring, unsigned int vmid)

Quoted 9 lines
                return -EINVAL;

        r = amdgpu_mes_reset_legacy_queue(ring->adev, ring, vmid, false);
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +4 -2
-       if (r)
-               return r;
+       if (r) {
+
+               dev_warn(adev->dev,"reset via MES failed and try
+ pipe reset %d\n",

r);

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +4 -1
+               r = gfx_v11_reset_gfx_pipe(ring);
+               if (r)
+                       return r;
+       }
 
        r = amdgpu_bo_reserve(ring->mqd_obj, false);
        if (unlikely(r != 0)) {
--

2.34.1