From: Christian Marangi When autonegotiation is restarted, MDIO_STAT1_ANEGCOMPLETE may be cleared before MDIO_STAT1_LSTATUS. In this case, the link status bit may still indicate link up even though autonegotiation has not completed. Force the link down when autonegotiation is enabled but has not completed, preventing as21xxx_read_status() from reporting a link up with an unknown or stale speed. Fixes: 830877d89edc ("net: phy: Add support for Aeonsemi AS21xxx PHYs") Reviewed-by: Maxime Chevallier Signed-off-by: Christian Marangi Signed-off-by: Cristian Ciocaltea --- drivers/net/phy/as21xxx.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/net/phy/as21xxx.c b/drivers/net/phy/as21xxx.c index dbe6be963389..3db455314b67 100644 --- a/drivers/net/phy/as21xxx.c +++ b/drivers/net/phy/as21xxx.c @@ -657,6 +657,13 @@ static int as21xxx_read_link(struct phy_device *phydev, int *bmcr) return status; phydev->link = !!(status & MDIO_STAT1_LSTATUS); + phydev->autoneg_complete = !!(status & MDIO_AN_STAT1_COMPLETE); + + /* Consider the case that autoneg was started and "aneg complete" + * bit has been reset, but "link up" bit not yet. + */ + if (phydev->autoneg == AUTONEG_ENABLE && !phydev->autoneg_complete) + phydev->link = 0; return 0; } -- 2.56.0