blob: 575675d7cef99ca4c889d0266c869ea4831180f9 [file] [log] [blame]
developer1a173672023-12-21 14:49:33 +08001From 2ce94ab60b821db9a1f3368df1b24b4f7904a00b Mon Sep 17 00:00:00 2001
developerbd9fa1e2023-10-16 11:04:00 +08002From: "sujuan.chen" <sujuan.chen@mediatek.com>
3Date: Wed, 19 Jul 2023 10:55:09 +0800
developer1a173672023-12-21 14:49:33 +08004Subject: [PATCH 2007/2020] mtk: wifi: mt76: mt7915: wed: find rx token by
5 physical address
developerbd9fa1e2023-10-16 11:04:00 +08006
7The token id in RxDMAD may be incorrect when it is not the last frame due to
8WED HW bug. Lookup correct token id by physical address in sdp0.
9Add len == 0 check to drop garbage frames
10
11Signed-off-by: Peter Chiu <chui-hao.chiu@mediatek.com>
12---
13 dma.c | 27 +++++++++++++++++++++++++--
14 1 file changed, 25 insertions(+), 2 deletions(-)
15
16diff --git a/dma.c b/dma.c
developer1a173672023-12-21 14:49:33 +080017index dfce79fa..69333769 100644
developerbd9fa1e2023-10-16 11:04:00 +080018--- a/dma.c
19+++ b/dma.c
developer1a173672023-12-21 14:49:33 +080020@@ -448,9 +448,32 @@ mt76_dma_get_buf(struct mt76_dev *dev, struct mt76_queue *q, int idx,
21 mt76_dma_should_drop_buf(drop, ctrl, buf1, desc_info);
developerbd9fa1e2023-10-16 11:04:00 +080022
23 if (mt76_queue_is_wed_rx(q)) {
24+ u32 id, find = 0;
developerbd9fa1e2023-10-16 11:04:00 +080025 u32 token = FIELD_GET(MT_DMA_CTL_TOKEN, buf1);
26- struct mt76_rxwi_cache *r = mt76_rx_token_release(dev, token);
27+ struct mt76_rxwi_cache *r;
28+
29+ if (*more) {
30+ spin_lock_bh(&dev->rx_token_lock);
31+
32+ idr_for_each_entry(&dev->rx_token, r, id) {
33+ if (r->dma_addr == le32_to_cpu(desc->buf0)) {
34+ find = 1;
35+ token = id;
36+
37+ /* Write correct id back to DMA*/
38+ u32p_replace_bits(&buf1, id,
39+ MT_DMA_CTL_TOKEN);
40+ WRITE_ONCE(desc->buf1, cpu_to_le32(buf1));
41+ break;
42+ }
43+ }
44
45+ spin_unlock_bh(&dev->rx_token_lock);
46+ if (!find)
47+ return NULL;
48+ }
49+
50+ r = mt76_rx_token_release(dev, token);
51 if (!r)
52 return NULL;
53
developer1a173672023-12-21 14:49:33 +080054@@ -978,7 +1001,7 @@ mt76_dma_rx_process(struct mt76_dev *dev, struct mt76_queue *q, int budget)
developerbd9fa1e2023-10-16 11:04:00 +080055 if (!data)
56 break;
57
58- if (drop)
59+ if (drop || (len == 0))
60 goto free_frag;
61
62 if (q->rx_head)
63--
642.18.0
65