1 From a2dfb33c8a0dc03fe2ec2121490df2b9352febef Mon Sep 17 00:00:00 2001
2 From: John Crispin <blogic@openwrt.org>
3 Date: Tue, 29 Mar 2016 17:00:47 +0200
4 Subject: [PATCH 70/81] net: mediatek: fix mtk_pending_work
6 The driver supports 2 MACs. Both run on the same DMA ring. If we hit a TX
7 timeout we need to stop both netdevs before retarting them again. If we
8 dont do thsi, mtk_stop() wont shutdown DMA and the consecutive call to
9 mtk_open() wont restart DMA and enable IRQs.
11 Signed-off-by: John Crispin <blogic@openwrt.org>
13 drivers/net/ethernet/mediatek/mtk_eth_soc.c | 30 +++++++++++++++++++--------
14 1 file changed, 21 insertions(+), 9 deletions(-)
16 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
17 +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
18 @@ -1430,19 +1430,31 @@ static int mtk_do_ioctl(struct net_devic
20 static void mtk_pending_work(struct work_struct *work)
22 - struct mtk_mac *mac = container_of(work, struct mtk_mac, pending_work);
23 - struct mtk_eth *eth = mac->hw;
24 - struct net_device *dev = eth->netdev[mac->id];
26 + struct mtk_eth *eth = container_of(work, struct mtk_eth, pending_work);
28 + unsigned long restart = 0;
33 - err = mtk_open(dev);
35 - netif_alert(eth, ifup, dev,
36 + /* stop all devices to make sure that dma is properly shut down */
37 + for (i = 0; i < MTK_MAC_COUNT; i++) {
38 + if (!netif_oper_up(eth->netdev[i]))
40 + mtk_stop(eth->netdev[i]);
41 + __set_bit(i, &restart);
45 + /* restart DMA and enable IRQs */
46 + for (i = 0; i < MTK_MAC_COUNT; i++) {
47 + if (!test_bit(i, &restart))
49 + err = mtk_open(eth->netdev[i]);
51 + netif_alert(eth, ifup, eth->netdev[i],
52 "Driver up/down cycle failed, closing device.\n");
54 + dev_close(eth->netdev[i]);