Message ID | 20250318235850.6411-2-ansuelsmth@gmail.com (mailing list archive) |
---|---|
State | New |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | net: pcs: Introduce support for PCS OF | expand |
diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c index 76b1a329607b..eef1712ec22c 100644 --- a/drivers/net/phy/phylink.c +++ b/drivers/net/phy/phylink.c @@ -2589,6 +2589,9 @@ void phylink_stop(struct phylink *pl) pl->pcs_state = PCS_STATE_DOWN; phylink_pcs_disable(pl->pcs); + if (pl->pcs) + pl->pcs->phylink = NULL; + pl->pcs = NULL; } EXPORT_SYMBOL_GPL(phylink_stop);
On calling phylink_stop, the double reference between PCS and Phylink is never reset. This is OK in the current rudimental implementation of PCS as current PCS driver doesn't autonomously handle link termination (or actually doesn't handle removal of the PCS driver at all) But this immediately became problematic if the PCS driver makes use of this double reference to track if the PCS have an actual user attached. If a driver makes use of this and the double reference is not reset, the driver might erroneously detect the PCS have a user and execute stop operation even if not actually used. (causing unwanted link termination) To permit PCS driver to detect this correctly, and to better handle this similar to how it done with phylink_major_config, set to NULL the double reference between PCS and Phylink on phylink_stop. On phylink_major_config, PCS is always refreshed by calling mac_select_pcs hence it's save to always reset it in phylink_stop. Signed-off-by: Christian Marangi <ansuelsmth@gmail.com> --- drivers/net/phy/phylink.c | 3 +++ 1 file changed, 3 insertions(+)