blob: 8890a596373eb0bd9582051f86fe9d0d8636f3d0 [file] [log] [blame]
developer9237f442024-06-14 17:13:04 +08001From 099ff0e39f8f83d3d6395db232da68448392b67b Mon Sep 17 00:00:00 2001
developer66e89bc2024-04-23 14:50:01 +08002From: mtk27745 <rex.lu@mediatek.com>
3Date: Fri, 6 Oct 2023 20:59:42 +0800
developer9237f442024-06-14 17:13:04 +08004Subject: [PATCH 069/116] mtk: wifi: mt76: mt7996: support backaward
developer66e89bc2024-04-23 14:50:01 +08005 compatiable
6
7revert upstream wed trigger mode to polling mode
8
developer66e89bc2024-04-23 14:50:01 +08009Signed-off-by: mtk27745 <rex.lu@mediatek.com>
developer66e89bc2024-04-23 14:50:01 +080010
11[Description]
12Change the SW token size from 1024 to 15360 according to HW capability.
13
14[Release-log]
15N/A
16
developer66e89bc2024-04-23 14:50:01 +080017Signed-off-by: Peter Chiu <chui-hao.chiu@mediatek.com>
18Signed-off-by: Rex Lu <rex.lu@mediatek.com>
19---
20 mt76.h | 2 ++
21 mt7996/mac.c | 3 ++-
22 mt7996/mcu.c | 2 +-
23 mt7996/mmio.c | 12 +++++++-----
24 mt7996/mt7996.h | 1 +
25 mt7996/pci.c | 17 +++++++++--------
26 wed.c | 4 ++--
27 7 files changed, 24 insertions(+), 17 deletions(-)
28
29diff --git a/mt76.h b/mt76.h
developer9237f442024-06-14 17:13:04 +080030index 9f1f7fc..677f68f 100644
developer66e89bc2024-04-23 14:50:01 +080031--- a/mt76.h
32+++ b/mt76.h
33@@ -53,6 +53,8 @@
34
35 #define MT76_TOKEN_FREE_THR 64
36
37+#define MT76_WED_SW_TOKEN_SIZE 15360
38+
39 #define MT_QFLAG_WED_RING GENMASK(1, 0)
40 #define MT_QFLAG_WED_TYPE GENMASK(4, 2)
41 #define MT_QFLAG_WED BIT(5)
42diff --git a/mt7996/mac.c b/mt7996/mac.c
developer9237f442024-06-14 17:13:04 +080043index 2ad9f48..8396e6d 100644
developer66e89bc2024-04-23 14:50:01 +080044--- a/mt7996/mac.c
45+++ b/mt7996/mac.c
46@@ -1777,7 +1777,7 @@ mt7996_mac_restart(struct mt7996_dev *dev)
47 }
48
49 mt76_wr(dev, MT_INT_MASK_CSR, wed_irq_mask);
50- mtk_wed_device_start_hwrro(&dev->mt76.mmio.wed, wed_irq_mask, false);
51+ mtk_wed_device_start_hw_rro(&dev->mt76.mmio.wed, wed_irq_mask, false);
52 mt7996_irq_enable(dev, wed_irq_mask);
53 mt7996_irq_disable(dev, 0);
54 }
55@@ -2009,6 +2009,7 @@ void mt7996_mac_reset_work(struct work_struct *work)
56
57 mtk_wed_device_start_hw_rro(&dev->mt76.mmio.wed, wed_irq_mask,
58 true);
59+
60 mt7996_irq_enable(dev, wed_irq_mask);
61 mt7996_irq_disable(dev, 0);
62 }
63diff --git a/mt7996/mcu.c b/mt7996/mcu.c
developer9237f442024-06-14 17:13:04 +080064index ef30d8e..6366cf0 100644
developer66e89bc2024-04-23 14:50:01 +080065--- a/mt7996/mcu.c
66+++ b/mt7996/mcu.c
67@@ -3254,7 +3254,7 @@ static int mt7996_mcu_wa_red_config(struct mt7996_dev *dev)
68
69 if (!mtk_wed_device_active(&dev->mt76.mmio.wed))
70 req.token_per_src[RED_TOKEN_SRC_CNT - 1] =
71- cpu_to_le16(MT7996_TOKEN_SIZE - MT7996_HW_TOKEN_SIZE);
72+ cpu_to_le16(MT7996_SW_TOKEN_SIZE);
73
74 return mt76_mcu_send_msg(&dev->mt76, MCU_WA_PARAM_CMD(SET),
75 &req, sizeof(req), false);
76diff --git a/mt7996/mmio.c b/mt7996/mmio.c
developer9237f442024-06-14 17:13:04 +080077index d29579f..1c2cea2 100644
developer66e89bc2024-04-23 14:50:01 +080078--- a/mt7996/mmio.c
79+++ b/mt7996/mmio.c
80@@ -14,7 +14,7 @@
81 #include "../trace.h"
82 #include "../dma.h"
83
84-static bool wed_enable;
85+static bool wed_enable = true;
86 module_param(wed_enable, bool, 0644);
87
88 static const struct __base mt7996_reg_base[] = {
89@@ -347,7 +347,7 @@ int mt7996_mmio_wed_init(struct mt7996_dev *dev, void *pdev_ptr,
90 }
91
92 wed->wlan.wpdma_rx_glo = wed->wlan.phy_base + hif1_ofs + MT_WFDMA0_GLO_CFG;
93- wed->wlan.wpdma_rx = wed->wlan.phy_base + hif1_ofs +
94+ wed->wlan.wpdma_rx[0] = wed->wlan.phy_base + hif1_ofs +
95 MT_RXQ_RING_BASE(MT7996_RXQ_BAND0) +
96 MT7996_RXQ_BAND0 * MT_RING_SIZE;
97
98@@ -362,7 +362,7 @@ int mt7996_mmio_wed_init(struct mt7996_dev *dev, void *pdev_ptr,
99
100 wed->wlan.wpdma_rx_glo = wed->wlan.phy_base + MT_WFDMA0_GLO_CFG;
101
102- wed->wlan.wpdma_rx = wed->wlan.phy_base +
103+ wed->wlan.wpdma_rx[0] = wed->wlan.phy_base +
104 MT_RXQ_RING_BASE(MT7996_RXQ_BAND0) +
105 MT7996_RXQ_BAND0 * MT_RING_SIZE;
106
107@@ -404,8 +404,8 @@ int mt7996_mmio_wed_init(struct mt7996_dev *dev, void *pdev_ptr,
108 dev->mt76.rx_token_size = MT7996_TOKEN_SIZE + wed->wlan.rx_npkt;
109 }
110
111- wed->wlan.nbuf = MT7996_HW_TOKEN_SIZE;
112- wed->wlan.token_start = MT7996_TOKEN_SIZE - wed->wlan.nbuf;
113+ wed->wlan.nbuf = MT7996_TOKEN_SIZE;
114+ wed->wlan.token_start = 0;
115
116 wed->wlan.amsdu_max_subframes = 8;
117 wed->wlan.amsdu_max_len = 1536;
118@@ -426,6 +426,8 @@ int mt7996_mmio_wed_init(struct mt7996_dev *dev, void *pdev_ptr,
119 *irq = wed->irq;
120 dev->mt76.dma_dev = wed->dev;
121
122+ dev->mt76.token_size = MT7996_SW_TOKEN_SIZE;
123+
124 return 1;
125 #else
126 return 0;
127diff --git a/mt7996/mt7996.h b/mt7996/mt7996.h
developer9237f442024-06-14 17:13:04 +0800128index 4090fad..7011f66 100644
developer66e89bc2024-04-23 14:50:01 +0800129--- a/mt7996/mt7996.h
130+++ b/mt7996/mt7996.h
131@@ -73,6 +73,7 @@
132 #define MT7996_EEPROM_BLOCK_SIZE 16
133 #define MT7996_TOKEN_SIZE 16384
134 #define MT7996_HW_TOKEN_SIZE 8192
135+#define MT7996_SW_TOKEN_SIZE 15360
136
137 #define MT7996_CFEND_RATE_DEFAULT 0x49 /* OFDM 24M */
138 #define MT7996_CFEND_RATE_11B 0x03 /* 11B LP, 11M */
139diff --git a/mt7996/pci.c b/mt7996/pci.c
developer9237f442024-06-14 17:13:04 +0800140index 05830c0..4e95777 100644
developer66e89bc2024-04-23 14:50:01 +0800141--- a/mt7996/pci.c
142+++ b/mt7996/pci.c
143@@ -171,7 +171,7 @@ static int mt7996_pci_probe(struct pci_dev *pdev,
144
145 ret = mt7996_mmio_wed_init(dev, hif2_dev, true, &hif2_irq);
146 if (ret < 0)
147- goto free_hif2_wed_irq_vector;
148+ goto free_wed_or_irq_vector;
149
150 if (!ret) {
151 ret = pci_alloc_irq_vectors(hif2_dev, 1, 1,
152@@ -180,14 +180,15 @@ static int mt7996_pci_probe(struct pci_dev *pdev,
153 goto free_hif2;
154
155 dev->hif2->irq = hif2_dev->irq;
156- hif2_irq = dev->hif2->irq;
157+ } else {
158+ dev->hif2->irq = irq;
159 }
160
161- ret = devm_request_irq(mdev->dev, hif2_irq, mt7996_irq_handler,
162- IRQF_SHARED, KBUILD_MODNAME "-hif",
163- dev);
164+ ret = devm_request_irq(mdev->dev, dev->hif2->irq,
165+ mt7996_irq_handler, IRQF_SHARED,
166+ KBUILD_MODNAME "-hif", dev);
167 if (ret)
168- goto free_hif2_wed_irq_vector;
169+ goto free_hif2_irq_vector;
170
171 mt76_wr(dev, MT_INT1_MASK_CSR, 0);
172 /* master switch of PCIe tnterrupt enable */
173@@ -202,8 +203,8 @@ static int mt7996_pci_probe(struct pci_dev *pdev,
174
175 free_hif2_irq:
176 if (dev->hif2)
177- devm_free_irq(mdev->dev, hif2_irq, dev);
178-free_hif2_wed_irq_vector:
179+ devm_free_irq(mdev->dev, dev->hif2->irq, dev);
180+free_hif2_irq_vector:
181 if (dev->hif2) {
182 if (mtk_wed_device_active(&dev->mt76.mmio.wed_hif2))
183 mtk_wed_device_detach(&dev->mt76.mmio.wed_hif2);
184diff --git a/wed.c b/wed.c
developer9237f442024-06-14 17:13:04 +0800185index 61a6bad..634c95c 100644
developer66e89bc2024-04-23 14:50:01 +0800186--- a/wed.c
187+++ b/wed.c
188@@ -120,7 +120,7 @@ int mt76_wed_offload_enable(struct mtk_wed_device *wed)
189 struct mt76_dev *dev = container_of(wed, struct mt76_dev, mmio.wed);
190
191 spin_lock_bh(&dev->token_lock);
192- dev->token_size = wed->wlan.token_start;
193+ dev->token_size = MT76_WED_SW_TOKEN_SIZE;
194 spin_unlock_bh(&dev->token_lock);
195
196 return !wait_event_timeout(dev->tx_wait, !dev->wed_token_count, HZ);
197@@ -204,7 +204,7 @@ void mt76_wed_offload_disable(struct mtk_wed_device *wed)
198 struct mt76_dev *dev = container_of(wed, struct mt76_dev, mmio.wed);
199
200 spin_lock_bh(&dev->token_lock);
201- dev->token_size = dev->drv->token_size;
202+ dev->token_size = MT76_WED_SW_TOKEN_SIZE;
203 spin_unlock_bh(&dev->token_lock);
204 }
205 EXPORT_SYMBOL_GPL(mt76_wed_offload_disable);
206--
developer9237f442024-06-14 17:13:04 +08002072.18.0
developer66e89bc2024-04-23 14:50:01 +0800208