792-v5.15-0001-net-dsa-b53-Fix-calculating-number-of-switch-ports.patch 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. From cdb067d31c0fe4cce98b9d15f1f2ef525acaa094 Mon Sep 17 00:00:00 2001
  2. From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <[email protected]>
  3. Date: Thu, 2 Sep 2021 10:30:50 +0200
  4. Subject: [PATCH] net: dsa: b53: Fix calculating number of switch ports
  5. MIME-Version: 1.0
  6. Content-Type: text/plain; charset=UTF-8
  7. Content-Transfer-Encoding: 8bit
  8. It isn't true that CPU port is always the last one. Switches BCM5301x
  9. have 9 ports (port 6 being inactive) and they use port 5 as CPU by
  10. default (depending on design some other may be CPU ports too).
  11. A more reliable way of determining number of ports is to check for the
  12. last set bit in the "enabled_ports" bitfield.
  13. This fixes b53 internal state, it will allow providing accurate info to
  14. the DSA and is required to fix BCM5301x support.
  15. Fixes: 967dd82ffc52 ("net: dsa: b53: Add support for Broadcom RoboSwitch")
  16. Signed-off-by: Rafał Miłecki <[email protected]>
  17. Reviewed-by: Florian Fainelli <[email protected]>
  18. Signed-off-by: David S. Miller <[email protected]>
  19. ---
  20. drivers/net/dsa/b53/b53_common.c | 3 +--
  21. 1 file changed, 1 insertion(+), 2 deletions(-)
  22. --- a/drivers/net/dsa/b53/b53_common.c
  23. +++ b/drivers/net/dsa/b53/b53_common.c
  24. @@ -2584,9 +2584,8 @@ static int b53_switch_init(struct b53_de
  25. dev->cpu_port = 5;
  26. }
  27. - /* cpu port is always last */
  28. - dev->num_ports = dev->cpu_port + 1;
  29. dev->enabled_ports |= BIT(dev->cpu_port);
  30. + dev->num_ports = fls(dev->enabled_ports);
  31. /* Include non standard CPU port built-in PHYs to be probed */
  32. if (is539x(dev) || is531x5(dev)) {