* [PATCH net-next v2 0/5] net: dsa: mt7530: disable regulators on teardown and setup failure
@ 2026-12-03 6:48 Haoran Wang
2026-12-03 6:48 ` [PATCH net-next v2 2/5] net: dsa: mt7530: factor out mt7530_disable_pwrs() Haoran Wang
` (5 more replies)
0 siblings, 6 replies; 10+ messages in thread
From: Haoran Wang @ 2026-12-03 6:48 UTC (permalink / raw)
To: Chester A. Unal, Daniel Golle, Andrew Lunn, Vladimir Oltean
Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Matthias Brugger, AngeloGioacchino Del Regno, netdev,
linux-arm-kernel, linux-mediatek, linux-kernel
This series fixes MT7530 regulator handling: the core and io regulators
are enabled in mt7530_setup() but were left enabled when the switch is
torn down without the driver being unbound, or when a setup step fails.
It also moves the GPIO controller registration after the FDB flush and
factors out the regulator disable into a helper that is reused on the
error paths.
Changes in v2:
- Target net-next instead of net: the issues are edge cases rather than
regressions reported in the field.
- Keep the regulator_disable() error reporting in the helper (Andrew).
- Add a sw_teardown() callback symmetric with sw_setup() and use it from
mt753x_teardown() and the mt753x_setup() error path (Andrew).
- Fix the Fixes tag on the last patch: the mt753x_setup() failure paths
were added by commit ba751e28d442 ("net: dsa: mt7530: add interrupt
support").
- Add Andrew's Reviewed-by.
Haoran Wang (5):
net: dsa: mt7530: disable regulators on switch teardown
net: dsa: mt7530: factor out mt7530_disable_pwrs()
net: dsa: mt7530: register the GPIO controller last in setup
net: dsa: mt7530: disable regulators on setup failure
net: dsa: mt7530: disable regulators on mt753x_setup() failure
drivers/net/dsa/mt7530-mdio.c | 14 +-----
drivers/net/dsa/mt7530.c | 81 ++++++++++++++++++++++++++++-------
drivers/net/dsa/mt7530.h | 2 +
3 files changed, 68 insertions(+), 29 deletions(-)
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH net-next v2 2/5] net: dsa: mt7530: factor out mt7530_disable_pwrs()
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 ` Haoran Wang
2026-12-03 6:48 ` [PATCH net-next v2 5/5] net: dsa: mt7530: disable regulators on mt753x_setup() failure Haoran Wang
` (4 subsequent siblings)
5 siblings, 0 replies; 10+ messages in thread
From: Haoran Wang @ 2026-12-03 6:48 UTC (permalink / raw)
To: Chester A. Unal, Daniel Golle, Andrew Lunn, Vladimir Oltean
Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Matthias Brugger, AngeloGioacchino Del Regno, netdev,
linux-arm-kernel, linux-mediatek, linux-kernel
Pull the regulator disable out of mt753x_teardown() into a helper so it
can also be used on the setup error paths added in later patches. The
helper keeps reporting regulator_disable() failures, since a failed
disable is worth investigating.
Signed-off-by: Haoran Wang <wanghr2026@mail.zgclab.edu.cn>
---
drivers/net/dsa/mt7530.c | 32 ++++++++++++++++++++------------
1 file changed, 20 insertions(+), 12 deletions(-)
diff --git a/drivers/net/dsa/mt7530.c b/drivers/net/dsa/mt7530.c
index c2f12ae2c6d7..17c62b53ca06 100644
--- a/drivers/net/dsa/mt7530.c
+++ b/drivers/net/dsa/mt7530.c
@@ -2376,6 +2376,25 @@ mt7530_setup_mdio(struct mt7530_priv *priv)
return ret;
}
+static void
+mt7530_disable_pwrs(struct mt7530_priv *priv)
+{
+ int ret;
+
+ if (priv->id != ID_MT7530)
+ return;
+
+ ret = regulator_disable(priv->core_pwr);
+ if (ret < 0)
+ dev_err(priv->dev,
+ "Failed to disable core power: %d\n", ret);
+
+ ret = regulator_disable(priv->io_pwr);
+ if (ret < 0)
+ dev_err(priv->dev, "Failed to disable io pwr: %d\n",
+ ret);
+}
+
static int
mt7530_setup(struct dsa_switch *ds)
{
@@ -3237,22 +3256,11 @@ static void
mt753x_teardown(struct dsa_switch *ds)
{
struct mt7530_priv *priv = ds->priv;
- int ret;
if (priv->bus)
cancel_delayed_work_sync(&priv->stats_work);
- if (priv->id == ID_MT7530) {
- ret = regulator_disable(priv->core_pwr);
- if (ret < 0)
- dev_err(priv->dev,
- "Failed to disable core power: %d\n", ret);
-
- ret = regulator_disable(priv->io_pwr);
- if (ret < 0)
- dev_err(priv->dev, "Failed to disable io pwr: %d\n",
- ret);
- }
+ mt7530_disable_pwrs(priv);
}
static int mt753x_set_mac_eee(struct dsa_switch *ds, int port,
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH net-next v2 1/5] net: dsa: mt7530: disable regulators on switch teardown
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-03 6:48 ` 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
` (2 subsequent siblings)
5 siblings, 1 reply; 10+ messages in thread
From: Haoran Wang @ 2026-12-03 6:48 UTC (permalink / raw)
To: Chester A. Unal, Daniel Golle, Andrew Lunn, Vladimir Oltean
Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Matthias Brugger, AngeloGioacchino Del Regno, netdev,
linux-arm-kernel, linux-mediatek, linux-kernel
mt7530_setup() enables the core and io regulators, so they should be
disabled by the matching teardown callback, not by the driver remove
callback. teardown is the counterpart of setup and runs for every switch
that was successfully set up, whereas remove() only runs when the whole
driver is unbound.
Move the regulator disable from mt7530_remove() to mt753x_teardown(),
after the stats polling work is cancelled so that no poll can run against
an unpowered switch. The regulator_disable() error reporting is kept.
A switch in a multi-switch tree whose sibling fails to set up is torn
down without its driver reaching remove(), so its regulators were left
enabled until now.
Fixes: b8f126a8d543 ("net-next: dsa: add dsa support for Mediatek MT7530 switch")
Signed-off-by: Haoran Wang <wanghr2026@mail.zgclab.edu.cn>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
---
drivers/net/dsa/mt7530-mdio.c | 14 +-------------
drivers/net/dsa/mt7530.c | 13 +++++++++++++
2 files changed, 14 insertions(+), 13 deletions(-)
diff --git a/drivers/net/dsa/mt7530-mdio.c b/drivers/net/dsa/mt7530-mdio.c
index e85ef2aceee5..faefbcad293f 100644
--- a/drivers/net/dsa/mt7530-mdio.c
+++ b/drivers/net/dsa/mt7530-mdio.c
@@ -227,23 +227,11 @@ static void
mt7530_remove(struct mdio_device *mdiodev)
{
struct mt7530_priv *priv = dev_get_drvdata(&mdiodev->dev);
- int ret = 0, i;
+ int i;
if (!priv)
return;
- if (priv->id == ID_MT7530) {
- ret = regulator_disable(priv->core_pwr);
- if (ret < 0)
- dev_err(priv->dev,
- "Failed to disable core power: %d\n", ret);
-
- ret = regulator_disable(priv->io_pwr);
- if (ret < 0)
- dev_err(priv->dev, "Failed to disable io pwr: %d\n",
- ret);
- }
-
mt7530_remove_common(priv);
for (i = 0; i < 2; ++i)
diff --git a/drivers/net/dsa/mt7530.c b/drivers/net/dsa/mt7530.c
index d5a199293f78..c2f12ae2c6d7 100644
--- a/drivers/net/dsa/mt7530.c
+++ b/drivers/net/dsa/mt7530.c
@@ -3237,9 +3237,22 @@ static void
mt753x_teardown(struct dsa_switch *ds)
{
struct mt7530_priv *priv = ds->priv;
+ int ret;
if (priv->bus)
cancel_delayed_work_sync(&priv->stats_work);
+
+ if (priv->id == ID_MT7530) {
+ ret = regulator_disable(priv->core_pwr);
+ if (ret < 0)
+ dev_err(priv->dev,
+ "Failed to disable core power: %d\n", ret);
+
+ ret = regulator_disable(priv->io_pwr);
+ if (ret < 0)
+ dev_err(priv->dev, "Failed to disable io pwr: %d\n",
+ ret);
+ }
}
static int mt753x_set_mac_eee(struct dsa_switch *ds, int port,
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH net-next v2 3/5] net: dsa: mt7530: register the GPIO controller last in setup
2026-12-03 6:48 [PATCH net-next v2 0/5] net: dsa: mt7530: disable regulators on teardown and setup failure Haoran Wang
` (3 preceding siblings ...)
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 ` 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
5 siblings, 1 reply; 10+ messages in thread
From: Haoran Wang @ 2026-12-03 6:48 UTC (permalink / raw)
To: Chester A. Unal, Daniel Golle, Andrew Lunn, Vladimir Oltean
Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Matthias Brugger, AngeloGioacchino Del Regno, netdev,
linux-arm-kernel, linux-mediatek, linux-kernel
mt7530_setup_gpio() publishes a GPIO controller that userspace and other
drivers can use immediately, but it currently runs before the FDB flush,
the last fallible step of mt7530_setup().
Move the GPIO controller registration after the FDB flush so that the
controller is not published when mt7530_setup() fails. This matters from
the next patch on, where a failed mt7530_setup() disables the regulators
and returns an error, and the controller must not be registered across a
failed setup.
Signed-off-by: Haoran Wang <wanghr2026@mail.zgclab.edu.cn>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
---
drivers/net/dsa/mt7530.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/net/dsa/mt7530.c b/drivers/net/dsa/mt7530.c
index 17c62b53ca06..e784123fb79c 100644
--- a/drivers/net/dsa/mt7530.c
+++ b/drivers/net/dsa/mt7530.c
@@ -2594,6 +2594,11 @@ mt7530_setup(struct dsa_switch *ds)
}
}
+ /* Flush the FDB table */
+ ret = mt7530_fdb_cmd(priv, MT7530_FDB_FLUSH, NULL);
+ if (ret < 0)
+ return ret;
+
#ifdef CONFIG_GPIOLIB
if (of_property_read_bool(priv->dev->of_node, "gpio-controller")) {
ret = mt7530_setup_gpio(priv);
@@ -2602,11 +2607,6 @@ mt7530_setup(struct dsa_switch *ds)
}
#endif /* CONFIG_GPIOLIB */
- /* Flush the FDB table */
- ret = mt7530_fdb_cmd(priv, MT7530_FDB_FLUSH, NULL);
- if (ret < 0)
- return ret;
-
return 0;
}
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH net-next v2 5/5] net: dsa: mt7530: disable regulators on mt753x_setup() failure
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 ` Haoran Wang
2026-12-04 7:51 ` netdev-bot+sashiko
2026-12-03 6:48 ` [PATCH net-next v2 1/5] net: dsa: mt7530: disable regulators on switch teardown Haoran Wang
` (3 subsequent siblings)
5 siblings, 1 reply; 10+ messages in thread
From: Haoran Wang @ 2026-12-03 6:48 UTC (permalink / raw)
To: Chester A. Unal, Daniel Golle, Andrew Lunn, Vladimir Oltean
Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Matthias Brugger, AngeloGioacchino Del Regno, netdev,
linux-arm-kernel, linux-mediatek, linux-kernel
mt753x_setup() calls the per-variant sw_setup() (mt7530_setup() for the
MT7530), which enables the regulators, but the steps that follow returned
on error without disabling them. The common case is mt7530_setup_irq()
returning -EPROBE_DEFER, which leaves the rails on and re-enables them on
every re-probe.
Route all failure paths after sw_setup() to a shared error label that
frees the mdio irq and disables the regulators, and add a sw_teardown()
callback symmetric with sw_setup() so that disabling goes through the
same per-variant hook as enabling. For the MT7530 variants the callback
disables the core and io regulators.
Fixes: ba751e28d442 ("net: dsa: mt7530: add interrupt support")
Signed-off-by: Haoran Wang <wanghr2026@mail.zgclab.edu.cn>
---
drivers/net/dsa/mt7530.c | 32 ++++++++++++++++++++++++++------
drivers/net/dsa/mt7530.h | 2 ++
2 files changed, 28 insertions(+), 6 deletions(-)
diff --git a/drivers/net/dsa/mt7530.c b/drivers/net/dsa/mt7530.c
index 1ae0ca278969..32cf4a1ce2ac 100644
--- a/drivers/net/dsa/mt7530.c
+++ b/drivers/net/dsa/mt7530.c
@@ -2395,6 +2395,14 @@ mt7530_disable_pwrs(struct mt7530_priv *priv)
ret);
}
+static void
+mt7530_teardown(struct dsa_switch *ds)
+{
+ struct mt7530_priv *priv = ds->priv;
+
+ mt7530_disable_pwrs(priv);
+}
+
static int
mt7530_setup(struct dsa_switch *ds)
{
@@ -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)
- return ret;
+ goto err_disable_pwrs;
/* Initialise the PCS devices */
for (i = 0; i < priv->ds->num_ports; i++) {
@@ -3248,15 +3256,24 @@ mt753x_setup(struct dsa_switch *ds)
if (priv->create_sgmii)
ret = priv->create_sgmii(priv);
- if (ret && priv->irq_domain)
- mt7530_free_mdio_irq(priv);
+ if (ret)
+ goto err_free_irq;
- if (!ret && priv->bus) {
+ if (priv->bus) {
mt7530_stats_refresh(priv);
schedule_delayed_work(&priv->stats_work,
MT7530_STATS_POLL_INTERVAL);
}
+ 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;
}
@@ -3268,7 +3285,8 @@ mt753x_teardown(struct dsa_switch *ds)
if (priv->bus)
cancel_delayed_work_sync(&priv->stats_work);
- mt7530_disable_pwrs(priv);
+ if (priv->info->sw_teardown)
+ priv->info->sw_teardown(ds);
}
static int mt753x_set_mac_eee(struct dsa_switch *ds, int port,
@@ -3484,6 +3502,7 @@ const struct mt753x_info mt753x_table[] = {
.id = ID_MT7621,
.pcs_ops = &mt7530_pcs_ops,
.sw_setup = mt7530_setup,
+ .sw_teardown = mt7530_teardown,
.phy_read_c22 = mt7530_phy_read_c22,
.phy_write_c22 = mt7530_phy_write_c22,
.phy_read_c45 = mt7530_phy_read_c45,
@@ -3495,6 +3514,7 @@ const struct mt753x_info mt753x_table[] = {
.id = ID_MT7530,
.pcs_ops = &mt7530_pcs_ops,
.sw_setup = mt7530_setup,
+ .sw_teardown = mt7530_teardown,
.phy_read_c22 = mt7530_phy_read_c22,
.phy_write_c22 = mt7530_phy_write_c22,
.phy_read_c45 = mt7530_phy_read_c45,
diff --git a/drivers/net/dsa/mt7530.h b/drivers/net/dsa/mt7530.h
index 2bbbe617b52e..c413a3836ff5 100644
--- a/drivers/net/dsa/mt7530.h
+++ b/drivers/net/dsa/mt7530.h
@@ -853,6 +853,7 @@ struct mt753x_pcs {
* @id: Holding the identifier to a switch model
* @pcs_ops: Holding the pointer to the MAC PCS operations structure
* @sw_setup: Holding the handler to a device initialization
+ * @sw_teardown: Holding the handler to a device deinitialization
* @phy_read_c22: Holding the way reading PHY port using C22
* @phy_write_c22: Holding the way writing PHY port using C22
* @phy_read_c45: Holding the way reading PHY port using C45
@@ -867,6 +868,7 @@ struct mt753x_info {
const struct phylink_pcs_ops *pcs_ops;
int (*sw_setup)(struct dsa_switch *ds);
+ void (*sw_teardown)(struct dsa_switch *ds);
int (*phy_read_c22)(struct mt7530_priv *priv, int port, int regnum);
int (*phy_write_c22)(struct mt7530_priv *priv, int port, int regnum,
u16 val);
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH net-next v2 4/5] net: dsa: mt7530: disable regulators on setup failure
2026-12-03 6:48 [PATCH net-next v2 0/5] net: dsa: mt7530: disable regulators on teardown and setup failure Haoran Wang
` (2 preceding siblings ...)
2026-12-03 6:48 ` [PATCH net-next v2 1/5] net: dsa: mt7530: disable regulators on switch teardown Haoran Wang
@ 2026-12-03 6:48 ` 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-03 6:53 ` [PATCH net-next v2 0/5] net: dsa: mt7530: disable regulators on teardown and setup failure netdev-bot+sinfo
5 siblings, 0 replies; 10+ messages in thread
From: Haoran Wang @ 2026-12-03 6:48 UTC (permalink / raw)
To: Chester A. Unal, Daniel Golle, Andrew Lunn, Vladimir Oltean
Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Matthias Brugger, AngeloGioacchino Del Regno, netdev,
linux-arm-kernel, linux-mediatek, linux-kernel
Once the core and io regulators have been enabled, every later failure
in mt7530_setup() returned without disabling them, leaving the rails
enabled and making the regulator core warn when devres later puts an
enabled regulator.
Route those failure paths to a common error label that disables both
regulators, and disable the already enabled core regulator if enabling
the io regulator fails.
Fixes: b8f126a8d543 ("net-next: dsa: add dsa support for Mediatek MT7530 switch")
Signed-off-by: Haoran Wang <wanghr2026@mail.zgclab.edu.cn>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
---
drivers/net/dsa/mt7530.c | 22 +++++++++++++++-------
1 file changed, 15 insertions(+), 7 deletions(-)
diff --git a/drivers/net/dsa/mt7530.c b/drivers/net/dsa/mt7530.c
index e784123fb79c..1ae0ca278969 100644
--- a/drivers/net/dsa/mt7530.c
+++ b/drivers/net/dsa/mt7530.c
@@ -2444,6 +2444,7 @@ mt7530_setup(struct dsa_switch *ds)
if (ret < 0) {
dev_err(priv->dev, "Failed to enable io pwr: %d\n",
ret);
+ regulator_disable(priv->core_pwr);
return ret;
}
}
@@ -2466,20 +2467,22 @@ mt7530_setup(struct dsa_switch *ds)
val != 0, 20, 1000000);
if (ret < 0) {
dev_err(priv->dev, "reset timeout\n");
- return ret;
+ goto err_disable_pwrs;
}
regmap_read(priv->regmap, MT7530_CREV, &id);
id = FIELD_GET(CHIP_NAME_MASK, id);
if (id != MT7530_ID) {
dev_err(priv->dev, "chip %x can't be supported\n", id);
- return -ENODEV;
+ ret = -ENODEV;
+ goto err_disable_pwrs;
}
if ((val & MT7530_XTAL_MASK) == MT7530_XTAL_20MHZ) {
dev_err(priv->dev,
"MT7530 with a 20MHz XTAL is not supported!\n");
- return -EINVAL;
+ ret = -EINVAL;
+ goto err_disable_pwrs;
}
/* Reset the switch through internal reset */
@@ -2546,7 +2549,7 @@ mt7530_setup(struct dsa_switch *ds)
/* Setup VLAN ID 0 for VLAN-unaware bridges */
ret = mt7530_setup_vlan0(priv);
if (ret)
- return ret;
+ goto err_disable_pwrs;
/* Check for PHY muxing on port 5 */
if (dsa_is_unused_port(ds, 5)) {
@@ -2573,7 +2576,7 @@ mt7530_setup(struct dsa_switch *ds)
if (ret && ret != -ENODEV) {
of_node_put(mac_np);
of_node_put(phy_node);
- return ret;
+ goto err_disable_pwrs;
}
id = of_mdio_parse_addr(ds->dev, phy_node);
if (id == 0)
@@ -2597,17 +2600,22 @@ mt7530_setup(struct dsa_switch *ds)
/* Flush the FDB table */
ret = mt7530_fdb_cmd(priv, MT7530_FDB_FLUSH, NULL);
if (ret < 0)
- return ret;
+ goto err_disable_pwrs;
#ifdef CONFIG_GPIOLIB
if (of_property_read_bool(priv->dev->of_node, "gpio-controller")) {
ret = mt7530_setup_gpio(priv);
if (ret)
- return ret;
+ goto err_disable_pwrs;
}
#endif /* CONFIG_GPIOLIB */
return 0;
+
+err_disable_pwrs:
+ mt7530_disable_pwrs(priv);
+
+ return ret;
}
static int
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH net-next v2 0/5] net: dsa: mt7530: disable regulators on teardown and setup failure
2026-12-03 6:48 [PATCH net-next v2 0/5] net: dsa: mt7530: disable regulators on teardown and setup failure Haoran Wang
` (4 preceding siblings ...)
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-03 6:53 ` netdev-bot+sinfo
5 siblings, 0 replies; 10+ messages in thread
From: netdev-bot+sinfo @ 2026-12-03 6:53 UTC (permalink / raw)
To: Haoran Wang
Cc: Chester A. Unal, Daniel Golle, Andrew Lunn, Vladimir Oltean,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Matthias Brugger, AngeloGioacchino Del Regno, netdev,
linux-arm-kernel, linux-mediatek, linux-kernel
Hi!
This is an automated message. This series looks like a fix, but its
commit messages seem to be missing some information:
- How the issue was discovered, e.g. hit in production, hit during
development, syzbot report, manual code inspection, LLM or static
analysis tool scan.
- Whether the issue was actually triggered, or is only theoretical
(e.g. found by LLM and not proven at runtime). If it was triggered
please include the symptoms, like the stack trace or kernel messages.
Please do not repost the series just to address the above. Instead,
reply to this email with the missing information, so that reviewers
can take it into account.
*IMPORTANT*: If you do repost (for other reasons) - please include
the relevant info in the cover letter or commit messages.
--
The evaluation is done by an LLM so it may be wrong, if you think
that is the case please reply and explain.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH net-next v2 1/5] net: dsa: mt7530: disable regulators on switch teardown
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
0 siblings, 0 replies; 10+ messages in thread
From: netdev-bot+sashiko @ 2026-12-04 7:51 UTC (permalink / raw)
To: wanghr2026
Cc: chester.a.unal, daniel, andrew, olteanv, davem, edumazet, kuba,
pabeni, matthias.bgg, angelogioacchino.delregno, netdev,
linux-arm-kernel, linux-mediatek, linux-kernel
Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.
Low priority / nit picks for your consideration:
- [Low] mt753x_teardown() (drivers/net/dsa/mt7530.c) now turns off the
MT7530 core and io regulators (regulator_disable(priv->core_pwr) /…
--
net: dsa: mt7530: disable regulators on switch teardown
This moves the MT7530 core and io regulator disable from mt7530_remove()
to mt753x_teardown(), after the stats polling work is cancelled. The aim
is to turn off the regulators of a switch that is torn down because a
sibling in a multi-switch tree failed setup.
> diff --git a/drivers/net/dsa/mt7530.c b/drivers/net/dsa/mt7530.c
> index d5a199293f78a..c2f12ae2c6d7b 100644
> --- a/drivers/net/dsa/mt7530.c
> +++ b/drivers/net/dsa/mt7530.c
> @@ -3237,9 +3237,22 @@ static void
> mt753x_teardown(struct dsa_switch *ds)
> {
> struct mt7530_priv *priv = ds->priv;
> + int ret;
>
> if (priv->bus)
> cancel_delayed_work_sync(&priv->stats_work);
> +
> + if (priv->id == ID_MT7530) {
> + ret = regulator_disable(priv->core_pwr);
> + if (ret < 0)
> + dev_err(priv->dev,
> + "Failed to disable core power: %d\n", ret);
> +
> + ret = regulator_disable(priv->io_pwr);
> + if (ret < 0)
> + dev_err(priv->dev, "Failed to disable io pwr: %d\n",
> + ret);
> + }
> }
[Severity: Low]
Is it safe to cut power here while resources registered by mt753x_setup()
are still live?
stats_work is the only thing stopped before the regulators go off. The
regmap IRQ chip, the internal MDIO bus and the GPIO controller are all
devm-managed. They are only released when the driver unbinds:
mt7530_setup_irq():
ret = devm_regmap_add_irq_chip_fwnode(dev, dev_fwnode(dev),
priv->regmap, irq, ...
mt7530_setup_mdio():
ret = devm_of_mdiobus_register(dev, bus, mnp);
mt7530_setup_gpio():
return devm_gpiochip_add_data(dev, gc, priv);
The commit message describes a case where a sibling switch fails setup and
the tree is torn down:
dsa_tree_setup()
dsa_tree_teardown_switches()
dsa_switch_teardown()
ds->ops->teardown()
mt753x_teardown()
Here the MT7530 probe has already returned 0, so mt7530_remove() never
runs. The device stays bound and the chip has no power, but the parent IRQ
handler, the MDIO bus (mt753x_phy_read_c22() and related accessors) and
the GPIO chip are all still registered. Before this patch the rails stayed
on in this state.
mt7530_setup_irq() sets TOP_SIG_CTRL_NORMAL so the chip drives its INT
pin. If that line floats or reads as asserted after power is removed,
regmap_irq_thread() would read and ack MT7530_SYS_INT_STS over MDIO on an
unpowered device. The nested PHY IRQs were already freed during port
teardown. Could this keep returning IRQ_NONE until the IRQ core reports
"nobody cared" and disables the line?
Anything still using the GPIO chip (for example gpio-leds on the switch
LED pins) would also read garbage or have its writes lost.
The commit message gives this reason for the ordering:
"after the stats polling work is cancelled so that no poll can run
against an unpowered switch"
That covers stats_work, but not the IRQ thread, the MDIO bus or the GPIO
chip. Setup powers the chip on and then registers these. Teardown powers
it off while they are still registered.
A later patch in the series, "net: dsa: mt7530: register the GPIO
controller last in setup", says the GPIO controller must not stay
registered across a powered-off failed setup. The same state seems to
exist after teardown here.
The final patch in the series, "net: dsa: mt7530: disable regulators on
mt753x_setup() failure", moves the disable into sw_teardown() but keeps
the same order. So this seems to still be present at the end of the
series.
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/179628050300.1224.11499384961750115678%40mail.zgclab.edu.cn
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH net-next v2 3/5] net: dsa: mt7530: register the GPIO controller last in setup
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
0 siblings, 0 replies; 10+ messages in thread
From: netdev-bot+sashiko @ 2026-12-04 7:51 UTC (permalink / raw)
To: wanghr2026
Cc: chester.a.unal, daniel, andrew, olteanv, davem, edumazet, kuba,
pabeni, matthias.bgg, angelogioacchino.delregno, netdev,
linux-arm-kernel, linux-mediatek, linux-kernel
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 2 · 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] mt7530_setup_gpio() allocates the gpio_chip with
devm_kzalloc_obj(priv->dev) and registers it with…
- [Medium] net: dsa: mt7530: GPIO controller registered before
mt753x_setup() finishes
--
net: dsa: mt7530: register the GPIO controller last in setup
This patch moves the GPIO controller registration in mt7530_setup() after
the FDB flush. With that order the controller is not published when
mt7530_setup() itself fails. The commit message says this is needed for
the next patch, where a failed setup disables the regulators.
> diff --git a/drivers/net/dsa/mt7530.c b/drivers/net/dsa/mt7530.c
> index 17c62b53ca062..e784123fb79ce 100644
> --- a/drivers/net/dsa/mt7530.c
> +++ b/drivers/net/dsa/mt7530.c
> @@ -2594,6 +2594,11 @@ mt7530_setup(struct dsa_switch *ds)
> }
> }
>
> + /* Flush the FDB table */
> + ret = mt7530_fdb_cmd(priv, MT7530_FDB_FLUSH, NULL);
> + if (ret < 0)
> + return ret;
> +
> #ifdef CONFIG_GPIOLIB
> if (of_property_read_bool(priv->dev->of_node, "gpio-controller")) {
> ret = mt7530_setup_gpio(priv);
[Severity: Medium]
mt7530_setup() is only the priv->info->sw_setup() step of
mt753x_setup(). After sw_setup() returns 0, mt753x_setup() still runs
two fallible steps, mt7530_setup_irq() and mt7530_setup_mdio(), so the
GPIO controller is not actually registered last in setup.
If either of those fails, mt753x_setup() returns an error and
dsa_switch_setup() jumps to unregister_notifier without calling
ds->ops->teardown(). Nothing unregisters the gpiochip that
mt7530_setup_gpio() added with devm_gpiochip_add_data(), so
mt7530_gpio_get(), mt7530_gpio_set() and the direction callbacks stay
reachable from /dev/gpiochipN and from in-kernel consumers.
Once the later patch in this series sends the mt7530_setup_irq() and
mt7530_setup_mdio() failures to mt7530_disable_pwrs(), the core_pwr and
io_pwr regulators are switched off while that controller is still
published. mt7530_setup_irq() getting -EPROBE_DEFER from of_irq_get()
is a realistic way to get there.
With a single switch the probe failure eventually releases devres. In a
multi-switch tree, where mt7530_probe() has already returned 0, the
chip stays registered until unbind, and a retried dsa_tree_setup()
would call devm_gpiochip_add_data() a second time on the same device.
Doesn't this leave the guarantee described in the commit message only
half met? Would it make sense to register the GPIO controller from
mt753x_setup() after mt7530_setup_mdio() succeeds, or to remove it
explicitly on those error paths before the regulators are disabled?
[Severity: Medium]
Does this reordering fully meet the goal in the commit message, that "the
controller must not be registered across a failed setup"?
mt7530_setup_gpio() registers the chip through devres on priv->dev:
drivers/net/dsa/mt7530.c:mt7530_setup_gpio() {
...
return devm_gpiochip_add_data(dev, gc, priv);
}
So the gpiochip lives until driver unbind, not until DSA teardown.
mt753x_teardown() powers the switch down but does not unregister the
gpiochip:
mt7530_disable_pwrs(priv);
DSA can call ->teardown while the driver stays bound. One case is when a
step after ops->setup fails in dsa_switch_setup(), for example
dsa_switch_setup_tag_protocol() or the user_mii_bus allocation or
mdiobus_register():
net/dsa/dsa.c:dsa_switch_setup() {
...
teardown:
if (ds->ops->teardown)
ds->ops->teardown(ds);
...
}
Another case is when a sibling switch fails in dsa_tree_setup_switches().
Switches that already set up successfully are then unwound:
err = dsa_switch_setup(dp->ds);
if (err) {
dsa_tree_teardown_switches(dst);
In both cases mt7530_setup() has returned 0 and the gpiochip is
registered. The switch is then powered off while the GPIO controller is
still published.
If the tree is set up again, would mt7530_setup() call
devm_gpiochip_add_data() a second time on the same device? That would
leave two "mt7530" gpiochips for the same fwnode, with the stale one held
until unbind.
Since the devm registration is tied to the device rather than to
setup/teardown, can reordering calls inside mt7530_setup() alone keep the
controller from staying registered across these failed DSA-level setups?
> if (ret)
> @@ -2602,11 +2607,6 @@ mt7530_setup(struct dsa_switch *ds)
> }
> #endif /* CONFIG_GPIOLIB */
>
> - /* Flush the FDB table */
> - ret = mt7530_fdb_cmd(priv, MT7530_FDB_FLUSH, NULL);
> - if (ret < 0)
> - return ret;
> -
> return 0;
> }
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/179628050300.1224.11499384961750115678%40mail.zgclab.edu.cn
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH net-next v2 5/5] net: dsa: mt7530: disable regulators on mt753x_setup() failure
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
0 siblings, 0 replies; 10+ messages in thread
From: netdev-bot+sashiko @ 2026-12-04 7:51 UTC (permalink / raw)
To: wanghr2026
Cc: chester.a.unal, daniel, andrew, olteanv, davem, edumazet, kuba,
pabeni, matthias.bgg, angelogioacchino.delregno, netdev,
linux-arm-kernel, linux-mediatek, linux-kernel
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
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2026-12-04 7:51 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox