Skip to content

Commit 671154f

Browse files
Russell King (Oracle)kuba-moo
authored andcommitted
net: phylink: ensure PHY momentary link-fails are handled
Normally, phylib won't notify changes in quick succession. However, as a result of commit 3e43b90 ("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: 3e43b90 ("net: phy: Immediately call adjust_link if only tx_lpi_enabled changes") Signed-off-by: Russell King (Oracle) <[email protected]> Reviewed-by: Oleksij Rempel <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 7d2253d commit 671154f

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

drivers/net/phy/phylink.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ struct phylink {
7878
unsigned int pcs_neg_mode;
7979
unsigned int pcs_state;
8080

81-
bool mac_link_dropped;
81+
bool link_failed;
8282
bool using_mac_select_pcs;
8383

8484
struct sfp_bus *sfp_bus;
@@ -1475,9 +1475,9 @@ static void phylink_resolve(struct work_struct *w)
14751475
cur_link_state = pl->old_link_state;
14761476

14771477
if (pl->phylink_disable_state) {
1478-
pl->mac_link_dropped = false;
1478+
pl->link_failed = false;
14791479
link_state.link = false;
1480-
} else if (pl->mac_link_dropped) {
1480+
} else if (pl->link_failed) {
14811481
link_state.link = false;
14821482
retrigger = true;
14831483
} else {
@@ -1572,7 +1572,7 @@ static void phylink_resolve(struct work_struct *w)
15721572
phylink_link_up(pl, link_state);
15731573
}
15741574
if (!link_state.link && retrigger) {
1575-
pl->mac_link_dropped = false;
1575+
pl->link_failed = false;
15761576
queue_work(system_power_efficient_wq, &pl->resolve);
15771577
}
15781578
mutex_unlock(&pl->state_mutex);
@@ -1835,6 +1835,8 @@ static void phylink_phy_change(struct phy_device *phydev, bool up)
18351835
pl->phy_state.pause |= MLO_PAUSE_RX;
18361836
pl->phy_state.interface = phydev->interface;
18371837
pl->phy_state.link = up;
1838+
if (!up)
1839+
pl->link_failed = true;
18381840
mutex_unlock(&pl->state_mutex);
18391841

18401842
phylink_run_resolve(pl);
@@ -2158,7 +2160,7 @@ EXPORT_SYMBOL_GPL(phylink_disconnect_phy);
21582160
static void phylink_link_changed(struct phylink *pl, bool up, const char *what)
21592161
{
21602162
if (!up)
2161-
pl->mac_link_dropped = true;
2163+
pl->link_failed = true;
21622164
phylink_run_resolve(pl);
21632165
phylink_dbg(pl, "%s link %s\n", what, up ? "up" : "down");
21642166
}
@@ -2792,7 +2794,7 @@ int phylink_ethtool_set_pauseparam(struct phylink *pl,
27922794
* link will cycle.
27932795
*/
27942796
if (manual_changed) {
2795-
pl->mac_link_dropped = true;
2797+
pl->link_failed = true;
27962798
phylink_run_resolve(pl);
27972799
}
27982800

0 commit comments

Comments
 (0)