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 v3 7/8] net: dsa: b53: harden mirror register programming
Date: Mon, 9 Nov 2026 16:06:44 -0800 [thread overview]
Message-ID: <d2fa8027-53da-42e2-a7eb-f666ed6bb4e0@broadcom.com> (raw)
In-Reply-To: <179348376557.3131.9793537339199409475@kernel.org>
On 10/31/26 14:56, netdev-bot+sashiko@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 1 potential
> issue(s) to consider.
>
> Critical: 0 · High: 0 · 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).
>
> - [Medium] This patch adds an unconditional b53_mirror_init() call to
> bcm_sf2_sw_setup() (drivers/net/dsa/bcm_sf2.c).
>
> --
>
> net: dsa: b53: harden mirror register programming
>
> This commit clears the mirror capture control register and both
> source-control registers during b53 and bcm_sf2 setup. It checks every
> mirror register access and only increments the source reference count
> once hardware programming has succeeded. It also decides whether the
> destination is occupied from the source masks instead of MIRROR_EN.
>
>> diff --git a/drivers/net/dsa/bcm_sf2.c b/drivers/net/dsa/bcm_sf2.c
>> index 9e5713015187b..9f54cd414c18f 100644
>> --- a/drivers/net/dsa/bcm_sf2.c
>> +++ b/drivers/net/dsa/bcm_sf2.c
>> @@ -1059,6 +1059,11 @@ static int bcm_sf2_sw_setup(struct dsa_switch *ds)
>> {
>> struct bcm_sf2_priv *priv = bcm_sf2_to_priv(ds);
>> unsigned int port;
>> + int ret;
>> +
>> + ret = b53_mirror_init(ds);
>> + if (ret)
>> + return ret;
>>
>> /* Enable all valid ports and disable those unused */
>> for (port = 0; port < priv->hw_params.num_ports; port++) {
>
> [Severity: Medium]
> Can this lose the installed mirror rules across suspend/resume?
>
> The resume path also calls bcm_sf2_sw_setup():
>
> drivers/net/dsa/bcm_sf2.c:bcm_sf2_sw_resume() {
> ...
> ret = bcm_sf2_cfp_resume(ds);
> ...
> ds->ops->setup(ds);
>
> return 0;
> }
>
> So every resume now writes 0 to B53_MIR_CAP_CTL, B53_IG_MIR_CTL and
> B53_EG_MIR_CTL. The tc matchall mirror rules stay installed.
>
> dev->ports[].mirror_count[] also keeps its value. The only thing that
> clears it is the memset in b53_reset_switch(), and the bcm_sf2 path never
> calls that.
>
> CFP gets restored by bcm_sf2_cfp_resume(), but nothing reprograms the
> mirror registers after resume.
>
> After resume, b53_mirror_add() would hit this:
>
> if (*mirror_count) {
> (*mirror_count)++;
> return 0;
> }
>
> A new rule for a port and direction that already has a reference would
> then return success without programming the hardware.
>
> The new occupancy check would also read all-zero source masks:
>
> if (((reg | other_reg) & MIRROR_MASK) &&
> (cap_ctl & CAP_PORT_MASK) != mirror->to_local_port) {
>
> That would accept a rule with a different destination while software
> still tracks rules for the old one.
>
> Doesn't this break the rule that mirror_count[] follows the hardware
> source mask bits? The commit message relies on that when it says
> "Reference counting must not record a first source reference until
> hardware programming has succeeded".
>
> bcm_sf2_sw_rst() may already clear these registers through EN_CHIP_RST.
> If so, the stale count came from the earlier patch in this series, "net:
> dsa: b53: reference count shared mirror source bits", and this patch makes
> the wipe unconditional.
>
> If the reset does not clear them, which is the case the commit message
> describes, this patch causes the loss on resume.
>
> The problem is still there at the end of the series. "net: dsa: b53: fix
> mirror port encoding on BCM5325 and BCM5365" only changes the port and
> capture encoding.
>
> A related question: bcm_sf2_sw_resume() ignores the return value of
> ds->ops->setup(). If b53_mirror_init() fails during resume, the new early
> return skips the port, VLAN and ACB setup below and no error is reported.
> Is that intended?
>
Agreed. This overlaps with the patch #6 finding. The respin will restore
the destination and source masks from retained software state during
setup, preserving reference counts for installed filters. It will also
propagate setup failures from bcm_sf2_sw_resume().
pw-bot: cr
--
Florian
next prev parent reply other threads:[~2026-11-10 0:06 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-30 21:16 [PATCH net v3 0/8] net: dsa: b53: Preliminary fixes Florian Fainelli
2026-10-30 21:16 ` [PATCH net v3 1/8] net: dsa: b53: initialize the jumbo frame size register offset Florian Fainelli
2026-10-30 21:16 ` [PATCH net v3 2/8] net: dsa: b53: fix the SRAB grant timeout check Florian Fainelli
2026-10-30 21:16 ` [PATCH net v3 3/8] net: dsa: b53: clear stale state when creating an ARL entry Florian Fainelli
2026-10-31 21:56 ` netdev-bot+sashiko
2026-11-09 23:56 ` Florian Fainelli
2026-10-30 21:16 ` [PATCH net v3 4/8] net: dsa: b53: reject conflicting mirror destinations Florian Fainelli
2026-10-31 21:56 ` netdev-bot+sashiko
2026-11-09 23:53 ` Florian Fainelli
2026-11-09 23:57 ` Florian Fainelli
2026-10-30 21:16 ` [PATCH net v3 5/8] net: dsa: b53: use the correct override register 2 Gbps bit Florian Fainelli
2026-10-31 21:56 ` netdev-bot+sashiko
2026-11-09 23:58 ` Florian Fainelli
2026-10-30 21:16 ` [PATCH net v3 6/8] net: dsa: b53: reference count shared mirror source bits Florian Fainelli
2026-10-31 21:56 ` netdev-bot+sashiko
2026-11-10 0:03 ` Florian Fainelli
2026-10-30 21:16 ` [PATCH net v3 7/8] net: dsa: b53: harden mirror register programming Florian Fainelli
2026-10-31 21:56 ` netdev-bot+sashiko
2026-11-10 0:06 ` Florian Fainelli [this message]
2026-10-30 21:16 ` [PATCH net v3 8/8] net: dsa: b53: fix mirror port encoding on BCM5325 and BCM5365 Florian Fainelli
2026-10-30 22:11 ` [PATCH net v3 0/8] net: dsa: b53: Preliminary fixes Florian Fainelli
-- strict thread matches above, loose matches on Subject: below --
2026-10-30 21:13 Florian Fainelli
2026-10-30 21:13 ` [PATCH net v3 7/8] net: dsa: b53: harden mirror register programming 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=d2fa8027-53da-42e2-a7eb-f666ed6bb4e0@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.