Skip to content

Commit 771046d

Browse files
Ben Hutchingsdavem330
authored andcommitted
mdio: Check MDIO_STAT1_FAULT in mdio45_links_ok()
Some PHYs will report that the link is up even though there is a fault condition. Therefore, check the fault flag too. We must also read STAT2 to reset this flag. Signed-off-by: Ben Hutchings <bhutchings@solarflare.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent d4ec09a commit 771046d

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

‎drivers/net/mdio.c‎

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,13 +109,20 @@ int mdio45_links_ok(const struct mdio_if_info *mdio, u32 mmd_mask)
109109
if (mmd_mask & (1 << devad)) {
110110
mmd_mask &= ~(1 << devad);
111111

112-
/* Read twice because link state is latched and a
113-
* read moves the current state into the register */
112+
/* Reset the latched status and fault flags */
114113
mdio->mdio_read(mdio->dev, mdio->prtad,
115114
devad, MDIO_STAT1);
115+
if (devad == MDIO_MMD_PMAPMD || devad == MDIO_MMD_PCS ||
116+
devad == MDIO_MMD_PHYXS || devad == MDIO_MMD_DTEXS)
117+
mdio->mdio_read(mdio->dev, mdio->prtad,
118+
devad, MDIO_STAT2);
119+
120+
/* Check the current status and fault flags */
116121
reg = mdio->mdio_read(mdio->dev, mdio->prtad,
117122
devad, MDIO_STAT1);
118-
if (reg < 0 || !(reg & MDIO_STAT1_LSTATUS))
123+
if (reg < 0 ||
124+
(reg & (MDIO_STAT1_FAULT | MDIO_STAT1_LSTATUS)) !=
125+
MDIO_STAT1_LSTATUS)
119126
return false;
120127
}
121128
}

0 commit comments

Comments
 (0)