Re: [PATCH RFT] driver core: faux: allow to set the firmware node for a faux device
From: Bartosz Golaszewski
Date: Tue Mar 10 2026 - 09:57:30 EST
On Mon, Mar 9, 2026 at 4:55 PM Greg Kroah-Hartman
<gregkh@xxxxxxxxxxxxxxxxxxx> wrote:
>
> On Mon, Mar 09, 2026 at 09:16:19PM +0530, Shivendra Pratap wrote:
> >
> >
> > On 06-03-2026 19:54, Bartosz Golaszewski wrote:
> > > On Fri, Mar 6, 2026 at 3:13 PM Greg Kroah-Hartman
> > > <gregkh@xxxxxxxxxxxxxxxxxxx> wrote:
> > > >
> > > > On Fri, Mar 06, 2026 at 03:07:03PM +0100, Bartosz Golaszewski wrote:
> > > > > On Fri, Mar 6, 2026 at 2:54 PM Greg Kroah-Hartman
> > > > > <gregkh@xxxxxxxxxxxxxxxxxxx> wrote:
> > > > > >
> > > > > > On Fri, Mar 06, 2026 at 02:45:56PM +0100, Bartosz Golaszewski wrote:
> > > > > > > Add a new variant of faux_device_create() taking a firmware node handle
> > > > > > > as argument and attaching it to the created faux device. This allows
> > > > > > > users to define and read device properties using the standard property
> > > > > > > accessors.
> > > > > >
> > > > > > Why would a faux device have firmware backing? Doesn't that mean it
> > > > > > should be a platform device?
> > > > > >
> > > > > > > While at it: order includes in faux.c alphabetically for easier
> > > > > > > maintenance.
> > > > > >
> > > > > > Hint, that should be a separate patch, and is never something that I
> > > > > > enforce or require in .c files I maintain :)
> > > > > >
> > > > > > > Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@xxxxxxxxxxxxxxxx>
> > > > > > > ---
> > > > > > > Hi Shivendra et al!
> > > > > > >
> > > > > > > This patch is related to my response to your reboot-mode patch[1].
> > > > > > >
> > > > > > > You should be able to use the new function like:
> > > > > > >
> > > > > > > faux_device_create_full("psci-reboot-mode", NULL, NULL, NULL, of_fwnode_handle(np));
> > > > > >
> > > > > > What is the fwnode handle here for? Why is it required at all? What
> > > > > > resources are involved that would want this?
> > > > > >
> > > > >
> > > > > Shivendra creates a faux device that registers with the reboot-mode
> > > > > subsystem which reads the reboot-mode definitions from devicetree. The
> > > > > faux device needs to have the "reboot-mode" OF-node attached. In his
> > > > > current proposal, Shivenda had to bypass faux device's probe() because
> > > > > he can't have the fwnode attached before probe() is called.
> > > >
> > > > Why would a firmware device be attached to a faux device? A firmware
> > > > device is, implicitly, already part of the firmware "device tree", so
> > > > there should be something for it to be a child of already in the system.
> > > >
> > >
> > > Shivendra: I rememeber there was an issue with using any proper
> > > devices like platform or auxiliary with this but - as the series is
> > > already at v20 - I can't find the actual discussion. Could you please
> > > describe what the issue with driver matching was?
> >
> > reboot-mode node is a property of psci which defines the reboot commands. As
> > its not an actual device we wanted to avoid creating platform or aux device.
> > few references here:
> >
> > https://lore.kernel.org/all/rz7tnl5gg73gtyij3kmwk6hubikfsvu3krekjkpoofpdio6cwe@innio7qvotye/
> >
> > Till v17, we were exposing an explicit of_node based registration in reboot
> > mode and then registering it from psci driver.
> > Post this, Lorenzo suggested to move this outside of psci and use a faux
> > device instead.
>
> As this is a "real" device that talks to hardware (i.e. you have a
> firmware device representation), please do not use a faux device, that
> is not what that interface is for. Instead, as it is a firmware device,
> just use a platform one as you already have a representation of it
> somewhere in the system, right?
While there is indeed a psci node on arm64 platforms, psci itself must
be brought up very early - specifically in setup_arch() - so there's
no platform device associated with it as the driver is called into
before the driver core is initialized. It's just a function called for
a specific compatible value.
Now looking again at Shivendra's patch, the faux device in question is
created from a device_initcall() which makes me think it's not needed
very early. It can actually come up quite late. What I would suggest
is to create a psci platform device (reusing the existing
of_device_id) that would populate its child OF nodes in probe(), in
this case: the reboot-mode driver, which could then also become a real
platform device.
On a completely unrelated note though - Greg: I think this patch could
still be considered because we now have quite a lot of functionality
put into software nodes and already have some auxiliary devices that
use software nodes as a source of device properties/config using the
same API as platform devices (fwnode). I think faux devices could also
profit from it and not necessairly use custom struct. If that sounds
good to you, I may convert one or two faux devices and send a series
with actual users of this.
Bartosz