aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Crispin <blogic@openwrt.org>2016-04-07 18:54:09 -0400
committerDavid S. Miller <davem@davemloft.net>2016-04-12 22:41:32 -0400
commite7d425dcea032f1d0b44b6fa4c6735f13882de6e (patch)
treeb3ed88f5546f9b6bdd963493f997fd6ba81323da
parent34c2e4c9e9b3e434a31f67eecf603dc1496c8cc9 (diff)
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 <blogic@openwrt.org> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/ethernet/mediatek/mtk_eth_soc.c28
1 files changed, 20 insertions, 8 deletions
diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
index 7b760752d2c1..cd5d0c97f0ce 100644
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
@@ -1432,17 +1432,29 @@ static void mtk_pending_work(struct work_struct *work)
1432{ 1432{
1433 struct mtk_mac *mac = container_of(work, struct mtk_mac, pending_work); 1433 struct mtk_mac *mac = container_of(work, struct mtk_mac, pending_work);
1434 struct mtk_eth *eth = mac->hw; 1434 struct mtk_eth *eth = mac->hw;
1435 struct net_device *dev = eth->netdev[mac->id]; 1435 int err, i;
1436 int err; 1436 unsigned long restart = 0;
1437 1437
1438 rtnl_lock(); 1438 rtnl_lock();
1439 mtk_stop(dev);
1440 1439
1441 err = mtk_open(dev); 1440 /* stop all devices to make sure that dma is properly shut down */
1442 if (err) { 1441 for (i = 0; i < MTK_MAC_COUNT; i++) {
1443 netif_alert(eth, ifup, dev, 1442 if (!netif_oper_up(eth->netdev[i]))
1444 "Driver up/down cycle failed, closing device.\n"); 1443 continue;
1445 dev_close(dev); 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 }
1446 } 1458 }
1447 rtnl_unlock(); 1459 rtnl_unlock();
1448} 1460}