Skip to contentSkip to conversation

cleanup abuse of sched.ready in each ring init

PATCH In review Guchun Chen 4 participants 9 messages May 18, 2023 – May 31, 2023

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

cover cleanup abuse of sched.ready in each ring init

This series intend to fix the abuse of flag sched.ready in each ring init process. Its status needs to be updated only after respective ring/IB test in init/resume.

Guchun Chen (3):
drm/amdgpu/sdma: set sched.ready status after ring/IB test in sdma drm/amdgpu/gfx: set sched.ready status after ring/IB test in gfx drm/amdgpu: switch to unified amdgpu_ring_test_helper

 drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c  |  9 ++-------
 drivers/gpu/drm/amd/amdgpu/cik_sdma.c    |  2 --
 drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c   | 24 ++++-------------------
 drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c   | 25 ++++--------------------
 drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c    |  2 --
 drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c    |  2 --
 drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c  |  1 -
 drivers/gpu/drm/amd/amdgpu/mes_v10_1.c   |  8 +-------
 drivers/gpu/drm/amd/amdgpu/mes_v11_0.c   |  7 +------
 drivers/gpu/drm/amd/amdgpu/sdma_v2_4.c   |  2 --
 drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c   |  2 --
 drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c   |  4 ----
 drivers/gpu/drm/amd/amdgpu/sdma_v4_4_2.c |  4 ----
 drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c   |  2 --
 drivers/gpu/drm/amd/amdgpu/sdma_v5_2.c   |  8 ++------
 drivers/gpu/drm/amd/amdgpu/sdma_v6_0.c   |  6 +-----
 drivers/gpu/drm/amd/amdgpu/si_dma.c      |  2 --
 17 files changed, 15 insertions(+), 95 deletions(-)
Signature · 1 line
2.25.1
#1 lore raw

PATCH 1/3 drm/amdgpu/sdma: set sched.ready status after ring/IB test in sdma

sched.ready is nothing with ring initialization, it needs to set to be true after ring/IB test in amdgpu_ring_test_helper to tell the ring is ready for submission.

---
 drivers/gpu/drm/amd/amdgpu/cik_sdma.c    | 2 --
 drivers/gpu/drm/amd/amdgpu/sdma_v2_4.c   | 2 --
 drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c   | 2 --
 drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c   | 4 ----
 drivers/gpu/drm/amd/amdgpu/sdma_v4_4_2.c | 4 ----
 drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c   | 2 --
 drivers/gpu/drm/amd/amdgpu/sdma_v5_2.c   | 4 ++--
 drivers/gpu/drm/amd/amdgpu/sdma_v6_0.c   | 6 +-----
 drivers/gpu/drm/amd/amdgpu/si_dma.c      | 2 --
 9 files changed, 3 insertions(+), 25 deletions(-)
drivers/gpu/drm/amd/amdgpu/cik_sdma.c +0 -2
index 67d16236b216..52598fbc9b39 100644
@@ -489,8 +489,6 @@ static int cik_sdma_gfx_resume(struct amdgpu_device *adev)
 #endif
 		/* enable DMA IBs */
 		WREG32(mmSDMA0_GFX_IB_CNTL + sdma_offsets[i], ib_cntl);
-
-		ring->sched.ready = true;
 	}
 
 	cik_sdma_enable(adev, true);
drivers/gpu/drm/amd/amdgpu/sdma_v2_4.c +0 -2
index fd2a7b66ac56..51afc92994a8 100644
@@ -466,8 +466,6 @@ static int sdma_v2_4_gfx_resume(struct amdgpu_device *adev)
 #endif
 		/* enable DMA IBs */
 		WREG32(mmSDMA0_GFX_IB_CNTL + sdma_offsets[i], ib_cntl);
-
-		ring->sched.ready = true;
 	}
 
 	sdma_v2_4_enable(adev, true);
drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c +0 -2
index e572389089d2..344202870aeb 100644
@@ -734,8 +734,6 @@ static int sdma_v3_0_gfx_resume(struct amdgpu_device *adev)
 #endif
 		/* enable DMA IBs */
 		WREG32(mmSDMA0_GFX_IB_CNTL + sdma_offsets[i], ib_cntl);
-
-		ring->sched.ready = true;
 	}
 
 	/* unhalt the MEs */
drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c +0 -4
index 9295ac7edd56..e3581852ed9c 100644
@@ -1114,8 +1114,6 @@ static void sdma_v4_0_gfx_resume(struct amdgpu_device *adev, unsigned int i)
 #endif
 	/* enable DMA IBs */
 	WREG32_SDMA(i, mmSDMA0_GFX_IB_CNTL, ib_cntl);
-
-	ring->sched.ready = true;
 }
 
 /**
@@ -1202,8 +1200,6 @@ static void sdma_v4_0_page_resume(struct amdgpu_device *adev, unsigned int i)
 #endif
 	/* enable DMA IBs */
 	WREG32_SDMA(i, mmSDMA0_PAGE_IB_CNTL, ib_cntl);
-
-	ring->sched.ready = true;
 }
 
 static void
drivers/gpu/drm/amd/amdgpu/sdma_v4_4_2.c +0 -4
index 64dcaa2670dd..c3517d9fc38c 100644
@@ -659,8 +659,6 @@ static void sdma_v4_4_2_gfx_resume(struct amdgpu_device *adev, unsigned int i)
 #endif
 	/* enable DMA IBs */
 	WREG32_SDMA(i, regSDMA_GFX_IB_CNTL, ib_cntl);
-
-	ring->sched.ready = true;
 }
 
 /**
@@ -750,8 +748,6 @@ static void sdma_v4_4_2_page_resume(struct amdgpu_device *adev, unsigned int i)
 #endif
 	/* enable DMA IBs */
 	WREG32_SDMA(i, regSDMA_PAGE_IB_CNTL, ib_cntl);
-
-	ring->sched.ready = true;
 }
 
 static void sdma_v4_4_2_init_pg(struct amdgpu_device *adev)
drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c +0 -2
index 92e1299be021..e2fe539ff3ed 100644
@@ -819,8 +819,6 @@ static int sdma_v5_0_gfx_resume(struct amdgpu_device *adev)
 		/* enable DMA IBs */
 		WREG32_SOC15_IP(GC, sdma_v5_0_get_reg_offset(adev, i, mmSDMA0_GFX_IB_CNTL), ib_cntl);
 
-		ring->sched.ready = true;
-
 		if (amdgpu_sriov_vf(adev)) { /* bare-metal sequence doesn't need below to lines */
 			sdma_v5_0_ctx_switch_enable(adev, true);
 			sdma_v5_0_enable(adev, true);
drivers/gpu/drm/amd/amdgpu/sdma_v5_2.c +2 -2
index ca7e8757d78e..23667605c372 100644
@@ -617,8 +617,6 @@ static int sdma_v5_2_gfx_resume(struct amdgpu_device *adev)
 		/* enable DMA IBs */
 		WREG32_SOC15_IP(GC, sdma_v5_2_get_reg_offset(adev, i, mmSDMA0_GFX_IB_CNTL), ib_cntl);
 
-		ring->sched.ready = true;
-
 		if (amdgpu_sriov_vf(adev)) { /* bare-metal sequence doesn't need below to lines */
 			sdma_v5_2_ctx_switch_enable(adev, true);
 			sdma_v5_2_enable(adev, true);
@@ -630,6 +628,8 @@ static int sdma_v5_2_gfx_resume(struct amdgpu_device *adev)
 			return r;
 		}
 
+		ring->sched.ready = true;
+
 		if (adev->mman.buffer_funcs_ring == ring)
 			amdgpu_ttm_set_buffer_funcs_status(adev, true);
 	}
drivers/gpu/drm/amd/amdgpu/sdma_v6_0.c +1 -5
index 3d9a80511a45..280a878cad68 100644
@@ -585,16 +585,12 @@ static int sdma_v6_0_gfx_resume(struct amdgpu_device *adev)
 		/* enable DMA IBs */
 		WREG32_SOC15_IP(GC, sdma_v6_0_get_reg_offset(adev, i, regSDMA0_QUEUE0_IB_CNTL), ib_cntl);
 
-		ring->sched.ready = true;
-
 		if (amdgpu_sriov_vf(adev))
 			sdma_v6_0_enable(adev, true);
 
 		r = amdgpu_ring_test_helper(ring);
-		if (r) {
-			ring->sched.ready = false;
+		if (r)
 			return r;
-		}
 
 		if (adev->mman.buffer_funcs_ring == ring)
 			amdgpu_ttm_set_buffer_funcs_status(adev, true);
drivers/gpu/drm/amd/amdgpu/si_dma.c +0 -2
index abca8b529721..42c4547f32ec 100644
@@ -174,8 +174,6 @@ static int si_dma_start(struct amdgpu_device *adev)
 		WREG32(DMA_RB_WPTR + sdma_offsets[i], ring->wptr << 2);
 		WREG32(DMA_RB_CNTL + sdma_offsets[i], rb_cntl | DMA_RB_ENABLE);
 
-		ring->sched.ready = true;
-
 		r = amdgpu_ring_test_helper(ring);
 		if (r)
 			return r;
Signature · 1 line
2.25.1
Acked-by on v1 1/3
#2 lore raw

Re: [PATCH 1/3] drm/amdgpu/sdma: set sched.ready status after ring/IB test in sdma

Series is:

Quoted 174 lines · Guchun Chen

sched.ready is nothing with ring initialization, it needs to set to be true after ring/IB test in amdgpu_ring_test_helper to tell the ring is ready for submission.

---
 drivers/gpu/drm/amd/amdgpu/cik_sdma.c    | 2 --
 drivers/gpu/drm/amd/amdgpu/sdma_v2_4.c   | 2 --
 drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c   | 2 --
 drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c   | 4 ----
 drivers/gpu/drm/amd/amdgpu/sdma_v4_4_2.c | 4 ----
 drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c   | 2 --
 drivers/gpu/drm/amd/amdgpu/sdma_v5_2.c   | 4 ++--
 drivers/gpu/drm/amd/amdgpu/sdma_v6_0.c   | 6 +-----
 drivers/gpu/drm/amd/amdgpu/si_dma.c      | 2 --
 9 files changed, 3 insertions(+), 25 deletions(-)
drivers/gpu/drm/amd/amdgpu/cik_sdma.c +0 -2
index 67d16236b216..52598fbc9b39 100644
@@ -489,8 +489,6 @@ static int cik_sdma_gfx_resume(struct amdgpu_device *adev)
 #endif
                /* enable DMA IBs */
                WREG32(mmSDMA0_GFX_IB_CNTL + sdma_offsets[i], ib_cntl);
-
-               ring->sched.ready = true;
        }
 
        cik_sdma_enable(adev, true);
drivers/gpu/drm/amd/amdgpu/sdma_v2_4.c +0 -2
index fd2a7b66ac56..51afc92994a8 100644
@@ -466,8 +466,6 @@ static int sdma_v2_4_gfx_resume(struct amdgpu_device *adev)
 #endif
                /* enable DMA IBs */
                WREG32(mmSDMA0_GFX_IB_CNTL + sdma_offsets[i], ib_cntl);
-
-               ring->sched.ready = true;
        }
 
        sdma_v2_4_enable(adev, true);
drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c +0 -2
index e572389089d2..344202870aeb 100644
@@ -734,8 +734,6 @@ static int sdma_v3_0_gfx_resume(struct amdgpu_device *adev)
 #endif
                /* enable DMA IBs */
                WREG32(mmSDMA0_GFX_IB_CNTL + sdma_offsets[i], ib_cntl);
-
-               ring->sched.ready = true;
        }
 
        /* unhalt the MEs */
drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c +0 -4
index 9295ac7edd56..e3581852ed9c 100644
@@ -1114,8 +1114,6 @@ static void sdma_v4_0_gfx_resume(struct amdgpu_device *adev, unsigned int i)
 #endif
        /* enable DMA IBs */
        WREG32_SDMA(i, mmSDMA0_GFX_IB_CNTL, ib_cntl);
-
-       ring->sched.ready = true;
 }
 
 /**
@@ -1202,8 +1200,6 @@ static void sdma_v4_0_page_resume(struct amdgpu_device *adev, unsigned int i)
 #endif
        /* enable DMA IBs */
        WREG32_SDMA(i, mmSDMA0_PAGE_IB_CNTL, ib_cntl);
-
-       ring->sched.ready = true;
 }
 
 static void
drivers/gpu/drm/amd/amdgpu/sdma_v4_4_2.c +0 -4
index 64dcaa2670dd..c3517d9fc38c 100644
@@ -659,8 +659,6 @@ static void sdma_v4_4_2_gfx_resume(struct amdgpu_device *adev, unsigned int i)
 #endif
        /* enable DMA IBs */
        WREG32_SDMA(i, regSDMA_GFX_IB_CNTL, ib_cntl);
-
-       ring->sched.ready = true;
 }
 
 /**
@@ -750,8 +748,6 @@ static void sdma_v4_4_2_page_resume(struct amdgpu_device *adev, unsigned int i)
 #endif
        /* enable DMA IBs */
        WREG32_SDMA(i, regSDMA_PAGE_IB_CNTL, ib_cntl);
-
-       ring->sched.ready = true;
 }
 
 static void sdma_v4_4_2_init_pg(struct amdgpu_device *adev)
drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c +0 -2
index 92e1299be021..e2fe539ff3ed 100644
@@ -819,8 +819,6 @@ static int sdma_v5_0_gfx_resume(struct amdgpu_device *adev)
                /* enable DMA IBs */
                WREG32_SOC15_IP(GC, sdma_v5_0_get_reg_offset(adev, i, mmSDMA0_GFX_IB_CNTL), ib_cntl);
 
-               ring->sched.ready = true;
-
                if (amdgpu_sriov_vf(adev)) { /* bare-metal sequence doesn't need below to lines */
                        sdma_v5_0_ctx_switch_enable(adev, true);
                        sdma_v5_0_enable(adev, true);
drivers/gpu/drm/amd/amdgpu/sdma_v5_2.c +2 -2
index ca7e8757d78e..23667605c372 100644
@@ -617,8 +617,6 @@ static int sdma_v5_2_gfx_resume(struct amdgpu_device *adev)
                /* enable DMA IBs */
                WREG32_SOC15_IP(GC, sdma_v5_2_get_reg_offset(adev, i, mmSDMA0_GFX_IB_CNTL), ib_cntl);
 
-               ring->sched.ready = true;
-
                if (amdgpu_sriov_vf(adev)) { /* bare-metal sequence doesn't need below to lines */
                        sdma_v5_2_ctx_switch_enable(adev, true);
                        sdma_v5_2_enable(adev, true);
@@ -630,6 +628,8 @@ static int sdma_v5_2_gfx_resume(struct amdgpu_device *adev)
                        return r;
                }
 
+               ring->sched.ready = true;
+
                if (adev->mman.buffer_funcs_ring == ring)
                        amdgpu_ttm_set_buffer_funcs_status(adev, true);
        }
drivers/gpu/drm/amd/amdgpu/sdma_v6_0.c +1 -5
index 3d9a80511a45..280a878cad68 100644
@@ -585,16 +585,12 @@ static int sdma_v6_0_gfx_resume(struct amdgpu_device *adev)
                /* enable DMA IBs */
                WREG32_SOC15_IP(GC, sdma_v6_0_get_reg_offset(adev, i, regSDMA0_QUEUE0_IB_CNTL), ib_cntl);
 
-               ring->sched.ready = true;
-
                if (amdgpu_sriov_vf(adev))
                        sdma_v6_0_enable(adev, true);
 
                r = amdgpu_ring_test_helper(ring);
-               if (r) {
-                       ring->sched.ready = false;
+               if (r)
                        return r;
-               }
 
                if (adev->mman.buffer_funcs_ring == ring)
                        amdgpu_ttm_set_buffer_funcs_status(adev, true);
drivers/gpu/drm/amd/amdgpu/si_dma.c +0 -3
index abca8b529721..42c4547f32ec 100644
@@ -174,8 +174,6 @@ static int si_dma_start(struct amdgpu_device *adev)
                WREG32(DMA_RB_WPTR + sdma_offsets[i], ring->wptr << 2);
                WREG32(DMA_RB_CNTL + sdma_offsets[i], rb_cntl | DMA_RB_ENABLE);
 
-               ring->sched.ready = true;
-
                r = amdgpu_ring_test_helper(ring);
                if (r)
                        return r;
--

2.25.1

maintainer
#3 lore raw

Re: [PATCH 1/3] drm/amdgpu/sdma: set sched.ready status after ring/IB test in sdma

If you haven't already pushed it: Reviewed-by: Christian König <[email protected]> for the entire series.

Thanks for looking into that,
Christian.

Am 22.05.23 um 16:47 schrieb Alex Deucher:

Quoted 177 lines

Series is:

Quoted 173 lines · Guchun Chen

sched.ready is nothing with ring initialization, it needs to set to be true after ring/IB test in amdgpu_ring_test_helper to tell the ring is ready for submission.

---
  drivers/gpu/drm/amd/amdgpu/cik_sdma.c    | 2 --
  drivers/gpu/drm/amd/amdgpu/sdma_v2_4.c   | 2 --
  drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c   | 2 --
  drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c   | 4 ----
  drivers/gpu/drm/amd/amdgpu/sdma_v4_4_2.c | 4 ----
  drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c   | 2 --
  drivers/gpu/drm/amd/amdgpu/sdma_v5_2.c   | 4 ++--
  drivers/gpu/drm/amd/amdgpu/sdma_v6_0.c   | 6 +-----
  drivers/gpu/drm/amd/amdgpu/si_dma.c      | 2 --
  9 files changed, 3 insertions(+), 25 deletions(-)
drivers/gpu/drm/amd/amdgpu/cik_sdma.c +0 -2
index 67d16236b216..52598fbc9b39 100644
@@ -489,8 +489,6 @@ static int cik_sdma_gfx_resume(struct amdgpu_device *adev)
  #endif
                 /* enable DMA IBs */
                 WREG32(mmSDMA0_GFX_IB_CNTL + sdma_offsets[i], ib_cntl);
-
-               ring->sched.ready = true;
         }
 
         cik_sdma_enable(adev, true);
drivers/gpu/drm/amd/amdgpu/sdma_v2_4.c +0 -2
index fd2a7b66ac56..51afc92994a8 100644
@@ -466,8 +466,6 @@ static int sdma_v2_4_gfx_resume(struct amdgpu_device *adev)
  #endif
                 /* enable DMA IBs */
                 WREG32(mmSDMA0_GFX_IB_CNTL + sdma_offsets[i], ib_cntl);
-
-               ring->sched.ready = true;
         }
 
         sdma_v2_4_enable(adev, true);
drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c +0 -2
index e572389089d2..344202870aeb 100644
@@ -734,8 +734,6 @@ static int sdma_v3_0_gfx_resume(struct amdgpu_device *adev)
  #endif
                 /* enable DMA IBs */
                 WREG32(mmSDMA0_GFX_IB_CNTL + sdma_offsets[i], ib_cntl);
-
-               ring->sched.ready = true;
         }
 
         /* unhalt the MEs */
drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c +0 -4
index 9295ac7edd56..e3581852ed9c 100644
@@ -1114,8 +1114,6 @@ static void sdma_v4_0_gfx_resume(struct amdgpu_device *adev, unsigned int i)
  #endif
         /* enable DMA IBs */
         WREG32_SDMA(i, mmSDMA0_GFX_IB_CNTL, ib_cntl);
