diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c index 9622455..1cf2cb9 100644 --- a/drivers/net/phy/phy.c +++ b/drivers/net/phy/phy.c @@ -401,11 +401,14 @@ return err; } -static int phy_aneg_done(struct phy_device *phydev) +int phy_wait_aneg_done(struct phy_device *phydev) { uint64_t start = get_time_ns(); int ctl; + if (phydev->autoneg == AUTONEG_DISABLE) + return 0; + while (!is_timeout(start, PHY_AN_TIMEOUT * SECOND)) { ctl = phy_read(phydev, MII_BMSR); if (ctl & BMSR_ANEGCOMPLETE) { @@ -452,7 +455,7 @@ if (ctl < 0) return ctl; - return phy_aneg_done(phydev); + return 0; } /** diff --git a/include/linux/phy.h b/include/linux/phy.h index b39eca5..6c9cac9 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h @@ -267,6 +267,7 @@ u32 flags, phy_interface_t interface); int phy_update_status(struct phy_device *phydev); +int phy_wait_aneg_done(struct phy_device *phydev); /* Generic PHY support and helper functions */ int genphy_restart_aneg(struct phy_device *phydev); diff --git a/net/eth.c b/net/eth.c index 493ecf9..98ec726 100644 --- a/net/eth.c +++ b/net/eth.c @@ -138,6 +138,9 @@ if (!eth_current->phydev) return 0; + if (force) + phy_wait_aneg_done(eth_current->phydev); + if (force || is_timeout(last_link_check, 5 * SECOND) || !eth_current->phydev->link) { ret = phy_update_status(eth_current->phydev);