From: Igor Velkov When phy_suspend() fails in mdio_bus_phy_suspend(), irq_suspended stays set and the state machine stays stopped: the PM core does not resume a device whose suspend callback failed, and the next PHY interrupt disables the line until the next resume. Undo the postponing and restart the state machine when phy_suspend() fails. Set suspended_by_mdio_bus only after phy_suspend() succeeds. Set before it, the flag outlived a failed suspend, and in a later cycle where mdio_bus_phy_may_suspend() returns false, mdio_bus_phy_resume() ran phy_init_hw() and phy_resume() on a PHY that the MDIO bus had not suspended. Fixes: 1758bde2e4aa ("net: phy: Don't trigger state machine while in suspend") Signed-off-by: Igor Velkov --- Haoning Cheng's Tested-by on v5 is not carried: this patch no longer changes the resume error path. --- drivers/net/phy/phy_device.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index f2e2370b4be7..2d2058c29f30 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -368,6 +368,7 @@ static __maybe_unused void mdio_bus_phy_resume_irq(struct phy_device *phydev) static __maybe_unused int mdio_bus_phy_suspend(struct device *dev) { struct phy_device *phydev = to_phy_device(dev); + int ret; if (phydev->mac_managed_pm) return 0; @@ -385,9 +386,20 @@ static __maybe_unused int mdio_bus_phy_suspend(struct device *dev) if (!mdio_bus_phy_may_suspend(phydev)) return 0; + ret = phy_suspend(phydev); + if (ret) { + /* The PM core skips the resume callback of a device whose + * suspend callback failed. + */ + mdio_bus_phy_resume_irq(phydev); + if (phy_uses_state_machine(phydev)) + phy_start_machine(phydev); + return ret; + } + phydev->suspended_by_mdio_bus = 1; - return phy_suspend(phydev); + return 0; } static __maybe_unused int mdio_bus_phy_resume(struct device *dev) -- 2.43.0