Skip to contentSkip to conversation

mdio: aspeed: Fix "Link is Down" issue

PATCH Applied Dylan Hung 5 participants 5 messages Nov 25, 2021

Subsystems (5)
lore
Share & tools
lore

Dylan Hung

author
#0 lore raw

PATCH v2 1/1 mdio: aspeed: Fix "Link is Down" issue

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 f160e99462c6 ("net: phy: Add mdio-aspeed")
Cc stable at vger.kernel.org

---
v2: revise commit message

 drivers/net/mdio/mdio-aspeed.c | 7 +++++++
 1 file changed, 7 insertions(+)
drivers/net/mdio/mdio-aspeed.c +7 -0
index cad820568f75..966c3b4ad59d 100644
@@ -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,
Signature · 1 line
2.25.1
Acked-by on v2 1/1
#1 lore raw
Quoted 11 lines · Dylan Hung

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

Quoted 4 lines
Fixes f160e99462c6 ("net: phy: Add mdio-aspeed")

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

maintainer Reviewed-by on v2 1/1
#2 lore raw
In reply to Dylan Hung
Quoted 11 lines · Dylan Hung

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

Quoted 4 lines
Fixes f160e99462c6 ("net: phy: Add mdio-aspeed")
Cc stable at vger.kernel.org

Andrew

reviewer Reviewed-by on v2 1/1
#3 lore raw
In reply to Dylan Hung
Quoted 11 lines · Dylan Hung

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

Quoted 4 lines
Fixes f160e99462c6 ("net: phy: Add mdio-aspeed")
Cc stable at vger.kernel.org

Thanks.

Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!
#4 lore raw
In reply to Dylan Hung
This patch was applied to netdev/net.git (master) by Jakub Kicinski <[email protected]>:

Hello:

This patch was applied to netdev/net.git (master)
by Jakub Kicinski <[email protected]>:

Quoted 11 lines · On Thu, 25 Nov 2021 10:44:32 +0800 you wrote:

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

Quoted 1 line

[...]

Here is the summary with links:
- [v2] mdio: aspeed: Fix "Link is Down" issue

    https://git.kernel.org/netdev/net/c/9dbe33cf371b

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html