[PATCH 2/3] drm/amdgpu/gfx9: Refactor cleaner shader initialization for GFX9

Alex Deucher alexdeucher at gmail.com
Thu Sep 5 00:40:08 UTC 2024


On Wed, Sep 4, 2024 at 8:37 PM Alex Deucher <alexdeucher at gmail.com> wrote:
>
> On Wed, Sep 4, 2024 at 9:53 AM Srinivasan Shanmugam
> <srinivasan.shanmugam at amd.com> wrote:
> >
> > This commit modifies the initialization only if the cleaner shader
> > object has been allocated. This is done by adding checks for
> > adev->gfx.cleaner_shader_obj before calling
> > amdgpu_gfx_cleaner_shader_init
> >
> > The changes are made in the gfx_v9_0_hw_init functions These functions
> > are responsible for initializing software components of the GFX v9.0.
> >
> > This change prevents unnecessary function calls and makes the control
> > flow of the program clearer. It also ensures that the cleaner shader is
> > only initialized when it has been properly allocated.
> >
> > Fixes: 776ad43d4170 ("drm/amdgpu/gfx9: Implement cleaner shader support for GFX9 hardware")
> > Cc: Christian König <christian.koenig at amd.com>
> > Cc: Alex Deucher <alexander.deucher at amd.com>
> > Suggested-by: Christian König <christian.koenig at amd.com>
> > Signed-off-by: Srinivasan Shanmugam <srinivasan.shanmugam at amd.com>
> > ---
> >  drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
> > index 23f0573ae47b..d6d07cfd279e 100644
> > --- a/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
> > +++ b/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
> > @@ -3975,8 +3975,8 @@ static int gfx_v9_0_hw_init(void *handle)
> >         int r;
> >         struct amdgpu_device *adev = (struct amdgpu_device *)handle;
> >
> > -       amdgpu_gfx_cleaner_shader_init(adev, adev->gfx.cleaner_shader_size,
> > -                                      adev->gfx.cleaner_shader_ptr);
> > +       if (adev->gfx.cleaner_shader_obj)
>
> Is this check actually needed?  I think amdgpu_bo_free_kernel() can
> deal with a NULL pointer.

Sorry, wrong function.  In this case we check if the CPU pointers are
valid already.

Alex

>
> Alex
>
> Alex
>
> > +               amdgpu_gfx_cleaner_shader_init(adev);
> >
> >         if (!amdgpu_sriov_vf(adev))
> >                 gfx_v9_0_init_golden_registers(adev);
> > --
> > 2.34.1
> >


More information about the amd-gfx mailing list