🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #19771

[PATCH net-next v4 5/5] net: stmmac: dwmac-sun8i: Register the MDIO mux in the MDIO setup

#19771
From: Arun Iyengar via B4 Relay
Date: Fri, 20 Nov 2026 10:45
109 lines
13853 bytes
From: Arun Iyengar <aiyengar1990@gmail.com>

Both PHYs sit behind the mux, but the mux is registered only after
stmmac_pltfr_probe() has registered the netdev, so an early open does
not find the PHY. On remove, the mux goes away before
unregister_netdev(), and unbinding with the link up oopses in
phy_stop().

Register and unregister the mux through the new mdio_init() and
mdio_exit() hooks.

Signed-off-by: Arun Iyengar <aiyengar1990@gmail.com>
---
 drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c | 41 ++++++-----------------
 1 file changed, 10 insertions(+), 31 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
index 4acfda235394..0ec25ae0b77e 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
@@ -17,7 +17,6 @@
 #include <linux/of_platform.h>
 #include <linux/phy.h>
 #include <linux/platform_device.h>
-#include <linux/pm_runtime.h>
 #include <linux/regulator/consumer.h>
 #include <linux/regmap.h>
 #include <linux/stmmac.h>
@@ -941,6 +940,13 @@ static int sun8i_dwmac_register_mdio_mux(struct stmmac_priv *priv)
 	return ret;
 }
 
+static void sun8i_dwmac_unregister_mdio_mux(struct stmmac_priv *priv)
+{
+	struct sunxi_priv_data *gmac = priv->plat->bsp_priv;
+
+	mdio_mux_uninit(gmac->mux_handle);
+}
+
 static int sun8i_dwmac_set_syscon(struct device *dev,
 				  struct plat_stmmacenet_data *plat)
 {
@@ -1133,8 +1139,6 @@ static int sun8i_dwmac_probe(struct platform_device *pdev)
 	struct stmmac_resources stmmac_res;
 	struct sunxi_priv_data *gmac;
 	struct device *dev = &pdev->dev;
-	struct stmmac_priv *priv;
-	struct net_device *ndev;
 	struct regmap *regmap;
 	int ret;
 
@@ -1217,6 +1221,9 @@ static int sun8i_dwmac_probe(struct platform_device *pdev)
 		ret = get_ephy_nodes(dev, gmac);
 		if (ret)
 			return ret;
+
+		plat_dat->mdio_init = sun8i_dwmac_register_mdio_mux;
+		plat_dat->mdio_exit = sun8i_dwmac_unregister_mdio_mux;
 	}
 
 	ret = sun8i_dwmac_set_syscon(&pdev->dev, plat_dat);
@@ -1227,33 +1234,8 @@ static int sun8i_dwmac_probe(struct platform_device *pdev)
 	if (ret)
 		goto dwmac_syscon;
 
-	ndev = dev_get_drvdata(&pdev->dev);
-	priv = netdev_priv(ndev);
-
-	/* the MAC is runtime suspended after stmmac_dvr_probe(), so we
-	 * need to ensure the MAC resume back before other operations such
-	 * as reset.
-	 */
-	pm_runtime_get_sync(&pdev->dev);
-
-	/* The mux must be registered after parent MDIO
-	 * so after stmmac_dvr_probe()
-	 */
-	if (gmac->variant->soc_has_internal_phy) {
-		ret = sun8i_dwmac_register_mdio_mux(priv);
-		if (ret) {
-			dev_err(&pdev->dev, "Failed to register mux\n");
-			goto dwmac_remove;
-		}
-	}
-
-	pm_runtime_put(&pdev->dev);
-
 	return 0;
 
-dwmac_remove:
-	pm_runtime_put_noidle(&pdev->dev);
-	stmmac_pltfr_remove(pdev);
 dwmac_syscon:
 	sun8i_dwmac_unset_syscon(gmac);
 dwmac_ephy:
@@ -1269,9 +1251,6 @@ static void sun8i_dwmac_remove(struct platform_device *pdev)
 	struct stmmac_priv *priv = netdev_priv(ndev);
 	struct sunxi_priv_data *gmac = priv->plat->bsp_priv;
 
