๐Ÿš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #21721

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

#21721
From: netdev-bot+sashiko
Date: Tue, 24 Nov 2026 11:16
142 lines
13409 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] The commit fixes two user-visible bugs but has no Fixes: tag and
  no Cc: stable.
- [Low] The mux children (and the PHYs on them) are now torn down after
  the EMAC has been put back into reset.

--

net: stmmac: dwmac-sun8i: Register the MDIO mux in the MDIO setup

This patch moves registration of the sun8i MDIO mux out of
sun8i_dwmac_probe(), where it ran after stmmac_pltfr_probe() returned,
and into the new plat->mdio_init() hook. The mux now exists before
register_netdev(). Teardown moves from sun8i_dwmac_remove() into
plat->mdio_exit(), which runs after unregister_netdev().

> 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>

[Severity: Low]
The message describes two user-visible bugs: an early open that cannot
find the PHY, and an oops on unbind. There is no Fixes: tag and no
Cc: stable. Should these tags be added so the fix is picked up for
backporting?

The probe-side logic ("The mux must be registered after parent MDIO so
after stmmac_dvr_probe()") seems to come from commit 634db83b8265
("net: stmmac: dwmac-sun8i: Handle integrated/external MDIOs").

The remove-side ordering seems to come from commit 529254216773. That is
the ordering where sun8i_dwmac_remove() calls mdio_mux_uninit() before
stmmac_pltfr_remove().

A backport would also need the earlier patch "net: stmmac: Add MDIO init
and exit platform hooks". The message says "the new mdio_init() and
mdio_exit() hooks" but does not name that patch. Could the dependency be
named explicitly?

> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
> index 4acfda235394d..0ec25ae0b77ef 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c

[ ... ]

> @@ -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);
> +}
> +

[ ... ]

> @@ -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);

[Severity: Low]
With this change, stmmac_mdio_unregister() calls mdio_mux_uninit()
through plat->mdio_exit(). In stmmac_dvr_remove() that call comes after
the EMAC resets are asserted:

drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:stmmac_dvr_remove() {
    ...
	phylink_destroy(priv->phylink);
	if (priv->plat->stmmac_rst)
		reset_control_assert(priv->plat->stmmac_rst);
	reset_control_assert(priv->plat->stmmac_ahb_rst);

	stmmac_pcs_clean(ndev);
	stmmac_mdio_unregister(ndev);
    ...
}

Before this patch, sun8i_dwmac_remove() tore down the mux children while
the EMAC was still out of reset. On H3/H5, sunxi-h3-h5.dtsi supplies the
stmmaceth reset, so plat->stmmac_rst is non-NULL there.

Could MDIO accesses made while the PHYs behind the mux are being removed
now reach an EMAC held in reset? This happens with CONFIG_PHYLIB_LEDS
and a PHY driver that implements led_brightness_set. The path looks like
this:

stmmac_mdio_unregister()
  sun8i_dwmac_unregister_mdio_mux()
    mdio_mux_uninit()
      mdiobus_unregister(child)
        phy_remove()
          phy_leds_unregister()
            led_classdev_unregister()      /* LED_OFF */
              drv->led_brightness_set()
                mdio_mux_write()
                  mdio_mux_syscon_switch_fn()
                  pb->mii_bus->write()     /* stmmac MDIO write */

If the target child is not the one currently selected,
mdio_mux_syscon_switch_fn() also does more work against the block in
reset. It rewrites the syscon EPHY select bits, toggles internal EPHY
power, and calls sun8i_dwmac_reset(priv->ioaddr).

It is not verified what the hardware returns for reads from a block in
reset. If it returns 0, the MII busy-bit poll and the soft-reset poll
would pass at once and the PHY write would be dropped silently. The PHY
LED could then stay in its previous state after unbind.

The practical impact looks limited:

The only in-tree H3/H5 board with PHY LED nodes is
sun50i-h5-orangepi-pc2.dts. It uses an RTL8211E, and that realtek driver
entry has no led_brightness_set.

Other glue drivers already have the same reset-before-mdio_unregister
ordering for PHYs that sit directly on the stmmac bus.

sun8i_dwmac_exit() and sun8i_dwmac_unset_syscon() still reconcile EPHY
power and syscon afterwards.

-- 
Sashiko AI review ยท https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261120-sun8i-emac-mux-uaf-v4-0-57eba8915f25%40gmail.com
Technical Details
Message-ID: <179551898345.3135.1078888477341036847@kernel.org>
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-370275-linux-kernel-netdev=dewy.ru
References: <20261120-sun8i-emac-mux-uaf-v4-5-57eba8915f25@gmail.com>

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-370275-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net-next v4 5/5] net: stmmac: dwmac-sun8i: Register the
 MDIO mux in the MDIO setup
