public inbox for netdev@vger.kernel.org 
 help / color / mirror / Atom feed
* [PATCH v1 1/1] net: phy: micrel: Add workaround for incomplete autonegotiation
@ 2023-12-26 14:19 Asmaa Mnebhi
  2023-12-27 22:19 ` Marek Mojík
                   ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: Asmaa Mnebhi @ 2023-12-26 14:19 UTC (permalink / raw)
  To: davem, linux, netdev; +Cc: Asmaa Mnebhi, davthompson

Very rarely, the KSZ9031 fails to complete autonegotiation although it was
initiated via phy_start(). As a result, the link stays down. Restarting
autonegotiation when in this state solves the issue.

Signed-off-by: Asmaa Mnebhi <asmaa@nvidia•com>
---
 drivers/net/phy/micrel.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c
index 08e3915001c3..de8140c5907f 100644
--- a/drivers/net/phy/micrel.c
+++ b/drivers/net/phy/micrel.c
@@ -1475,6 +1475,7 @@ static int ksz9031_get_features(struct phy_device *phydev)
 
 static int ksz9031_read_status(struct phy_device *phydev)
 {
+	u8 timeout = 10;
 	int err;
 	int regval;
 
@@ -1494,6 +1495,22 @@ static int ksz9031_read_status(struct phy_device *phydev)
 		return genphy_config_aneg(phydev);
 	}
 
+	/* KSZ9031's autonegotiation takes normally 4-5 seconds to complete.
+	 * Occasionally it fails to complete autonegotiation. The workaround is
+	 * to restart it.
+	 */
+        if (phydev->autoneg == AUTONEG_ENABLE) {
+		while (timeout) {
+			if (phy_aneg_done(phydev))
+				break;
+			mdelay(1000);
+			timeout--;
+		};
+
+		if (timeout == 0)
+			phy_restart_aneg(phydev);
+	}
+
 	return 0;
 }
 
-- 
2.30.1


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

end of thread, other threads:[~2024-01-24 22:18 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-26 14:19 [PATCH v1 1/1] net: phy: micrel: Add workaround for incomplete autonegotiation Asmaa Mnebhi
2023-12-27 22:19 ` Marek Mojík
2024-01-02 18:45 ` Russell King (Oracle)
2024-01-03  1:27   ` Andrew Lunn
2024-01-19 18:11     ` Asmaa Mnebhi
2024-01-19 19:44       ` Andrew Lunn
2024-01-19 19:56         ` Andrew Lunn
2024-01-19 20:18         ` Asmaa Mnebhi
2024-01-19 22:38           ` Andrew Lunn
2024-01-19 22:57             ` Asmaa Mnebhi
2024-01-24 22:18               ` Asmaa Mnebhi
2024-01-19 23:14 ` Florian Fainelli

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox