NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: kern/60732: amdgpu attempts to take (sleeping) mutex while holding a spin lock



> Date: Wed, 16 Sep 2026 00:27:06 +0000 (UTC)
> From: mrg%eterna23.net@localhost
> 
> idea i did not look at to see if feasible or try, would be to
> make the mutex into an spin mutex.

Won't work -- even if you change gtt_window_lock to a spin lock, the
function in question sleeps:

    341 static void gmc_v10_0_flush_gpu_tlb(struct amdgpu_device *adev, uint32_t vmid,
    342 					uint32_t vmhub, uint32_t flush_type)
    343 {
...
    377 	r = amdgpu_job_alloc_with_ib(adev, 16 * 4, &job);
...
    392 	dma_fence_wait(fence, false);
...
    403 }

https://nxr.NetBSD.org/xref/src/sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_gmc_v10_0.c?r=1.5#333

Try the attached patch to drop the spin lock, but hold a reference to
the node so the iteration is safe, while calling
amdgpu_ttm_recover_gart?
# HG changeset patch
# User Taylor R Campbell <riastradh%NetBSD.org@localhost>
# Date 1789563496 0
#      Wed Sep 16 12:58:16 2026 +0000
# Branch trunk
# Node ID 2c75d691e0dd07e7b4ab40237114314280231942
# Parent  4fbd288ac1da9e7d9592ddecf04f7513e244152f
# EXP-Topic riastradh-pr60732-amdgpugartrecoverspinmutex
WIP: amdgpu: Drop spin lock across possible (non-spin) mutex & wait.

PR kern/60732: amdgpu attempts to take (sleeping) mutex while holding
a spin lock

diff -r 4fbd288ac1da -r 2c75d691e0dd sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_gtt_mgr.c
--- a/sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_gtt_mgr.c	Mon Aug 10 13:36:10 2026 +0000
+++ b/sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_gtt_mgr.c	Wed Sep 16 12:58:16 2026 +0000
@@ -336,7 +336,11 @@ int amdgpu_gtt_mgr_recover(struct ttm_me
 	spin_lock(&mgr->lock);
 	drm_mm_for_each_node(mm_node, &mgr->mm) {
 		node = container_of(mm_node, struct amdgpu_gtt_node, node);
+		ttm_bo_get(node->tbo);
+		spin_unlock(&mgr->lock);
 		r = amdgpu_ttm_recover_gart(node->tbo);
+		spin_lock(&mgr->lock);
+		ttm_bo_put(node->tbo);
 		if (r)
 			break;
 	}


Home | Main Index | Thread Index | Old Index