mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Daniel Almeida <daniel.almeida@collabora.com>
To: "Sumit Semwal" <sumit.semwal@linaro.org>,
	"Christian König" <christian.koenig@amd.com>,
	"Philipp Stanner" <phasta@kernel.org>,
	"Danilo Krummrich" <dakr@kernel.org>,
	"Alice Ryhl" <aliceryhl@google.com>,
	"Miguel Ojeda" <ojeda@kernel.org>,
	"Boqun Feng" <boqun@kernel.org>, "Gary Guo" <gary@garyguo.net>,
	"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
	"Benno Lossin" <lossin@kernel.org>,
	"Andreas Hindborg" <a.hindborg@kernel.org>,
	"Trevor Gross" <tmgross@umich.edu>,
	"Daniel Almeida" <daniel.almeida@collabora.com>,
	"Tamir Duberstein" <tamird@kernel.org>,
	"Alexandre Courbot" <acourbot@nvidia.com>,
	"Onur Özkan" <work@onurozkan.dev>
Cc: linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org,
	 linaro-mm-sig@lists.linaro.org, rust-for-linux@vger.kernel.org,
	 linux-kernel@vger.kernel.org
Subject: [PATCH 2/2] rust: dma_buf: dma_fence: require a SignallingSection in signal()
Date: Fri, 27 Nov 2026 15:30:38 -0300	[thread overview]
Message-ID: <20261127-dma-fence-signalling-v1-2-c44e8f4910ca@collabora.com> (raw)
In-Reply-To: <20261127-dma-fence-signalling-v1-0-c44e8f4910ca@collabora.com>

DriverFence::signal() is where a fence's signalling path ends. The
dma-fence rules require the whole path, from the point where the fence
becomes visible to other threads up to the signal, to run in a
signalling section. A caller of signal() has most likely been running
on that path before the call.

Make DriverFence::signal() take a &SignallingSection, so that callers
have to open a section. This does not ensure that the section covers
the whole signalling path, as drivers can simply do:

    fence.signal(res, &SignallingSection::begin());

But at least it nudges drivers in the right direction and forces them
to consider signalling sections instead of ignoring them.

Update the DriverFence example accordingly.

Signed-off-by: Daniel Almeida <daniel.almeida@collabora.com>
---
 rust/kernel/dma_buf/dma_fence.rs | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/rust/kernel/dma_buf/dma_fence.rs b/rust/kernel/dma_buf/dma_fence.rs
index 7ee87935d3be..39f9bb9d1be3 100644
--- a/rust/kernel/dma_buf/dma_fence.rs
+++ b/rust/kernel/dma_buf/dma_fence.rs
@@ -773,7 +773,7 @@ struct DriverFenceData<'a, T: Send + Sync + FenceContextOps> {
 ///
 /// let section = SignallingSection::begin();
 /// assert_eq!(waiting_fence.is_signaled(), false);
-/// fence.signal(Ok(()));
+/// fence.signal(Ok(()), &section);
 /// drop(section);
 /// assert_eq!(waiting_fence.is_signaled(), true);
 ///
@@ -873,7 +873,10 @@ pub fn as_fence(&self) -> &Fence {
     }
 
     /// Signal the fence. This will invoke all registered callbacks.
-    pub fn signal(self, res: Result) {
+    ///
+    /// Takes a [`SignallingSection`] because all code needed to signal the
+    /// fence must run in one.
+    pub fn signal(self, res: Result, _section: &SignallingSection) {
         let fence = self.as_fence().lock();
 
         // SAFETY: `fence` is valid because `self` is valid. The lock must be

-- 
2.56.0


  parent reply	other threads:[~2026-11-27 18:31 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-27 18:30 [PATCH 0/2] rust: dma_buf: add dma-fence signalling sections Daniel Almeida
2026-11-27 18:30 ` [PATCH 1/2] rust: dma_buf: dma_fence: add SignallingSection Daniel Almeida
2026-11-27 21:06   ` Danilo Krummrich
2026-11-27 18:30 ` Daniel Almeida [this message]
2026-11-27 18:59 ` [PATCH 0/2] rust: dma_buf: add dma-fence signalling sections Gary Guo
2026-11-27 20:11   ` Danilo Krummrich
2026-11-27 20:26     ` Danilo Krummrich

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=20261127-dma-fence-signalling-v1-2-c44e8f4910ca@collabora.com \
    --to=daniel.almeida@collabora.com \
    --cc=a.hindborg@kernel.org \
    --cc=acourbot@nvidia.com \
    --cc=aliceryhl@google.com \
    --cc=bjorn3_gh@protonmail.com \
    --cc=boqun@kernel.org \
    --cc=christian.koenig@amd.com \
    --cc=dakr@kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=gary@garyguo.net \
    --cc=linaro-mm-sig@lists.linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=lossin@kernel.org \
    --cc=ojeda@kernel.org \
    --cc=phasta@kernel.org \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=sumit.semwal@linaro.org \
    --cc=tamird@kernel.org \
    --cc=tmgross@umich.edu \
    --cc=work@onurozkan.dev \
    /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

all inboxes | Powered by JetHome®