[Public]

Regards,
      Prike

> -----Original Message-----
> From: Timur Kristóf <[email protected]>
> Sent: Monday, January 19, 2026 7:21 PM
> To: [email protected]; Deucher, Alexander
> <[email protected]>; Liang, Prike <[email protected]>;
> Limonciello, Mario <[email protected]>; Koenig, Christian
> <[email protected]>
> Subject: Re: [PATCH] drm/amdgpu: Fix validating flush_gpu_tlb_pasid()
>
> On Monday, January 19, 2026 11:12:02 AM Central European Standard Time
> Christian König wrote:
> > On 1/18/26 13:57, Timur Kristóf wrote:
> > > When a function holds a lock and we return without unlocking it, it
> > > deadlocks the kernel. We should always unlock before returning.
> > >
> > > This commit fixes suspend/resume on SI.
> > > Tested on two Tahiti GPUs: FirePro W9000 and R9 280X.
> > >
> > > Fixes: bc2dea30038a ("drm/amdgpu: validate the
> > > flush_gpu_tlb_pasid()")
> > > Signed-off-by: Timur Kristóf <[email protected]>
> > > ---
> > >
> > >  drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c | 5 ++---
> > >  1 file changed, 2 insertions(+), 3 deletions(-)
> > >
> > > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c
> > > b/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c index
> > > 0e67fa4338ff..4fa24be1bf45 100644
> > > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c
> > > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c
> > > @@ -769,7 +769,7 @@ int amdgpu_gmc_flush_gpu_tlb_pasid(struct
> > > amdgpu_device *adev, uint16_t pasid,>
> > >   struct amdgpu_ring *ring = &adev->gfx.kiq[inst].ring;
> > >   struct amdgpu_kiq *kiq = &adev->gfx.kiq[inst];
> > >   unsigned int ndw;
> > >
> > > - int r, cnt = 0;
> > > + int r = 0, cnt = 0;
> >
> > Please don't initialize return values in the declaration, that is
> > usually considered bad coding style.
>
> The initialization is necessary, otherwise the function will return an 
> uninitialized value
> when flush_gpu_tlb_pasid==NULL

We can initialize the r before goto error_unlock_reset.

> > >   uint32_t seq;
> > >
> > >   /*
> > >
> > > @@ -782,7 +782,7 @@ int amdgpu_gmc_flush_gpu_tlb_pasid(struct
> > > amdgpu_device *adev, uint16_t pasid,>
> > >   if (!adev->gmc.flush_pasid_uses_kiq || !ring->sched.ready) {
> > >
> > >           if (!adev->gmc.gmc_funcs->flush_gpu_tlb_pasid)
> > >
> > > -                 return 0;
> > > +                 goto error_unlock_reset;
> >
> > Ah, yes good catch!
> >
> > With the change to r initialization dropped: Reviewed-by: Christian
> > König <[email protected]>
>
> If I drop it, then it will regress again because it returns an uninitialized 
> value.
>
> >
> > Regards,
> > Christian.
> >
> > >           if (adev->gmc.flush_tlb_needs_extra_type_2)
> > >
> > >                   adev->gmc.gmc_funcs-
> >flush_gpu_tlb_pasid(adev, pasid,
> > >
> > > @@ -797,7 +797,6 @@ int amdgpu_gmc_flush_gpu_tlb_pasid(struct
> > > amdgpu_device *adev, uint16_t pasid,>
> > >           adev->gmc.gmc_funcs->flush_gpu_tlb_pasid(adev, pasid,
> > >
> > >
> flush_type, all_hub,
> > >
> inst);
> > >
> > > -         r = 0;
> > >
> > >   } else {
> > >
> > >           /* 2 dwords flush + 8 dwords fence */
> > >           ndw = kiq->pmf->invalidate_tlbs_size + 8;
>
>
>

Reply via email to