1 From: Russell King <rmk+kernel@armlinux.org.uk>
2 Date: Mon, 19 Dec 2016 12:17:57 +0000
3 Subject: [PATCH] phylink: ensure link drops are reported
5 When the MAC reports a link failure, it can be momentary. Ensure
6 that the event is reported by latching the loss of link, so that the
7 worker reports link down.
9 Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
12 --- a/drivers/net/phy/phylink.c
13 +++ b/drivers/net/phy/phylink.c
14 @@ -60,6 +60,8 @@ struct phylink {
15 struct phylink_link_state phy_state;
16 struct work_struct resolve;
18 + bool mac_link_dropped;
20 const struct phylink_module_ops *module_ops;
23 @@ -340,6 +342,9 @@ static void phylink_resolve(struct work_
25 mutex_lock(&pl->state_mutex);
26 if (pl->phylink_disable_state) {
27 + pl->mac_link_dropped = false;
28 + link_state.link = false;
29 + } else if (pl->mac_link_dropped) {
30 link_state.link = false;
32 switch (pl->link_an_mode) {
33 @@ -405,6 +410,10 @@ static void phylink_resolve(struct work_
34 phylink_pause_to_str(link_state.pause));
37 + if (!link_state.link && pl->mac_link_dropped) {
38 + pl->mac_link_dropped = false;
39 + queue_work(system_power_efficient_wq, &pl->resolve);
41 mutex_unlock(&pl->state_mutex);
44 @@ -641,6 +650,8 @@ EXPORT_SYMBOL_GPL(phylink_disconnect_phy
46 void phylink_mac_change(struct phylink *pl, bool up)
49 + pl->mac_link_dropped = true;
50 phylink_run_resolve(pl);
51 netdev_dbg(pl->netdev, "mac link %s\n", up ? "up" : "down");