]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
wifi: mt76: mt7925: use irq_map for chip-specific interrupt handling
authorJavier Tia <floss@jetm.me>
Sat, 25 Apr 2026 19:49:58 +0000 (14:49 -0500)
committerFelix Fietkau <nbd@nbd.name>
Tue, 9 Jun 2026 10:15:21 +0000 (10:15 +0000)
The mac_reset and resume paths use the hardcoded MT_INT_RX_DONE_ALL
constant (bits 0-2) to re-enable RX interrupts. This is correct for
MT7925 (RX rings 0, 1, 2) but wrong for chips using different ring
indices.

Define a per-chip irq_map with the correct RX interrupt enable bits and
replace hardcoded MT_INT_RX_DONE_ALL with irq_map field reads in the
resume and mac_reset paths. Add the MT7927 irq_map with interrupt bits
matching its RX ring layout (rings 4, 6, 7), selected at probe time
based on PCI device ID.

This ensures the correct interrupt bits are enabled regardless of the
chip variant.

Tested-by: Marcin FM <marcin@lgic.pl>
Tested-by: Cristian-Florin Radoi <radoi.chris@gmail.com>
Tested-by: George Salukvadze <giosal90@gmail.com>
Tested-by: Evgeny Kapusta <3193631@gmail.com>
Tested-by: Samu Toljamo <samu.toljamo@gmail.com>
Tested-by: Ariel Rosenfeld <ariel.rosenfeld.750@gmail.com>
Tested-by: Chapuis Dario <chapuisdario4@gmail.com>
Tested-by: Thibaut François <tibo@humeurlibre.fr>
Tested-by: 张旭涵 <Loong.0x00@gmail.com>
Reviewed-by: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: Javier Tia <floss@jetm.me>
Link: https://patch.msgid.link/20260425195011.790265-9-sean.wang@kernel.org
Signed-off-by: Felix Fietkau <nbd@nbd.name>
drivers/net/wireless/mediatek/mt76/mt7925/pci.c
drivers/net/wireless/mediatek/mt76/mt7925/pci_mac.c
drivers/net/wireless/mediatek/mt76/mt792x_regs.h

index 76139a54878572a01785fd87ea5625916b753b92..7e0d0e247fa3e029cefad022b52a9f81971fdd35 100644 (file)
@@ -266,6 +266,18 @@ static int mt7925_dma_init(struct mt792x_dev *dev)
        return mt792x_dma_enable(dev);
 }
 
+static const struct mt792x_irq_map mt7927_irq_map = {
+       .host_irq_enable = MT_WFDMA0_HOST_INT_ENA,
+       .tx = {
+               .all_complete_mask = MT_INT_TX_DONE_ALL,
+               .mcu_complete_mask = MT_INT_TX_DONE_MCU,
+       },
+       .rx = {
+               .data_complete_mask = MT7927_RX_DONE_INT_ENA4,
+               .wm_complete_mask = MT7927_RX_DONE_INT_ENA6,
+               .wm2_complete_mask = MT7927_RX_DONE_INT_ENA7,
+       },
+};
 static int mt7925_pci_probe(struct pci_dev *pdev,
                            const struct pci_device_id *id)
 {
@@ -310,6 +322,7 @@ static int mt7925_pci_probe(struct pci_dev *pdev,
        struct mt76_bus_ops *bus_ops;
        struct mt792x_dev *dev;
        struct mt76_dev *mdev;
+       bool is_mt7927_hw;
        u8 features;
        int ret;
        u16 cmd;
@@ -358,7 +371,8 @@ static int mt7925_pci_probe(struct pci_dev *pdev,
        dev = container_of(mdev, struct mt792x_dev, mt76);
        dev->fw_features = features;
        dev->hif_ops = &mt7925_pcie_ops;
-       dev->irq_map = &irq_map;
+       is_mt7927_hw = (pdev->device == 0x6639 || pdev->device == 0x7927);
+       dev->irq_map = is_mt7927_hw ? &mt7927_irq_map : &irq_map;
        mt76_mmio_init(&dev->mt76, pcim_iomap_table(pdev)[0]);
        tasklet_init(&mdev->irq_tasklet, mt792x_irq_tasklet, (unsigned long)dev);
 
@@ -551,7 +565,10 @@ static int _mt7925_pci_resume(struct device *device, bool restore)
        mt76_wr(dev, MT_PCIE_MAC_INT_ENABLE, 0xff);
        mt76_connac_irq_enable(&dev->mt76,
                               dev->irq_map->tx.all_complete_mask |
-                              MT_INT_RX_DONE_ALL | MT_INT_MCU_CMD);
+                              dev->irq_map->rx.data_complete_mask |
+                              dev->irq_map->rx.wm_complete_mask |
+                              dev->irq_map->rx.wm2_complete_mask |
+                              MT_INT_MCU_CMD);
        mt76_set(dev, MT_MCU2HOST_SW_INT_ENA, MT_MCU_CMD_WAKE_RX_PCIE);
 
        /* put dma enabled */
index 3072850c27526d836df4c10456c4082b5cb51ca7..1626a368408280be06929d66aab2d2e66976b41e 100644 (file)
@@ -118,7 +118,10 @@ int mt7925e_mac_reset(struct mt792x_dev *dev)
 
        mt76_wr(dev, dev->irq_map->host_irq_enable,
                dev->irq_map->tx.all_complete_mask |
-               MT_INT_RX_DONE_ALL | MT_INT_MCU_CMD);
+               dev->irq_map->rx.data_complete_mask |
+               dev->irq_map->rx.wm_complete_mask |
+               dev->irq_map->rx.wm2_complete_mask |
+               MT_INT_MCU_CMD);
        mt76_wr(dev, MT_PCIE_MAC_INT_ENABLE, 0xff);
 
        err = mt792xe_mcu_fw_pmctrl(dev);
index d2a8b2b0df32cdaf770c8a8abfe8c7e8bfe01683..20d27ae89aca479360adf98b34eaa89ff9ecae51 100644 (file)
 #define HOST_RX_DONE_INT_ENA1          BIT(1)
 #define HOST_RX_DONE_INT_ENA2          BIT(2)
 #define HOST_RX_DONE_INT_ENA3          BIT(3)
+#define MT7927_RX_DONE_INT_ENA4                BIT(12)
+#define MT7927_RX_DONE_INT_ENA6                BIT(14)
+#define MT7927_RX_DONE_INT_ENA7                BIT(15)
 #define HOST_TX_DONE_INT_ENA0          BIT(4)
 #define HOST_TX_DONE_INT_ENA1          BIT(5)
 #define HOST_TX_DONE_INT_ENA2          BIT(6)