]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
dma-buf: Assign separate lockdep class to chain lock
authorMatthew Brost <matthew.brost@intel.com>
Tue, 24 Feb 2026 18:39:21 +0000 (10:39 -0800)
committerMatthew Brost <matthew.brost@intel.com>
Wed, 25 Feb 2026 09:16:11 +0000 (01:16 -0800)
dma_fence_chain_enable_signaling() and 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>
Reviewed-by: Christian König <christian.koenig@amd.com>
Link: https://patch.msgid.link/20260224183922.2256492-1-matthew.brost@intel.com
drivers/dma-buf/dma-fence-chain.c

index a707792b6025a52642a86bfb5d350d5ac8b76e5d..a588f55ea4d3d80b1a5001313516090672c2d925 100644 (file)
@@ -242,6 +242,7 @@ void dma_fence_chain_init(struct dma_fence_chain *chain,
                          struct dma_fence *fence,
                          uint64_t seqno)
 {
+       static struct lock_class_key dma_fence_chain_lock_key;
        struct dma_fence_chain *prev_chain = to_dma_fence_chain(prev);
        uint64_t context;
 
@@ -263,6 +264,18 @@ void dma_fence_chain_init(struct dma_fence_chain *chain,
        dma_fence_init64(&chain->base, &dma_fence_chain_ops, NULL,
                         context, seqno);
 
+       /*
+        * 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);
+
        /*
         * Chaining dma_fence_chain container together is only allowed through
         * the prev fence and not through the contained fence.