wifi: mt76: mt7915: complete wed reset support
authorLorenzo Bianconi <lorenzo@kernel.org>
Tue, 17 Jan 2023 14:02:56 +0000 (15:02 +0100)
committerFelix Fietkau <nbd@nbd.name>
Fri, 3 Feb 2023 13:47:48 +0000 (14:47 +0100)
Stop Wireless Ethernet Dispatcher during mt7915 reset procedure.

Tested-by: Daniel Golle <daniel@makrotopia.org>
Co-developed-by: Sujuan Chen <sujuan.chen@mediatek.com>
Signed-off-by: Sujuan Chen <sujuan.chen@mediatek.com>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
drivers/net/wireless/mediatek/mt76/mt7915/dma.c
drivers/net/wireless/mediatek/mt76/mt7915/mac.c

index a956e2a0be4f6c8fcde6819d9808edf14add41ab..abe17dac9996145b353474746786f830384c39d4 100644 (file)
@@ -573,9 +573,18 @@ static void mt7915_dma_wed_reset(struct mt7915_dev *dev)
                dev_err(dev->mt76.dev, "wed reset complete timeout\n");
 }
 
+static void
+mt7915_dma_reset_tx_queue(struct mt7915_dev *dev, struct mt76_queue *q)
+{
+       mt76_queue_reset(dev, q);
+       if (mtk_wed_device_active(&dev->mt76.mmio.wed))
+               mt76_dma_wed_setup(&dev->mt76, q, true);
+}
+
 int mt7915_dma_reset(struct mt7915_dev *dev, bool force)
 {
        struct mt76_phy *mphy_ext = dev->mt76.phys[MT_BAND1];
+       struct mtk_wed_device *wed = &dev->mt76.mmio.wed;
        int i;
 
        /* clean up hw queues */
@@ -595,29 +604,40 @@ int mt7915_dma_reset(struct mt7915_dev *dev, bool force)
        if (force)
                mt7915_wfsys_reset(dev);
 
+       if (mtk_wed_device_active(wed))
+               mtk_wed_device_dma_reset(wed);
+
        mt7915_dma_disable(dev, force);
        mt7915_dma_wed_reset(dev);
 
        /* reset hw queues */
        for (i = 0; i < __MT_TXQ_MAX; i++) {
-               mt76_queue_reset(dev, dev->mphy.q_tx[i]);
+               mt7915_dma_reset_tx_queue(dev, dev->mphy.q_tx[i]);
                if (mphy_ext)
-                       mt76_queue_reset(dev, mphy_ext->q_tx[i]);
+                       mt7915_dma_reset_tx_queue(dev, mphy_ext->q_tx[i]);
        }
 
        for (i = 0; i < __MT_MCUQ_MAX; i++)
                mt76_queue_reset(dev, dev->mt76.q_mcu[i]);
 
-       mt76_for_each_q_rx(&dev->mt76, i)
+       mt76_for_each_q_rx(&dev->mt76, i) {
+               if (dev->mt76.q_rx[i].flags == MT_WED_Q_TXFREE)
+                       continue;
+
                mt76_queue_reset(dev, &dev->mt76.q_rx[i]);
+       }
 
        mt76_tx_status_check(&dev->mt76, true);
 
-       mt7915_dma_enable(dev);
-
        mt76_for_each_q_rx(&dev->mt76, i)
                mt76_queue_rx_reset(dev, i);
 
+       if (mtk_wed_device_active(wed) && is_mt7915(&dev->mt76))
+               mt76_rmw(dev, MT_WFDMA0_EXT0_CFG, MT_WFDMA0_EXT0_RXWB_KEEP,
+                        MT_WFDMA0_EXT0_RXWB_KEEP);
+
+       mt7915_dma_enable(dev);
+
        return 0;
 }
 
index e98df603d3ec03a98f0a618a893866d68b2e4d9d..97ca55d283fb18d66a23c9422ee6f0344e1be0ac 100644 (file)
@@ -1578,6 +1578,12 @@ void mt7915_mac_reset_work(struct work_struct *work)
        if (!(READ_ONCE(dev->recovery.state) & MT_MCU_CMD_STOP_DMA))
                return;
 
+       if (mtk_wed_device_active(&dev->mt76.mmio.wed)) {
+               mtk_wed_device_stop(&dev->mt76.mmio.wed);
+               if (!is_mt7986(&dev->mt76))
+                       mt76_wr(dev, MT_INT_WED_MASK_CSR, 0);
+       }
+
        ieee80211_stop_queues(mt76_hw(dev));
        if (ext_phy)
                ieee80211_stop_queues(ext_phy->hw);