mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: iav@iav.lv
Cc: andrew@lunn.ch, hkallweit1@gmail.com, linux@armlinux.org.uk,
	davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org,
	pabeni@redhat.com, tglx@kernel.org, linux-pm@vger.kernel.org,
	maxime.chevallier@bootlin.com, lukas@wunner.de,
	rafael.j.wysocki@intel.com, wei.fang@nxp.com,
	niklas.soderlund@ragnatech.se, paul@pbarker.dev,
	florian.fainelli@broadcom.com, opendmb@gmail.com,
	Thangaraj.S@microchip.com, shenwei.wang@nxp.com,
	Haoning.CHENG@cn.bosch.com, willemb@google.com,
	netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH net v9 5/5] net: phy: postpone PHY interrupts during sleep with MAC-managed PM
Date: Tue, 01 Dec 2026 07:30:50 +0000	[thread overview]
Message-ID: <179611025036.3146.14237551146049687109@kernel.org> (raw)
In-Reply-To: <20261130-b4-phylib-mac-pm-irq-v3-v9-5-7b9c3c9ac9f7@iav.lv>

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

Critical: 0 · High: 0 · Medium: 3 · 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] This patch makes PHY drivers responsible for something, and
  the in-tree Broadcom BCM54xx driver does not do it.
- [Medium] On an edge-triggered PHY interrupt line with a MAC-managed
  PHY, a Wake-on-LAN packet that arrives during the transition is still…
- [Medium] In the device-link topology, and when the MAC's resume fails,
  the resume-side MDIO stall this patch targets can still happen.

--

net: phy: postpone PHY interrupts during sleep with MAC-managed PM

This patch makes PHYs with mac_managed_pm postpone their interrupts from
the PM prepare callback until resume or complete. Before, the PHY handler
could run while the MAC had already powered the MDIO bus down. The patch
also re-enables, in the noirq suspend phase, a wake-armed line that a
postponed interrupt disabled. Postponed interrupts of MAC-managed PHYs no
longer report a wakeup.

> diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
> index 6dce49f01d2ba..4a33100fa809b 100644
> --- a/drivers/net/phy/phy.c
> +++ b/drivers/net/phy/phy.c
> @@ -1419,7 +1419,10 @@ static irqreturn_t phy_interrupt(int irq, void *phy_dat)
>  	if (IS_ENABLED(CONFIG_PM_SLEEP) && READ_ONCE(phydev->irq_suspended)) {
>  		struct net_device *netdev = phydev->attached_dev;
>  
> -		if (netdev) {
> +		/* With MAC-managed PM, a postponed interrupt cannot tell
> +		 * Wake-on-LAN from a link change the MAC causes.
> +		 */
> +		if (netdev && !phydev->mac_managed_pm) {
>  			struct device *parent = netdev->dev.parent;
>  
>  			if (netdev->ethtool->wol_enabled)

[Severity: Medium]

On an edge-triggered PHY interrupt line, can a Wake-on-LAN packet that
arrives between mdio_bus_phy_prepare() and suspend_device_irqs() still be
lost? If so, every later packet is lost with it.

For a MAC-managed PHY, the postponed path here reports no wakeup. It also
never reads the PHY status. An RTL8211F keeps PME latched and INTB asserted
until RTL8211F_INSR is read, which only happens in
rtl8211f_handle_interrupt():

	if (irq_status & RTL8211F_INER_PME) {
		pm_wakeup_event(&phydev->mdio.dev, 0);
		return IRQ_HANDLED;
	}

mdio_bus_phy_suspend_noirq() then calls enable_irq() on the line. The edge
was consumed while the line was still enabled, so IRQS_PENDING is not set.
check_irq_resend() has nothing to replay, and no wakeup is produced.

The RTL8211F raises PME once per arming, so later magic packets raise no
new edge either. The system sleeps until another wake source fires.

The commit message acknowledges this:

  "on an edge-triggered line a magic packet that arrives during the
  transition does not abort it ... the RTL8211F, which raises PME once per
  arming, does not"

The in-tree ODROID-HC4 DT (meson-sm1-odroid.dtsi) uses IRQ_TYPE_LEVEL_LOW,
so the tested board works. On edge-triggered lines, though, the HC4
failure this patch sets out to fix remains. Is that meant to be handled
separately?

[ ... ]

> diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
> index 16b398794486f..eaa6e284cfd37 100644
> --- a/drivers/net/phy/phy_device.c
> +++ b/drivers/net/phy/phy_device.c

[ ... ]

> @@ -414,8 +445,10 @@ static __maybe_unused int mdio_bus_phy_resume(struct device *dev)
>  	struct phy_device *phydev = to_phy_device(dev);
>  	int ret;
>  
> -	if (phydev->mac_managed_pm)
> +	if (phydev->mac_managed_pm) {
> +		mdio_bus_phy_resume_irq(phydev);
>  		return 0;
> +	}

[Severity: Medium]

Can this replay still reach an unclocked MDIO controller in the
device-link topology?

mdio_bus_phy_resume()->mdio_bus_phy_resume_irq() runs
drv->handle_interrupt(), which reads the PHY over MDIO:

	if (phydev->irq == phydev->irq_rerun_line &&
	    phydev->irq_requested) {
		mutex_lock(&phydev->lock);
		phydev->drv->handle_interrupt(phydev);
		mutex_unlock(&phydev->lock);
	}

This only runs after the MAC's resume when the PHY is a dpm descendant of
the MAC that owns the MDIO controller, as on Helios64.

The PHY can instead sit on a bus whose dpm parent is not the MAC, while
its traffic still goes through the MAC's controller. Examples are
mdio-mux-meson-g12a, or an mdio-mux-gpio whose mdio-parent-bus is the
MAC's own MDIO. There the MAC is only a device-link consumer of the PHY,
so the PHY resumes first.

Some MAC glue drivers gate their clocks in the normal-phase suspend
callback, as rk_gmac_suspend() and fec_suspend() do. Behind such a MAC,
the replayed MDIO access would run before the MAC's resume callback.

The same happens if the MAC's resume callback fails. The PM core still
resumes the PHY, and the replay reaches the powered-down controller.

The commit message describes both cases, and the old handler run from
resume_device_irqs() behaved the same. So this is a gap left in the fix
rather than a new regression.

For the device-link case, would it help to do the replay for MAC-managed
PHYs from mdio_bus_phy_complete() instead? dpm_complete() handles
consumers before suppliers.

[ ... ]

> @@ -446,8 +479,48 @@ static __maybe_unused int mdio_bus_phy_resume(struct device *dev)
>  	return 0;
>  }
>  
> -static SIMPLE_DEV_PM_OPS(mdio_bus_phy_pm_ops, mdio_bus_phy_suspend,
> -			 mdio_bus_phy_resume);
> +static __maybe_unused int mdio_bus_phy_suspend_noirq(struct device *dev)
> +{
> +	struct phy_device *phydev = to_phy_device(dev);
> +	struct irq_data *d;
> +
> +	mutex_lock(&phydev->irq_pm_lock);
> +	/* We enable the line a postponed interrupt disabled if the irq core
> +	 * armed it for wakeup, so that it wakes the system.
> +	 */
> +	if (phydev->irq_rerun) {
> +		d = irq_get_irq_data(phydev->irq_rerun_line);
> +		if (d && irqd_irq_disabled(d) && irqd_is_wakeup_armed(d)) {
> +			enable_irq(phydev->irq_rerun_line);
> +			phydev->irq_wake_enabled = true;
> +		}
> +	}

[Severity: Medium]

With a Broadcom BCM54xx PHY on a level-triggered line, does this make
every suspend with Wake-on-LAN enabled abort?

The commit message says a PHY driver "has to restrict the interrupt to
Wake-on-LAN in its suspend callback, as rtl8211f_suspend() does". Of the
in-tree drivers that arm phydev->irq for wakeup, realtek_main.c and
air_an8801.c do that, but the Broadcom code does not appear to.

bcm_phy_set_wol() in bcm-phy-lib.c arms the PHY's link interrupt line:

	if (phy_interrupt_is_valid(phydev))
		enable_irq_wake(phydev->irq);

bcm54xx_suspend() only acks the WoL status and arms the separate wake IRQ:

	/* Acknowledge any Wake-on-LAN interrupt prior to suspend */
	ret = bcm_phy_read_exp(phydev, BCM54XX_WOL_INT_STATUS);
	if (ret < 0)
		return ret;

	if (phydev->wol_enabled)
		return bcm54xx_set_wakeup_irq(phydev, true);

The link, speed and duplex sources stay unmasked in MII_BCM54XX_IMR, and
ECR_IM stays clear.

stmmac sets wol_phy_speed_ctrl, so with stmmac the sequence looks like
this:

stmmac suspend
  phylink_suspend()
    phylink_speed_down()      /* aneg restart, link-down interrupt */
phy_interrupt()               /* irq_suspended set by prepare,
                                 MII_BCM54XX_ISR not read,
                                 line disabled */
suspend_device_irqs()         /* arms the line */
mdio_bus_phy_suspend_noirq()
  enable_irq()                /* asserted level fires */
    irq_pm_check_wakeup()     /* transition aborts */

bcm54xx_phy_probe() calls device_init_wakeup() when the PHY has an
interrupt, so phy_may_wakeup() holds and the speed-down happens.

Before this patch, the handler ran and acked the link interrupt during the
transition. For suspend-to-RAM, the link-up interrupt after the
lower-speed aneg could already wake the system shortly after it slept.

The guaranteed abort at suspend_noirq/freeze_noirq is new, for example on
every hibernation freeze with Wake-on-LAN enabled. Any link change between
prepare and suspend_device_irqs() now also aborts the transition instead
of being handled.

Should bcm54xx_suspend() mask the link interrupt as part of this change?

> +	mutex_unlock(&phydev->irq_pm_lock);

[ ... ]

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261130-b4-phylib-mac-pm-irq-v3-v9-0-7b9c3c9ac9f7%40iav.lv

      reply	other threads:[~2026-12-01  7:30 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-30  7:04 [PATCH net v9 0/5] " Igor Velkov via B4 Relay
2026-11-30  7:04 ` [PATCH net v9 1/5] net: phy: move irq_suspended and irq_rerun out of the bitfield Igor Velkov via B4 Relay
2026-11-30  7:04 ` [PATCH net v9 2/5] net: phy: fix three paths that unbalance a postponed PHY interrupt line Igor Velkov via B4 Relay
2026-12-01  7:30   ` netdev-bot+sashiko
2026-11-30  7:04 ` [PATCH net v9 3/5] net: phy: stop postponing PHY interrupts when phy_suspend() fails Igor Velkov via B4 Relay
2026-12-01  7:30   ` netdev-bot+sashiko
2026-11-30  7:04 ` [PATCH net v9 4/5] net: phy: run a postponed PHY interrupt handler directly on resume Igor Velkov via B4 Relay
2026-11-30  7:04 ` [PATCH net v9 5/5] net: phy: postpone PHY interrupts during sleep with MAC-managed PM Igor Velkov via B4 Relay
2026-12-01  7:30   ` netdev-bot+sashiko [this message]

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=179611025036.3146.14237551146049687109@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=Haoning.CHENG@cn.bosch.com \
    --cc=Thangaraj.S@microchip.com \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=florian.fainelli@broadcom.com \
    --cc=hkallweit1@gmail.com \
    --cc=iav@iav.lv \
    --cc=kuba@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=linux-rockchip@lists.infradead.org \
    --cc=linux@armlinux.org.uk \
    --cc=lukas@wunner.de \
    --cc=maxime.chevallier@bootlin.com \
    --cc=netdev@vger.kernel.org \
    --cc=niklas.soderlund@ragnatech.se \
    --cc=opendmb@gmail.com \
    --cc=pabeni@redhat.com \
    --cc=paul@pbarker.dev \
    --cc=rafael.j.wysocki@intel.com \
    --cc=shenwei.wang@nxp.com \
    --cc=tglx@kernel.org \
    --cc=wei.fang@nxp.com \
    --cc=willemb@google.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

all inboxes | Powered by JetHome®