[net-next PATCH 1/6] net: phylink: reset PCS-Phylink double reference on phylink_stop

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx>
---
 drivers/net/phy/phylink.c | 3 +++
 1 file changed, 3 insertions(+)

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);
 
-- 
2.48.1





[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]


  Powered by Linux