mediatek: update patches
[openwrt/openwrt.git] / target / linux / mediatek / patches-4.4 / 0066-net-mediatek-fix-mtk_pending_work.patch
1 From e2cc73e6ddb0cc39b8f58654a449651a621916a9 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 066/102] 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 diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
17 index 04bdb9d..26eeb1a 100644
18 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
19 +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
20 @@ -1430,19 +1430,31 @@ static int mtk_do_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
21
22 static void mtk_pending_work(struct work_struct *work)
23 {
24 - struct mtk_mac *mac = container_of(work, struct mtk_mac, pending_work);
25 - struct mtk_eth *eth = mac->hw;
26 - struct net_device *dev = eth->netdev[mac->id];
27 - int err;
28 + struct mtk_eth *eth = container_of(work, struct mtk_eth, pending_work);
29 + int err, i;
30 + unsigned long restart = 0;
31
32 rtnl_lock();
33 - mtk_stop(dev);
34
35 - err = mtk_open(dev);
36 - if (err) {
37 - netif_alert(eth, ifup, dev,
38 + /* stop all devices to make sure that dma is properly shut down */
39 + for (i = 0; i < MTK_MAC_COUNT; i++) {
40 + if (!netif_oper_up(eth->netdev[i]))
41 + continue;
42 + mtk_stop(eth->netdev[i]);
43 + __set_bit(i, &restart);
44 + }
45 +
46 +
47 + /* restart DMA and enable IRQs */
48 + for (i = 0; i < MTK_MAC_COUNT; i++) {
49 + if (!test_bit(i, &restart))
50 + continue;
51 + err = mtk_open(eth->netdev[i]);
52 + if (err) {
53 + netif_alert(eth, ifup, eth->netdev[i],
54 "Driver up/down cycle failed, closing device.\n");
55 - dev_close(dev);
56 + dev_close(eth->netdev[i]);
57 + }
58 }
59 rtnl_unlock();
60 }
61 --
62 1.7.10.4
63