Re: [PATCH v3] net: dsa: mt7530: manage the core and io regulators with devm actions

From: Xiangwu Lai

Date: Mon Nov 23 2026 - 20:39:08 EST


Hi Andrew,

Thanks for the review of "[PATCH v3] net: dsa: mt7530: manage the core
and io regulators with devm actions"
(https://lore.kernel.org/r/20261123022415.433-1-laixiangwu@xxxxxxxxxxxxxxxxxxxx).

> > Move the enables to mt7530_probe(), right after the regulators are
> > acquired
>
> Please add an explanation why this is safe. Since the original code
> did not do this, there might be a reason it is done later.

Done in v4. The short version: nothing accesses the switch between
the enables and dsa_register_switch(). 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, and
mt7530_setup() still releases the reset afterwards, unchanged.
MT7621 has no such supplies (skipped by the ID_MT7530 guards) and the
MT7988 MMIO variant has no regulators at all. I could not find a
reason in the history of b8f126a8d543 why the enables were done in
setup rather than probe - it just grew there when the driver was
originally written.

> This is maybe one case where devm is the wrong solution. Please keep
> with the normal way of doing cleanup.

Understood - v4 drops the devm_add_action_or_reset() calls. The
enables stay in mt7530_probe(), but a later failure now unwinds with
plain error labels, and the explicit disables in mt7530_remove() are
restored. This keeps every failure path balanced: a failed probe
always unwinds (including -EPROBE_DEFER retries), and a switch that
stays bound is disabled exactly once by mt7530_remove().

> > Fixes: b8f126a8d543 ("net-next: dsa: add dsa support for Mediatek MT7530 switch")
>
> Who does this bother?

Honestly: nobody has reported it. I found the leak by code inspection
and have no MT7530 hardware. In-tree, the boards that wire these
supplies are the MT7623 ones (mt7623n-bananapi-bpi-r2 and
mt7623n-rfb-emmc via mt7623a.dtsi), and they connect them to switchable
MT6323 PMIC outputs, so there the leak would keep the supplies on
after a failed probe and trip the WARN_ON(enable_count) in
_regulator_put() when the devm handles are released. It is a
robustness fix rather than a fix for an observed failure. If you
prefer, I am happy to drop the Fixes tag so it does not go to
stable - your call.

v4 is here:
[PATCH v4] net: dsa: mt7530: enable the regulators in probe() and unwind on error
https://lore.kernel.org/r/20261124013422.1408-1-laixiangwu@xxxxxxxxxxxxxxxxxxxx

Best regards,
Xiangwu Lai