| From 8078f6868b60b6468958fd0990c5a697e1ac12df Mon Sep 17 00:00:00 2001 |
| From: mtk27745 <rex.lu@mediatek.com> |
| Date: Fri, 6 Oct 2023 20:59:42 +0800 |
| Subject: [PATCH 062/223] mtk: mt76: mt7996: support backaward compatiable |
| |
| revert upstream wed trigger mode to polling mode |
| |
| [Description] |
| Change the SW token size from 1024 to 15360 according to HW capability. |
| |
| [Release-log] |
| N/A |
| |
| Change-Id: Ifd40df7094052b13e26f42f09908f6404917ad8e |
| Change-Id: I337f41aa80758d00b4c8e7a5cc4d6faeb6f0a4a2 |
| Signed-off-by: Peter Chiu <chui-hao.chiu@mediatek.com> |
| Signed-off-by: mtk27745 <rex.lu@mediatek.com> |
| Signed-off-by: Rex Lu <rex.lu@mediatek.com> |
| --- |
| mt76.h | 2 ++ |
| mt7996/mac.c | 3 ++- |
| mt7996/mcu.c | 2 +- |
| mt7996/mmio.c | 12 +++++++----- |
| mt7996/mt7996.h | 1 + |
| mt7996/pci.c | 17 +++++++++-------- |
| wed.c | 4 ++-- |
| 7 files changed, 24 insertions(+), 17 deletions(-) |
| |
| diff --git a/mt76.h b/mt76.h |
| index 8bf37558..e7901e57 100644 |
| --- a/mt76.h |
| +++ b/mt76.h |
| @@ -54,6 +54,8 @@ |
| |
| #define MT76_TOKEN_FREE_THR 64 |
| |
| +#define MT76_WED_SW_TOKEN_SIZE 15360 |
| + |
| #define MT_QFLAG_WED_RING GENMASK(1, 0) |
| #define MT_QFLAG_WED_TYPE GENMASK(4, 2) |
| #define MT_QFLAG_WED BIT(5) |
| diff --git a/mt7996/mac.c b/mt7996/mac.c |
| index d58177ec..0c5fa02d 100644 |
| --- a/mt7996/mac.c |
| +++ b/mt7996/mac.c |
| @@ -1786,7 +1786,7 @@ mt7996_mac_restart(struct mt7996_dev *dev) |
| } |
| |
| mt76_wr(dev, MT_INT_MASK_CSR, wed_irq_mask); |
| - mtk_wed_device_start_hwrro(&dev->mt76.mmio.wed, wed_irq_mask, false); |
| + mtk_wed_device_start_hw_rro(&dev->mt76.mmio.wed, wed_irq_mask, false); |
| mt7996_irq_enable(dev, wed_irq_mask); |
| mt7996_irq_disable(dev, 0); |
| } |
| @@ -2018,6 +2018,7 @@ void mt7996_mac_reset_work(struct work_struct *work) |
| |
| mtk_wed_device_start_hw_rro(&dev->mt76.mmio.wed, wed_irq_mask, |
| true); |
| + |
| mt7996_irq_enable(dev, wed_irq_mask); |
| mt7996_irq_disable(dev, 0); |
| } |
| diff --git a/mt7996/mcu.c b/mt7996/mcu.c |
| index 6b78357d..be273181 100644 |
| --- a/mt7996/mcu.c |
| +++ b/mt7996/mcu.c |
| @@ -3265,7 +3265,7 @@ static int mt7996_mcu_wa_red_config(struct mt7996_dev *dev) |
| |
| if (!mtk_wed_device_active(&dev->mt76.mmio.wed)) |
| req.token_per_src[RED_TOKEN_SRC_CNT - 1] = |
| - cpu_to_le16(MT7996_TOKEN_SIZE - MT7996_HW_TOKEN_SIZE); |
| + cpu_to_le16(MT7996_SW_TOKEN_SIZE); |
| |
| return mt76_mcu_send_msg(&dev->mt76, MCU_WA_PARAM_CMD(SET), |
| &req, sizeof(req), false); |
| diff --git a/mt7996/mmio.c b/mt7996/mmio.c |
| index 55d83f1d..ee9ba3ff 100644 |
| --- a/mt7996/mmio.c |
| +++ b/mt7996/mmio.c |
| @@ -14,7 +14,7 @@ |
| #include "../trace.h" |
| #include "../dma.h" |
| |
| -static bool wed_enable; |
| +static bool wed_enable = true; |
| module_param(wed_enable, bool, 0644); |
| |
| static const struct __base mt7996_reg_base[] = { |
| @@ -347,7 +347,7 @@ int mt7996_mmio_wed_init(struct mt7996_dev *dev, void *pdev_ptr, |
| } |
| |
| wed->wlan.wpdma_rx_glo = wed->wlan.phy_base + hif1_ofs + MT_WFDMA0_GLO_CFG; |
| - wed->wlan.wpdma_rx = wed->wlan.phy_base + hif1_ofs + |
| + wed->wlan.wpdma_rx[0] = wed->wlan.phy_base + hif1_ofs + |
| MT_RXQ_RING_BASE(MT7996_RXQ_BAND0) + |
| MT7996_RXQ_BAND0 * MT_RING_SIZE; |
| |
| @@ -362,7 +362,7 @@ int mt7996_mmio_wed_init(struct mt7996_dev *dev, void *pdev_ptr, |
| |
| wed->wlan.wpdma_rx_glo = wed->wlan.phy_base + MT_WFDMA0_GLO_CFG; |
| |
| - wed->wlan.wpdma_rx = wed->wlan.phy_base + |
| + wed->wlan.wpdma_rx[0] = wed->wlan.phy_base + |
| MT_RXQ_RING_BASE(MT7996_RXQ_BAND0) + |
| MT7996_RXQ_BAND0 * MT_RING_SIZE; |
| |
| @@ -404,8 +404,8 @@ int mt7996_mmio_wed_init(struct mt7996_dev *dev, void *pdev_ptr, |
| dev->mt76.rx_token_size = MT7996_TOKEN_SIZE + wed->wlan.rx_npkt; |
| } |
| |
| - wed->wlan.nbuf = MT7996_HW_TOKEN_SIZE; |
| - wed->wlan.token_start = MT7996_TOKEN_SIZE - wed->wlan.nbuf; |
| + wed->wlan.nbuf = MT7996_TOKEN_SIZE; |
| + wed->wlan.token_start = 0; |
| |
| wed->wlan.amsdu_max_subframes = 8; |
| wed->wlan.amsdu_max_len = 1536; |
| @@ -426,6 +426,8 @@ int mt7996_mmio_wed_init(struct mt7996_dev *dev, void *pdev_ptr, |
| *irq = wed->irq; |
| dev->mt76.dma_dev = wed->dev; |
| |
| + dev->mt76.token_size = MT7996_SW_TOKEN_SIZE; |
| + |
| return 1; |
| #else |
| return 0; |
| diff --git a/mt7996/mt7996.h b/mt7996/mt7996.h |
| index 674f9de1..1e17c291 100644 |
| --- a/mt7996/mt7996.h |
| +++ b/mt7996/mt7996.h |
| @@ -76,6 +76,7 @@ |
| #define MT7996_EEPROM_BLOCK_SIZE 16 |
| #define MT7996_TOKEN_SIZE 16384 |
| #define MT7996_HW_TOKEN_SIZE 8192 |
| +#define MT7996_SW_TOKEN_SIZE 15360 |
| |
| #define MT7996_CFEND_RATE_DEFAULT 0x49 /* OFDM 24M */ |
| #define MT7996_CFEND_RATE_11B 0x03 /* 11B LP, 11M */ |
| diff --git a/mt7996/pci.c b/mt7996/pci.c |
| index 05830c01..4e957771 100644 |
| --- a/mt7996/pci.c |
| +++ b/mt7996/pci.c |
| @@ -171,7 +171,7 @@ static int mt7996_pci_probe(struct pci_dev *pdev, |
| |
| ret = mt7996_mmio_wed_init(dev, hif2_dev, true, &hif2_irq); |
| if (ret < 0) |
| - goto free_hif2_wed_irq_vector; |
| + goto free_wed_or_irq_vector; |
| |
| if (!ret) { |
| ret = pci_alloc_irq_vectors(hif2_dev, 1, 1, |
| @@ -180,14 +180,15 @@ static int mt7996_pci_probe(struct pci_dev *pdev, |
| goto free_hif2; |
| |
| dev->hif2->irq = hif2_dev->irq; |
| - hif2_irq = dev->hif2->irq; |
| + } else { |
| + dev->hif2->irq = irq; |
| } |
| |
| - ret = devm_request_irq(mdev->dev, hif2_irq, mt7996_irq_handler, |
| - IRQF_SHARED, KBUILD_MODNAME "-hif", |
| - dev); |
| + ret = devm_request_irq(mdev->dev, dev->hif2->irq, |
| + mt7996_irq_handler, IRQF_SHARED, |
| + KBUILD_MODNAME "-hif", dev); |
| if (ret) |
| - goto free_hif2_wed_irq_vector; |
| + goto free_hif2_irq_vector; |
| |
| mt76_wr(dev, MT_INT1_MASK_CSR, 0); |
| /* master switch of PCIe tnterrupt enable */ |
| @@ -202,8 +203,8 @@ static int mt7996_pci_probe(struct pci_dev *pdev, |
| |
| free_hif2_irq: |
| if (dev->hif2) |
| - devm_free_irq(mdev->dev, hif2_irq, dev); |
| -free_hif2_wed_irq_vector: |
| + devm_free_irq(mdev->dev, dev->hif2->irq, dev); |
| +free_hif2_irq_vector: |
| if (dev->hif2) { |
| if (mtk_wed_device_active(&dev->mt76.mmio.wed_hif2)) |
| mtk_wed_device_detach(&dev->mt76.mmio.wed_hif2); |
| diff --git a/wed.c b/wed.c |
| index 61a6badf..634c95cf 100644 |
| --- a/wed.c |
| +++ b/wed.c |
| @@ -120,7 +120,7 @@ int mt76_wed_offload_enable(struct mtk_wed_device *wed) |
| struct mt76_dev *dev = container_of(wed, struct mt76_dev, mmio.wed); |
| |
| spin_lock_bh(&dev->token_lock); |
| - dev->token_size = wed->wlan.token_start; |
| + dev->token_size = MT76_WED_SW_TOKEN_SIZE; |
| spin_unlock_bh(&dev->token_lock); |
| |
| return !wait_event_timeout(dev->tx_wait, !dev->wed_token_count, HZ); |
| @@ -204,7 +204,7 @@ void mt76_wed_offload_disable(struct mtk_wed_device *wed) |
| struct mt76_dev *dev = container_of(wed, struct mt76_dev, mmio.wed); |
| |
| spin_lock_bh(&dev->token_lock); |
| - dev->token_size = dev->drv->token_size; |
| + dev->token_size = MT76_WED_SW_TOKEN_SIZE; |
| spin_unlock_bh(&dev->token_lock); |
| } |
| EXPORT_SYMBOL_GPL(mt76_wed_offload_disable); |
| -- |
| 2.45.2 |
| |