From: Boris Brezillon <boris.brezillon@collabora.com>
To: Alice Ryhl <aliceryhl@google.com>
Cc: "Christian König" <christian.koenig@amd.com>,
"Philipp Stanner" <phasta@mailbox.org>,
phasta@kernel.org, "Danilo Krummrich" <dakr@kernel.org>,
"David Airlie" <airlied@gmail.com>,
"Simona Vetter" <simona@ffwll.ch>, "Gary Guo" <gary@garyguo.net>,
"Benno Lossin" <lossin@kernel.org>,
"Daniel Almeida" <daniel.almeida@collabora.com>,
"Joel Fernandes" <joelagnelf@nvidia.com>,
linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org,
rust-for-linux@vger.kernel.org
Subject: Re: [RFC PATCH 2/4] rust: sync: Add dma_fence abstractions
Date: Tue, 10 Feb 2026 15:50:25 +0100 [thread overview]
Message-ID: <20260210155025.1b9ad2f1@fedora> (raw)
In-Reply-To: <aYs8gN34IVPQiqLk@google.com>
On Tue, 10 Feb 2026 14:11:12 +0000
Alice Ryhl <aliceryhl@google.com> wrote:
> On Tue, Feb 10, 2026 at 02:51:56PM +0100, Boris Brezillon wrote:
> > On Tue, 10 Feb 2026 13:26:48 +0000
> > Alice Ryhl <aliceryhl@google.com> wrote:
> >
> > > On Tue, Feb 10, 2026 at 01:49:13PM +0100, Boris Brezillon wrote:
> > > > On Tue, 10 Feb 2026 10:15:04 +0000
> > > > Alice Ryhl <aliceryhl@google.com> wrote:
> > > >
> > > > > /// The owner of this value must ensure that this fence is signalled.
> > > > > struct MustBeSignalled<'fence> { ... }
> > > > > /// Proof value indicating that the fence has either already been
> > > > > /// signalled, or it will be. The lifetime ensures that you cannot mix
> > > > > /// up the proof value.
> > > > > struct WillBeSignalled<'fence> { ... }
> > > >
> > > > Sorry, I have more questions, unfortunately. Seems that
> > > > {Must,Will}BeSignalled are targeting specific fences (at least that's
> > > > what the doc and 'fence lifetime says), but in practice, the WorkItem
> > > > backing the scheduler can queue 0-N jobs (0 if no jobs have their deps
> > > > met, and N > 1 if more than one job is ready). Similarly, an IRQ
> > > > handler can signal 0-N fences (can be that the IRQ has nothing to do we
> > > > job completion, or, it can be that multiple jobs have completed). How
> > > > is this MustBeSignalled object going to be instantiated in practice if
> > > > it's done before the DmaFenceWorkItem::run() function is called?
> > >
> > > The {Must,Will}BeSignalled closure pair needs to wrap the piece of code
> > > that ensures a specific fence is signalled. If you have code that
> > > manages a collection of fences and invokes code for specific fences
> > > depending on outside conditions, then that's a different matter.
> > >
> > > After all, transfer_to_wq() has two components:
> > > 1. Logic to ensure any spawned workqueue job eventually gets to run.
> > > 2. Once the individual job runs, logic specific to the one fence ensures
> > > that this one fence gets signalled.
> >
> > Okay, that's a change compared to how things are modeled in C (and in
> > JobQueue) at the moment: the WorkItem is not embedded in a specific
> > job, it's something that's attached to the JobQueue. The idea being
> > that the WorkItem represents a task to be done on the queue itself
> > (check if the first element in the queue is ready for execution), not on
> > a particular job. Now, we could change that and have a per-job WorkItem,
> > but ultimately, we'll have to make sure jobs are dequeued in order
> > (deps on JobN can be met before deps on Job0, but we still want JobN to
> > be submitted after Job0), and we'd pay the WorkItem overhead once per
> > Job instead of once per JobQueue. Probably not the end of the world,
> > but it's worth considering, still.
>
> It sounds like the fix here is to have transfer_to_job_queue() instead
> of trying to do it at the workqueue level.
Hm, so Job would be something like that (naming/trait-def are just
suggestions to get the discussion going):
trait JobConsumer {
type FenceType;
type JobData;
fn run(self: MustBeSignalled<T::FenceType>) -> Result<WillBeSignaled<Self::FenceType>>;
}
struct Job<T: JobConsumer> {
fence: MustBeSignalled<T::FenceType>,
data: T::JobData,
}
I guess that would do.
And then we need to flag the WorkItem that's exposed by the
JobQueue as a DmaFenceWorkItem so that
bindings::dma_fence_begin_signalling() is called before entry and
lockdep can do its job and check that nothing forbidden happens in
this WorkItem.
>
> > > And {Must,Will}BeSignalled exists to help model part (2.). But what you
> > > described with the IRQ callback falls into (1.) instead, which is
> > > outside the scope of {Must,Will}BeSignalled (or at least requires more
> > > complex APIs).
> >
> > For IRQ callbacks, it's not just about making sure they run, but also
> > making sure nothing in there can lead to deadlocks, which is basically
> > #2, except it's not scoped to a particular fence. It's just a "fences
> > can be signaled from there" marker. We could restrict it to "fences of
> > this particular implementation can be signaled from there" but not
> > "this particular fence instance will be signaled next, if any", because
> > that we don't know until we've walked some HW state to figure out which
> > job is complete and thus which fence we need to signal (the interrupt
> > we get is most likely multiplexing completion on multiple GPU contexts,
> > so before we can even get to our per-context in-flight-jobs FIFO, we
> > need to demux this thing).
>
> All I can say is that this is a different use-case for the C api
> dma_fence_begin_signalling(). This different usage also seems useful,
> but it would be one that does not involve {Must,Will}BeSignalled
> arguments at all.
>
> After all, dma_fence_begin_signalling() only requires those arguments if
> you want to convert a PrivateFence into a PublishedFence. (I guess a
> better name is PublishableFence.) If you're not trying to prove that a
> specific fence will be signalled, then you don't need the
> {Must,Will}BeSignalled arguments.
Okay, so that would be another function returning some sort of guard
then? What I find confusing is the fact
dma_fence::dma_fence_begin_signalling() matches the C function name
which is not per-fence, but just this lock-guard model flagging a
section from which any fence can be signalled, so maybe we should
name your dma_fence_begin_signalling() proposal differently, dunno.
next prev parent reply other threads:[~2026-02-10 14:50 UTC|newest]
Thread overview: 105+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-03 8:13 [RFC PATCH 0/4] Add dma_fence abstractions and DRM Jobqueue Philipp Stanner
2026-02-03 8:14 ` [RFC PATCH 1/4] rust: list: Add unsafe for container_of Philipp Stanner
2026-02-03 15:25 ` Gary Guo
2026-02-04 10:30 ` Alice Ryhl
2026-02-03 8:14 ` [RFC PATCH 2/4] rust: sync: Add dma_fence abstractions Philipp Stanner
2026-02-05 8:57 ` Boris Brezillon
2026-02-06 10:23 ` Danilo Krummrich
2026-02-09 8:19 ` Philipp Stanner
2026-02-09 14:58 ` Boris Brezillon
2026-02-10 8:16 ` Christian König
2026-02-10 8:38 ` Alice Ryhl
2026-02-10 9:06 ` Philipp Stanner
2026-02-10 9:54 ` Christian König
2026-02-10 9:15 ` Boris Brezillon
2026-02-10 10:15 ` Alice Ryhl
2026-02-10 10:36 ` Danilo Krummrich
2026-02-10 10:46 ` Christian König
2026-02-10 11:40 ` Alice Ryhl
2026-02-10 12:28 ` Boris Brezillon
2026-02-11 9:57 ` Danilo Krummrich
2026-02-11 10:08 ` Philipp Stanner
2026-02-11 10:28 ` Boris Brezillon
2026-02-11 10:20 ` Boris Brezillon
2026-02-11 11:00 ` Danilo Krummrich
2026-02-11 11:12 ` Boris Brezillon
2026-02-11 14:38 ` Danilo Krummrich
2026-02-11 15:00 ` Boris Brezillon
2026-02-11 15:05 ` Danilo Krummrich
2026-02-11 15:14 ` Boris Brezillon
2026-02-11 15:16 ` Danilo Krummrich
2026-03-13 17:27 ` Matthew Brost
2026-02-10 10:46 ` Boris Brezillon
2026-02-10 11:34 ` Boris Brezillon
2026-02-10 11:45 ` Alice Ryhl
2026-02-10 12:21 ` Boris Brezillon
2026-02-10 13:34 ` Alice Ryhl
2026-02-10 12:36 ` Boris Brezillon
2026-02-10 13:15 ` Alice Ryhl
2026-02-10 13:26 ` Boris Brezillon
2026-02-10 13:49 ` Alice Ryhl
2026-02-10 13:56 ` Christian König
2026-02-10 14:00 ` Philipp Stanner
2026-02-10 14:06 ` Christian König
2026-02-10 15:32 ` Philipp Stanner
2026-02-10 15:50 ` Christian König
2026-02-10 15:07 ` Alice Ryhl
2026-02-10 15:45 ` Christian König
2026-02-11 8:16 ` Philipp Stanner
2026-02-17 14:03 ` Philipp Stanner
2026-02-17 14:09 ` Alice Ryhl
2026-02-17 14:22 ` Christian König
2026-02-17 14:28 ` Philipp Stanner
2026-02-17 14:44 ` Danilo Krummrich
2026-03-13 23:20 ` Matthew Brost
2026-02-17 15:01 ` Christian König
2026-02-18 9:50 ` Alice Ryhl
2026-02-18 10:48 ` Boris Brezillon
2026-02-10 12:49 ` Boris Brezillon
2026-02-10 12:56 ` Boris Brezillon
2026-02-10 13:26 ` Alice Ryhl
2026-02-10 13:51 ` Boris Brezillon
2026-02-10 14:11 ` Alice Ryhl
2026-02-10 14:50 ` Boris Brezillon [this message]
2026-02-11 8:16 ` Alice Ryhl
2026-02-11 9:20 ` Boris Brezillon
2026-02-10 9:26 ` Christian König
2026-02-05 10:16 ` Boris Brezillon
2026-02-05 13:16 ` Gary Guo
2026-02-06 9:32 ` Philipp Stanner
2026-02-06 10:16 ` Danilo Krummrich
2026-02-06 13:24 ` Philipp Stanner
2026-02-06 11:04 ` Boris Brezillon
2026-02-09 8:21 ` Philipp Stanner
2026-02-06 11:23 ` Boris Brezillon
2026-02-05 12:35 ` kernel test robot
2026-02-09 11:30 ` Alice Ryhl
2026-02-03 8:14 ` [RFC PATCH 3/4] rust/drm: Add DRM Jobqueue Philipp Stanner
2026-02-05 13:58 ` kernel test robot
2026-02-10 14:57 ` Boris Brezillon
2026-02-11 10:47 ` Philipp Stanner
2026-02-11 11:07 ` Boris Brezillon
2026-02-11 11:19 ` Danilo Krummrich
2026-02-11 12:10 ` Boris Brezillon
2026-02-11 12:32 ` Danilo Krummrich
2026-02-11 12:51 ` Boris Brezillon
2026-02-11 11:19 ` Philipp Stanner
2026-02-11 11:59 ` Boris Brezillon
2026-02-11 12:14 ` Philipp Stanner
2026-02-11 12:24 ` Boris Brezillon
2026-02-11 12:22 ` Alice Ryhl
2026-02-11 12:44 ` Philipp Stanner
2026-02-11 12:52 ` Alice Ryhl
2026-02-11 13:53 ` Philipp Stanner
2026-02-11 15:28 ` Alice Ryhl
2026-02-11 12:45 ` Danilo Krummrich
2026-02-11 13:45 ` Gary Guo
2026-02-11 14:07 ` Boris Brezillon
2026-02-11 15:17 ` Alice Ryhl
2026-02-11 15:20 ` Philipp Stanner
2026-02-11 15:51 ` Boris Brezillon
2026-02-11 15:53 ` Alice Ryhl
2026-02-11 15:54 ` Danilo Krummrich
2026-02-11 15:33 ` Alice Ryhl
2026-02-03 8:14 ` [RFC PATCH 4/4] samples: rust: Add jobqueue tester Philipp Stanner
2026-02-03 16:46 ` [RFC PATCH 0/4] Add dma_fence abstractions and DRM Jobqueue Daniel Almeida
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=20260210155025.1b9ad2f1@fedora \
--to=boris.brezillon@collabora.com \
--cc=airlied@gmail.com \
--cc=aliceryhl@google.com \
--cc=christian.koenig@amd.com \
--cc=dakr@kernel.org \
--cc=daniel.almeida@collabora.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=gary@garyguo.net \
--cc=joelagnelf@nvidia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lossin@kernel.org \
--cc=phasta@kernel.org \
--cc=phasta@mailbox.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=simona@ffwll.ch \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.