diff options
author | Russell King <rmk+kernel@armlinux.org.uk> | 2020-01-28 12:55:52 +0000 |
---|---|---|
committer | Russell King <rmk+kernel@armlinux.org.uk> | 2020-04-17 15:28:50 +0100 |
commit | e969c67bbe15e1680a5205d54b8c7ff90f6470d7 (patch) | |
tree | c7e90ac8c7fe9ee00e8eac87e21e11e30fcc907d | |
parent | febd058b88c48c0cd9893897b38af86ab2e5f8a3 (diff) |
net: phylink: ensure link is down when changing interface
This is a correctness patch; no bug has been reported. It changes the
way we deal with the interface changing by ensuring that the link is
down before we call any of the *_config() methods.
Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
-rw-r--r-- | drivers/net/phy/phylink.c | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c index 16cf2dd0ef50..4421f283e910 100644 --- a/drivers/net/phy/phylink.c +++ b/drivers/net/phy/phylink.c @@ -616,8 +616,26 @@ static void phylink_resolve(struct work_struct *w) } } - if (mac_config) - phylink_mac_config(pl, &link_state); + if (mac_config) { + if (link_state.interface == pl->link_config.interface) { + /* The interface remains unchanged, only the speed, + * duplex or pause settings have changed. + */ + phylink_mac_config(pl, &link_state); + } else if (cur_link_state) { + /* The interface has changed, but the link is up. + * Force it down and retrigger resolution. + */ + link_state.link = false; + retrigger = true; + } else { + /* The interface has changed and the link is down. + * Reconfigure the MAC and PCS. + */ + phylink_pcs_config(pl, false, &link_state); + pl->link_config.interface = link_state.interface; + } + } if (link_state.link != cur_link_state) { pl->old_link_state = link_state.link; |