diff mbox series

[V2,net,1/2] net: dsa: b53: Fix calculating number of switch ports

Message ID 20210902083051.18206-1-zajec5@gmail.com (mailing list archive)
State Accepted
Commit cdb067d31c0fe4cce98b9d15f1f2ef525acaa094
Delegated to: Netdev Maintainers
Headers show
Series [V2,net,1/2] net: dsa: b53: Fix calculating number of switch ports | expand

Checks

Context Check Description
netdev/cover_letter success Link
netdev/fixes_present success Link
netdev/patch_count success Link
netdev/tree_selection success Clearly marked for net
netdev/subject_prefix success Link
netdev/cc_maintainers success CCed 7 of 7 maintainers
netdev/source_inline success Was 0 now: 0
netdev/verify_signedoff success Link
netdev/module_param success Was 0 now: 0
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/verify_fixes success Link
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 10 lines checked
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/header_inline success Link

Commit Message

Rafał Miłecki Sept. 2, 2021, 8:30 a.m. UTC
From: Rafał Miłecki <rafal@milecki.pl>

It isn't true that CPU port is always the last one. Switches BCM5301x
have 9 ports (port 6 being inactive) and they use port 5 as CPU by
default (depending on design some other may be CPU ports too).

A more reliable way of determining number of ports is to check for the
last set bit in the "enabled_ports" bitfield.

This fixes b53 internal state, it will allow providing accurate info to
the DSA and is required to fix BCM5301x support.

Fixes: 967dd82ffc52 ("net: dsa: b53: Add support for Broadcom RoboSwitch")
Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
---
 drivers/net/dsa/b53/b53_common.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Comments

patchwork-bot+netdevbpf@kernel.org Sept. 2, 2021, 12:40 p.m. UTC | #1
Hello:

This series was applied to netdev/net.git (refs/heads/master):

On Thu,  2 Sep 2021 10:30:50 +0200 you wrote:
> From: Rafał Miłecki <rafal@milecki.pl>
> 
> It isn't true that CPU port is always the last one. Switches BCM5301x
> have 9 ports (port 6 being inactive) and they use port 5 as CPU by
> default (depending on design some other may be CPU ports too).
> 
> A more reliable way of determining number of ports is to check for the
> last set bit in the "enabled_ports" bitfield.
> 
> [...]

Here is the summary with links:
  - [V2,net,1/2] net: dsa: b53: Fix calculating number of switch ports
    https://git.kernel.org/netdev/net/c/cdb067d31c0f
  - [V2,net,2/2] net: dsa: b53: Set correct number of ports in the DSA struct
    https://git.kernel.org/netdev/net/c/d12e1c464988

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
diff mbox series

Patch

diff --git a/drivers/net/dsa/b53/b53_common.c b/drivers/net/dsa/b53/b53_common.c
index bd1417a66cbf..dcf9d7e5ae14 100644
--- a/drivers/net/dsa/b53/b53_common.c
+++ b/drivers/net/dsa/b53/b53_common.c
@@ -2612,9 +2612,8 @@  static int b53_switch_init(struct b53_device *dev)
 			dev->cpu_port = 5;
 	}
 
-	/* cpu port is always last */
-	dev->num_ports = dev->cpu_port + 1;
 	dev->enabled_ports |= BIT(dev->cpu_port);
+	dev->num_ports = fls(dev->enabled_ports);
 
 	/* Include non standard CPU port built-in PHYs to be probed */
 	if (is539x(dev) || is531x5(dev)) {