* [PATCH net-next] net: stmmac: the XPCS obscures a potential "PHY not found" error
@ 2021-05-27 15:59 Vladimir Oltean
2021-05-28 22:30 ` patchwork-bot+netdevbpf
0 siblings, 1 reply; 2+ messages in thread
From: Vladimir Oltean @ 2021-05-27 15:59 UTC (permalink / raw)
To: Jakub Kicinski, David S. Miller, netdev
Cc: Giuseppe Cavallaro, Alexandre Torgue, Jose Abreu, Maxime Coquelin,
Heiner Kallweit, Russell King - ARM Linux admin, Florian Fainelli,
Andrew Lunn, Vladimir Oltean
From: Vladimir Oltean <vladimir.oltean@nxp.com>
stmmac_mdio_register() has logic to search for PHYs on the MDIO bus and
assign them IRQ lines, as well as to set priv->plat->phy_addr.
If no PHY is found, the "found" variable remains set to 0 and the
function errors out.
After the introduction of commit f213bbe8a9d6 ("net: stmmac: Integrate
it with DesignWare XPCS"), the "found" variable was immediately reused
for searching for a PCS on the same MDIO bus.
This can result in 2 types of potential problems (none of them seems to
be seen on the only Intel system that sets has_xpcs = true, otherwise it
would have been reported):
1. If a PCS is found but a PHY is not, then the code happily exits with
no error. One might say "yes, but this is not possible, because
of_mdiobus_register will probe a PHY for all MDIO addresses,
including for the XPCS, so if an XPCS exists, then a PHY certainly
exists too". Well, that is not true, see intel_mgbe_common_data():
/* Ensure mdio bus scan skips intel serdes and pcs-xpcs */
plat->mdio_bus_data->phy_mask = 1 << INTEL_MGBE_ADHOC_ADDR;
plat->mdio_bus_data->phy_mask |= 1 << INTEL_MGBE_XPCS_ADDR;
2. A PHY is found but an MDIO device with the XPCS PHY ID isn't, and in
that case, the error message will be "No PHY found". Confusing.
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
---
.../net/ethernet/stmicro/stmmac/stmmac_mdio.c | 21 +++++++++++++------
1 file changed, 15 insertions(+), 6 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c
index b750074f8f9c..e293bf1ce9f3 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c
@@ -503,6 +503,12 @@ int stmmac_mdio_register(struct net_device *ndev)
found = 1;
}
+ if (!found && !mdio_node) {
+ dev_warn(dev, "No PHY found\n");
+ err = -ENODEV;
+ goto no_phy_found;
+ }
+
/* Try to probe the XPCS by scanning all addresses. */
if (priv->hw->xpcs) {
struct mdio_xpcs_args *xpcs = &priv->hw->xpcs_args;
@@ -511,6 +517,7 @@ int stmmac_mdio_register(struct net_device *ndev)
xpcs->bus = new_bus;
+ found = 0;
for (addr = 0; addr < max_addr; addr++) {
xpcs->addr = addr;
@@ -520,13 +527,12 @@ int stmmac_mdio_register(struct net_device *ndev)
break;
}
}
- }
- if (!found && !mdio_node) {
- dev_warn(dev, "No PHY found\n");
- mdiobus_unregister(new_bus);
- mdiobus_free(new_bus);
- return -ENODEV;
+ if (!found && !mdio_node) {
+ dev_warn(dev, "No XPCS found\n");
+ err = -ENODEV;
+ goto no_xpcs_found;
+ }
}
bus_register_done:
@@ -534,6 +540,9 @@ int stmmac_mdio_register(struct net_device *ndev)
return 0;
+no_xpcs_found:
+no_phy_found:
+ mdiobus_unregister(new_bus);
bus_register_fail:
mdiobus_free(new_bus);
return err;
--
2.25.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH net-next] net: stmmac: the XPCS obscures a potential "PHY not found" error
2021-05-27 15:59 [PATCH net-next] net: stmmac: the XPCS obscures a potential "PHY not found" error Vladimir Oltean
@ 2021-05-28 22:30 ` patchwork-bot+netdevbpf
0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2021-05-28 22:30 UTC (permalink / raw)
To: Vladimir Oltean
Cc: kuba, davem, netdev, peppe.cavallaro, alexandre.torgue, joabreu,
mcoquelin.stm32, hkallweit1, linux, f.fainelli, andrew,
vladimir.oltean
Hello:
This patch was applied to netdev/net-next.git (refs/heads/master):
On Thu, 27 May 2021 18:59:59 +0300 you wrote:
> From: Vladimir Oltean <vladimir.oltean@nxp.com>
>
> stmmac_mdio_register() has logic to search for PHYs on the MDIO bus and
> assign them IRQ lines, as well as to set priv->plat->phy_addr.
>
> If no PHY is found, the "found" variable remains set to 0 and the
> function errors out.
>
> [...]
Here is the summary with links:
- [net-next] net: stmmac: the XPCS obscures a potential "PHY not found" error
https://git.kernel.org/netdev/net-next/c/4751d2aa321f
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-05-28 22:30 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-05-27 15:59 [PATCH net-next] net: stmmac: the XPCS obscures a potential "PHY not found" error Vladimir Oltean
2021-05-28 22:30 ` patchwork-bot+netdevbpf
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).