Re: [PATCH 2/2] rust/kernel: Add platform::ModuleDevice
From: Simona Vetter
Date: Fri Jan 31 2025 - 11:44:21 EST
On Fri, Jan 24, 2025 at 12:02:38PM +0100, Danilo Krummrich wrote:
> On Thu, Jan 23, 2025 at 07:33:28PM -0500, Lyude Paul wrote:
> > On Thu, 2025-01-23 at 07:23 +0100, Greg Kroah-Hartman wrote:
> > > On Wed, Jan 22, 2025 at 06:49:22PM -0500, Lyude Paul wrote:
> > >
> > > And modules are code, not data. Let's not start to even attempt to tie
> > > lifetimes of device structures to module code, that way lies madness and
> > > rolls back the work we did decades ago to split the two apart :)
> >
> > To make sure I'm understanding you properly, by "are code not data" you're
> > suggesting that resources (devices, driver registrations, etc.) should have
> > their lifetime entirely managed by the kernel and not as part of the module
> > data structure correct?
>
> I think that's two different things.
>
> Driver registrations are bound to the module lifetime and in Rust, where we have
> a structure that represents the module lifetime, driver registrations are part
> of the module structure. That's fine.
>
> Device are more of a concern here, since they ideally orginate from real
> hardware and hence shouldn't be bound to a module lifetime.
>
> I think a virtual device would need to be an exception though. What else, if not
> the module should define its lifetime?
Yeah for virtual devices this should be possible I think. We do have plans
for vkms to gain configfs support, and then maybe the current device
wouldn't be needed anymore and we'd just register the configfs when
loading the module.
-Sima
--
Simona Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch