Skip to content

Commit 952098c

Browse files
committed
Revert "net: eth-mux: try decoupling work-queue suggested by chatgpt"
This reverts commit 87e190f.
1 parent 1a9e30e commit 952098c

2 files changed

Lines changed: 17 additions & 31 deletions

File tree

drivers/net/ethernet/mediatek/mtk_eth_soc.c

Lines changed: 17 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -4919,17 +4919,26 @@ static const struct net_device_ops mtk_netdev_ops = {
49194919
.ndo_select_queue = mtk_select_queue,
49204920
};
49214921

4922-
static void mtk_mux_reconfig_work(struct work_struct *work)
4922+
static void mux_poll(struct work_struct *work)
49234923
{
4924-
struct mtk_mux *mux = container_of(work, struct mtk_mux, reconfig_work);
4924+
struct mtk_mux *mux = container_of(work, struct mtk_mux, poll.work);
49254925
struct mtk_mac *mac = mux->mac;
49264926
struct mtk_eth *eth = mac->hw;
49274927
struct net_device *dev = eth->netdev[mac->id];
4928-
unsigned int new_channel = mux->pending_channel;
4928+
unsigned int new_channel;
4929+
int sfp_present;
49294930

4930-
if (!netif_running(dev))
4931-
return;
4931+
//dev_info(eth->dev, "ethernet mux: %s:%d\n",__func__,__LINE__);
4932+
if (IS_ERR(mux->mod_def0_gpio) || IS_ERR(mux->chan_sel_gpio))
4933+
goto reschedule;
49324934

4935+
sfp_present = gpiod_get_value_cansleep(mux->mod_def0_gpio);
4936+
new_channel = sfp_present ? mux->sfp_present_channel : !mux->sfp_present_channel;
4937+
4938+
if (mux->channel == new_channel || !netif_running(dev))
4939+
goto reschedule;
4940+
4941+
dev_info(eth->dev, "ethernet mux: line:%d new channel:%d,sfp:%d\n",__LINE__, new_channel,sfp_present);
49334942
rtnl_lock();
49344943

49354944
mtk_stop(dev);
@@ -4941,32 +4950,13 @@ static void mtk_mux_reconfig_work(struct work_struct *work)
49414950

49424951
gpiod_set_value_cansleep(mux->chan_sel_gpio, new_channel);
49434952

4944-
mtk_open(dev);
4953+
usleep_range(100000,200000);
49454954

4946-
mux->channel = new_channel;
4955+
mtk_open(dev);
49474956

49484957
rtnl_unlock();
4949-
}
49504958

4951-
static void mux_poll(struct work_struct *work)
4952-
{
4953-
struct mtk_mux *mux = container_of(work, struct mtk_mux, poll.work);
4954-
struct mtk_mac *mac = mux->mac;
4955-
struct mtk_eth *eth = mac->hw;
4956-
struct net_device *dev = eth->netdev[mac->id];
4957-
unsigned int new_channel;
4958-
int sfp_present;
4959-
4960-
if (IS_ERR(mux->mod_def0_gpio) || IS_ERR(mux->chan_sel_gpio))
4961-
goto reschedule;
4962-
4963-
sfp_present = gpiod_get_value_cansleep(mux->mod_def0_gpio);
4964-
new_channel = sfp_present ? mux->sfp_present_channel : !mux->sfp_present_channel;
4965-
4966-
if (mux->channel != new_channel && netif_running(dev)) {
4967-
mux->pending_channel = new_channel;
4968-
schedule_work(&mux->reconfig_work);
4969-
}
4959+
mux->channel = new_channel;
49704960

49714961
reschedule:
49724962
mod_delayed_work(system_wq, &mux->poll, msecs_to_jiffies(100));
@@ -5035,7 +5025,6 @@ static void mtk_release_mux(struct mtk_eth *eth, int id)
50355025
return;
50365026

50375027
cancel_delayed_work_sync(&mux->poll);
5038-
cancel_work_sync(&mux->reconfig_work);
50395028

50405029
if (!IS_ERR_OR_NULL(mux->mod_def0_gpio))
50415030
gpiod_put(mux->mod_def0_gpio);
@@ -5127,7 +5116,6 @@ static int mtk_add_mux(struct mtk_eth *eth, struct device_node *np)
51275116
dev_info(eth->dev, "ethernet mux: line:%d added new mux\n",__LINE__);
51285117
INIT_DELAYED_WORK(&mux->poll, mux_poll);
51295118
mod_delayed_work(system_wq, &mux->poll, msecs_to_jiffies(3000));
5130-
INIT_WORK(&mux->reconfig_work, mtk_mux_reconfig_work);
51315119

51325120
return 0;
51335121

drivers/net/ethernet/mediatek/mtk_eth_soc.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1491,13 +1491,11 @@ struct mtk_mux_data {
14911491
*/
14921492
struct mtk_mux {
14931493
struct delayed_work poll;
1494-
struct work_struct reconfig_work;
14951494
struct gpio_desc *mod_def0_gpio;
14961495
struct gpio_desc *chan_sel_gpio;
14971496
struct mtk_mux_data *data[2];
14981497
struct mtk_mac *mac;
14991498
unsigned int channel;
1500-
unsigned int pending_channel;
15011499
unsigned int sfp_present_channel;
15021500
};
15031501

0 commit comments

Comments
 (0)