Skip to content

Commit a459810

Browse files
committed
drivers: ethernet: vsc8541: Add timeout on SW reset
The driver previously could enter an infinite loop if the PHY software reset failed to complete, which could happen due to hardware reset issues or MDIO bus problems. Add a timeout of 1000 iterations so we report an error in this scenario rather than causing a lockup. Signed-off-by: Robert Hancock <robert.hancock@calian.com>
1 parent 5cdb8df commit a459810

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

drivers/ethernet/phy/phy_microchip_vsc8541.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,8 +218,13 @@ static int phy_mc_vsc8541_reset(const struct device *dev)
218218
/* wait for phy finished software reset */
219219
uint16_t reg = 0;
220220

221+
int count = 0;
221222
do {
222223
phy_mc_vsc8541_read(dev, PHY_REG_PAGE0_BMCR, &reg);
224+
if (count++ > 1000) {
225+
LOG_ERR("phy reset timed out");
226+
return -ETIMEDOUT;
227+
}
223228
} while (reg & BMCR_RESET);
224229

225230
/* forced MDI-X */

0 commit comments

Comments
 (0)