[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20210615212153.fvfenkyqabyqp7dk@skbuf>
Date: Wed, 16 Jun 2021 00:21:53 +0300
From: Ioana Ciornei <ciorneiioana@...il.com>
To: "Russell King (Oracle)" <linux@...linux.org.uk>
Cc: Andrew Lunn <andrew@...n.ch>,
Ioana Ciornei <ciorneiioana@...il.com>, davem@...emloft.net,
kuba@...nel.org, netdev@...r.kernel.org,
calvin.johnson@....nxp.com, hkallweit1@...il.com,
Ioana Ciornei <ioana.ciornei@....com>
Subject: Re: [PATCH net-next] mdio: mdiobus: setup of_node for the MDIO device
On Tue, Jun 15, 2021 at 10:09:07PM +0100, Russell King (Oracle) wrote:
> On Tue, Jun 15, 2021 at 08:31:06PM +0200, Andrew Lunn wrote:
> > On Tue, Jun 15, 2021 at 06:13:31PM +0100, Russell King (Oracle) wrote:
> > > On Tue, Jun 15, 2021 at 06:44:01PM +0300, Ioana Ciornei wrote:
> > > > From: Ioana Ciornei <ioana.ciornei@....com>
> > > >
> > > > By mistake, the of_node of the MDIO device was not setup in the patch
> > > > linked below. As a consequence, any PHY driver that depends on the
> > > > of_node in its probe callback was not be able to successfully finish its
> > > > probe on a PHY, thus the Generic PHY driver was used instead.
> > > >
> > > > Fix this by actually setting up the of_node.
> > > >
> > > > Fixes: bc1bee3b87ee ("net: mdiobus: Introduce fwnode_mdiobus_register_phy()")
> > > > Signed-off-by: Ioana Ciornei <ioana.ciornei@....com>
> > > > ---
> > > > drivers/net/mdio/fwnode_mdio.c | 1 +
> > > > 1 file changed, 1 insertion(+)
> > > >
> > > > diff --git a/drivers/net/mdio/fwnode_mdio.c b/drivers/net/mdio/fwnode_mdio.c
> > > > index e96766da8de4..283ddb1185bd 100644
> > > > --- a/drivers/net/mdio/fwnode_mdio.c
> > > > +++ b/drivers/net/mdio/fwnode_mdio.c
> > > > @@ -65,6 +65,7 @@ int fwnode_mdiobus_phy_device_register(struct mii_bus *mdio,
> > > > * can be looked up later
> > > > */
> > > > fwnode_handle_get(child);
> > > > + phy->mdio.dev.of_node = to_of_node(child);
> > > > phy->mdio.dev.fwnode = child;
> > >
> > > Yes, this is something that was missed, but let's first look at what
> > > other places to when setting up a device:
> > >
> > > pdev->dev.fwnode = pdevinfo->fwnode;
> > > pdev->dev.of_node = of_node_get(to_of_node(pdev->dev.fwnode));
> > > pdev->dev.of_node_reused = pdevinfo->of_node_reused;
> > >
> > > dev->dev.of_node = of_node_get(np);
> > > dev->dev.fwnode = &np->fwnode;
> > >
> > > dev->dev.of_node = of_node_get(node);
> > > dev->dev.fwnode = &node->fwnode;
> > >
> > > That seems to be pretty clear that an of_node_get() is also needed.
> >
> > I think it also shows we have very little consistency, and the recent
> > patchset needs a bit of cleanup. Maybe yet another helper which when
> > passed a struct device * and a node pointer, it sets both values?
>
> I do like that idea - maybe a couple of helpers, one that takes the
> of_node for a struct device, and another that takes a fwnode and
> does the appropriate stuff.
>
I agree. Some consistency would be needed here.
I'll submit something tomorrow.
On the other hand, I would like to keep this patch as it is and build on
top of it with the helpers that Andrew suggested.
> Note that platform_device_release() does this:
>
> of_node_put(pa->pdev.dev.of_node);
>
> which is currently fine, because platform devices appear to only
> have their DT refcount increased. From what I can tell from looking
> at drivers/acpi/arm64/iort.c, ACPI fwnodes don't look like they're
> refcounted. Seems we're wading into something of a mess here. :(
>
The fwnode_operations declared in drivers/acpi/property.c also suggest
the ACPI fwnodes are not refcounted.
Ioana
Powered by blists - more mailing lists