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 <redacted>
---
drivers/net/mdio/mdio-aspeed.c | 7 +++++++
1 file changed, 7 insertions(+)
@@ -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)+returnrc;+rc=readl_poll_timeout(ctx->base+ASPEED_MDIO_DATA,data,data&ASPEED_MDIO_DATA_IDLE,ASPEED_MDIO_INTERVAL_US,
From: Joel Stanley <joel@jms.id.au> Date: 2021-11-24 10:06:01
On Wed, 24 Nov 2021 at 06:11, Dylan Hung [off-list ref] 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
I consulted the datasheet and it doesn't mention this. Perhaps
something to be added?
Reviewed-by: Joel Stanley <joel@jms.id.au>
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.
@@ -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)+returnrc;+rc=readl_poll_timeout(ctx->base+ASPEED_MDIO_DATA,data,data&ASPEED_MDIO_DATA_IDLE,ASPEED_MDIO_INTERVAL_US,--
-----Original Message-----
From: Joel Stanley [mailto:joel@jms.id.au]
Sent: 2021年11月24日 6:06 PM
To: Dylan Hung <redacted>
Cc: Linux Kernel Mailing List <redacted>; linux-aspeed
[off-list ref]; Linux ARM
[off-list ref]; Networking
[off-list ref]; Andrew Jeffery [off-list ref]; Jakub Kicinski
[off-list ref]; David S . Miller [off-list ref]; Russell King
[off-list ref]; hkallweit1@gmail.com; Andrew Lunn
[off-list ref]; BMC-SW [off-list ref]
Subject: Re: [PATCH] net:phy: Fix "Link is Down" issue
On Wed, 24 Nov 2021 at 06:11, Dylan Hung [off-list ref]
wrote:
quoted
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?
We will add this sequence into the datasheet, thank you.
Reviewed-by: Joel Stanley <joel@jms.id.au>
quoted
Fixes: a9770eac511a ("net: mdio: Move MDIO drivers into a new
subdirectory")
I think this should be:
Fixes: f160e99462c6 ("net: phy: Add mdio-aspeed")
-----Original Message-----
From: Andrew Lunn [mailto:andrew@lunn.ch]
Sent: 2021年11月24日 11:30 PM
To: Joel Stanley <joel@jms.id.au>
Cc: Dylan Hung <redacted>; Linux Kernel Mailing List
[off-list ref]; linux-aspeed [off-list ref];
Linux ARM [off-list ref]; Networking
[off-list ref]; Andrew Jeffery [off-list ref]; Jakub Kicinski
[off-list ref]; David S . Miller [off-list ref]; Russell King
[off-list ref]; hkallweit1@gmail.com; BMC-SW
[off-list ref]
Subject: Re: [PATCH] net:phy: Fix "Link is Down" issue