Netdev List
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: f.fainelli@gmail.com
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
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	[thread overview]
Message-ID: <179517076197.3136.575167773294560465@kernel.org> (raw)
In-Reply-To: <20261117193223.2795612-10-f.fainelli@gmail.com>

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

  reply	other threads:[~2026-11-20 10:32 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-17 19:32 [PATCH net v3 00/10] net: au1000: Bug fixes Florian Fainelli
2026-11-17 19:32 ` [PATCH net v3 01/10] net: au1000: recycle RX descriptors on allocation failure Florian Fainelli
2026-11-17 19:32 ` [PATCH net v3 02/10] net: au1000: clear all-multicast mode when restoring hash filtering Florian Fainelli
2026-11-17 19:32 ` [PATCH net v3 03/10] net: au1000: disconnect the PHY before freeing the MDIO bus Florian Fainelli
2026-11-20 10:32   ` netdev-bot+sashiko
2026-11-17 19:32 ` [PATCH net v3 04/10] net: au1000: report MDIO transaction timeouts Florian Fainelli
2026-11-17 19:32 ` [PATCH net v3 05/10] net: au1000: serialize TX completion with packet submission Florian Fainelli
2026-11-20 10:32   ` netdev-bot+sashiko
2026-11-17 19:32 ` [PATCH net v3 06/10] net: au1000: restore receive filtering before enabling RX Florian Fainelli
2026-11-17 19:32 ` [PATCH net v3 07/10] net: au1000: restore RX buffer addresses when restarting the MAC Florian Fainelli
2026-11-20 10:32   ` netdev-bot+sashiko
2026-11-17 19:32 ` [PATCH net v3 08/10] net: phy: smsc: wait for LAN83C183 power-down recovery Florian Fainelli
2026-11-20 10:32   ` netdev-bot+sashiko
2026-11-17 19:32 ` [PATCH net v3 09/10] net: au1000: keep the MAC stopped until the PHY link is ready Florian Fainelli
2026-11-20 10:32   ` netdev-bot+sashiko [this message]
2026-11-17 19:32 ` [PATCH net v3 10/10] net: au1000: reject frames larger than the TX bounce buffer Florian Fainelli
2026-11-17 19:38 ` [PATCH net v3 00/10] net: au1000: Bug fixes netdev-bot+sinfo
2026-11-17 21:54   ` Florian Fainelli

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=179517076197.3136.575167773294560465@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=andrew+netdev@lunn.ch \
    --cc=danny.kukawka@bisect.de \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=f.fainelli@gmail.com \
    --cc=hkallweit1@gmail.com \
    --cc=horms@kernel.org \
    --cc=hvr@gnu.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=manuel.lauss@gmail.com \
    --cc=mmyangfl@gmail.com \
    --cc=mugunthanvnm@ti.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=runyu.xiao@seu.edu.cn \
    --cc=sebastian.hesselbarth@gmail.com \
    --cc=shaojijie@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox