developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame^] | 1 | From d810c1768039fafabea801f2c4a5fc517e8cd68d Mon Sep 17 00:00:00 2001 |
| 2 | From: "sujuan.chen" <sujuan.chen@mediatek.com> |
| 3 | Date: Wed, 19 Jul 2023 10:55:09 +0800 |
| 4 | Subject: [PATCH 064/116] mtk: wifi: mt76: mt7915: wed: find rx token by |
| 5 | physical address |
| 6 | |
| 7 | The token id in RxDMAD may be incorrect when it is not the last frame due to |
| 8 | WED HW bug. Lookup correct token id by physical address in sdp0. |
| 9 | Add len == 0 check to drop garbage frames |
| 10 | |
| 11 | Signed-off-by: Peter Chiu <chui-hao.chiu@mediatek.com> |
| 12 | Change-Id: I4cd90294ad24990826075e92a710cc4e301dcbb7 |
| 13 | --- |
| 14 | dma.c | 27 +++++++++++++++++++++++++-- |
| 15 | 1 file changed, 25 insertions(+), 2 deletions(-) |
| 16 | |
| 17 | diff --git a/dma.c b/dma.c |
| 18 | index e5be891cb..1021b3e5d 100644 |
| 19 | --- a/dma.c |
| 20 | +++ b/dma.c |
| 21 | @@ -446,9 +446,32 @@ mt76_dma_get_buf(struct mt76_dev *dev, struct mt76_queue *q, int idx, |
| 22 | mt76_dma_should_drop_buf(drop, ctrl, buf1, desc_info); |
| 23 | |
| 24 | if (mt76_queue_is_wed_rx(q)) { |
| 25 | + u32 id, find = 0; |
| 26 | u32 token = FIELD_GET(MT_DMA_CTL_TOKEN, buf1); |
| 27 | - struct mt76_rxwi_cache *r = mt76_rx_token_release(dev, token); |
| 28 | + struct mt76_rxwi_cache *r; |
| 29 | + |
| 30 | + if (*more) { |
| 31 | + spin_lock_bh(&dev->rx_token_lock); |
| 32 | + |
| 33 | + idr_for_each_entry(&dev->rx_token, r, id) { |
| 34 | + if (r->dma_addr == le32_to_cpu(desc->buf0)) { |
| 35 | + find = 1; |
| 36 | + token = id; |
| 37 | + |
| 38 | + /* Write correct id back to DMA*/ |
| 39 | + u32p_replace_bits(&buf1, id, |
| 40 | + MT_DMA_CTL_TOKEN); |
| 41 | + WRITE_ONCE(desc->buf1, cpu_to_le32(buf1)); |
| 42 | + break; |
| 43 | + } |
| 44 | + } |
| 45 | |
| 46 | + spin_unlock_bh(&dev->rx_token_lock); |
| 47 | + if (!find) |
| 48 | + return NULL; |
| 49 | + } |
| 50 | + |
| 51 | + r = mt76_rx_token_release(dev, token); |
| 52 | if (!r) |
| 53 | return NULL; |
| 54 | |
| 55 | @@ -902,7 +925,7 @@ mt76_dma_rx_process(struct mt76_dev *dev, struct mt76_queue *q, int budget) |
| 56 | if (!data) |
| 57 | break; |
| 58 | |
| 59 | - if (drop) |
| 60 | + if (drop || (len == 0)) |
| 61 | goto free_frag; |
| 62 | |
| 63 | if (q->rx_head) |
| 64 | -- |
| 65 | 2.39.2 |
| 66 | |