Skip to contentSkip to conversation

net: phy: marvell: add sleep time after enabling the loopback bit

PATCH Superseded Aminuddin Jamaluddin 3 participants 5 messages Nov 8, 2022 – Nov 11, 2022

Subsystems (4)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 net: phy: marvell: add sleep time after enabling the loopback bit

Sleep time is added to ensure the phy to be ready after loopback bit was set. This to prevent the phy loopback test from failing.

---
V1: https://patchwork.kernel.org/project/netdevbpf/patch/[email protected]/
---

Fixes 020a45aff119 ("net: phy: marvell: add Marvell specific PHY loopback")
Cc <[email protected]> # 5.15.x
---
 drivers/net/phy/marvell.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)
drivers/net/phy/marvell.c +9 -7
index a3e810705ce2..860610ba4d00 100644
@@ -2015,14 +2015,16 @@ static int m88e1510_loopback(struct phy_device *phydev, bool enable)
 		if (err < 0)
 			return err;
 
-		/* FIXME: Based on trial and error test, it seem 1G need to have
-		 * delay between soft reset and loopback enablement.
-		 */
-		if (phydev->speed == SPEED_1000)
-			msleep(1000);
+		err = phy_modify(phydev, MII_BMCR, BMCR_LOOPBACK,
+				 BMCR_LOOPBACK);
 
