blob: 7c2bb77b9651f06071541babf6b286cb0e88f011 [file] [log] [blame]
developer2cbf2fb2022-11-16 12:20:48 +08001From 70c17335911119c353fdf709d8ce1688509c02d0 Mon Sep 17 00:00:00 2001
developer36936c32022-09-30 12:55:06 +08002From: Peter Chiu <chui-hao.chiu@mediatek.com>
3Date: Tue, 27 Sep 2022 16:34:26 +0800
developer2cbf2fb2022-11-16 12:20:48 +08004Subject: [PATCH 3009/3011] mt76: mt7915: find rx token by physical address
developer36936c32022-09-30 12:55:06 +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
developer2cbf2fb2022-11-16 12:20:48 +080015index d63b02f5..a7a4538a 100644
developer36936c32022-09-30 12:55:06 +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,
developerf1313102022-10-11 11:02:55 +080019
developer36936c32022-09-30 12:55:06 +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;
developerf1313102022-10-11 11:02:55 +080025
developer36936c32022-09-30 12:55:06 +080026 token = FIELD_GET(MT_DMA_CTL_TOKEN, desc->buf1);
developerf1313102022-10-11 11:02:55 +080027
developer36936c32022-09-30 12:55:06 +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;
developerf1313102022-10-11 11:02:55 +080048--
developerb81e95d2022-11-08 10:16:29 +0800492.18.0
developer36936c32022-09-30 12:55:06 +080050