net: phy: phy_device: repeat reading of the phy-state when state is down

This attempts to work around an issue where there is a spurious link down detected

Signed-off-by: Jan Sondhauss <jan.sondhauss@wago.com>
This commit is contained in:
Jan Sondhauss
2025-10-23 12:55:00 +02:00
committed by Oleg KARFICH
parent cae69a410f
commit 621a26e5dd
+15 -4
View File
@@ -2343,12 +2343,13 @@ EXPORT_SYMBOL(genphy_aneg_done);
*/
int genphy_update_link(struct phy_device *phydev)
{
int status = 0, bmcr;
int status = 0, bmcr, i;
bmcr = phy_read(phydev, MII_BMCR);
if (bmcr < 0)
return bmcr;
/* Autoneg is being started, therefore disregard BMSR value and
* report link as down.
*/
@@ -2369,9 +2370,19 @@ int genphy_update_link(struct phy_device *phydev)
}
/* Read link and autonegotiation status */
status = phy_read(phydev, MII_BMSR);
if (status < 0)
return status;
for (i = 0; i < 20; i++) {
status = phy_read(phydev, MII_BMSR);
if (status < 0)
return status;
if (status & BMSR_LSTATUS)
break;
cpu_relax();
}
if (status & BMSR_LSTATUS)
if (i >= 1)
phydev_info(phydev, "link up after multiple reads: %di\n", i);
done:
phydev->link = status & BMSR_LSTATUS ? 1 : 0;
phydev->autoneg_complete = status & BMSR_ANEGCOMPLETE ? 1 : 0;