-	if (gmac->variant->soc_has_internal_phy)
-		mdio_mux_uninit(gmac->mux_handle);
-
 	stmmac_pltfr_remove(pdev);
 	reset_control_put(gmac->rst_ephy);
 	clk_put(gmac->ephy_clk);

-- 
2.55.0
Technical Details
Message-ID: <20261120-sun8i-emac-mux-uaf-v4-5-57eba8915f25@gmail.com>
Path: mbox-mo1.pugleaf.net!news-lax.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-367880-linux-kernel-netdev=dewy.ru
References: <20261120-sun8i-emac-mux-uaf-v4-0-57eba8915f25@gmail.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.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-367880-linux-kernel-netdev=dewy.ru
From: devnull+aiyengar1990.gmail.com@kernel.org (Arun Iyengar via B4 Relay)
Newsgroups: linux.kernel.netdev
Subject: [PATCH net-next v4 5/5] net: stmmac: dwmac-sun8i: Register the
 MDIO mux in the MDIO setup
Date: Fri, 20 Nov 2026 10:45:36 +0000
Organization: Usenet Network
Message-ID: <20261120-sun8i-emac-mux-uaf-v4-5-57eba8915f25@gmail.com>
References: <20261120-sun8i-emac-mux-uaf-v4-0-57eba8915f25@gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
Injection-Info: usenet.network;
	logging-data="3137330"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:qCgaKiXz8/A19lRL3vNVI4emcFk= sha256:NEUp7TfhY18Ivj95c8c4S6yg9aMC99Rjj5Iwejxoo6Y=
	sha1:LPl3jF27dHzKd+14+hvKRKzKuWs= sha256:E0J8M6Rt0YVzQiFcQSjj1uRI3dsdPzLR5vUCWKV4X2E=
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 9BD5311596B; Fri, 20 Nov 2026 13:46:42 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.151
X-Spam-Status: No, score=-3.151 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,
	FREEMAIL_REPLYTO_END_DIGIT=0.25, MAILING_LIST_MULTI=-1,
	RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-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 47f1BFeUUFyR;
	Fri, 20 Nov 2026 13:46:39 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-367880-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 8B057115966; Fri, 20 Nov 2026 13:46:31 +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 7C3E51200EA; Fri, 20 Nov 2026 10:46:21 +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=3; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1795171555;
	b=1nG1gpeYV8SkxUnN97uSPrGFh8q9j5J63RrkpIpl6xkbyURIySAJHpzaIthZ7NH15/xt
	 KeuyLSNkqXvSWo5yv4QrHACEfoHD3YPqYGzALBgyGRTafj9Byo/Tp3fA8GLwdxM1aZWki
	 YaKP5qO3kN7aWmhNJGMT8cMqaw0i8B7IKurWSer81xE6ArFPf7EkCtFGDoVkwuOJXPuIp
	 BV0DTKGzAl+LaWSVXKrMiLycxZ92RGyL7+rl4/myy+ZK+cUusQG6MfwAVVDPAgyDg+paa
	 JhAINjxd/wYG9eGwLaPsETkckxi9pNKA9E+mgjW4/YOgXdgEh64Hd0M8EycodpuUyDg==
X-ARC-Message-Signature: i=3; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795171555;
	h=X-Original-To:Received:Received:DKIM-Signature:Received:From:Date:
	 Subject:X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe:
	 List-Unsubscribe:List-Owner:Precedence:MIME-Version:Content-Type:
	 Message-Id:References:In-Reply-To:To:Cc:X-Mailer:
	 X-Developer-Signature:X-Developer-Key:X-Endpoint-Received:
	 X-Original-From:Reply-To:Content-Transfer-Encoding;
	bh=4cMBRj+b901aGtJUyANY3Td7kRUuNaUX44ZRB5XZFG0=;
	b=HK2Yylt1jjyYVqail+kOwM2kjNpNPRjF0VSSbH6NCe5pu46vrqb85UsfVl4jXoVphmv9
	 yHSZiw4vm4tG5QUWj3CeOb11bEAUEFle9ny54zLLdMqM2uxiU/+F6EMNgNywE/QOhYjo2
	 gaTBtfPB9Px9X0sBeRz7o2fI86QLkvX9SO8NL3oaZe1bSiQmrj0INUUQuKrKXVDgcOX63
	 FS1ZgDzAWlSdhh846kZql9VwMrm4WlC5n76YG5IL7Hno+fy9X5QBYuprjDfjBrRT6W5Nj
	 Hb+ozP3JE86u3+d4uPIhsxJt8y2sMHawDKuWGKMT5DRYfb7Z4y5l8V3NRJRKa3Rnzfw==
