🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #8659

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

#8659
From: Florian Fainelli
Date: Thu, 29 Oct 2026 17:23
127 lines
16022 bytes
On 10/29/26 09:15, netdev-bot+sashiko@kernel.org wrote:
> 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);
>>
> 

Agreed. PHY teardown can re-enable the MAC through MDIO accesses. I’ll 
update patch #3 to call au1000_reset_mac() after MDIO bus teardown, 
matching the probe error path.

The RTNL annotation concern appears to be a separate phylib issue shared 
by other drivers.

pw-bot: cr
-- 
Florian
Technical Details
Message-ID: <b15c85ea-85b4-4900-b422-07fd629c0b6e@gmail.com>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-353408-linux-kernel-netdev=dewy.ru
References: <20261027223140.3774570-4-f.fainelli@gmail.com> <179329051062.3134.8683202411485629333@kernel.org>

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-353408-linux-kernel-netdev=dewy.ru
From: f.fainelli@gmail.com (Florian Fainelli)
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 10:23:52 -0700
Organization: Usenet Network
Message-ID: <b15c85ea-85b4-4900-b422-07fd629c0b6e@gmail.com>
References: <20261027223140.3774570-4-f.fainelli@gmail.com>
 <179329051062.3134.8683202411485629333@kernel.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="2059189"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:a7iUG5NgI1fKa39lgE9nTXarR20= sha256:B1V9Sl3Fo7VitfpRu83xWnwJu3VTyLtVjop4SRYyRYY=
	sha1:fN9BE2tkBf8GWrXyVxsVXs+3TOA= sha256:sNcozQV0KwPzQmOFzTfHKv+r/J07a11p0skCUmKdwqQ=
Content-Language: en-US, fr-FR
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 BA75A125C6C; Thu, 29 Oct 2026 20:24:40 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.048
X-Spam-Status: No, score=-3.048 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
	DKIM_VALID_AU=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.001,
	FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=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=gmail.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 RtN6denUsl2I;
	Thu, 29 Oct 2026 20:24:38 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=104.64.211.4; helo=sin.lore.kernel.org; envelope-from=netdev+bounces-353408-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=gmail.com
X-Received: from sin.lore.kernel.org (sin.lore.kernel.org [104.64.211.4])
	by mail.dewy.ru (Postfix) with ESMTPS id 7DC53125C6B; Thu, 29 Oct 2026 20:24:27 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sin.lore.kernel.org (Postfix) with ESMTP id F12502310A; Thu, 29 Oct 2026 17:24:01 +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=1793294640;
	b=HkDOxXnsI8mGjEsExMMoZyorrmThdpYPPxyjcBS8zl3j/OojBbLOLK40vpT0rl2v6Q6T
	 F635WdeBCS6hkiEsN2fOmNLHX3PFPX8N1nINU3sohrl5i9Mhh6RI2BrY8ptBFjsmmvjr3
	 7JtGxW5QUIC9jejTaFeANVhdzD1b79VX0nU5rNnEzXEjkHPytlx4W19WxpUbAJQ+T4Khd
	 3bL66lnD4Bad1gtKpKBA6VFtf1MxaLWThS35KrG8If0OtwCl392JaEX6Eyx2FQHqfHWgo
	 fnYNpWaUvWVV3VQLGmBJOM6AXCQXWhoHs+7kk393rz61W1iQ1BXVn7WNkmhwJCQM07A==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793294640;
	h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature:
	 X-Google-DKIM-Signature:X-Gm-Message-State:X-Gm-Gg:X-Received:
	 Received:Message-ID:Date:X-Mailing-List:List-Id:List-Post:List-Help:
	 List-Subscribe:List-Unsubscribe:List-Owner:Precedence:MIME-Version:
	 User-Agent:Subject:To:Cc:References:Content-Language:From:In-Reply-To:
	 Content-Type:Content-Transfer-Encoding;
	bh=kDOYEDypZwZQvak6poIdRizAekLUNGBFX3LN2eRVDcU=;
	b=jwM99+Jftje26E6TNts7g366+2yfBqLtmNwrHKALsyGCCqmKq812IUZgIB/WXu4PXqvG
	 lFXQlP37vG/9r+qWUOF5bxXn+zypKpONAXxPUOsmcOLuWRpnXFHpGE0MJfEJZCslG9uS4
	 RMwX/+ttbAoWyMmBEUTI4Ur6SUNlTNfCm6hR7CsXDM0lB701Q3WiQ5Adh2wZIZOubVDmH
	 3CfB0lZReOcT7uBMuuTtfWvCjX90DiQp/a2fQTowrKTqIa2XBqWTOnK0ofhQ8U3eyggzm
	 pSC7jx2bv3Bu0qrg0P8rsg9F1EPgviMWGmxdcpocSfzNucv2ED18XTAPn+iQDAuXxDA==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=XUrrV0Xg;
	dmarc=pass header.from=gmail.com;
	spf=pass smtp.mailfrom=gmail.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 F14CB606A32C;
	Thu, 29 Oct 2026 17:23:59 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=XUrrV0Xg
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.215.175
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1793294639;
	b=ThBoYgDdcwExkwVoaDimegQaXfuc8yKPZvtmNXB0sQ3Ne/irQVA2elrtB1tfA1Y60Iyt
	 Vs0ABbNAmx1P81/J/8bG4pkpWvleTPe78iuhcpxVzdNVtRTc6/zKn11wRok7MO4pd91dW
	 pRwXLyefbmf47xpqb3iSGPAHjhv3h43EiOn0hSeM8m+RHGigQd5aoWHBmhig/oLP/AIJr
	 DAyuLaV6g7CvPuwoJZMxPgwGcq38Yx52k7Kt+APnD1L2uBiIEzwlbbR88yGHHVUduLVk+
	 vdvAYBtcvMR4NVWikUZk0v5jzuPzaS2UiWHNfh2BN3BJUM3iog17CFf5I9YOgkvicEA==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793294639;
	h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature:
	 X-Gm-Message-State:X-Gm-Gg:X-Received:Received:Message-ID:Date:
	 MIME-Version:User-Agent:Subject:To:Cc:References:Content-Language:
	 From:In-Reply-To:Content-Type:Content-Transfer-Encoding;
	bh=kDOYEDypZwZQvak6poIdRizAekLUNGBFX3LN2eRVDcU=;
	b=hEkTR3W1jyut4DA9zHRTfTUXXjIQcRsKHNgpu4sb85ftp99aIyJf0gOYKmf0xjskITEV
	 dOthg+wXTas+seHvnjWY4Obe6lQLA/7BCCYyH9uw0UE6Sd91fi+rxLvW+1p7dUXRJWxnk
	 6xUDqUr/zldJU52/2vz11KU2suhWZmcBJIWp9CAKVTs5a4getehswmSRYGpFGg2Fymg2x
	 NXgd5US45flJe7DktYys6/bNMyodyB9ZYy1cClOsNTXECGOm1xlhPOGRUAPWlt53/7lXQ
	 i+25EWnm6v7yK5STSivS/dumywMN9wuUEpL0/JPA0UKhLSxILNz8/yyAL+VUsaFB0kA==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dmarc=pass header.from=gmail.com;
	spf=pass smtp.mailfrom=gmail.com;
	dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=XUrrV0Xg;
	arc=none smtp.remote-ip=209.85.215.175
X-Received: from mail-pg1-f175.google.com (mail-pg1-f175.google.com [209.85.215.175])
	(using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id C3E6C606A31C
	for <netdev@vger.kernel.org>; Thu, 29 Oct 2026 17:23:58 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org C3E6C606A31C
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com
X-Received: by mail-pg1-f175.google.com with SMTP id 41be03b00d2f7-cc52c1b8286so642792a12.1
        for <netdev@vger.kernel.org>; Thu, 29 Oct 2026 10:23:58 -0700 (PDT)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20260707; t=1793294638; x=1793899438; darn=vger.kernel.org;
        h=content-transfer-encoding:content-type:in-reply-to:from
         :content-language:references:cc:to:subject:user-agent:mime-version
         :date:message-id:from:to:cc:subject:date:message-id:reply-to
         :content-type;
        bh=kDOYEDypZwZQvak6poIdRizAekLUNGBFX3LN2eRVDcU=;
        b=XUrrV0XgCwb6DIMhoQZ1+DIjsS5tP74/bl3g3LFluCRlh1hmrBW3QmxOjEPrmqEmvP
         RrVkqDp0aixBRtdtQZkGDMTryt5cXGLViw+OC6ckWhBStpeT44up24n0KEyi9W4LXZO4
         lzJBGqSV8MsKcczDJoPmtEJC47YglRWYwt45QXDmfjoDQABQ9ZA96NDwRRvoNF2H4uFs
         oRmJE92Mi3EuRIUFmug1Dppv3plLfRqvCmbrMZaZBeowoD5G0cOpBR6wQBoYmz70AUMk
         CdzhmGfdzROHHtb1Rtr+0LfK2L93TZHwH6Cu8LHimLeIxSheK+KvlBA55029G/3dq0yW
         ct8w==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20260707; t=1793294638; x=1793899438;
        h=content-transfer-encoding:content-type:in-reply-to:from
         :content-language:references:cc:to:subject:user-agent:mime-version
         :date:message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date
         :message-id:reply-to:content-type;
        bh=kDOYEDypZwZQvak6poIdRizAekLUNGBFX3LN2eRVDcU=;
        b=Y0yeOx3Sem2b1g3X+1KNcFDfTLNnWkYjTCMQBGGYjzNylxgQdKIvsSMFfPfjDSra+6
         FPBzzSXp3hQ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==
X-Received: by 2002:a17:90b:2585:b0:3a7:9ec3:ea0e with SMTP id 98e67ed59e1d1-3ae6ed455e9mr2153404a91.22.1793294638096;
        Thu, 29 Oct 2026 10:23:58 -0700 (PDT)
X-Received: from [10.67.48.245] ([192.19.223.252])
        by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3ae6e98f888sm5003173a91.13.2026.10.29.10.23.55
        (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);
        Thu, 29 Oct 2026 10:23:56 -0700 (PDT)
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-User-Agent: Mozilla Thunderbird
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: <179329051062.3134.8683202411485629333@kernel.org>