mt76: mt7921: rely on mt76_connac_pm_ref/mt76_connac_pm_unref in tx/rx napi
Introduce mt7921_poll_rx rx napi callback for mt7921. Do not access device registers in tx/rx napi if the device is not awake. Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> Signed-off-by: Felix Fietkau <nbd@nbd.name>
This commit is contained in:
parent
cb8ed33d4b
commit
917dccb6ee
@ -53,8 +53,7 @@ void mt7921_queue_rx_skb(struct mt76_dev *mdev, enum mt76_rxq_id q,
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
mt7921_tx_cleanup(struct mt7921_dev *dev)
|
||||
void mt7921_tx_cleanup(struct mt7921_dev *dev)
|
||||
{
|
||||
mt76_queue_tx_cleanup(dev, dev->mt76.q_mcu[MT_MCUQ_WM], false);
|
||||
mt76_queue_tx_cleanup(dev, dev->mt76.q_mcu[MT_MCUQ_WA], false);
|
||||
@ -66,14 +65,38 @@ static int mt7921_poll_tx(struct napi_struct *napi, int budget)
|
||||
|
||||
dev = container_of(napi, struct mt7921_dev, mt76.tx_napi);
|
||||
|
||||
mt7921_tx_cleanup(dev);
|
||||
if (!mt76_connac_pm_ref(&dev->mphy, &dev->pm)) {
|
||||
napi_complete(napi);
|
||||
queue_work(dev->mt76.wq, &dev->pm.wake_work);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (napi_complete_done(napi, 0))
|
||||
mt7921_tx_cleanup(dev);
|
||||
if (napi_complete(napi))
|
||||
mt7921_irq_enable(dev, MT_INT_TX_DONE_ALL);
|
||||
mt76_connac_pm_unref(&dev->pm);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int mt7921_poll_rx(struct napi_struct *napi, int budget)
|
||||
{
|
||||
struct mt7921_dev *dev;
|
||||
int done;
|
||||
|
||||
dev = container_of(napi->dev, struct mt7921_dev, mt76.napi_dev);
|
||||
|
||||
if (!mt76_connac_pm_ref(&dev->mphy, &dev->pm)) {
|
||||
napi_complete(napi);
|
||||
queue_work(dev->mt76.wq, &dev->pm.wake_work);
|
||||
return 0;
|
||||
}
|
||||
done = mt76_dma_rx_poll(napi, budget);
|
||||
mt76_connac_pm_unref(&dev->pm);
|
||||
|
||||
return done;
|
||||
}
|
||||
|
||||
void mt7921_dma_prefetch(struct mt7921_dev *dev)
|
||||
{
|
||||
#define PREFETCH(base, depth) ((base) << 16 | (depth))
|
||||
@ -295,7 +318,7 @@ int mt7921_dma_init(struct mt7921_dev *dev)
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
ret = mt76_init_queues(dev, mt76_dma_rx_poll);
|
||||
ret = mt76_init_queues(dev, mt7921_poll_rx);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
|
@ -1367,6 +1367,7 @@ mt7921_mac_reset(struct mt7921_dev *dev)
|
||||
mt76_worker_enable(&dev->mt76.tx_worker);
|
||||
|
||||
clear_bit(MT76_MCU_RESET, &dev->mphy.state);
|
||||
clear_bit(MT76_STATE_PM, &dev->mphy.state);
|
||||
|
||||
mt76_wr(dev, MT_WFDMA0_HOST_INT_ENA, 0);
|
||||
mt76_wr(dev, MT_PCIE_MAC_INT_ENABLE, 0xff);
|
||||
@ -1530,10 +1531,14 @@ void mt7921_pm_wake_work(struct work_struct *work)
|
||||
pm.wake_work);
|
||||
mphy = dev->phy.mt76;
|
||||
|
||||
if (!mt7921_mcu_drv_pmctrl(dev))
|
||||
if (!mt7921_mcu_drv_pmctrl(dev)) {
|
||||
int i;
|
||||
|
||||
mt76_for_each_q_rx(&dev->mt76, i)
|
||||
napi_schedule(&dev->mt76.napi[i]);
|
||||
mt76_connac_pm_dequeue_skbs(mphy, &dev->pm);
|
||||
else
|
||||
dev_err(mphy->dev->dev, "failed to wake device\n");
|
||||
mt7921_tx_cleanup(dev);
|
||||
}
|
||||
|
||||
ieee80211_wake_queues(mphy->hw);
|
||||
complete_all(&dev->pm.wake_cmpl);
|
||||
|
@ -332,6 +332,7 @@ void mt7921_mac_sta_remove(struct mt76_dev *mdev, struct ieee80211_vif *vif,
|
||||
void mt7921_mac_work(struct work_struct *work);
|
||||
void mt7921_mac_reset_work(struct work_struct *work);
|
||||
void mt7921_reset(struct mt76_dev *mdev);
|
||||
void mt7921_tx_cleanup(struct mt7921_dev *dev);
|
||||
int mt7921_tx_prepare_skb(struct mt76_dev *mdev, void *txwi_ptr,
|
||||
enum mt76_txq_id qid, struct mt76_wcid *wcid,
|
||||
struct ieee80211_sta *sta,
|
||||
|
Loading…
Reference in New Issue
Block a user