Skip to contentSkip to conversation

net:phy: Fix "Link is Down" issue

PATCH In review Dylan Hung 4 participants 9 messages Nov 24, 2021 – Nov 25, 2021

Subsystems (4)
lore
Share & tools
lore

Dylan Hung

author
#0 lore raw

PATCH 1/1 net:phy: 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 a9770eac511a ("net: mdio: Move MDIO drivers into a new subdirectory")
---
 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
maintainer Reviewed-by on v1 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

I consulted the datasheet and it doesn't mention this. Perhaps something to be added?

Quoted 2 lines
Fixes a9770eac511a ("net: mdio: Move MDIO drivers into a new subdirectory")

I think this should be:

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

We should cc stable too.

Quoted 26 lines
---
 drivers/net/mdio/mdio-aspeed.c | 7 +++++++
 1 file changed, 7 insertions(+)
drivers/net/mdio/mdio-aspeed.c +7 -1
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,
--

2.25.1

author
#2 lore raw
Quoted 26 lines

-----Original Message-----
From: Joel Stanley [mailto:joel at jms.id.au]
Sent: 2021?11?24? 6:06 PM
To: Dylan Hung <[email protected]>
Cc: Linux Kernel Mailing List <[email protected]>; linux-aspeed <[email protected]>; Linux ARM <[email protected]>; Networking <[email protected]>; Andrew Jeffery <[email protected]>; Jakub Kicinski <[email protected]>; David S . Miller <[email protected]>; Russell King <[email protected]>; hkallweit1 at gmail.com; Andrew Lunn <[email protected]>; BMC-SW <[email protected]>
Subject: Re: [PATCH] net:phy: Fix "Link is Down" issue

Quoted 10 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 2 lines

I consulted the datasheet and it doesn't mention this. Perhaps something to be added?

We will add this sequence into the datasheet, thank you.

Quoted 10 lines
Quoted 3 lines
Fixes a9770eac511a ("net: mdio: Move MDIO drivers into a new

subdirectory")

I think this should be:

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

I will change this in V2.

Quoted 2 lines

We should cc stable too.

I will change this in V2.

Quoted 29 lines
Quoted 29 lines
---
 drivers/net/mdio/mdio-aspeed.c | 7 +++++++
 1 file changed, 7 insertions(+)
(quoted diff) +0 -0

b/drivers/net/mdio/mdio-aspeed.c index cad820568f75..966c3b4ad59d 100644

drivers/net/mdio/mdio-aspeed.c +7 -0
@@ -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

maintainer
#6 lore raw
In reply to Dylan Hung
Quoted 1 line · On Wed, 24 Nov 2021 14:10:57 +0800 Dylan Hung wrote:

Subject: [PATCH] net:phy: Fix "Link is Down" issue

Since there will be v2, please also add a space between net: and phy:.

author
#7 lore raw
Quoted 11 lines

-----Original Message-----
From: Jakub Kicinski [mailto:kuba at kernel.org]
Sent: 2021?11?25? 7:31 AM
To: Dylan Hung <[email protected]>
Cc: linux-kernel at vger.kernel.org; linux-aspeed at lists.ozlabs.org; linux-arm-kernel at lists.infradead.org; netdev at vger.kernel.org; andrew at aj.id.au; joel at jms.id.au; davem at davemloft.net; linux at armlinux.org.uk; hkallweit1 at gmail.com; andrew at lunn.ch; BMC-SW <[email protected]>
Subject: Re: [PATCH] net:phy: Fix "Link is Down" issue

Quoted 4 lines
Quoted 1 line · On Wed, 24 Nov 2021 14:10:57 +0800 Dylan Hung wrote:

Subject: [PATCH] net:phy: Fix "Link is Down" issue

Since there will be v2, please also add a space between net: and phy:.

Should I use "net: mdio: " instead of "net: phy: "? Since this file was moved from net/phy to net/mdio by commit a9770eac511a.

maintainer
#8 lore raw

PATCH 1/1 net:phy: Fix "Link is Down" issue

Quoted 11 lines · On Thu, 25 Nov 2021 01:42:08 +0000 Dylan Hung wrote:
Quoted 11 lines

-----Original Message-----
From: Jakub Kicinski [mailto:kuba at kernel.org]
Sent: 2021?11?25? 7:31 AM
To: Dylan Hung <[email protected]>
Cc: linux-kernel at vger.kernel.org; linux-aspeed at lists.ozlabs.org; linux-arm-kernel at lists.infradead.org; netdev at vger.kernel.org; andrew at aj.id.au; joel at jms.id.au; davem at davemloft.net; linux at armlinux.org.uk; hkallweit1 at gmail.com; andrew at lunn.ch; BMC-SW <[email protected]>
Subject: Re: [PATCH] net:phy: Fix "Link is Down" issue

Quoted 6 lines
Quoted 4 lines · On Wed, 24 Nov 2021 14:10:57 +0800 Dylan Hung wrote:
Quoted 1 line

Subject: [PATCH] net:phy: Fix "Link is Down" issue

Since there will be v2, please also add a space between net: and phy:.

Should I use "net: mdio: " instead of "net: phy: "? Since this file was moved from net/phy to net/mdio by commit a9770eac511a.

Since you asked, I'd go for mdio: aspeed:, without the net part.

author
#4 lore raw
In reply to Andrew Lunn
Quoted 13 lines

-----Original Message-----
From: Andrew Lunn [mailto:andrew at lunn.ch]
Sent: 2021?11?24? 11:30 PM
To: Joel Stanley <[email protected]>
Cc: Dylan Hung <[email protected]>; Linux Kernel Mailing List <[email protected]>; linux-aspeed <[email protected]>; Linux ARM <[email protected]>; Networking <[email protected]>; Andrew Jeffery <[email protected]>; Jakub Kicinski <[email protected]>; David S . Miller <[email protected]>; Russell King <[email protected]>; hkallweit1 at gmail.com; BMC-SW <[email protected]>
Subject: Re: [PATCH] net:phy: Fix "Link is Down" issue

Quoted 6 lines
Quoted 1 line

We should cc stable too.

https://www.kernel.org/doc/html/v5.12/networking/netdev-FAQ.html#how-do-
i-indicate-which-tree-net-vs-net-next-my-patch-should-be-in

Andrew

Sorry, I got this mail after I sent v2 out. Should I prepare patch v3 with --subject-prefix='PATCH net'?

maintainer
#5 lore raw
Quoted 7 lines · On Thu, 25 Nov 2021 03:08:22 +0000 Dylan Hung wrote:
Quoted 4 lines
Quoted 1 line

We should cc stable too.

https://www.kernel.org/doc/html/v5.12/networking/netdev-FAQ.html#how-do-
i-indicate-which-tree-net-vs-net-next-my-patch-should-be-in

Sorry, I got this mail after I sent v2 out. Should I prepare patch v3 with --subject-prefix='PATCH net'?

That's leave it be now, but please keep this in mind in the future.