When the MAC driver manages PHY PM, phylib never sets irq_suspended, and
a PHY interrupt during the sleep transition runs the PHY driver's
handler while the MDIO bus may be powered down. On Helios64 (dwmac-rk)
this hangs the board on suspend as well as on resume.
Patch 1 moves the two flags out of a bitfield they share with the link
state written under phydev->lock; patch 2 sets irq_suspended for these
PHYs too.
mac_managed_pm (fba863b81604) means the MAC driver suspends and resumes
the PHY; it does not cover the PHY interrupt. Neither phylink nor any
MAC driver touches irq_suspended, and resume_device_irqs() runs at the
end of the noirq phase, before the normal resume callbacks of the MAC,
the MDIO bus and the PHY, so callback order does not help the
interrupt. v1 asked whether phylink_suspend()/phylink_resume() would be
the better place; v2 keeps the fix in phylib, which also covers MAC
drivers that use phylib without phylink.
Changes in v2:
- new patch 1: bools instead of bitfields (Sashiko); sizeof(struct
phy_device) is unchanged on arm64
- phy_free_interrupt(): re-enable a shared line after free_irq()
instead of dropping irq_rerun before it (Sashiko)
- reworded the comment in mdio_bus_phy_suspend() (Andrew)
- described and tested the suspend-side window, noted the wakeup
event; the v1 tests with Wake-on-LAN (Helios64 20/20, ODROID-HC4
10/10) were on v1 code
- W=1 allmodconfig/allyesconfig: no new warnings
Not tested: patch 1 alone, and a vanilla net kernel on hardware; the
tests ran on an Armbian 7.3 kernel whose Helios64 DT describes the PHY
interrupt.
Link to v1: https://lore.kernel.org/r/20261002043548.1302145-1-iav@iav.lv (local)
Igor Velkov (2):
net: phy: move irq_suspended and irq_rerun out of the bitfield
net: phy: postpone PHY interrupts during sleep with MAC-managed PM
drivers/net/phy/phy.c | 9 ++++++++
drivers/net/phy/phy_device.c | 44 ++++++++++++++++++++++--------------
include/linux/phy.h | 5 ++--
3 files changed, 39 insertions(+), 19 deletions(-)
base-commit: 7076f684d5132e6a6145e1da2fa74771ecd052e5
--
2.43.0