medaitek: convert the NAND target to UBI
[oweals/openwrt.git] / target / linux / mediatek / patches-4.4 / 0065-net-mediatek-fix-stop-and-wakeup-of-queue.patch
1 From afc838dde560ab584d3fb0e4b011e4a6770dab3d Mon Sep 17 00:00:00 2001
2 From: John Crispin <blogic@openwrt.org>
3 Date: Tue, 29 Mar 2016 16:41:07 +0200
4 Subject: [PATCH 065/102] net: mediatek: fix stop and wakeup of queue
5
6 The driver supports 2 MACs. Both run on the same DMA ring. If we go
7 above/below the TX rings thershold value, we always need to wake/stop
8 the queu of both devices. Not doing to can cause TX stalls and packet
9 drops on one of the devices.
10
11 Signed-off-by: John Crispin <blogic@openwrt.org>
12 ---
13  drivers/net/ethernet/mediatek/mtk_eth_soc.c |   37 +++++++++++++++++++--------
14  1 file changed, 27 insertions(+), 10 deletions(-)
15
16 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
17 +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
18 @@ -684,6 +684,28 @@ static inline int mtk_cal_txd_req(struct
19         return nfrags;
20  }
21  
22 +static void mtk_wake_queue(struct mtk_eth *eth)
23 +{
24 +       int i;
25 +
26 +       for (i = 0; i < MTK_MAC_COUNT; i++) {
27 +               if (!eth->netdev[i])
28 +                       continue;
29 +               netif_wake_queue(eth->netdev[i]);
30 +       }
31 +}
32 +
33 +static void mtk_stop_queue(struct mtk_eth *eth)
34 +{
35 +       int i;
36 +
37 +       for (i = 0; i < MTK_MAC_COUNT; i++) {
38 +               if (!eth->netdev[i])
39 +                       continue;
40 +               netif_stop_queue(eth->netdev[i]);
41 +       }
42 +}
43 +
44  static int mtk_start_xmit(struct sk_buff *skb, struct net_device *dev)
45  {
46         struct mtk_mac *mac = netdev_priv(dev);
47 @@ -695,7 +717,7 @@ static int mtk_start_xmit(struct sk_buff
48  
49         tx_num = mtk_cal_txd_req(skb);
50         if (unlikely(atomic_read(&ring->free_count) <= tx_num)) {
51 -               netif_stop_queue(dev);
52 +               mtk_stop_queue(eth);
53                 netif_err(eth, tx_queued, dev,
54                           "Tx Ring full when queue awake!\n");
55                 return NETDEV_TX_BUSY;
56 @@ -720,10 +742,10 @@ static int mtk_start_xmit(struct sk_buff
57                 goto drop;
58  
59         if (unlikely(atomic_read(&ring->free_count) <= ring->thresh)) {
60 -               netif_stop_queue(dev);
61 +               mtk_stop_queue(eth);
62                 if (unlikely(atomic_read(&ring->free_count) >
63                              ring->thresh))
64 -                       netif_wake_queue(dev);
65 +                       mtk_wake_queue(eth);
66         }
67  
68         return NETDEV_TX_OK;
69 @@ -897,13 +919,8 @@ static int mtk_poll_tx(struct mtk_eth *e
70         if (!total)
71                 return 0;
72  
73 -       for (i = 0; i < MTK_MAC_COUNT; i++) {
74 -               if (!eth->netdev[i] ||
75 -                   unlikely(!netif_queue_stopped(eth->netdev[i])))
76 -                       continue;
77 -               if (atomic_read(&ring->free_count) > ring->thresh)
78 -                       netif_wake_queue(eth->netdev[i]);
79 -       }
80 +       if (atomic_read(&ring->free_count) > ring->thresh)
81 +               mtk_wake_queue(eth);
82  
83         return total;
84  }