Article View: linux.kernel.netdev
Article #21746Re: [PATCH v2] net: dsa: mt7530: disable the power rails on setup failure
From: netdev-bot+sashiko
Date: Tue, 24 Nov 2026 12:05
Date: Tue, 24 Nov 2026 12:05
168 lines
14149 bytes
14149 bytes
Thank you for your contribution! Sashiko AI review found 3 potential
issue(s) to consider.
Critical: 0 · High: 1 · Medium: 0 · Low: 2
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).
- [High] The commit message says moving mt7530_setup_gpio() after the FDB
flush means "the gpiochip is not left registered when the rails are…
- [Low] The patch fixes a runtime bug: regulators stay enabled on
mt7530_setup()/mt753x_setup() failure, enable_count grows on each…
- [Low] The new power-down helper mt7530_disable_pwrs() drops core_pwr
and io_pwr without first asserting the chip reset.
--
net: dsa: mt7530: disable the power rails on setup failure
This patch moves the MT7530 core/io regulator disable out of
mt7530_remove(). The rails are now disabled in mt753x_teardown() and on
the mt7530_setup()/mt753x_setup() error paths. It also moves
mt7530_setup_gpio() after the FDB flush in mt7530_setup().
> Signed-off-by: Haoran Wang <wanghr2026@mail.zgclab.edu.cn>
[Severity: Low]
This fixes a regulator core WARN and an unbalanced regulator_disable() in
mt7530_remove(), but there is no Fixes: tag.
git blame shows that the regulator_enable() calls in mt7530_setup(), with
their bare return ret error paths, come from:
ddda1ac116c8 ("net: dsa: mt7530: support the 7530 switch on the Mediatek MT7621 SoC")
That commit restructured code first added in:
b8f126a8d543 ("net-next: dsa: add dsa support for Mediatek MT7530 switch")
Should one of these be added as a Fixes: tag? The recent fix to the same
regulator handling, c2cdef41e0b4 ("net: dsa: mt7530: fix NULL dereference
on unbind of MT7531 and MT7621"), carries one.
> diff --git a/drivers/net/dsa/mt7530.c b/drivers/net/dsa/mt7530.c
> index d5a199293f78a..5bbeed0491c45 100644
> --- a/drivers/net/dsa/mt7530.c
> +++ b/drivers/net/dsa/mt7530.c
> @@ -2376,6 +2376,16 @@ mt7530_setup_mdio(struct mt7530_priv *priv)
> return ret;
> }
>
> +static void
> +mt7530_disable_pwrs(struct mt7530_priv *priv)
> +{
> + if (priv->id != ID_MT7530)
> + return;
> +
> + regulator_disable(priv->core_pwr);
> + regulator_disable(priv->io_pwr);
> +}
[Severity: Low]
Should reset be asserted here before the rails are dropped?
mt7530_probe() requests the reset GPIO with GPIOD_OUT_LOW, so reset is
asserted while the chip is unpowered. mt7530_setup() then pulses reset and
leaves it deasserted:
gpiod_set_value_cansleep(priv->reset, 0);
usleep_range(5000, 5100);
gpiod_set_value_cansleep(priv->reset, 1);
Every new caller of mt7530_disable_pwrs() cuts io_pwr and core_pwr with
reset still deasserted. That covers the err_disable_pwrs labels in
mt7530_setup() after the reset pulse, the mt753x_setup() error paths, and
mt753x_teardown().
The SoC then keeps driving the inactive level into the RESET pad of a chip
whose IO rail is off, and this repeats on every -EPROBE_DEFER re-probe.
The MCM path also never calls reset_control_assert() before power-off.
The v2 notes say this was left out because it matches the old
mt7530_remove() ordering. However, this patch adds several new power-down
points. Would asserting reset first, then disabling io_pwr and core_pwr,
better mirror the power-up sequence?
[ ... ]
> @@ -3205,11 +3228,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;
[Severity: High]
The commit message says:
Move mt7530_setup_gpio() after the FDB flush so the gpiochip is not left
registered when the rails are dropped.
and the v2 notes say "no failure path leaves the gpiochip registered after
the rails are disabled". Does that hold on these paths?
mt7530_setup_gpio() is now the last step of mt7530_setup(), so the reorder
only covers the FDB flush failure. When mt7530_setup_irq() fails here, for
example with -EPROBE_DEFER from of_irq_get(), the gpiochip is already
registered through devm:
mt7530_setup_gpio() {
...
return devm_gpiochip_add_data(dev, gc, priv);
}
err_disable_pwrs then calls mt7530_disable_pwrs() while the gpiochip is
still registered. The commit message calls -EPROBE_DEFER the common case.
On the mt7530_setup_mdio() failure path, mt7530_setup_irq() has also
already registered the regmap IRQ chip and its threaded handler:
ret = devm_regmap_add_irq_chip_fwnode(dev, dev_fwnode(dev),
priv->regmap, irq,
IRQF_ONESHOT,
0, &mt7530_regmap_irq_chip,
&irq_data);
The new mt7530_disable_pwrs() call in mt753x_teardown() has the same
problem. DSA calls teardown from the teardown label in dsa_switch_setup()
when tag protocol or user MDIO bus setup fails. It also runs on any tree
teardown, through:
dsa_tree_teardown()->dsa_tree_teardown_switches()->dsa_switch_teardown()
In all of these cases three resources stay registered while the rails are
cut: the gpiochip, the regmap IRQ chip, and the internal MDIO bus from
devm_of_mdiobus_register(). Their lifetime is tied to device bind, not to
DSA setup/teardown.
In a multi-switch tree, unbinding another switch tears this switch down
while it stays bound. The registered-but-unpowered state then lasts for as
long as this switch stays bound. Before this patch the rails stayed on in
these cases.
Can a gpiochip consumer (mt7530_gpio_get(), mt7530_gpio_set() and the
direction callbacks), the regmap-irq threaded handler, or a PHY on the MDIO
bus then issue regmap/MDIO accesses to an unpowered chip?
Would this need explicit unregistration in teardown and on these error
paths, using non-devm registration or the devm_*_release helpers, instead
of the reorder? If not, could the commit message and the v2 notes be
corrected?
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/179543215348.11880.18316180385674365789%40mail.zgclab.edu.cn
Technical Details
Message-ID:
<179552195677.3135.2679930645626053258@kernel.org>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!2.eu.feeder.erje.net!feeder.erje.net!feeder2.feed.ams11.usenet.farm!feed.usenet.farm!feeder.usenetexpress.com!tr3.eu1.usenetexpress.com!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-370309-linux-kernel-netdev=dewy.ruReferences:
<179543215348.11880.18316180385674365789@mail.zgclab.edu.cn>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!2.eu.feeder.erje.net!feeder.erje.net!feeder2.feed.ams11.usenet.farm!feed.usenet.farm!feeder.usenetexpress.com!tr3.eu1.usenetexpress.com!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-370309-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH v2] net: dsa: mt7530: disable the power rails on setup failure Date: Tue, 24 Nov 2026 12:05:56 +0000 Organization: Usenet Network Message-ID: <179552195677.3135.2679930645626053258@kernel.org> References: <179543215348.11880.18316180385674365789@mail.zgclab.edu.cn> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="4129415"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:3GnVSFsMsVYPnptQM1ZAm4uQfzY= sha256:s83xvrjh9oZ0aUq7rOs1h6MqjD1u3w1MHcn83pl5Z+Y= sha1:G0wCWZWrGGVmBuWOJKoysTTrhjs= sha256:MzHSgcayMD9y8oePDQZDQ+zDZtJqeHAEQspiEWM/Kok= List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id 14112125E08; Tue, 24 Nov 2026 15:06:28 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.4 X-Spam-Status: No, score=-3.4 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key) header.d=kernel.org X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id iiPGCb5_Acyv; Tue, 24 Nov 2026 15:06:24 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-370309-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mail.dewy.ru (Postfix) with ESMTPS id D5DE4125DFF; Tue, 24 Nov 2026 15:06:15 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sea.lore.kernel.org (Postfix) with ESMTP id 80A5D25F4E; Tue, 24 Nov 2026 12:06:01 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1795521961; b=4I5rI68+9o/PQ2pM8RGPudqiZjFFRmOc4lX8jR7+QfxZVrzMb8m7b00Rz6VvwooQaDcv lqosn5yngBCUeO2B+KbFzpaYtdhhyJQCCtmqeYtY7Q8/SKlZ0AuZrLfes/o/Crcx7jeDo YO+Ca4bwuZMNWJwHbWN6zd1w59q2GRdol1w+zg2mEmTAOaT1v41Ifvk5kX6VDBI+LLUK9 1aOqTclt1TGLrJw2j4YZVogHke0B8TLIOqWsKCd22u1QI5pDwam2YRld6pFffXeLqY+rK VFSGHjL9gw5eR3+04mOGN3cKuBf3F0BMh4Mi5dPGh7xlh94YVTHlAgm+9tFvWbNuqsw== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795521961; h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc: Date:Message-ID:In-Reply-To:References:X-sashiko-severity: Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id: List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner: Precedence:MIME-Version; bh=uh6VIcmUihTJZpbQIAs5Uul2q/clKDFIcJydo+fPY/c=; b=wl/46bCbhs97Yura97nREaasfiwItM7YChto4NF5PdNdKaTgym9mQ077Zdv+5oYIsFpx JP+I9/J9UpQDcWwaUar9TtSfDxQS4CLMaWi2lWWyCuPQTieBHpbvjZC1lxbhYx3IyCcyD AIwbgSyeCg+gUt00QTEtccNvnR0HWZijRGFA92R4B1ICxSFaFxKS5eb4kH96wtbVMxfd9 YVKQ4FzsJOWQO6kCoyAOq5jqFJNk7wDB3rENqgivQDYvOgSrxlBA3KJCWtv7frMT2zh7J fi6vna53vnIJ1a4jsaUn7nRNDVPqLEX9zeU3nZQR6vV9/66GcId4+VqMr/ji2jjljyg== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b="jkO62I/N"; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 26679606A33A; Tue, 24 Nov 2026 12:06:01 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=jkO62I/N X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795521958; b=RO8pbREZbogVWi1RUoq/kFoDV6u6Vt+xLf9Cees/RxwSsWyoCc8Wn3b7VWd9JurXx/PV lDCNO3eQLqJt6b+CWmJG/hKeJTONgEZtZuE38jwj4LOAUC5BNNykC/tlr/3S0Zns0iNkx 6Om7u29j0M9CM//Q9CJZrcuQL/CscwmCUHJTY1/H9v2ErtzFx7HcfujWfNZaMb1pYIAts W75n6ch0FP10dMGIRNl2va+zxGMm0sYMOrdJAXWY2vBOg12MeBMUa+A4wmQbRfbg0Rkg/ glhcRB5TEx9cB4Bb9qelirLHupIUTz8jskvGJV0YxLmsyv44eGWa/X55jmUl1UlvOLA== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795521958; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=uh6VIcmUihTJZpbQIAs5Uul2q/clKDFIcJydo+fPY/c=; b=SKkys6nNKXzK41uEz1uQuGFVxxlpmKbFRY19Bs40JC6oMQwkM82lUXlIUkJH4sLfdtcF D8Ovouj0m5KFblb1lHaa5yAj0aegav7KpY88uIndLFq0Tv4Lx9/n7nm3iZ57QGS7sfsDG hZCVf8rMjxQxDb4XhEp8JKTGWyTvfB0opoGZFYIJTmilq11NQkNBbi/oIaRs/L10RVhkn Q3DGVx/eFl6CO6ovD1itCQK4t4vrSiPxcO1di+Soz5zSUXC/ImHgzLtN17MKKl8RDTNhN pz6LlGjWNga6tZelbTAsbjC2slEBn44bpwzRUwuT9CcAMcesanXQrPbreE/B/AsXOgg== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b="jkO62I/N"; arc=none smtp.remote-ip=100.103.45.18 X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 93977606A330; Tue, 24 Nov 2026 12:05:58 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3816E1F000EF; Tue, 24 Nov 2026 12:05:57 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795521958; bh=uh6VIcmUihTJZpbQIAs5Uul2q/clKDFIcJydo+fPY/c=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=jkO62I/NkOgxLczWDu+s+u6Vg9w+FOcmx9E0LT9FVUmdYwqbuW/6XfqM+4cTjlWwl /DMR3U9M0WVJK3k/DpZDuAx2HptQYdiZ0ZZDmguKe/3xuiUTRJh6eVaf5Yl2sFVgWl LNHeEJBu5kuf6e9G4GVSbWI3s4PYuA1Qb7uel+lYx+J1Lk1c/7JWeOgSl0GO048IMr NUb0Qn4jJ143ter8OZhYaZflZEnDxnS1JXD4xU5mJhGcV9zApiWZ77+s60/9Pw32b/ +6KYSeua4GbIi5RqKV8iblvGZJAyFacFUsQJLLDUIB+qiB7xZK+Xk6j9UTksJL7VFq FW4U0YiQ1OUqw== X-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 X-In-Reply-To: <179543215348.11880.18316180385674365789@mail.zgclab.edu.cn> X-sashiko-severity: High X-Mailing-List: netdev@vger.kernel.org X-List-Post: <mailto:netdev@vger.kernel.org> X-List-Help: <mailto:netdev+help@vger.kernel.org> X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-List-Owner: <mailto:netdev+owner@vger.kernel.org> X-Precedence: list