-
-       ring->sched.ready = true;
  }
 
  /**
@@ -1202,8 +1200,6 @@ static void sdma_v4_0_page_resume(struct amdgpu_device *adev, unsigned int i)
  #endif
         /* enable DMA IBs */
         WREG32_SDMA(i, mmSDMA0_PAGE_IB_CNTL, ib_cntl);
-
-       ring->sched.ready = true;
  }
 
  static void
drivers/gpu/drm/amd/amdgpu/sdma_v4_4_2.c +0 -4
index 64dcaa2670dd..c3517d9fc38c 100644
@@ -659,8 +659,6 @@ static void sdma_v4_4_2_gfx_resume(struct amdgpu_device *adev, unsigned int i)
  #endif
         /* enable DMA IBs */
         WREG32_SDMA(i, regSDMA_GFX_IB_CNTL, ib_cntl);
-
-       ring->sched.ready = true;
  }
 
  /**
@@ -750,8 +748,6 @@ static void sdma_v4_4_2_page_resume(struct amdgpu_device *adev, unsigned int i)
  #endif
         /* enable DMA IBs */
         WREG32_SDMA(i, regSDMA_PAGE_IB_CNTL, ib_cntl);
-
-       ring->sched.ready = true;
  }
 
  static void sdma_v4_4_2_init_pg(struct amdgpu_device *adev)
drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c +0 -2
index 92e1299be021..e2fe539ff3ed 100644
@@ -819,8 +819,6 @@ static int sdma_v5_0_gfx_resume(struct amdgpu_device *adev)
                 /* enable DMA IBs */
                 WREG32_SOC15_IP(GC, sdma_v5_0_get_reg_offset(adev, i, mmSDMA0_GFX_IB_CNTL), ib_cntl);
 
-               ring->sched.ready = true;
-
                 if (amdgpu_sriov_vf(adev)) { /* bare-metal sequence doesn't need below to lines */
                         sdma_v5_0_ctx_switch_enable(adev, true);
                         sdma_v5_0_enable(adev, true);
drivers/gpu/drm/amd/amdgpu/sdma_v5_2.c +2 -2
index ca7e8757d78e..23667605c372 100644
@@ -617,8 +617,6 @@ static int sdma_v5_2_gfx_resume(struct amdgpu_device *adev)
                 /* enable DMA IBs */
                 WREG32_SOC15_IP(GC, sdma_v5_2_get_reg_offset(adev, i, mmSDMA0_GFX_IB_CNTL), ib_cntl);
 
-               ring->sched.ready = true;
-
                 if (amdgpu_sriov_vf(adev)) { /* bare-metal sequence doesn't need below to lines */
                         sdma_v5_2_ctx_switch_enable(adev, true);
                         sdma_v5_2_enable(adev, true);
@@ -630,6 +628,8 @@ static int sdma_v5_2_gfx_resume(struct amdgpu_device *adev)
                         return r;
                 }
 
+               ring->sched.ready = true;
+
                 if (adev->mman.buffer_funcs_ring == ring)
                         amdgpu_ttm_set_buffer_funcs_status(adev, true);
         }
drivers/gpu/drm/amd/amdgpu/sdma_v6_0.c +1 -5
index 3d9a80511a45..280a878cad68 100644
@@ -585,16 +585,12 @@ static int sdma_v6_0_gfx_resume(struct amdgpu_device *adev)
                 /* enable DMA IBs */
                 WREG32_SOC15_IP(GC, sdma_v6_0_get_reg_offset(adev, i, regSDMA0_QUEUE0_IB_CNTL), ib_cntl);
 
-               ring->sched.ready = true;
-
                 if (amdgpu_sriov_vf(adev))
                         sdma_v6_0_enable(adev, true);
 
                 r = amdgpu_ring_test_helper(ring);
-               if (r) {
-                       ring->sched.ready = false;
+               if (r)
                         return r;
-               }
 
                 if (adev->mman.buffer_funcs_ring == ring)
                         amdgpu_ttm_set_buffer_funcs_status(adev, true);
drivers/gpu/drm/amd/amdgpu/si_dma.c +0 -3
index abca8b529721..42c4547f32ec 100644
@@ -174,8 +174,6 @@ static int si_dma_start(struct amdgpu_device *adev)
                 WREG32(DMA_RB_WPTR + sdma_offsets[i], ring->wptr << 2);
                 WREG32(DMA_RB_CNTL + sdma_offsets[i], rb_cntl | DMA_RB_ENABLE);
 
-               ring->sched.ready = true;
-
                 r = amdgpu_ring_test_helper(ring);
                 if (r)
                         return r;
--

2.25.1

#4 lore raw

RE: [PATCH 1/3] drm/amdgpu/sdma: set sched.ready status after ring/IB test in sdma

[Public]

Thanks for your review, Christian. I have pushed them to amd-staging-drm-next branch with Alex's Acked-by last week.

Regards,
Guchun

Quoted 226 lines

-----Original Message-----
From: Koenig, Christian <[email protected]>
Sent: Wednesday, May 31, 2023 2:39 PM
To: Alex Deucher <[email protected]>; Chen, Guchun <[email protected]>
Cc: [email protected]; Deucher, Alexander <[email protected]>; Zhang, Hawking <[email protected]>; Pan, Xinhui <[email protected]>
Subject: Re: [PATCH 1/3] drm/amdgpu/sdma: set sched.ready status after ring/IB test in sdma

If you haven't already pushed it: Reviewed-by: Christian König <[email protected]> for the entire series.

Thanks for looking into that,
Christian.

Am 22.05.23 um 16:47 schrieb Alex Deucher:

Quoted 4 lines

Series is:

On Thu, May 18, 2023 at 3:04 AM Guchun Chen <[email protected]>

Quoted 17 lines · wrote:
Quoted 17 lines

sched.ready is nothing with ring initialization, it needs to set to be true after ring/IB test in amdgpu_ring_test_helper to tell the ring is ready for submission.

---
  drivers/gpu/drm/amd/amdgpu/cik_sdma.c    | 2 --
  drivers/gpu/drm/amd/amdgpu/sdma_v2_4.c   | 2 --
  drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c   | 2 --
  drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c   | 4 ----
  drivers/gpu/drm/amd/amdgpu/sdma_v4_4_2.c | 4 ----
  drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c   | 2 --
  drivers/gpu/drm/amd/amdgpu/sdma_v5_2.c   | 4 ++--
  drivers/gpu/drm/amd/amdgpu/sdma_v6_0.c   | 6 +-----
  drivers/gpu/drm/amd/amdgpu/si_dma.c      | 2 --
  9 files changed, 3 insertions(+), 25 deletions(-)
