developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame^] | 1 | From 8078f6868b60b6468958fd0990c5a697e1ac12df Mon Sep 17 00:00:00 2001 |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 2 | From: mtk27745 <rex.lu@mediatek.com> |
| 3 | Date: Fri, 6 Oct 2023 20:59:42 +0800 |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame^] | 4 | Subject: [PATCH 062/223] mtk: mt76: mt7996: support backaward compatiable |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 5 | |
| 6 | revert upstream wed trigger mode to polling mode |
| 7 | |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 8 | [Description] |
| 9 | Change the SW token size from 1024 to 15360 according to HW capability. |
| 10 | |
| 11 | [Release-log] |
| 12 | N/A |
| 13 | |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame^] | 14 | Change-Id: Ifd40df7094052b13e26f42f09908f6404917ad8e |
| 15 | Change-Id: I337f41aa80758d00b4c8e7a5cc4d6faeb6f0a4a2 |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 16 | Signed-off-by: Peter Chiu <chui-hao.chiu@mediatek.com> |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 17 | Signed-off-by: mtk27745 <rex.lu@mediatek.com> |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 18 | Signed-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 | |
| 29 | diff --git a/mt76.h b/mt76.h |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame^] | 30 | index 8bf37558..e7901e57 100644 |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 31 | --- a/mt76.h |
| 32 | +++ b/mt76.h |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame^] | 33 | @@ -54,6 +54,8 @@ |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 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) |
| 42 | diff --git a/mt7996/mac.c b/mt7996/mac.c |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame^] | 43 | index d58177ec..0c5fa02d 100644 |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 44 | --- a/mt7996/mac.c |
| 45 | +++ b/mt7996/mac.c |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame^] | 46 | @@ -1786,7 +1786,7 @@ mt7996_mac_restart(struct mt7996_dev *dev) |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 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 | } |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame^] | 55 | @@ -2018,6 +2018,7 @@ void mt7996_mac_reset_work(struct work_struct *work) |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 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 | } |
| 63 | diff --git a/mt7996/mcu.c b/mt7996/mcu.c |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame^] | 64 | index 6b78357d..be273181 100644 |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 65 | --- a/mt7996/mcu.c |
| 66 | +++ b/mt7996/mcu.c |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame^] | 67 | @@ -3265,7 +3265,7 @@ static int mt7996_mcu_wa_red_config(struct mt7996_dev *dev) |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 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); |
| 76 | diff --git a/mt7996/mmio.c b/mt7996/mmio.c |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame^] | 77 | index 55d83f1d..ee9ba3ff 100644 |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 78 | --- 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; |
| 127 | diff --git a/mt7996/mt7996.h b/mt7996/mt7996.h |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame^] | 128 | index 674f9de1..1e17c291 100644 |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 129 | --- a/mt7996/mt7996.h |
| 130 | +++ b/mt7996/mt7996.h |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame^] | 131 | @@ -76,6 +76,7 @@ |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 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 */ |
| 139 | diff --git a/mt7996/pci.c b/mt7996/pci.c |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 140 | index 05830c01..4e957771 100644 |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 141 | --- 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); |
| 184 | diff --git a/wed.c b/wed.c |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 185 | index 61a6badf..634c95cf 100644 |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 186 | --- 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 | -- |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame^] | 207 | 2.45.2 |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 208 | |