public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Alice Ryhl <aliceryhl@google.com>
To: "Christian König" <christian.koenig@amd.com>
Cc: Boris Brezillon <boris.brezillon@collabora.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 08:38:00 +0000	[thread overview]
Message-ID: <aYruaIxn8sMXVI0r@google.com> (raw)
In-Reply-To: <c319c349-eb95-4c38-84fb-47440daefc3b@amd.com>

On Tue, Feb 10, 2026 at 09:16:34AM +0100, Christian König wrote:
> On 2/9/26 15:58, Boris Brezillon wrote:
> > On Mon, 09 Feb 2026 09:19:46 +0100
> > Philipp Stanner <phasta@mailbox.org> wrote:
> > 
> >> On Fri, 2026-02-06 at 11:23 +0100, Danilo Krummrich wrote:
> >>> On Thu Feb 5, 2026 at 9:57 AM CET, Boris Brezillon wrote:  
> >>>> On Tue,  3 Feb 2026 09:14:01 +0100
> >>>> Philipp Stanner <phasta@kernel.org> wrote:
> >>>> Unfortunately, I don't know how to translate that in rust, but we
> >>>> need a way to check if any path code path does a DmaFence.signal(),
> >>>> go back to the entry point (for a WorkItem, that would be
> >>>> WorkItem::run() for instance), and make it a DmaFenceSignallingPath.
> >>>> Not only that, but we need to know all the deps that make it so
> >>>> this path can be called (if I take the WorkItem example, that would
> >>>> be the path that leads to the WorkItem being scheduled).  
> >>>
> >>> I think we need a guard object for this that is not Send, just like for any
> >>> other lock.
> >>>
> >>> Internally, those markers rely on lockdep, i.e. they just acquire and release a
> >>> "fake" lock.  
> >>
> >> The guard object would be created through fence.begin_signalling(), wouldn't it?
> > 
> > It shouldn't be a (&self)-method, because at the start of a DMA
> > signaling path, you don't necessarily know which fence you're going to
> > signal (you might actually signal several of them).
> > 
> >> And when it drops you call dma_fence_end_signalling()?
> > 
> > Yep, dma_fence_end_signalling() should be called when the guard is
> > dropped.
> > 
> >>
> >> How would that ensure that the driver actually marks the signalling region correctly?
> > 
> > Nothing, and that's a problem we have in C: you have no way of telling
> > which code section is going to be a DMA-signaling path. I can't think
> > of any way to make that safer in rust, unfortunately. The best I can
> > think of would be to
> > 
> > - Have a special DmaFenceSignalWorkItem (wrapper a WorkItem with extra
> >   constraints) that's designed for DMA-fence signaling, and that takes
> >   the DmaSignaling guard around the ::run() call.
> > - We would then need to ensure that any code path scheduling this work
> >   item is also in a DMA-signaling path by taking a ref to the
> >   DmaSignalingGuard. This of course doesn't guarantee that the section
> >   is wide enough to prevent any non-authorized operations in any path
> >   leading to this WorkItem scheduling, but it would at least force the
> >   caller to consider the problem.
> 
> On the C side I have a patch set which does something very similar.
> 
> It's basically a WARN_ON_ONCE() which triggers as soon as you try to
> signal a DMA fence from an IOCTL, or more specific process context.
> 
> Signaling a DMA fence from interrupt context, a work item or kernel
> thread is still allowed, there is just the hole that you can schedule
> a work item from process context as well.
> 
> The major problem with that patch set is that we have tons of very
> hacky signaling paths in drivers already because we initially didn't
> knew how much trouble getting this wrong causes.
> 
> I'm strongly in favor of getting this right for the rust side from the
> beginning and enforcing strict rules for every code trying to
> implement a DMA fence.

Hmm. Could you say a bit more about what the rules are? I just re-read
the comments in dma-fence.c, but I have some questions.

First, how does the signalling annotation work when the signalling path
crosses thread boundaries? For example, let's say I call an ioctl to
perform an async VM_BIND, then the dma fence signalling critical path
starts in the ioctl, but then it moves into a workqueue and finishes
there, right?

Second, it looks like we have the same challenge as with irq locks where
you must properly nest dma_fence_begin_signalling() regions, and can't
e.g. do this:

c1 = dma_fence_begin_signalling()
c2 = dma_fence_begin_signalling()
dma_fence_end_signalling(c1)
dma_fence_end_signalling(c2)

Alice

  reply	other threads:[~2026-02-10  8:38 UTC|newest]

Thread overview: 103+ 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 [this message]
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
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-09 11:30   ` Alice Ryhl
2026-02-03  8:14 ` [RFC PATCH 3/4] rust/drm: Add DRM Jobqueue Philipp Stanner
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=aYruaIxn8sMXVI0r@google.com \
    --to=aliceryhl@google.com \
    --cc=airlied@gmail.com \
    --cc=boris.brezillon@collabora.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox