From: Marcin Wojtas <mw@semihalf.com>
To: Andrew Lunn <andrew@lunn.ch>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
netdev <netdev@vger.kernel.org>,
"David S. Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>,
Russell King - ARM Linux <linux@armlinux.org.uk>,
Grzegorz Jaszczyk <jaz@semihalf.com>,
Grzegorz Bernacki <gjb@semihalf.com>,
upstream@semihalf.com,
Samer El-Haj-Mahmoud <Samer.El-Haj-Mahmoud@arm.com>,
Jon Nettleton <jon@solid-run.com>,
Tomasz Nowicki <tn@semihalf.com>,
rjw@rjwysocki.net, lenb@kernel.org,
Stephen Rothwell <sfr@canb.auug.org.au>
Subject: Re: [net-next: PATCH v3 2/6] net: mdiobus: Introduce fwnode_mdbiobus_register()
Date: Thu, 24 Jun 2021 13:10:04 +0200 [thread overview]
Message-ID: <CAPv3WKdSNZzvDS5-FNK4eTMfRt6xuk6xYJ6eQf0N01Q4OhRS9Q@mail.gmail.com> (raw)
In-Reply-To: <CAPv3WKdR-NJ8oPo5JHb9rztYdQUZA=D3sLyf07D5n5oOm=UfjA@mail.gmail.com>
Hi,
czw., 24 cze 2021 o 00:10 Marcin Wojtas <mw@semihalf.com> napisał(a):
>
> Hi,
>
> śr., 23 cze 2021 o 22:22 Andrew Lunn <andrew@lunn.ch> napisał(a):
> >
> > On Mon, Jun 21, 2021 at 07:30:24PM +0200, Marcin Wojtas wrote:
> > > This patch introduces a new helper function that
> > > wraps acpi_/of_ mdiobus_register() and allows its
> > > usage via common fwnode_ interface.
> > >
> > > Fall back to raw mdiobus_register() in case CONFIG_FWNODE_MDIO
> > > is not enabled, in order to satisfy compatibility
> > > in all future user drivers.
> > >
> > > Signed-off-by: Marcin Wojtas <mw@semihalf.com>
> > > ---
> > > include/linux/fwnode_mdio.h | 12 +++++++++++
> > > drivers/net/mdio/fwnode_mdio.c | 22 ++++++++++++++++++++
> > > 2 files changed, 34 insertions(+)
> > >
> > > diff --git a/include/linux/fwnode_mdio.h b/include/linux/fwnode_mdio.h
> > > index faf603c48c86..13d4ae8fee0a 100644
> > > --- a/include/linux/fwnode_mdio.h
> > > +++ b/include/linux/fwnode_mdio.h
> > > @@ -16,6 +16,7 @@ int fwnode_mdiobus_phy_device_register(struct mii_bus *mdio,
> > > int fwnode_mdiobus_register_phy(struct mii_bus *bus,
> > > struct fwnode_handle *child, u32 addr);
> > >
> > > +int fwnode_mdiobus_register(struct mii_bus *bus, struct fwnode_handle *fwnode);
> > > #else /* CONFIG_FWNODE_MDIO */
> > > int fwnode_mdiobus_phy_device_register(struct mii_bus *mdio,
> > > struct phy_device *phy,
> > > @@ -30,6 +31,17 @@ static inline int fwnode_mdiobus_register_phy(struct mii_bus *bus,
> > > {
> > > return -EINVAL;
> > > }
> > > +
> > > +static inline int fwnode_mdiobus_register(struct mii_bus *bus,
> > > + struct fwnode_handle *fwnode)
> > > +{
> > > + /*
> > > + * Fall back to mdiobus_register() function to register a bus.
> > > + * This way, we don't have to keep compat bits around in drivers.
> > > + */
> > > +
> > > + return mdiobus_register(mdio);
> > > +}
> > > #endif
> >
> > I looked at this some more, and in the end i decided it was O.K.
> >
> > > +/**
> > > + * fwnode_mdiobus_register - bring up all the PHYs on a given MDIO bus and
> > > + * attach them to it.
> > > + * @bus: Target MDIO bus.
> > > + * @fwnode: Pointer to fwnode of the MDIO controller.
> > > + *
> > > + * Return values are determined accordingly to acpi_/of_ mdiobus_register()
> > > + * operation.
> > > + */
> > > +int fwnode_mdiobus_register(struct mii_bus *bus, struct fwnode_handle *fwnode)
> > > +{
> > > + if (is_acpi_node(fwnode))
> > > + return acpi_mdiobus_register(bus, fwnode);
> > > + else if (is_of_node(fwnode))
> > > + return of_mdiobus_register(bus, to_of_node(fwnode));
> > > + else
> > > + return -EINVAL;
> >
> > I wounder if here you should call mdiobus_register(mdio), rather than
> > -EINVAL?
> >
> > I don't have a strong opinion.
>
> Currently (and in foreseeable future) we support only DT/ACPI as a
> firmware description, reaching the last "else" means something really
> wrong. The case of lack of DT/ACPI and the fallback is handled on the
> include/linux/fwnode_mdio.h level.
>
> >
> > Reviewed-by: Andrew Lunn <andrew@lunn.ch>
> >
Unfortunately I have to withdraw this patch, as well as xgmac_mdio
one. In case the fwnode_/of_/acpi_mdio are built as modules, we get a
cycle dependency during depmod phase of modules_install, eg.:
depmod: ERROR: Cycle detected: fwnode_mdio -> of_mdio -> fwnode_mdio
depmod: ERROR: Found 2 modules in dependency cycles!
OR:
depmod: ERROR: Cycle detected: acpi_mdio -> fwnode_mdio -> acpi_mdio
depmod: ERROR: Found 2 modules in dependency cycles!
The proper solution would be to merge contents of
acpi_mdiobus_register and of_mdiobus_register inside the common
fwnode_mdiobus_register (so that the former would only call the
latter). However this change seems feasible, but I'd expect it to be a
patchset bigger than this one alone and deserves its own thorough
review and testing, as it would affect huge amount of current
of_mdiobus_register users.
Given above, for now I will resubmit this patchset in the shape as
proposed in v1, i.e. using the 'if' condition explicitly in mvmdio
driver.
Best regards,
Marcin
next prev parent reply other threads:[~2021-06-24 11:10 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-21 17:30 [net-next: PATCH v3 0/6] ACPI MDIO support for Marvell controllers Marcin Wojtas
2021-06-21 17:30 ` [net-next: PATCH v3 1/6] Documentation: ACPI: DSD: describe additional MAC configuration Marcin Wojtas
2021-06-23 20:18 ` Andrew Lunn
2021-06-23 21:00 ` Marcin Wojtas
2021-06-23 21:36 ` Andrew Lunn
2021-06-23 21:42 ` Vladimir Oltean
2021-06-21 17:30 ` [net-next: PATCH v3 2/6] net: mdiobus: Introduce fwnode_mdbiobus_register() Marcin Wojtas
2021-06-23 20:22 ` Andrew Lunn
2021-06-23 22:10 ` Marcin Wojtas
2021-06-24 11:10 ` Marcin Wojtas [this message]
2021-06-21 17:30 ` [net-next: PATCH v3 3/6] net/fsl: switch to fwnode_mdiobus_register Marcin Wojtas
2021-06-23 20:24 ` Andrew Lunn
2021-06-21 17:30 ` [net-next: PATCH v3 4/6] net: mvmdio: add ACPI support Marcin Wojtas
2021-06-23 20:28 ` Andrew Lunn
2021-06-23 21:58 ` Marcin Wojtas
2021-06-24 1:24 ` Andrew Lunn
2021-06-21 17:30 ` [net-next: PATCH v3 5/6] net: mvpp2: enable using phylink with ACPI Marcin Wojtas
2021-06-23 20:37 ` Andrew Lunn
2021-06-23 21:45 ` Marcin Wojtas
2021-06-24 1:17 ` Andrew Lunn
2021-06-21 17:30 ` [net-next: PATCH v3 6/6] net: mvpp2: remove unused 'has_phy' field Marcin Wojtas
2021-06-23 11:56 ` [net-next: PATCH v3 0/6] ACPI MDIO support for Marvell controllers Marcin Wojtas
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAPv3WKdSNZzvDS5-FNK4eTMfRt6xuk6xYJ6eQf0N01Q4OhRS9Q@mail.gmail.com \
--to=mw@semihalf.com \
--cc=Samer.El-Haj-Mahmoud@arm.com \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=gjb@semihalf.com \
--cc=jaz@semihalf.com \
--cc=jon@solid-run.com \
--cc=kuba@kernel.org \
--cc=lenb@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=netdev@vger.kernel.org \
--cc=rjw@rjwysocki.net \
--cc=sfr@canb.auug.org.au \
--cc=tn@semihalf.com \
--cc=upstream@semihalf.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).