mediatek: sync and patches add support for several boards
[openwrt/staging/lynxis/omap.git] / target / linux / mediatek / patches-4.4 / 0079-net-next-mediatek-fix-BQL-support.patch
1 From d449af97701c1da5b373df5a7675b93b9a2067bf Mon Sep 17 00:00:00 2001
2 From: John Crispin <blogic@openwrt.org>
3 Date: Sat, 23 Apr 2016 11:57:21 +0200
4 Subject: [PATCH 79/90] net-next: mediatek: fix BQL support
5
6 Signed-off-by: John Crispin <blogic@openwrt.org>
7 ---
8 drivers/net/ethernet/mediatek/mtk_eth_soc.c | 33 ++++++++++++++++-----------
9 1 file changed, 20 insertions(+), 13 deletions(-)
10
11 diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
12 index bab5d45..9928a79 100644
13 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
14 +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
15 @@ -625,7 +625,16 @@ static int mtk_tx_map(struct sk_buff *skb, struct net_device *dev,
16 WRITE_ONCE(itxd->txd3, (TX_DMA_SWC | TX_DMA_PLEN0(skb_headlen(skb)) |
17 (!nr_frags * TX_DMA_LS0)));
18
19 - netdev_sent_queue(dev, skb->len);
20 + /* we have a single DMA ring so BQL needs to be updated for all devices
21 + * sitting on this ring
22 + */
23 + for (i = 0; i < MTK_MAC_COUNT; i++) {
24 + if (!eth->netdev[i])
25 + continue;
26 +
27 + netdev_sent_queue(eth->netdev[i], skb->len);
28 + }
29 +
30 skb_tx_timestamp(skb);
31
32 ring->next_free = mtk_qdma_phys_to_virt(ring, txd->txd2);
33 @@ -853,21 +862,18 @@ static int mtk_poll_tx(struct mtk_eth *eth, int budget, bool *tx_again)
34 struct mtk_tx_dma *desc;
35 struct sk_buff *skb;
36 struct mtk_tx_buf *tx_buf;
37 - int total = 0, done[MTK_MAX_DEVS];
38 - unsigned int bytes[MTK_MAX_DEVS];
39 + int total = 0, done = 0;
40 + unsigned int bytes = 0;
41 u32 cpu, dma;
42 static int condition;
43 int i;
44
45 - memset(done, 0, sizeof(done));
46 - memset(bytes, 0, sizeof(bytes));
47 -
48 cpu = mtk_r32(eth, MTK_QTX_CRX_PTR);
49 dma = mtk_r32(eth, MTK_QTX_DRX_PTR);
50
51 desc = mtk_qdma_phys_to_virt(ring, cpu);
52
53 - while ((cpu != dma) && budget) {
54 + while ((cpu != dma) && done < budget) {
55 u32 next_cpu = desc->txd2;
56 int mac;
57
58 @@ -887,9 +893,8 @@ static int mtk_poll_tx(struct mtk_eth *eth, int budget, bool *tx_again)
59 }
60
61 if (skb != (struct sk_buff *)MTK_DMA_DUMMY_DESC) {
62 - bytes[mac] += skb->len;
63 - done[mac]++;
64 - budget--;
65 + bytes += skb->len;
66 + done++;
67 }
68 mtk_tx_unmap(eth->dev, tx_buf);
69
70 @@ -902,11 +907,13 @@ static int mtk_poll_tx(struct mtk_eth *eth, int budget, bool *tx_again)
71
72 mtk_w32(eth, cpu, MTK_QTX_CRX_PTR);
73
74 + /* we have a single DMA ring so BQL needs to be updated for all devices
75 + * sitting on this ring
76 + */
77 for (i = 0; i < MTK_MAC_COUNT; i++) {
78 - if (!eth->netdev[i] || !done[i])
79 + if (!eth->netdev[i])
80 continue;
81 - netdev_completed_queue(eth->netdev[i], done[i], bytes[i]);
82 - total += done[i];
83 + netdev_completed_queue(eth->netdev[i], done, bytes);
84 }
85
86 /* read hw index again make sure no new tx packet */
87 --
88 1.7.10.4
89