Re: [PATCH 2/2] rust/kernel: Add platform::ModuleDevice

Danilo Krummrich
2025-01-23T10:21:34Z

On Thu, Jan 23, 2025 at 07:23:08AM +0100, Greg Kroah-Hartman wrote:
> On Wed, Jan 22, 2025 at 06:49:22PM -0500, Lyude Paul wrote:
> > A number of kernel modules work with virtual devices, where being virtual
> > implies that there's no physical device to actually be plugged into the
> > system. Because of that, such modules need to be able to manually
> > instantiate a kernel device themselves - which can then be probed in the
> > same manner as any other kernel device.
> >
> > This adds support for such a usecase by introducing another platform device
> > type, ModuleDevice. This type is interchangeable with normal platform
> > devices, with the one exception being that it controls the lifetime of the
> > registration of the device.
>
> Sorry, but a "virtual" device is NOT a platform device at all. Platform
> devices are things that are not on a real bus and are described by
> firmware somehow.
>
> The kernel has "virtual" devices today just fine, look at
> /sys/devices/virtual/ so why not just use that api instead of making up
> something new?

I think we briefly discussed this in another mail thread [1] for the example of
the vKMS driver [2] in the past.

In [1] you mentioned that with the virtual device API, things are a bit
inconvenient and that you want to follow up on this.

I can't speak for Lyude, but I assume that she would also be willing to help
out getting to a better solution than what drivers like vKMS currently do and
then have a Rust abstraction for that, but your previous reply didn't indicate
there's already one ready to grab.

[1] https://lore.kernel.org/lkml/2024071106-handed-oversleep-2377@gregkh/
[2] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/gpu/drm/vkms/vkms_drv.c