From: Boris Brezillon <boris.brezillon@collabora.com>
To: Philipp Stanner <phasta@mailbox.org>
Cc: phasta@kernel.org,
"Christian König" <ckoenig.leichtzumerken@gmail.com>,
matthew.brost@intel.com, sumit.semwal@linaro.org,
dri-devel@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org
Subject: Re: [PATCH 4/8] dma-buf: inline spinlock for fence protection v4
Date: Mon, 16 Feb 2026 10:48:01 +0100 [thread overview]
Message-ID: <20260216104801.214f3b3c@fedora> (raw)
In-Reply-To: <668921abf453f3cb65aca13a9c06e8c81c46a411.camel@mailbox.org>
On Mon, 16 Feb 2026 08:33:21 +0100
Philipp Stanner <phasta@mailbox.org> wrote:
> On Fri, 2026-02-13 at 15:27 +0100, Boris Brezillon wrote:
> > On Tue, 10 Feb 2026 11:01:59 +0100
> > "Christian König" <ckoenig.leichtzumerken@gmail.com> wrote:
> >
> > > Implement per-fence spinlocks, allowing implementations to not give an
> > > external spinlock to protect the fence internal statei. Instead a spinlock
> > > embedded into the fence structure itself is used in this case.
> > >
> > > Shared spinlocks have the problem that implementations need to guarantee
> > > that the lock live at least as long all fences referencing them.
> > >
> > > Using a per-fence spinlock allows completely decoupling spinlock producer
> > > and consumer life times, simplifying the handling in most use cases.
> > >
> > > v2: improve naming, coverage and function documentation
> > > v3: fix one additional locking in the selftests
> > > v4: separate out some changes to make the patch smaller,
> > > fix one amdgpu crash found by CI systems
> > >
> > > Signed-off-by: Christian König <christian.koenig@amd.com>
> > > ---
> > > drivers/dma-buf/dma-fence.c | 21 ++++++++++++++++-----
> > > drivers/dma-buf/sync_debug.h | 2 +-
> > > drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h | 2 +-
> > > drivers/gpu/drm/drm_crtc.c | 2 +-
> > > drivers/gpu/drm/drm_writeback.c | 2 +-
> > > drivers/gpu/drm/nouveau/nouveau_fence.c | 3 ++-
> > > drivers/gpu/drm/qxl/qxl_release.c | 3 ++-
> > > drivers/gpu/drm/vmwgfx/vmwgfx_fence.c | 3 ++-
> > > drivers/gpu/drm/xe/xe_hw_fence.c | 3 ++-
> > > include/linux/dma-fence.h | 19 +++++++++++++------
> > > 10 files changed, 41 insertions(+), 19 deletions(-)
> > >
> > > diff --git a/drivers/dma-buf/dma-fence.c b/drivers/dma-buf/dma-fence.c
> > > index 56aa59867eaa..1833889e7466 100644
> > > --- a/drivers/dma-buf/dma-fence.c
> > > +++ b/drivers/dma-buf/dma-fence.c
> > > @@ -343,7 +343,6 @@ void __dma_fence_might_wait(void)
> > > }
> > > #endif
> > >
> > > -
> > > /**
> > > * dma_fence_signal_timestamp_locked - signal completion of a fence
> > > * @fence: the fence to signal
> > > @@ -1067,7 +1066,6 @@ static void
> > > __dma_fence_init(struct dma_fence *fence, const struct dma_fence_ops *ops,
> > > spinlock_t *lock, u64 context, u64 seqno, unsigned long flags)
> > > {
> > > - BUG_ON(!lock);
> > > BUG_ON(!ops || !ops->get_driver_name || !ops->get_timeline_name);
> > >
> > > kref_init(&fence->refcount);
> > > @@ -1078,10 +1076,15 @@ __dma_fence_init(struct dma_fence *fence, const struct dma_fence_ops *ops,
> > > */
> > > RCU_INIT_POINTER(fence->ops, ops);
> > > INIT_LIST_HEAD(&fence->cb_list);
> > > - fence->lock = lock;
> > > fence->context = context;
> > > fence->seqno = seqno;
> > > fence->flags = flags | BIT(DMA_FENCE_FLAG_INITIALIZED_BIT);
> > > + if (lock) {
> > > + fence->extern_lock = lock;
> > > + } else {
> > > + spin_lock_init(&fence->inline_lock);
> > > + fence->flags |= BIT(DMA_FENCE_FLAG_INLINE_LOCK_BIT);
> >
> > Hm, does this even make a different in term of instructions to check for
> > a bit instead of extern_lock == NULL? If not, I'd be in favor of
> > killing this redundancy and checking extern_lock against NULL in
> > dma_fence_spinlock().
>
> extern_lock and inline_lock are a union, so they overlap each other.
> inline_lock will only be equivalent to all zeros after initializing a
> new fence to 0.
>
>
> P.
>
> PS: Can you terminate messages by a delimiter or by cropping? I give
> this tip sometimes, because often the reviewer has to scroll emails
> down to the end to see whether there are further comments. I terminate
> my messages with "P." for that purpose ;]
I tend to strip messages and quote only the bits I comment on. I get
this time I didn't, my bad.
next prev parent reply other threads:[~2026-02-16 9:48 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-10 10:01 Independence for dma_fences! v7 Christian König
2026-02-10 10:01 ` [PATCH 1/8] dma-buf: protected fence ops by RCU v5 Christian König
2026-02-11 10:06 ` Philipp Stanner
2026-02-11 15:43 ` Christian König
2026-02-12 8:56 ` Philipp Stanner
2026-02-19 10:23 ` Christian König
2026-02-19 10:35 ` Philipp Stanner
2026-02-19 12:49 ` Christian König
2026-02-12 9:03 ` Tvrtko Ursulin
2026-02-12 9:31 ` Tvrtko Ursulin
2026-02-13 14:20 ` Boris Brezillon
2026-02-10 10:01 ` [PATCH 2/8] dma-buf: detach fence ops on signal v2 Christian König
2026-02-13 14:22 ` Boris Brezillon
2026-02-19 12:52 ` Christian König
2026-02-19 15:49 ` Boris Brezillon
2026-02-10 10:01 ` [PATCH 3/8] dma-buf: abstract fence locking v2 Christian König
2026-02-12 9:07 ` Tvrtko Ursulin
2026-02-10 10:01 ` [PATCH 4/8] dma-buf: inline spinlock for fence protection v4 Christian König
2026-02-11 9:50 ` Philipp Stanner
2026-02-11 14:59 ` Christian König
2026-02-12 9:01 ` Philipp Stanner
2026-02-12 9:16 ` Tvrtko Ursulin
2026-02-13 14:27 ` Boris Brezillon
2026-02-15 8:48 ` Boris Brezillon
2026-02-16 7:33 ` Philipp Stanner
2026-02-16 9:48 ` Boris Brezillon [this message]
2026-02-10 10:02 ` [PATCH 5/8] dma-buf/selftests: test RCU ops and inline lock v2 Christian König
2026-02-10 10:02 ` [PATCH 6/8] dma-buf: use inline lock for the stub fence v2 Christian König
2026-02-13 14:32 ` Boris Brezillon
2026-02-10 10:02 ` [PATCH 7/8] dma-buf: use inline lock for the dma-fence-array Christian König
2026-02-13 14:33 ` Boris Brezillon
2026-02-10 10:02 ` [PATCH 8/8] dma-buf: use inline lock for the dma-fence-chain Christian König
2026-02-13 14:33 ` Boris Brezillon
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260216104801.214f3b3c@fedora \
--to=boris.brezillon@collabora.com \
--cc=ckoenig.leichtzumerken@gmail.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=linaro-mm-sig@lists.linaro.org \
--cc=matthew.brost@intel.com \
--cc=phasta@kernel.org \
--cc=phasta@mailbox.org \
--cc=sumit.semwal@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox