Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.45 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796251811; b=zwgA2ziqlT4dX+vC0EQhHnUoq+eqH4ksfHooXCR/8vkQ/8HgjZt2HvR8TrBn9/VfvRMx pYjP6J9PFvMIcxi2KBM+QxGKYL5US5gwpE0quuO9L7EaEnWhZcsxo05q72wkDHIdZJgHZ /6eo4J9qgTfRwhDiU/NN7NGlxEBIZNR83B0Vqt+OyBoVbkAcNUeK7ofN5nm5DTnX2P/hb UTO0qbH8F2t6VeN/rBhdsTCSKBd2VKfV8mgj+yboqxHF5X9UhfhH73OVmeDC7fHmZgXL5 vLAQwi0xVf2TTLzdikYkGsl9iIeztq0njkKE/lId+U0JLJLyPzGBG248iG5ZldtlQTQ== 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-Forwarded-Encrypted: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=Lf3Nnp7ilVmnTEp8ZPiElccbkuVz/LNg5yArLAgY7Kt35fxHbv6K+xV+Zx4EOltA82fy CSVxOA4YHltu4tW7jvBpgImgUTXxYpJHe/kVbFtwHdTWPHHvuA4cr3DTtx2hYk+wsDOnP XOEGAJeNceqUC4CgkW+d5wL+JtvF8SUMn73PJXohnNO0M9/iadTrWsSSMQY9nZLTc65Yl j/NQkDRrK3BvrOoXofNmjoEggVFJZtQ3/E/uyDcXNqXNq+NRKtmNgxu+cZPFD/rQ+iTF/ HAfGMDHczjiCxHqFkYlAoaLPF9aTUdCfbbUyFnEO+dZwkG27Zehlxz+BKDz3RxlFZHA== 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.45 Received: from mail-dl1-f45.google.com (mail-dl1-f45.google.com [74.125.82.45]) (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 C136F606A337 for ; Wed, 2 Dec 2026 22:50:10 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org C136F606A337 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com 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 Received: by mail-dl1-f45.google.com with SMTP id a92af1059eb24-1b563e32936so9308369c88.1 for ; Wed, 02 Dec 2026 14:50:10 -0800 (PST) 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=uF3S380kvuGpCO87hpvSsLjf/Tjqw7WaTolmWi8dCnaDQluHPJSJ6VomNbHhZbxz6R V0KMAsbMAmdG9HX6XELneIlPuoofs5rdIlE6XfCYD2uezuxgbZ0bsqX5n0f9lfFRZWdN UGpwQ1mXqLax6nwC//moBojrY3MFDsKiygX9IZEuyVyqQAoJ2nM8N4u4+FeVOyaksZFR 3UF4cfrc+tNVZjhi4+n8nu0omeCHRRosAwllYdupq8mkKMhxgXg9kU8WimtScnjHWTMn ExiH90S+F//gKeCjT/f4i19K/+HZhi4gDqgCq4ijLUn9c05mi+t/4fp6PxroXwmKg6re 2ceA== X-Forwarded-Encrypted: i=1; AL+hErFulRqpsOH44jK1TOY0NLYNYxB8jXaIHdXvEA5IY/s10xoZ/80K7GilA8CS34mAq2Pr4VlEFIxHjjvGJSY=@vger.kernel.org X-Gm-Message-State: APuU4Z8MNr21gLYMkPBHycuajge7ZY3CGOZNB43cv2ni2HTFsR8vp7jJ tvAme3tbssBzUeZIH795Mc8/TnVtuJf4AYSKa0bKTolU9S2l1zcHx3h1 X-Gm-Gg: AZFdTZfpFArNTCA60XFLLHMjrYzZ5kYj3sHxxoZSguE4RE9QXk4TP53/zTapps63nhV d1Tmm0W7MRPxrHeQ+IbiN8WTEY3sU0r9P/+0prKsxBVg9uzhXRSz/76ilWZ/QM5LH+a2gDmeAJ9 mxnBr8zJdCiY+XNqLAkiykpdy6y05Lrpkwai4Se0cexlDioesY6zzxF9xTWJFW0fQlRiHd2ewNB /igMet2p/QVNKlqovZ9YNZK/94jQyRki4WcHCG2yfWqbsvYWONIBh1DNgy1kq3pXmxZpTGQ++sc ZVEoIWWtrxKMF1veEjT2u3VlSv+5zGXCEhryh+Bn3I+76mw+vmoN+AR2j4YtDWns+zpoHMZEpkB +BDgs8zK/BNpKLezydCCoc3zOPQOqLxMvdjHc1XRdPqkMtodnPjO9tlX616Y/ZYy/DtW2LetFVJ VRp7c1ySNJEKw9LmrBvOq/GXANMjRuGv+RVgHpv6epYmJwBDjd14HvLbyQZT62kaiItfanlDqmJ IgrlNpvBFiPY219nCq89P1q+6WTmSROrACTk6CIjsZkP/qcb23UrTDUvu4Pmx4Lwey0PMrF5Ssj opwCLMF6N1BSW99Hl8MiNysn6Nac 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) 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) From: Florian Fainelli To: netdev@vger.kernel.org Cc: Florian Fainelli , Simon Horman , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Heiner Kallweit , Russell King , Jijie Shao , Runyu Xiao , David Yang , Herbert Valerio Riedel , Danny Kukawka , Mugunthan V N , Sebastian Hesselbarth , linux-kernel@vger.kernel.org (open list), Manuel Lauss 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 Message-ID: <20261202224957.3043478-4-f.fainelli@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20261202224957.3043478-1-f.fainelli@gmail.com> References: <20261202224957.3043478-1-f.fainelli@gmail.com> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Simon Horman --- 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