Re: [PATCH] rust: DamFence: Remove warning about unsignaled drop

From: Philipp Stanner

Date: Tue Nov 17 2026 - 03:25:11 EST


On Thu, 2026-11-12 at 11:29 +0100, Christian König wrote:
> On 11/12/26 11:10, Philipp Stanner wrote:
> > DriverFence::drop() contains a pr_warn!() for when the fence drops
> > unsignaled. This warning gets into the way of canonical teardown in
> > Rust: when you drop a lock, it unlocks itself, when you drop a KBox, it
> > frees itself etc. Congruently, users should be able to tear down fences
> > they don't care about anymore with ECANCELED, which is already the
> > default error code.
>
> Well a dma_fence should never automatically signal when the last
> reference drops.
>
> Leaving it unsignaled is the most defensive path we can go. That can
> lead to deadlocks but it can at least not lead to memory corruption.

True, you choose between the Unholy Trinity of DRM: deadlocks, UAF and
memory corruption :]

In this particular case, however, Rust does not allow for preventing
the user from signaling "forgotten" fences anyways, no matter how we
write the fence core:

struct DriverFoo {
f: DriverFence<()>,
}

impl Drop for Driver Foo {
pub fn drop(&mut self) {
// Signals fence implicitly & automatically.
self.f.signal(ECANCELED);
}
}


So we decided to die this death because this way we get rid of the two
of the three problems that *can* be solved in the API.


But it will please you to hear that all users of drm::JobQueue do not
have access to fences directly anyways, they can only signal them
through JobQueue. Thus, they can also not forget them (signaled or
unsignaled), because they would have to forget / leak the entire
JobQueue as a whole, so effectively forgetting also their GPU ring. If
that would happen, the driver would be broken beyond repair anyways.

Regards
P.