wifi: mt76: mt7996: Add __mt7996_npu_hw_init routine

Introduce __mt7996_npu_hw_init utility routine in order to run it
holding mt76 mutex and move NPU hw re-initialization before restarting
the NAPIs during device reset.

Tested-by: Kang Yang <kang.yang@airoha.com>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Link: https://patch.msgid.link/20260122-mt76-npu-eagle-offload-v2-12-2374614c0de6@kernel.org
Signed-off-by: Felix Fietkau <nbd@nbd.name>
This commit is contained in:
Lorenzo Bianconi 2026-01-22 11:39:56 +01:00 committed by Felix Fietkau
parent cd7951f242
commit 93e2491470
3 changed files with 27 additions and 14 deletions

View File

@ -2569,6 +2569,8 @@ void mt7996_mac_reset_work(struct work_struct *work)
MT_INT_TX_RX_DONE_EXT);
}
__mt7996_npu_hw_init(dev);
clear_bit(MT76_MCU_RESET, &dev->mphy.state);
mt7996_for_each_phy(dev, phy)
clear_bit(MT76_RESET, &phy->mt76->state);
@ -2598,8 +2600,6 @@ void mt7996_mac_reset_work(struct work_struct *work)
mutex_unlock(&dev->mt76.mutex);
mt7996_npu_hw_init(dev);
mt7996_for_each_phy(dev, phy)
ieee80211_queue_delayed_work(hw, &phy->mt76->mac_work,
MT7996_WATCHDOG_TIME);

View File

@ -889,10 +889,16 @@ int mt7996_mtk_init_debugfs(struct mt7996_phy *phy, struct dentry *dir);
int mt7996_dma_rro_init(struct mt7996_dev *dev);
#ifdef CONFIG_MT7996_NPU
int __mt7996_npu_hw_init(struct mt7996_dev *dev);
int mt7996_npu_hw_init(struct mt7996_dev *dev);
int mt7996_npu_hw_stop(struct mt7996_dev *dev);
int mt7996_npu_rx_queues_init(struct mt7996_dev *dev);
#else
static inline int __mt7996_npu_hw_init(struct mt7996_dev *dev)
{
return 0;
}
static inline int mt7996_npu_hw_init(struct mt7996_dev *dev)
{
return 0;

View File

@ -525,20 +525,18 @@ int mt7996_npu_rx_queues_init(struct mt7996_dev *dev)
&dev->mt76.q_rx[MT_RXQ_NPU1]);
}
int mt7996_npu_hw_init(struct mt7996_dev *dev)
int __mt7996_npu_hw_init(struct mt7996_dev *dev)
{
struct airoha_npu *npu;
int i, err = 0;
mutex_lock(&dev->mt76.mutex);
int i, err;
npu = rcu_dereference_protected(dev->mt76.mmio.npu, &dev->mt76.mutex);
if (!npu)
goto unlock;
return 0;
err = mt7996_npu_offload_init(dev, npu);
if (err)
goto unlock;
return err;
if (is_mt7996(&dev->mt76))
err = mt7996_npu_rxd_init(dev, npu);
@ -546,27 +544,36 @@ int mt7996_npu_hw_init(struct mt7996_dev *dev)
err = mt7992_npu_rxd_init(dev, npu);
if (err)
goto unlock;
return err;
err = mt7996_npu_txd_init(dev, npu);
if (err)
goto unlock;
return err;
err = mt7996_npu_rx_event_init(dev, npu);
if (err)
goto unlock;
return err;
err = mt7996_npu_set_pcie_addr(dev, npu);
if (err)
goto unlock;
return err;
err = mt7996_npu_tx_done_init(dev, npu);
if (err)
goto unlock;
return err;
for (i = MT_RXQ_NPU0; i <= MT_RXQ_NPU1; i++)
airoha_npu_wlan_enable_irq(npu, i - MT_RXQ_NPU0);
unlock:
return 0;
}
int mt7996_npu_hw_init(struct mt7996_dev *dev)
{
int err;
mutex_lock(&dev->mt76.mutex);
err = __mt7996_npu_hw_init(dev);
mutex_unlock(&dev->mt76.mutex);
return err;