Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: phylink: ensure PHY momentary link-fails are handled

Normally, phylib won't notify changes in quick succession. However, as
a result of commit 3e43b903da04 ("net: phy: Immediately call
adjust_link if only tx_lpi_enabled changes") this is no longer true -
it is now possible that phy_link_down() and phy_link_up() will both
complete before phylink's resolver has run, which means it'll miss that
pl->phy_state.link momentarily became false.

Rename "mac_link_dropped" to be more generic "link_failed" since it will
cover more than the MAC/PCS end of the link failing, and arrange to set
this in phylink_phy_change() if we notice that the PHY reports that the
link is down.

This will ensure that we capture an EEE reconfiguration event.

Fixes: 3e43b903da04 ("net: phy: Immediately call adjust_link if only tx_lpi_enabled changes")
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Reviewed-by: Oleksij Rempel <o.rempel@pengutronix.de>
Link: https://patch.msgid.link/E1tAtcW-002RBS-LB@rmk-PC.armlinux.org.uk
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Russell King (Oracle) and committed by
Jakub Kicinski
671154f1 7d2253d9

+8 -6
+8 -6
drivers/net/phy/phylink.c
··· 78 78 unsigned int pcs_neg_mode; 79 79 unsigned int pcs_state; 80 80 81 - bool mac_link_dropped; 81 + bool link_failed; 82 82 bool using_mac_select_pcs; 83 83 84 84 struct sfp_bus *sfp_bus; ··· 1475 1475 cur_link_state = pl->old_link_state; 1476 1476 1477 1477 if (pl->phylink_disable_state) { 1478 - pl->mac_link_dropped = false; 1478 + pl->link_failed = false; 1479 1479 link_state.link = false; 1480 - } else if (pl->mac_link_dropped) { 1480 + } else if (pl->link_failed) { 1481 1481 link_state.link = false; 1482 1482 retrigger = true; 1483 1483 } else { ··· 1572 1572 phylink_link_up(pl, link_state); 1573 1573 } 1574 1574 if (!link_state.link && retrigger) { 1575 - pl->mac_link_dropped = false; 1575 + pl->link_failed = false; 1576 1576 queue_work(system_power_efficient_wq, &pl->resolve); 1577 1577 } 1578 1578 mutex_unlock(&pl->state_mutex); ··· 1835 1835 pl->phy_state.pause |= MLO_PAUSE_RX; 1836 1836 pl->phy_state.interface = phydev->interface; 1837 1837 pl->phy_state.link = up; 1838 + if (!up) 1839 + pl->link_failed = true; 1838 1840 mutex_unlock(&pl->state_mutex); 1839 1841 1840 1842 phylink_run_resolve(pl); ··· 2160 2158 static void phylink_link_changed(struct phylink *pl, bool up, const char *what) 2161 2159 { 2162 2160 if (!up) 2163 - pl->mac_link_dropped = true; 2161 + pl->link_failed = true; 2164 2162 phylink_run_resolve(pl); 2165 2163 phylink_dbg(pl, "%s link %s\n", what, up ? "up" : "down"); 2166 2164 } ··· 2794 2792 * link will cycle. 2795 2793 */ 2796 2794 if (manual_changed) { 2797 - pl->mac_link_dropped = true; 2795 + pl->link_failed = true; 2798 2796 phylink_run_resolve(pl); 2799 2797 } 2800 2798