Skip to content

Commit 744d23c

Browse files
ffainellikuba-moo
authored andcommitted
net: phy: Warn about incorrect mdio_bus_phy_resume() state
Calling mdio_bus_phy_resume() with neither the PHY state machine set to PHY_HALTED nor phydev->mac_managed_pm set to true is a good indication that we can produce a race condition looking like this: CPU0 CPU1 bcmgenet_resume -> phy_resume -> phy_init_hw -> phy_start -> phy_resume phy_start_aneg() mdio_bus_phy_resume -> phy_resume -> phy_write(..., BMCR_RESET) -> usleep() -> phy_read() with the phy_resume() function triggering a PHY behavior that might have to be worked around with (see bf8bfc4 ("net: phy: broadcom: Fix brcm_fet_config_init()") for instance) that ultimately leads to an error reading from the PHY. Fixes: fba863b ("net: phy: make PHY PM ops a no-op if MAC driver manages PHY PM") Signed-off-by: Florian Fainelli <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 7de196a commit 744d23c

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

drivers/net/phy/phy_device.c

+6
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,12 @@ static __maybe_unused int mdio_bus_phy_resume(struct device *dev)
316316

317317
phydev->suspended_by_mdio_bus = 0;
318318

319+
/* If we managed to get here with the PHY state machine in a state other
320+
* than PHY_HALTED this is an indication that something went wrong and
321+
* we should most likely be using MAC managed PM and we are not.
322+
*/
323+
WARN_ON(phydev->state != PHY_HALTED && !phydev->mac_managed_pm);
324+
319325
ret = phy_init_hw(phydev);
320326
if (ret < 0)
321327
return ret;

0 commit comments

Comments
 (0)