Re: [PATCH net v5 6/8] net: dsa: b53: reference count shared mirror source bits
From: Florian Fainelli
Date: Mon Nov 16 2026 - 15:42:51 EST
On 11/16/26 11:02, netdev-bot+sashiko@xxxxxxxxxx wrote:
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.
Critical: 0 · High: 1 · Medium: 1 · Low: 0
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [High] This patch changes bcm_sf2_sw_resume()
(drivers/net/dsa/bcm_sf2.c).
- [Medium] The new error path in bcm_sf2_sw_resume() gates the switch
clock (`if (ret && !priv->wol_ports_mask)…
--
net: dsa: b53: reference count shared mirror source bits
This commit adds reference counts for each port's ingress and egress
mirror source bits in b53. A bit is only cleared when its last tc
matchall filter is removed. It also adds a b53_mirror_init() helper and
changes bcm_sf2_sw_resume() to return the result of ds->ops->setup().
[ ... ]
diff --git a/drivers/net/dsa/bcm_sf2.c b/drivers/net/dsa/bcm_sf2.c
index 1747a1f20c78e..98a4a62ca73a2 100644
--- a/drivers/net/dsa/bcm_sf2.c
+++ b/drivers/net/dsa/bcm_sf2.c
@@ -996,9 +996,11 @@ static int bcm_sf2_sw_resume(struct dsa_switch *ds)
if (priv->hw_params.num_gphy == 1)
bcm_sf2_gphy_enable_set(ds, true);
- ds->ops->setup(ds);
+ ret = ds->ops->setup(ds);
+ if (ret && !priv->wol_ports_mask)
+ clk_disable_unprepare(priv->clk);
- return 0;
+ return ret;
}
[Severity: High]
Does this make every other system resume fail, starting with the first?
bcm_sf2_sw_setup() is not safe to run twice. It ends with:
return b53_setup_devlink_resources(ds);
Probe already registers the "VLAN" devlink resource through
dsa_switch_setup() -> ops->setup. Only bcm_sf2_sw_teardown() removes it.
On resume the call chain is:
bcm_sf2_sw_resume()
bcm_sf2_sw_setup()
b53_setup_devlink_resources()
dsa_devlink_resource_register()
__devl_resource_register()
if (resource)
return -EEXIST;
b53_setup_devlink_resources() then jumps to out:, calls
dsa_devlink_resources_unregister(ds) and returns -EEXIST. Before this
patch that error was ignored. Now bcm_sf2_sw_resume() returns it and
also gates the switch clock.
dsa_switch_resume() then returns early:
if (ds->ops->resume)
ret = ds->ops->resume(ds);
if (ret)
return ret;
As a result, dsa_user_resume() never runs for any user port. Without
netif_device_attach() or phylink_start(), all user ports stay down
after an ordinary suspend/resume.
The failure path unregistered the resources, so the next resume
succeeds and the one after that fails again.
The clock is already off after a failed resume. The next
bcm_sf2_sw_suspend() (when wol_ports_mask is 0) and bcm_sf2_sw_remove()
will each call clk_disable_unprepare() again. Can that underflow the
enable/prepare counts?
The commit message only covers mirror refcounting and does not mention
this resume change. With the Fixes: tag, a stable backport would bring
this change along. Could this change be split into its own patch, after
making the setup path safe to run again on resume?
[Severity: Medium]
On this new error path, gating the clock is the only rollback. By this
point the switch is out of reset, the crossbar is configured and the
GPHY is powered on through bcm_sf2_gphy_enable_set(ds, true).
bcm_sf2_sw_setup() may also have enabled ports already. Nothing marks
the device as clock-gated, and the switch stays bound.
On the next system suspend, dsa_switch_suspend() still calls
bcm_sf2_sw_suspend():
bcm_sf2_intr_disable(priv);
...
bcm_sf2_port_disable(ds, port);
}
if (!priv->wol_ports_mask)
clk_disable_unprepare(priv->clk);
Won't this access switch registers while the clock is gated? It then
calls clk_disable_unprepare() a second time, which would trigger the
clk core already disabled/unprepared warnings.
Callbacks that run under RTNL, such as b53_mirror_del() when a tc
filter is deleted, can still run and would also access registers with
the clock off.
Before this patch, a setup failure on resume left the clock enabled.
The rst and cfp failure paths already roll back only partially in the
same way, but this path runs after the GPHY has been powered up. Given
the devlink -EEXIST issue above, it would be hit on every other resume.
It would also be hit on any register I/O failure inside setup, for
example in b53_enable_mcast_snooping(), or later in the series in
b53_mirror_init().
[High] You are right. bcm_sf2_sw_resume() calls ds->ops->setup(), which
ends in b53_setup_devlink_resources(). The VLAN resource is already registered from probe, so on resume it returns -EEXIST. That error is
ignored today. Propagating it would make dsa_switch_resume() return
before dsa_user_resume(), leaving the user ports down. The resume change
does not belong in this patch, so I dropped it in v6. The mirror
re-initialization on resume is unaffected, since bcm_sf2_sw_setup() still calls b53_mirror_init() once the later patch adds it.
[Medium] This only applied to the new error path, which is gone in v6.
pw-bot: cr
--
Florian