From: Joris Vaisvila <joey@tinyisr.com>
To: Jakub Kicinski <kuba@kernel.org>
Cc: netdev@vger.kernel.org, horms@kernel.org, pabeni@redhat.com,
edumazet@google.com, davem@davemloft.net, olteanv@gmail.com,
andrew@lunn.ch, devicetree@vger.kernel.org, robh@kernel.org,
krzk+dt@kernel.org, conor+dt@kernel.org, arinc.unal@arinc9.com,
Landen.Chao@mediatek.com, dqfext@gmail.com,
sean.wang@mediatek.com, daniel@makrotopia.org
Subject: Re: [PATCH net-next v6 4/4] net: dsa: initial support for MT7628 embedded switch
Date: Mon, 3 Aug 2026 22:50:34 +0300 [thread overview]
Message-ID: <anDmcBoebeG-DDXc@archlinux> (raw)
In-Reply-To: <20260720235219.466404-1-kuba@kernel.org>
On Mon, Jul 20, 2026 at 04:52:19PM -0700, Jakub Kicinski wrote:
> This is an AI-generated review of your patch. The human sending this
> email has considered the AI review valid, or at least plausible.
> ---
> net: dsa: initial support for MT7628 embedded switch
>
> Add support for the MT7628 embedded switch. The switch has 5 built-in
> 100Mbps user ports and one 1Gbps CPU port.
>
> > diff --git a/drivers/net/dsa/Kconfig b/drivers/net/dsa/Kconfig
> > index 4ab567c5bbafc..daa1d3d4ba609 100644
> > --- a/drivers/net/dsa/Kconfig
> > +++ b/drivers/net/dsa/Kconfig
> > @@ -63,6 +63,14 @@ config NET_DSA_MT7530_MMIO
> > are directly mapped into the SoCs register space rather than being
> > accessible via MDIO.
> >
> > +config NET_DSA_MT7628
> > + tristate "MediaTek MT7628 Embedded Ethernet switch support"
> > + select NET_DSA_TAG_MT7628
> > + select MEDIATEK_FE_SOC_PHY
> > + help
>
> [Severity: Low]
> Can this lead to a build or link failure on randconfig? It looks like this
> is missing a select REGMAP_MMIO and depends on HAS_IOMEM, which might cause
> devm_regmap_init_mmio() to be unresolved when CONFIG_REGMAP_MMIO is not set.
Will fix with v7.
> > diff --git a/drivers/net/dsa/mt7628.c b/drivers/net/dsa/mt7628.c
> > new file mode 100644
> > index 0000000000000..eccdb05fce9b7
> > --- /dev/null
> > +++ b/drivers/net/dsa/mt7628.c
> > @@ -0,0 +1,649 @@
> > [ ... ]
> > +static int mt7628_setup_internal_mdio(struct dsa_switch *ds)
> > +{
> > + struct mt7628_esw *esw = ds->priv;
> > + struct device *dev = ds->dev;
> > + struct mii_bus *bus;
> > +
> > + bus = devm_mdiobus_alloc(dev);
> > + if (!bus)
> > + return -ENOMEM;
> > +
> > + bus->name = "MT7628 internal MDIO bus";
> > + snprintf(bus->id, MII_BUS_ID_SIZE, "%s-mii", dev_name(dev));
> > + bus->priv = esw;
> > + bus->read = mt7628_mii_read;
> > + bus->write = mt7628_mii_write;
> > + bus->parent = dev;
> > +
> > + ds->user_mii_bus = bus;
> > + bus->phy_mask = ~ds->phys_mii_mask;
> > +
> > + return devm_mdiobus_register(dev, bus);
> > +}
>
> [Severity: High]
> Does this cause a resource leak and sysfs name collision if the switch setup
> callback runs multiple times?
>
> If the DSA master device unbinds and rebinds, dsa_tree_teardown() and
> dsa_tree_setup() can be triggered again. Because devm_mdiobus_alloc() and
> devm_mdiobus_register() tie the resource to the platform device's lifetime
> rather than the DSA tree setup/teardown cycle, the first registration will
> leak, and the second might fail with -EEXIST.
I am not able to find any code path that would trigger dsa_switch_ops
setup other than through `dsa_register_switch`, which is called in the
platform device probe. That would make it impossible for setup to be
called again without removing the platform device first, which tears
down the mdiobus.
This pattern is used in multiple other DSA drivers. A few examples:
- in NXP NETC priv->dev is sset to the &pci_dev->dev, which is used
in devm_mdiobus_alloc_size().
- in mt7530-mmio priv->dev is set to the &platform_device->dev,
which is then used in devm_mdiobus_alloc().
This seems like an AI review false positive.
> > [ ... ]
> > +static void mt7628_switch_init(struct dsa_switch *ds)
> > +{
> > + struct mt7628_esw *esw = ds->priv;
> > +
> > + regmap_write(esw->regmap, MT7628_ESW_REG_FCT0,
> > + FIELD_PREP(MT7628_ESW_FCT0_DROP_SET_TH, 0x50) |
> > + FIELD_PREP(MT7628_ESW_FCT0_DROP_RLS_TH, 0x78) |
> > + FIELD_PREP(MT7628_ESW_FCT0_FC_SET_TH, 0xa0) |
> > + FIELD_PREP(MT7628_ESW_FCT0_FC_RLS_TH, 0xc8));
>
> [Severity: High]
> Can traffic leak across isolated ports (like WAN and LAN) during boot?
>
> It looks like mt7628_switch_init() resets the switch but fails to explicitly
> set the MT7628_ESW_POC0_PORT_DISABLE bits for the user ports. Since the
> DSA core relies on port_disable during ndo_close and doesn't automatically
> disable ports upon initialization, does the hardware default to acting as
> an unmanaged switch, bridging all networks until the interfaces are brought
> up administratively?
The hardware defaults to an all ports disabled state. Will add this as a
comment in v7.
prev parent reply other threads:[~2026-08-03 19:51 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-04 10:56 [PATCH net-next v6 0/4] net: dsa: mt7628 embedded switch initial support Joris Vaisvila
2026-07-04 10:56 ` [PATCH net-next v6 1/4] dt-bindings: net: dsa: add MT7628 ESW Joris Vaisvila
2026-07-04 10:56 ` [PATCH net-next v6 2/4] net: phy: mediatek: add phy driver for MT7628 built-in Fast Ethernet PHYs Joris Vaisvila
2026-07-04 10:56 ` [PATCH net-next v6 3/4] net: dsa: initial MT7628 tagging driver Joris Vaisvila
2026-07-04 10:56 ` [PATCH net-next v6 4/4] net: dsa: initial support for MT7628 embedded switch Joris Vaisvila
2026-07-05 10:58 ` sashiko-bot
2026-07-20 23:52 ` Jakub Kicinski
2026-08-03 20:55 ` Joris Vaisvila
2026-07-20 23:52 ` Jakub Kicinski
2026-08-03 19:50 ` Joris Vaisvila [this message]
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=anDmcBoebeG-DDXc@archlinux \
--to=joey@tinyisr.com \
--cc=Landen.Chao@mediatek.com \
--cc=andrew@lunn.ch \
--cc=arinc.unal@arinc9.com \
--cc=conor+dt@kernel.org \
--cc=daniel@makrotopia.org \
--cc=davem@davemloft.net \
--cc=devicetree@vger.kernel.org \
--cc=dqfext@gmail.com \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=olteanv@gmail.com \
--cc=pabeni@redhat.com \
--cc=robh@kernel.org \
--cc=sean.wang@mediatek.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