From: netdev-bot+sashiko@kernel.org
To: namiltd@yahoo.com
Cc: linusw@kernel.org, andrew@lunn.ch, olteanv@gmail.com,
kuba@kernel.org, davem@davemloft.net, edumazet@google.com,
pabeni@redhat.com, linux@armlinux.org.uk, luizluca@gmail.com,
maxime.chevallier@bootlin.com, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org, alvin.sipraga@analog.com,
gusfmora@gmail.com, kuncy7@gmail.com, fabianotassotti@gmail.com,
gabonpivovich@gmail.com, contact@c127.dev
Subject: Re: [PATCH net-next v13 07/14] net: dsa: realtek: rtl8365mb: set and get vlan 4k for family D
Date: Mon, 23 Nov 2026 09:51:36 +0000 [thread overview]
Message-ID: <179542749608.3135.8744349482532821261@kernel.org> (raw)
In-Reply-To: <0552fff4-ac3d-4e2b-8d66-610d0e661e11@yahoo.com>
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 · Low: 1
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] In rtl8365mb_d_vlan_4k_set_ivl()
(drivers/net/dsa/realtek/rtl8365mb_vlan.c), the rollback loop skips…
- [Low] The new field vlan_4k_used is added to struct realtek_priv in
drivers/net/dsa/realtek/realtek.h.
--
net: dsa: realtek: rtl8365mb: set and get vlan 4k for family D
This adds two-word CVLAN pack/unpack helpers for family D. On family D,
IVL_EN now follows the switch-wide VLAN filtering state. A vlan_4k_used
bitmap in struct realtek_priv lets a filtering flip rewrite only the 4K
entries in use.
> diff --git a/drivers/net/dsa/realtek/realtek.h b/drivers/net/dsa/realtek/realtek.h
> index cfe56d30f5cb1..a3ecc13ec561e 100644
> --- a/drivers/net/dsa/realtek/realtek.h
> +++ b/drivers/net/dsa/realtek/realtek.h
[ ... ]
> @@ -65,6 +67,11 @@ struct realtek_priv {
> * deleting port VLAN memberships and PVID configurations.
> */
> struct mutex vlan_lock;
> + /* VIDs with a non-empty 4K VLAN entry, protected by vlan_lock. Lets
> + * a switch-wide update visit only the entries in use instead of
> + * reading all 4094 over the slow management bus.
> + */
> + DECLARE_BITMAP(vlan_4k_used, VLAN_N_VID);
[Severity: Low]
Does this comment describe more than the code maintains?
struct realtek_priv is shared by the rtl8365mb and rtl8366rb/rtl8366-core
drivers. The only place that updates the bitmap is
rtl8365mb_vlan_4k_port_set(), and only on family D:
if (rtl8365mb_is_d(priv)) {
if (vlan4k.member)
set_bit(vlan->vid, priv->vlan_4k_used);
else
clear_bit(vlan->vid, priv->vlan_4k_used);
}
On rtl8365mb family C, and in rtl8366rb/rtl8366-core (which write 4K
entries through priv->ops->set_vlan_4k), the bitmap stays empty even when
4K entries are populated. As the commit message notes, it also never holds
entries that were in the table before the driver loaded.
Should the comment say that this is rtl8365mb family D only and covers only
entries written by this driver? Or would the field fit better in struct
rtl8365mb (chip_data), since it adds 512 bytes to every realtek_priv?
This is unchanged at the end of the series.
[ ... ]
> diff --git a/drivers/net/dsa/realtek/rtl8365mb_vlan.c b/drivers/net/dsa/realtek/rtl8365mb_vlan.c
> index 566c6bc1449af..b80783502884b 100644
> --- a/drivers/net/dsa/realtek/rtl8365mb_vlan.c
> +++ b/drivers/net/dsa/realtek/rtl8365mb_vlan.c
[ ... ]
> @@ -277,6 +324,124 @@ int rtl8365mb_c_vlan_4k_write(struct realtek_priv *priv,
[ ... ]
> +int rtl8365mb_d_vlan_4k_set_ivl(struct dsa_switch *ds, bool want_ivl)
> +{
[ ... ]
> + for_each_set_bit(vid, priv->vlan_4k_used, VLAN_N_VID) {
> + ret = fi->vlan_4k_read(priv, vid, &vlan4k);
> + if (ret)
> + goto rollback;
> + if (!vlan4k.member || vlan4k.ivl_en == want_ivl)
> + continue;
> +
> + vlan4k.ivl_en = want_ivl;
> + ret = fi->vlan_4k_write(priv, &vlan4k);
> + if (ret)
> + goto rollback;
> + }
> +
> + return 0;
> +
> +rollback:
> + /* Best effort: restore the entries rewritten so far. IVL_EN is
> + * switch-wide, so before the scan every entry in use had the old
> + * value (!want_ivl) and every entry below @failed that now has
> + * want_ivl was rewritten above.
> + */
> + failed = vid;
> + for_each_set_bit(vid, priv->vlan_4k_used, failed) {
[Severity: Medium]
Can this rollback skip the one VID most likely to be half-changed?
Say fi->vlan_4k_write() fails for some VID X in the forward loop. The code
then jumps here with vid == X. The bound given to for_each_set_bit() is
exclusive, so X itself is never re-read or restored.
The write can fail after the chip has already taken the new value.
rtl8365mb_d_vlan_4k_write()->rtl8365mb_table_query() issues the command
before it polls for completion:
rtl8365mb_table_query() {
...
/* Execute */
ret = regmap_write(priv->map_nolock, RTL8365MB_TABLE_CTRL_REG, cmd);
if (ret)
goto out;
/* Poll for completion */
ret = rtl8365mb_table_poll_busy(priv);
if (ret)
goto out;
...
}
The entry may already hold want_ivl in two cases: the busy poll times out,
or the bus reports an error after the command write has reached the chip.
rtl8365mb_port_vlan_filtering() then returns the error, and DSA keeps the
old dp->vlan_filtering. So rtl8365mb_d_want_ivl(ds, -1, false) still
reports the old mode while VLAN X may be in the other learning mode (IVL vs
SVL). X stays like that until a later flip to that target succeeds or
rtl8365mb_vlan_4k_port_set() rewrites that VID.
The commit message says the rewrite is a separate function "so that an
error path can restore the previous state", but the entry that failed is
not restored.
Would failed = vid + 1 be safe here? The rollback re-reads each entry and
only changes entries that hold want_ivl, so an unmodified X would be left
alone.
This code is unchanged at the end of the series.
> + if (fi->vlan_4k_read(priv, vid, &vlan4k))
> + continue;
> + if (!vlan4k.member || vlan4k.ivl_en != want_ivl)
> + continue;
> + vlan4k.ivl_en = !want_ivl;
> + fi->vlan_4k_write(priv, &vlan4k);
> + }
> + return ret;
> +}
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/3f1826f8-3096-40dd-a278-c70fce4852c8%40yahoo.com
next prev parent reply other threads:[~2026-11-23 9:51 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <3f1826f8-3096-40dd-a278-c70fce4852c8.ref@yahoo.com>
2026-11-22 9:35 ` [PATCH net-next v13 00/14] net: dsa: realtek: rtl8365mb: add support for RTL8367S-VB Mieczyslaw Nalewaj
2026-11-22 9:36 ` [PATCH net-next v13 01/14] dt-bindings: net: dsa: realtek: add RTL8367S-VB Mieczyslaw Nalewaj
2026-11-22 9:37 ` [PATCH net-next v13 02/14] net: dsa: realtek: rtl8365mb: add chip family infrastructure Mieczyslaw Nalewaj
2026-11-22 9:38 ` [PATCH net-next v13 03/14] net: dsa: realtek: rtl8365mb: refactor forcemode handling Mieczyslaw Nalewaj
2026-11-22 9:39 ` [PATCH net-next v13 04/14] net: dsa: realtek: rtl8365mb: set speed for family D Mieczyslaw Nalewaj
2026-11-22 9:41 ` [PATCH net-next v13 05/14] net: dsa: realtek: rtl8365mb: set RGMII mode " Mieczyslaw Nalewaj
2026-11-22 9:42 ` [PATCH net-next v13 06/14] net: dsa: realtek: rtl8365mb: refactor VLAN 4k handling Mieczyslaw Nalewaj
2026-11-22 9:43 ` [PATCH net-next v13 07/14] net: dsa: realtek: rtl8365mb: set and get vlan 4k for family D Mieczyslaw Nalewaj
2026-11-23 9:51 ` netdev-bot+sashiko [this message]
2026-11-22 9:44 ` [PATCH net-next v13 08/14] net: dsa: realtek: rtl8365mb: refactor PVID handling Mieczyslaw Nalewaj
2026-11-22 9:45 ` [PATCH net-next v13 09/14] net: dsa: realtek: rtl8365mb: use raw VID for PVID on family D Mieczyslaw Nalewaj
2026-11-22 9:46 ` [PATCH net-next v13 10/14] net: dsa: realtek: rtl8365mb: add family D SDS13 PCS support Mieczyslaw Nalewaj
2026-11-23 9:51 ` netdev-bot+sashiko
2026-11-22 9:47 ` [PATCH net-next v13 11/14] net: dsa: realtek: rtl8365mb: refactor L2 MAC handling Mieczyslaw Nalewaj
2026-11-22 9:48 ` [PATCH net-next v13 12/14] net: dsa: realtek: rtl8365mb: make L2/LUT access work on family D Mieczyslaw Nalewaj
2026-11-23 9:51 ` netdev-bot+sashiko
2026-11-22 9:49 ` [PATCH net-next v13 13/14] net: dsa: realtek: rtl8365mb: use PCP numbering " Mieczyslaw Nalewaj
2026-11-23 9:51 ` netdev-bot+sashiko
2026-11-22 9:50 ` [PATCH net-next v13 14/14] net: dsa: realtek: rtl8365mb: add support for RTL8367S-VB Mieczyslaw Nalewaj
2026-11-23 9:51 ` netdev-bot+sashiko
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=179542749608.3135.8744349482532821261@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=alvin.sipraga@analog.com \
--cc=andrew@lunn.ch \
--cc=contact@c127.dev \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=fabianotassotti@gmail.com \
--cc=gabonpivovich@gmail.com \
--cc=gusfmora@gmail.com \
--cc=kuba@kernel.org \
--cc=kuncy7@gmail.com \
--cc=linusw@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=luizluca@gmail.com \
--cc=maxime.chevallier@bootlin.com \
--cc=namiltd@yahoo.com \
--cc=netdev@vger.kernel.org \
--cc=olteanv@gmail.com \
--cc=pabeni@redhat.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®