* [PATCH net-next v2 0/2] Unify C22 and C45 error handling during bus enumeration
@ 2024-02-04 23:14 Andrew Lunn
2024-02-04 23:14 ` [PATCH net-next v2 1/2] net: phy: c45 scanning: Don't consider -ENODEV fatal Andrew Lunn
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Andrew Lunn @ 2024-02-04 23:14 UTC (permalink / raw)
To: Heiner Kallweit, Russell King, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Florian Fainelli, Vladimir Oltean
Cc: netdev, Tim Menninger, Andrew Lunn, Florian Fainelli
When enumerating an MDIO bus, an MDIO bus driver can return -ENODEV to
a C22 read transaction to indicate there is no device at that address
on the bus. Enumeration will then continue with the next address on
the bus.
Modify C45 enumeration so that it also accepts -ENODEV and moves to
the next address on the bus, rather than consider -ENODEV as a fatal
error.
Convert the mv88e6xxx driver to return -ENODEV rather than 0xffff on
read for families which do not support C45 bus transactions. This is
more efficient, since enumeration will scan multiple devices at one
address when 0xffff is returned, where as -EONDEV immediately jumps to
the next address on the bus.
Signed-off-by: Andrew Lunn <andrew@lunn.ch>
---
Changes in v2:
- C44 -> C45 Typo
- Only return -ENODEV for unimplemented C45 read.
- Link to v1: https://lore.kernel.org/r/20240203-unify-c22-c45-scan-error-handling-v1-0-8aa9fa3c4fca@lunn.ch
---
Andrew Lunn (2):
net: phy: c45 scanning: Don't consider -ENODEV fatal
net: dsa: mv88e6xxx: Return -ENODEV when C45 not supported
drivers/net/dsa/mv88e6xxx/chip.c | 2 +-
drivers/net/phy/phy_device.c | 8 ++++++--
2 files changed, 7 insertions(+), 3 deletions(-)
---
base-commit: d6aa8e0aa605a6baba08220e4a83fa2619a4c4d7
change-id: 20240203-unify-c22-c45-scan-error-handling-8012bb69bbf9
Best regards,
--
Andrew Lunn <andrew@lunn.ch>
^ permalink raw reply [flat|nested] 7+ messages in thread* [PATCH net-next v2 1/2] net: phy: c45 scanning: Don't consider -ENODEV fatal 2024-02-04 23:14 [PATCH net-next v2 0/2] Unify C22 and C45 error handling during bus enumeration Andrew Lunn @ 2024-02-04 23:14 ` Andrew Lunn 2026-04-07 18:15 ` Charles Perry 2024-02-04 23:14 ` [PATCH net-next v2 2/2] net: dsa: mv88e6xxx: Return -ENODEV when C45 not supported Andrew Lunn 2024-02-07 13:50 ` [PATCH net-next v2 0/2] Unify C22 and C45 error handling during bus enumeration patchwork-bot+netdevbpf 2 siblings, 1 reply; 7+ messages in thread From: Andrew Lunn @ 2024-02-04 23:14 UTC (permalink / raw) To: Heiner Kallweit, Russell King, David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, Florian Fainelli, Vladimir Oltean Cc: netdev, Tim Menninger, Andrew Lunn, Florian Fainelli When scanning the MDIO bus for C22 devices, the driver returning -ENODEV is not considered fatal, it just indicates the MDIO bus master knows there is no device at that address, maybe because of hardware limitation. Make the C45 scan code act on -ENODEV the same way, to make C22 and C45 more uniform. It is expected all reads for a given address will return -ENODEV, so within get_phy_c45_ids() only the first place a read occurs has been changed. Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com> Signed-off-by: Andrew Lunn <andrew@lunn.ch> --- drivers/net/phy/phy_device.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index 52828d1c64f7..962ab53c23ff 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -780,7 +780,7 @@ static int get_phy_c45_devs_in_pkg(struct mii_bus *bus, int addr, int dev_addr, * and identifiers in @c45_ids. * * Returns zero on success, %-EIO on bus access error, or %-ENODEV if - * the "devices in package" is invalid. + * the "devices in package" is invalid or no device responds. */ static int get_phy_c45_ids(struct mii_bus *bus, int addr, struct phy_c45_device_ids *c45_ids) @@ -803,7 +803,11 @@ static int get_phy_c45_ids(struct mii_bus *bus, int addr, */ ret = phy_c45_probe_present(bus, addr, i); if (ret < 0) - return -EIO; + /* returning -ENODEV doesn't stop bus + * scanning + */ + return (phy_reg == -EIO || + phy_reg == -ENODEV) ? -ENODEV : -EIO; if (!ret) continue; -- 2.43.0 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH net-next v2 1/2] net: phy: c45 scanning: Don't consider -ENODEV fatal 2024-02-04 23:14 ` [PATCH net-next v2 1/2] net: phy: c45 scanning: Don't consider -ENODEV fatal Andrew Lunn @ 2026-04-07 18:15 ` Charles Perry 2026-04-07 18:57 ` Andrew Lunn 0 siblings, 1 reply; 7+ messages in thread From: Charles Perry @ 2026-04-07 18:15 UTC (permalink / raw) To: Andrew Lunn Cc: Heiner Kallweit, Russell King, David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, Florian Fainelli, Vladimir Oltean, netdev, Tim Menninger, Florian Fainelli, charles.perry On Sun, Feb 04, 2024 at 05:14:14PM -0600, Andrew Lunn wrote: > When scanning the MDIO bus for C22 devices, the driver returning > -ENODEV is not considered fatal, it just indicates the MDIO bus master > knows there is no device at that address, maybe because of hardware > limitation. > > Make the C45 scan code act on -ENODEV the same way, to make C22 and > C45 more uniform. > > It is expected all reads for a given address will return -ENODEV, so > within get_phy_c45_ids() only the first place a read occurs has been > changed. > > Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com> > Signed-off-by: Andrew Lunn <andrew@lunn.ch> > --- > drivers/net/phy/phy_device.c | 8 ++++++-- > 1 file changed, 6 insertions(+), 2 deletions(-) > > diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c > index 52828d1c64f7..962ab53c23ff 100644 > --- a/drivers/net/phy/phy_device.c > +++ b/drivers/net/phy/phy_device.c > @@ -780,7 +780,7 @@ static int get_phy_c45_devs_in_pkg(struct mii_bus *bus, int addr, int dev_addr, > * and identifiers in @c45_ids. > * > * Returns zero on success, %-EIO on bus access error, or %-ENODEV if > - * the "devices in package" is invalid. > + * the "devices in package" is invalid or no device responds. > */ > static int get_phy_c45_ids(struct mii_bus *bus, int addr, > struct phy_c45_device_ids *c45_ids) > @@ -803,7 +803,11 @@ static int get_phy_c45_ids(struct mii_bus *bus, int addr, > */ > ret = phy_c45_probe_present(bus, addr, i); > if (ret < 0) > - return -EIO; > + /* returning -ENODEV doesn't stop bus > + * scanning > + */ > + return (phy_reg == -EIO || > + phy_reg == -ENODEV) ? -ENODEV : -EIO; Hello Andrew, Did you meant "ret" instead of "phy_reg" here? "phy_reg" doesn't make sense here because you would have already returned in the previous iteration of the loop. Thanks, Charles > > if (!ret) > continue; > > -- > 2.43.0 > > ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH net-next v2 1/2] net: phy: c45 scanning: Don't consider -ENODEV fatal 2026-04-07 18:15 ` Charles Perry @ 2026-04-07 18:57 ` Andrew Lunn 0 siblings, 0 replies; 7+ messages in thread From: Andrew Lunn @ 2026-04-07 18:57 UTC (permalink / raw) To: Charles Perry Cc: Heiner Kallweit, Russell King, David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, Florian Fainelli, Vladimir Oltean, netdev, Tim Menninger, Florian Fainelli On Tue, Apr 07, 2026 at 11:15:49AM -0700, Charles Perry wrote: > On Sun, Feb 04, 2024 at 05:14:14PM -0600, Andrew Lunn wrote: > > When scanning the MDIO bus for C22 devices, the driver returning > > -ENODEV is not considered fatal, it just indicates the MDIO bus master > > knows there is no device at that address, maybe because of hardware > > limitation. > > > > Make the C45 scan code act on -ENODEV the same way, to make C22 and > > C45 more uniform. > > > > It is expected all reads for a given address will return -ENODEV, so > > within get_phy_c45_ids() only the first place a read occurs has been > > changed. > > > > Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com> > > Signed-off-by: Andrew Lunn <andrew@lunn.ch> > > --- > > drivers/net/phy/phy_device.c | 8 ++++++-- > > 1 file changed, 6 insertions(+), 2 deletions(-) > > > > diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c > > index 52828d1c64f7..962ab53c23ff 100644 > > --- a/drivers/net/phy/phy_device.c > > +++ b/drivers/net/phy/phy_device.c > > @@ -780,7 +780,7 @@ static int get_phy_c45_devs_in_pkg(struct mii_bus *bus, int addr, int dev_addr, > > * and identifiers in @c45_ids. > > * > > * Returns zero on success, %-EIO on bus access error, or %-ENODEV if > > - * the "devices in package" is invalid. > > + * the "devices in package" is invalid or no device responds. > > */ > > static int get_phy_c45_ids(struct mii_bus *bus, int addr, > > struct phy_c45_device_ids *c45_ids) > > @@ -803,7 +803,11 @@ static int get_phy_c45_ids(struct mii_bus *bus, int addr, > > */ > > ret = phy_c45_probe_present(bus, addr, i); > > if (ret < 0) > > - return -EIO; > > + /* returning -ENODEV doesn't stop bus > > + * scanning > > + */ > > + return (phy_reg == -EIO || > > + phy_reg == -ENODEV) ? -ENODEV : -EIO; > > Hello Andrew, > > Did you meant "ret" instead of "phy_reg" here? > > "phy_reg" doesn't make sense here because you would have already returned > in the previous iteration of the loop. Hum, good catch. That makes no sense. Looks like i cut/pasted from the C22 code, and did not fixup the variable name. Andrew ^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH net-next v2 2/2] net: dsa: mv88e6xxx: Return -ENODEV when C45 not supported 2024-02-04 23:14 [PATCH net-next v2 0/2] Unify C22 and C45 error handling during bus enumeration Andrew Lunn 2024-02-04 23:14 ` [PATCH net-next v2 1/2] net: phy: c45 scanning: Don't consider -ENODEV fatal Andrew Lunn @ 2024-02-04 23:14 ` Andrew Lunn 2024-02-05 1:07 ` Florian Fainelli 2024-02-07 13:50 ` [PATCH net-next v2 0/2] Unify C22 and C45 error handling during bus enumeration patchwork-bot+netdevbpf 2 siblings, 1 reply; 7+ messages in thread From: Andrew Lunn @ 2024-02-04 23:14 UTC (permalink / raw) To: Heiner Kallweit, Russell King, David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, Florian Fainelli, Vladimir Oltean Cc: netdev, Tim Menninger, Andrew Lunn MDIO bus drivers can return -ENODEV when they know the bus does not have a device at the given address, e.g. because of hardware limitation. One such limitation is that the bus does not support C45 at all. This is more efficient than returning 0xffff, since it immediately stops the probing on the given address, where as further reads can be made when 0xffff is returned. Signed-off-by: Andrew Lunn <andrew@lunn.ch> --- drivers/net/dsa/mv88e6xxx/chip.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c index 6eec2e4aa031..9caecb4dfbfa 100644 --- a/drivers/net/dsa/mv88e6xxx/chip.c +++ b/drivers/net/dsa/mv88e6xxx/chip.c @@ -3659,7 +3659,7 @@ static int mv88e6xxx_mdio_read_c45(struct mii_bus *bus, int phy, int devad, int err; if (!chip->info->ops->phy_read_c45) - return 0xffff; + return -ENODEV; mv88e6xxx_reg_lock(chip); err = chip->info->ops->phy_read_c45(chip, bus, phy, devad, reg, &val); -- 2.43.0 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH net-next v2 2/2] net: dsa: mv88e6xxx: Return -ENODEV when C45 not supported 2024-02-04 23:14 ` [PATCH net-next v2 2/2] net: dsa: mv88e6xxx: Return -ENODEV when C45 not supported Andrew Lunn @ 2024-02-05 1:07 ` Florian Fainelli 0 siblings, 0 replies; 7+ messages in thread From: Florian Fainelli @ 2024-02-05 1:07 UTC (permalink / raw) To: Andrew Lunn, Heiner Kallweit, Russell King, David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, Vladimir Oltean Cc: netdev, Tim Menninger On 2/4/2024 3:14 PM, Andrew Lunn wrote: > MDIO bus drivers can return -ENODEV when they know the bus does not > have a device at the given address, e.g. because of hardware > limitation. One such limitation is that the bus does not support C45 > at all. This is more efficient than returning 0xffff, since it > immediately stops the probing on the given address, where as further > reads can be made when 0xffff is returned. > > Signed-off-by: Andrew Lunn <andrew@lunn.ch> Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com> -- Florian ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH net-next v2 0/2] Unify C22 and C45 error handling during bus enumeration 2024-02-04 23:14 [PATCH net-next v2 0/2] Unify C22 and C45 error handling during bus enumeration Andrew Lunn 2024-02-04 23:14 ` [PATCH net-next v2 1/2] net: phy: c45 scanning: Don't consider -ENODEV fatal Andrew Lunn 2024-02-04 23:14 ` [PATCH net-next v2 2/2] net: dsa: mv88e6xxx: Return -ENODEV when C45 not supported Andrew Lunn @ 2024-02-07 13:50 ` patchwork-bot+netdevbpf 2 siblings, 0 replies; 7+ messages in thread From: patchwork-bot+netdevbpf @ 2024-02-07 13:50 UTC (permalink / raw) To: Andrew Lunn Cc: hkallweit1, linux, davem, edumazet, kuba, pabeni, f.fainelli, olteanv, netdev, tmenninger, florian.fainelli Hello: This series was applied to netdev/net-next.git (main) by David S. Miller <davem@davemloft.net>: On Sun, 04 Feb 2024 17:14:13 -0600 you wrote: > When enumerating an MDIO bus, an MDIO bus driver can return -ENODEV to > a C22 read transaction to indicate there is no device at that address > on the bus. Enumeration will then continue with the next address on > the bus. > > Modify C45 enumeration so that it also accepts -ENODEV and moves to > the next address on the bus, rather than consider -ENODEV as a fatal > error. > > [...] Here is the summary with links: - [net-next,v2,1/2] net: phy: c45 scanning: Don't consider -ENODEV fatal https://git.kernel.org/netdev/net-next/c/17b447539408 - [net-next,v2,2/2] net: dsa: mv88e6xxx: Return -ENODEV when C45 not supported https://git.kernel.org/netdev/net-next/c/88b3934e3f31 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] 7+ messages in thread
end of thread, other threads:[~2026-04-07 18:57 UTC | newest] Thread overview: 7+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2024-02-04 23:14 [PATCH net-next v2 0/2] Unify C22 and C45 error handling during bus enumeration Andrew Lunn 2024-02-04 23:14 ` [PATCH net-next v2 1/2] net: phy: c45 scanning: Don't consider -ENODEV fatal Andrew Lunn 2026-04-07 18:15 ` Charles Perry 2026-04-07 18:57 ` Andrew Lunn 2024-02-04 23:14 ` [PATCH net-next v2 2/2] net: dsa: mv88e6xxx: Return -ENODEV when C45 not supported Andrew Lunn 2024-02-05 1:07 ` Florian Fainelli 2024-02-07 13:50 ` [PATCH net-next v2 0/2] Unify C22 and C45 error handling during bus enumeration 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