All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next] net: dsa: felix: Don't restart PCS SGMII AN if not needed
@ 2020-01-16 18:09 Vladimir Oltean
  2020-01-17 12:18 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Vladimir Oltean @ 2020-01-16 18:09 UTC (permalink / raw)
  To: davem, netdev, linux
  Cc: andrew, f.fainelli, vivien.didelot, claudiu.manoil,
	Alex Marginean, Vladimir Oltean

From: Alex Marginean <alexandru.marginean@nxp.com>

Some PHYs like VSC8234 don't like it when AN restarts on their system side
and they restart line side AN too, going into an endless link up/down loop.
Don't restart PCS AN if link is up already.

Although in theory this feedback loop should be possible with the other
in-band AN modes too, for some reason it was not seen with the VSC8514
QSGMII and AQR412 USXGMII PHYs. So keep this logic only for SGMII where
the problem was found.

Fixes: bdeced75b13f ("net: dsa: felix: Add PCS operations for PHYLINK")
Suggested-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Signed-off-by: Alex Marginean <alexandru.marginean@nxp.com>
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
---
 drivers/net/dsa/ocelot/felix_vsc9959.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/drivers/net/dsa/ocelot/felix_vsc9959.c b/drivers/net/dsa/ocelot/felix_vsc9959.c
index 1e82b0d72058..2c812b481778 100644
--- a/drivers/net/dsa/ocelot/felix_vsc9959.c
+++ b/drivers/net/dsa/ocelot/felix_vsc9959.c
@@ -645,6 +645,27 @@ static void vsc9959_pcs_init_sgmii(struct phy_device *pcs,
 				   const struct phylink_link_state *state)
 {
 	if (link_an_mode == MLO_AN_INBAND) {
+		int bmsr, bmcr;
+
+		/* Some PHYs like VSC8234 don't like it when AN restarts on
+		 * their system  side and they restart line side AN too, going
+		 * into an endless link up/down loop.  Don't restart PCS AN if
+		 * link is up already.
+		 * We do check that AN is enabled just in case this is the 1st
+		 * call, PCS detects a carrier but AN is disabled from power on
+		 * or by boot loader.
+		 */
+		bmcr = phy_read(pcs, MII_BMCR);
+		if (bmcr < 0)
+			return;
+
+		bmsr = phy_read(pcs, MII_BMSR);
+		if (bmsr < 0)
+			return;
+
+		if ((bmcr & BMCR_ANENABLE) && (bmsr & BMSR_LSTATUS))
+			return;
+
 		/* SGMII spec requires tx_config_Reg[15:0] to be exactly 0x4001
 		 * for the MAC PCS in order to acknowledge the AN.
 		 */
-- 
2.17.1


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

* Re: [PATCH net-next] net: dsa: felix: Don't restart PCS SGMII AN if not needed
  2020-01-16 18:09 [PATCH net-next] net: dsa: felix: Don't restart PCS SGMII AN if not needed Vladimir Oltean
@ 2020-01-17 12:18 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2020-01-17 12:18 UTC (permalink / raw)
  To: olteanv
  Cc: netdev, linux, andrew, f.fainelli, vivien.didelot,
	claudiu.manoil, alexandru.marginean, vladimir.oltean

From: Vladimir Oltean <olteanv@gmail.com>
Date: Thu, 16 Jan 2020 20:09:59 +0200

> From: Alex Marginean <alexandru.marginean@nxp.com>
> 
> Some PHYs like VSC8234 don't like it when AN restarts on their system side
> and they restart line side AN too, going into an endless link up/down loop.
> Don't restart PCS AN if link is up already.
> 
> Although in theory this feedback loop should be possible with the other
> in-band AN modes too, for some reason it was not seen with the VSC8514
> QSGMII and AQR412 USXGMII PHYs. So keep this logic only for SGMII where
> the problem was found.
> 
> Fixes: bdeced75b13f ("net: dsa: felix: Add PCS operations for PHYLINK")
> Suggested-by: Vladimir Oltean <vladimir.oltean@nxp.com>
> Signed-off-by: Alex Marginean <alexandru.marginean@nxp.com>
> Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>

Applied.

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

end of thread, other threads:[~2020-01-19 11:31 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-16 18:09 [PATCH net-next] net: dsa: felix: Don't restart PCS SGMII AN if not needed Vladimir Oltean
2020-01-17 12:18 ` David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.