From: Philipp Stanner <phasta@mailbox.org>
To: "Christian König" <christian.koenig@amd.com>,
phasta@kernel.org, "Danilo Krummrich" <dakr@kernel.org>
Cc: "Sumit Semwal" <sumit.semwal@linaro.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>,
linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org,
rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] rust: DamFence: Remove warning about unsignaled drop
Date: Thu, 19 Nov 2026 15:55:42 +0100 [thread overview]
Message-ID: <972ba9ddea36c9dc84ce649e2edcf6bde71420d1.camel@mailbox.org> (raw)
In-Reply-To: <141892f8-180c-4157-8c59-6e69057334f2@amd.com>
On Thu, 2026-11-19 at 11:47 +0100, Christian König wrote:
> On 11/19/26 10:58, Philipp Stanner wrote:
> BTW that is the reason why dma_fences are RCU protected as well. That
> is not because of performance but rather to be able to do a try get
> on a reference to solve reference direction problems.
You mean dma_fence_get_rcu()?
That's simply a workaround for broken refcounting. Either you have a
reference, then you can increment it. Or you don't, because you stole
someone else's reference, and now you need a magic RCU delay so that
the rightful owner of the reference cannot free the memory that you
illegally occupy.
> No it doesn't.
>
> What I want to ensure is that drivers don't come up with funky methods to signal fences.
They won't because the only signal mechanisms is our API.
All the driver needs to do right is to associate the fence container
with the object associated with the hardware.
>
> The cleanup part you want to have here is clearly good to get that
> defined as well, but to be honest that is peanuts compared to what
> you get when you have the dma_fence signaling wrong.
>
> >
> > That's how teardown is done in Rust. You drop the lock, it unlocks
> > itself. You drop the memory, it frees itself. You drop the fence, it
> > signals itself.
> >
> > That's by design because the object lifetime model falls naturally into
> > place.
> >
> > > I think the most defensive way would be as last resort scream loud in
> > > the logs that the driver is somehow buggy and hasn't signaled it's
> > > fence, wait for a certain amount of time (100ms?) as safeguard and
> > > then signal the fence with an error.
> >
> > Now that doesn't make any sense at all, either the hardware is stopped
> > or it isn't.
>
> There is a huge window of state in between.
>
> > Having some random delay is probably even worse because
> > the problem is then more difficult to even encounter and thus fix.
>
> Well the whole point of the delay is to at least have some kind of
> save guard that makes follow up problems less likely to encounter in
> production.
>
> That the underlying problem is fixed should be triggered by the big
> warning in the system log and not because I notice that my valuable
> data is corrupted because a DMA fence signaled to early and caused
> random corruption.
Again, if the driver, the only one who understands the hardware, really
wants to screw up then your system is done anyway.
Remember my previous example:
// forgets to stop hardware
dma_fence_signal(f);
// still forgets to stop hardware
Your WARN_ON will not trigger. Your sleep/delay would not trigger.
> > > Exactly that is what I disagree on.
> > >
> > > Stopping the HW is what makes fences signal and that is what this
> > > tear down process should block for.
> >
> > Our point is that dropping stuff stops the hardware, and *then* signals
> > the fences. Exactly what you want! :)
>
> No, that is completely backwards.
>
> A dma_fence should *NEVER* signal because you waited for something. Instead the dma_fence is what is waited on.
By whom? And who signals it? It's the party stopping the hardware, no?
So just like with our design.
P.
next prev parent reply other threads:[~2026-11-19 14:55 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-12 10:10 [PATCH] rust: DamFence: Remove warning about unsignaled drop Philipp Stanner
2026-11-12 10:29 ` Christian König
2026-11-17 8:24 ` Philipp Stanner
2026-11-17 9:51 ` Christian König
2026-11-17 10:54 ` Philipp Stanner
2026-11-17 13:40 ` Christian König
2026-11-17 13:50 ` Danilo Krummrich
2026-11-17 14:50 ` Christian König
2026-11-17 16:26 ` Gary Guo
2026-11-17 16:36 ` Danilo Krummrich
2026-11-19 9:32 ` Christian König
2026-11-19 9:58 ` Philipp Stanner
2026-11-19 10:47 ` Christian König
2026-11-19 14:55 ` Philipp Stanner [this message]
2026-11-19 15:34 ` Danilo Krummrich
2026-11-19 12:35 ` Danilo Krummrich
2026-11-17 14:06 ` 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=972ba9ddea36c9dc84ce649e2edcf6bde71420d1.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=christian.koenig@amd.com \
--cc=dakr@kernel.org \
--cc=daniel.almeida@collabora.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=gary@garyguo.net \
--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