blob: 09b05b81ac67f7d2ac4ccd17dc8d199f84acf0ef [file] [log] [blame]
developer81ca9d62022-10-14 11:23:22 +08001From 8798ce118731d2446d8d1b1c4ab0f1062fc08ea7 Mon Sep 17 00:00:00 2001
developer6abc5082022-09-27 17:39:17 +08002From: Peter Chiu <chui-hao.chiu@mediatek.com>
3Date: Tue, 27 Sep 2022 16:34:26 +0800
developer81ca9d62022-10-14 11:23:22 +08004Subject: [PATCH 3009/3011] mt76: mt7915: find rx token by physical address
developer6abc5082022-09-27 17:39:17 +08005
6The token id in RxDMAD may be incorrect when it is not the last frame due to
7WED HW bug. Lookup correct token id by physical address in sdp0.
8
9Signed-off-by: Peter Chiu <chui-hao.chiu@mediatek.com>
10---
11 dma.c | 19 ++++++++++++++++++-
12 1 file changed, 18 insertions(+), 1 deletion(-)
13
14diff --git a/dma.c b/dma.c
developer81ca9d62022-10-14 11:23:22 +080015index d63b02f5..a7a4538a 100644
developer6abc5082022-09-27 17:39:17 +080016--- a/dma.c
17+++ b/dma.c
18@@ -380,11 +380,28 @@ mt76_dma_get_buf(struct mt76_dev *dev, struct mt76_queue *q, int idx,
developerc226de82022-10-03 12:24:57 +080019
developer6abc5082022-09-27 17:39:17 +080020 type = FIELD_GET(MT_QFLAG_WED_TYPE, q->flags);
21 if (mtk_wed_device_active(wed) && type == MT76_WED_Q_RX) {
22- u32 token;
23+ u32 token, id, find = 0;
24 struct mt76_txwi_cache *r;
developerc226de82022-10-03 12:24:57 +080025
developer6abc5082022-09-27 17:39:17 +080026 token = FIELD_GET(MT_DMA_CTL_TOKEN, desc->buf1);
developerc226de82022-10-03 12:24:57 +080027
developer6abc5082022-09-27 17:39:17 +080028+ 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+ desc->buf1 = FIELD_PREP(MT_DMA_CTL_TOKEN, id);
35+ token = id;
36+ break;
37+ }
38+ }
39+
40+ spin_unlock_bh(&dev->rx_token_lock);
41+ if (!find)
42+ return NULL;
43+
44+ }
45 r = mt76_rx_token_release(dev, token);
46 if (!r)
47 return NULL;
developerc226de82022-10-03 12:24:57 +080048--
developer81ca9d62022-10-14 11:23:22 +0800492.25.1
developer6abc5082022-09-27 17:39:17 +080050