From: Philipp Stanner <phasta@mailbox.org>
To: "Christian König" <ckoenig.leichtzumerken@gmail.com>,
phasta@kernel.org, matthew.brost@intel.com,
sumit.semwal@linaro.org
Cc: 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: Thu, 12 Feb 2026 10:01:49 +0100 [thread overview]
Message-ID: <69ff58e846ea7bf60e6f5dc58cf224f7c461d0d6.camel@mailbox.org> (raw)
In-Reply-To: <96407179-3ab9-4ba8-9b1c-171187683b41@gmail.com>
On Wed, 2026-02-11 at 15:59 +0100, Christian König wrote:
> On 2/11/26 10:50, Philipp Stanner wrote:
> > On Tue, 2026-02-10 at 11:01 +0100, Christian König wrote:
> ...
> > > Using a per-fence spinlock allows completely decoupling spinlock producer
> > > and consumer life times, simplifying the handling in most use cases.
> >
> > That's a good commit message btw, detailing what the motivation is.
> > Would be great to see messages like that more frequently :]
>
> Yeah, but they are not so easy to write.
Valuable things are rarely easy :}
>
> > > trace_dma_fence_init(fence);
> > > @@ -1091,7 +1094,7 @@ __dma_fence_init(struct dma_fence *fence, const struct dma_fence_ops *ops,
> > > * dma_fence_init - Initialize a custom fence.
> > > * @fence: the fence to initialize
> > > * @ops: the dma_fence_ops for operations on this fence
> > > - * @lock: the irqsafe spinlock to use for locking this fence
> > > + * @lock: optional irqsafe spinlock to use for locking this fence
> > > * @context: the execution context this fence is run on
> > > * @seqno: a linear increasing sequence number for this context
> > > *
> > > @@ -1101,6 +1104,10 @@ __dma_fence_init(struct dma_fence *fence, const struct dma_fence_ops *ops,
> > > *
> > > * context and seqno are used for easy comparison between fences, allowing
> > > * to check which fence is later by simply using dma_fence_later().
> > > + *
> > > + * It is strongly discouraged to provide an external lock. This is only allowed
> >
> > "strongly discouraged […] because this does not decouple lock and fence
> > life times." ?
>
> Good point, added some more text.
>
> > > + * for legacy use cases when multiple fences need to be prevented from
> > > + * signaling out of order.
> >
> > I think our previous discussions revealed that the external lock does
> > not even help with that, does it?
>
> Well only when you provide a ->signaled() callback in the dma_fence_ops.
Mhm, no?
The external lock does not protect against signaling out ouf order,
independently of that callback, because a driver can take and release
that lock in between signaling.
The way how to get this right is to make the fence context and actual
object with actual rules. In Rust, it could also house timeline and
driver name strings, requiring two fewer callbacks.
>
> The reason we have so much different approaches in the dma_fence handling is because it is basically the unification multiple different driver implementations which all targeted more or less different use cases.
>
When did dma_fence actually come to be? I suppose at some point we
discovered that all drivers basically have very similar requirements
regarding their job completion signaling.
> > >
[…]
> > >
> > > enum dma_fence_flag_bits {
> > > DMA_FENCE_FLAG_INITIALIZED_BIT,
> > > + DMA_FENCE_FLAG_INLINE_LOCK_BIT,
> >
> > Just asking about a nit: what's the order here, always alphabetically?
>
> In which the flags are used in the code flow.
Not intuitive, but it's OK, no big deal
P.
next prev parent reply other threads:[~2026-02-12 9:02 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 [this message]
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
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=69ff58e846ea7bf60e6f5dc58cf224f7c461d0d6.camel@mailbox.org \
--to=phasta@mailbox.org \
--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=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