🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #24050

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

#24050
From: netdev-bot+sashiko
Date: Sun, 29 Nov 2026 03:08
173 lines
13896 bytes
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.

Critical: 0 · High: 0 · Medium: 1 (1) · Low: 1

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] On the MCM boards (mt7623a.dtsi sets mediatek,mcm and resets =
  <&ethsys MT2701_ETHSYS_MCM_RST>), mt7530_probe() now enables the core…
- [Low] The commit message lists 'the SGMII PCS creation' among the
  failures that leave the MT7530 core/io regulators enabled.

Pre-existing issues:
- [Medium] mt7530_remove() calls regulator_disable() on core_pwr and
  io_pwr (mt7530-mdio.c:267-277) before mt7530_remove_common() calls…

--

net: dsa: mt7530: enable the regulators in probe() and unwind on error

This moves the MT7530 core and io regulator enables out of mt7530_setup()
and into mt7530_probe(). It also adds error labels that disable them again
if regmap init or dsa_register_switch() fails, so a failed or deferred
probe no longer trips the WARN_ON() in _regulator_put().

Link: https://lore.kernel.org/r/20261124013422.1408-1-laixiangwu@cmss.chinamobile.com

> never runs when the probe fails.  A failure anywhere between the enables
> and a fully registered switch - the remaining steps of mt7530_setup(),
> the IRQ chip or MDIO bus registration in mt753x_setup() (both can also
> return -EPROBE_DEFER), the SGMII PCS creation, or the DSA core itself -
> therefore leaves both regulators enabled.

[Severity: Low]
Can the SGMII PCS creation leave these regulators enabled? The core and io
regulators only exist for ID_MT7530. mt7530_probe() sets create_sgmii only
for ID_MT7531:

	if (priv->id == ID_MT7531)
		priv->create_sgmii = mt7531_create_sgmii;

mt753x_setup() only calls it when the pointer is set:

	if (priv->create_sgmii)
		ret = priv->create_sgmii(priv);

So on MT7530 this step never runs. Should "the SGMII PCS creation" be
removed from the list?

> diff --git a/drivers/net/dsa/mt7530-mdio.c b/drivers/net/dsa/mt7530-mdio.c
> index e85ef2aceee56..2de5e26edad61 100644
> --- a/drivers/net/dsa/mt7530-mdio.c
> +++ b/drivers/net/dsa/mt7530-mdio.c
> @@ -209,18 +209,50 @@ mt7530_probe(struct mdio_device *mdiodev)
>  		priv->io_pwr = devm_regulator_get(&mdiodev->dev, "io");
>  		if (IS_ERR(priv->io_pwr))
>  			return PTR_ERR(priv->io_pwr);
> +
> +		regulator_set_voltage(priv->core_pwr, 1000000, 1000000);
> +		ret = regulator_enable(priv->core_pwr);

[Severity: Medium]
On the MCM boards, is the switch held in reset when the rails come up
here? mt7530_probe() gets the reset control but does not assert it:

	priv->rstc = devm_reset_control_get(&mdiodev->dev, "mcm");