-		return phy_modify(phydev, MII_BMCR, BMCR_LOOPBACK,
-				  BMCR_LOOPBACK);
+		if (!err) {
+			/* It takes some time for PHY device to switch
+			 * into/out-of loopback mode.
+			 */
+			msleep(1000);
+		}
+		return err;
 	} else {
 		err = phy_modify(phydev, MII_BMCR, BMCR_LOOPBACK, 0);
 		if (err < 0)
Signature · 1 line
2.17.1
maintainer
#1 lore raw
Quoted 1 line · On Tue, 8 Nov 2022 15:40:05 +0800 Aminuddin Jamaluddin wrote:

Subject: [PATCH net-next v2] net: phy: marvell: add sleep time after enabling the loopback bit

Looks like v1 was tagged for net, why switch to net-next? It's either a fix or not, we don't do gray scales in netdev.

Quoted 6 lines

Sleep time is added to ensure the phy to be ready after loopback bit was set. This to prevent the phy loopback test from failing.

---
V1: https://patchwork.kernel.org/project/netdevbpf/patch/[email protected]/
---

git am will cut off at the first --- it finds, so the v1 link and all the tags below we'll be lost when the patch is applied. Please move this section after the tags.

Quoted 4 lines
Fixes 020a45aff119 ("net: phy: marvell: add Marvell specific PHY loopback")
Cc <[email protected]> # 5.15.x
#3 lore raw
In reply to Aminuddin Jamaluddin
Quoted 28 lines · Aminuddin Jamaluddin

Sleep time is added to ensure the phy to be ready after loopback bit was set. This to prevent the phy loopback test from failing.

---
V1: https://patchwork.kernel.org/project/netdevbpf/patch/[email protected]/
---

Fixes 020a45aff119 ("net: phy: marvell: add Marvell specific PHY loopback")
Cc <[email protected]> # 5.15.x
---
  drivers/net/phy/marvell.c | 16 +++++++++-------
  1 file changed, 9 insertions(+), 7 deletions(-)
drivers/net/phy/marvell.c +0 -5
index a3e810705ce2..860610ba4d00 100644
@@ -2015,14 +2015,16 @@ static int m88e1510_loopback(struct phy_device *phydev, bool enable)
  		if (err < 0)
  			return err;
 
-		/* FIXME: Based on trial and error test, it seem 1G need to have
-		 * delay between soft reset and loopback enablement.
-		 */
-		if (phydev->speed == SPEED_1000)
-			msleep(1000);

drivers/net/phy/marvell.c static int m88e1510_loopback(struct phy_device *phydev, bool enable) · line 2025

Quoted 10 lines
drivers/net/phy/marvell.c +7 -2
+		err = phy_modify(phydev, MII_BMCR, BMCR_LOOPBACK,
+				 BMCR_LOOPBACK);
 
-		return phy_modify(phydev, MII_BMCR, BMCR_LOOPBACK,
-				  BMCR_LOOPBACK);
+		if (!err) {
+			/* It takes some time for PHY device to switch
+			 * into/out-of loopback mode.
+			 */
+			msleep(1000);

Is not there a better indication than waiting a full second to ensure the PHY exited loopback?

Signature · 1 line
Florian
#4 lore raw
Quoted 57 lines

-----Original Message-----
From: Florian Fainelli <[email protected]>
Sent: Thursday, 10 November, 2022 11:54 AM
To: Jamaluddin, Aminuddin <[email protected]>; Andrew Lunn <[email protected]>; Heiner Kallweit <[email protected]>; Russell King <[email protected]>; David S . Miller <[email protected]>; Eric Dumazet <[email protected]>; Jakub Kicinski <[email protected]>; Paolo Abeni <[email protected]>; Ismail, Mohammad Athari <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; Tan, Tee Min <[email protected]>; Zulkifli, Muhammad Husaini <[email protected]>; Looi, Hong Aun <[email protected]>
Subject: Re: [PATCH net-next v2] net: phy: marvell: add sleep time after enabling the loopback bit

Quoted 6 lines · Aminuddin Jamaluddin

Sleep time is added to ensure the phy to be ready after loopback bit was set. This to prevent the phy loopback test from failing.

---
V1:

https://patchwork.kernel.org/project/netdevbpf/patch/20220825082238.11

drivers/net/phy/marvell.c static int m88e1510_loopback(struct

Quoted 18 lines

[email protected]/
---

Fixes 020a45aff119 ("net: phy: marvell: add Marvell specific PHY

loopback")
Cc: <[email protected]> # 5.15.x
Signed-off-by: Muhammad Husaini Zulkifli
<[email protected]>

---
  drivers/net/phy/marvell.c | 16 +++++++++-------
  1 file changed, 9 insertions(+), 7 deletions(-)
drivers/net/phy/marvell.c +0 -0
index a3e810705ce2..860610ba4d00 100644
@@ -2015,14 +2015,16 @@ static int m88e1510_loopback(struct

phy_device *phydev, bool enable)

drivers/net/phy/marvell.c static int m88e1510_loopback(struct phy_device *phydev, bool enable)

Quoted 4 lines
drivers/net/phy/marvell.c +0 -1
  		if (err < 0)
  			return err;
 
-		/* FIXME: Based on trial and error test, it seem 1G need to

have

Quoted 7 lines
drivers/net/phy/marvell.c +2 -4
-		 * delay between soft reset and loopback enablement.
-		 */
-		if (phydev->speed == SPEED_1000)
-			msleep(1000);
+		err = phy_modify(phydev, MII_BMCR, BMCR_LOOPBACK,
+				 BMCR_LOOPBACK);
 
Quoted 10 lines

drivers/net/phy/marvell.c static int m88e1510_loopback(struct phy_device *phydev, bool enable) · line 2025

Quoted 7 lines
drivers/net/phy/marvell.c +5 -2
-		return phy_modify(phydev, MII_BMCR, BMCR_LOOPBACK,
-				  BMCR_LOOPBACK);
+		if (!err) {
+			/* It takes some time for PHY device to switch
+			 * into/out-of loopback mode.
+			 */
+			msleep(1000);

Is not there a better indication than waiting a full second to ensure the PHY exited loopback?

Previously we implemented the link status check that waiting phy to be ready before the loopback bit being set in V1. But we removed it due to simpler behaviour as that can be achieve with this. And previous discussion with Marvell stated the delay timing was needed after loopback bit is set.

Quoted 1 line

--

Amin

#2 lore raw
In reply to Jakub Kicinski
Quoted 29 lines

-----Original Message-----
From: Jakub Kicinski <[email protected]>
Sent: Thursday, 10 November, 2022 10:42 AM
To: Jamaluddin, Aminuddin <[email protected]>
Cc: Andrew Lunn <[email protected]>; Heiner Kallweit <[email protected]>; Russell King <[email protected]>; David S . Miller <[email protected]>; Eric Dumazet <[email protected]>; Paolo Abeni <[email protected]>; Ismail, Mohammad Athari <[email protected]>; [email protected]; linux- [email protected]; [email protected]; Tan, Tee Min <[email protected]>; Zulkifli, Muhammad Husaini <[email protected]>; Looi, Hong Aun <[email protected]>
Subject: Re: [PATCH net-next v2] net: phy: marvell: add sleep time after enabling the loopback bit

Quoted 2 lines · On Tue, 8 Nov 2022 15:40:05 +0800 Aminuddin Jamaluddin wrote:

Subject: [PATCH net-next v2] net: phy: marvell: add sleep time after enabling the loopback bit

Looks like v1 was tagged for net, why switch to net-next? It's either a fix or not, we don't do gray scales in netdev.

Quoted 6 lines

Sleep time is added to ensure the phy to be ready after loopback bit was set. This to prevent the phy loopback test from failing.

---
V1:

Quoted 8 lines

https://patchwork.kernel.org/project/netdevbpf/patch/20220825082238.11

Quoted 2 lines

[email protected]/
---

git am will cut off at the first --- it finds, so the v1 link and all the tags below we'll be lost when the patch is applied. Please move this section after the tags.

Ok noted will correct this with V3

Quoted 6 lines
Quoted 6 lines
Fixes 020a45aff119 ("net: phy: marvell: add Marvell specific PHY

loopback")
Cc: <[email protected]> # 5.15.x
Signed-off-by: Muhammad Husaini Zulkifli
<[email protected]>

Amin