All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Caleb James DeLisle" <cjd@cjdns.fr>
Cc: devicetree@vger.kernel.org, robh@kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH v2 net-next 5/7] net: dsa: mediatek: support MDIO switch downstream of MMIO switch
Date: Wed, 16 Sep 2026 17:47:46 +0000	[thread overview]
Message-ID: <20260916174746.BBD7E1F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260915174643.253660-6-cjd@cjdns.fr>

Thank you for your contribution! Sashiko AI review found 5 potential issue(s) to consider:
- [Critical] dsa: mt7530: hardware access while in reset causes bus hangs
- [High] dsa: mt7530: PHYs are permanently masked out due to early MDIO setup
- [High] dsa: mt7530: PHY interrupts are broken due to late IRQ assignment
- [Medium] dsa: mt7530: resource leak and silent failure in mt7988_probe()
- [Medium] dsa: mt7530: data race on static idx in unlocked mt7988_probe()
--

commit b6de045bf619c20c22824d1e2470474ed02da7d7
Author: Caleb James DeLisle <cjd@cjdns.fr>
Subject: net: dsa: mediatek: support MDIO switch downstream of MMIO switch

The MT7530 / MT7531 can connect via either MDIO or MMIO. In MMIO mode the
switch provides its own MDIO bus which connects to its integrated PHYs. This
commit updates mt7530_setup_mdio() to be called from mt7988_probe() to allow
downstream switches to register.

> diff --git a/drivers/net/dsa/mt7530-mmio.c b/drivers/net/dsa/mt7530-mmio.c
> index cf3bdb23a2d54..f387190a95391 100644
> --- a/drivers/net/dsa/mt7530-mmio.c
> +++ b/drivers/net/dsa/mt7530-mmio.c
> @@ -61,7 +61,14 @@ mt7988_probe(struct platform_device *pdev)
>  	if (IS_ERR(priv->regmap))
>  		return PTR_ERR(priv->regmap);
>  
> -	return dsa_register_switch(priv->ds);
> +	ret = dsa_register_switch(priv->ds);
> +
> +	if (ret)
> +		return ret;
> +
> +	mt7530_setup_mdio(priv);

[Severity: Critical]
Does calling mt7530_setup_mdio() here access the hardware while the chip is
still held in reset?

If the DSA tree is incomplete, dsa_register_switch() returns 0 without
executing the switch's setup callback, which is normally responsible for
deasserting the hardware reset.

When mt7530_setup_mdio() registers the MDIO bus, it immediately triggers
MDIO read/write operations to probe PHYs. Can this cause invalid data reads
or fatal AXI bus hangs if the chip is still in reset?

[Severity: Medium]
Also, if mt7530_setup_mdio() returns an error (such as -ENOMEM or -ENODEV),
this unconditionally ignores the return value.

Does this allow the driver to bind successfully even if MDIO setup fails, and
leak the successfully registered DSA switch (priv->ds) since
dsa_unregister_switch() is not called on the error path?

> +
> +	return 0;
>  }
>  
>  static void mt7988_remove(struct platform_device *pdev)
> diff --git a/drivers/net/dsa/mt7530.c b/drivers/net/dsa/mt7530.c
> index b152b73315d50..fe93be1ece7d7 100644
> --- a/drivers/net/dsa/mt7530.c
> +++ b/drivers/net/dsa/mt7530.c
[ ... ]
> @@ -2414,6 +2414,10 @@ mt7530_setup_mdio(struct mt7530_priv *priv)
>  	static int idx;
>  	int ret = 0;

[Severity: Medium]
Before this patch, mt7530_setup_mdio() was exclusively called from
mt753x_setup(), which is serialized by the DSA subsystem's dsa2_mutex.

With the new call path in mt7988_probe() executing concurrently outside of
dsa2_mutex, can multiple switches probing concurrently race on the lockless
idx++ increment?

Could this lead to duplicate MDIO bus IDs and sysfs registration failures
here?

mt7530.c:mt7530_setup_mdio() {
    ...
    snprintf(bus->id, MII_BUS_ID_SIZE, KBUILD_MODNAME "-%d", idx++);
    ...
}

> +	/* Already done */
> +	if (priv->child_bus)
> +		return 0;
> +
>  	mnp = of_get_child_by_name(np, "mdio");
>  
>  	if (mnp && !of_device_is_available(mnp))
> @@ -2438,9 +2442,6 @@ mt7530_setup_mdio(struct mt7530_priv *priv)
>  	bus->parent = dev;
>  	bus->phy_mask = ~ds->phys_mii_mask;