X-ARC-Authentication-Results: i=3; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=WDbv4siK;
	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 4729F60A2610;
	Fri, 20 Nov 2026 10:45:55 +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=WDbv4siK
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=100.103.45.18
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1795171554;
	b=QgD+optFygSv4BPCtS11rSwJjgaEK93//W6TM3bgIDQBV0WAWQ1l0BSYixji8kwnZ7VR
	 73YCyQOKS7uFaE8h3+wp//a3AgEGkQ5BG+PFCAqNSB9EyKWz6V+UY7fATUKJQ2gnPGuwI
	 BVGRDB2SLk/slxBzEJRZmCi7BRHArXyyDL02P4ivFBBc1wolj69zo/SC+lzZb3kkvP/PA
	 TqGdScrLUJlR/kr9esLv/wDKjUAHFLzrVh45lkXcj4gxwzsML63wdFSCdNedPABFyMh9P
	 mSHhYHJRKeB7pj5vQdDoS1BihPMjbHCrzCxOQmYSuVOZHTKI32zD1KJZScjZ23Nnmug==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795171554;
	h=Received:DKIM-Signature:Received:From:Date:Subject:MIME-Version:
	 Content-Type:Message-Id:References:In-Reply-To:To:Cc:X-Mailer:
	 X-Developer-Signature:X-Developer-Key:X-Endpoint-Received:
	 X-Original-From:Reply-To:Content-Transfer-Encoding;
	bh=4cMBRj+b901aGtJUyANY3Td7kRUuNaUX44ZRB5XZFG0=;
	b=ItUW4kmBFIIZZ5uubCBTdFN5ASXN2BJg3wAaFkRURQnHOJS2xxSk/8y+OP0wGTM+S/tc
	 sykRatKQqSvZfyTSXlBj+n/imVLgSAC78bw0PqJZQA9kf2InrRiEXcAvbf29IuxHLzT5A
	 a5dVuCPdBApgR4a1eKhA5DOx6+9eKystB0X5XyOt5pMgg0LyoKdzunA1peh+nkwTpdQ4f
	 Ei2YyghcEkQ0IOw3b8hfUE19yufDBwFsS+0NgLVB1OirKPyM0evquX3D9yIH927XcwW7v
	 HmuSX3d8FooBvW3wBZxqETut0TNwjESjSA+43ysPmPVZin0GXe04/OmPQsqWhgbXD6g==
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=WDbv4siK;
	arc=pass header.oldest-pass=0 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 623BF60A2605;
	Fri, 20 Nov 2026 10:45:54 +0000 (UTC)
X-Authentication-Results: smtp.kernel.org; arc=none smtp.remote-ip=100.80.115.77
X-ARC-Seal: i=1; d=kernel.org; s=arc20260519; a=rsa-sha256; cv=none;
	t=1795171553;
	b=tfpiM/k0fu05qSAftCunN6pzkoYzJdNZioeRdhUlZwmcfOg1UVjbwoCJNwJY9T9gdGUh
	 W5b+NDHbeyBe9QHbcsYaETCC7a6fK028wbRiljRJwI2lIEkum6gEgeS5/jcdXXlJonQjg
	 GanzGOx1OPYtqEVj5Y9kzeGheBiChH34A6eUZqm/7KpG6ra72sKBoYSfY11+JPMjarFMq
	 iUCpbdQZHO6CdysgA7S6XTUp4tf4TuA4P7ywQp1Yno9u3B3ZK1sb2rvRvq9sfaAR5mdwu
	 efBvJjoGkRWIGSDySAi5bvrLL73JE7ov+8mTwPfWgj3KXQl53CEAuh9x3VzgyejyC1A==
