On 11/17/26 11:54, Philipp Stanner wrote:
> 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.

I completely agree that we can't fix things from the dma_fence code, but it is 
our obligation to tell the user that something very very bad happened.

I mean that is what WARN_ON(), BUG_ON() and panic() are essentially good for, 
they never fix anything but just point out that the system should probably be 
rebooted and driver developers informed.

Regards,
Christian.

> 
> 
> P.

Reply via email to