[Severity: High]
Since mt7988_probe() calls mt7530_setup_mdio() before the DSA tree is
completed, is ds->phys_mii_mask initialized at this point?

ds->phys_mii_mask is initialized by dsa_switch_setup() only after the tree
completes. Does this mean ds->phys_mii_mask is 0 here, causing bus->phy_mask
to be ~0?

If there are PHYs relying on auto-probing, this mask would cause the MDIO
core to skip probing them entirely. When the tree eventually completes,
mt7530_setup_mdio() will return early due to priv->child_bus already being
set, potentially leaving those PHYs permanently unprobed.

> -	if (priv->irq_domain && !mnp)
> -		mt7530_setup_mdio_irq(priv);
> -
>  	priv->child_bus = bus;
>  
>  	ret = devm_of_mdiobus_register(dev, bus, mnp);
[ ... ]
> @@ -3285,6 +3287,9 @@ mt753x_setup(struct dsa_switch *ds)
>  	if (ret)
>  		return ret;
>  
> +	if (priv->irq_domain && ds->user_mii_bus)
> +		mt7530_setup_mdio_irq(priv);
> +

[Severity: High]
Does moving the mt7530_setup_mdio_irq() call here populate the IRQs too late?

mt7530_setup_mdio() invokes devm_of_mdiobus_register(), which scans the MDIO
bus and creates PHY devices. During creation, the PHY framework copies
bus->irq[addr] into phydev->irq.

Since bus->irq is populated by mt7530_setup_mdio_irq() only after the PHYs
are already instantiated, won't the PHYs receive an initial value of 0
(PHY_POLL), silently breaking interrupt-driven link events?

>  	/* Initialise the PCS devices */
>  	for (i = 0; i < priv->ds->num_ports; i++) {
>  		priv->pcs[i].pcs.ops = priv->info->pcs_ops;

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260915174643.253660-1-cjd@cjdns.fr?part=5

  reply	other threads:[~2026-09-16 17:47 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-15 17:46 [PATCH v2 net-next 0/7] net: dsa: mt7530: support EcoNet EN751221 Caleb James DeLisle
2026-09-15 17:46 ` [PATCH v2 net-next 1/7] net: dsa: mt7530: get ctrl phy addr using a function Caleb James DeLisle
2026-09-17 20:49   ` netdev-bot+sashiko
2026-09-15 17:46 ` [PATCH v2 net-next 2/7] dt-bindings: net: dsa: mediatek,mt7530: add passthrough mode Caleb James DeLisle
2026-09-17 20:49   ` netdev-bot+sashiko
2026-09-24 15:45     ` Rob Herring
2026-09-24 15:45   ` Rob Herring (Arm)
2026-09-15 17:46 ` [PATCH v2 net-next 3/7] net: dsa: mediatek: add support for " Caleb James DeLisle
2026-09-16 17:47   ` sashiko-bot
2026-09-17 20:49   ` netdev-bot+sashiko
2026-09-15 17:46 ` [PATCH v2 net-next 4/7] net: dsa: mediatek: support PLL setup on MMIO MT7530 Caleb James DeLisle
2026-09-17 20:49   ` netdev-bot+sashiko
2026-09-15 17:46 ` [PATCH v2 net-next 5/7] net: dsa: mediatek: support MDIO switch downstream of MMIO switch Caleb James DeLisle
2026-09-16 17:47   ` sashiko-bot [this message]
2026-09-17 20:49   ` netdev-bot+sashiko
2026-09-15 17:46 ` [PATCH v2 net-next 6/7] dt-bindings: net: dsa: mediatek,mt7530: add econet,en751221 Caleb James DeLisle
2026-09-16 17:47   ` sashiko-bot
2026-09-17 20:50   ` netdev-bot+sashiko
2026-09-24 15:49     ` Rob Herring
2026-09-15 17:46 ` [PATCH v2 net-next 7/7] net: dsa: mediatek: support EN751221 switch Caleb James DeLisle
2026-09-16 17:47   ` sashiko-bot
2026-09-17 20:50   ` netdev-bot+sashiko
2026-09-20 10:33   ` Benjamin Larsson
2026-10-09 22:03     ` Cristian Papa

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=20260916174746.BBD7E1F000FF@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=cjd@cjdns.fr \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --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 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.