X-ARC-Message-Signature: i=1; d=kernel.org; s=arc20260519; a=rsa-sha256;
	c=relaxed/relaxed; t=1795171553;
	h=DKIM-Signature:Received:From:Date:Subject:MIME-Version:Content-Type:
	 Message-Id:References:In-Reply-To:To:Cc:X-Mailer:
	 X-Developer-Signature:X-Developer-Key:X-Endpoint-Received:
	 X-Original-From:Reply-To:Content-Transfer-Encoding;
	bh=4cMBRj+b901aGtJUyANY3Td7kRUuNaUX44ZRB5XZFG0=;
	b=Sp43DaJxgh3qiBmYWNAkjmrSUCifQ6Cv4S/KZXPfoUr7twjOE7oHNBhfPQwRdoKD+gb/
	 pMNT1Psw/i8Gmm2hYZdaSWQJfwe6AatGvAheLfvLp/CMhxFYATJuZxLQJHXxP9y323EJS
	 gLBPkIP+9rF58UNVsIU9J5Is3qyqFzkGMX7LAMde1AKSJi3dWw6jAHNeHyJHHeGgIkuzI
	 pmPhyeo+tjkX4rbmJbKjMIPvvc05kP0J5ybbuqiGlnGa9E5q7F3NGWm70Wy0UyP/4STPr
	 GLUung5SxaNGKSP4omij1Y4UXWpZYJH07XffELL57npzar3yFyp+STxzZybvy1Mw/Xg==
X-ARC-Authentication-Results: i=1; smtp.kernel.org; 
	arc=none smtp.remote-ip=100.80.115.77
X-Received: from lkml.kernel.org (nexus.subspace.kernel.org [100.80.115.77])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
	(No client certificate requested)
	by smtp.kernel.org (Postfix) with ESMTPS id 5D1E21F000EF;
	Fri, 20 Nov 2026 10:45:43 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1795171553;
	bh=4cMBRj+b901aGtJUyANY3Td7kRUuNaUX44ZRB5XZFG0=;
	h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To;
	b=WDbv4siK9lct6BeRQftTXZ43dIPMqgdqFV2tKcPIceG+/T5DkFlTQKF843RhUizsQ
	 4E4NE8Xjg1ERMz7ZxP9U1uSqV7g+RdAHBKrxc97uGd3tbGld9a//KFesiYNMv0wSv7
	 typ/o6jTfsENf5R2c6mStlXAZg1yDDDxOP7pZPkH6uS9pTDqw91Wiotc2fLVIIFWY3
	 TWreJy9BgadNjbDnhu8h1ip1bPkuVxwDRhP9PmiD+9CA/mGJHdt9v8B8IZMbVNTWPg
	 AAgykz987e0FCKSGrq8SaQbaaH+85qmw9XRtMssp0I1s/OdOVjaGz2IYU03IXBCyhk
	 w2ANIZ8j6pBeA==
X-Received: from nexus.subspace.kernel.org (localhost [IPv6:::1])
	by lkml.kernel.org (Postfix) with ESMTP id 12CE649818;
	Fri, 20 Nov 2026 10:45:33 +0000 (UTC)
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
X-In-Reply-To: <20261120-sun8i-emac-mux-uaf-v4-0-57eba8915f25@gmail.com>
X-Cc: netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org, 
 linux-sunxi@lists.linux.dev, linux-stm32@st-md-mailman.stormreply.com, 
 linux-kernel@vger.kernel.org, Arun Iyengar <aiyengar1990@gmail.com>
X-Mailer: b4 0.15.2
X-Developer-Signature: v=1; a=ed25519-sha256; t=1795171532; l=3350;
 i=aiyengar1990@gmail.com; s=20261110; h=from:subject:message-id;
 bh=JfM+9MPeN1RmnCdgarPUkycnEJJWmRjCl52LkmzQh0s=;
 b=aTjlE4zwV3WTHytPRv86NIs+k/GjHC4xnrCKN6relL0LScb4VxAra3i8RkcT/XDCZkwYWaorK
 amiU4eEBE3FAcssbf+FD4c8tvmq1iKPfqAo3+xouKrDK4C5aTKdfw0u
X-Developer-Key: i=aiyengar1990@gmail.com; a=ed25519;
 pk=zXpRgUTrhaFe6jLyPqbBy3ccfkj04w0g2690Wv3mg+0=
X-Endpoint-Received: by B4 Relay for aiyengar1990@gmail.com/20261110 with
 auth_id=1480
X-Original-From: Arun Iyengar <aiyengar1990@gmail.com>
X-Reply-To: aiyengar1990@gmail.com