All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] net: phy: return EPROBE_DEFER if PHY is not accessible
@ 2023-03-17 12:16 arturo.buzarra
  2023-03-17 17:05 ` Florian Fainelli
                   ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: arturo.buzarra @ 2023-03-17 12:16 UTC (permalink / raw)
  To: netdev

From: Arturo Buzarra <arturo.buzarra@digi.com>

A PHY driver can dynamically determine the devices features, but in some
circunstances, the PHY is not yet ready and the read capabilities does not fail
but returns an undefined value, so incorrect capabilities are assumed and the
initialization process fails. This commit postpones the PHY probe to ensure the
PHY is accessible.

Signed-off-by: Arturo Buzarra <arturo.buzarra@digi.com>
---
 drivers/net/phy/phy_device.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index 1785f1cead97..f8c31e741936 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -2628,10 +2628,14 @@ int genphy_read_abilities(struct phy_device *phydev)
 			       phydev->supported);
 
 	val = phy_read(phydev, MII_BMSR);
 	if (val < 0)
 		return val;
+	if (val == 0x0000 || val == 0xffff) {
+		phydev_err(phydev, "PHY is not accessible\n");
+		return -EPROBE_DEFER;
+	}
 
 	linkmode_mod_bit(ETHTOOL_LINK_MODE_Autoneg_BIT, phydev->supported,
 			 val & BMSR_ANEGCAPABLE);
 
 	linkmode_mod_bit(ETHTOOL_LINK_MODE_100baseT_Full_BIT, phydev->supported,

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

end of thread, other threads:[~2023-03-30 12:01 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-17 12:16 [PATCH] net: phy: return EPROBE_DEFER if PHY is not accessible arturo.buzarra
2023-03-17 17:05 ` Florian Fainelli
2023-03-17 17:24 ` Andrew Lunn
2023-03-17 18:21 ` Heiner Kallweit
2023-03-20  9:45   ` Buzarra, Arturo
2023-03-20 10:12     ` Russell King (Oracle)
2023-03-20 12:00     ` Andrew Lunn
2023-03-23  8:02       ` Buzarra, Arturo
2023-03-23 14:19         ` Andrew Lunn
2023-03-23 14:35           ` Russell King (Oracle)
2023-03-30  7:46             ` Buzarra, Arturo
2023-03-30 12:01               ` Andrew Lunn

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.