Date: Tue, 24 Nov 2026 11:16:23 +0000
Organization: Usenet Network
Message-ID: <179551898345.3135.1078888477341036847@kernel.org>
References: <20261120-sun8i-emac-mux-uaf-v4-5-57eba8915f25@gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="4121725"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:Ail1GrYq0lDnR3B29Qx1lQQ37cQ= sha256:u2tdg6O82xQu8iSVZP6yuG/pTLVcZPVUYARHkhyic9s=
	sha1:qzZSUUe7SFZIvWOI4m8CEhqq9FM= sha256:bnHEV54PmLi+9KHzTJ5ReGwEbxEdyEdzprM01yUEzzY=
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 2DFE5125DFC; Tue, 24 Nov 2026 14:16:46 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.401
X-Spam-Status: No, score=-3.401 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,
	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 3yz8TkaGKYI2;
	Tue, 24 Nov 2026 14:16:42 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-370275-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 133DA125E01; Tue, 24 Nov 2026 14:16: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 DE8792CF12; Tue, 24 Nov 2026 11:16:27 +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=1795518986;
	b=X//vcaAhV9NLhAnOHGTI6pyDy3Owkl8uJTptJBAFFhKJiLwOCZrQQssoI+Z691isdSyO
	 QmKwlsWnHOkrdMAJgVQq6hTayS7f2hLz3ii+4JA9BmGTRxY7VfeH/vfFZ54SlTY10NG+p
	 zdK9wQGq/HjWFEvFy3jwO53rt7HcIcEzcDN+fowfGjXUgN9q65nUglSPjwvnQsRjP9TjC
	 V0Vi+TYli7JIPUrChNFHloIVnXkLYrjjRhbepsrM2qzMZlw+3meKwYyIeX2VrQmtmySfU
	 8N+kMQrvTHv26JFm76JgIWkV/rVPQMKJFkCmekiKafhfoe8f9iMCI3V/VQWH/MtwK0g==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795518986;
	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=FgfkXvgrc7uLZ8CZZkTM/Ni360utD6hlAVDSp6eqokk=;
	b=0q/FvOESvlx9Xdrs6DFoDwdge4aZAm3WuCFx5aNG5QwSBJuDaavbC4IiViFmgJDGhQFv
	 9RC2cMthS9qE5tRNxz5vAmZT41KPFOVjojogh9SsM88laOxu2nZ/1SvlmpwkvDO/yuJi5
	 MRPhkOzQZ47aZQI7MJq56KnuYNZIHq6SJXQDRYfiaohoLPP0HtlWTnzpBJevZOrDM02fL
	 sLjNQHfUXGOttsGVT84susAQV/+ileGYrnbaQMKGfdouJV/knJ4N6S2KMpZKRJq6AXwks
	 yQNKJ7N4RmX9ZG6B1qxnFMWCI29jH4nj32KnaDBxFKLYT3/JBH7sIkPCrf5Q98NTs1A==
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=k0kVkh8d;
	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 607DE606A685;
	Tue, 24 Nov 2026 11:16:26 +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=k0kVkh8d
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=1795518985;
	b=zxbNpe/Y0rOwUSdz822patC6FoyyNcS/aw7xjl3DCGP6XlV+Bj8CjVjpDKTOj10XYhRk
	 gxa1n/JFN59WA9AlrsuUjqkulcaB2J3rVEaDuxy9WEAO8137ZfzjKjdlJOMXe9GhWI6Gt
	 6Zc4P3zyWJtoQaP6mna/0JwlX5QuXoH1rCRH6jAxVy1n8vReJ12qy6dY2W+V2pTb37gcO
	 DMYPgrHDYA9s5pjTs+rJunsplzEDWXdAphe+6pJDRpV0nhdcUjjHibTeZZa1bV1g3y5mx
	 Olf1VERErxtGu3RkEDfWjJRepy/JWfK5YXBjvaFNp70HB5nntBTkOCq2F/32jMif50A==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795518985;
	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=FgfkXvgrc7uLZ8CZZkTM/Ni360utD6hlAVDSp6eqokk=;
	b=RLWHYanLiW9+R3twj+izaWl8Hnr3iXR3Izc5BeUqrn63ZtG1VwiMVdmy/gjPemSLXR6g
	 EW8WRbn3oBsZeY9kTYuAQ4JsKTtiHD14SFkyiMNUOnDrROCyLf3qI9LFmVGOvN8DHvkOy
	 37cfWqCrXr+7j0IzC+GsL4VJdR5JpRMbMvUh7+a/IagfwlBT5XioY5vlG6/X65IKI3eNX
	 4iWQ0EARdIV9yRUbqn32poaHzKn+NA05qBnbTpykFicg7dvzxtYU+egO6g1rau6jQYPuK
	 0B1qdzjYnKcQ6XAsu8CqpHlvpcLbj4sqPSo+fNVez5LlyROIP8TQFZhfxgQgmrtMb3w==
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=k0kVkh8d;
	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 82E53606A32A;
	Tue, 24 Nov 2026 11:16:25 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id E39731F000C0;
	Tue, 24 Nov 2026 11:16:23 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1795518985;
	bh=FgfkXvgrc7uLZ8CZZkTM/Ni360utD6hlAVDSp6eqokk=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=k0kVkh8dZcS/xPqg16cgv3QP+uZzFSq2766UJlz1RxFDRIymeZXSFErQy7uhrfZLR
	 VT/mwGl14pTgUJ4A2BYosFih2psoKYXILqbhLHy3Z390QCcdA3nBrjR9dS2bjgbNSw
	 R6UUBCbAWaZ93WvZQMXK4Wg32x85Fxzzy9tQ1IRodkJmsbOX1wukPze5ZNE8sW1osT
	 10thy26lELO1nJlPytAKtP9Yncw0tVEmA+YdXSHdh8W7Rbk0Lawy4tmEikl0t28srd
	 Ip2tZEhVDWIHrBuIeH6jcifwLxkIVK12H4G6o9Pwam0UA46I3Bj8uSNn6d7VN3xF15
	 +nTqmbvqvsKjg==
X-Cc: maxime.chevallier@bootlin.com, andrew+netdev@lunn.ch, davem@davemloft.net,
 edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com,
 mcoquelin.stm32@gmail.com, alexandre.torgue@foss.st.com, wens@kernel.org,
 jernej.skrabec@gmail.com, samuel@sholland.org, p.zabel@pengutronix.de,
 linux@armlinux.org.uk, 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
X-In-Reply-To: <20261120-sun8i-emac-mux-uaf-v4-5-57eba8915f25@gmail.com>
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