]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
net: dsa: mv88e6xxx: prevent interrupt storm caused by mv88e6390x_port_set_cmode
authorHeiner Kallweit <hkallweit1@gmail.com>
Thu, 28 Feb 2019 06:39:15 +0000 (07:39 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 10 Mar 2019 06:10:14 +0000 (07:10 +0100)
[ Upstream commit ed8fe20205ac054bf585156709de3913d1890f30 ]

When debugging another issue I faced an interrupt storm in this
driver (88E6390, port 9 in SGMII mode), consisting of alternating
link-up / link-down interrupts. Analysis showed that the driver
wanted to set a cmode that was set already. But so far
mv88e6390x_port_set_cmode() doesn't check this and powers down
SERDES, what causes the link to break, and eventually results in
the described interrupt storm.

Fix this by checking whether the cmode actually changes. We want
that the very first call to mv88e6390x_port_set_cmode() always
configures the registers, therefore initialize port.cmode with
a value that is different from any supported cmode value.
We have to take care that we only init the ports cmode once
chip->info->num_ports is set.

v2:
- add small helper and init the number of actual ports only

Fixes: 364e9d7776a3 ("net: dsa: mv88e6xxx: Power on/off SERDES on cmode change")
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/net/dsa/mv88e6xxx/chip.c
drivers/net/dsa/mv88e6xxx/port.c
drivers/net/dsa/mv88e6xxx/port.h

index 0166f740e625a97d61bdbc17ec5ce69e90f64762..9021f01651d651452126e8fc021f4649a07a3348 100644 (file)
@@ -4579,6 +4579,14 @@ static int mv88e6xxx_smi_init(struct mv88e6xxx_chip *chip,
        return 0;
 }
 
+static void mv88e6xxx_ports_cmode_init(struct mv88e6xxx_chip *chip)
+{
+       int i;
+
+       for (i = 0; i < mv88e6xxx_num_ports(chip); i++)
+               chip->ports[i].cmode = MV88E6XXX_PORT_STS_CMODE_INVALID;
+}
+
 static enum dsa_tag_protocol mv88e6xxx_get_tag_protocol(struct dsa_switch *ds,
                                                        int port)
 {
@@ -4615,6 +4623,8 @@ static const char *mv88e6xxx_drv_probe(struct device *dsa_dev,
        if (err)
                goto free;
 
+       mv88e6xxx_ports_cmode_init(chip);
+
        mutex_lock(&chip->reg_lock);
        err = mv88e6xxx_switch_reset(chip);
        mutex_unlock(&chip->reg_lock);
index 71e604e9531a85da3cdbe48005a6e3f7f747ec5e..abe86d7781d826a60a2a209c71ed8353c8b8ecae 100644 (file)
@@ -395,6 +395,10 @@ int mv88e6390x_port_set_cmode(struct mv88e6xxx_chip *chip, int port,
                cmode = 0;
        }
 
+       /* cmode doesn't change, nothing to do for us */
+       if (cmode == chip->ports[port].cmode)
+               return 0;
+
        lane = mv88e6390x_serdes_get_lane(chip, port);
        if (lane < 0)
                return lane;
index 091aa0057f1f65a051b1e6dc99390da157903f49..cbb64a7683e287d724203cda74a186297e85d6b3 100644 (file)
@@ -52,6 +52,7 @@
 #define MV88E6185_PORT_STS_CMODE_1000BASE_X    0x0005
 #define MV88E6185_PORT_STS_CMODE_PHY           0x0006
 #define MV88E6185_PORT_STS_CMODE_DISABLED      0x0007
+#define MV88E6XXX_PORT_STS_CMODE_INVALID       0xff
 
 /* Offset 0x01: MAC (or PCS or Physical) Control Register */
 #define MV88E6XXX_PORT_MAC_CTL                         0x01