]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
5.10-stable patches
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 16 Aug 2021 19:21:44 +0000 (21:21 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 16 Aug 2021 19:21:44 +0000 (21:21 +0200)
added patches:
net-dsa-microchip-fix-probing-ksz87xx-switch-with-dt-node-for-host-port.patch
net-dsa-microchip-ksz8795-fix-pvid-tag-insertion.patch
net-dsa-microchip-ksz8795-fix-vlan-untagged-flag-change-on-deletion.patch
net-dsa-microchip-ksz8795-reject-unsupported-vlan-configuration.patch
net-dsa-microchip-ksz8795-use-software-untagging-on-cpu-port.patch

queue-5.10/net-dsa-microchip-fix-probing-ksz87xx-switch-with-dt-node-for-host-port.patch [new file with mode: 0644]
queue-5.10/net-dsa-microchip-ksz8795-fix-pvid-tag-insertion.patch [new file with mode: 0644]
queue-5.10/net-dsa-microchip-ksz8795-fix-vlan-untagged-flag-change-on-deletion.patch [new file with mode: 0644]
queue-5.10/net-dsa-microchip-ksz8795-reject-unsupported-vlan-configuration.patch [new file with mode: 0644]
queue-5.10/net-dsa-microchip-ksz8795-use-software-untagging-on-cpu-port.patch [new file with mode: 0644]
queue-5.10/series

diff --git a/queue-5.10/net-dsa-microchip-fix-probing-ksz87xx-switch-with-dt-node-for-host-port.patch b/queue-5.10/net-dsa-microchip-fix-probing-ksz87xx-switch-with-dt-node-for-host-port.patch
new file mode 100644 (file)
index 0000000..d7bec97
--- /dev/null
@@ -0,0 +1,43 @@
+From foo@baz Mon Aug 16 09:21:03 PM CEST 2021
+From: Ben Hutchings <ben.hutchings@mind.be>
+Date: Mon, 16 Aug 2021 20:09:09 +0200
+Subject: net: dsa: microchip: Fix probing KSZ87xx switch with DT node for host port
+To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Cc: linux-kernel@vger.kernel.org, stable@vger.kernel.org, "David S. Miller" <davem@davemloft.net>, Sasha Levin <sashal@kernel.org>, Woojung Huh <woojung.huh@microchip.com>, Microchip Linux Driver Support <UNGLinuxDriver@microchip.com>, Michael Grzeschik <m.grzeschik@pengutronix.de>, Marek Vasut <marex@denx.de>
+Message-ID: <20210816180909.GE18930@cephalopod>
+Content-Disposition: inline
+
+From: Ben Hutchings <ben.hutchings@mind.be>
+
+The ksz8795 and ksz9477 drivers differ in the way they count ports.
+For ksz8795, ksz_device::port_cnt does not include the host port
+whereas for ksz9477 it does.  This inconsistency was fixed in Linux
+5.11 by a series of changes, but remains in 5.10-stable.
+
+When probing, the common code treats a port device node with an
+address >= dev->port_cnt as a fatal error.  As a minimal fix, change
+it to compare again dev->mib_port_cnt.  This is the length of the
+dev->ports array that the port number will be used to index, and
+always includes the host port.
+
+Cc: Woojung Huh <woojung.huh@microchip.com>
+Cc: Microchip Linux Driver Support <UNGLinuxDriver@microchip.com>
+Cc: Michael Grzeschik <m.grzeschik@pengutronix.de>
+Cc: Marek Vasut <marex@denx.de>
+Signed-off-by: Ben Hutchings <ben.hutchings@mind.be>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/net/dsa/microchip/ksz_common.c |    2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/drivers/net/dsa/microchip/ksz_common.c
++++ b/drivers/net/dsa/microchip/ksz_common.c
+@@ -432,7 +432,7 @@ int ksz_switch_register(struct ksz_devic
+                               if (of_property_read_u32(port, "reg",
+                                                        &port_num))
+                                       continue;
+-                              if (port_num >= dev->port_cnt)
++                              if (port_num >= dev->mib_port_cnt)
+                                       return -EINVAL;
+                               of_get_phy_mode(port,
+                                               &dev->ports[port_num].interface);
diff --git a/queue-5.10/net-dsa-microchip-ksz8795-fix-pvid-tag-insertion.patch b/queue-5.10/net-dsa-microchip-ksz8795-fix-pvid-tag-insertion.patch
new file mode 100644 (file)
index 0000000..dc71ae5
--- /dev/null
@@ -0,0 +1,95 @@
+From foo@baz Mon Aug 16 09:21:03 PM CEST 2021
+From: Ben Hutchings <ben.hutchings@mind.be>
+Date: Mon, 16 Aug 2021 20:09:22 +0200
+Subject: net: dsa: microchip: ksz8795: Fix PVID tag insertion
+To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Cc: linux-kernel@vger.kernel.org, stable@vger.kernel.org, "David S. Miller" <davem@davemloft.net>, Sasha Levin <sashal@kernel.org>
+Message-ID: <20210816180921.GF18930@cephalopod>
+Content-Disposition: inline
+
+From: Ben Hutchings <ben.hutchings@mind.be>
+
+commit ef3b02a1d79b691f9a354c4903cf1e6917e315f9 upstream.
+
+ksz8795 has never actually enabled PVID tag insertion, and it also
+programmed the PVID incorrectly.  To fix this:
+
+* Allow tag insertion to be controlled per ingress port.  On most
+  chips, set bit 2 in Global Control 19.  On KSZ88x3 this control
+  flag doesn't exist.
+
+* When adding a PVID:
+  - Set the appropriate register bits to enable tag insertion on
+    egress at every other port if this was the packet's ingress port.
+  - Mask *out* the VID from the default tag, before or-ing in the new
+    PVID.
+
+* When removing a PVID:
+  - Clear the same control bits to disable tag insertion.
+  - Don't update the default tag.  This wasn't doing anything useful.
+
+Fixes: e66f840c08a2 ("net: dsa: ksz: Add Microchip KSZ8795 DSA driver")
+Signed-off-by: Ben Hutchings <ben.hutchings@mind.be>
+Signed-off-by: David S. Miller <davem@davemloft.net>
+[bwh: Backport to 5.10:
+ - Drop the KSZ88x3 cases as those chips are not supported here
+ - Handle VID ranges in ksz8795_port_vlan_del()]
+Signed-off-by: Ben Hutchings <ben.hutchings@mind.be>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/net/dsa/microchip/ksz8795.c |   15 ++++++++++-----
+ 1 file changed, 10 insertions(+), 5 deletions(-)
+
+--- a/drivers/net/dsa/microchip/ksz8795.c
++++ b/drivers/net/dsa/microchip/ksz8795.c
+@@ -833,9 +833,11 @@ static void ksz8795_port_vlan_add(struct
+       if (new_pvid) {
+               ksz_pread16(dev, port, REG_PORT_CTRL_VID, &vid);
+-              vid &= 0xfff;
++              vid &= ~VLAN_VID_MASK;
+               vid |= new_pvid;
+               ksz_pwrite16(dev, port, REG_PORT_CTRL_VID, vid);
++
++              ksz_pwrite8(dev, port, REG_PORT_CTRL_12, 0x0f);
+       }
+ }
+@@ -844,8 +846,9 @@ static int ksz8795_port_vlan_del(struct
+ {
+       bool untagged = vlan->flags & BRIDGE_VLAN_INFO_UNTAGGED;
+       struct ksz_device *dev = ds->priv;
+-      u16 data, vid, pvid, new_pvid = 0;
++      u16 data, vid, pvid;
+       u8 fid, member, valid;
++      bool del_pvid = false;
+       ksz_pread16(dev, port, REG_PORT_CTRL_VID, &pvid);
+       pvid = pvid & 0xFFF;
+@@ -865,14 +868,14 @@ static int ksz8795_port_vlan_del(struct
+               }
+               if (pvid == vid)
+-                      new_pvid = 1;
++                      del_pvid = true;
+               ksz8795_to_vlan(fid, member, valid, &data);
+               ksz8795_w_vlan_table(dev, vid, data);
+       }
+-      if (new_pvid != pvid)
+-              ksz_pwrite16(dev, port, REG_PORT_CTRL_VID, pvid);
++      if (del_pvid)
++              ksz_pwrite8(dev, port, REG_PORT_CTRL_12, 0x00);
+       return 0;
+ }
+@@ -1085,6 +1088,8 @@ static int ksz8795_setup(struct dsa_swit
+       ksz_cfg(dev, S_MIRROR_CTRL, SW_MIRROR_RX_TX, false);
++      ksz_cfg(dev, REG_SW_CTRL_19, SW_INS_TAG_ENABLE, true);
++
+       /* set broadcast storm protection 10% rate */
+       regmap_update_bits(dev->regmap[1], S_REPLACE_VID_CTRL,
+                          BROADCAST_STORM_RATE,
diff --git a/queue-5.10/net-dsa-microchip-ksz8795-fix-vlan-untagged-flag-change-on-deletion.patch b/queue-5.10/net-dsa-microchip-ksz8795-fix-vlan-untagged-flag-change-on-deletion.patch
new file mode 100644 (file)
index 0000000..096492c
--- /dev/null
@@ -0,0 +1,54 @@
+From foo@baz Mon Aug 16 09:21:03 PM CEST 2021
+From: Ben Hutchings <ben.hutchings@mind.be>
+Date: Mon, 16 Aug 2021 20:09:38 +0200
+Subject: net: dsa: microchip: ksz8795: Fix VLAN untagged flag change on deletion
+To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Cc: linux-kernel@vger.kernel.org, stable@vger.kernel.org, "David S. Miller" <davem@davemloft.net>, Sasha Levin <sashal@kernel.org>
+Message-ID: <20210816180938.GH18930@cephalopod>
+Content-Disposition: inline
+
+From: Ben Hutchings <ben.hutchings@mind.be>
+
+commit af01754f9e3c553a2ee63b4693c79a3956e230ab upstream.
+
+When a VLAN is deleted from a port, the flags in struct
+switchdev_obj_port_vlan are always 0.  ksz8_port_vlan_del() copies the
+BRIDGE_VLAN_INFO_UNTAGGED flag to the port's Tag Removal flag, and
+therefore always clears it.
+
+In case there are multiple VLANs configured as untagged on this port -
+which seems useless, but is allowed - deleting one of them changes the
+remaining VLANs to be tagged.
+
+It's only ever necessary to change this flag when a VLAN is added to
+the port, so leave it unchanged in ksz8_port_vlan_del().
+
+Fixes: e66f840c08a2 ("net: dsa: ksz: Add Microchip KSZ8795 DSA driver")
+Signed-off-by: Ben Hutchings <ben.hutchings@mind.be>
+Signed-off-by: David S. Miller <davem@davemloft.net>
+[bwh: Backport to 5.10: adjust context]
+Signed-off-by: Ben Hutchings <ben.hutchings@mind.be>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/net/dsa/microchip/ksz8795.c |    3 ---
+ 1 file changed, 3 deletions(-)
+
+--- a/drivers/net/dsa/microchip/ksz8795.c
++++ b/drivers/net/dsa/microchip/ksz8795.c
+@@ -895,7 +895,6 @@ static void ksz8795_port_vlan_add(struct
+ static int ksz8795_port_vlan_del(struct dsa_switch *ds, int port,
+                                const struct switchdev_obj_port_vlan *vlan)
+ {
+-      bool untagged = vlan->flags & BRIDGE_VLAN_INFO_UNTAGGED;
+       struct ksz_device *dev = ds->priv;
+       u16 data, vid, pvid;
+       u8 fid, member, valid;
+@@ -904,8 +903,6 @@ static int ksz8795_port_vlan_del(struct
+       ksz_pread16(dev, port, REG_PORT_CTRL_VID, &pvid);
+       pvid = pvid & 0xFFF;
+-      ksz_port_cfg(dev, port, P_TAG_CTRL, PORT_REMOVE_TAG, untagged);
+-
+       for (vid = vlan->vid_begin; vid <= vlan->vid_end; vid++) {
+               ksz8795_r_vlan_table(dev, vid, &data);
+               ksz8795_from_vlan(data, &fid, &member, &valid);
diff --git a/queue-5.10/net-dsa-microchip-ksz8795-reject-unsupported-vlan-configuration.patch b/queue-5.10/net-dsa-microchip-ksz8795-reject-unsupported-vlan-configuration.patch
new file mode 100644 (file)
index 0000000..8bdc94e
--- /dev/null
@@ -0,0 +1,131 @@
+From foo@baz Mon Aug 16 09:21:03 PM CEST 2021
+From: Ben Hutchings <ben.hutchings@mind.be>
+Date: Mon, 16 Aug 2021 20:09:31 +0200
+Subject: net: dsa: microchip: ksz8795: Reject unsupported VLAN configuration
+To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Cc: linux-kernel@vger.kernel.org, stable@vger.kernel.org, "David S. Miller" <davem@davemloft.net>, Sasha Levin <sashal@kernel.org>
+Message-ID: <20210816180930.GG18930@cephalopod>
+Content-Disposition: inline
+
+From: Ben Hutchings <ben.hutchings@mind.be>
+
+commit 8f4f58f88fe0d9bd591f21f53de7dbd42baeb3fa upstream.
+
+The switches supported by ksz8795 only have a per-port flag for Tag
+Removal.  This means it is not possible to support both tagged and
+untagged VLANs on the same port.  Reject attempts to add a VLAN that
+requires the flag to be changed, unless there are no VLANs currently
+configured.
+
+VID 0 is excluded from this check since it is untagged regardless of
+the state of the flag.
+
+On the CPU port we could support tagged and untagged VLANs at the same
+time.  This will be enabled by a later patch.
+
+Fixes: e66f840c08a2 ("net: dsa: ksz: Add Microchip KSZ8795 DSA driver")
+Signed-off-by: Ben Hutchings <ben.hutchings@mind.be>
+Signed-off-by: David S. Miller <davem@davemloft.net>
+[bwh: Backport to 5.10:
+ - This configuration has to be detected and rejected in the
+   port_vlan_prepare operation
+ - ksz8795_port_vlan_add() has to check again to decide whether to
+   change the Tag Removal flag, so put the common condition in a
+   separate function
+ - Handle VID ranges]
+Signed-off-by: Ben Hutchings <ben.hutchings@mind.be>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/net/dsa/microchip/ksz8795.c    |   55 +++++++++++++++++++++++++++++++--
+ drivers/net/dsa/microchip/ksz_common.h |    1 
+ 2 files changed, 54 insertions(+), 2 deletions(-)
+
+--- a/drivers/net/dsa/microchip/ksz8795.c
++++ b/drivers/net/dsa/microchip/ksz8795.c
+@@ -801,15 +801,66 @@ static int ksz8795_port_vlan_filtering(s
+       return 0;
+ }
++static bool ksz8795_port_vlan_changes_remove_tag(
++      struct dsa_switch *ds, int port,
++      const struct switchdev_obj_port_vlan *vlan)
++{
++      bool untagged = vlan->flags & BRIDGE_VLAN_INFO_UNTAGGED;
++      struct ksz_device *dev = ds->priv;
++      struct ksz_port *p = &dev->ports[port];
++
++      /* If a VLAN is added with untagged flag different from the
++       * port's Remove Tag flag, we need to change the latter.
++       * Ignore VID 0, which is always untagged.
++       */
++      return untagged != p->remove_tag &&
++              !(vlan->vid_begin == 0 && vlan->vid_end == 0);
++}
++
++int ksz8795_port_vlan_prepare(struct dsa_switch *ds, int port,
++                            const struct switchdev_obj_port_vlan *vlan)
++{
++      struct ksz_device *dev = ds->priv;
++
++      /* Reject attempts to add a VLAN that requires the Remove Tag
++       * flag to be changed, unless there are no other VLANs
++       * currently configured.
++       */
++      if (ksz8795_port_vlan_changes_remove_tag(ds, port, vlan)) {
++              unsigned int vid;
++
++              for (vid = 1; vid < dev->num_vlans; ++vid) {
++                      u8 fid, member, valid;
++
++                      /* Skip the VIDs we are going to add or reconfigure */
++                      if (vid == vlan->vid_begin) {
++                              vid = vlan->vid_end;
++                              continue;
++                      }
++
++                      ksz8795_from_vlan(dev->vlan_cache[vid].table[0],
++                                        &fid, &member, &valid);
++                      if (valid && (member & BIT(port)))
++                              return -EINVAL;
++              }
++      }
++
++      return ksz_port_vlan_prepare(ds, port, vlan);
++}
++
+ static void ksz8795_port_vlan_add(struct dsa_switch *ds, int port,
+                                 const struct switchdev_obj_port_vlan *vlan)
+ {
+       bool untagged = vlan->flags & BRIDGE_VLAN_INFO_UNTAGGED;
+       struct ksz_device *dev = ds->priv;
++      struct ksz_port *p = &dev->ports[port];
+       u16 data, vid, new_pvid = 0;
+       u8 fid, member, valid;
+-      ksz_port_cfg(dev, port, P_TAG_CTRL, PORT_REMOVE_TAG, untagged);
++      if (ksz8795_port_vlan_changes_remove_tag(ds, port, vlan)) {
++              ksz_port_cfg(dev, port, P_TAG_CTRL, PORT_REMOVE_TAG, untagged);
++              p->remove_tag = untagged;
++      }
+       for (vid = vlan->vid_begin; vid <= vlan->vid_end; vid++) {
+               ksz8795_r_vlan_table(dev, vid, &data);
+@@ -1128,7 +1179,7 @@ static const struct dsa_switch_ops ksz87
+       .port_stp_state_set     = ksz8795_port_stp_state_set,
+       .port_fast_age          = ksz_port_fast_age,
+       .port_vlan_filtering    = ksz8795_port_vlan_filtering,
+-      .port_vlan_prepare      = ksz_port_vlan_prepare,
++      .port_vlan_prepare      = ksz8795_port_vlan_prepare,
+       .port_vlan_add          = ksz8795_port_vlan_add,
+       .port_vlan_del          = ksz8795_port_vlan_del,
+       .port_fdb_dump          = ksz_port_fdb_dump,
+--- a/drivers/net/dsa/microchip/ksz_common.h
++++ b/drivers/net/dsa/microchip/ksz_common.h
+@@ -27,6 +27,7 @@ struct ksz_port_mib {
+ struct ksz_port {
+       u16 member;
+       u16 vid_member;
++      bool remove_tag;                /* Remove Tag flag set, for ksz8795 only */
+       int stp_state;
+       struct phy_device phydev;
diff --git a/queue-5.10/net-dsa-microchip-ksz8795-use-software-untagging-on-cpu-port.patch b/queue-5.10/net-dsa-microchip-ksz8795-use-software-untagging-on-cpu-port.patch
new file mode 100644 (file)
index 0000000..5b7ad06
--- /dev/null
@@ -0,0 +1,55 @@
+From foo@baz Mon Aug 16 09:21:03 PM CEST 2021
+From: Ben Hutchings <ben.hutchings@mind.be>
+Date: Mon, 16 Aug 2021 20:09:45 +0200
+Subject: net: dsa: microchip: ksz8795: Use software untagging on CPU port
+To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Cc: linux-kernel@vger.kernel.org, stable@vger.kernel.org, "David S. Miller" <davem@davemloft.net>, Sasha Levin <sashal@kernel.org>
+Message-ID: <20210816180945.GI18930@cephalopod>
+Content-Disposition: inline
+
+From: Ben Hutchings <ben.hutchings@mind.be>
+
+commit 9130c2d30c17846287b803a9803106318cbe5266 upstream.
+
+On the CPU port, we can support both tagged and untagged VLANs at the
+same time by doing any necessary untagging in software rather than
+hardware.  To enable that, keep the CPU port's Remove Tag flag cleared
+and set the dsa_switch::untag_bridge_pvid flag.
+
+Fixes: e66f840c08a2 ("net: dsa: ksz: Add Microchip KSZ8795 DSA driver")
+Signed-off-by: Ben Hutchings <ben.hutchings@mind.be>
+Signed-off-by: David S. Miller <davem@davemloft.net>
+[bwh: Backport to 5.10: adjust context]
+Signed-off-by: Ben Hutchings <ben.hutchings@mind.be>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/net/dsa/microchip/ksz8795.c |    9 ++++++++-
+ 1 file changed, 8 insertions(+), 1 deletion(-)
+
+--- a/drivers/net/dsa/microchip/ksz8795.c
++++ b/drivers/net/dsa/microchip/ksz8795.c
+@@ -812,9 +812,11 @@ static bool ksz8795_port_vlan_changes_re
+       /* If a VLAN is added with untagged flag different from the
+        * port's Remove Tag flag, we need to change the latter.
+        * Ignore VID 0, which is always untagged.
++       * Ignore CPU port, which will always be tagged.
+        */
+       return untagged != p->remove_tag &&
+-              !(vlan->vid_begin == 0 && vlan->vid_end == 0);
++              !(vlan->vid_begin == 0 && vlan->vid_end == 0) &&
++              port != dev->cpu_port;
+ }
+ int ksz8795_port_vlan_prepare(struct dsa_switch *ds, int port,
+@@ -1325,6 +1327,11 @@ static int ksz8795_switch_init(struct ks
+       /* set the real number of ports */
+       dev->ds->num_ports = dev->port_cnt + 1;
++      /* We rely on software untagging on the CPU port, so that we
++       * can support both tagged and untagged VLANs
++       */
++      dev->ds->untag_bridge_pvid = true;
++
+       /* VLAN filtering is partly controlled by the global VLAN
+        * Enable flag
+        */
index 5c8a8ccaca24b42fc6f06bdf75eca898704b6f6b..a132998b9f121e779c29646ddd993b5747c2729f 100644 (file)
@@ -96,3 +96,8 @@ ceph-take-snap_empty_lock-atomically-with-snaprealm-refcount-change.patch
 vmlinux.lds.h-handle-clang-s-module.-c-d-tor-sections.patch
 kvm-nsvm-avoid-picking-up-unsupported-bits-from-l2-in-int_ctl-cve-2021-3653.patch
 kvm-nsvm-always-intercept-vmload-vmsave-when-nested-cve-2021-3656.patch
+net-dsa-microchip-fix-probing-ksz87xx-switch-with-dt-node-for-host-port.patch
+net-dsa-microchip-ksz8795-fix-pvid-tag-insertion.patch
+net-dsa-microchip-ksz8795-reject-unsupported-vlan-configuration.patch
+net-dsa-microchip-ksz8795-fix-vlan-untagged-flag-change-on-deletion.patch
+net-dsa-microchip-ksz8795-use-software-untagging-on-cpu-port.patch