blob: 9c22c3c38d71a8e66b7e98f9969a4e52004016b6 [file] [log] [blame]
developer1f55fcf2024-10-17 14:52:33 +08001From ffca50bc2c2afe6303705b84f242a44e6a6cd459 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
developer1f55fcf2024-10-17 14:52:33 +08004Subject: [PATCH 062/193] mtk: mt76: mt7996: support backaward compatiable
developer66e89bc2024-04-23 14:50:01 +08005
6revert upstream wed trigger mode to polling mode
7
developer66e89bc2024-04-23 14:50:01 +08008[Description]
9Change the SW token size from 1024 to 15360 according to HW capability.
10
11[Release-log]
12N/A
13
developerd0c89452024-10-11 16:53:27 +080014Change-Id: Ifd40df7094052b13e26f42f09908f6404917ad8e
15Change-Id: I337f41aa80758d00b4c8e7a5cc4d6faeb6f0a4a2
developer66e89bc2024-04-23 14:50:01 +080016Signed-off-by: Peter Chiu <chui-hao.chiu@mediatek.com>
developer05f3b2b2024-08-19 19:17:34 +080017Signed-off-by: mtk27745 <rex.lu@mediatek.com>
developer66e89bc2024-04-23 14:50:01 +080018Signed-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
developer1f55fcf2024-10-17 14:52:33 +080030index 8bf3755..e7901e5 100644
developer66e89bc2024-04-23 14:50:01 +080031--- a/mt76.h
32+++ b/mt76.h
developerd0c89452024-10-11 16:53:27 +080033@@ -54,6 +54,8 @@
developer66e89bc2024-04-23 14:50:01 +080034
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
developer1f55fcf2024-10-17 14:52:33 +080043index d58177e..0c5fa02 100644
developer66e89bc2024-04-23 14:50:01 +080044--- a/mt7996/mac.c
45+++ b/mt7996/mac.c
developerd0c89452024-10-11 16:53:27 +080046@@ -1786,7 +1786,7 @@ mt7996_mac_restart(struct mt7996_dev *dev)
developer66e89bc2024-04-23 14:50:01 +080047 }
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 }
developerd0c89452024-10-11 16:53:27 +080055@@ -2018,6 +2018,7 @@ void mt7996_mac_reset_work(struct work_struct *work)
developer66e89bc2024-04-23 14:50:01 +080056
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
developer1f55fcf2024-10-17 14:52:33 +080064index 6c27360..d671734 100644
developer66e89bc2024-04-23 14:50:01 +080065--- a/mt7996/mcu.c
66+++ b/mt7996/mcu.c
developerd0c89452024-10-11 16:53:27 +080067@@ -3265,7 +3265,7 @@ static int mt7996_mcu_wa_red_config(struct mt7996_dev *dev)
developer66e89bc2024-04-23 14:50:01 +080068
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
developer1f55fcf2024-10-17 14:52:33 +080077index 55d83f1..ee9ba3f 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
developer1f55fcf2024-10-17 14:52:33 +0800128index 674f9de..1e17c29 100644
developer66e89bc2024-04-23 14:50:01 +0800129--- a/mt7996/mt7996.h
130+++ b/mt7996/mt7996.h
developerd0c89452024-10-11 16:53:27 +0800131@@ -76,6 +76,7 @@
developer66e89bc2024-04-23 14:50:01 +0800132 #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
developer1f55fcf2024-10-17 14:52:33 +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
developer1f55fcf2024-10-17 14:52:33 +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--
developerd0c89452024-10-11 16:53:27 +08002072.45.2
developer66e89bc2024-04-23 14:50:01 +0800208