Unify C22 and C45 error handling during bus enumeration
Subsystems (5)
Andrew Lunn
maintainerv2 cover Unify C22 and C45 error handling during bus enumeration
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.
---
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,
Signature · 1 line
Andrew Lunn <[email protected]>
Andrew Lunn
maintainerPATCH v2 1/2 net: phy: c45 scanning: Don't consider -ENODEV fatal
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.
--- drivers/net/phy/phy_device.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/net/phy/phy_device.c +6 -2
@@ -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 ;
Signature · 1 line
2.43.0
Re: [PATCH net-next v2 1/2] net: phy: c45 scanning: Don't consider -ENODEV fatal
Quoted 32 lines · Andrew Lunn
When scanning the MDIO bus for C22 devices, the driver returning
-ENODEVis 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
-ENODEVthe same way, to make C22 and C45 more uniform.It is expected all reads for a given address will return
-ENODEV, so withinget_phy_c45_ids()only the first place a read occurs has been changed.Reviewed-by Florian Fainelli <[email protected]>Signed-off-by Andrew Lunn <[email protected]>--- drivers/net/phy/phy_device.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)drivers/net/phy/phy_device.c +1
-1@@ -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)
drivers/net/phy/phy_device.c static int get_phy_c45_ids(struct mii_bus *bus, int addr, · line 810
Quoted 9 lines
drivers/net/phy/phy_device.c +5
-1@@ -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
Quoted 8 lines
drivers/net/phy/phy_device.c +0
-0if (!ret)continue ;Signature · 1 line
2.43.0
Andrew Lunn
maintainerRe: [PATCH net-next v2 1/2] net: phy: c45 scanning: Don't consider -ENODEV fatal
Quoted 45 lines · Charles Perry
Quoted 32 lines · Andrew Lunn
When scanning the MDIO bus for C22 devices, the driver returning
-ENODEVis 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
-ENODEVthe same way, to make C22 and C45 more uniform.It is expected all reads for a given address will return
-ENODEV, so withinget_phy_c45_ids()only the first place a read occurs has been changed.Reviewed-by Florian Fainelli <[email protected]>Signed-off-by Andrew Lunn <[email protected]>--- drivers/net/phy/phy_device.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)drivers/net/phy/phy_device.c +1
-1@@ -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)drivers/net/phy/phy_device.c static int get_phy_c45_ids(struct mii_bus *bus, int addr, · line 810
Quoted 9 lines
drivers/net/phy/phy_device.c +5
-1@@ -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,
Quoted 4 lines
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
Andrew Lunn
maintainerPATCH v2 2/2 net: dsa: mv88e6xxx: Return -ENODEV when C45 not supported
In reply to Andrew LunnMDIO 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.
--- drivers/net/dsa/mv88e6xxx/chip.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/dsa/mv88e6xxx/chip.c +1 -1
@@ -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);
Signature · 1 line
2.43.0
Re: [PATCH net-next v2 2/2] net: dsa: mv88e6xxx: Return -ENODEV when C45 not supported
Quoted 8 lines · Andrew Lunn
MDIO bus drivers can return
-ENODEVwhen 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 returning0xffff, since it immediately stops the probing on the given address, where as further reads can be made when0xffffis returned.Signed-off-by Andrew Lunn <[email protected]>
Signature · 1 line
Florian
This series was applied to netdev/net-next.git (main) by David S. Miller <[email protected]>:
Hello:
This series was applied to netdev/net-next.git (main) by David S. Miller <[email protected]>:
Quoted 10 lines · On Sun, 04 Feb 2024 17:14:13 -0600 you wrote:
When enumerating an MDIO bus, an MDIO bus driver can return
-ENODEVto 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
-ENODEVand moves to the next address on the bus, rather than consider-ENODEVas 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!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html