]> git.proxmox.com Git - mirror_ubuntu-disco-kernel.git/commitdiff
net: marvell: mvpp2: fix stuck in-band SGMII negotiation
authorRussell King <rmk+kernel@armlinux.org.uk>
Fri, 8 Feb 2019 15:35:43 +0000 (15:35 +0000)
committerStefan Bader <stefan.bader@canonical.com>
Tue, 14 May 2019 18:55:24 +0000 (20:55 +0200)
BugLink: https://bugs.launchpad.net/bugs/1828410
[ Upstream commit 316734fdcf70900a83065360cff11a5826919067 ]

It appears that the mvpp22 can get stuck with SGMII negotiation.  The
symptoms are that in-band negotiation never completes and the partner
(eg, PHY) never reports SGMII link up, or if it supports negotiation
bypass, goes into negotiation bypass mode (which will happen when the
PHY sees that the MAC is alive but gets no response.)

Triggering the PHY end of the link to re-negotiate results in the
bypass bit clearing on the PHY, and then re-setting - indicating that
the problem is at the mvpp22 GMAC end.

Asserting the GMAC reset and de-asserting it resolves the issue.
Arrange to assert the GMAC reset at probe time, and deassert it only
after we have configured the GMAC for the appropriate mode.  This
resolves the issue.

Tested-by: Sven Auhagen <sven.auhagen@voleatech.de>
Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c

index 16066c2d5b3a23d5c5d784658edd506563583768..931beac3359d1854ff4d469ec8b18b0a698311e5 100644 (file)
@@ -1380,13 +1380,9 @@ static void mvpp2_port_reset(struct mvpp2_port *port)
        for (i = 0; i < ARRAY_SIZE(mvpp2_ethtool_regs); i++)
                mvpp2_read_count(port, &mvpp2_ethtool_regs[i]);
 
-       val = readl(port->base + MVPP2_GMAC_CTRL_2_REG) &
-                   ~MVPP2_GMAC_PORT_RESET_MASK;
+       val = readl(port->base + MVPP2_GMAC_CTRL_2_REG) |
+             MVPP2_GMAC_PORT_RESET_MASK;
        writel(val, port->base + MVPP2_GMAC_CTRL_2_REG);
-
-       while (readl(port->base + MVPP2_GMAC_CTRL_2_REG) &
-              MVPP2_GMAC_PORT_RESET_MASK)
-               continue;
 }
 
 /* Change maximum receive size of the port */
@@ -4543,12 +4539,15 @@ static void mvpp2_gmac_config(struct mvpp2_port *port, unsigned int mode,
                              const struct phylink_link_state *state)
 {
        u32 an, ctrl0, ctrl2, ctrl4;
+       u32 old_ctrl2;
 
        an = readl(port->base + MVPP2_GMAC_AUTONEG_CONFIG);
        ctrl0 = readl(port->base + MVPP2_GMAC_CTRL_0_REG);
        ctrl2 = readl(port->base + MVPP2_GMAC_CTRL_2_REG);
        ctrl4 = readl(port->base + MVPP22_GMAC_CTRL_4_REG);
 
+       old_ctrl2 = ctrl2;
+
        /* Force link down */
        an &= ~MVPP2_GMAC_FORCE_LINK_PASS;
        an |= MVPP2_GMAC_FORCE_LINK_DOWN;
@@ -4621,6 +4620,12 @@ static void mvpp2_gmac_config(struct mvpp2_port *port, unsigned int mode,
        writel(ctrl2, port->base + MVPP2_GMAC_CTRL_2_REG);
        writel(ctrl4, port->base + MVPP22_GMAC_CTRL_4_REG);
        writel(an, port->base + MVPP2_GMAC_AUTONEG_CONFIG);
+
+       if (old_ctrl2 & MVPP2_GMAC_PORT_RESET_MASK) {
+               while (readl(port->base + MVPP2_GMAC_CTRL_2_REG) &
+                      MVPP2_GMAC_PORT_RESET_MASK)
+                       continue;
+       }
 }
 
 static void mvpp2_mac_config(struct net_device *dev, unsigned int mode,