🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #21460

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

#21460
From: Xiangwu Lai
Date: Tue, 24 Nov 2026 01:38
55 lines
11148 bytes
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@cmss.chinamobile.com).

> > 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@cmss.chinamobile.com

Best regards,
Xiangwu Lai
Technical Details
Message-ID: <20261124013852.1101-1-laixiangwu@cmss.chinamobile.com>
Path: mbox-mo1.pugleaf.net!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-369944-linux-kernel-netdev=dewy.ru
References: <426c9bff-1928-4829-a3e0-dc021e4c783e@lunn.ch>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!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-369944-linux-kernel-netdev=dewy.ru
From: laixiangwu@cmss.chinamobile.com (Xiangwu Lai)
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH v3] net: dsa: mt7530: manage the core and io regulators with devm actions
Date: Tue, 24 Nov 2026 09:38:51 +0800
Organization: Usenet Network
Message-ID: <20261124013852.1101-1-laixiangwu@cmss.chinamobile.com>
References: <426c9bff-1928-4829-a3e0-dc021e4c783e@lunn.ch>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="4028247"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:dvTzLhRx8iqVuj/OGDLYFRevVLg= sha256:ipGwY/30bmjLPK4az+H9fvSWz4m62rfRBtcajgRiGds=
	sha1:zhPl6wXsYSmNYF9f7DPJZQ12NBs= sha256:N1MyNeS+qx2O3jgSLmIb6kW1MJk/mlRaVnSmww6vfTc=
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 71EAA125DC7; Tue, 24 Nov 2026 04:39:17 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -2.75
X-Spam-Status: No, score=-2.75 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIM_INVALID=0.1, DKIM_SIGNED=0.1,
	HEADER_FROM_DIFFERENT_DOMAINS=0.249, 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=fail (1024-bit key)
	reason="fail (body has been altered)" header.d=cmss.chinamobile.com
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 V_b3N6QzSrtH;
	Tue, 24 Nov 2026 04:39:13 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-369944-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=cmss.chinamobile.com
X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])
	by mail.dewy.ru (Postfix) with ESMTPS id C88AB125DC6; Tue, 24 Nov 2026 04:39:03 +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 B928E2FBE5; Tue, 24 Nov 2026 01:39:02 +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=1795484342;
	b=QBaJaZUmd/1P1SF2aiWN9WCFog1hYRSv22ktc2fShty3W5NAmNzU+J+okPPocsGGaYX7
	 DfbVKYf7j30W4I+te4V6e9JvJJOwGod0qQ5MogkfeJvEXR43SZrxHWFLH00p+QCwu+7Jn
	 Du1CICU1JFaDmEJ7RIG/UCqNLg/T4WN23AVslO0+tVjMNDSj4Ig5y2eEWp5vjDNjPaDTq
	 nWzQPHXXCigEQ2Ejw14VDet1Wsr68fLowKbVPH832F8hz9+HTN4aL1zRUS4CpkDnjO4lt
	 KNc6SuhqFKQUh7QBGtYR0Cpx2RGdiFbb59cOGRQAZ/vLMJ1b/26Y31UWC71Pd+cKMww==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795484342;
	h=X-Original-To:Received:DMARC-Filter:DKIM-Signature:X-RM-TagInfo:
	 X-RM-SPAM-FLAG:Received:X-RM-TRANSID:X-RM-TagInfo:X-RM-SPAM-FLAG:
	 Received:X-RM-TRANSID:From:To:Cc:Subject:Date:Message-ID:X-Mailer:
	 In-Reply-To:References:X-Mailing-List:List-Id:List-Post:List-Help:
	 List-Subscribe:List-Unsubscribe:List-Owner:Precedence:MIME-Version:
	 Content-Transfer-Encoding;
	bh=UrsxTwQWNnPxqy/+u/D6/SODCBpmj/qInDB3Yqh00ck=;
	b=kI9w0DodnCCeukJVZGocSmeeiH2S97ThLHgghgl5nnQG2dnWwSoHf8nng50ENmw8qVBu
	 Gov0Xohen/y4acsXfIOwLU2+qxjX4y4h/A1qrs51gzObQhkln5KeSnHd1vWQTUYWWNX+0
	 X5fQDeEPFSaH+awkRz1VmhzUue7U8MOnPE2Lev/GjxxGN2mZkz3cwIp/66aeUv9nx/24+
	 iXok9ocVX1OLHzNDFqZdv4j5Ftxf2+8isaFfX/mh7V6EC/ynonSmrxy72jxhqH3dsovfS
	 HuTIGZFnLqthkVIlgel/ZLpOAGzKMZ17LDjT5d9lZz6DEnj1HOP7Ixtqv475uFXBdQQ==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=cmss.chinamobile.com header.i=@cmss.chinamobile.com header.a=rsa-sha256 header.s=default header.b=z4MjaWR9;
	dmarc=pass header.from=cmss.chinamobile.com;
	spf=pass smtp.mailfrom=cmss.chinamobile.com;
	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 54936606A330;
	Tue, 24 Nov 2026 01:39:02 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (1024-bit key) header.d=cmss.chinamobile.com header.i=@cmss.chinamobile.com header.a=rsa-sha256 header.s=default header.b=z4MjaWR9
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=111.22.67.137
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1795484336;
	b=nTkpxPfUjgho+aPA681c4NQo49UHoRktbSgQPZWBXY8B1+OxgTBTJ9kUNRM2ShhqXxY1
	 sUI+vWvS9IuNhqiQJCJMlc/FHZK31YnJ2G9VBJa4jGc5s3y5xoNYOm/qQUIivZF4cuxwb
	 U6pdAE3KHBIgFfiw8wr+RBKrrBF1EawsJsqhbm95Wt8aLSrx8zzkV1lqfYsEOoAZxkgyp
	 euAVJ3uEifT3dMQ8sMC4n1Dih3zfvUVSOhwm7tm+foNRTYJ4gVSWeaJ2774fNdIs1vccS
	 X6SaQ1HOTHsw38VXCwsnJQY1YweA6nEDRs65LHXkLxnTO92UeLYfFA/KiVonNn/twjQ==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795484336;
	h=DMARC-Filter:DKIM-Signature:X-RM-TagInfo:X-RM-SPAM-FLAG:Received:
	 X-RM-TRANSID:X-RM-TagInfo:X-RM-SPAM-FLAG:Received:X-RM-TRANSID:From:
	 To:Cc:Subject:Date:Message-ID:X-Mailer:In-Reply-To:References:
	 MIME-Version:Content-Transfer-Encoding;
	bh=UrsxTwQWNnPxqy/+u/D6/SODCBpmj/qInDB3Yqh00ck=;
	b=UIRjDMZ6vhCXPm33XvyxJYa+yWOe0V4yEz5KaSMbDaYdjdwsTiLHwXM/OGgwVvE3p2Kx
	 In2DLRYG0G63gbA11KhZh8ogQDT0k0i31b++CQVb9ZdTsQB8nzex+5a4/iPBxbkhJFcxM
	 s68eu/g423h5ZpgIbrFLHXdMO2rFNzMLYUTK16MWJZHrqxkWRNfyMZz4CNj/cu0gbUONN
	 hSAB0QYkx0gPvW05vLHkVV9Txhl45kGzF1SHzfasCs9+IlvK/p5MmW5kXLDFZeoHg8BIS
	 N5lucpVGhGG49fsj2Sbp3CgzUy932ypPiLjt0gG5JCM2i0VJUOqMVvbqTAE25jlEaLg==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dmarc=pass header.from=cmss.chinamobile.com;
	spf=pass smtp.mailfrom=cmss.chinamobile.com;
	dkim=pass header.d=cmss.chinamobile.com header.i=@cmss.chinamobile.com header.a=rsa-sha256 header.s=default header.b=z4MjaWR9;
	arc=none smtp.remote-ip=111.22.67.137
