All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] drm/amdgpu: reserve a fence slot before adding the eviction fence
@ 2026-11-19  9:56 Jesse Zhang
  2026-11-19  9:56 ` [PATCH 2/2] drm/amdgpu: don't unreserve the freed root PD in amdgpu_vm_init() Jesse Zhang
  2026-11-19 10:13 ` [PATCH 1/2] drm/amdgpu: reserve a fence slot before adding the eviction fence sashiko-bot
  0 siblings, 2 replies; 7+ messages in thread
From: Jesse Zhang @ 2026-11-19  9:56 UTC (permalink / raw)
  To: amd-gfx; +Cc: Alexander.Deucher, Christian Koenig, Sunil Khatri, Jesse Zhang

After lock contention, drm_exec may retain a BO removed from the VM
during the retry. The BO misses caller-side fence reservation, but
rearm still attaches a fence to it. If validation needs no move, this
can trigger BUG_ON() in dma_resv_add_fence().

 kernel BUG at drivers/dma-buf/dma-resv.c:319!
      Oops: invalid opcode: 0000 [#1] SMP KASAN NOPTI
      Workqueue: events_freezable amdgpu_userq_restore_worker [amdgpu]
      RIP: 0010:dma_resv_add_fence+0x833/0x920
       amdgpu_evf_mgr_attach_fence+0x2d3/0x4c0 [amdgpu]
       amdgpu_evf_mgr_rearm+0x279/0x370 [amdgpu]
       amdgpu_userq_vm_validate_and_restore_queue+0x166c/0x1dc0 [amdgpu]
       amdgpu_userq_restore_worker+0x6d/0x180 [amdgpu]

Reserve one slot before attaching the eviction fence.

Fixes: 2cd7284ba54b ("drm/amdgpu: completely rework eviction fence handling v2")
Signed-off-by: Jesse Zhang <Jesse.Zhang@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_eviction_fence.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_eviction_fence.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_eviction_fence.c
index f8652fd0525d..f01e08c4de4a 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_eviction_fence.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_eviction_fence.c
@@ -108,13 +108,21 @@ int amdgpu_evf_mgr_attach_fence(struct amdgpu_eviction_fence_mgr *evf_mgr,
 
 		amdgpu_bo_placement_from_domain(bo, bo->allowed_domains);
 		ret = ttm_bo_validate(&bo->tbo, &bo->placement, &ctx);
-		if (!ret)
-			dma_resv_add_fence(resv, ev_fence,
-					   DMA_RESV_USAGE_BOOKKEEP);
+		if (ret)
+			goto out;
+
+		/* BOs prelocked by drm_exec may not have reserved fence slots. */
+		dma_resv_reserve_fences(resv, 1);
+		if (ret)
+			goto out;
+
+		dma_resv_add_fence(resv, ev_fence,
+				   DMA_RESV_USAGE_BOOKKEEP);
 	} else {
 		ret = 0;
 	}
 
+out:
 	dma_fence_put(ev_fence);
 	return ret;
 }
-- 
2.50.1


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

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

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-19  9:56 [PATCH 1/2] drm/amdgpu: reserve a fence slot before adding the eviction fence Jesse Zhang
2026-11-19  9:56 ` [PATCH 2/2] drm/amdgpu: don't unreserve the freed root PD in amdgpu_vm_init() Jesse Zhang
2026-11-19 14:46   ` Christian König
2026-11-19 15:54     ` Alex Deucher
2026-11-19 23:43       ` Zhang, Jesse(Jie)
2026-11-20 12:00         ` Christian König
2026-11-19 10:13 ` [PATCH 1/2] drm/amdgpu: reserve a fence slot before adding the eviction fence sashiko-bot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.