Skip to content

Commit 38c54d7

Browse files
committed
net: fix eth-mux completely
1 parent 2a7267d commit 38c54d7

1 file changed

Lines changed: 12 additions & 7 deletions

File tree

drivers/net/ethernet/mediatek/mtk_eth_soc.c

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4970,17 +4970,27 @@ static void mux_poll(struct work_struct *work)
49704970
goto reschedule;
49714971

49724972
dev_info(eth->dev, "ethernet mux: line:%d new channel:%d,sfp:%d\n",__LINE__, new_channel,sfp_present);
4973-
rtnl_lock();
49744973

4974+
rtnl_lock();
49754975
mtk_stop(dev);
4976+
rtnl_unlock();
49764977

49774978
/* Destroy old phylink if it exists */
49784979
if (mux->data[mux->channel] && mux->data[mux->channel]->phylink) {
49794980
dev_info(eth->dev, "Destroying phylink for channel %u\n", mux->channel);
49804981
phylink_destroy(mux->data[mux->channel]->phylink);
4982+
phylink_stop(mux->data[mux->channel]->phylink);
4983+
phylink_disconnect_phy(mux->data[mux->channel]->phylink);
4984+
phylink_destroy(mux->data[mux->channel]->phylink);
49814985
mux->data[mux->channel]->phylink = NULL;
49824986
}
49834987

4988+
dev_info(eth->dev, "ethernet mux: switch to channel%d\n", new_channel);
4989+
4990+
gpiod_set_value_cansleep(mux->chan_sel_gpio, new_channel);
4991+
4992+
usleep_range(100000,200000);
4993+
49844994
/* Create new phylink if not yet present */
49854995
if (!mux->data[new_channel]->phylink) {
49864996
mux->data[new_channel]->phylink = mtk_mux_create_phylink(mux, new_channel);
@@ -4994,12 +5004,7 @@ static void mux_poll(struct work_struct *work)
49945004
mac->of_node = mux->data[new_channel]->of_node;
49955005
mac->phylink = mux->data[new_channel]->phylink;
49965006

4997-
dev_info(eth->dev, "ethernet mux: switch to channel%d\n", new_channel);
4998-
4999-
gpiod_set_value_cansleep(mux->chan_sel_gpio, new_channel);
5000-
5001-
usleep_range(100000,200000);
5002-
5007+
rtnl_lock();//only for mtk_open/phylink_start
50035008
mtk_open(dev);
50045009

50055010
rtnl_unlock();

0 commit comments

Comments
 (0)