X-Received: from cmccmta4.chinamobile.com (cmccmta4.chinamobile.com [111.22.67.137])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 663C5606A31E;
	Tue, 24 Nov 2026 01:38:55 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 663C5606A31E
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=cmss.chinamobile.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=cmss.chinamobile.com
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
	d=cmss.chinamobile.com; s=default; l=0;
	h=from:subject:message-id:to:cc:mime-version;
	bh=47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=;
	b=z4MjaWR90MXKBH3gOd6AZHLAwhyV7lkVPn4IkseHF4mAG0sspcNNXj7l5PyCIsLucjcgCIeIo/yy+
	 Fgh0BU6iQZBAVQrhtA+TiomwiUvj9UUmfD2zc1HFnGHi5WpTC4dOZEMJC41SkhD5lniiAWkdYqLzXm
	 uFKzTHZD5kn96bJM=
X-RM-TagInfo: emlType=0                                       
X-RM-SPAM-FLAG: 00000000
X-Received: from spf.mail.chinamobile.com (unknown[10.188.0.87])
	by rmmx-syy-dmz-app08-12008 (RichMail) with SMTP id 2ee86b04eaac59b-e1ec6;
	Tue, 24 Nov 2026 09:38:53 +0800 (CST)
X-RM-TRANSID: 2ee86b04eaac59b-e1ec6
X-RM-TagInfo: emlType=0                                       
X-RM-SPAM-FLAG: 00000000
X-Received: from DESKTOP-3K8GUTQ (unknown[223.108.79.98])
	by rmsmtp-syy-appsvr04-12004 (RichMail) with SMTP id 2ee46b04eaab172-0e260;
	Tue, 24 Nov 2026 09:38:53 +0800 (CST)
X-RM-TRANSID: 2ee46b04eaab172-0e260
X-Cc: Xiangwu Lai <laixiangwu@cmss.chinamobile.com>,
	chester.a.unal@arinc9.com,
	daniel@makrotopia.org,
	olteanv@gmail.com,
	sean.wang@mediatek.com,
	netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	netdev-bot+sashiko@kernel.org
X-Mailer: git-send-email 2.50.1.windows.1
X-In-Reply-To: <426c9bff-1928-4829-a3e0-dc021e4c783e@lunn.ch>
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