blob: cee1e63a976dc1b45643674d9867251cfb31fd57 [file] [log] [blame]
From bcd2e7f4520fa16b90fb7e4d98e0590d3e70fe11 Mon Sep 17 00:00:00 2001
From: Sujuan Chen <sujuan.chen@mediatek.com>
Date: Fri, 25 Nov 2022 12:05:06 +0800
Subject: [PATCH 32/39] mt76: add wed rx copy skb
Signed-off-by: Sujuan Chen <sujuan.chen@mediatek.com>
---
dma.c | 23 ++++++++++++++++++-----
1 file changed, 18 insertions(+), 5 deletions(-)
diff --git a/dma.c b/dma.c
index d2891c64..929816b7 100644
--- a/dma.c
+++ b/dma.c
@@ -382,9 +382,12 @@ mt76_dma_get_buf(struct mt76_dev *dev, struct mt76_queue *q, int idx,
SKB_WITH_OVERHEAD(q->buf_size),
DMA_FROM_DEVICE);
- buf = t->ptr;
+ buf = page_frag_alloc(&q->rx_page, q->buf_size, GFP_ATOMIC);
+ if (!buf)
+ return NULL;
+
+ memcpy(buf, t->ptr, SKB_WITH_OVERHEAD(q->buf_size));
t->dma_addr = 0;
- t->ptr = NULL;
mt76_put_rxwi(dev, t);
@@ -578,6 +581,7 @@ mt76_dma_rx_fill(struct mt76_dev *dev, struct mt76_queue *q)
while (q->queued < q->ndesc - 1) {
struct mt76_txwi_cache *t = NULL;
struct mt76_queue_buf qbuf;
+ bool skip_alloc = false;
void *buf = NULL;
if ((q->flags & MT_QFLAG_WED) &&
@@ -585,11 +589,18 @@ mt76_dma_rx_fill(struct mt76_dev *dev, struct mt76_queue *q)
t = mt76_get_rxwi(dev);
if (!t)
break;
+
+ if (t->ptr) {
+ skip_alloc = true;
+ buf = t->ptr;
+ }
}
- buf = page_frag_alloc(rx_page, q->buf_size, GFP_ATOMIC);
- if (!buf)
- break;
+ if (!skip_alloc) {
+ buf = page_frag_alloc(rx_page, q->buf_size, GFP_ATOMIC);
+ if (!buf)
+ break;
+ }
addr = dma_map_single(dev->dma_dev, buf, len, DMA_FROM_DEVICE);
if (unlikely(dma_mapping_error(dev->dma_dev, addr))) {
@@ -954,5 +965,7 @@ void mt76_dma_cleanup(struct mt76_dev *dev)
if (mtk_wed_device_active(&dev->mmio.wed))
mtk_wed_device_detach(&dev->mmio.wed);
+
+ mt76_free_pending_rxwi(dev);
}
EXPORT_SYMBOL_GPL(mt76_dma_cleanup);
--
2.18.0