kernel: update kernel 4.4 to version 4.4.7
[openwrt.git] / target / linux / mediatek / patches-4.4 / 0070-net-mediatek-fix-mtk_pending_work.patch
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
5
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.
10
11 Signed-off-by: John Crispin <blogic@openwrt.org>
12 ---
13  drivers/net/ethernet/mediatek/mtk_eth_soc.c |   30 +++++++++++++++++++--------
14  1 file changed, 21 insertions(+), 9 deletions(-)
15
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
19  
20  static void mtk_pending_work(struct work_struct *work)
21  {
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];
25 -       int err;
26 +       struct mtk_eth *eth = container_of(work, struct mtk_eth, pending_work);
27 +       int err, i;
28 +       unsigned long restart = 0;
29  
30         rtnl_lock();
31 -       mtk_stop(dev);
32  
33 -       err = mtk_open(dev);
34 -       if (err) {
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]))
39 +                       continue;
40 +               mtk_stop(eth->netdev[i]);
41 +               __set_bit(i, &restart);
42 +       }
43 +
44 +
45 +       /* restart DMA and enable IRQs */
46 +       for (i = 0; i < MTK_MAC_COUNT; i++) {
47 +               if (!test_bit(i, &restart))
48 +                       continue;
49 +               err = mtk_open(eth->netdev[i]);
50 +               if (err) {
51 +                       netif_alert(eth, ifup, eth->netdev[i],
52                             "Driver up/down cycle failed, closing device.\n");
53 -               dev_close(dev);
54 +                       dev_close(eth->netdev[i]);
55 +               }
56         }
57         rtnl_unlock();
58  }