From: sashiko-bot@kernel.org
To: "Christian Marangi" <ansuelsmth@gmail.com>
Cc: mfd@lists.linux.dev, conor+dt@kernel.org,
devicetree@vger.kernel.org, robh@kernel.org, lee@kernel.org
Subject: Re: [PATCH net-next v21 8/9] net: dsa: mt7530: generalize and move common function to lib module
Date: Sat, 12 Sep 2026 22:55:10 +0000 [thread overview]
Message-ID: <20260912225510.99F6E1F00893@smtp.kernel.org> (raw)
In-Reply-To: <20260911225414.225980-9-ansuelsmth@gmail.com>
Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider:
- [High] Clearing `__MT7530_VAWD2` in `mt7530_hw_vlan_add()` destroys the egress tag configuration of all other ports in the VLAN.
- [Medium] Missing clearing of the `__MT7530_VAWD1` register before configuring VLAN 0.
- [Low] Passing an `int *` to `regmap_field_read()` triggers an incompatible pointer types warning.
- [Low] Enabling mirroring before setting the destination port creates a race condition.
--
commit df02cf8f99d1289b20bc7e77c9448ff004d35005
Author: Christian Marangi <ansuelsmth@gmail.com>
net: dsa: mt7530: generalize and move common function to lib module
This commit introduces a library module for MT7530 and moves common functions
into it. The functions are generalized to use the reg_field regmap API while
applying the same logic, and mirror functions are cleaned up.
> diff --git a/drivers/net/dsa/mt7530-lib.c b/drivers/net/dsa/mt7530-lib.c
> --- /dev/null
> +++ b/drivers/net/dsa/mt7530-lib.c
[ ... ]
> +int mt7530_lib_port_mirror_add(struct mt7530_lib_priv *priv, int port,
> + struct dsa_mall_mirror_tc_entry *mirror,
> + bool ingress, struct netlink_ext_ack *extack)
> +{
> + int monitor_port = -1;
> + u32 val = 0;
> +
> + /* Check for existent entry */
> + if ((ingress ? priv->mirror_rx : priv->mirror_tx) & BIT(port))
> + return -EEXIST;
> +
> + regmap_field_read(priv->fields[MT7530_MIRROR_EN], &val);
> + regmap_field_read(priv->fields[MT7530_MIRROR_PORT], &monitor_port);
[Severity: Low]
Does this pass an incompatible pointer type?
The monitor_port variable is declared as an int, but regmap_field_read()
expects an unsigned int * as its second argument. This can trigger a compiler
warning for incompatible pointer types, which may cause builds to fail if
configured with -Werror.
> +
> + /* MT7530 only supports one monitor port */
> + if (val && monitor_port != mirror->to_local_port)
> + return -EEXIST;
> +
> + regmap_field_write(priv->fields[MT7530_MIRROR_EN], 1);
> + regmap_field_write(priv->fields[MT7530_MIRROR_PORT],
> + mirror->to_local_port);
[Severity: Low]
Could this create a race condition where mirroring is enabled before the
destination port is safely updated?
Writing the enable bit before configuring the destination port creates a small
window where mirroring is active but directed to the old or default destination
port. This might cause a momentary glitch where packets are mirrored to the
wrong port.
[ ... ]
> +static void mt7530_hw_vlan_add(struct mt7530_lib_priv *priv,
> + struct mt7530_hw_vlan_entry *entry)
> +{
> + struct dsa_port *dp = dsa_to_port(priv->ds, entry->port);
> + u8 new_members;
> + u32 val;
> +
> + new_members = entry->old_members | BIT(entry->port);
> +
> + /* Clear VAWD registers from previous access */
> + regmap_field_write(priv->fields[__MT7530_VAWD1], 0);
> + regmap_field_write(priv->fields[__MT7530_VAWD2], 0);
[Severity: High]
Can this wipe out the egress tag configuration of all other ports in the VLAN?
When adding a port to an existing VLAN, mt7530_hw_vlan_update() copies the
current VLAN entry from hardware into the VAWD1 and VAWD2 registers. By
unconditionally zeroing __MT7530_VAWD2 here, the egress tag settings of all
prior ports in the VLAN are reset to zero (MT7530_VLAN_EGRESS_UNTAG).
Adding a user port to a VLAN could thus strip the CPU port of its required
MT7530_VLAN_EGRESS_STACK tagging, breaking VLAN traffic routing.
[ ... ]
> +int mt7530_lib_setup_vlan0(struct mt7530_lib_priv *priv)
> +{
> + regmap_field_write(priv->fields[MT7530_VAWD_IVL_MAC], 1);
> + regmap_field_write(priv->fields[MT7530_VAWD_VTAG_EN], 0);
> + regmap_field_write(priv->fields[MT7530_VAWD_EG_CON], 1);
[Severity: Medium]
Should this clear the __MT7530_VAWD1 register before configuring VLAN 0?
Unlike mt7530_hw_vlan_add() which clears the register first, this sequence
performs read-modify-write operations on individual fields. Any residual bits
from previous VLAN or FDB hardware commands (like the PORT_STAG bit or reserved
bits) might leak into the configuration for VLAN 0. This state leak can
misconfigure the switch for VLAN-unaware bridging traffic.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260911225414.225980-1-ansuelsmth@gmail.com?part=8
next prev parent reply other threads:[~2026-09-12 22:55 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-11 22:53 [PATCH net-next v21 0/9] net: dsa: Add Airoha AN8855 support Christian Marangi
2026-09-11 22:53 ` [PATCH net-next v21 1/9] dt-bindings: net: dsa: Document support for Airoha AN8855 DSA Switch Christian Marangi
2026-09-12 22:55 ` sashiko-bot
2026-09-11 22:53 ` [PATCH net-next v21 2/9] dt-bindings: net: Document support for AN8855 Switch Internal PHY Christian Marangi
2026-09-12 22:55 ` sashiko-bot
2026-09-11 22:53 ` [PATCH net-next v21 3/9] dt-bindings: mfd: Document support for Airoha AN8855 Switch SoC Christian Marangi
2026-09-12 22:55 ` sashiko-bot
2026-09-11 22:53 ` [PATCH net-next v21 4/9] mfd: an8855: Add support for Airoha AN8855 Switch Christian Marangi
2026-09-12 22:55 ` sashiko-bot
2026-09-11 22:53 ` [PATCH net-next v21 5/9] net: phy: Add Airoha AN8855 Internal Switch Gigabit PHY Christian Marangi
2026-09-12 22:55 ` sashiko-bot
2026-09-11 22:53 ` [PATCH net-next v21 6/9] net: dsa: tag_mtk: add Airoha variant usage of this TAG Christian Marangi
2026-09-12 22:55 ` sashiko-bot
2026-09-11 22:53 ` [PATCH net-next v21 7/9] MAINTAINERS: add myself as maintainer for Airoha AN8855 Switch Christian Marangi
2026-09-11 22:53 ` [PATCH net-next v21 8/9] net: dsa: mt7530: generalize and move common function to lib module Christian Marangi
2026-09-12 22:55 ` sashiko-bot [this message]
2026-09-11 22:53 ` [PATCH net-next v21 9/9] net: dsa: Add Airoha AN8855 5-Port Gigabit DSA Switch driver Christian Marangi
2026-09-12 22:55 ` sashiko-bot
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=20260912225510.99F6E1F00893@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=ansuelsmth@gmail.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=lee@kernel.org \
--cc=mfd@lists.linux.dev \
--cc=robh@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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