From: Boris Brezillon <boris.brezillon@collabora.com>
To: Philipp Stanner <phasta@mailbox.org>
Cc: phasta@kernel.org,
"Daniel Almeida" <daniel.almeida@collabora.com>,
"Alice Ryhl" <aliceryhl@google.com>,
"Danilo Krummrich" <dakr@kernel.org>,
"Christian König" <ckoenig.leichtzumerken@gmail.com>,
"Tvrtko Ursulin" <tursulin@ursulin.net>,
"Alexandre Courbot" <acourbot@nvidia.com>,
"Dave Airlie" <airlied@redhat.com>,
"Lyude Paul" <lyude@redhat.com>,
"Peter Colberg" <pcolberg@redhat.com>,
dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
rust-for-linux@vger.kernel.org
Subject: Re: [RFC WIP 2/3] rust: sync: Add dma_fence abstractions
Date: Tue, 25 Nov 2025 11:58:29 +0100 [thread overview]
Message-ID: <20251125115829.24e6caf7@fedora> (raw)
In-Reply-To: <bc4f01ec5172d29abd64429e3017cc53c0522e01.camel@mailbox.org>
On Tue, 25 Nov 2025 10:48:12 +0100
Philipp Stanner <phasta@mailbox.org> wrote:
> > > +impl ArcBorrow<'_, DmaFenceCtx> {
> > > + /// Create a new fence, consuming `data`.
> > > + ///
> > > + /// The fence will increment the refcount of the fence context associated with this
> > > + /// [`DmaFenceCtx`].
> > > + pub fn new_fence<T>(
> > > + &mut self,
> > > + data: impl PinInit<T>,
> > > + ) -> Result<ARef<DmaFence<T>>> {
> > > + let fctx: Arc<DmaFenceCtx> = (*self).into();
> > > + let seqno: u64 = fctx.get_new_fence_seqno();
> > > +
> > > + // TODO: Should we reset seqno in case of failure?
> >
> > I think we should go back to the old value, yeah.
>
> It would be trivial to implement that (just atomic.decrement()).
>
> The thing why the TODO even exists is that I'm a bit unsure about
> races. It seems we have to choose between either a gap in the seqnos or
> the possiblity of seqnos being out of order.
>
> If the user / driver creates fences with >1 thread on a fence context,
> I mean.
>
> We're pretty free in our choices, however. The shared fence-fctx
> spinlock will be removed anyways, so one could later easily replace the
> fctx atomic with a lock if that's desirable.
>
> I can implement a seqno-decrement for now.
I don't think we need to return unused seqnos in case of failure. I
mean, we could have something like the following pseudo-code:
atomic_cmpxchg(ctx.seqno, fence.seqno + 1, fence.seqno)
but it wouldn't cover the case where fences are not returned in the
order they were assigned, and seqnos are pretty cheap anyway (if a u64
is enough to count things in nanoseconds for hundreds of years, they are
more than enough for a fence timeline on which fences are emitted at a
way lower rate, even in case of recurring failures). The guarantee we
really care about is seqnos not going backward, because that would mess
up with the assumption that fences on a given timeline/ctx are signalled
in order (this assumption is used to coalesce fences in a
fence_array/resv IIRC).
next prev parent reply other threads:[~2025-11-25 10:58 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-18 13:25 [RFC WIP 0/3] DRM Jobqueue Philipp Stanner
2025-11-18 13:25 ` [RFC WIP 1/3] rust: list: Add unsafe for container_of Philipp Stanner
2025-11-18 13:25 ` [RFC WIP 2/3] rust: sync: Add dma_fence abstractions Philipp Stanner
2025-11-21 23:03 ` Lyude Paul
2025-11-24 9:31 ` Alice Ryhl
2025-11-27 13:45 ` Philipp Stanner
2025-11-24 12:49 ` Daniel Almeida
2025-11-25 9:48 ` Philipp Stanner
2025-11-25 10:58 ` Boris Brezillon [this message]
2025-11-25 12:20 ` Philipp Stanner
2025-11-25 13:50 ` Boris Brezillon
2025-11-26 13:42 ` Philipp Stanner
2025-11-26 14:55 ` Boris Brezillon
2025-11-27 13:48 ` Daniel Almeida
2025-11-28 11:08 ` Philipp Stanner
2025-11-28 12:21 ` Daniel Almeida
2025-11-18 13:25 ` [RFC WIP 3/3] rust/drm: Add initial jobqueue sceleton Philipp Stanner
2025-11-24 13:58 ` Daniel Almeida
2025-11-25 13:20 ` Philipp Stanner
2025-11-27 14:13 ` Daniel Almeida
2025-11-28 10:07 ` Philipp Stanner
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=20251125115829.24e6caf7@fedora \
--to=boris.brezillon@collabora.com \
--cc=acourbot@nvidia.com \
--cc=airlied@redhat.com \
--cc=aliceryhl@google.com \
--cc=ckoenig.leichtzumerken@gmail.com \
--cc=dakr@kernel.org \
--cc=daniel.almeida@collabora.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lyude@redhat.com \
--cc=pcolberg@redhat.com \
--cc=phasta@kernel.org \
--cc=phasta@mailbox.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=tursulin@ursulin.net \
/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;
as well as URLs for NNTP newsgroup(s).