| From 6a2341ff1a75100d530982d0c021a133124174cc Mon Sep 17 00:00:00 2001 |
| From: Sujuan Chen <sujuan.chen@mediatek.com> |
| Date: Thu, 28 Jul 2022 11:16:15 +0800 |
| Subject: [PATCH 3/3] mt76 add ser spport when wed on |
| |
| Signed-off-by: Sujuan Chen <sujuan.chen@mediatek.com> |
| --- |
| dma.c | 26 ++++++++++++++++++-------- |
| dma.h | 2 +- |
| mt7915/dma.c | 26 +++++++++++++++++++++----- |
| mt7915/mac.c | 6 ++++++ |
| 4 files changed, 46 insertions(+), 14 deletions(-) |
| |
| diff --git a/dma.c b/dma.c |
| index 4d4d4046..9c821442 100644 |
| --- a/dma.c |
| +++ b/dma.c |
| @@ -624,14 +624,18 @@ mt76_dma_rx_fill(struct mt76_dev *dev, struct mt76_queue *q) |
| return frames; |
| } |
| |
| -static int |
| -mt76_dma_wed_setup(struct mt76_dev *dev, struct mt76_queue *q) |
| +int |
| +mt76_dma_wed_setup(struct mt76_dev *dev, struct mt76_queue *q, bool reset) |
| { |
| #ifdef CONFIG_NET_MEDIATEK_SOC_WED |
| struct mtk_wed_device *wed = &dev->mmio.wed; |
| int ret, type, ring; |
| - u8 flags = q->flags; |
| + u8 flags; |
| + |
| + if (!q || !q->ndesc) |
| + return -EINVAL; |
| |
| + flags = q->flags; |
| if (!mtk_wed_device_active(wed)) |
| q->flags &= ~MT_QFLAG_WED; |
| |
| @@ -643,7 +647,7 @@ mt76_dma_wed_setup(struct mt76_dev *dev, struct mt76_queue *q) |
| |
| switch (type) { |
| case MT76_WED_Q_TX: |
| - ret = mtk_wed_device_tx_ring_setup(wed, ring, q->regs); |
| + ret = mtk_wed_device_tx_ring_setup(wed, ring, q->regs, reset); |
| if (!ret) |
| q->wed_regs = wed->tx_ring[ring].reg_base; |
| break; |
| @@ -659,7 +663,7 @@ mt76_dma_wed_setup(struct mt76_dev *dev, struct mt76_queue *q) |
| q->wed_regs = wed->txfree_ring.reg_base; |
| break; |
| case MT76_WED_Q_RX: |
| - ret = mtk_wed_device_rx_ring_setup(wed, ring, q->regs); |
| + ret = mtk_wed_device_rx_ring_setup(wed, ring, q->regs, reset); |
| if (!ret) |
| q->wed_regs = wed->rx_ring[ring].reg_base; |
| break; |
| @@ -672,6 +676,7 @@ mt76_dma_wed_setup(struct mt76_dev *dev, struct mt76_queue *q) |
| return 0; |
| #endif |
| } |
| +EXPORT_SYMBOL_GPL(mt76_dma_wed_setup); |
| |
| static int |
| mt76_dma_alloc_queue(struct mt76_dev *dev, struct mt76_queue *q, |
| @@ -704,7 +709,7 @@ mt76_dma_alloc_queue(struct mt76_dev *dev, struct mt76_queue *q, |
| if (!q->entry) |
| return -ENOMEM; |
| |
| - ret = mt76_dma_wed_setup(dev, q); |
| + ret = mt76_dma_wed_setup(dev, q, false); |
| if (ret) |
| return ret; |
| |
| @@ -755,8 +760,13 @@ mt76_dma_rx_reset(struct mt76_dev *dev, enum mt76_rxq_id qid) |
| q->desc[i].ctrl = cpu_to_le32(MT_DMA_CTL_DMA_DONE); |
| |
| mt76_dma_rx_cleanup(dev, q); |
| - mt76_dma_sync_idx(dev, q); |
| - mt76_dma_rx_fill(dev, q); |
| + |
| + mt76_dma_wed_setup(dev, q, true); |
| + |
| + if (q->flags != MT_WED_Q_TXFREE) { |
| + mt76_dma_sync_idx(dev, q); |
| + mt76_dma_rx_fill(dev, q); |
| + } |
| |
| if (!q->rx_head) |
| return; |
| diff --git a/dma.h b/dma.h |
| index 90370d12..083cbca4 100644 |
| --- a/dma.h |
| +++ b/dma.h |
| @@ -58,5 +58,5 @@ enum mt76_mcu_evt_type { |
| int mt76_dma_rx_poll(struct napi_struct *napi, int budget); |
| void mt76_dma_attach(struct mt76_dev *dev); |
| void mt76_dma_cleanup(struct mt76_dev *dev); |
| - |
| +int mt76_dma_wed_setup(struct mt76_dev *dev, struct mt76_queue *q, bool reset); |
| #endif |
| diff --git a/mt7915/dma.c b/mt7915/dma.c |
| index 7d8d60bb..8df7d0ee 100644 |
| --- a/mt7915/dma.c |
| +++ b/mt7915/dma.c |
| @@ -549,28 +549,44 @@ int mt7915_dma_reset(struct mt7915_dev *dev, bool force) |
| mt7915_wfsys_reset(dev); |
| |
| /* disable wfdma */ |
| + if (mtk_wed_device_active(&dev->mt76.mmio.wed)) |
| + mtk_wed_device_dma_reset(&dev->mt76.mmio.wed); |
| mt7915_dma_disable(dev, force); |
| |
| /* reset hw queues */ |
| for (i = 0; i < __MT_TXQ_MAX; i++) { |
| mt76_queue_reset(dev, dev->mphy.q_tx[i]); |
| - if (mphy_ext) |
| + if (mphy_ext) { |
| mt76_queue_reset(dev, mphy_ext->q_tx[i]); |
| + if (mtk_wed_device_active(&dev->mt76.mmio.wed)) |
| + mt76_dma_wed_setup(&dev->mt76, |
| + mphy_ext->q_tx[i], |
| + true); |
| + } |
| + if (mtk_wed_device_active(&dev->mt76.mmio.wed)) |
| + mt76_dma_wed_setup(&dev->mt76, dev->mphy.q_tx[i], |
| + true); |
| } |
| |
| 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_queue_reset(dev, &dev->mt76.q_rx[i]); |
| + mt76_for_each_q_rx(&dev->mt76, i) { |
| + if (dev->mt76.q_rx[i].flags != MT_WED_Q_TXFREE) |
| + 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(&dev->mt76.mmio.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; |
| } |
| |
| diff --git a/mt7915/mac.c b/mt7915/mac.c |
| index 1f8e1230..f53de870 100644 |
| --- a/mt7915/mac.c |
| +++ b/mt7915/mac.c |
| @@ -1674,6 +1674,12 @@ void mt7915_mac_reset_work(struct work_struct *work) |
| if (!(READ_ONCE(dev->reset_state) & MT_MCU_CMD_STOP_DMA)) |
| return; |
| |
| + if (mtk_wed_device_active(&dev->mt76.mmio.wed)) { |
| + mtk_wed_device_stop(&dev->mt76.mmio.wed, true); |
| + 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); |
| -- |
| 2.18.0 |
| |