From: Vitaly Prosyak <[email protected]>

amdgpu_devcoredump_format() takes dma_resv_lock on the VM root BO via
amdgpu_vm_lock_by_pasid(), then attempts amdgpu_bo_reserve() on the IB
backing BO. Both are reservation_ww_class_mutex instances, so lockdep
reports a recursive locking (possible deadlock) since no ww_acquire_ctx
distinguishes them.

Since the coredump path is best-effort and non-critical, replace the
blocking amdgpu_bo_reserve() with dma_resv_trylock(). If the IB BO is
contended, we simply skip dumping that IB content rather than risk a
real deadlock or a false lockdep splat.

Cc: Christian König <[email protected]>
Cc: Alex Deucher <[email protected]>
Signed-off-by: Vitaly Prosyak <[email protected]>
Change-Id: Ieebe7f103f52eb98b040c5aabf0a57c42db3cdf9
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.c
index 0811593fca7f..714419c7b18d 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.c
@@ -371,7 +371,7 @@ amdgpu_devcoredump_format(char *buffer, size_t count, 
struct amdgpu_coredump_inf
 
                        offset = va_start - (mapping->start * 
AMDGPU_GPU_PAGE_SIZE);
                        abo = amdgpu_bo_ref(mapping->bo_va->base.bo);
-                       r = amdgpu_bo_reserve(abo, false);
+                       r = dma_resv_trylock(abo->tbo.base.resv) ? 0 : -EBUSY;
                        if (r)
                                goto free_ib_content;
 
-- 
2.54.0

Reply via email to