The first reset pulse still happens in mt7530_setup():

	if (priv->mcm) {
		reset_control_assert(priv->rstc);
		usleep_range(5000, 5100);
		reset_control_deassert(priv->rstc);

Before this patch, the core supply on these boards was first enabled in
mt7530_setup(), right before that pulse. That supply is mt6323_vpa_reg,
which has neither regulator-boot-on nor regulator-always-on.

Now the chip runs on its power-on defaults from probe until ops->setup.
That window includes dsa_register_switch() deferrals and any wait for the
conduit or other tree members. Each -EPROBE_DEFER retry also power-cycles
the chip.

The commit message says:

  The pulse at the start of mt7530_setup() re-initializes the chip, so the
  window behaves like a cold boot whose external reset arrives late; no
  configuration is lost.

mt7530_setup() clears PCR_MATRIX on every port ("Disable forwarding by
default on all ports") and forces the PMCR links down. That suggests the
power-on default is to forward between front-panel ports.

Could the unconfigured switch forward frames between, for example, the
LAN and WAN ports during this window?

The GPIO reset boards avoid this because devm_gpiod_get_optional() with
GPIOD_OUT_LOW keeps the reset line asserted. Would calling
reset_control_assert(priv->rstc) in mt7530_probe() before the regulator
enables close the window on the MCM boards as well?

> +		if (ret < 0) {
> +			dev_err(&mdiodev->dev,
> +				"Failed to enable core power: %d\n", ret);
> +			return ret;
> +		}

[ ... ]

> -	return dsa_register_switch(priv->ds);
> +	ret = dsa_register_switch(priv->ds);
> +	if (ret)
> +		goto err_disable_powers;
> +
> +	return 0;
> +
> +err_disable_powers:
> +	if (priv->id == ID_MT7530)
> +		regulator_disable(priv->io_pwr);
> +
> +err_disable_core_pwr:
> +	if (priv->id == ID_MT7530)
> +		regulator_disable(priv->core_pwr);
> +
> +	return ret;
>  }

[Severity: Medium]
This is a pre-existing issue, not one introduced by this patch. Since the
patch now relies on mt7530_remove() to balance these enables, is the order
of operations there correct? mt7530_remove() turns off both regulators
before the switch is unregistered:

mt7530_remove() {
	...
	if (priv->id == ID_MT7530) {
		ret = regulator_disable(priv->core_pwr);
		...
		ret = regulator_disable(priv->io_pwr);
		...
	}

	mt7530_remove_common(priv);
	...
}

mt7530_remove_common() then calls dsa_unregister_switch(). So the whole
DSA teardown runs against an unpowered chip:

  - phylink mac_link_down writes PMCR
  - port_disable writes PCR
  - the PHYs are stopped over MDIO
  - stats_work keeps polling the MIB counters

stats_work only stops when mt753x_teardown() cancels it:

	if (priv->bus)
		cancel_delayed_work_sync(&priv->stats_work);

Would these writes be lost, and would the reads return bus-idle values
like 0xffff or 0xffffffff? Reset is not reasserted before power is removed
either.

Should mt7530_remove() call mt7530_remove_common() before it disables the
regulators?

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261125022231.1936-1-laixiangwu%40cmss.chinamobile.com
Technical Details
Message-ID: <179592171884.3146.4230652985424770811@kernel.org>
Path: mbox-mo1.pugleaf.net!news-can.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-373350-linux-kernel-netdev=dewy.ru
References: <20261125022231.1936-1-laixiangwu@cmss.chinamobile.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-can.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-373350-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH v5] net: dsa: mt7530: enable the regulators in probe() and
 unwind on error
