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.
> 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]>
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;