mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Florian Fainelli <florian.fainelli@broadcom.com>
To: netdev-bot+sashiko@kernel.org
Cc: netdev@vger.kernel.org, jonas.gorski@gmail.com, andrew@lunn.ch,
	olteanv@gmail.com, davem@davemloft.net, edumazet@kernel.org,
	kuba@kernel.org, pabeni@redhat.com, vivien.didelot@gmail.com,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH net v5 6/8] net: dsa: b53: reference count shared mirror source bits
Date: Mon, 16 Nov 2026 12:42:37 -0800	[thread overview]
Message-ID: <a8c3b390-2243-442a-889f-4ee69a551ed8@broadcom.com> (raw)
In-Reply-To: <179485574117.3136.2818958695058742581@kernel.org>

On 11/16/26 11:02, netdev-bot+sashiko@kernel.org 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

  reply	other threads:[~2026-11-16 20:42 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-12 18:01 [PATCH net v5 0/8] net: dsa: b53: Preliminary fixes Florian Fainelli
2026-11-12 18:01 ` [PATCH net v5 1/8] net: dsa: b53: initialize the jumbo frame size register offset Florian Fainelli
2026-11-12 18:01 ` [PATCH net v5 2/8] net: dsa: b53: fix the SRAB grant timeout check Florian Fainelli
2026-11-12 18:01 ` [PATCH net v5 3/8] net: dsa: b53: clear stale state when creating an ARL entry Florian Fainelli
2026-11-16 19:02   ` netdev-bot+sashiko
2026-11-16 20:37     ` Florian Fainelli
2026-11-12 18:01 ` [PATCH net v5 4/8] net: dsa: b53: reject conflicting mirror destinations Florian Fainelli
2026-11-16 19:02   ` netdev-bot+sashiko
2026-11-16 20:38     ` Florian Fainelli
2026-11-12 18:01 ` [PATCH net v5 5/8] net: dsa: b53: use the correct override register 2 Gbps bit Florian Fainelli
2026-11-16 19:02   ` netdev-bot+sashiko
2026-11-16 20:41     ` Florian Fainelli
2026-11-12 18:02 ` [PATCH net v5 6/8] net: dsa: b53: reference count shared mirror source bits Florian Fainelli
2026-11-16 19:02   ` netdev-bot+sashiko
2026-11-16 20:42     ` Florian Fainelli [this message]
2026-11-12 18:02 ` [PATCH net v5 7/8] net: dsa: b53: harden mirror register programming Florian Fainelli
2026-11-16 19:02   ` netdev-bot+sashiko
2026-11-16 20:47     ` Florian Fainelli
2026-11-12 18:02 ` [PATCH net v5 8/8] net: dsa: b53: fix mirror port encoding on BCM5325 and BCM5365 Florian Fainelli

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a8c3b390-2243-442a-889f-4ee69a551ed8@broadcom.com \
    --to=florian.fainelli@broadcom.com \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=jonas.gorski@gmail.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev-bot+sashiko@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=olteanv@gmail.com \
    --cc=pabeni@redhat.com \
    --cc=vivien.didelot@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®