🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #8627

Re: [PATCH net 03/11] net: au1000: disconnect the PHY before freeing the MDIO bus

#8627
From: netdev-bot+sashiko
Date: Thu, 29 Oct 2026 16:15
117 lines
12285 bytes
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.

Critical: 0 · High: 0 · Medium: 1 · Low: 0 (1)

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] In drivers/net/ethernet/amd/au1000_eth.c, au1000_remove() now
  calls phy_disconnect() after unregister_netdev().

Pre-existing issues:
- [Low] The two new phy_disconnect() calls (au1000_remove() after
  unregister_netdev(), and the au1000_probe() err_out path) run without…

--

net: au1000: disconnect the PHY before freeing the MDIO bus

This patch adds phy_disconnect() calls to the au1000_probe() error path
and to au1000_remove(). This balances the phy_connect() done in
au1000_mii_probe(). In both paths the disconnect runs before the MDIO bus
is unregistered.

> diff --git a/drivers/net/ethernet/amd/au1000_eth.c b/drivers/net/ethernet/amd/au1000_eth.c
> index 58bc8e1b539d5..70319b432182f 100644
> --- a/drivers/net/ethernet/amd/au1000_eth.c
> +++ b/drivers/net/ethernet/amd/au1000_eth.c
> @@ -1287,6 +1287,8 @@ static int au1000_probe(struct platform_device *pdev)
>  	return 0;
>  
>  err_out:
> +	if (dev->phydev)
> +		phy_disconnect(dev->phydev);
>  	if (aup->mii_bus)
>  		mdiobus_unregister(aup->mii_bus);
>  

[ ... ]

> @@ -1334,6 +1336,8 @@ static void au1000_remove(struct platform_device *pdev)
>  	struct resource *base, *macen;
>  
>  	unregister_netdev(dev);
> +	if (dev->phydev)
> +		phy_disconnect(dev->phydev);

[Severity: Medium]
Can this leave the MAC clocked and out of reset after the driver unbinds?

By the time au1000_remove() reaches this point, the MAC is already in
reset with its clock gated, and aup->mac_enabled is 0. If the interface
was never opened, au1000_probe() did this by calling au1000_reset_mac()
just before register_netdev(). If the interface was opened,
au1000_close() did it.

If the interface was never opened, phydev->suspended is still false,
because phy_attach_direct() resumed the PHY. In that case phy_disconnect()
does MDIO accesses:

phy_disconnect()
  phy_detach()
    phy_detach_internal()
      phy_suspend()
        genphy_suspend()
          phy_set_bits(phydev, MII_BMCR, BMCR_PDOWN)

Each of these accesses goes through au1000_mdiobus_read() or
au1000_mdiobus_write(). Both call au1000_enable_mac(dev, 0) first:

	if (force_reset || (!aup->mac_enabled)) {
		writel(MAC_EN_CLOCK_ENABLE, aup->enable);
		...
		writel((MAC_EN_RESET0 | MAC_EN_RESET1 | MAC_EN_RESET2
				| MAC_EN_CLOCK_ENABLE), aup->enable);
		...
		aup->mac_enabled = 1;
	}

Nothing later in au1000_remove() calls au1000_reset_mac() again before
the registers are unmapped and the netdev is freed. Before this patch,
remove left the MAC in reset with its clock gated.

The err_out path in au1000_probe() does call au1000_reset_mac(dev) after
phy_disconnect() and mdiobus_unregister(). Should au1000_remove() also
call au1000_reset_mac(dev) after phy_disconnect(), to match it?

[Severity: Low]
This is a pre-existing issue, not one introduced by this patch, but both
new phy_disconnect() calls run without RTNL held. In au1000_remove(),
unregister_netdev() has already dropped RTNL. au1000_probe() never takes
it.

phy_disconnect()->phy_detach()->phy_detach_internal() does:

		hwprov = rtnl_dereference(dev->hwprov);

