From: netdev-bot+sashiko@kernel.org
To: laixiangwu@cmss.chinamobile.com
Cc: chester.a.unal@arinc9.com, daniel@makrotopia.org, andrew@lunn.ch,
olteanv@gmail.com, sean.wang@mediatek.com,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
netdev-bot+sashiko@kernel.org, kuba@kernel.org
Subject: Re: [PATCH v4] net: dsa: mt7530: enable the regulators in probe() and unwind on error
Date: Wed, 25 Nov 2026 01:34:59 +0000 [thread overview]
Message-ID: <179557049962.3135.7449288288799250763@kernel.org> (raw)
In-Reply-To: <20261124013422.1408-1-laixiangwu@cmss.chinamobile.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] The commit message's safety argument for enabling the supplies
early in mt7530_probe() does not hold on the in-tree boards that run…
- [Low] The new error labels in mt7530_probe()
(err_disable_powers/err_disable_core_pwr, lines 247-253) cut the core…
--
net: dsa: mt7530: enable the regulators in probe() and unwind on error
This moves the MT7530 core and io regulator enables from mt7530_setup()
into mt7530_probe(). It also adds error labels that disable the supplies
again if regmap init or dsa_register_switch() fails. The aim is to stop a
failed or deferred probe from leaving the regulators enabled.
Link: https://lore.kernel.org/r/20261123022415.433-1-laixiangwu@cmss.chinamobile.com
> diff --git a/drivers/net/dsa/mt7530-mdio.c b/drivers/net/dsa/mt7530-mdio.c
> index e85ef2aceee56..2de5e26edad61 100644
> --- a/drivers/net/dsa/mt7530-mdio.c
> +++ b/drivers/net/dsa/mt7530-mdio.c
> @@ -209,18 +209,50 @@ mt7530_probe(struct mdio_device *mdiodev)
> priv->io_pwr = devm_regulator_get(&mdiodev->dev, "io");
> if (IS_ERR(priv->io_pwr))
> return PTR_ERR(priv->io_pwr);
> +
> + regulator_set_voltage(priv->core_pwr, 1000000, 1000000);
> + ret = regulator_enable(priv->core_pwr);
> + if (ret < 0) {
> + dev_err(&mdiodev->dev,
> + "Failed to enable core power: %d\n", ret);
> + return ret;
> + }
> +
> + regulator_set_voltage(priv->io_pwr, 3300000, 3300000);
> + ret = regulator_enable(priv->io_pwr);
> + if (ret < 0) {
> + dev_err(&mdiodev->dev,
> + "Failed to enable io pwr: %d\n", ret);
> + goto err_disable_core_pwr;
> + }
> }
[Severity: Medium]
Does the safety argument in the commit message hold when the switch is a
multi-chip module? The commit message says:
the reset line has been asserted since it was acquired in
mt7530_probe() with GPIOD_OUT_LOW, so the rails come up while the
chip is held in reset
When mediatek,mcm is set there is no reset GPIO. mt7530_probe() only gets
a handle to the reset control, and getting the handle does not assert it:
if (priv->mcm) {
...
priv->rstc = devm_reset_control_get(&mdiodev->dev, "mcm");
The first assert happens in mt7530_setup(). That function only runs from
dsa_register_switch() during tree setup:
if (priv->mcm) {
reset_control_assert(priv->rstc);
usleep_range(5000, 5100);
reset_control_deassert(priv->rstc);
With this patch the switch is powered, out of reset and running on its
power-on defaults from probe until mt7530_setup() runs. Before the patch,
the reset pulse came right after the enables.
The window now covers all of dsa_register_switch() up to setup. It
repeats on every -EPROBE_DEFER retry. It can also last indefinitely when
dsa_register_switch() returns 0 for a multi-switch tree that is not yet
complete.
Non-MCM boards without reset-gpios are affected the same way, because
devm_gpiod_get_optional() returns NULL there.
The list of affected boards also looks wrong:
The in-tree boards that wire these supplies (the MT7623 boards
mt7623n-bananapi-bpi-r2 and mt7623n-rfb-emmc via mt7623a.dtsi)
mt7623n-bananapi-bpi-r2.dts and mt7623n-rfb-emmc.dts include mt7623n.dtsi,
not mt7623a.dtsi. They set reset-gpios and the supplies inline.
The boards that get mediatek,mcm plus core-supply and io-supply from
mt7623a.dtsi are mt7623a-rfb-emmc.dts and mt7623a-rfb-nand.dts. Those are
the boards where the chip is not held in reset while the rails come up.
Could the commit message be corrected? Is the longer powered but
unconfigured window on these boards intended?
>
> rc.lock_arg = &priv->bus->mdio_lock;
[ ... ]
> - return dsa_register_switch(priv->ds);
> + ret = dsa_register_switch(priv->ds);
> + if (ret)
> + goto err_disable_powers;
> +
> + return 0;
> +
> +err_disable_powers:
> + if (priv->id == ID_MT7530)
> + regulator_disable(priv->io_pwr);
> +
> +err_disable_core_pwr:
> + if (priv->id == ID_MT7530)
> + regulator_disable(priv->core_pwr);
> +
> + return ret;
> }
[Severity: Low]
Is this teardown order safe when dsa_register_switch() fails after
mt753x_setup() has already run? Some ways this can happen:
- mt7530_setup_mdio() returns -EPROBE_DEFER after the IRQ chip was
added
- create_sgmii fails
- a later step in the DSA core fails
In that case, devm resources created during setup are still registered
on mdiodev->dev:
mt7530_setup_irq()
devm_regmap_add_irq_chip_fwnode(...)
mt7530_setup_mdio()
devm_of_mdiobus_register(dev, bus, mnp)
mt753x_teardown() only cancels stats_work. The IRQ chip and the internal
MDIO bus are therefore released by devres_release_all() after
mt7530_probe() returns, which is after these labels have already cut the
supplies.
If the threaded regmap-irq handler runs in that window, it reads
MT7530_SYS_INT_STS from an unpowered chip.
mt7530_setup() has also already deasserted the reset with
gpiod_set_value_cansleep(priv->reset, 1). Nothing reasserts it before
power is removed here.
Would it help to register the disables with devm right after the
enables? The other option is to reassert reset and release the setup
resources before disabling the supplies.
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261124013422.1408-1-laixiangwu%40cmss.chinamobile.com
prev parent reply other threads:[~2026-11-25 1:35 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-24 1:34 Xiangwu Lai
2026-11-25 1:34 ` netdev-bot+sashiko [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=179557049962.3135.7449288288799250763@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=andrew@lunn.ch \
--cc=chester.a.unal@arinc9.com \
--cc=daniel@makrotopia.org \
--cc=kuba@kernel.org \
--cc=laixiangwu@cmss.chinamobile.com \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=olteanv@gmail.com \
--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
all inboxes | Powered by JetHome®