Use amdgpu_gfx_write_csb_to_ring() to replace duplicated CSB parse in gfx_v9_0_cp_gfx_start().
Signed-off-by: Rodrigo Siqueira <sique...@igalia.com> --- drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c index d377a7c57d5e..be38650a2b9b 100644 --- a/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +++ b/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c @@ -3295,9 +3295,8 @@ static int gfx_v9_0_cp_gfx_load_microcode(struct amdgpu_device *adev) static int gfx_v9_0_cp_gfx_start(struct amdgpu_device *adev) { struct amdgpu_ring *ring = &adev->gfx.gfx_ring[0]; - const struct cs_section_def *sect = NULL; - const struct cs_extent_def *ext = NULL; - int r, i, tmp; + u32 csb_size; + int r, tmp; /* init the CP */ WREG32_SOC15(GC, 0, mmCP_MAX_CONTEXT, adev->gfx.config.max_hw_contexts - 1); @@ -3313,7 +3312,9 @@ static int gfx_v9_0_cp_gfx_start(struct amdgpu_device *adev) DRM_INFO("Will skip the CSB packet resubmit\n"); return 0; } - r = amdgpu_ring_alloc(ring, gfx_v9_0_get_csb_size(adev) + 4 + 3); + + csb_size = gfx_v9_0_get_csb_size(adev); + r = amdgpu_ring_alloc(ring, csb_size + 4 + 3); if (r) { DRM_ERROR("amdgpu: cp failed to lock ring (%d).\n", r); return r; @@ -3326,19 +3327,7 @@ static int gfx_v9_0_cp_gfx_start(struct amdgpu_device *adev) amdgpu_ring_write(ring, 0x80000000); amdgpu_ring_write(ring, 0x80000000); - for (sect = gfx9_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); amdgpu_ring_write(ring, PACKET3(PACKET3_PREAMBLE_CNTL, 0)); amdgpu_ring_write(ring, PACKET3_PREAMBLE_END_CLEAR_STATE); -- 2.47.2