Quoted 6 lines

drivers/gpu/drm/amd/amdgpu/cik_sdma.c static int cik_sdma_gfx_resume(struct

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/cik_sdma.c +0 -0
index 67d16236b216..52598fbc9b39 100644
@@ -489,8 +489,6 @@ static int cik_sdma_gfx_resume(struct

amdgpu_device *adev)

Quoted 8 lines
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/cik_sdma.c +0 -2
  #endif
                 /* enable DMA IBs */
                 WREG32(mmSDMA0_GFX_IB_CNTL + sdma_offsets[i],
 ib_cntl);
-
-               ring->sched.ready = true;
         }
 
Quoted 7 lines

drivers/gpu/drm/amd/amdgpu/sdma_v2_4.c static int sdma_v2_4_gfx_resume(struct

Quoted 7 lines
         cik_sdma_enable(adev, true); diff --git

a/drivers/gpu/drm/amd/amdgpu/sdma_v2_4.c
b/drivers/gpu/drm/amd/amdgpu/sdma_v2_4.c
index fd2a7b66ac56..51afc92994a8 100644

drivers/gpu/drm/amd/amdgpu/sdma_v2_4.c +0 -0
@@ -466,8 +466,6 @@ static int sdma_v2_4_gfx_resume(struct

amdgpu_device *adev)

Quoted 8 lines
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/sdma_v2_4.c +0 -2
  #endif
                 /* enable DMA IBs */
                 WREG32(mmSDMA0_GFX_IB_CNTL + sdma_offsets[i],
 ib_cntl);
-
-               ring->sched.ready = true;
         }
 
Quoted 7 lines

drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c static int sdma_v3_0_gfx_resume(struct

Quoted 7 lines
         sdma_v2_4_enable(adev, true); diff --git

a/drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c
b/drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c
index e572389089d2..344202870aeb 100644

drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c +0 -0
@@ -734,8 +734,6 @@ static int sdma_v3_0_gfx_resume(struct

amdgpu_device *adev)

Quoted 8 lines
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c +0 -2
  #endif
                 /* enable DMA IBs */
                 WREG32(mmSDMA0_GFX_IB_CNTL + sdma_offsets[i],
 ib_cntl);
-
-               ring->sched.ready = true;
         }
 
Quoted 7 lines

drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c static void sdma_v4_0_gfx_resume(struct

Quoted 7 lines
         /* unhalt the MEs */
drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c +0 -0
index 9295ac7edd56..e3581852ed9c 100644
@@ -1114,8 +1114,6 @@ static void sdma_v4_0_gfx_resume(struct

amdgpu_device *adev, unsigned int i)

Quoted 9 lines

drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c static void sdma_v4_0_page_resume(struct

Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c +0 -2
  #endif
         /* enable DMA IBs */
         WREG32_SDMA(i, mmSDMA0_GFX_IB_CNTL, ib_cntl);
-
-       ring->sched.ready = true;
  }
 
  /**
@@ -1202,8 +1200,6 @@ static void sdma_v4_0_page_resume(struct

amdgpu_device *adev, unsigned int i)

Quoted 7 lines
Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c +0 -2
  #endif
         /* enable DMA IBs */
         WREG32_SDMA(i, mmSDMA0_PAGE_IB_CNTL, ib_cntl);
-
-       ring->sched.ready = true;
  }
 
Quoted 7 lines

drivers/gpu/drm/amd/amdgpu/sdma_v4_4_2.c static void sdma_v4_4_2_gfx_resume(struct

Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c +0 -0
  static void
drivers/gpu/drm/amd/amdgpu/sdma_v4_4_2.c +0 -0
index 64dcaa2670dd..c3517d9fc38c 100644
@@ -659,8 +659,6 @@ static void sdma_v4_4_2_gfx_resume(struct

amdgpu_device *adev, unsigned int i)

Quoted 9 lines

drivers/gpu/drm/amd/amdgpu/sdma_v4_4_2.c static void sdma_v4_4_2_page_resume(struct

Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/sdma_v4_4_2.c +0 -2
  #endif
         /* enable DMA IBs */
         WREG32_SDMA(i, regSDMA_GFX_IB_CNTL, ib_cntl);
-
-       ring->sched.ready = true;
  }
 
  /**
@@ -750,8 +748,6 @@ static void sdma_v4_4_2_page_resume(struct

amdgpu_device *adev, unsigned int i)

Quoted 7 lines
Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/sdma_v4_4_2.c +0 -2
  #endif
         /* enable DMA IBs */
         WREG32_SDMA(i, regSDMA_PAGE_IB_CNTL, ib_cntl);
-
-       ring->sched.ready = true;
  }
 
Quoted 7 lines

drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c static int sdma_v5_0_gfx_resume(struct

Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/sdma_v4_4_2.c +0 -1
  static void sdma_v4_4_2_init_pg(struct amdgpu_device *adev) diff
--git a/drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c

b/drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c
index 92e1299be021..e2fe539ff3ed 100644

drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c +0 -0
@@ -819,8 +819,6 @@ static int sdma_v5_0_gfx_resume(struct

amdgpu_device *adev)

Quoted 7 lines

drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c static int sdma_v5_0_gfx_resume(struct amdgpu_device *adev)

Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c +0 -2
                 /* enable DMA IBs */
                 WREG32_SOC15_IP(GC, sdma_v5_0_get_reg_offset(adev,
 i, mmSDMA0_GFX_IB_CNTL), ib_cntl);
 
-               ring->sched.ready = true;
-
                 if (amdgpu_sriov_vf(adev)) { /* bare-metal sequence doesn't

need below to lines */

Quoted 8 lines

drivers/gpu/drm/amd/amdgpu/sdma_v5_2.c static int sdma_v5_2_gfx_resume(struct

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c +0 -0
                         sdma_v5_0_ctx_switch_enable(adev, true);
                         sdma_v5_0_enable(adev, true); diff --git

a/drivers/gpu/drm/amd/amdgpu/sdma_v5_2.c
b/drivers/gpu/drm/amd/amdgpu/sdma_v5_2.c
index ca7e8757d78e..23667605c372 100644

drivers/gpu/drm/amd/amdgpu/sdma_v5_2.c +0 -0
@@ -617,8 +617,6 @@ static int sdma_v5_2_gfx_resume(struct

amdgpu_device *adev)

Quoted 7 lines

drivers/gpu/drm/amd/amdgpu/sdma_v5_2.c static int sdma_v5_2_gfx_resume(struct · line 621

Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/sdma_v5_2.c +0 -2
                 /* enable DMA IBs */
                 WREG32_SOC15_IP(GC, sdma_v5_2_get_reg_offset(adev,
 i, mmSDMA0_GFX_IB_CNTL), ib_cntl);
 
-               ring->sched.ready = true;
-
                 if (amdgpu_sriov_vf(adev)) { /* bare-metal sequence doesn't

need below to lines */

Quoted 3 lines
Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/sdma_v5_2.c +0 -0
                         sdma_v5_2_ctx_switch_enable(adev, true);
                         sdma_v5_2_enable(adev, true); @@ -630,6

+628,8 @@ static int sdma_v5_2_gfx_resume(struct amdgpu_device

*adev)

Quoted 14 lines

drivers/gpu/drm/amd/amdgpu/sdma_v6_0.c static int sdma_v6_0_gfx_resume(struct

Quoted 14 lines
                         return r;
                 }
drivers/gpu/drm/amd/amdgpu/sdma_v5_2.c +2 -0
+               ring->sched.ready = true;
+
                 if (adev->mman.buffer_funcs_ring == ring)
                         amdgpu_ttm_set_buffer_funcs_status(adev, true);
         }
drivers/gpu/drm/amd/amdgpu/sdma_v6_0.c +0 -0
index 3d9a80511a45..280a878cad68 100644
@@ -585,16 +585,12 @@ static int sdma_v6_0_gfx_resume(struct

amdgpu_device *adev)

Quoted 16 lines
Quoted 16 lines
drivers/gpu/drm/amd/amdgpu/sdma_v6_0.c +1 -5
                 /* enable DMA IBs */
                 WREG32_SOC15_IP(GC, sdma_v6_0_get_reg_offset(adev,
 i, regSDMA0_QUEUE0_IB_CNTL), ib_cntl);
 
-               ring->sched.ready = true;
-
                 if (amdgpu_sriov_vf(adev))
                         sdma_v6_0_enable(adev, true);
 
                 r = amdgpu_ring_test_helper(ring);
-               if (r) {
-                       ring->sched.ready = false;
+               if (r)
                         return r;
-               }
 
Quoted 8 lines

drivers/gpu/drm/amd/amdgpu/si_dma.c static int si_dma_start(struct amdgpu_device

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/sdma_v6_0.c +0 -0
                 if (adev->mman.buffer_funcs_ring == ring)

amdgpu_ttm_set_buffer_funcs_status(adev,
true); diff --git a/drivers/gpu/drm/amd/amdgpu/si_dma.c b/drivers/gpu/drm/amd/amdgpu/si_dma.c
index abca8b529721..42c4547f32ec 100644

drivers/gpu/drm/amd/amdgpu/si_dma.c +0 -0
@@ -174,8 +174,6 @@ static int si_dma_start(struct amdgpu_device

*adev)

Quoted 12 lines
Quoted 12 lines
drivers/gpu/drm/amd/amdgpu/si_dma.c +0 -2
                 WREG32(DMA_RB_WPTR + sdma_offsets[i], ring->wptr << 2);
                 WREG32(DMA_RB_CNTL + sdma_offsets[i], rb_cntl |
 DMA_RB_ENABLE);
 
-               ring->sched.ready = true;
-
                 r = amdgpu_ring_test_helper(ring);
                 if (r)
                         return r;

--
2.25.1

#5 lore raw

PATCH 2/3 drm/amdgpu/gfx: set sched.ready status after ring/IB test in gfx

In reply to Guchun Chen

sched.ready is nothing with ring initialization, it needs to set to be true after ring/IB test in amdgpu_ring_test_helper to tell the ring is ready for submission.

---
 drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c  | 24 ++++--------------------
 drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c  | 25 ++++---------------------
 drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c   |  2 --
 drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c   |  2 --
 drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c |  1 -
 5 files changed, 8 insertions(+), 46 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c +4 -20
index 8e86b2c23c0a..d57671c729bb 100644
@@ -6073,7 +6073,6 @@ static int gfx_v10_0_cp_gfx_resume(struct amdgpu_device *adev)
 	u32 tmp;
 	u32 rb_bufsz;
 	u64 rb_addr, rptr_addr, wptr_gpu_addr;
-	u32 i;
 
 	/* Set the write pointer delay */
 	WREG32_SOC15(GC, 0, mmCP_RB_WPTR_DELAY, 0);
@@ -6168,11 +6167,6 @@ static int gfx_v10_0_cp_gfx_resume(struct amdgpu_device *adev)
 	/* start the ring */
 	gfx_v10_0_cp_gfx_start(adev);
 
-	for (i = 0; i < adev->gfx.num_gfx_rings; i++) {
-		ring = &adev->gfx.gfx_ring[i];
-		ring->sched.ready = true;
-	}
-
 	return 0;
 }
 
@@ -6470,7 +6464,7 @@ static int gfx_v10_0_cp_async_gfx_ring_resume(struct amdgpu_device *adev)
 
 		r = amdgpu_bo_reserve(ring->mqd_obj, false);
 		if (unlikely(r != 0))
-			goto done;
+			return r;
 
 		r = amdgpu_bo_kmap(ring->mqd_obj, (void **)&ring->mqd_ptr);
 		if (!r) {
@@ -6480,23 +6474,14 @@ static int gfx_v10_0_cp_async_gfx_ring_resume(struct amdgpu_device *adev)
 		}
 		amdgpu_bo_unreserve(ring->mqd_obj);
 		if (r)
-			goto done;
+			return r;
 	}
 
 	r = amdgpu_gfx_enable_kgq(adev, 0);
 	if (r)
-		goto done;
-
-	r = gfx_v10_0_cp_gfx_start(adev);
-	if (r)
-		goto done;
+		return r;
 
-	for (i = 0; i < adev->gfx.num_gfx_rings; i++) {
-		ring = &adev->gfx.gfx_ring[i];
-		ring->sched.ready = true;
-	}
-done:
-	return r;
+	return gfx_v10_0_cp_gfx_start(adev);
 }
 
 static int gfx_v10_0_compute_mqd_init(struct amdgpu_device *adev, void *m,
@@ -6810,7 +6795,6 @@ static int gfx_v10_0_kiq_resume(struct amdgpu_device *adev)
 	amdgpu_bo_kunmap(ring->mqd_obj);
 	ring->mqd_ptr = NULL;
 	amdgpu_bo_unreserve(ring->mqd_obj);
-	ring->sched.ready = true;
 	return 0;
 }
 
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +4 -21
index f77779c31043..b9a4ef396628 100644
@@ -3228,7 +3228,6 @@ static int gfx_v11_0_cp_gfx_resume(struct amdgpu_device *adev)
 	u32 tmp;
 	u32 rb_bufsz;
 	u64 rb_addr, rptr_addr, wptr_gpu_addr;
-	u32 i;
 
 	/* Set the write pointer delay */
 	WREG32_SOC15(GC, 0, regCP_RB_WPTR_DELAY, 0);
@@ -3320,11 +3319,6 @@ static int gfx_v11_0_cp_gfx_resume(struct amdgpu_device *adev)
 	/* start the ring */
 	gfx_v11_0_cp_gfx_start(adev);
 
-	for (i = 0; i < adev->gfx.num_gfx_rings; i++) {
-		ring = &adev->gfx.gfx_ring[i];
-		ring->sched.ready = true;
-	}
-
 	return 0;
 }
 
@@ -3370,8 +3364,6 @@ static void gfx_v11_0_cp_compute_enable(struct amdgpu_device *adev, bool enable)
 		WREG32_SOC15(GC, 0, regCP_MEC_CNTL, data);
 	}
 
