AMD-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Timur Kristóf" <timur.kristof@gmail.com>
To: amd-gfx@lists.freedesktop.org, Alexander.Deucher@amd.com,
	Christian.Koenig@amd.com, Prike Liang <Prike.Liang@amd.com>,
	Mario Limonciello <mario.limonciello@amd.com>
Cc: "Timur Kristóf" <timur.kristof@gmail.com>
Subject: [PATCH] drm/amdgpu: Fix validating flush_gpu_tlb_pasid()
Date: Sun, 18 Jan 2026 13:57:46 +0100	[thread overview]
Message-ID: <20260118125746.40221-1-timur.kristof@gmail.com> (raw)

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 <timur.kristof@gmail.com>
---
 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;
 	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;
 
 		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;
-- 
2.52.0


             reply	other threads:[~2026-01-18 12:57 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-18 12:57 Timur Kristóf [this message]
2026-01-19  1:57 ` [PATCH] drm/amdgpu: Fix validating flush_gpu_tlb_pasid() Liang, Prike
2026-01-19  5:27   ` Liang, Prike
2026-01-19  9:00     ` Timur Kristóf
2026-01-19 10:33     ` Christian König
2026-01-19 11:44       ` Liang, Prike
2026-01-19 10:12 ` Christian König
2026-01-19 11:20   ` Timur Kristóf
2026-01-19 11:47     ` Liang, Prike
  -- strict thread matches above, loose matches on Subject: below --
2026-01-19 12:07 Prike Liang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260118125746.40221-1-timur.kristof@gmail.com \
    --to=timur.kristof@gmail.com \
    --cc=Alexander.Deucher@amd.com \
    --cc=Christian.Koenig@amd.com \
    --cc=Prike.Liang@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=mario.limonciello@amd.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox