blob: 1c5a1fbe36a73fee9c22b42921ec450d783f36de [file] [log] [blame]
developer05f3b2b2024-08-19 19:17:34 +08001From d19b337c221ed6c72d9733c3206bcd6f24b3a774 Mon Sep 17 00:00:00 2001
developer66e89bc2024-04-23 14:50:01 +08002From: "sujuan.chen" <sujuan.chen@mediatek.com>
3Date: Wed, 19 Jul 2023 10:55:09 +0800
developer05f3b2b2024-08-19 19:17:34 +08004Subject: [PATCH 068/199] mtk: mt76: find rx token by physical address
developer66e89bc2024-04-23 14:50:01 +08005
developer05f3b2b2024-08-19 19:17:34 +08006The token id in RxDMAD may be incorrect when it is not the last frame in
7WED HW. Lookup correct token id by physical address in sdp0.
developer66e89bc2024-04-23 14:50:01 +08008Add len == 0 check to drop garbage frames
9
10Signed-off-by: Peter Chiu <chui-hao.chiu@mediatek.com>
developer66e89bc2024-04-23 14:50:01 +080011---
12 dma.c | 27 +++++++++++++++++++++++++--
13 1 file changed, 25 insertions(+), 2 deletions(-)
14
15diff --git a/dma.c b/dma.c
developer05f3b2b2024-08-19 19:17:34 +080016index e5be891c..1021b3e5 100644
developer66e89bc2024-04-23 14:50:01 +080017--- a/dma.c
18+++ b/dma.c
19@@ -446,9 +446,32 @@ mt76_dma_get_buf(struct mt76_dev *dev, struct mt76_queue *q, int idx,
20 mt76_dma_should_drop_buf(drop, ctrl, buf1, desc_info);
21
22 if (mt76_queue_is_wed_rx(q)) {
23+ u32 id, find = 0;
24 u32 token = FIELD_GET(MT_DMA_CTL_TOKEN, buf1);
25- struct mt76_rxwi_cache *r = mt76_rx_token_release(dev, token);
26+ struct mt76_rxwi_cache *r;
27+
28+ if (*more) {
29+ spin_lock_bh(&dev->rx_token_lock);
30+
31+ idr_for_each_entry(&dev->rx_token, r, id) {
32+ if (r->dma_addr == le32_to_cpu(desc->buf0)) {
33+ find = 1;
34+ token = id;
35+
36+ /* Write correct id back to DMA*/
37+ u32p_replace_bits(&buf1, id,
38+ MT_DMA_CTL_TOKEN);
39+ WRITE_ONCE(desc->buf1, cpu_to_le32(buf1));
40+ break;
41+ }
42+ }
43
44+ spin_unlock_bh(&dev->rx_token_lock);
45+ if (!find)
46+ return NULL;
47+ }
48+
49+ r = mt76_rx_token_release(dev, token);
50 if (!r)
51 return NULL;
52
53@@ -902,7 +925,7 @@ mt76_dma_rx_process(struct mt76_dev *dev, struct mt76_queue *q, int budget)
54 if (!data)
55 break;
56
57- if (drop)
58+ if (drop || (len == 0))
59 goto free_frag;
60
61 if (q->rx_head)
62--
developer9237f442024-06-14 17:13:04 +0800632.18.0
developer66e89bc2024-04-23 14:50:01 +080064