Re: [PATCH] rust: DmaFence: Add better warning through Device reference
From: Danilo Krummrich
Date: Fri Sep 25 2026 - 12:21:27 EST
On Fri Sep 25, 2026 at 3:08 PM CEST, Philipp Stanner wrote:
> On Fri, 2026-09-25 at 14:30 +0200, Danilo Krummrich wrote:
>> On Fri Sep 25, 2026 at 12:26 PM CEST, Gary Guo wrote:
>> > On Fri Sep 25, 2026 at 9:19 AM BST, Philipp Stanner wrote:
>> > > Replace the warning print with a dev_warn!(). To do so, have the
>> > > FenceContext carry a reference to a Device, protected by the already
>> > > present lifetime.
>> >
>> > Add a lifetime just to do this a print doesn't sound ideal. You could use
>> > `ARef<Device>` instead?
>>
>> Yes, that's what I recommend in general.
>
> Weren't you super opposed to refcounting wherever it's avoidable?
Well, a device by itself is already reference counted (which is fine). The
lifetime constraint does not come from the lifetime of a struct device, it comes
from it being bound to a driver for bus devices; for class devices the lifetime
constraint comes from the device being registered.
I'm opposed to refcount stuff that has a bounded lifetime that is defined by
some scope it must not outlive.