Re: [PATCH v4] net: dsa: mt7530: enable the regulators in probe() and unwind on error

From: Xiangwu Lai

Date: Tue Nov 24 2026 - 21:24:41 EST


Hello,

On the review of v4 (Subject: [PATCH v4] net: dsa: mt7530: enable the
regulators in probe() and unwind on error,
https://lore.kernel.org/all/20261124013422.1408-1-laixiangwu@xxxxxxxxxxxxxxxxxxxx/):

> [Severity: Medium]
> Does the safety argument in the commit message hold when the switch is a
> multi-chip module? ... 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 ... The first assert happens in mt7530_setup()
> ... 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.

Both parts of this finding are correct, thank you. I verified:

- On the mcm path mt7530_probe() only calls devm_reset_control_get();
the first reset_control_assert() is at the top of mt7530_setup(),
which only runs from dsa_register_switch(). So on the mcm boards
the chip runs on its power-on defaults between probe and setup.
- The board list in the v4 commit message was wrong.
mt7623n-bananapi-bpi-r2.dts and mt7623n-rfb-emmc.dts include
mt7623n.dtsi and wire the supplies and reset-gpios inline; those
boards are held in reset while the rails come up. The boards that
get mediatek,mcm and the supplies from mt7623a.dtsi are
mt7623a-rfb-emmc.dts and mt7623a-rfb-nand.dts.

V5 with the corrected commit message is out; the diff is unchanged:

[PATCH v5] net: dsa: mt7530: enable the regulators in probe() and unwind on error
https://lore.kernel.org/all/20261125022147.377-1-laixiangwu@xxxxxxxxxxxxxxxxxxxx/

The v5 message now scopes the reset-held argument to the reset-gpios
boards and describes the mcm window as it is, including that it
repeats on -EPROBE_DEFER and is unbounded while a multi-switch tree
waits for its other members.

> [Severity: Low]
> Is this teardown order safe when dsa_register_switch() fails after
> mt753x_setup() has already run? ... 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.

The mechanics are correct: mt7530_setup_irq() registers the IRQ chip
with devm_regmap_add_irq_chip_fwnode() and mt7530_setup_mdio() with
devm_of_mdiobus_register(), both on the mdiodev, and mt753x_teardown()
only cancels stats_work, so those resources do live until
devres_release_all() after the probe returns.

I would scope the practical impact as follows:

- None of the in-tree MT7530 boards that wire the regulators
(mt7623a-rfb-emmc, mt7623a-rfb-nand, mt7623n-bananapi-bpi-r2,
mt7623n-rfb-emmc) wire the switch interrupt, so
mt7530_setup_irq() takes the "no interrupt support" exit and there
is no regmap-irq handler to run in the window.
- The create_sgmii() example path is MT7531, which has no regulators;
the error labels are guarded by priv->id == ID_MT7530 and are no-ops
there.
- devm was deliberately ruled out for this driver per the netdev
maintainer guidance (the disables are plain error labels on
request of the tree owner), so the "register the disables with
devm" suggestion is not an option here.
- mt7530_remove() in the unmodified driver also cuts the supplies
before the devm resources are released, so the probe error path
now mirrors the existing remove order rather than introducing a
brand new shape.

That said, asserting the reset control and releasing the setup
resources before disabling the supplies in the probe error path would
be a cleaner unwind, and I am happy to add it if the maintainers want
it; that is Andrew's call to make.

pw-bot: cr