-	adev->gfx.kiq[0].ring.sched.ready = enable;
-
 	udelay(50);
 }
 
@@ -3711,7 +3703,7 @@ static int gfx_v11_0_cp_async_gfx_ring_resume(struct amdgpu_device *adev)
 
 		r = amdgpu_bo_reserve(ring->mqd_obj, false);
 		if (unlikely(r != 0))
-			goto done;
+			return r;
 
 		r = amdgpu_bo_kmap(ring->mqd_obj, (void **)&ring->mqd_ptr);
 		if (!r) {
@@ -3721,23 +3713,14 @@ static int gfx_v11_0_cp_async_gfx_ring_resume(struct amdgpu_device *adev)
 		}
 		amdgpu_bo_unreserve(ring->mqd_obj);
 		if (r)
-			goto done;
+			return r;
 	}
 
 	r = amdgpu_gfx_enable_kgq(adev, 0);
 	if (r)
-		goto done;
-
-	r = gfx_v11_0_cp_gfx_start(adev);
-	if (r)
-		goto done;
+		return r;
 
-	for (i = 0; i < adev->gfx.num_gfx_rings; i++) {
-		ring = &adev->gfx.gfx_ring[i];
-		ring->sched.ready = true;
-	}
-done:
-	return r;
+	return gfx_v11_0_cp_gfx_start(adev);
 }
 
 static int gfx_v11_0_compute_mqd_init(struct amdgpu_device *adev, void *m,
drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c +0 -2
index 2ae7f167985f..22828bdb5c70 100644
@@ -4283,7 +4283,6 @@ static int gfx_v8_0_cp_gfx_resume(struct amdgpu_device *adev)
 	/* start the ring */
 	amdgpu_ring_clear_ring(ring);
 	gfx_v8_0_cp_gfx_start(adev);
-	ring->sched.ready = true;
 
 	return 0;
 }
@@ -4693,7 +4692,6 @@ static int gfx_v8_0_kiq_resume(struct amdgpu_device *adev)
 	amdgpu_bo_kunmap(ring->mqd_obj);
 	ring->mqd_ptr = NULL;
 	amdgpu_bo_unreserve(ring->mqd_obj);
-	ring->sched.ready = true;
 	return 0;
 }
 
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +0 -2
index e093e83ae739..dcfaf3176da4 100644
@@ -3144,7 +3144,6 @@ static int gfx_v9_0_cp_gfx_resume(struct amdgpu_device *adev)
 
 	/* start the ring */
 	gfx_v9_0_cp_gfx_start(adev);
-	ring->sched.ready = true;
 
 	return 0;
 }
@@ -3621,7 +3620,6 @@ static int gfx_v9_0_kiq_resume(struct amdgpu_device *adev)
 	amdgpu_bo_kunmap(ring->mqd_obj);
 	ring->mqd_ptr = NULL;
 	amdgpu_bo_unreserve(ring->mqd_obj);
-	ring->sched.ready = true;
 	return 0;
 }
 
drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c +0 -1
index 9d17dcfae130..fa97c8c603f0 100644
@@ -1829,7 +1829,6 @@ static int gfx_v9_4_3_kiq_resume(struct amdgpu_device *adev, int xcc_id)
 	amdgpu_bo_kunmap(ring->mqd_obj);
 	ring->mqd_ptr = NULL;
 	amdgpu_bo_unreserve(ring->mqd_obj);
-	ring->sched.ready = true;
 	return 0;
 }
 
Signature · 1 line
2.25.1
#6 lore raw

PATCH 3/3 drm/amdgpu: switch to unified amdgpu_ring_test_helper

In reply to Guchun Chen

This will simplify code.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c | 9 ++-------
 drivers/gpu/drm/amd/amdgpu/mes_v10_1.c  | 8 +-------
 drivers/gpu/drm/amd/amdgpu/mes_v11_0.c  | 7 +------
 drivers/gpu/drm/amd/amdgpu/sdma_v5_2.c  | 8 ++------
 4 files changed, 6 insertions(+), 26 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c +2 -7
index f0f00466b59f..49bb6c03d606 100644
@@ -1305,14 +1305,9 @@ static int amdgpu_mes_test_queues(struct amdgpu_ring **added_rings)
 		if (!ring)
 			continue;
 
-		r = amdgpu_ring_test_ring(ring);
-		if (r) {
-			DRM_DEV_ERROR(ring->adev->dev,
-				      "ring %s test failed (%d)\n",
-				      ring->name, r);
+		r = amdgpu_ring_test_helper(ring);
+		if (r)
 			return r;
-		} else
-			DRM_INFO("ring %s test pass\n", ring->name);
 
 		r = amdgpu_ring_test_ib(ring, 1000 * 10);
 		if (r) {
drivers/gpu/drm/amd/amdgpu/mes_v10_1.c +1 -7
index 4560476c7c31..af66e985a33a 100644
@@ -812,13 +812,7 @@ static int mes_v10_1_kiq_enable_queue(struct amdgpu_device *adev)
 
 	kiq->pmf->kiq_map_queues(kiq_ring, &adev->mes.ring);
 
-	r = amdgpu_ring_test_ring(kiq_ring);
-	if (r) {
-		DRM_ERROR("kfq enable failed\n");
-		kiq_ring->sched.ready = false;
-	}
-
-	return r;
+	return amdgpu_ring_test_helper(kiq_ring);
 }
 
 static int mes_v10_1_queue_init(struct amdgpu_device *adev)
