mediatek: update patches
[openwrt/staging/chunkeey.git] / target / linux / mediatek / patches-4.4 / 0073-net-mediatek-fix-stop-and-wakeup-of-queue.patch
1 From 283001c04f395f32e55345632d8129f5395cde33 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 73/91] 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 diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
17 index 293ea59..04bdb9d 100644
18 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
19 +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
20 @@ -684,6 +684,28 @@ static inline int mtk_cal_txd_req(struct sk_buff *skb)
21 return nfrags;
22 }
23
24 +static void mtk_wake_queue(struct mtk_eth *eth)
25 +{
26 + int i;
27 +
28 + for (i = 0; i < MTK_MAC_COUNT; i++) {
29 + if (!eth->netdev[i])
30 + continue;
31 + netif_wake_queue(eth->netdev[i]);
32 + }
33 +}
34 +
35 +static void mtk_stop_queue(struct mtk_eth *eth)
36 +{
37 + int i;
38 +
39 + for (i = 0; i < MTK_MAC_COUNT; i++) {
40 + if (!eth->netdev[i])
41 + continue;
42 + netif_stop_queue(eth->netdev[i]);
43 + }
44 +}
45 +
46 static int mtk_start_xmit(struct sk_buff *skb, struct net_device *dev)
47 {
48 struct mtk_mac *mac = netdev_priv(dev);
49 @@ -695,7 +717,7 @@ static int mtk_start_xmit(struct sk_buff *skb, struct net_device *dev)
50
51 tx_num = mtk_cal_txd_req(skb);
52 if (unlikely(atomic_read(&ring->free_count) <= tx_num)) {
53 - netif_stop_queue(dev);
54 + mtk_stop_queue(eth);
55 netif_err(eth, tx_queued, dev,
56 "Tx Ring full when queue awake!\n");
57 return NETDEV_TX_BUSY;
58 @@ -720,10 +742,10 @@ static int mtk_start_xmit(struct sk_buff *skb, struct net_device *dev)
59 goto drop;
60
61 if (unlikely(atomic_read(&ring->free_count) <= ring->thresh)) {
62 - netif_stop_queue(dev);
63 + mtk_stop_queue(eth);
64 if (unlikely(atomic_read(&ring->free_count) >
65 ring->thresh))
66 - netif_wake_queue(dev);
67 + mtk_wake_queue(eth);
68 }
69
70 return NETDEV_TX_OK;
71 @@ -897,13 +919,8 @@ static int mtk_poll_tx(struct mtk_eth *eth, int budget, bool *tx_again)
72 if (!total)
73 return 0;
74
75 - for (i = 0; i < MTK_MAC_COUNT; i++) {
76 - if (!eth->netdev[i] ||
77 - unlikely(!netif_queue_stopped(eth->netdev[i])))
78 - continue;
79 - if (atomic_read(&ring->free_count) > ring->thresh)
80 - netif_wake_queue(eth->netdev[i]);
81 - }
82 + if (atomic_read(&ring->free_count) > ring->thresh)
83 + mtk_wake_queue(eth);
84
85 return total;
86 }
87 --
88 1.7.10.4
89