Date: Sun, 29 Nov 2026 03:08:38 +0000
Organization: Usenet Network
Message-ID: <179592171884.3146.4230652985424770811@kernel.org>
References: <20261125022231.1936-1-laixiangwu@cmss.chinamobile.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="1089730"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:7RVRejjis79VO6kw68nyvLekvMk= sha256:ic/sy2DKkR+sFuSqEYrNzhwj31OjK1mX9WZPOtTyxFA=
	sha1:poPJzqrdqjezio7Z4Xd+PySuPOM= sha256:6dKBrJvF5FD8jBtiUB/ZHMd33ig6vc3epvR/h61O9nU=
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 62B04125F8A; Sun, 29 Nov 2026 06:09:08 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.5
X-Spam-Status: No, score=-3.5 tagged_above=-9999 required=6.31
	tests=[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 pGI4WnkknlML;
	Sun, 29 Nov 2026 06:09:00 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-373350-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 tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])
	by mail.dewy.ru (Postfix) with ESMTPS id EE289125F90; Sun, 29 Nov 2026 06:08:49 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by tor.lore.kernel.org (Postfix) with ESMTP id E40B82640A; Sun, 29 Nov 2026 03:08:46 +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=1795921726;
	b=Tv+NO2GaIx4Esz/Ik87cecfYsaAJoZLZGw81ZG1b6dRFBGzVWnBx+PmunnQL6n/hHwtx
	 pWJQY+UBi1LazsuKvvwKR3RV1AWNa0mzdmR4awgCcDC+16ErSfCSbYmpdXDKPr0AHvp0Y
	 MqWbcn0VEu3FzvToF3j552dLYepPXmRyRSce98/ZgF2XGJIK54+a72tT5PtVlhXnIHwTu
	 ubvCkToQ1cMjL05Y9F57faFBhyoWwugMBigg7uG7xZPO/u1S8UjIFJdCOsu5eMCIQ3C68
	 zhtlAjiodPZE3OiIKIfwgwu0Zw1rKYXp4+6J4fG+WRDRfjQF3VL9KYeP+NightZEWZQ==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795921726;
	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=/QZ4spRzyrcl979yT7G0sn9sXOYnswum9SgSSEw5we8=;
	b=0nmFkoRtS0eLp2AKQSRpX0RYSKwRQULUxY+fmc9qj5y8/479CbmBcP45c+W3rvcQGR6F
	 PjiUyp2zYs1ybqL6iDJC+IUBg6eUg3GRiL3Eh0ULuQAivMrxWoeKsM+U3EXX1mwiF2VAP
	 msQfifL3QrdOq6hjLWOF70S/Rf08nU9mYPo9btPKtXwhcKbkQxzVIUJH38kXYof6xTldh
	 LJjncdDz243xxQi/xK5Ilaudn3SgebpRIWC6vxaMwBl3o/1vGQa5SLGVYgD106Aarxe7C
	 wLdRT6Z9SHKrxocctLN4WAMdd1KD8LohCFQSnBhCj1Jx/R9DLX2QF7++U0TFmdB2MLA==
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=o2QEKabo;
	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 034C4606A333;
	Sun, 29 Nov 2026 03:08:46 +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=o2QEKabo
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=1795921720;
	b=TJXoAkLO6RT0N9cIRwuCv8qvQEUC6N178U9IpS2N8Dbn+qP73elVace/9V5Rd7i/l4IS
	 p1crFHT0oMT/pL9NbLBdqZJMXJaExAVVCfIX7auXE/fGYFHgwVsNjrRXS7gHZjXlSImFp
	 2kgUajETzpdu/IhWccu+GgxSxJlBcWvcCfLI+ToQeQ0qr8fHoqs3eFiUggyuWm6COIe9B
	 QpWmoSj3NlJdM7kJwigktAH8To6+DFZu2PigNxWEy1BNDOOizM7i8LC+e4Op9GiLisQkB
	 KnJyLYDT3AQxIPI2YKBIR6Cy+0m0JZRPt/tH5y+v9224Lz3aQ/Dy4UQFKYUvnaKjsmg==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795921720;
	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=/QZ4spRzyrcl979yT7G0sn9sXOYnswum9SgSSEw5we8=;
	b=K4spv2trywncpalnN7w48Ro+xpof2Ih4vv0eVIE35cK7a5vPZvr4JbOTx2OEyT5gnWWz
	 r9R8TIQfYNMIsAfKfOEmyrpGQyA0vB+PucWaXMpF8JtwtoFxL7ZUA45+bnMe/nITSVLFc
	 F63QzwLfBboey+QQlsneAVvg3iSOZLpVAIWPwG8Cz+c4FvqJStEA2pn+YCPCWi9Tdc9su
	 S65nIaWZY61QIfk5owfD1DMEI7AhNa98jvHLHEf+9hqGvKNFj5wlD1QK+vC8xsd6ihrqN
	 mrecJho/7u7dMPy3+MLPzWzeTvkq9QBfeLHVZzKg/ocQh4280TjnYl1aNyL/jR0Elzw==
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=o2QEKabo;
	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 20DEA606A31C;
	Sun, 29 Nov 2026 03:08:40 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 535501F00896;
	Sun, 29 Nov 2026 03:08:39 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1795921719;
	bh=/QZ4spRzyrcl979yT7G0sn9sXOYnswum9SgSSEw5we8=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=o2QEKabofYr/wGLLhIidGY7cGyxJ/nEhmSxtAXfecJwoMYZltTvfR/p92r8mRt3gq
	 y/jUyZJby3UlsfwugMW3Inp8ZLyJG7U8f+AQWqTQYgTleJbEIHaSgzXDeLLClpKRf6
	 BMfLnaR9B4UBeyH4WepD0xyPF5SpnKwsfIzmVSW5Guf0GZaoako39oMPbQZLXSJ80+
	 PbLw285IkMdrpzTjKnewlIj54X1I7cW9faTOSmAwP5jwO+gIlqy7RNyD3tp/qDzcvQ
	 1C0WiYiOTjbUzI3NY4y1Y737ECWI0TGbGrHXLJ3SFw5L2mQGEfVcTAT/Nw7Aoi7fnt
	 6siqPWfhJ+hbg==
X-Cc: chester.a.unal@arinc9.com, daniel@makrotopia.org, andrew@lunn.ch,
 olteanv@gmail.com, sean.wang@mediatek.com, netdev@vger.kernel.org,
 linux-kernel@vger.kernel.org, netdev-bot+sashiko@kernel.org, kuba@kernel.org
X-In-Reply-To: <20261125022231.1936-1-laixiangwu@cmss.chinamobile.com>
X-sashiko-severity: Medium
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