From: Philipp Stanner <phasta@mailbox.org>
To: Danilo Krummrich <dakr@kernel.org>, 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: Wed, 23 Sep 2026 11:21:26 +0200 [thread overview]
Message-ID: <ffad51ef7d5f20d21396c84362fbdd2ac5883116.camel@mailbox.org> (raw)
In-Reply-To: <DL9AEUZ4VGV5.2RT33JE0MHYME@kernel.org>
On Mon, 2026-09-07 at 20:14 +0200, Danilo Krummrich wrote:
> 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.
Yeah, it would be odd. I would not expect it to happen. But many things
have happened which I did not expect, so … :)
>
> 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.
Hypothetically, it could mean that there is a forgotten job still
running on the GPU, which might then access freed resources through
DMA. Sure, that would mean that the driver is fundamentally broken, but
that's what warnings like that are about.
Just to ellaborate on my thinking. I wouldn't insist on any wording.
From my POV we can just say "… drops unsignaled.". That should be
enough.
>
> 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.
Yup, with the JobQueue design I have in mind this error is largely
impossible, just as the forgetting of DriverFences is. Which is why I
think it's a good design idea to have the JQ own the jobs, isolating
the driver from direct fence interaction.
P.
next prev parent reply other threads:[~2026-09-23 9:21 UTC|newest]
Thread overview: 6+ 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
2026-09-23 9:21 ` Philipp Stanner [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=ffad51ef7d5f20d21396c84362fbdd2ac5883116.camel@mailbox.org \
--to=phasta@mailbox.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=dakr@kernel.org \
--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®