From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796110252; b=az8HpmyaeQx3IrOveZ3/VKcQUfV/MbdT0OCdD65MoffRVWfd0oQKu7VbAyfj5zEQTknp 5c18gfFM0qHwl+7oMxcxq2fAOPc1QbxczRAGSvEB70grdgj3OdpM6KbCPcCULRULCzFdv Bk0tllGiYm+14NJQg6yAdHO8ppKS85qRDkw/8+TvoaktiswNxY+yInKyFgbdZsXlBTXd6 KlBMNQtIcy6s4vFd/6aTlvfxEIeVk72OXExoTeeHCXByq+Rxtd3VE5Ga4X3PQgtutHhAI XTNYDFTPwN5QHGHPykqqPgja9uLu9QE06bIGndNGndZOHm3EzGCdsIrWdts+sJqJ1hg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796110252; 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=4fJf/2Q0RwTkSdgv1C9CQQLaTDh2RtcisF7ctvOZFuE=; b=V0ikRJ3ZiMAjrrky0TWnvry6u7txYJkqBhKax+ZXE0DczStwKWP6yFHweKaJa7n1RCHl mdZKpk3sJNMoUAbPu0+mAs6gUHKvWGNaLT6Fk9XFT+1/NaBJ/DzY4a4dNsmNnam5l1TDc T/+Kvoer+5RONXDMiLjOaSlhjcNgXj+MQL1NIztomh0ydzTveC0O1NjrtnybU3NZ424PY e9RL2M9keNWNz1f7sMjY+Yq7weiQJ7NUmN9d9Q/cviWHjQrQox67AYHqy9GEozubEs2h5 L4rCtZKNHXKYq2o/OneiX8DkIpgZ5Ix9VtTJTgxmE56pNT7Oxy2mvnitFjVfuzP79ww== 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=VPeEVfp6; arc=none smtp.remote-ip=100.103.45.18 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 609D0606A6AD; Tue, 1 Dec 2026 07:30:52 +0000 (UTC) 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=VPeEVfp6 Received: by smtp.kernel.org (Postfix) with ESMTPSA id C8E021F00898; Tue, 1 Dec 2026 07:30:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796110252; bh=4fJf/2Q0RwTkSdgv1C9CQQLaTDh2RtcisF7ctvOZFuE=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=VPeEVfp6wm0TIEPNUKsbfCFppSRyX6+iTZUEy9z4opQb6sCEf9UKo8oy90v7VsaE4 4CviBQ9xgorDiwmfWhmMxoivXj4AQ6gyv4zDXYcr6nEc90nS855Oy7KMcWWceeoJeO CBhQNbe3Y8aVKPFMQjgiHkHfRrcilaF3g3NvIBL5pj0JVQH8rJU+vsQIJsaOBQoZT0 3OhEmGlAIvsO/mMK6goVpzp1ClqQPSK9oase8hSD6OdCt8tX04DQRQaY1rVzHojQAU +2h8zUUX4tWhc0QP00rBapAh11pKTZJcyGSGtL1zl9oLxVVtllMn3qHSP4qCnZDOrf iRx+lUNwMbLHA== Subject: Re: [PATCH net v9 5/5] net: phy: postpone PHY interrupts during sleep with MAC-managed PM 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 Date: Tue, 01 Dec 2026 07:30:50 +0000 Message-ID: <179611025036.3146.14237551146049687109@kernel.org> In-Reply-To: <20261130-b4-phylib-mac-pm-irq-v3-v9-5-7b9c3c9ac9f7@iav.lv> References: <20261130-b4-phylib-mac-pm-irq-v3-v9-5-7b9c3c9ac9f7@iav.lv> X-sashiko-severity: Medium Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 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