On Fri, Apr 11, 2025 at 12:37 PM Srinivasan Shanmugam <srinivasan.shanmu...@amd.com> wrote: > > This commit modifies the gfx_v9_0_ring_emit_cleaner_shader function > to use a switch statement for cleaner shader emission based on the > specific GFX IP version. > > The function now distinguishes between different IP versions, using > PACKET3_RUN_CLEANER_SHADER_9_0 for the versions 9.0.1, 9.1.0, > 9.2.1, 9.2.2, 9.3.0, and 9.4.0, while retaining > PACKET3_RUN_CLEANER_SHADER for version 9.4.2. > > Cc: Christian König <christian.koe...@amd.com> > Cc: Alex Deucher <alexander.deuc...@amd.com> > Signed-off-by: Srinivasan Shanmugam <srinivasan.shanmu...@amd.com> > Suggested-by: Alex Deucher <alexander.deuc...@amd.com> > --- > drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 21 ++++++++++++++++++++- > 1 file changed, 20 insertions(+), 1 deletion(-) > > diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c > b/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c > index e62c77b3934a..bfe66a0e0e71 100644 > --- a/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c > +++ b/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c > @@ -7387,8 +7387,27 @@ static void gfx_v9_ip_dump(struct amdgpu_ip_block > *ip_block) > > static void gfx_v9_0_ring_emit_cleaner_shader(struct amdgpu_ring *ring) > { > + struct amdgpu_device *adev = ring->adev; > + unsigned int ip_version = amdgpu_ip_version(adev, GC_HWIP, 0); > + > /* Emit the cleaner shader */ > - amdgpu_ring_write(ring, PACKET3(PACKET3_RUN_CLEANER_SHADER, 0)); > + switch (ip_version) { > + case IP_VERSION(9, 0, 1): > + case IP_VERSION(9, 1, 0): > + case IP_VERSION(9, 2, 1): > + case IP_VERSION(9, 2, 2): > + case IP_VERSION(9, 3, 0): > + case IP_VERSION(9, 4, 0): > + amdgpu_ring_write(ring, > PACKET3(PACKET3_RUN_CLEANER_SHADER_9_0, 0)); > + break; > + case IP_VERSION(9, 4, 2): > + amdgpu_ring_write(ring, PACKET3(PACKET3_RUN_CLEANER_SHADER, > 0)); > + break; > + default: > + dev_err(adev->dev, "Unknown IP version for Cleaner Shader: > %u\n", ip_version); > + break; > + } > +
I think this can be simplified to: if (amdgpu_ip_version(adev, GC_HWIP, 0) == IP_VERSION(9, 4, 2) amdgpu_ring_write(ring, PACKET3(PACKET3_RUN_CLEANER_SHADER, 0)); else amdgpu_ring_write(ring, PACKET3(PACKET3_RUN_CLEANER_SHADER_9_0, 0)); Alex > amdgpu_ring_write(ring, 0); /* RESERVED field, programmed to zero */ > } > > -- > 2.34.1 >