blob: e81206a103c1a6c7b1c18b27ee8f55973e8ba4a3 [file] [log] [blame]
developerfc0da102023-09-12 10:11:25 +08001From 182e4031ab7bdd94ac4791ea183a17cb3f1d3e0c Mon Sep 17 00:00:00 2001
2From: "sujuan.chen" <sujuan.chen@mediatek.com>
3Date: Mon, 11 Sep 2023 17:57:32 +0800
4Subject: [PATCH 1/2] mt76: wifi: mt7915: wed: setting wed hw tx token to 8192
5
6Signed-off-by: sujuan.chen <sujuan.chen@mediatek.com>
7---
8 mt7915/mmio.c | 8 ++++----
9 mt7915/mt7915.h | 4 ++--
10 tx.c | 26 ++++++++------------------
11 3 files changed, 14 insertions(+), 24 deletions(-)
12
13diff --git a/mt7915/mmio.c b/mt7915/mmio.c
14index aa5c5dd6..b6779474 100644
15--- a/mt7915/mmio.c
16+++ b/mt7915/mmio.c
17@@ -593,7 +593,7 @@ static int mt7915_mmio_wed_offload_enable(struct mtk_wed_device *wed)
18 dev = container_of(wed, struct mt7915_dev, mt76.mmio.wed);
19
20 spin_lock_bh(&dev->mt76.token_lock);
21- dev->mt76.token_size = wed->wlan.token_start;
22+ dev->mt76.token_size = MT7915_TOKEN_SIZE - MT7915_HW_TOKEN_SIZE;
23 spin_unlock_bh(&dev->mt76.token_lock);
24
25 return !wait_event_timeout(dev->mt76.tx_wait,
26@@ -607,7 +607,7 @@ static void mt7915_mmio_wed_offload_disable(struct mtk_wed_device *wed)
27 dev = container_of(wed, struct mt7915_dev, mt76.mmio.wed);
28
29 spin_lock_bh(&dev->mt76.token_lock);
30- dev->mt76.token_size = wed->wlan.token_start;//MT7915_TOKEN_SIZE
31+ dev->mt76.token_size = MT7915_TOKEN_SIZE - MT7915_HW_TOKEN_SIZE;
32 spin_unlock_bh(&dev->mt76.token_lock);
33 }
34
35@@ -841,7 +841,7 @@ int mt7915_mmio_wed_init(struct mt7915_dev *dev, void *pdev_ptr,
36 wed->wlan.tx_tbit[0] = is_mt7915(&dev->mt76) ? 4 : 30;
37 wed->wlan.tx_tbit[1] = is_mt7915(&dev->mt76) ? 5 : 31;
38 wed->wlan.txfree_tbit = is_mt798x(&dev->mt76) ? 2 : 1;
39- wed->wlan.token_start = MT7915_TOKEN_SIZE - wed->wlan.nbuf;
40+ wed->wlan.token_start = 0;
41 wed->wlan.wcid_512 = !is_mt7915(&dev->mt76);
42
43 wed->wlan.rx_nbuf = 65536;
44@@ -874,7 +874,7 @@ int mt7915_mmio_wed_init(struct mt7915_dev *dev, void *pdev_ptr,
45
46 *irq = wed->irq;
47 dev->mt76.dma_dev = wed->dev;
48- dev->mt76.token_size = wed->wlan.token_start;
49+ dev->mt76.token_size = MT7915_TOKEN_SIZE - MT7915_HW_TOKEN_SIZE;
50
51 ret = dma_set_mask(wed->dev, DMA_BIT_MASK(32));
52 if (ret)
53diff --git a/mt7915/mt7915.h b/mt7915/mt7915.h
54index e8f7ca58..d3054be0 100644
55--- a/mt7915/mt7915.h
56+++ b/mt7915/mt7915.h
57@@ -62,8 +62,8 @@
58 #define MT7916_EEPROM_SIZE 4096
59
60 #define MT7915_EEPROM_BLOCK_SIZE 16
61-#define MT7915_HW_TOKEN_SIZE 7168
62-#define MT7915_TOKEN_SIZE 8192
63+#define MT7915_HW_TOKEN_SIZE 8192
64+#define MT7915_TOKEN_SIZE 9216
65 #define MT7915_RX_TOKEN_SIZE 4096
66
67 #define MT7915_CFEND_RATE_DEFAULT 0x49 /* OFDM 24M */
68diff --git a/tx.c b/tx.c
69index 2594a625..c88fb290 100644
70--- a/tx.c
71+++ b/tx.c
72@@ -750,20 +750,18 @@ EXPORT_SYMBOL_GPL(__mt76_set_tx_blocked);
73
74 int mt76_token_consume(struct mt76_dev *dev, struct mt76_txwi_cache **ptxwi)
75 {
76- int token;
77+ int token, start = 0;
78+
79+ if (mtk_wed_device_active(&dev->mmio.wed))
80+ start = dev->mmio.wed.wlan.nbuf;
81
82 spin_lock_bh(&dev->token_lock);
83
84- token = idr_alloc(&dev->token, *ptxwi, 0, dev->token_size, GFP_ATOMIC);
85- if (token >= 0)
86+ token = idr_alloc(&dev->token, *ptxwi, start, start + dev->token_size,
87+ GFP_ATOMIC);
88+ if (token >= start)
89 dev->token_count++;
90
91-#ifdef CONFIG_NET_MEDIATEK_SOC_WED
92- if (mtk_wed_device_active(&dev->mmio.wed) &&
93- token >= dev->mmio.wed.wlan.token_start)
94- dev->wed_token_count++;
95-#endif
96-
97 if (dev->token_count >= dev->token_size - MT76_TOKEN_FREE_THR)
98 __mt76_set_tx_blocked(dev, true);
99
100@@ -799,17 +797,9 @@ mt76_token_release(struct mt76_dev *dev, int token, bool *wake)
101 spin_lock_bh(&dev->token_lock);
102
103 txwi = idr_remove(&dev->token, token);
104- if (txwi) {
105+ if (txwi)
106 dev->token_count--;
107
108-#ifdef CONFIG_NET_MEDIATEK_SOC_WED
109- if (mtk_wed_device_active(&dev->mmio.wed) &&
110- token >= dev->mmio.wed.wlan.token_start &&
111- --dev->wed_token_count == 0)
112- wake_up(&dev->tx_wait);
113-#endif
114- }
115-
116 if (dev->token_count < dev->token_size - MT76_TOKEN_FREE_THR &&
117 dev->phy.q_tx[0]->blocked)
118 *wake = true;
119--
1202.18.0
121