netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next 0/2] Unify C22 and C45 error handling during bus enumeration
@ 2024-02-03 20:52 Andrew Lunn
  2024-02-03 20:52 ` [PATCH net-next 1/2] net: phy: c45 scanning: Don't consider -ENODEV fatal Andrew Lunn
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Andrew Lunn @ 2024-02-03 20:52 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

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 C44 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>
---
Andrew Lunn (2):
      net: phy: c45 scanning: Don't consider -ENODEV fatal
      net: dsa: mv88e6xxx: Return -ENODEV when C22/C45 not supported

 drivers/net/dsa/mv88e6xxx/chip.c | 4 ++--
 drivers/net/phy/phy_device.c     | 8 ++++++--
 2 files changed, 8 insertions(+), 4 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] 6+ messages in thread

* [PATCH net-next 1/2] net: phy: c45 scanning: Don't consider -ENODEV fatal
  2024-02-03 20:52 [PATCH net-next 0/2] Unify C22 and C45 error handling during bus enumeration Andrew Lunn
@ 2024-02-03 20:52 ` Andrew Lunn
  2024-02-03 21:40   ` Florian Fainelli
  2024-02-03 20:52 ` [PATCH net-next 2/2] net: dsa: mv88e6xxx: Return -ENODEV when C22/C45 not supported Andrew Lunn
  2024-02-03 21:28 ` [PATCH net-next 0/2] Unify C22 and C45 error handling during bus enumeration Russell King (Oracle)
  2 siblings, 1 reply; 6+ messages in thread
From: Andrew Lunn @ 2024-02-03 20:52 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

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.

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] 6+ messages in thread

* [PATCH net-next 2/2] net: dsa: mv88e6xxx: Return -ENODEV when C22/C45 not supported
  2024-02-03 20:52 [PATCH net-next 0/2] Unify C22 and C45 error handling during bus enumeration Andrew Lunn
  2024-02-03 20:52 ` [PATCH net-next 1/2] net: phy: c45 scanning: Don't consider -ENODEV fatal Andrew Lunn
@ 2024-02-03 20:52 ` Andrew Lunn
  2024-02-03 21:07   ` Florian Fainelli
  2024-02-03 21:28 ` [PATCH net-next 0/2] Unify C22 and C45 error handling during bus enumeration Russell King (Oracle)
  2 siblings, 1 reply; 6+ messages in thread
From: Andrew Lunn @ 2024-02-03 20:52 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 C22
or 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 | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c
index 6eec2e4aa031..ce4e4bdf475d 100644
--- a/drivers/net/dsa/mv88e6xxx/chip.c
+++ b/drivers/net/dsa/mv88e6xxx/chip.c
@@ -3633,7 +3633,7 @@ static int mv88e6xxx_mdio_read(struct mii_bus *bus, int phy, int reg)
 	int err;
 
 	if (!chip->info->ops->phy_read)
-		return -EOPNOTSUPP;
+		return -ENODEV;
 
 	mv88e6xxx_reg_lock(chip);
 	err = chip->info->ops->phy_read(chip, bus, phy, reg, &val);
@@ -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] 6+ messages in thread

* Re: [PATCH net-next 2/2] net: dsa: mv88e6xxx: Return -ENODEV when C22/C45 not supported
  2024-02-03 20:52 ` [PATCH net-next 2/2] net: dsa: mv88e6xxx: Return -ENODEV when C22/C45 not supported Andrew Lunn
@ 2024-02-03 21:07   ` Florian Fainelli
  0 siblings, 0 replies; 6+ messages in thread
From: Florian Fainelli @ 2024-02-03 21: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/3/2024 12:52 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 C22
> or 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 | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c
> index 6eec2e4aa031..ce4e4bdf475d 100644
> --- a/drivers/net/dsa/mv88e6xxx/chip.c
> +++ b/drivers/net/dsa/mv88e6xxx/chip.c
> @@ -3633,7 +3633,7 @@ static int mv88e6xxx_mdio_read(struct mii_bus *bus, int phy, int reg)
>   	int err;
>   
>   	if (!chip->info->ops->phy_read)
> -		return -EOPNOTSUPP;
> +		return -ENODEV;

Still not sure this is the right way to do do it here.

>   
>   	mv88e6xxx_reg_lock(chip);
>   	err = chip->info->ops->phy_read(chip, bus, phy, reg, &val);
> @@ -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;

Whereas here it makes sense to me to switch to -ENODEV.
-- 
Florian

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH net-next 0/2] Unify C22 and C45 error handling during bus enumeration
  2024-02-03 20:52 [PATCH net-next 0/2] Unify C22 and C45 error handling during bus enumeration Andrew Lunn
  2024-02-03 20:52 ` [PATCH net-next 1/2] net: phy: c45 scanning: Don't consider -ENODEV fatal Andrew Lunn
  2024-02-03 20:52 ` [PATCH net-next 2/2] net: dsa: mv88e6xxx: Return -ENODEV when C22/C45 not supported Andrew Lunn
@ 2024-02-03 21:28 ` Russell King (Oracle)
  2 siblings, 0 replies; 6+ messages in thread
From: Russell King (Oracle) @ 2024-02-03 21:28 UTC (permalink / raw)
  To: Andrew Lunn
  Cc: Heiner Kallweit, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Florian Fainelli, Vladimir Oltean, netdev,
	Tim Menninger

On Sat, Feb 03, 2024 at 02:52:47PM -0600, Andrew Lunn 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 C44 enumeration so that it also accepts -ENODEV and moves to

C45

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH net-next 1/2] net: phy: c45 scanning: Don't consider -ENODEV fatal
  2024-02-03 20:52 ` [PATCH net-next 1/2] net: phy: c45 scanning: Don't consider -ENODEV fatal Andrew Lunn
@ 2024-02-03 21:40   ` Florian Fainelli
  0 siblings, 0 replies; 6+ messages in thread
From: Florian Fainelli @ 2024-02-03 21:40 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/3/2024 12:52 PM, 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.
> 
> Signed-off-by: Andrew Lunn <andrew@lunn.ch>

Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
-- 
Florian

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-02-03 21:40 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-03 20:52 [PATCH net-next 0/2] Unify C22 and C45 error handling during bus enumeration Andrew Lunn
2024-02-03 20:52 ` [PATCH net-next 1/2] net: phy: c45 scanning: Don't consider -ENODEV fatal Andrew Lunn
2024-02-03 21:40   ` Florian Fainelli
2024-02-03 20:52 ` [PATCH net-next 2/2] net: dsa: mv88e6xxx: Return -ENODEV when C22/C45 not supported Andrew Lunn
2024-02-03 21:07   ` Florian Fainelli
2024-02-03 21:28 ` [PATCH net-next 0/2] Unify C22 and C45 error handling during bus enumeration Russell King (Oracle)

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).