From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3BE44606A33B for ; Tue, 1 Dec 2026 07:31:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=CTV1Ltpu; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=VPeEVfp6 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:MIME-Version: Content-Transfer-Encoding:Content-Type:References:In-Reply-To:Message-ID:Date :Cc:To:From:Subject:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Unsubscribe-Post:List-Owner; bh=4fJf/2Q0RwTkSdgv1C9CQQLaTDh2RtcisF7ctvOZFuE=; b=CTV1LtpueSzKXVqzuS83CA5BMm oFNppB0XciqN4YaD27+08rcTS0gvgGW5YFUvOM3rve/zPgQZXujPKMvqObN3h8IUI8zVNc8RoCnxR 5aKPvC2H4aexbm1C9IT/CFXdoEN575E4QmZOdHHKGRjjIRXoLTJMWjGMmg3v25084Hu7MRno1Xy54 WIBQ7HNLKzlqmSRBuYHBZeaFxtyd5EF155eCBSWGLgVl8IvsxKF9JG4TVmyKX8BuuqoLbRQdW9wFX nsDMhmHT4LYJNMylMonmBH+MEEbqb0UleeJwHK7dxYgtkLkLmKcG1gLS3y6kmCD+tv36ZJvSpE0Mf hdOSzI8g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xYIKO-00000006uQ3-0MWK; Tue, 01 Dec 2026 07:31:04 +0000 Received: from tor.source.kernel.org ([172.105.4.254]) by bombadil.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xYIKD-00000006uLa-0pVv; Tue, 01 Dec 2026 07:30:53 +0000 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by tor.source.kernel.org (Postfix) with ESMTP id 86FCE61CD6; Tue, 1 Dec 2026 07:30:52 +0000 (UTC) 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-Archived-By: MIME-Version: 1.0 X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" X-Spam-Status: No, score=-10.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 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