blob: 45262aea41517364f53a7e8a5674e95eeab75a6b [file] [log] [blame]
From aa5ba9b452355d0bd7d76868753c66a88464318c Mon Sep 17 00:00:00 2001
From: "sujuan.chen" <sujuan.chen@mediatek.com>
Date: Wed, 19 Jul 2023 10:55:09 +0800
Subject: [PATCH 2009/2012] wifi: mt76: mt7915: wed: find rx token by physical
address
The token id in RxDMAD may be incorrect when it is not the last frame due to
WED HW bug. Lookup correct token id by physical address in sdp0.
Add len == 0 check to drop garbage frames
Signed-off-by: Peter Chiu <chui-hao.chiu@mediatek.com>
---
dma.c | 27 +++++++++++++++++++++++++--
1 file changed, 25 insertions(+), 2 deletions(-)
diff --git a/dma.c b/dma.c
index bfe188134..415121f74 100644
--- a/dma.c
+++ b/dma.c
@@ -441,10 +441,33 @@ mt76_dma_get_buf(struct mt76_dev *dev, struct mt76_queue *q, int idx,
}
if (mt76_queue_is_wed_rx(q)) {
+ u32 id, find = 0;
u32 buf1 = le32_to_cpu(desc->buf1);
u32 token = FIELD_GET(MT_DMA_CTL_TOKEN, buf1);
- struct mt76_rxwi_cache *r = mt76_rx_token_release(dev, token);
+ struct mt76_rxwi_cache *r;
+
+ if (*more) {
+ spin_lock_bh(&dev->rx_token_lock);
+
+ idr_for_each_entry(&dev->rx_token, r, id) {
+ if (r->dma_addr == le32_to_cpu(desc->buf0)) {
+ find = 1;
+ token = id;
+
+ /* Write correct id back to DMA*/
+ u32p_replace_bits(&buf1, id,
+ MT_DMA_CTL_TOKEN);
+ WRITE_ONCE(desc->buf1, cpu_to_le32(buf1));
+ break;
+ }
+ }
+ spin_unlock_bh(&dev->rx_token_lock);
+ if (!find)
+ return NULL;
+ }
+
+ r = mt76_rx_token_release(dev, token);
if (!r)
return NULL;
@@ -972,7 +995,7 @@ mt76_dma_rx_process(struct mt76_dev *dev, struct mt76_queue *q, int budget)
if (!data)
break;
- if (drop)
+ if (drop || (len == 0))
goto free_frag;
if (q->rx_head)
--
2.39.2