drivers/gpu/drm/amd/amdgpu/mes_v11_0.c +1 -6
index 3adb450eec07..b8eabb37d48d 100644
@@ -879,12 +879,7 @@ static int mes_v11_0_kiq_enable_queue(struct amdgpu_device *adev)
 
 	kiq->pmf->kiq_map_queues(kiq_ring, &adev->mes.ring);
 
-	r = amdgpu_ring_test_ring(kiq_ring);
-	if (r) {
-		DRM_ERROR("kfq enable failed\n");
-		kiq_ring->sched.ready = false;
-	}
-	return r;
+	return amdgpu_ring_test_helper(kiq_ring);
 }
 
 static int mes_v11_0_queue_init(struct amdgpu_device *adev,
drivers/gpu/drm/amd/amdgpu/sdma_v5_2.c +2 -6
index 23667605c372..3f722d21b17f 100644
@@ -622,13 +622,9 @@ static int sdma_v5_2_gfx_resume(struct amdgpu_device *adev)
 			sdma_v5_2_enable(adev, true);
 		}
 
-		r = amdgpu_ring_test_ring(ring);
-		if (r) {
-			ring->sched.ready = false;
+		r = amdgpu_ring_test_helper(ring);
+		if (r)
 			return r;
-		}
-
-		ring->sched.ready = true;
 
 		if (adev->mman.buffer_funcs_ring == ring)
 			amdgpu_ttm_set_buffer_funcs_status(adev, true);
Signature · 1 line
2.25.1
#7 lore raw
In reply to Guchun Chen

[AMD Official Use Only - General]

Threre are a lot of places in the code where we check sched.ready. Will this break any of those?

Alex

________________________________
From: Chen, Guchun <[email protected]>
Sent: Thursday, May 18, 2023 3:02 AM
To: [email protected] <[email protected]>; Deucher, Alexander <[email protected]>; Zhang, Hawking <[email protected]>; Koenig, Christian <[email protected]>; Pan, Xinhui <[email protected]>
Cc: Chen, Guchun <[email protected]>
Subject: [PATCH 0/3] cleanup abuse of sched.ready in each ring init

This series intend to fix the abuse of flag sched.ready in each ring init process. Its status needs to be updated only after respective ring/IB test in init/resume.

Guchun Chen (3):
drm/amdgpu/sdma: set sched.ready status after ring/IB test in sdma drm/amdgpu/gfx: set sched.ready status after ring/IB test in gfx drm/amdgpu: switch to unified amdgpu_ring_test_helper

 drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c  |  9 ++-------
 drivers/gpu/drm/amd/amdgpu/cik_sdma.c    |  2 --
 drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c   | 24 ++++-------------------
 drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c   | 25 ++++--------------------
 drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c    |  2 --
 drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c    |  2 --
 drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c  |  1 -
 drivers/gpu/drm/amd/amdgpu/mes_v10_1.c   |  8 +-------
 drivers/gpu/drm/amd/amdgpu/mes_v11_0.c   |  7 +------
 drivers/gpu/drm/amd/amdgpu/sdma_v2_4.c   |  2 --
 drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c   |  2 --
 drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c   |  4 ----
 drivers/gpu/drm/amd/amdgpu/sdma_v4_4_2.c |  4 ----
 drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c   |  2 --
 drivers/gpu/drm/amd/amdgpu/sdma_v5_2.c   |  8 ++------
 drivers/gpu/drm/amd/amdgpu/sdma_v6_0.c   |  6 +-----
 drivers/gpu/drm/amd/amdgpu/si_dma.c      |  2 --
 17 files changed, 15 insertions(+), 95 deletions(-)

--
2.25.1

#8 lore raw

[Public]

Hello Alex,

Should not. Almost original codes set sched.ready before amdgpu_ring_test_helper in each ring initialization. The new codes drop that and leave sched.ready set in amdgpu_ring_test_helper. I tested it both on gfx10 and gfx11 chip.

Regards,
Guchun

From: Deucher, Alexander <[email protected]>
Sent: Thursday, May 18, 2023 10:47 PM
To: Chen, Guchun <[email protected]>; [email protected]; Zhang, Hawking <[email protected]>; Koenig, Christian <[email protected]>; Pan, Xinhui <[email protected]>
Subject: Re: [PATCH 0/3] cleanup abuse of sched.ready in each ring init

[AMD Official Use Only - General]

Threre are a lot of places in the code where we check sched.ready. Will this break any of those?

Alex

________________________________
From: Chen, Guchun <[email protected]<mailto:[email protected]>>
Sent: Thursday, May 18, 2023 3:02 AM
To: [email protected]<mailto:[email protected]> <[email protected]<mailto:[email protected]>>; Deucher, Alexander <[email protected]<mailto:[email protected]>>; Zhang, Hawking <[email protected]<mailto:[email protected]>>; Koenig, Christian <[email protected]<mailto:[email protected]>>; Pan, Xinhui <[email protected]<mailto:[email protected]>>
Cc: Chen, Guchun <[email protected]<mailto:[email protected]>>
Subject: [PATCH 0/3] cleanup abuse of sched.ready in each ring init

This series intend to fix the abuse of flag sched.ready in each ring init process. Its status needs to be updated only after respective ring/IB test in init/resume.

Guchun Chen (3):
drm/amdgpu/sdma: set sched.ready status after ring/IB test in sdma drm/amdgpu/gfx: set sched.ready status after ring/IB test in gfx drm/amdgpu: switch to unified amdgpu_ring_test_helper

 drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c  |  9 ++-------
 drivers/gpu/drm/amd/amdgpu/cik_sdma.c    |  2 --
 drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c   | 24 ++++-------------------
 drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c   | 25 ++++--------------------
 drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c    |  2 --
 drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c    |  2 --
 drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c  |  1 -
 drivers/gpu/drm/amd/amdgpu/mes_v10_1.c   |  8 +-------
 drivers/gpu/drm/amd/amdgpu/mes_v11_0.c   |  7 +------
 drivers/gpu/drm/amd/amdgpu/sdma_v2_4.c   |  2 --
 drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c   |  2 --
 drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c   |  4 ----
 drivers/gpu/drm/amd/amdgpu/sdma_v4_4_2.c |  4 ----
 drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c   |  2 --
 drivers/gpu/drm/amd/amdgpu/sdma_v5_2.c   |  8 ++------
 drivers/gpu/drm/amd/amdgpu/sdma_v6_0.c   |  6 +-----
 drivers/gpu/drm/amd/amdgpu/si_dma.c      |  2 --
 17 files changed, 15 insertions(+), 95 deletions(-)

--
2.25.1