When mdio driver polling the phy state in the phy_state_machine, sometimes it results in -ETIMEDOUT and link is down. But the phy is still alive and just didn't meet the polling deadline. Closing the phy link in this case seems too radical. Failing to meet the deadline happens very rarely. When stress test runs for tens of hours with multiple target boards (Xilinx Zynq7000 with marvell 88E1512 PHY, Xilinx custom emac IP), it happens. This patch gives another chance to the phy_state_machine when polling timeout happens. Only two consecutive failing the deadline is treated as the real phy halt and close the connection.
Signed-off-by: kwangdo.yi <kwangdo...@gmail.com> --- drivers/net/phy/phy.c | 6 ++++++ include/linux/phy.h | 1 + 2 files changed, 7 insertions(+) diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c index e888542..9e8138b 100644 --- a/drivers/net/phy/phy.c +++ b/drivers/net/phy/phy.c @@ -919,7 +919,13 @@ void phy_state_machine(struct work_struct *work) break; case PHY_NOLINK: case PHY_RUNNING: + case PHY_BUSY: err = phy_check_link_status(phydev); + if (err == -ETIMEDOUT && old_state == PHY_RUNNING) { + phy->state = PHY_BUSY; + err = 0; + + } break; case PHY_FORCING: err = genphy_update_link(phydev); diff --git a/include/linux/phy.h b/include/linux/phy.h index 6424586..4a49401 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h @@ -313,6 +313,7 @@ enum phy_state { PHY_RUNNING, PHY_NOLINK, PHY_FORCING, + PHY_BUSY, }; /** -- 2.7.4