๐Ÿš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #26822

Re: [PATCH net-next v2 1/5] net: dsa: mt7530: disable regulators on switch teardown

#26822
From: netdev-bot+sashiko
Date: Fri, 04 Dec 2026 07:51
109 lines
12060 bytes
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
Technical Details
Message-ID: <179637066109.3146.17558378695130953570@kernel.org>
Path: mbox-mo1.pugleaf.net!feed-us-txt.newsdeef.eu!feed-us-mo.newsdeef.eu!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-377171-linux-kernel-netdev=dewy.ru
References: <179628050300.1224.2498848542937309110@mail.zgclab.edu.cn>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!feed-us-txt.newsdeef.eu!feed-us-mo.newsdeef.eu!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-377171-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net-next v2 1/5] net: dsa: mt7530: disable regulators on
 switch teardown
Date: Fri, 04 Dec 2026 07:51:01 +0000
Organization: Usenet Network
Message-ID: <179637066109.3146.17558378695130953570@kernel.org>
References: <179628050300.1224.2498848542937309110@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="2708811"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:t7DwHnQB1/jEvvH9UxrqSAErDiw= sha256:38xSi6l7zl6uV/kEC9wzCf8PFIQ+hAmiH9qTgm+/o14=
	sha1:YFBWdS+AQSbz20ARATETBFI4SyI= sha256:PHnRyoGePQdOjxhi5bXl0dq6vJaplwZ12GmBn5j4yoI=
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 39C36117B5C; Fri,  4 Dec 2026 10:51:43 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.639
X-Spam-Status: No, score=-3.639 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.24, 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 EGEmk9lRnhmv;
	Fri,  4 Dec 2026 10:51:40 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-377171-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 028F6117B46; Fri,  4 Dec 2026 10:51:31 +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 A07902A3F1; Fri,  4 Dec 2026 07:51:13 +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=1796370668;
	b=HytKDjBb4QUiY3RMiU2ph+gx2ipQfaanZu767Ap/M8oA5TaxuZe/ZAzXB1I1REHrUdxV
	 ujgnl38oSJl8cpBtXH05VIAhgti5693mMlYqA+GtnQG77LbocCeWDJHuVC0X/WNMmeREM
	 Sww0h9+7iPVLHTQbCuos0E7Pb40gvV/R9VWsvYzY2jtz41VK3IIXCJV6OkQi5QmXUvvCt
	 dRUKjMtaQXxhQrAPylchRxOKVN4zrrd9DZB9gOOqatPWh2MVqXy2XhwCh1aYKXc8pCTbk
	 VWdqTiGC7xMkIlm1wbKbvNTLYDuQqZK/fparrqa9vIMqkZoCyrD9BNpUYGzshimPTCA==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796370668;
	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=dFcKv4ocPOD5ezkh3P5RWyOwM1Uugkqkv1ugGcphHAU=;
	b=QK+RdpKToU7bhwo9S2YorsDL31Pw8HG8OpEsCTkoc95evhI5dhseQLDkPuTBMZf9L+6W
	 CrMeJSLmsUjywn5kPmOMex2WJUcg77ApqoBT3zIB5rNbZ4wxMPk7wRho8Rqtuq4Ex3mwm
	 mg1I+DKdE6urgQGN+IQ5EUQkBRE0RuOgCZJyW5lmPmK+Yy0XhJ2gbcOGIXPhZpCiBm28U
	 L/X3hNexHXxzXwxMJ9fFASh2ctF2rMhMJ04h4C99h/Nj8epE8ACFFs6WCwb6h+OF2rFNw
	 Ka+nTTzNxT/zXPHLDzbj/wzqbMnYE53ennERtjDvLSftM7pXCK/N+HcZ1m0xN0gRCzA==
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=P6iSrJGn;
	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 63F62606A698;
	Fri,  4 Dec 2026 07:51:08 +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=P6iSrJGn
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=1796370662;
	b=N7Z9RIr/0DeG9U2XHnnljNKpbcjXcXdsanPqG1XHjNTuKkily6qfln7g+VZYPKVr5Z6I
	 xvHrsZtosK9/zx7MzkbkBQCcpfD6qKCdVbm+yAY90+7Mj0SSQy2oY7vWfp3YpGn2wTt2K
	 O9PHzZmAlCtc7vld4Yjkvtae2wHfSzw9jc34wPS2bo9pNJTXkzcjxnWm3Y740jLvdh/uI
	 FgwqM0nP3N0HrZ83Wpz7INLzK2i2t0MXdy3FC/EXzjD1QYzDCAMGsE+1uA+Lm1P6AHN7Z
	 eTO0dZOlqo3QSJHfDotqpskxVAXTEZaT47Lmx6c6PQA6yawtRN5S62VOlCuuSVw/sew==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796370662;
	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=dFcKv4ocPOD5ezkh3P5RWyOwM1Uugkqkv1ugGcphHAU=;
	b=zFu1sZvMDzAgcoCDIdA2tUN1EgRxj45LYz7jWmhvCHbRFe6YLhW9ZJMIIaTN0UePRcus
	 aYNy5YdOUia3oirq9r4ZyE9i0Z4vtEey89KHCPkfkrBuaieYJHiCBvo/PFex6MWAlfoAB
	 qLzoeY5G/Ia4ZYc82ugxyeoINkxTUXXzFn1A6Te7xd7cP9Y1MWCzKePy3gZW5BBQdAvVu
	 JbLQXZOw6f1OBiP46a7Ec/uHKIZ3RhqitNehoMqGUUMOiNsFyk1elefEpVbHbA2Ydbewp
	 xN0Cw7d6H9zar+B1N6dQbyqrQZiG+xk1Gig7bvdRdjPt1BtLTZSRIEnn4MQRM3Rxbrw==
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=P6iSrJGn;
	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 84368606A32C;
	Fri,  4 Dec 2026 07:51:02 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8A7C41F000C2;
	Fri,  4 Dec 2026 07:51:01 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1796370662;
	bh=dFcKv4ocPOD5ezkh3P5RWyOwM1Uugkqkv1ugGcphHAU=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=P6iSrJGnuWsDxvy86EJg0nChj4IH1PZunPAfbPl5DazpwoMhLtfNskTw0vIR3CP1I
	 hPpJsC8cVAXlUs9ZgSuNxg0sq50yS+rjZOhIcKU7nLpRNztWQY2EcWEmJl+Vs+9CvW
	 HNNokVrMb/bT1utvTKgOjCfoWxJxEv/LFIGhqXF0/+sUdyWsQrYoEKCkC9lb18pO2f
	 Y01QSk+NYD+u8SnWNxBe692OWiRWJq45l3mxkH/cSx6NHoNJAPBll/RMWao+zdWvXE
	 1z6SIkfuoW2u6k8NAFSWa4t2ZIGlT67jx9Qh8UG0r6Rn9O4dLwoYISRKr60PfEVrGU
	 i7ARLpldcXtDQ==
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: <179628050300.1224.2498848542937309110@mail.zgclab.edu.cn>
X-sashiko-severity: Low
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