AMD-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/amdgpu: Fix validating flush_gpu_tlb_pasid()
@ 2026-01-18 12:57 Timur Kristóf
  2026-01-19  1:57 ` Liang, Prike
  2026-01-19 10:12 ` Christian König
  0 siblings, 2 replies; 10+ messages in thread
From: Timur Kristóf @ 2026-01-18 12:57 UTC (permalink / raw)
  To: amd-gfx, Alexander.Deucher, Christian.Koenig, Prike Liang,
	Mario Limonciello
  Cc: Timur Kristóf

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


^ permalink raw reply related	[flat|nested] 10+ messages in thread
* [PATCH] drm/amdgpu: Fix validating flush_gpu_tlb_pasid()
@ 2026-01-19 12:07 Prike Liang
  0 siblings, 0 replies; 10+ messages in thread
From: Prike Liang @ 2026-01-19 12:07 UTC (permalink / raw)
  To: amd-gfx
  Cc: Alexander.Deucher, Christian.Koenig, Timur Kristóf,
	kernel test robot, Dan Carpenter, Prike Liang,
	Christian König

From: Timur Kristóf <timur.kristof@gmail.com>

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()")
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Closes: https://lore.kernel.org/r/202601190121.z9C0uml5-lkp@intel.com/

Signed-off-by: Timur Kristóf <timur.kristof@gmail.com>
Signed-off-by: Prike Liang <Prike.Liang@amd.com>
Reviewed-by: Prike Liang <Prike.Liang@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c
index 0e67fa4338ff..d9ff68a43178 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c
@@ -781,8 +781,10 @@ 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;
+		if (!adev->gmc.gmc_funcs->flush_gpu_tlb_pasid) {
+			r = 0;
+			goto error_unlock_reset;
+		}
 
 		if (adev->gmc.flush_tlb_needs_extra_type_2)
 			adev->gmc.gmc_funcs->flush_gpu_tlb_pasid(adev, pasid,
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2026-01-19 12:07 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-18 12:57 [PATCH] drm/amdgpu: Fix validating flush_gpu_tlb_pasid() Timur Kristóf
2026-01-19  1:57 ` 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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox