public inbox for intel-xe@lists.freedesktop.org
 help / color / mirror / Atom feed
* [PATCH 1/2] dma-buf: Assign separate lockdep class to chain lock
@ 2026-02-24 17:55 Matthew Brost
  2026-02-24 17:55 ` [PATCH 2/2] dma-buf: Assign separate lockdep class to array lock Matthew Brost
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Matthew Brost @ 2026-02-24 17:55 UTC (permalink / raw)
  To: intel-xe, dri-devel
  Cc: Christian König, Tvrtko Ursulin, Philipp Stanner,
	Boris Brezillon

dma_fence_chain_enable_signaling() runs while holding the chain
inline_lock and may add callbacks to underlying fences, which takes
their inline_lock.

Since both locks share the same lockdep class, this valid nesting
triggers a recursive locking warning. Assign a distinct lockdep class
to the chain inline_lock so lockdep can correctly model the hierarchy.

Fixes: a408c0ca0c41 ("dma-buf: use inline lock for the dma-fence-chain")
Cc: Christian König <christian.koenig@amd.com>
Cc: Tvrtko Ursulin <tvrtko.ursulin@igalia.com>
Cc: Philipp Stanner <phasta@kernel.org>
Cc: Boris Brezillon <boris.brezillon@collabora.com>
Signed-off-by: Matthew Brost <matthew.brost@intel.com>
---
 drivers/dma-buf/dma-fence-chain.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/drivers/dma-buf/dma-fence-chain.c b/drivers/dma-buf/dma-fence-chain.c
index a707792b6025..4c2a9f2ce126 100644
--- a/drivers/dma-buf/dma-fence-chain.c
+++ b/drivers/dma-buf/dma-fence-chain.c
@@ -242,6 +242,9 @@ void dma_fence_chain_init(struct dma_fence_chain *chain,
 			  struct dma_fence *fence,
 			  uint64_t seqno)
 {
+#if IS_ENABLED(CONFIG_LOCKDEP)
+	static struct lock_class_key dma_fence_chain_lock_key;
+#endif
 	struct dma_fence_chain *prev_chain = to_dma_fence_chain(prev);
 	uint64_t context;
 
@@ -263,6 +266,20 @@ void dma_fence_chain_init(struct dma_fence_chain *chain,
 	dma_fence_init64(&chain->base, &dma_fence_chain_ops, NULL,
 			 context, seqno);
 
+#if IS_ENABLED(CONFIG_LOCKDEP)
+	/*
+	 * dma_fence_chain_enable_signaling() is invoked while holding
+	 * chain->base.inline_lock and may call dma_fence_add_callback()
+	 * on the underlying fences, which takes their inline_lock.
+	 *
+	 * Since both locks share the same lockdep class, this legitimate
+	 * nesting confuses lockdep and triggers a recursive locking
+	 * warning. Assign a separate lockdep class to the chain lock
+	 * to model this hierarchy correctly.
+	 */
+	lockdep_set_class(&chain->base.inline_lock, &dma_fence_chain_lock_key);
+#endif
+
 	/*
 	 * Chaining dma_fence_chain container together is only allowed through
 	 * the prev fence and not through the contained fence.
-- 
2.34.1


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

end of thread, other threads:[~2026-03-03  8:36 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-24 17:55 [PATCH 1/2] dma-buf: Assign separate lockdep class to chain lock Matthew Brost
2026-02-24 17:55 ` [PATCH 2/2] dma-buf: Assign separate lockdep class to array lock Matthew Brost
2026-02-25  8:26 ` [PATCH 1/2] dma-buf: Assign separate lockdep class to chain lock Christian König
2026-03-02 15:28 ` Boris Brezillon
2026-03-02 15:42   ` Christian König
2026-03-02 16:39     ` Boris Brezillon
2026-03-02 20:05       ` Matthew Brost
2026-03-03  8:36         ` Boris Brezillon

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