linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net:phy: Fix "Link is Down" issue
@ 2021-11-24  6:10 Dylan Hung
  2021-11-24 10:05 ` Joel Stanley
  2021-11-24 23:30 ` Jakub Kicinski
  0 siblings, 2 replies; 8+ 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] 8+ messages in thread

* Re: [PATCH] net:phy: Fix "Link is Down" issue
  2021-11-24  6:10 [PATCH] net:phy: Fix "Link is Down" issue Dylan Hung
@ 2021-11-24 10:05 ` Joel Stanley
  2021-11-24 10:33   ` Dylan Hung
  2021-11-24 15:29   ` Andrew Lunn
  2021-11-24 23:30 ` Jakub Kicinski
  1 sibling, 2 replies; 8+ messages in thread
From: Joel Stanley @ 2021-11-24 10:05 UTC (permalink / raw)
  To: Dylan Hung
  Cc: Linux Kernel Mailing List, linux-aspeed, Linux ARM, Networking,
	Andrew Jeffery, Jakub Kicinski, David S . Miller, Russell King,
	hkallweit1, Andrew Lunn, BMC-SW

On Wed, 24 Nov 2021 at 06:11, Dylan Hung <dylan_hung@aspeedtech.com> 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.

> 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	[flat|nested] 8+ messages in thread

* RE: [PATCH] net:phy: Fix "Link is Down" issue
  2021-11-24 10:05 ` Joel Stanley
@ 2021-11-24 10:33   ` Dylan Hung
  2021-11-24 15:29   ` Andrew Lunn
  1 sibling, 0 replies; 8+ messages in thread
From: Dylan Hung @ 2021-11-24 10:33 UTC (permalink / raw)
  To: Joel Stanley
  Cc: Linux Kernel Mailing List, linux-aspeed, Linux ARM, Networking,
	Andrew Jeffery, Jakub Kicinski, David S . Miller, Russell King,
	hkallweit1, Andrew Lunn, BMC-SW

> -----Original Message-----
> From: Joel Stanley [mailto:joel@jms.id.au]
> Sent: 2021年11月24日 6:06 PM
> To: Dylan Hung <dylan_hung@aspeedtech.com>
> Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>; linux-aspeed
> <linux-aspeed@lists.ozlabs.org>; Linux ARM
> <linux-arm-kernel@lists.infradead.org>; Networking
> <netdev@vger.kernel.org>; Andrew Jeffery <andrew@aj.id.au>; Jakub Kicinski
> <kuba@kernel.org>; David S . Miller <davem@davemloft.net>; Russell King
> <linux@armlinux.org.uk>; hkallweit1@gmail.com; Andrew Lunn
> <andrew@lunn.ch>; BMC-SW <BMC-SW@aspeedtech.com>
> Subject: Re: [PATCH] net:phy: Fix "Link is Down" issue
> 
> On Wed, 24 Nov 2021 at 06:11, Dylan Hung <dylan_hung@aspeedtech.com>
> 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?
We will add this sequence into the datasheet, thank you.
> 
> 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")
I will change this in V2.
> 
> We should cc stable too.
I will change this in V2.
> 
> > 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	[flat|nested] 8+ messages in thread

* Re: [PATCH] net:phy: Fix "Link is Down" issue
  2021-11-24 10:05 ` Joel Stanley
  2021-11-24 10:33   ` Dylan Hung
@ 2021-11-24 15:29   ` Andrew Lunn
  2021-11-25  3:08     ` Dylan Hung
  1 sibling, 1 reply; 8+ messages in thread
From: Andrew Lunn @ 2021-11-24 15:29 UTC (permalink / raw)
  To: Joel Stanley
  Cc: Dylan Hung, Linux Kernel Mailing List, linux-aspeed, Linux ARM,
	Networking, Andrew Jeffery, Jakub Kicinski, David S . Miller,
	Russell King, hkallweit1, BMC-SW

> 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

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

* Re: [PATCH] net:phy: Fix "Link is Down" issue
  2021-11-24  6:10 [PATCH] net:phy: Fix "Link is Down" issue Dylan Hung
  2021-11-24 10:05 ` Joel Stanley
@ 2021-11-24 23:30 ` Jakub Kicinski
  2021-11-25  1:42   ` Dylan Hung
  1 sibling, 1 reply; 8+ messages in thread
From: Jakub Kicinski @ 2021-11-24 23:30 UTC (permalink / raw)
  To: Dylan Hung
  Cc: linux-kernel, linux-aspeed, linux-arm-kernel, netdev, andrew,
	joel, davem, linux, hkallweit1, andrew, BMC-SW

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:.

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

* RE: [PATCH] net:phy: Fix "Link is Down" issue
  2021-11-24 23:30 ` Jakub Kicinski
@ 2021-11-25  1:42   ` Dylan Hung
  0 siblings, 0 replies; 8+ messages in thread
From: Dylan Hung @ 2021-11-25  1:42 UTC (permalink / raw)
  To: Jakub Kicinski
  Cc: linux-kernel, linux-aspeed, linux-arm-kernel, netdev, andrew,
	joel, davem, linux, hkallweit1, andrew, BMC-SW

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

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

* RE: [PATCH] net:phy: Fix "Link is Down" issue
  2021-11-24 15:29   ` Andrew Lunn
@ 2021-11-25  3:08     ` Dylan Hung
  2021-11-25  3:18       ` Jakub Kicinski
  0 siblings, 1 reply; 8+ messages in thread
From: Dylan Hung @ 2021-11-25  3:08 UTC (permalink / raw)
  To: Andrew Lunn, Joel Stanley
  Cc: Linux Kernel Mailing List, linux-aspeed, Linux ARM, Networking,
	Andrew Jeffery, Jakub Kicinski, David S . Miller, Russell King,
	hkallweit1, BMC-SW

> -----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 <dylan_hung@aspeedtech.com>; Linux Kernel Mailing List
> <linux-kernel@vger.kernel.org>; linux-aspeed <linux-aspeed@lists.ozlabs.org>;
> Linux ARM <linux-arm-kernel@lists.infradead.org>; Networking
> <netdev@vger.kernel.org>; Andrew Jeffery <andrew@aj.id.au>; Jakub Kicinski
> <kuba@kernel.org>; David S . Miller <davem@davemloft.net>; Russell King
> <linux@armlinux.org.uk>; hkallweit1@gmail.com; BMC-SW
> <BMC-SW@aspeedtech.com>
> Subject: Re: [PATCH] net:phy: Fix "Link is Down" issue
> 
> > 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'?

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

* Re: [PATCH] net:phy: Fix "Link is Down" issue
  2021-11-25  3:08     ` Dylan Hung
@ 2021-11-25  3:18       ` Jakub Kicinski
  0 siblings, 0 replies; 8+ messages in thread
From: Jakub Kicinski @ 2021-11-25  3:18 UTC (permalink / raw)
  To: Dylan Hung
  Cc: Andrew Lunn, Joel Stanley, Linux Kernel Mailing List,
	linux-aspeed, Linux ARM, Networking, Andrew Jeffery,
	David S . Miller, Russell King, hkallweit1, BMC-SW

On Thu, 25 Nov 2021 03:08:22 +0000 Dylan Hung wrote:
> > > 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.

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

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

Thread overview: 8+ 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 10:05 ` Joel Stanley
2021-11-24 10:33   ` Dylan Hung
2021-11-24 15:29   ` Andrew Lunn
2021-11-25  3:08     ` Dylan Hung
2021-11-25  3:18       ` Jakub Kicinski
2021-11-24 23:30 ` Jakub Kicinski
2021-11-25  1:42   ` Dylan Hung

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).