Skip to content

Commit e7d425d

Browse files
John Crispindavem330
authored andcommitted
net: mediatek: fix mtk_pending_work
The driver supports 2 MACs. Both run on the same DMA ring. If we hit a TX timeout we need to stop both netdevs before restarting them again. If we don't do this, mtk_stop() wont shutdown DMA and the consecutive call to mtk_open() wont restart DMA and enable IRQs. Signed-off-by: John Crispin <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 34c2e4c commit e7d425d

File tree

1 file changed

+20
-8
lines changed

1 file changed

+20
-8
lines changed

drivers/net/ethernet/mediatek/mtk_eth_soc.c

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1432,17 +1432,29 @@ static void mtk_pending_work(struct work_struct *work)
14321432
{
14331433
struct mtk_mac *mac = container_of(work, struct mtk_mac, pending_work);
14341434
struct mtk_eth *eth = mac->hw;
1435-
struct net_device *dev = eth->netdev[mac->id];
1436-
int err;
1435+
int err, i;
1436+
unsigned long restart = 0;
14371437

14381438
rtnl_lock();
1439-
mtk_stop(dev);
14401439

1441-
err = mtk_open(dev);
1442-
if (err) {
1443-
netif_alert(eth, ifup, dev,
1444-
"Driver up/down cycle failed, closing device.\n");
1445-
dev_close(dev);
1440+
/* stop all devices to make sure that dma is properly shut down */
1441+
for (i = 0; i < MTK_MAC_COUNT; i++) {
1442+
if (!netif_oper_up(eth->netdev[i]))
1443+
continue;
1444+
mtk_stop(eth->netdev[i]);
1445+
__set_bit(i, &restart);
1446+
}
1447+
1448+
/* restart DMA and enable IRQs */
1449+
for (i = 0; i < MTK_MAC_COUNT; i++) {
1450+
if (!test_bit(i, &restart))
1451+
continue;
1452+
err = mtk_open(eth->netdev[i]);
1453+
if (err) {
1454+
netif_alert(eth, ifup, eth->netdev[i],
1455+
"Driver up/down cycle failed, closing device.\n");
1456+
dev_close(eth->netdev[i]);
1457+
}
14461458
}
14471459
rtnl_unlock();
14481460
}

0 commit comments

Comments
 (0)