Re: [PATCH] rust: DamFence: Remove warning about unsignaled drop
From: Philipp Stanner
Date: Tue Nov 17 2026 - 05:54:34 EST
On Tue, 2026-11-17 at 10:51 +0100, Christian König wrote:
> On 11/17/26 09:24, Philipp Stanner wrote:
> > struct DriverFoo {
> > f: DriverFence<()>,
> > }
> >
> > impl Drop for Driver Foo {
> > pub fn drop(&mut self) {
> > // Signals fence implicitly & automatically.
> > self.f.signal(ECANCELED);
> > }
> > }
>
> Yeah, exactly that is still a bad idea :) See the HW eventually
> doesn't necessarily stop doing DMA if you unload the driver.
I know.
> So just signaling all fences with ECANCELED is not enough.
Yes. What I was trying to tell you as that you have no way to enforce
this in Rust or C.
dma_fence_signal(f);
free_driver_resources();
// Driver forgets to stop the hardware. Memory corruption occurs.
You see? Neither your BUG_ON() or WARN_ON() saves you if the driver
does it like that, no matter the programming language. You cannot
prevent it.
The only one who understands how the hardware works is the driver. The
only one who can stop it is the driver.
In Rust, the place where a driver drops its JobQueue is the same place
where it has to halt its GPU ring correctly. Enforcing this cannot be
done by dma_fence code.
P.