🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #19761

Re: [PATCH net v3 09/10] net: au1000: keep the MAC stopped until the PHY link is ready

#19761
From: netdev-bot+sashiko
Date: Fri, 20 Nov 2026 10:32
135 lines
12765 bytes
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.

Critical: 0 · High: 1 · Medium: 0 · Low: 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).

- [High] The fix stops MAC RX/TX in only one place: the link-down branch
  of au1000_adjust_link()…
- [Low] The new au1000_hard_stop(dev) call in the link-down branch of
  au1000_adjust_link() (au1000_eth.c:460) runs inside…

--

net: au1000: keep the MAC stopped until the PHY link is ready

This patch stops MAC RX/TX in the link-down branch of
au1000_adjust_link(). In au1000_open() it resumes the PHY synchronously
before au1000_init(). It also changes au1000_init() to leave RX/TX
disabled until au1000_adjust_link() has acknowledged a link.

> diff --git a/drivers/net/ethernet/amd/au1000_eth.c b/drivers/net/ethernet/amd/au1000_eth.c
> index cb2f3333ba9fd..98a75aba92e1a 100644
> --- a/drivers/net/ethernet/amd/au1000_eth.c
> +++ b/drivers/net/ethernet/amd/au1000_eth.c
> @@ -456,7 +456,8 @@ au1000_adjust_link(struct net_device *dev)
>  		/* link state changed */
>  
>  		if (!phydev->link) {
> -			/* link went down */
> +			/* Stop the MAC before the PHY can remove its clocks. */
> +			au1000_hard_stop(dev);

[Severity: High]
This covers phy_stop() on close. Is there a path that powers the PHY down
without ever calling adjust_link, though?

During system sleep, mdio_bus_phy_suspend() only skips the PHY when
mac_managed_pm is set, and au1000_eth never sets it:

drivers/net/phy/phy_device.c:mdio_bus_phy_suspend() {
    ...
	if (phydev->mac_managed_pm)
		return 0;
    ...
	if (phy_uses_state_machine(phydev))
		phy_stop_machine(phydev);
    ...
	return phy_suspend(phydev);
}

phy_stop_machine() only cancels the work and moves the state to PHY_UP,
so it never reaches the PHY_HALTED path that calls phy_link_down():

drivers/net/phy/phy.c:phy_stop_machine() {
	cancel_delayed_work_sync(&phydev->state_queue);
	mutex_lock(&phydev->lock);
	if (phy_is_started(phydev))
		phydev->state = PHY_UP;
    ...
}

On MTX-1 the LAN83C183 then gets genphy_suspend(), which sets BMCR_PDOWN.
au1000_eth_driver has no .driver.pm callbacks. With the interface up and
the link up, the MAC appears to keep MAC_RX_ENABLE | MAC_TX_ENABLE set for
the whole sleep.

On resume, mdio_bus_phy_resume()->lan83c183_resume() waits 500 ms, and
the MAC is still running during that wait.

Those are the two conditions the commit message describes: "MTX-1 can
hang when the MAC runs while its MII clocks are absent or still
recovering."

This looks reachable on MTX-1 itself through s2idle, because
pm_states_init() always offers "freeze" even without platform
suspend_ops. Alchemy db1x boards can also reach it through suspend-to-mem,
via the db1x_pm_ops registered in arch/mips/alchemy/devboards/pm.c.

The last patch in the series ("net: au1000: reject frames larger than the
TX bounce buffer") only touches au1000_tx(), so this gap is still there
at the end of the series.

Would it make sense to add MAC-side suspend/resume handling here? Another
option is to set mac_managed_pm and stop and start the MAC explicitly.

[Severity: Low]
This call runs inside the spin_lock_irqsave(&aup->lock, flags) region of
au1000_adjust_link(), and au1000_hard_stop() ends with a busy-wait:

au1000_hard_stop() {
    ...
	writel(reg, &aup->mac->control);
	wmb(); /* drain writebuffer */
	mdelay(10);
}

Doesn't this mean every link-down event now spins for 10 ms with local
interrupts disabled? Before this change the link-down branch did no MMIO
and had no delay.

On close the wait also seems to happen twice. phy_stop() leads to
phy_link_down()->au1000_adjust_link(), which does the first hard stop.

au1000_close() then takes aup->lock with irqsave and calls
au1000_reset_mac_unlocked(). Since MDIO accesses have re-enabled the MAC,
mac_enabled is still 1, so au1000_hard_stop() runs again with RX/TX
already cleared:

au1000_reset_mac_unlocked() {
    ...
	if (aup->mac_enabled) {
		au1000_hard_stop(dev);
    ...
}

The delay is only there so the MAC can quiesce before phylib suspends the
PHY, and that suspend happens after adjust_link returns.

Could the register write stay under the lock, with the mdelay() moved
after spin_unlock_irqrestore()?

>  			aup->old_speed = 0;
>  			aup->old_duplex = -1;
>  		}

[ ... ]

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261117193223.2795612-1-f.fainelli%40gmail.com
Technical Details
Message-ID: <179517076197.3136.575167773294560465@kernel.org>
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-367869-linux-kernel-netdev=dewy.ru
References: <20261117193223.2795612-10-f.fainelli@gmail.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-367869-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net v3 09/10] net: au1000: keep the MAC stopped until the
 PHY link is ready
Date: Fri, 20 Nov 2026 10:32:41 +0000
Organization: Usenet Network
Message-ID: <179517076197.3136.575167773294560465@kernel.org>
References: <20261117193223.2795612-10-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="3134981"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:pLM1UGaN0QW059N7T+HcKdLFi88= sha256:DhGy0J0jqCYkQmjSKABdlzZDR0ZnFhciclypS8YQjx8=
	sha1:L5XGYJnv/a4BB3cThpQXKH/u69w= sha256:cvE4F6WS8RtF1hi9G0twzxmHYmBm6pWq1bhlufzPlo8=
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 7ED4611595F; Fri, 20 Nov 2026 13:33:36 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.4
X-Spam-Status: No, score=-3.4 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, URIBL_BLOCKED=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 a0nyiGw6AqwT;
	Fri, 20 Nov 2026 13:33:33 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-367869-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 A224011595C; Fri, 20 Nov 2026 13:33:24 +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 70E0BCAC55; Fri, 20 Nov 2026 10:32:50 +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=1795170764;
	b=SdVNEeN/D0k0Hr+pJTBaET74pc1Kf8H4RaaqyYIWqniTsqcTaRfv+QZtfeCMA/ikTLSG
	 4NY+4Mhu5jPsjEdoJjhIwlMl0pk7Y9fv3i6sldv8eGH1WGiAkr6uO+yx3mOHEuwUalkwY
	 q6UOXOdQoVvh8nMkdjGgOicDh5qRxwgnyiNNSrFksWZLDVOwDC7rGMcVkxVdFlknWDlob
	 ZEavJEu4ajJhfvRTK45bZmclJARSyGOzJLTpAPxjb7F3cVbyNyY1jsM+ck+CN7AVVo2aF
	 qFXb25pOlAufRMQWCATojmEaj9Jl0G7kB89DD8U+SR90IeIeqRwO0O/PPy9EXsKrQLw==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795170764;
	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=3Bzon3iWvUaUY96e3SA5cgJ7L9dQgMChALNIrIrFeCA=;
	b=MtjDOeTb44ZXcGTsxOsiKrC7OV/qYn/A5DriOVgn9iUT0fVuo2mb37VecXn6V4fpg5y7
	 xbklWveyf/VwF/DrdURuIMVk+bakLKiGGQ/Cy+jswRXIZJD+Tv3vUE3/z8J8LOl3/JuOG
	 f282HPoaIrq8xfROIHekBQWGXTV8hgtBsItuteWUHGVESpZmGNPfRAbEiGAJmdo1YC1YG
	 B6RAbKRrzS3aCtu5cL0xKyMpj1kHHGi3am/PQlvwOm+jcQjgutcI2wq0WzfZkmbveY6I2
	 XCY5et1lkGbSFbQwGkXJrDRdqvtSoz3OQapFg7Ffak2aToQgsgHR4PHanF9RurkVnsg==
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=d769vmyH;
	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 6226360A263C;
	Fri, 20 Nov 2026 10:32:44 +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=d769vmyH
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=1795170763;
	b=Z4Q9kCpZi/6DVa6whpTJmSUXi0wFR0ULlsHu+kC+iz+Fd7KuiEU12J7qO1BZTZ0cZhCm
	 Z4oBYiPzbxv4isMEPuxPWrPPWa6wrRDdE7k6Z3zIAsymdWTHoAtPSPCaFFj3EnOtGPJEs
	 O2xjlBJC6Y78mV3jBiC7eNpAbUwQpQNJ3WFHY2MJpI0AMgn38kEZAhUeIBtQbpYGoZV7M
	 QTJKX61bhtorFhQ+BjFGfTHv96OBVL1wham2jL6NmnoS/sAwTYpQH+dBbkxqKFevnXr9L
	 Re9XTc32EsQwP8b/nIyE7eFhuasQKVaVJ7+yDgMuuiut70/sw+THZldFuIhju1/1ufA==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795170763;
	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=3Bzon3iWvUaUY96e3SA5cgJ7L9dQgMChALNIrIrFeCA=;
	b=gaB5kC6RNpwHym9+PN+Fjgb/T8VGEA16AJhjQphl7g2C5tDApC/ltRoOhI3SFgRWgHWk
	 JYJGv9vKJ043mKVgOOb+vMJC7FpbUITd3udK+0OenT6DGHAHCxIKvp5sQuMO7K/HVu4v7
	 Ch/zg5QkqzmLqwTgR2aLE416Szk8XnneWQoHmgGpaae+RTvple9PtyiCJk6ay4lfS7cmB
	 1yuQVUSMSheHJiMf1AQoICz1h7K792ZorzdFQgz0ajHmU5F10eL+tz2rYwuMoiXMOcdHP
	 CzWLMWV8jmV7psJ00Pzfg4b6CU+EaWulWVgI8fBSL3cJx7dipCRy5L4zHjhoLoJS1Xg==
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=d769vmyH;
	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 832D860A262E;
	Fri, 20 Nov 2026 10:32:43 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5FE321F00A36;
	Fri, 20 Nov 2026 10:32:42 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1795170763;
	bh=3Bzon3iWvUaUY96e3SA5cgJ7L9dQgMChALNIrIrFeCA=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=d769vmyH+YXDYqXQIiDJyzrv96P2247yEvThlIwBs3NCaKJwM/vDydEZG41mPGDsZ
	 YrsygRu5d770zzC6z5bh9+cBGwZPAec1sg6u5VWvSPztLGygHIuTcvns9MD6llHnx3
	 XeK/nlnI1aIQt2m51g77dCR+hdgJB3tleJcUKpmGeVVlDVjj+8nE3jVC+P5opFqAOA
	 l+Cktg7FI/FTWxCYfI8RJg34ByGRZ0WaWA07xsUs4dchK8dVPoHKm4zxRFt1AiE93S
	 shgV9ywey/cSDRMtHN8h5kCZg8Eb6kvTpymp4QSq26IXN58wEzh+VkoUV3BuqS/+J4
	 zgJrbkSKuu1KA==
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,
 danny.kukawka@bisect.de, mugunthanvnm@ti.com, sebastian.hesselbarth@gmail.com,
 linux-kernel@vger.kernel.org, manuel.lauss@gmail.com
X-In-Reply-To: <20261117193223.2795612-10-f.fainelli@gmail.com>
X-sashiko-severity: High
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