With CONFIG_PROVE_RCU enabled, could this emit a one-time "suspicious
rcu_dereference_protected() usage" warning? The read itself looks
harmless, since au1000 never installs a hwtstamp provider.

Other drivers already call phy_disconnect() after unregister_netdev()
without RTNL, for example r6040_remove_one(), et131x_pci_remove(),
bgmac_enet_remove(), mlxbf_gige_remove(), hisi_femac_drv_remove() and
ixp4xx_eth_remove(). So this looks like a problem with the phylib
annotation, not with this driver.

>  	mdiobus_unregister(aup->mii_bus);
>  	mdiobus_free(aup->mii_bus);
>

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261027223140.3774570-1-f.fainelli%40gmail.com
Technical Details
Message-ID: <179329051062.3134.8683202411485629333@kernel.org>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-353365-linux-kernel-netdev=dewy.ru
References: <20261027223140.3774570-4-f.fainelli@gmail.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-353365-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net 03/11] net: au1000: disconnect the PHY before freeing
 the MDIO bus
Date: Thu, 29 Oct 2026 16:15:10 +0000
Organization: Usenet Network
Message-ID: <179329051062.3134.8683202411485629333@kernel.org>
References: <20261027223140.3774570-4-f.fainelli@gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="2045834"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:jnTDEb2DpUzUWsoyT1DiOKJ/sOI= sha256:B2k/zf9UWDvT/8LKIT3lqxaIJtL8SlT+9VIfXB2b1GE=
	sha1:xLlUqkXpt35R1mp1eGl79NZQ1IQ= sha256:ZxDXh2Au8XpQdEyucrmbc5AzzLFbqV5BkX2PshSG32s=
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 2CCE1125C6B; Thu, 29 Oct 2026 19:25:20 +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 JNAWAZpyQGhU;
	Thu, 29 Oct 2026 19:25:16 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-353365-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 574AC125C6C; Thu, 29 Oct 2026 19:25:08 +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 CF2E22E9D4; Thu, 29 Oct 2026 16:15:42 +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=1793290523;
	b=YeZ8mlMbhzK3BcayAJxU687HrEwTIDa7oT8HIqGKBBiEzihRiQ6/Su9b6F23Bo6p0Zas
	 0WMVPOFt0qaNesDCHTts7aDbFT5Jrs9NpHI4DtUuS+pS7p+q030tCjDXcPhwSN5TBtZAu
	 wmpyLdEs5oLgeyPY2FhXTRnpys5lAoG1PMItFX0F3NTan9crSFtugVOlut5yrOCtmvXuC
	 TLa7a8X0yA8xJvpSsSvV7kNlwJW0RLfBPTKPyOo35xyb5vRermbmum3wClsqiTOkvhx+k
	 hn8RjDZ5/JkGjtFUan9rA8R6dpruuoWZBSENgie52sT3Hnnro1GXQk+vUL/DWH5kZuQ==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793290523;
	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=H3Ht48U7r5upqNLR9c6At5eHo2k/mTK3e8pFH5RlT8o=;
	b=INhB5yJPslPVU+WWhuQE2i7avPWVCkKAlBrBvWD0oPQoY86xHnu+tvnBvUpmigmcqWvd
	 ga9W9ZiHfRHjtQ9jZfPScgXyq6MytMv0MYEbjrQdJY2wF5kOeKn8HBu/Exvxu8HLx8ngD
	 JXEyWFqyndegaFJdu6hbyAnfWFP5cTimBfuoR+jiEzAk4e+5BniONhhggDzq7g2+GYTIu
	 hmFPahpQzOXvn1JohtQFHFfTChZvwU5bIvqzrmLssviUsa6z1cj6yq0CcYHHAXGBmNB6/
	 1WaZNSol4HpM+XL271gABsiebihWwsyxJ4SacJLw2B6D1Jr9qWgHxJgC57vngPNAIaQ==
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=adxsOyO8;
	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 B668760A2639;
	Thu, 29 Oct 2026 16:15:23 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key, unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=adxsOyO8
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=1793290512;
	b=I5TC5iOtaaHR4qWaBrJadNLh80eLsQfMzjdBPK+MKU+OvhnCABQhoEkJnzjzCT1UiriR
	 R+QZM/ypD+TL+Hz8Pjd1WdcaAf5d/yliZ+WDKH32ewWGLMbMMuRLOKiTsjLoYTdntxr+v
	 Boun3JCm+l0o5tsy39WTU3dYxMEN4h5768x7HOUMaX241c/yNkVBW+dWF5uPVi+bzrDwi
	 pG0qnUogerMm8K+DZ+0dryaYFkIAPdD/53m0SNZbU35Pm7I1D8zMrQvkgBz+RfyIUG+T9
	 9MeB7bXWYGmLdKpk70+lgE8bI1I0fw7UoGFglrcPxUHuezt21Gfm5wqCe1wn6oH+QJw==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793290512;
	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=H3Ht48U7r5upqNLR9c6At5eHo2k/mTK3e8pFH5RlT8o=;
	b=JZBIHbxpsZczYb3Kj5go9Zp8vi4RxjQcJn+tOrqHdSUuVTnF5PfXAMtmevJ2CnPkwypW
	 hUCTesVR9383OrRXH9eBR1Y4J87djBExSGJPAoS7FrgYSD6iYCs6e/0bX6FYyr7ezCLvO
	 ym2PWgbPq2Z+saWchPSmzRIqpAZ5ybUtYe5GTgaiGSLiAYQGrrnmkjpoYQFp/KSZ90qtH
	 wS/OVRwS7VsUay0YZk6yf+siKFksvRpc89t5YrVTUtd1Nlw8TpXRLevcs4GApr9MpENpL
	 Mx6NKYEwguU6TDu2FDVW6an7eWJHuKJLl5D3HJsLZWie3wsaLxZnLXrnyRBE4J4otyw==
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=adxsOyO8;
	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 7BCB2606A325;
	Thu, 29 Oct 2026 16:15:12 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 147D31F01816;
	Thu, 29 Oct 2026 16:15:11 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1793290512;
	bh=H3Ht48U7r5upqNLR9c6At5eHo2k/mTK3e8pFH5RlT8o=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=adxsOyO86OAkINTzhxfFlFBBBQ4M9e/dH6MU3SG7Qa1X33af/IW2yspONkB6k3ISe
	 lowUsBDgTxKVO50eE1yP9AbucBJNdESf2af6K2QRYujrdqNCl1kORgtuOpxIGOTIAs
	 7pxv/SSAELY54Ndgxl0lDSOJWh55m8TYX27v6x7phgNwThnLZaUMneTYxG7vpI+qnW
	 GIC6q22C8FJQiurjiim9wZjGXe8kmY6pKngRyLjLfXAa+nf155P7sGztZsICuZfoi/
	 LwrUyCjOtztboOgC6IrFIdJSXg3Mochy4SV65qvBlC+0B8fu26TG93Qyoe7lzmdGCs
	 mJYwusveZveUw==
X-Cc: netdev@vger.kernel.org, andrew+netdev@lunn.ch, davem@davemloft.net,
 edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, hkallweit1@gmail.com,
 linux@armlinux.org.uk, shaojijie@huawei.com, horms@kernel.org,
 runyu.xiao@seu.edu.cn, mmyangfl@gmail.com, hvr@gnu.org, jeff@garzik.org,
 danny.kukawka@bisect.de, mugunthanvnm@ti.com, sebastian.hesselbarth@gmail.com,
 linux-kernel@vger.kernel.org, manuel.lauss@gmail.com
X-In-Reply-To: <20261027223140.3774570-4-f.fainelli@gmail.com>
X-sashiko-severity: Medium
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