]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - queue-4.19/net-marvell-mvpp2-fix-stuck-in-band-sgmii-negotiatio.patch
Linux 4.14.111
[thirdparty/kernel/stable-queue.git] / queue-4.19 / net-marvell-mvpp2-fix-stuck-in-band-sgmii-negotiatio.patch
1 From cb43d1468ff100a42287ee68c4e292676cd1f9eb Mon Sep 17 00:00:00 2001
2 From: Russell King <rmk+kernel@armlinux.org.uk>
3 Date: Fri, 8 Feb 2019 15:35:43 +0000
4 Subject: net: marvell: mvpp2: fix stuck in-band SGMII negotiation
5
6 [ Upstream commit 316734fdcf70900a83065360cff11a5826919067 ]
7
8 It appears that the mvpp22 can get stuck with SGMII negotiation. The
9 symptoms are that in-band negotiation never completes and the partner
10 (eg, PHY) never reports SGMII link up, or if it supports negotiation
11 bypass, goes into negotiation bypass mode (which will happen when the
12 PHY sees that the MAC is alive but gets no response.)
13
14 Triggering the PHY end of the link to re-negotiate results in the
15 bypass bit clearing on the PHY, and then re-setting - indicating that
16 the problem is at the mvpp22 GMAC end.
17
18 Asserting the GMAC reset and de-asserting it resolves the issue.
19 Arrange to assert the GMAC reset at probe time, and deassert it only
20 after we have configured the GMAC for the appropriate mode. This
21 resolves the issue.
22
23 Tested-by: Sven Auhagen <sven.auhagen@voleatech.de>
24 Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
25 Signed-off-by: David S. Miller <davem@davemloft.net>
26 Signed-off-by: Sasha Levin <sashal@kernel.org>
27 ---
28 drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c | 17 +++++++++++------
29 1 file changed, 11 insertions(+), 6 deletions(-)
30
31 diff --git a/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c b/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
32 index f8e4808a8317..9988c89ed9fd 100644
33 --- a/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
34 +++ b/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
35 @@ -1372,13 +1372,9 @@ static void mvpp2_port_reset(struct mvpp2_port *port)
36 for (i = 0; i < ARRAY_SIZE(mvpp2_ethtool_regs); i++)
37 mvpp2_read_count(port, &mvpp2_ethtool_regs[i]);
38
39 - val = readl(port->base + MVPP2_GMAC_CTRL_2_REG) &
40 - ~MVPP2_GMAC_PORT_RESET_MASK;
41 + val = readl(port->base + MVPP2_GMAC_CTRL_2_REG) |
42 + MVPP2_GMAC_PORT_RESET_MASK;
43 writel(val, port->base + MVPP2_GMAC_CTRL_2_REG);
44 -
45 - while (readl(port->base + MVPP2_GMAC_CTRL_2_REG) &
46 - MVPP2_GMAC_PORT_RESET_MASK)
47 - continue;
48 }
49
50 /* Change maximum receive size of the port */
51 @@ -4445,12 +4441,15 @@ static void mvpp2_gmac_config(struct mvpp2_port *port, unsigned int mode,
52 const struct phylink_link_state *state)
53 {
54 u32 an, ctrl0, ctrl2, ctrl4;
55 + u32 old_ctrl2;
56
57 an = readl(port->base + MVPP2_GMAC_AUTONEG_CONFIG);
58 ctrl0 = readl(port->base + MVPP2_GMAC_CTRL_0_REG);
59 ctrl2 = readl(port->base + MVPP2_GMAC_CTRL_2_REG);
60 ctrl4 = readl(port->base + MVPP22_GMAC_CTRL_4_REG);
61
62 + old_ctrl2 = ctrl2;
63 +
64 /* Force link down */
65 an &= ~MVPP2_GMAC_FORCE_LINK_PASS;
66 an |= MVPP2_GMAC_FORCE_LINK_DOWN;
67 @@ -4523,6 +4522,12 @@ static void mvpp2_gmac_config(struct mvpp2_port *port, unsigned int mode,
68 writel(ctrl2, port->base + MVPP2_GMAC_CTRL_2_REG);
69 writel(ctrl4, port->base + MVPP22_GMAC_CTRL_4_REG);
70 writel(an, port->base + MVPP2_GMAC_AUTONEG_CONFIG);
71 +
72 + if (old_ctrl2 & MVPP2_GMAC_PORT_RESET_MASK) {
73 + while (readl(port->base + MVPP2_GMAC_CTRL_2_REG) &
74 + MVPP2_GMAC_PORT_RESET_MASK)
75 + continue;
76 + }
77 }
78
79 static void mvpp2_mac_config(struct net_device *dev, unsigned int mode,
80 --
81 2.19.1
82