base-files: fix some failsafe issues
[openwrt/openwrt.git] / target / linux / mediatek / patches-4.4 / 0079-net-next-mediatek-fix-BQL-support.patch
1 From f26f228f312fafc090d21036b682bd1062bb731f 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/91] 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 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
12 +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
13 @@ -625,7 +625,16 @@ static int mtk_tx_map(struct sk_buff *sk
14 WRITE_ONCE(itxd->txd3, (TX_DMA_SWC | TX_DMA_PLEN0(skb_headlen(skb)) |
15 (!nr_frags * TX_DMA_LS0)));
16
17 - netdev_sent_queue(dev, skb->len);
18 + /* we have a single DMA ring so BQL needs to be updated for all devices
19 + * sitting on this ring
20 + */
21 + for (i = 0; i < MTK_MAC_COUNT; i++) {
22 + if (!eth->netdev[i])
23 + continue;
24 +
25 + netdev_sent_queue(eth->netdev[i], skb->len);
26 + }
27 +
28 skb_tx_timestamp(skb);
29
30 ring->next_free = mtk_qdma_phys_to_virt(ring, txd->txd2);
31 @@ -853,21 +862,18 @@ static int mtk_poll_tx(struct mtk_eth *e
32 struct mtk_tx_dma *desc;
33 struct sk_buff *skb;
34 struct mtk_tx_buf *tx_buf;
35 - int total = 0, done[MTK_MAX_DEVS];
36 - unsigned int bytes[MTK_MAX_DEVS];
37 + int total = 0, done = 0;
38 + unsigned int bytes = 0;
39 u32 cpu, dma;
40 static int condition;
41 int i;
42
43 - memset(done, 0, sizeof(done));
44 - memset(bytes, 0, sizeof(bytes));
45 -
46 cpu = mtk_r32(eth, MTK_QTX_CRX_PTR);
47 dma = mtk_r32(eth, MTK_QTX_DRX_PTR);
48
49 desc = mtk_qdma_phys_to_virt(ring, cpu);
50
51 - while ((cpu != dma) && budget) {
52 + while ((cpu != dma) && done < budget) {
53 u32 next_cpu = desc->txd2;
54 int mac;
55
56 @@ -887,9 +893,8 @@ static int mtk_poll_tx(struct mtk_eth *e
57 }
58
59 if (skb != (struct sk_buff *)MTK_DMA_DUMMY_DESC) {
60 - bytes[mac] += skb->len;
61 - done[mac]++;
62 - budget--;
63 + bytes += skb->len;
64 + done++;
65 }
66 mtk_tx_unmap(eth->dev, tx_buf);
67
68 @@ -902,11 +907,13 @@ static int mtk_poll_tx(struct mtk_eth *e
69
70 mtk_w32(eth, cpu, MTK_QTX_CRX_PTR);
71
72 + /* we have a single DMA ring so BQL needs to be updated for all devices
73 + * sitting on this ring
74 + */
75 for (i = 0; i < MTK_MAC_COUNT; i++) {
76 - if (!eth->netdev[i] || !done[i])
77 + if (!eth->netdev[i])
78 continue;
79 - netdev_completed_queue(eth->netdev[i], done[i], bytes[i]);
80 - total += done[i];
81 + netdev_completed_queue(eth->netdev[i], done, bytes);
82 }
83
84 /* read hw index again make sure no new tx packet */