All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] net:phy: Fix "Link is Down" issue
@ 2021-11-24  6:10 ` Dylan Hung
  0 siblings, 0 replies; 16+ messages in thread
From: Dylan Hung @ 2021-11-24  6:10 UTC (permalink / raw)
  To: linux-kernel, linux-aspeed, linux-arm-kernel, netdev, andrew,
	joel, kuba, davem, linux, hkallweit1, andrew
  Cc: BMC-SW

The issue happened randomly in runtime.  The message "Link is Down" is
popped but soon it recovered to "Link is Up".

The "Link is Down" results from the incorrect read data for reading the
PHY register via MDIO bus.  The correct sequence for reading the data
shall be:
1. fire the command
2. wait for command done (this step was missing)
3. wait for data idle
4. read data from data register

Fixes: a9770eac511a ("net: mdio: Move MDIO drivers into a new subdirectory")
Signed-off-by: Dylan Hung <dylan_hung@aspeedtech.com>
---
 drivers/net/mdio/mdio-aspeed.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/net/mdio/mdio-aspeed.c b/drivers/net/mdio/mdio-aspeed.c
index cad820568f75..966c3b4ad59d 100644
--- a/drivers/net/mdio/mdio-aspeed.c
+++ b/drivers/net/mdio/mdio-aspeed.c
@@ -61,6 +61,13 @@ static int aspeed_mdio_read(struct mii_bus *bus, int addr, int regnum)
 
 	iowrite32(ctrl, ctx->base + ASPEED_MDIO_CTRL);
 
+	rc = readl_poll_timeout(ctx->base + ASPEED_MDIO_CTRL, ctrl,
+				!(ctrl & ASPEED_MDIO_CTRL_FIRE),
+				ASPEED_MDIO_INTERVAL_US,
+				ASPEED_MDIO_TIMEOUT_US);
+	if (rc < 0)
+		return rc;
+
 	rc = readl_poll_timeout(ctx->base + ASPEED_MDIO_DATA, data,
 				data & ASPEED_MDIO_DATA_IDLE,
 				ASPEED_MDIO_INTERVAL_US,
-- 
2.25.1


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

end of thread, other threads:[~2021-11-25  3:25 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-24  6:10 [PATCH] net:phy: Fix "Link is Down" issue Dylan Hung
2021-11-24  6:10 ` Dylan Hung
2021-11-24 10:05 ` Joel Stanley
2021-11-24 10:05   ` Joel Stanley
2021-11-24 10:33   ` Dylan Hung
2021-11-24 10:33     ` Dylan Hung
2021-11-24 15:29   ` Andrew Lunn
2021-11-24 15:29     ` Andrew Lunn
2021-11-25  3:08     ` Dylan Hung
2021-11-25  3:08       ` Dylan Hung
2021-11-25  3:18       ` Jakub Kicinski
2021-11-25  3:18         ` Jakub Kicinski
2021-11-24 23:30 ` Jakub Kicinski
2021-11-24 23:30   ` Jakub Kicinski
2021-11-25  1:42   ` Dylan Hung
2021-11-25  1:42     ` Dylan Hung

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.