Article View: linux.kernel.netdev
Article #25991[PATCH net v5 03/10] net: au1000: disconnect the PHY before freeing the MDIO bus
From: Florian Fainelli
Date: Wed, 02 Dec 2026 22:49
Date: Wed, 02 Dec 2026 22:49
102 lines
15065 bytes
15065 bytes
Balance phy_connect() on probe failure and removal. Otherwise device
and module references taken during PHY attachment leak, and the PHY
retains an attached_dev pointer to the freed netdev. The attachment path
uses PHY polling, so there is no PHY interrupt to release. Disconnect
before unregistering the bus while its MDIO callbacks and MAC registers
remain usable.
PHY teardown can re-enable the MAC for MDIO even if the interface was
never opened. Reset the MAC after PHY and MDIO bus teardown, before
releasing descriptors and register mappings. Skip MAC control accesses
when mac_enabled is clear, since stopping an already clock-gated MAC
hangs MTX-1. This guard also covers the existing probe failure path:
au1000_probe() resets and gates the MAC before register_netdev(), and
registration failure reaches another reset in err_out. If no intervening
MDIO access has re-enabled the MAC, that second reset must not touch its
control register. Always clear the DMA descriptor control bits and TX
state.
The teardown corrections were identified by Sashiko AI review and
hardware testing, with OpenAI Codex assisting implementation, validation
and commit-message consolidation. Previously validated on MTX-1 with
opened and never-opened removal, rebind and traffic; both removal cases
left the MAC enable register at zero. MIPS build and extracted-function
ASan/UBSan checks passed before this series was consolidated.
Sashiko AI review identified the polling-only attachment path and the
additional probe-unwind case; OpenAI Codex assisted call-path analysis
and commit-message revision. The registration-failure path was reviewed
in source but was not fault-injection tested.
Fixes: 0638dec01e89 ("[PATCH] net: au1000_eth: PHY framework conversion")
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Reviewed-by: Simon Horman <horms@kernel.org>
---
drivers/net/ethernet/amd/au1000_eth.c | 26 +++++++++++++++++---------
1 file changed, 17 insertions(+), 9 deletions(-)
diff --git a/drivers/net/ethernet/amd/au1000_eth.c b/drivers/net/ethernet/amd/au1000_eth.c
index 58bc8e1b539d..7063f9e5bc7c 100644
--- a/drivers/net/ethernet/amd/au1000_eth.c
+++ b/drivers/net/ethernet/amd/au1000_eth.c
@@ -584,14 +584,17 @@ static void au1000_reset_mac_unlocked(struct net_device *dev)
struct au1000_private *const aup = netdev_priv(dev);
int i;
- au1000_hard_stop(dev);
+ if (aup->mac_enabled) {
+ au1000_hard_stop(dev);
- writel(MAC_EN_CLOCK_ENABLE, aup->enable);
- wmb(); /* drain writebuffer */
- mdelay(2);
- writel(0, aup->enable);
- wmb(); /* drain writebuffer */
- mdelay(2);
+ writel(MAC_EN_CLOCK_ENABLE, aup->enable);
+ wmb(); /* drain writebuffer */
+ mdelay(2);
+ writel(0, aup->enable);
+ wmb(); /* drain writebuffer */
+ mdelay(2);
+ aup->mac_enabled = 0;
+ }
aup->tx_full = 0;
for (i = 0; i < NUM_RX_DMA; i++) {
@@ -603,8 +606,6 @@ static void au1000_reset_mac_unlocked(struct net_device *dev)
aup->tx_dma_ring[i]->buff_stat &= ~0xf;
}
- aup->mac_enabled = 0;
-
}
static void au1000_reset_mac(struct net_device *dev)
@@ -1287,6 +1288,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,9 +1337,14 @@ static void au1000_remove(struct platform_device *pdev)
struct resource *base, *macen;
unregister_netdev(dev);
+ if (dev->phydev)
+ phy_disconnect(dev->phydev);
mdiobus_unregister(aup->mii_bus);
mdiobus_free(aup->mii_bus);
+ /* PHY teardown may have re-enabled the MAC for MDIO accesses. */
+ au1000_reset_mac(dev);
+
for (i = 0; i < NUM_RX_DMA; i++)
if (aup->rx_db_inuse[i])
au1000_ReleaseDB(aup, aup->rx_db_inuse[i]);
--
2.53.0
Technical Details
Message-ID:
<20261202224957.3043478-4-f.fainelli@gmail.com>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu.MISMATCH!feed-us-txt.newsdeef.eu!feed-us-ny.newsdeef.eu!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-376085-linux-kernel-netdev=dewy.ruReferences:
<20261202224957.3043478-1-f.fainelli@gmail.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu.MISMATCH!feed-us-txt.newsdeef.eu!feed-us-ny.newsdeef.eu!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-376085-linux-kernel-netdev=dewy.ru
From: f.fainelli@gmail.com (Florian Fainelli)
Newsgroups: linux.kernel.netdev
Subject: [PATCH net v5 03/10] net: au1000: disconnect the PHY before freeing the MDIO bus
Date: Wed, 2 Dec 2026 14:49:50 -0800
Organization: Usenet Network
Message-ID: <20261202224957.3043478-4-f.fainelli@gmail.com>
References: <20261202224957.3043478-1-f.fainelli@gmail.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
logging-data="2079967"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:r4ullJfvg71H3CmpVtJRqSBc5b8= sha256:/QiO2o8llryzoYCcNtxFsTkiB4qbhA/8o7Y9sv4gAIY=
sha1:dDl/xNzkVm6frfCQ2C7Deml5jw4= sha256:uCoFizhJbKFgFUqG6oRyCOXF4/Q4oAI/9vDTATe0WxU=
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 A7176117763; Thu, 3 Dec 2026 01:50:33 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.149
X-Spam-Status: No, score=-3.149 tagged_above=-9999 required=6.31
tests=[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.249, 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 QPlo2HTctoGm;
Thu, 3 Dec 2026 01:50:30 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=netdev+bounces-376085-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 sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74])
by mail.dewy.ru (Postfix) with ESMTPS id C5F26117760; Thu, 3 Dec 2026 01:50:22 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
by sto.lore.kernel.org (Postfix) with ESMTP id E0C66602CFD; Wed, 2 Dec 2026 22:50: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=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
t=1796251812;
b=fvbfe/qLw1fLZyWhsM8fAGE3bZUAjUBTZo4lgPmfOWC/a7/pUxEk9sQ/iC5TnuMUegdo
MrrQ3RkpDIpbEEKhgkTT5bC2E0dvjJ+OBRYNkZIjs4HHBo1A7BIQi+3CaU4ULciGJZMuc
jbahuj5MaPvg83+b5W68UgF25yTu2r9D8PoEBXx+L7NM70KZ0F/IQCBnY3lPq5wa9/ARq
EH96ibAquKKmvVoraU7QYLsHG8GQ1D3tECSO6NNa0EQlYzoK2oZ9BZ7MmxcUfBG9FwOax
SwVW1mvcg0WjANYUnCzBJ3eWJxcFkhr2d7lK6/hUEG18NxYvhYjykpzGgHzcZvtu+Zw==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1796251812;
h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature:
X-Google-DKIM-Signature:X-Gm-Message-State:X-Gm-Gg:X-Received:
Received:From:To:Cc:Subject:Date:Message-ID:X-Mailer:In-Reply-To:
References:X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe:
List-Unsubscribe:List-Owner:Precedence:MIME-Version:
Content-Transfer-Encoding;
bh=Q8Jvty8Ctfs5xjH32H+u9qDxpxdGOzQSPOLbydpnLBs=;
b=Kx5W1VXTI/224l3dF0yTlLnrXxxZKuSF31sUPxjAa84wDUpvMh0YMEMyFHR8KWT3moFl
5tCXm2OyWjZcFbZQucvHc1FkUVSxqMuHADwPetmlRL+PjO8dR0M94W53luijzJQywxv+3
CpEAIjUJdCvq2tCdOR3bX5bJTE1qAGFX6yhOIPuXkbGa/8M0o1tCYH4Xv24l9K5AIaFp2
ZAmRTaDYP+cH75Uynq3bHa3qCv5XoyI7bcFOca+vwQ9HzWQkFzTleS7eE/HdxTWUecBti
8ZDD1YNMq9Q4dZvnLmxKcArFujKZGKdFwk1YwECtoQeAw0o6vYISOEq7pOUPsBZBNlQ==
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=PZQXYBnb;
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 0C68B606A681;
Wed, 2 Dec 2026 22:50:12 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=PZQXYBnb
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.50
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
t=1796251811;
b=EuqOg56kMRH0FK++QcRZijS/1SDcpzH2oE2a3BF4Vkpq4l5dFOiToGuiHORl8PeT3+eK
FTnYYVLBFSSnZg96Dc570bGFq5Tf/EqRV3O6aclfB7brKyd4IWTmbq7NS40iLrNnPSGgV
f477hF4TEcKGRK8Cu64fMZomRbnFn+gD2qVLyQpoDlU7Oy+y3y//wxKa1dzU5FWVwiHrv
PBhfeXVdY55lyfzkce3PczvmtoqEe9iGzSNRrAIYxuyEC9neRNhCj7JZzSa7f9metuASi
z8zXH19wDINbrrlQiEcJl+RdSXZTYMIhy63lv0F78ZOGD2gh0x/khTuQWIBKFXmgDxQ==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1796251811;
h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature:
X-Gm-Message-State:X-Gm-Gg:X-Received:Received:From:To:Cc:Subject:
Date:Message-ID:X-Mailer:In-Reply-To:References:MIME-Version:
Content-Transfer-Encoding;
bh=Q8Jvty8Ctfs5xjH32H+u9qDxpxdGOzQSPOLbydpnLBs=;
b=sDEkfWKa2rdsKQB9BCTRmSRTLIDsLXzUiPjDlntIutlGFoUkFNkjbVpQQZ0xCKfcmuU9
y0giDpalYBkVmJZmqzS4t8Oo/6vwRLL3oNZVmk03g2s3OToN/zomq8MStZzyToJslJXF9
O34xHITx1+9Hba9Y2/tqZ47EfOMLcqwSxYRxcp7JPpzQ3ImwSj6HGdCVgryQ1LOZLumZ4
Dm48jE64zf6nS7s2NvTHyd3GDv3bjNPir2uQJTrNswIJt+PFX7uitfgwaMIMtp5Ri1X9A
ICLT4oFHG/L6zZ2Tz8QidVFzfUWut/qhtvL4XDbYP6P7miQuBWS+C7lUFBb1ZoVFnfQ==
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=PZQXYBnb;
arc=none smtp.remote-ip=74.125.82.50
X-Received: from mail-dl1-f50.google.com (mail-dl1-f50.google.com [74.125.82.50])
(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 D2A4C606A6AD
for <netdev@vger.kernel.org>; Wed, 2 Dec 2026 22:50:10 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org D2A4C606A6AD
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-dl1-f50.google.com with SMTP id a92af1059eb24-1b5786e099cso14281191c88.0
for <netdev@vger.kernel.org>; Wed, 02 Dec 2026 14:50:10 -0800 (PST)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20260707; t=1796251810; x=1796856610; darn=vger.kernel.org;
h=content-transfer-encoding:mime-version:references:in-reply-to
:message-id:date:subject:cc:to:from:from:to:cc:subject:date
:message-id:reply-to:content-type;
bh=Q8Jvty8Ctfs5xjH32H+u9qDxpxdGOzQSPOLbydpnLBs=;
b=PZQXYBnbr0oWGgivEYJXi8N9xz37/N0FkCGoQR8su9uWFetG86El0JEH9+rDlKLfdE
RLzWIYKKhYTev0moOctiev/TWbbpJCLPZSM7Tbmz6m0T0Dl6/kCBIGilJt3zZciz/kYh
ca6ChWlFL9/Kfc5n/MAJZcoZXPkRkJ796/5UPkxFdwW40jQMSekJorYbBky0/7XtxCQ/
PODnqdpphINu+IO3bZMM24YCM+TSpB2Ry6LhW0TzdzF//PgyKxyqL2HQObXafqCU8ayh
1Erk2WVPexC3Uv4QewjoqqrK6jYOfjyrNFirS5VPZETKgWrPQvQ3UPs9/NVLSZvUklh/
2LiA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20260707; t=1796251810; x=1796856610;
h=content-transfer-encoding:mime-version:references:in-reply-to
:message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from
:to:cc:subject:date:message-id:reply-to:content-type;
bh=Q8Jvty8Ctfs5xjH32H+u9qDxpxdGOzQSPOLbydpnLBs=;
b=GY3GNCTbFwcMVWakalDy6pvfnx764EtHWaBRCRVHQ+dd/DurFx/9iisvhZ6F8uA9m7
btd9IaLssakk/nmSrF4R2pWxBiWNdlIP/UZZcciO4xoeRggb+ajkyp4tOUMMbz+no3SL
nmBZgHWJSDMbaqrs5Z7B5oiqEi/suzFoVEn9u3+0soFpxo5M+TnZOvb4lBsthU2NO+Qz
uHZzqEJampcQlyQTXFugqqZB6r05ZAgE/v9pTybHELtH/uTk9s1AeXLcGYiA8+g80n+I
52AGBnOxvNOF34f3MWa4DIgdCyF2QFHAZMquKXAAN9IZTPRsrc+zr65ohqT0MaB8KSIg
nS7A==
X-Gm-Message-State: APuU4Z8KjjWaD97spVblrS0ag9HalrSXpETiTHdonSozbBeQy4eeqWrz
cvn3FC98iDHRIsaiocQs15zJEvSI4RunDAXb7e2RkTnFEA/yXLbM1cjczYo0fw==
X-Gm-Gg: AZFdTZcFrhfI+Kk8A46YSAYloeDB3NaWPTwhQFuuaIiM9/EQkVzL4GpJ+N0/4oQIaT+
lWkPgUnIP3fZNZ2ZNJyAtYW6sLtqwrUIM5Xc38ZmafeLS3jRQmoYX8JPN9kfgxJ8oC2k7kfa/lW
kJv3iFa3r7ot4606mCXed3PKV/CQTy5O4hiGImPNP80SpbzYV5MqJMVKj79f9pvVL+Qzq4eHY8j
2AH8rqvwJ60vPPg7RVu2eyEZjVkfmkO27o3vthGY7QBOIi1enWzcIj75T8+jZd3vC+TDMucFdco
4RxWi08vcviidok5P4P+l5rqUy/EIpkZVqjoTbcGuhk8Oyfpn+oQbyn6tYZQZXvUsoqY5bIYMn2
F90UJCXr5HwLzO1ToXOfTvGMrtqbei1YFYWeN6lw6G6A1wUypvrmTZ+tB8sIBHqjojO6eMH29Zv
OcNkcrDXOAf1vgJ+201vJaOADfnZvxZ1RKFZlJsZNrbyEH8nGc+bOdNKsl2UAYHw7BDCm7SOeRM
huRltM2XbAFyXXlMDs8o5kPG/2B2XWqFWGvGxNDgh7QVlnHmrGqpKq8zmB+aQFEF75WNMV5TnAI
MGjUwNiVwrPsLDtoVhN5lwtxMJBK
X-Received: by 2002:a05:7022:4196:b0:1b2:3b5b:b80b with SMTP id a92af1059eb24-1b55689ee3amr64651422c88.8.1796251809725;
Wed, 02 Dec 2026 14:50:09 -0800 (PST)
X-Received: from eldorado ([2600:8802:b00:1f88:d294:66ff:fe95:a98e])
by smtp.gmail.com with ESMTPSA id a92af1059eb24-1b55684c85fsm151770048c88.14.2026.12.02.14.50.08
(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
Wed, 02 Dec 2026 14:50:08 -0800 (PST)
X-Cc: Florian Fainelli <f.fainelli@gmail.com>,
Simon Horman <horms@kernel.org>,
Andrew Lunn <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@kernel.org>,
Jakub Kicinski <kuba@kernel.org>,
Paolo Abeni <pabeni@redhat.com>,
Heiner Kallweit <hkallweit1@gmail.com>,
Russell King <linux@armlinux.org.uk>,
Jijie Shao <shaojijie@huawei.com>,
Runyu Xiao <runyu.xiao@seu.edu.cn>,
David Yang <mmyangfl@gmail.com>,
Herbert Valerio Riedel <hvr@gnu.org>,
Danny Kukawka <danny.kukawka@bisect.de>,
Mugunthan V N <mugunthanvnm@ti.com>,
Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>,
linux-kernel@vger.kernel.org (open list),
Manuel Lauss <manuel.lauss@gmail.com>
X-Mailer: git-send-email 2.53.0
X-In-Reply-To: <20261202224957.3043478-1-f.fainelli@gmail.com>
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