[PATCH 6/6] drm/amd/amdgpu: Avoid re-parser CSB in gfx_v11_0_cp_gfx_start

Rodrigo Siqueira siqueira at igalia.com
Sun May 4 21:47:39 UTC 2025


Remove the unnecessary parser of the CSB buffer in the GFX11, and
directly use the result from "adev->gfx.rlc.cs_ptr".

Signed-off-by: Rodrigo Siqueira <siqueira at igalia.com>
---
 drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c | 23 +++++------------------
 1 file changed, 5 insertions(+), 18 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c
index 3f4ee4b3b0a4..a9ff66525ce1 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c
@@ -3575,10 +3575,8 @@ static int gfx_v11_0_cp_gfx_load_microcode(struct amdgpu_device *adev)
 static int gfx_v11_0_cp_gfx_start(struct amdgpu_device *adev)
 {
 	struct amdgpu_ring *ring;
-	const struct cs_section_def *sect = NULL;
-	const struct cs_extent_def *ext = NULL;
-	int r, i;
-	int ctx_reg_offset;
+	u32 csb_size;
+	int r, ctx_reg_offset;
 
 	/* init the CP */
 	WREG32_SOC15(GC, 0, regCP_MAX_CONTEXT,
@@ -3589,7 +3587,8 @@ static int gfx_v11_0_cp_gfx_start(struct amdgpu_device *adev)
 		gfx_v11_0_cp_gfx_enable(adev, true);
 
 	ring = &adev->gfx.gfx_ring[0];
-	r = amdgpu_ring_alloc(ring, gfx_v11_0_get_csb_size(adev));
+	csb_size = gfx_v11_0_get_csb_size(adev);
+	r = amdgpu_ring_alloc(ring, csb_size);
 	if (r) {
 		DRM_ERROR("amdgpu: cp failed to lock ring (%d).\n", r);
 		return r;
@@ -3602,19 +3601,7 @@ static int gfx_v11_0_cp_gfx_start(struct amdgpu_device *adev)
 	amdgpu_ring_write(ring, 0x80000000);
 	amdgpu_ring_write(ring, 0x80000000);
 
-	for (sect = gfx11_cs_data; sect->section != NULL; ++sect) {
-		for (ext = sect->section; ext->extent != NULL; ++ext) {
-			if (sect->id == SECT_CONTEXT) {
-				amdgpu_ring_write(ring,
-						  PACKET3(PACKET3_SET_CONTEXT_REG,
-							  ext->reg_count));
-				amdgpu_ring_write(ring, ext->reg_index -
-						  PACKET3_SET_CONTEXT_REG_START);
-				for (i = 0; i < ext->reg_count; i++)
-					amdgpu_ring_write(ring, ext->extent[i]);
-			}
-		}
-	}
+	amdgpu_gfx_write_csb_to_ring(ring, adev->gfx.rlc.cs_ptr, csb_size);
 
 	ctx_reg_offset =
 		SOC15_REG_OFFSET(GC, 0, regPA_SC_TILE_STEERING_OVERRIDE) - PACKET3_SET_CONTEXT_REG_START;
-- 
2.47.2



More information about the amd-gfx mailing list