From e969c67bbe15e1680a5205d54b8c7ff90f6470d7 Mon Sep 17 00:00:00 2001 From: Russell King Date: Tue, 28 Jan 2020 12:55:52 +0000 Subject: 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 --- drivers/net/phy/phylink.c | 22 ++++++++++++++++++++-- 1 file 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; -- cgit