Netdev List
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: nb@tipi-net.de
Cc: opendmb@gmail.com, florian.fainelli@broadcom.com,
	bcm-kernel-feedback-list@broadcom.com, andrew+netdev@lunn.ch,
	davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org,
	pabeni@redhat.com, f.fainelli@gmail.com, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH net 1/4] net: bcmgenet: stop the PHY when a WoL resume rebuilds the datapath
Date: Sun, 18 Oct 2026 12:02:09 +0000	[thread overview]
Message-ID: <179232492989.3135.6148472964891077526@kernel.org> (raw)
In-Reply-To: <20261017-nb-genet-fini-dma-net-v1-1-47e7c57f6834@tipi-net.de>

Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.

Critical: 0 · High: 0 · Medium: 1 · Low: 0

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 bcmgenet_resume()
  (drivers/net/ethernet/broadcom/genet/bcmgenet.c), the new guard on the…

--

net: bcmgenet: stop the PHY when a WoL resume rebuilds the datapath

This patch adds a phy_stop() to the WoL teardown path in
bcmgenet_resume(), which runs when the MAC was found reset, so the
phy_start() in the rebuild does not warn and do nothing. The stop is
skipped when phy_is_started() says the PHY is not running, because a
failed earlier rebuild may already have stopped it.

> diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.c b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
> index e8908916558b1..308716cddc077 100644
> --- a/drivers/net/ethernet/broadcom/genet/bcmgenet.c
> +++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
> @@ -4288,6 +4288,9 @@ static int bcmgenet_resume(struct device *d)
>  		bcmgenet_rdma_disable(priv);
>  		bcmgenet_intr_disable(priv);
>  		bcmgenet_fini_dma(priv);
> +		/* An earlier rebuild of this datapath may have stopped it */
> +		if (phy_is_started(dev->phydev))
> +			phy_stop(dev->phydev);

[Severity: Medium]

If the PHY is in PHY_ERROR at this point, does it get past this guard
and still hit the phy_start() warning during the rebuild?

phy_is_started() only returns true for states at or above PHY_UP:

include/linux/phy.h:phy_is_started() {
	return phydev->state >= PHY_UP;
}

In enum phy_state, PHY_ERROR comes before PHY_UP, so a PHY in that state
skips phy_stop(). phy_stop() itself accepts PHY_ERROR without warning
and moves the PHY to PHY_HALTED:

drivers/net/phy/phy.c:phy_stop() {
	if (!phy_is_started(phydev) && phydev->state != PHY_DOWN &&
	    phydev->state != PHY_ERROR) {
		WARN(1, "called from state %s\n",
		...
	phydev->state = PHY_HALTED;
	...
}

The kernel-doc for PHY_ERROR in enum phy_state also says "phy_stop moves
to @PHY_HALTED".

Next, the rebuild calls bcmgenet_netif_start()->phy_start(), which only
accepts READY or HALTED:

drivers/net/phy/phy.c:phy_start() {
	if (phydev->state != PHY_READY && phydev->state != PHY_HALTED) {
		WARN(1, "called from state %s\n",
		     phy_state_to_str(phydev->state));
		goto out;
	}
	...
}

When that happens, the PHY is not resumed and the state machine is not
restarted. bcmgenet_resume() still returns 0, but the link stays down
until the interface is taken down and up again.

Nothing stops the PHY state machine during a WoL suspend:

  - bcmgenet_mii_probe() sets mac_managed_pm = true, so
    mdio_bus_phy_suspend() and mdio_bus_phy_resume() return early.
  - The WoL branch of bcmgenet_suspend() does not call phy_stop().
  - bcmgenet_wol_power_up_cfg() writes PHY_RUNNING or PHY_NOLINK
    without stopping the machine.

So two things in that window could leave the PHY in PHY_ERROR when this
check runs:

  - an MDIO error in _phy_state_machine(), via phy_error_precise()
  - a phy_error() call from a PHY driver's interrupt handler

Nobody has seen this happen in practice yet. It follows from the code
paths above.

The commit message says:

    A rebuild that failed can have stopped it already, and
    phy_stop() warns about that too.

That holds for PHY_READY and PHY_HALTED, but not for PHY_ERROR. Would it
make sense to have the guard accept the same states phy_stop() does?
For example:

	if (phy_is_started(dev->phydev) ||
	    dev->phydev->state == PHY_ERROR)
		phy_stop(dev->phydev);

The non-WoL path does not have this gap, because bcmgenet_netif_stop()
always calls phy_stop().

>  		enable_irq(priv->irq1);
>  	}
>

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261017-nb-genet-fini-dma-net-v1-0-47e7c57f6834%40tipi-net.de

  reply	other threads:[~2026-10-18 12:02 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-17 11:59 [PATCH net 0/4] net: bcmgenet: fixes for a failed resume and the ring rebuild Nicolai Buchwitz
2026-10-17 11:59 ` [PATCH net 1/4] net: bcmgenet: stop the PHY when a WoL resume rebuilds the datapath Nicolai Buchwitz
2026-10-18 12:02   ` netdev-bot+sashiko [this message]
2026-10-19  7:07     ` Nicolai Buchwitz
2026-10-17 11:59 ` [PATCH net 2/4] net: bcmgenet: do not tear the datapath down twice after a failed resume Nicolai Buchwitz
2026-10-18 12:02   ` netdev-bot+sashiko
2026-10-17 11:59 ` [PATCH net 3/4] net: bcmgenet: let the interface be reopened " Nicolai Buchwitz
2026-10-17 11:59 ` [PATCH net 4/4] net: bcmgenet: restore the Tx coalescing setting when the rings are rebuilt Nicolai Buchwitz

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=179232492989.3135.6148472964891077526@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=andrew+netdev@lunn.ch \
    --cc=bcm-kernel-feedback-list@broadcom.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=f.fainelli@gmail.com \
    --cc=florian.fainelli@broadcom.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nb@tipi-net.de \
    --cc=netdev@vger.kernel.org \
    --cc=opendmb@gmail.com \
    --cc=pabeni@redhat.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