From: Maxime Chevallier <maxime.chevallier@bootlin.com>
To: Heiner Kallweit <hkallweit1@gmail.com>
Cc: davem@davemloft.net, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org, thomas.petazzoni@bootlin.com,
"Andrew Lunn" <andrew@lunn.ch>,
"Jakub Kicinski" <kuba@kernel.org>,
"Eric Dumazet" <edumazet@google.com>,
"Paolo Abeni" <pabeni@redhat.com>,
"Russell King" <linux@armlinux.org.uk>,
linux-arm-kernel@lists.infradead.org,
"Christophe Leroy" <christophe.leroy@csgroup.eu>,
"Herve Codina" <herve.codina@bootlin.com>,
"Florian Fainelli" <f.fainelli@gmail.com>,
"Vladimir Oltean" <vladimir.oltean@nxp.com>,
"Köry Maincent" <kory.maincent@bootlin.com>,
"Jesse Brandeburg" <jesse.brandeburg@intel.com>,
"Marek Behún" <kabel@kernel.org>,
"Piergiorgio Beruto" <piergiorgio.beruto@gmail.com>,
"Oleksij Rempel" <o.rempel@pengutronix.de>,
"Nicolò Veronese" <nicveronese@gmail.com>,
"Simon Horman" <horms@kernel.org>,
mwojtas@chromium.org, "Nathan Chancellor" <nathan@kernel.org>,
"Antoine Tenart" <atenart@kernel.org>
Subject: Re: [PATCH net-next] net: phy: phy_link_topology: Handle NULL topologies
Date: Fri, 12 Apr 2024 15:23:35 +0200 [thread overview]
Message-ID: <20240412152335.751a8dbb@device-28.home> (raw)
In-Reply-To: <c37482d9-f97b-4f9a-8a2d-efde1a654514@gmail.com>
Hello Heiner,
On Fri, 12 Apr 2024 15:07:46 +0200
Heiner Kallweit <hkallweit1@gmail.com> wrote:
> On 12.04.2024 12:46, Maxime Chevallier wrote:
> > In situations where phylib is a module, the topology can be NULL as it's
> > not initialized at netdev creation.
> >
>
> What we see here is a bigger drawback of IS_REACHABLE(). For phylib it's
> false from net core, but true from r8169 driver. So topo_create is a stub,
> but topo_add is not. IS_REACHABLE() hides dependencies.
>
> topo_create et al don't really use something from phylib.
> Therefore, could/should it be moved to net core?
That's a valid point, and a better solution indeed.
> At least for topo_create this would resolve the dependency.
>
> We could also add a config symbol and the PHY topology an optional
> extension of net core.
That could be a thing indeed. It could be selected by phylib then, I
don't see it being a user-controlled option, as this would make it very
confusing for users to only be able to see when there are mutiple PHYs
on the link when the relevant option is enabled (but I might be wrong).
Maxime
>
> > Allow passing a NULL topology pointer to phy_link_topo helpers.
> >
> > Signed-off-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
> > Closes: https://lore.kernel.org/netdev/2e11b89d-100f-49e7-9c9a-834cc0b82f97@gmail.com/
> > Closes: https://lore.kernel.org/netdev/20240409201553.GA4124869@dev-arch.thelio-3990X/
> > ---
> >
> > Hi,
> >
> > This patch fixes a commit that is in net-next, hence the net-next tag and the
> > lack of "Fixes" tag.
> >
> > Nathan, Heiner, can you confirm this solves what you're seeing ?
> >
> > I think we can improve on this solution by moving the topology init at
> > the first PHY insertion and clearing it at netdev destruction.
> >
> > Maxime
> >
> > drivers/net/phy/phy_link_topology.c | 10 +++++++++-
> > include/linux/phy_link_topology.h | 7 ++++++-
> > 2 files changed, 15 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/net/phy/phy_link_topology.c b/drivers/net/phy/phy_link_topology.c
> > index 985941c5c558..0f3973f07fac 100644
> > --- a/drivers/net/phy/phy_link_topology.c
> > +++ b/drivers/net/phy/phy_link_topology.c
> > @@ -42,6 +42,9 @@ int phy_link_topo_add_phy(struct phy_link_topology *topo,
> > struct phy_device_node *pdn;
> > int ret;
> >
> > + if (!topo)
> > + return 0;
> > +
> > pdn = kzalloc(sizeof(*pdn), GFP_KERNEL);
> > if (!pdn)
> > return -ENOMEM;
> > @@ -93,7 +96,12 @@ EXPORT_SYMBOL_GPL(phy_link_topo_add_phy);
> > void phy_link_topo_del_phy(struct phy_link_topology *topo,
> > struct phy_device *phy)
> > {
> > - struct phy_device_node *pdn = xa_erase(&topo->phys, phy->phyindex);
> > + struct phy_device_node *pdn;
> > +
> > + if (!topo)
> > + return;
> > +
> > + pdn = xa_erase(&topo->phys, phy->phyindex);
> >
> > /* We delete the PHY from the topology, however we don't re-set the
> > * phy->phyindex field. If the PHY isn't gone, we can re-assign it the
> > diff --git a/include/linux/phy_link_topology.h b/include/linux/phy_link_topology.h
> > index 6b79feb607e7..21ca78127d0f 100644
> > --- a/include/linux/phy_link_topology.h
> > +++ b/include/linux/phy_link_topology.h
> > @@ -40,7 +40,12 @@ struct phy_link_topology {
> > static inline struct phy_device *
> > phy_link_topo_get_phy(struct phy_link_topology *topo, u32 phyindex)
> > {
> > - struct phy_device_node *pdn = xa_load(&topo->phys, phyindex);
> > + struct phy_device_node *pdn;
> > +
> > + if (!topo)
> > + return NULL;
> > +
> > + pdn = xa_load(&topo->phys, phyindex);
> >
> > if (pdn)
> > return pdn->phy;
>
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2024-04-12 13:24 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-12 10:46 [PATCH net-next] net: phy: phy_link_topology: Handle NULL topologies Maxime Chevallier
2024-04-12 11:35 ` Heiner Kallweit
2024-04-12 13:03 ` Antoine Tenart
2024-04-12 13:16 ` Maxime Chevallier
2024-04-12 13:20 ` Antoine Tenart
2024-04-12 13:07 ` Heiner Kallweit
2024-04-12 13:23 ` Maxime Chevallier [this message]
2024-04-27 19:34 ` Heiner Kallweit
2024-04-29 11:55 ` Maxime Chevallier
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=20240412152335.751a8dbb@device-28.home \
--to=maxime.chevallier@bootlin.com \
--cc=andrew@lunn.ch \
--cc=atenart@kernel.org \
--cc=christophe.leroy@csgroup.eu \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=f.fainelli@gmail.com \
--cc=herve.codina@bootlin.com \
--cc=hkallweit1@gmail.com \
--cc=horms@kernel.org \
--cc=jesse.brandeburg@intel.com \
--cc=kabel@kernel.org \
--cc=kory.maincent@bootlin.com \
--cc=kuba@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=mwojtas@chromium.org \
--cc=nathan@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=nicveronese@gmail.com \
--cc=o.rempel@pengutronix.de \
--cc=pabeni@redhat.com \
--cc=piergiorgio.beruto@gmail.com \
--cc=thomas.petazzoni@bootlin.com \
--cc=vladimir.oltean@nxp.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).