developer | 1f55fcf | 2024-10-17 14:52:33 +0800 | [diff] [blame^] | 1 | From 0fce899e41f4a9056720548ab96a567a193a991b 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 | 1f55fcf | 2024-10-17 14:52:33 +0800 | [diff] [blame^] | 4 | Subject: [PATCH 056/193] 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 | |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame] | 10 | Change-Id: I4cd90294ad24990826075e92a710cc4e301dcbb7 |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 11 | Signed-off-by: Peter Chiu <chui-hao.chiu@mediatek.com> |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 12 | --- |
| 13 | dma.c | 27 +++++++++++++++++++++++++-- |
| 14 | 1 file changed, 25 insertions(+), 2 deletions(-) |
| 15 | |
| 16 | diff --git a/dma.c b/dma.c |
developer | 1f55fcf | 2024-10-17 14:52:33 +0800 | [diff] [blame^] | 17 | index e5be891..1021b3e 100644 |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 18 | --- a/dma.c |
| 19 | +++ b/dma.c |
| 20 | @@ -446,9 +446,32 @@ mt76_dma_get_buf(struct mt76_dev *dev, struct mt76_queue *q, int idx, |
| 21 | mt76_dma_should_drop_buf(drop, ctrl, buf1, desc_info); |
| 22 | |
| 23 | if (mt76_queue_is_wed_rx(q)) { |
| 24 | + u32 id, find = 0; |
| 25 | u32 token = FIELD_GET(MT_DMA_CTL_TOKEN, buf1); |
| 26 | - struct mt76_rxwi_cache *r = mt76_rx_token_release(dev, token); |
| 27 | + struct mt76_rxwi_cache *r; |
| 28 | + |
| 29 | + if (*more) { |
| 30 | + spin_lock_bh(&dev->rx_token_lock); |
| 31 | + |
| 32 | + idr_for_each_entry(&dev->rx_token, r, id) { |
| 33 | + if (r->dma_addr == le32_to_cpu(desc->buf0)) { |
| 34 | + find = 1; |
| 35 | + token = id; |
| 36 | + |
| 37 | + /* Write correct id back to DMA*/ |
| 38 | + u32p_replace_bits(&buf1, id, |
| 39 | + MT_DMA_CTL_TOKEN); |
| 40 | + WRITE_ONCE(desc->buf1, cpu_to_le32(buf1)); |
| 41 | + break; |
| 42 | + } |
| 43 | + } |
| 44 | |
| 45 | + spin_unlock_bh(&dev->rx_token_lock); |
| 46 | + if (!find) |
| 47 | + return NULL; |
| 48 | + } |
| 49 | + |
| 50 | + r = mt76_rx_token_release(dev, token); |
| 51 | if (!r) |
| 52 | return NULL; |
| 53 | |
| 54 | @@ -902,7 +925,7 @@ mt76_dma_rx_process(struct mt76_dev *dev, struct mt76_queue *q, int budget) |
| 55 | if (!data) |
| 56 | break; |
| 57 | |
| 58 | - if (drop) |
| 59 | + if (drop || (len == 0)) |
| 60 | goto free_frag; |
| 61 | |
| 62 | if (q->rx_head) |
| 63 | -- |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame] | 64 | 2.45.2 |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 65 | |