From: netdev-bot+sashiko@kernel.org
To: wanghr2026@mail.zgclab.edu.cn
Cc: chester.a.unal@arinc9.com, daniel@makrotopia.org, andrew@lunn.ch,
olteanv@gmail.com, davem@davemloft.net, edumazet@kernel.org,
kuba@kernel.org, pabeni@redhat.com, matthias.bgg@gmail.com,
angelogioacchino.delregno@collabora.com, netdev@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next v2 5/5] net: dsa: mt7530: disable regulators on mt753x_setup() failure
Date: Fri, 04 Dec 2026 07:51:03 +0000 [thread overview]
Message-ID: <179637066398.3146.16717058703088608275@kernel.org> (raw)
In-Reply-To: <179628050300.1224.2090604648819997374@mail.zgclab.edu.cn>
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 · Low: 0
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] Two changes in mt753x_setup() (drivers/net/dsa/mt7530.c) now
power off the switch through sw_teardown while the GPIO controller is…
--
net: dsa: mt7530: disable regulators on mt753x_setup() failure
This patch sends every failure path in mt753x_setup() that runs after
sw_setup() to a shared error label. That label frees the mdio irq and
turns off the regulators. It also adds a per-variant sw_teardown()
callback, and for the MT7530 variants that callback calls
mt7530_disable_pwrs().
> diff --git a/drivers/net/dsa/mt7530.c b/drivers/net/dsa/mt7530.c
> index 1ae0ca2789690..32cf4a1ce2ace 100644
> --- a/drivers/net/dsa/mt7530.c
> +++ b/drivers/net/dsa/mt7530.c
[ ... ]
> @@ -3232,11 +3240,11 @@ mt753x_setup(struct dsa_switch *ds)
>
> ret = mt7530_setup_irq(priv);
> if (ret)
> - return ret;
> + goto err_disable_pwrs;
>
> ret = mt7530_setup_mdio(priv);
> if (ret)
> - goto err_disable_pwrs;
> + goto err_disable_pwrs;
[Severity: Medium]
Can these two new error paths leave the GPIO controller registered for a
switch that has no power?
By the time mt753x_setup() reaches mt7530_setup_irq(), sw_setup() has
already run. The last thing mt7530_setup() does is register the gpiochip:
drivers/net/dsa/mt7530.c:mt7530_setup() {
...
#ifdef CONFIG_GPIOLIB
if (of_property_read_bool(priv->dev->of_node, "gpio-controller")) {
ret = mt7530_setup_gpio(priv);
if (ret)
goto err_disable_pwrs;
}
...
}
mt7530_setup_gpio() uses devm_gpiochip_add_data(). The gpiochip is
therefore only removed when the switch device's devres unwinds.
mt7530_teardown() does not remove it.
On the mt7530_setup_mdio() failure path, the regmap IRQ chip registered
by devm_regmap_add_irq_chip_fwnode() in mt7530_setup_irq() is also still
live, together with its threaded handler.
mt753x_setup()
sw_setup() == mt7530_setup()
mt7530_setup_gpio()
devm_gpiochip_add_data()
mt7530_setup_irq() fails (for example -EPROBE_DEFER from of_irq_get())
goto err_disable_pwrs
mt7530_teardown()
mt7530_disable_pwrs()
regulator_disable(core_pwr / io_pwr)
The earlier patch in this series, "net: dsa: mt7530: register the GPIO
controller last in setup", moved GPIO registration to the end of
mt7530_setup(). The goal was that the controller would not stay
registered across a failed setup that turns off the regulators. Doesn't
this patch add new failure points after that registration? One of them
is the -EPROBE_DEFER case the commit message calls common.
In a single-switch tree this state only lasts until the failed probe's
devres unwinds.
In a multi-switch tree, dsa_tree_setup() runs from whichever member
probes last. An MT7530 whose own probe already returned 0 would then keep
its devm gpiochip, and possibly its regmap-irq handler, registered while
its core and io rails are off. Any GPIO get/set/direction call would then
do regmap accesses on an unpowered chip.
Before this patch, these paths left the rails on. Only ID_MT7530 is
affected, because mt7530_disable_pwrs() returns early for other ids.
The commit message describes sw_teardown() as "symmetric with
sw_setup()". mt7530_teardown() only undoes the regulator enable, though,
not the gpiochip that sw_setup() registers. Would it make sense either to
unregister the gpiochip (and the regmap irq chip) before cutting power
here, or to keep the regulators on for these paths until devres cleanup
runs?
>
> /* Initialise the PCS devices */
> for (i = 0; i < priv->ds->num_ports; i++) {
[ ... ]
> + return 0;
> +
> +err_free_irq:
> + if (priv->irq_domain)
> + mt7530_free_mdio_irq(priv);
> +err_disable_pwrs:
> + if (priv->info->sw_teardown)
> + priv->info->sw_teardown(ds);
> +
> return ret;
> }
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/179628050300.1224.11499384961750115678%40mail.zgclab.edu.cn
next prev parent reply other threads:[~2026-12-04 7:51 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-03 6:48 [PATCH net-next v2 0/5] net: dsa: mt7530: disable regulators on teardown and setup failure Haoran Wang
2026-12-03 6:48 ` [PATCH net-next v2 2/5] net: dsa: mt7530: factor out mt7530_disable_pwrs() Haoran Wang
2026-12-03 6:48 ` [PATCH net-next v2 5/5] net: dsa: mt7530: disable regulators on mt753x_setup() failure Haoran Wang
2026-12-04 7:51 ` netdev-bot+sashiko [this message]
2026-12-03 6:48 ` [PATCH net-next v2 1/5] net: dsa: mt7530: disable regulators on switch teardown Haoran Wang
2026-12-04 7:51 ` netdev-bot+sashiko
2026-12-03 6:48 ` [PATCH net-next v2 4/5] net: dsa: mt7530: disable regulators on setup failure Haoran Wang
2026-12-03 6:48 ` [PATCH net-next v2 3/5] net: dsa: mt7530: register the GPIO controller last in setup Haoran Wang
2026-12-04 7:51 ` netdev-bot+sashiko
2026-12-03 6:53 ` [PATCH net-next v2 0/5] net: dsa: mt7530: disable regulators on teardown and setup failure netdev-bot+sinfo
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=179637066398.3146.16717058703088608275@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=andrew@lunn.ch \
--cc=angelogioacchino.delregno@collabora.com \
--cc=chester.a.unal@arinc9.com \
--cc=daniel@makrotopia.org \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=matthias.bgg@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=olteanv@gmail.com \
--cc=pabeni@redhat.com \
--cc=wanghr2026@mail.zgclab.edu.cn \
/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