From: "Danilo Krummrich" <dakr@kernel.org>
To: "Philipp Stanner" <phasta@kernel.org>
Cc: "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>,
"Alice Ryhl" <aliceryhl@google.com>,
"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>,
"Sumit Semwal" <sumit.semwal@linaro.org>,
"Christian König" <christian.koenig@amd.com>,
"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
"Yury Norov (NVIDIA)" <yury.norov@gmail.com>,
"Asahi Lina" <lina+kernel@asahilina.net>,
"Burak Emir" <burak.emir@gmail.com>,
"Lorenzo Stoakes" <ljs@kernel.org>,
"Joel Fernandes" <joelagnelf@nvidia.com>,
"FUJITA Tomonori" <fujita.tomonori@gmail.com>,
"Boris Brezillon" <boris.brezillon@collabora.com>,
linux-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org,
linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v11 1/2] rust: Add dma_fence abstractions
Date: Mon, 07 Sep 2026 20:14:52 +0200 [thread overview]
Message-ID: <DL9AEUZ4VGV5.2RT33JE0MHYME@kernel.org> (raw)
In-Reply-To: <20260905085343.1827305-3-phasta@kernel.org>
On Sat Sep 5, 2026 at 10:53 AM CEST, Philipp Stanner wrote:
> +impl<'a, T: Send + Sync + FenceContextOps> Drop for DriverFence<'a, T> {
> + fn drop(&mut self) {
> + let guard = self.as_fence().lock();
> +
> + // Use dma_fence_test_signaled_flag() instead of
> + // dma_fence_is_signaled_locked() because the C backend wants to get rid
> + // of the latter.
> +
> + // SAFETY: `guard` is valid until the `call_rcu()` below.
> + let signaled: bool = unsafe { bindings::dma_fence_test_signaled_flag(guard.as_raw()) };
> + if !signaled {
> + pr_err!("DriverFence drops unsignaled. Danger of memory corruption!\n");
I'm not sure we want to keep this as pr_err!().
If we really want to keep warning about this I'd either make this a WARN_ON() or
dev_warn() (we can easily store a device reference in the fence context), such
that it is at least clear who's the offender.
My preference would be dev_warn(), as I don't think it is that bad of an error
condition to begin with. It would be pretty odd to have a driver where a DriverFence
drops while the corresponding GPU job is not dropped. And further it'd be pretty
odd if dropping the GPU job would not imply that the GPU actually stopped
processing the work associated with the job.
For the same reason I also think it is a bit misleading to say "Danger of memory
corruption!". It's not the signaling of the fence that does prevent memory
corruption; it's the driver implementing a proper teardown sequence. And if this
sequence is structurally detached from the lifetime of the DriverFence (and Job)
structure, something is structurally wrong with the driver anyway.
Furthermore, it would be very natural to just require the generic Job type to
own a DriverFence. In this case it becomes natural to either signal the fence on
Job completion, or just drop the Jobqueue, which does the ring teardown and
subsequently drops all the Jobs, which would also imply signaling the
DriverFence with ECANCELED. I.e. I think the fact that the DriverFence is
signaled with ECANCELED if it is still unsignaled should just be an API contract
and not an error condition.
Honestly, given all that, I'd expect drivers to otherwise just wrap a
DriverFence in a new type, which just signales the inner DriverFence with an
error code in its own destructor.
next prev parent reply other threads:[~2026-09-07 18:14 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-05 8:53 [PATCH v11 0/2] rust / dma_buf: Add abstractions for dma_fence Philipp Stanner
2026-09-05 8:53 ` [PATCH v11 1/2] rust: Add dma_fence abstractions Philipp Stanner
2026-09-07 18:14 ` Danilo Krummrich [this message]
2026-09-05 8:53 ` [PATCH v11 2/2] MAINTAINERS: Add entry for Rust dma-buf Philipp Stanner
2026-09-07 17:47 ` [PATCH v11 0/2] rust / dma_buf: Add abstractions for dma_fence 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=DL9AEUZ4VGV5.2RT33JE0MHYME@kernel.org \
--to=dakr@kernel.org \
--cc=a.hindborg@kernel.org \
--cc=acourbot@nvidia.com \
--cc=aliceryhl@google.com \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun@kernel.org \
--cc=boris.brezillon@collabora.com \
--cc=burak.emir@gmail.com \
--cc=christian.koenig@amd.com \
--cc=daniel.almeida@collabora.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=fujita.tomonori@gmail.com \
--cc=gary@garyguo.net \
--cc=gregkh@linuxfoundation.org \
--cc=joelagnelf@nvidia.com \
--cc=lina+kernel@asahilina.net \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=ljs@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 \
--cc=yury.norov@gmail.com \
/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®