Re: [PATCH] gpu: nova-core: fb: make sure to unregister SysmemFlush on boot failure
From: Danilo Krummrich
Date: Mon Apr 13 2026 - 06:58:05 EST
On Fri Apr 10, 2026 at 5:57 PM CEST, Gary Guo wrote:
>> +impl Drop for SysmemFlush {
>> + fn drop(&mut self) {
>> + let _ = self.bar.try_access_with(|bar| self.unregister(bar));
>
> I feel that this is the wrong solution to the problem.
Yeah, it is pretty fragile as it relies on outer implementation details, such as
the fact that SysmemFlush is part of the device private data and hence
try_access_with() will fail when not dropped in an unwind path.
> The thing we want is to *ensure* that `SysmemFlush` Drop is called with device
> still being bound.
>
> It's not yet fully clear to me how we'd want to guarantee that, but one API that
> might make sense is to create a DevRes API that allows you to reference an
> existing `DevRes` and have driver-core making sure that the tear down happens in
> reverse order. So inside the `Drop` the `bar` can still be unconditionally
> access.
Yes, I have something like this on my list of things I want to look into for
while (my list entry calls it DevresChain).
I want to leverage the internal reference count of Devres for this, which is not
exactly straight forward, but should be possible.
I will prioritize this and have a look.
Thanks,
Danilo