Rust GPU fence cleanup collides with dma_fence rules
Christian König says an unsignaled fence must not complete just because a Rust object went out of scope; the Rust DRM authors say that warning no longer means what it used to.
A one-line change in the kernel's Rust DMA fence code has turned into a dispute over whether Rust ownership can stand in for the rules that have governed GPU synchronization for years.
Philipp Stanner, with the change suggested by Danilo Krummrich, wants to drop the error printed when a driver fence is destroyed before anyone has signaled it. The destructor already marks that fence canceled. Stanner's case is that the message fights ordinary Rust teardown: dropping a lock unlocks it, dropping a box frees it, and a fence the driver no longer cares about should be allowed to end the same way, with cancellation as the default error.
Christian König, who maintains the C dma_fence code used across DRM, rejected that reading. "A dma_fence should never automatically signal when the last reference drops," he wrote on the dri-devel list. Leaving the fence unsignaled can deadlock waiters, he argued, but it at least does not invite memory corruption. Signaling every forgotten fence with a cancel error is not enough, because unloading a driver does not mean the hardware has stopped DMA. He cited firmware that kept writing into a buffer after the driver had given up, and said a software object falling out of scope is not evidence that the device has stopped. If fences are still outstanding when the driver goes away, he wants a log warning at minimum, and possibly a BUG or a panic: those calls do not fix the bug, but they tell an operator to reboot and a developer that something is badly wrong.
Stanner answered that neither C nor Rust can enforce the safe order. A driver can signal, free its resources, and still forget to halt the ring; a warning in the fence core does not catch that. Only the driver knows how its hardware works. In the Rust job-queue API, callers do not hold fences directly, so "forgetting" one means leaking the queue and the GPU ring with it.
Krummrich went further: an unsignaled drop is not proof that "something very very bad happened." Rust drivers embed the fence in the object that represents the hardware or firmware queue. When that fence's destructor runs, the owning object's destructor, which is supposed to stop the device, has already run. König called binding fence state to an object lifetime "extremely bad practice." Krummrich said that judgment assumes the C DRM habit of reference-counting hardware state past unbind. Rust, he wrote, defines ownership so a destructor that owns DMA memory is the place that must stop the device from touching it. If the hardware cannot be stopped, the driver must not finish unloading.
The warning is still in the tree. The argument is about whether Rust RAII has changed what an unsignaled fence means, or whether GPU synchronization still has to scream when software walks away first.