lantiq: clarify VG3503J name
[oweals/openwrt.git] / target / linux / mvebu / patches-4.9 / 437-phylink-ensure-link-drops-are-reported.patch
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
4
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.
8
9 Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
10 ---
11
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;
17  
18 +       bool mac_link_dropped;
19 +
20         const struct phylink_module_ops *module_ops;
21         void *module_data;
22  };
23 @@ -340,6 +342,9 @@ static void phylink_resolve(struct work_
24  
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;
31         } else {
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));
35                 }
36         }
37 +       if (!link_state.link && pl->mac_link_dropped) {
38 +               pl->mac_link_dropped = false;
39 +               queue_work(system_power_efficient_wq, &pl->resolve);
40 +       }
41         mutex_unlock(&pl->state_mutex);
42  }
43  
44 @@ -641,6 +650,8 @@ EXPORT_SYMBOL_GPL(phylink_disconnect_phy
45  
46  void phylink_mac_change(struct phylink *pl, bool up)
47  {
48 +       if (!up)
49 +               pl->mac_link_dropped = true;
50         phylink_run_resolve(pl);
51         netdev_dbg(pl->netdev, "mac link %s\n", up ? "up" : "down");
52  }