blob: c11071b513b0dab056e9c46c973ba235a320d5fe [file] [log] [blame]
developerbf24a8a2022-11-30 14:52:20 +08001From 632b007beff9a0800d2a37d173dee028701ecd02 Mon Sep 17 00:00:00 2001
developer144824b2022-11-25 21:27:43 +08002From: Sujuan Chen <sujuan.chen@mediatek.com>
3Date: Fri, 25 Nov 2022 12:05:06 +0800
developerbf24a8a2022-11-30 14:52:20 +08004Subject: [PATCH 3003/3010] mt76: connac: wed: add wed rx copy skb
developer144824b2022-11-25 21:27:43 +08005
6Signed-off-by: Sujuan Chen <sujuan.chen@mediatek.com>
7---
8 dma.c | 23 ++++++++++++++++++-----
9 1 file changed, 18 insertions(+), 5 deletions(-)
10
11diff --git a/dma.c b/dma.c
developerbf24a8a2022-11-30 14:52:20 +080012index d2891c64..40885754 100644
developer144824b2022-11-25 21:27:43 +080013--- a/dma.c
14+++ b/dma.c
15@@ -382,9 +382,12 @@ mt76_dma_get_buf(struct mt76_dev *dev, struct mt76_queue *q, int idx,
16 SKB_WITH_OVERHEAD(q->buf_size),
17 DMA_FROM_DEVICE);
18
19- buf = t->ptr;
20+ buf = page_frag_alloc(&q->rx_page, q->buf_size, GFP_ATOMIC);
21+ if (!buf)
22+ return NULL;
23+
24+ memcpy(buf, t->ptr, SKB_WITH_OVERHEAD(q->buf_size));
25 t->dma_addr = 0;
26- t->ptr = NULL;
27
28 mt76_put_rxwi(dev, t);
29
30@@ -578,6 +581,7 @@ mt76_dma_rx_fill(struct mt76_dev *dev, struct mt76_queue *q)
31 while (q->queued < q->ndesc - 1) {
32 struct mt76_txwi_cache *t = NULL;
33 struct mt76_queue_buf qbuf;
34+ bool skip_alloc = false;
35 void *buf = NULL;
36
37 if ((q->flags & MT_QFLAG_WED) &&
38@@ -585,11 +589,18 @@ mt76_dma_rx_fill(struct mt76_dev *dev, struct mt76_queue *q)
39 t = mt76_get_rxwi(dev);
40 if (!t)
41 break;
42+
43+ if (t->ptr) {
44+ skip_alloc = true;
45+ buf = t->ptr;
46+ }
47 }
48
49- buf = page_frag_alloc(rx_page, q->buf_size, GFP_ATOMIC);
50- if (!buf)
51- break;
52+ if (!skip_alloc) {
53+ buf = page_frag_alloc(rx_page, q->buf_size, GFP_ATOMIC);
54+ if (!buf)
55+ break;
56+ }
57
58 addr = dma_map_single(dev->dma_dev, buf, len, DMA_FROM_DEVICE);
59 if (unlikely(dma_mapping_error(dev->dma_dev, addr))) {
60@@ -954,5 +965,7 @@ void mt76_dma_cleanup(struct mt76_dev *dev)
61
62 if (mtk_wed_device_active(&dev->mmio.wed))
63 mtk_wed_device_detach(&dev->mmio.wed);
64+
65+ mt76_free_pending_rxwi(dev);
66 }
67 EXPORT_SYMBOL_GPL(mt76_dma_cleanup);
68--
developerbf24a8a2022-11-30 14:52:20 +0800692.36.1
developer144824b2022-11-25 21:27:43 +080070