793-01-v6.11-net-dsa-qca8k-do-not-write-port-mask-twice-in-bridge.patch 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. From e85d3e6fea05c8ae21a40809a3c6b7adc97411c7 Mon Sep 17 00:00:00 2001
  2. Message-ID: <e85d3e6fea05c8ae21a40809a3c6b7adc97411c7.1728674648.git.mschiffer@universe-factory.net>
  3. From: Matthias Schiffer <[email protected]>
  4. Date: Thu, 20 Jun 2024 19:25:48 +0200
  5. Subject: [PATCH] net: dsa: qca8k: do not write port mask twice in bridge
  6. join/leave
  7. qca8k_port_bridge_join() set QCA8K_PORT_LOOKUP_CTRL() for i == port twice,
  8. once in the loop handling all other port's masks, and finally at the end
  9. with the accumulated port_mask.
  10. The first time it would incorrectly set the port's own bit in the mask,
  11. only to correct the mistake a moment later. qca8k_port_bridge_leave() had
  12. the same issue, but here the regmap_clear_bits() was a no-op rather than
  13. setting an unintended value.
  14. Remove the duplicate assignment by skipping the whole loop iteration for
  15. i == port. The unintended bit setting doesn't seem to have any negative
  16. effects (even when not reverted right away), so the change is submitted
  17. as a simple cleanup rather than a fix.
  18. Signed-off-by: Matthias Schiffer <[email protected]>
  19. Reviewed-by: Wojciech Drewek <[email protected]>
  20. Signed-off-by: David S. Miller <[email protected]>
  21. ---
  22. drivers/net/dsa/qca/qca8k-common.c | 7 +++++--
  23. 1 file changed, 5 insertions(+), 2 deletions(-)
  24. --- a/drivers/net/dsa/qca/qca8k-common.c
  25. +++ b/drivers/net/dsa/qca/qca8k-common.c
  26. @@ -654,6 +654,8 @@ int qca8k_port_bridge_join(struct dsa_sw
  27. port_mask = BIT(cpu_port);
  28. for (i = 0; i < QCA8K_NUM_PORTS; i++) {
  29. + if (i == port)
  30. + continue;
  31. if (dsa_is_cpu_port(ds, i))
  32. continue;
  33. if (!dsa_port_offloads_bridge(dsa_to_port(ds, i), &bridge))
  34. @@ -666,8 +668,7 @@ int qca8k_port_bridge_join(struct dsa_sw
  35. BIT(port));
  36. if (ret)
  37. return ret;
  38. - if (i != port)
  39. - port_mask |= BIT(i);
  40. + port_mask |= BIT(i);
  41. }
  42. /* Add all other ports to this ports portvlan mask */
  43. @@ -686,6 +687,8 @@ void qca8k_port_bridge_leave(struct dsa_
  44. cpu_port = dsa_to_port(ds, port)->cpu_dp->index;
  45. for (i = 0; i < QCA8K_NUM_PORTS; i++) {
  46. + if (i == port)
  47. + continue;
  48. if (dsa_is_cpu_port(ds, i))
  49. continue;
  50. if (!dsa_port_offloads_bridge(dsa_to_port(ds, i), &bridge))