developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 1 | From d19b337c221ed6c72d9733c3206bcd6f24b3a774 Mon Sep 17 00:00:00 2001 |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 2 | From: "sujuan.chen" <sujuan.chen@mediatek.com> |
| 3 | Date: Wed, 19 Jul 2023 10:55:09 +0800 |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 4 | Subject: [PATCH 068/199] mtk: mt76: find rx token by physical address |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 5 | |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 6 | The token id in RxDMAD may be incorrect when it is not the last frame in |
| 7 | WED HW. Lookup correct token id by physical address in sdp0. |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 8 | Add len == 0 check to drop garbage frames |
| 9 | |
| 10 | Signed-off-by: Peter Chiu <chui-hao.chiu@mediatek.com> |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 11 | --- |
| 12 | dma.c | 27 +++++++++++++++++++++++++-- |
| 13 | 1 file changed, 25 insertions(+), 2 deletions(-) |
| 14 | |
| 15 | diff --git a/dma.c b/dma.c |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 16 | index e5be891c..1021b3e5 100644 |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 17 | --- 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 | -- |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 63 | 2.18.0 |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 64 | |