From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796370665; b=zbpNXr/HU1Frd8YI9iFqnlb5ddKjFZSwnaxUzwKd/CCmFXiVh/SAFHgVyB1J8Pw67vUC PYJnro3nxR8Xdxsuc7wMG0AwUGcpZPHXaE0vEPD0ZEVnYyKpkL7vRq+hm3oKjx5TMTQZt q6PT1Hsxv8yNfeBgdoNMSxDo/azEXku80HvLOQFSmuMqNY8i84RbyfLDWbCRUR5JCbTtr iIZKlp3HYc0UwefRcufG/6069+ZVXsMjYteWs04qq/Xp4cReAYE887GW04vgJ78YxY6u2 Mqc7NL44Sok6o5pgqcLTfHF3f7UOo4vwYy17Kn9Jx/S0fUdNjXEEqrI6XmZjx9O0KAw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796370665; 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=uYD23LsOI7Rlnq0noFIWKyU9zh02NlqM1CYGJeQBuaw=; b=TgG6ULVDSVvkOMjDJEbKtIjQMCD8nBN6FVzy8N/3eLh5Mzw1rwsLAL8cW9tZpEvhcVNm /S6uwXEnqacSOiCo52A0ko49ohiqFF9c2LZhDd6jSe8DGKj6uU0dpm6HrjUQzGGn1MyLK WTdvzIZI9nUeUdgGbaL3AsWgFCQELHKddQibZaVPEIU3ZrV2inw/4er9/e/4CmdDqckaF kqOZRoHOLyMqvEQtz9RsjNGRc6VKtozJUNEQt2h3TkkCKKfCiUSEtyp3/AdFVRSRoqVKb lalwbazb64Vz6DnDHyF38c+9mbRy1DvphIG8C4WhJX8aorRt+UkGaFKcg7XTdkdJxvg== 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=YnPfeSdO; arc=none smtp.remote-ip=100.103.45.18 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 7B1AE606A336; Fri, 4 Dec 2026 07:51:05 +0000 (UTC) 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=YnPfeSdO Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6531E1F0092C; Fri, 4 Dec 2026 07:51:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796370665; bh=uYD23LsOI7Rlnq0noFIWKyU9zh02NlqM1CYGJeQBuaw=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=YnPfeSdOHihndzBw0/dt/rMITcGDIx7VHCmZn9DV8EJ5i9GXO4U1+vORzCXbxaORW N5OYlQVGZko/w0lFd7SuZ4GEgSTfn5/Qkotkty6EcK/zM+T/lAJvTP5gWxQ9kTvBq6 ZIz6UnG4xZnGDWScmyAbotGNhugXmAzfxAjIxnh8lOaTseYXsxKbQAlcaJDFhGlL33 4dQ+xGd4BMICsWCFalqDws/u/CySE71g1luGuyN5SrVXR7VWTPGIHhZqGdpgN0lVAT mD/NhQOeQ5NVq64WYW81n/Kc6++4jEk3iN9y3EBd+bFoiQvYkYQVuCdcoNuhqC4Ijk HHeX7C+ZbhwHQ== Subject: Re: [PATCH net-next v2 5/5] net: dsa: mt7530: disable regulators on mt753x_setup() failure From: netdev-bot+sashiko@kernel.org To: wanghr2026@mail.zgclab.edu.cn 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 Date: Fri, 04 Dec 2026 07:51:03 +0000 Message-ID: <179637066398.3146.16717058703088608275@kernel.org> In-Reply-To: <179628050300.1224.2090604648819997374@mail.zgclab.edu.cn> References: <179628050300.1224.2090604648819997374@mail.zgclab.edu.cn> X-sashiko-severity: Medium Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 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