1 From 72f973f292b3eaaf451ebcd3253900d41f4ef24a Mon Sep 17 00:00:00 2001
2 From: Russell King <rmk+kernel@armlinux.org.uk>
3 Date: Fri, 25 Jan 2019 17:42:51 +0000
4 Subject: [PATCH] net: phylink: ensure inband AN works correctly
6 Do not update the link interface mode while the link is down to avoid
7 spurious link interface changes.
9 Always call mac_config if we have a PHY to propagate the pause mode
12 Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
14 drivers/net/phy/phylink.c | 37 +++++++++++++++----------------------
15 1 file changed, 15 insertions(+), 22 deletions(-)
17 --- a/drivers/net/phy/phylink.c
18 +++ b/drivers/net/phy/phylink.c
19 @@ -457,28 +457,21 @@ static void phylink_resolve(struct work_
22 phylink_get_mac_state(pl, &link_state);
24 - bool changed = false;
26 - link_state.link = link_state.link &&
28 + /* If we have a phy, the "up" state is the union of
29 + * both the PHY and the MAC */
31 + link_state.link &= pl->phy_state.link;
33 - if (pl->phy_state.interface !=
34 - link_state.interface) {
35 - link_state.interface = pl->phy_state.interface;
38 + /* Only update if the PHY link is up */
39 + if (pl->phydev && pl->phy_state.link) {
40 + link_state.interface = pl->phy_state.interface;
42 - /* Propagate the flow control from the PHY
43 - * to the MAC. Also propagate the interface
46 - if (pl->phy_state.link || changed) {
47 - link_state.pause |= pl->phy_state.pause;
48 - phylink_resolve_flow(pl, &link_state);
50 - phylink_mac_config(pl, &link_state);
52 + /* If we have a PHY, we need to update with
53 + * the pause mode bits. */
54 + link_state.pause |= pl->phy_state.pause;
55 + phylink_resolve_flow(pl, &link_state);
56 + phylink_mac_config(pl, &link_state);