mt76: mt7663s: rely on mt76_connac_pm_ref/mt76_connac_pm_unref in tx path
authorLorenzo Bianconi <lorenzo@kernel.org>
Fri, 18 Jun 2021 08:08:22 +0000 (10:08 +0200)
committerFelix Fietkau <nbd@nbd.name>
Sat, 19 Jun 2021 07:22:51 +0000 (09:22 +0200)
Similar to mt7663e, rely on mt76_connac_pm_ref/mt76_connac_pm_unref to
check PM state and increment/decrement wake counter

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
drivers/net/wireless/mediatek/mt76/mt7615/mac.c
drivers/net/wireless/mediatek/mt76/mt7615/sdio_txrx.c

index f41fbb6..bd0d189 100644 (file)
@@ -1942,12 +1942,18 @@ void mt7615_pm_wake_work(struct work_struct *work)
        mphy = dev->phy.mt76;
 
        if (!mt7615_mcu_set_drv_ctrl(dev)) {
+               struct mt76_dev *mdev = &dev->mt76;
                int i;
 
-               mt76_for_each_q_rx(&dev->mt76, i)
-                       napi_schedule(&dev->mt76.napi[i]);
-               mt76_connac_pm_dequeue_skbs(mphy, &dev->pm);
-               mt76_queue_tx_cleanup(dev, dev->mt76.q_mcu[MT_MCUQ_WM], false);
+               if (mt76_is_sdio(mdev)) {
+                       mt76_worker_schedule(&mdev->sdio.txrx_worker);
+               } else {
+                       mt76_for_each_q_rx(mdev, i)
+                               napi_schedule(&mdev->napi[i]);
+                       mt76_connac_pm_dequeue_skbs(mphy, &dev->pm);
+                       mt76_queue_tx_cleanup(dev, mdev->q_mcu[MT_MCUQ_WM],
+                                             false);
+               }
                if (test_bit(MT76_STATE_RUNNING, &mphy->state))
                        ieee80211_queue_delayed_work(mphy->hw, &mphy->mac_work,
                                                     MT7615_WATCHDOG_TIME);
index 4393dd2..04f4c89 100644 (file)
@@ -283,9 +283,15 @@ void mt7663s_txrx_worker(struct mt76_worker *w)
 {
        struct mt76_sdio *sdio = container_of(w, struct mt76_sdio,
                                              txrx_worker);
-       struct mt76_dev *dev = container_of(sdio, struct mt76_dev, sdio);
+       struct mt76_dev *mdev = container_of(sdio, struct mt76_dev, sdio);
+       struct mt7615_dev *dev = container_of(mdev, struct mt7615_dev, mt76);
        int i, nframes, ret;
 
+       if (!mt76_connac_pm_ref(&dev->mphy, &dev->pm)) {
+               queue_work(mdev->wq, &dev->pm.wake_work);
+               return;
+       }
+
        /* disable interrupt */
        sdio_claim_host(sdio->func);
        sdio_writel(sdio->func, WHLPCR_INT_EN_CLR, MCR_WHLPCR, NULL);
@@ -295,16 +301,16 @@ void mt7663s_txrx_worker(struct mt76_worker *w)
 
                /* tx */
                for (i = 0; i <= MT_TXQ_PSD; i++) {
-                       ret = mt7663s_tx_run_queue(dev, dev->phy.q_tx[i]);
+                       ret = mt7663s_tx_run_queue(mdev, mdev->phy.q_tx[i]);
                        if (ret > 0)
                                nframes += ret;
                }
-               ret = mt7663s_tx_run_queue(dev, dev->q_mcu[MT_MCUQ_WM]);
+               ret = mt7663s_tx_run_queue(mdev, mdev->q_mcu[MT_MCUQ_WM]);
                if (ret > 0)
                        nframes += ret;
 
                /* rx */
-               ret = mt7663s_rx_handler(dev);
+               ret = mt7663s_rx_handler(mdev);
                if (ret > 0)
                        nframes += ret;
        } while (nframes > 0);
@@ -312,6 +318,8 @@ void mt7663s_txrx_worker(struct mt76_worker *w)
        /* enable interrupt */
        sdio_writel(sdio->func, WHLPCR_INT_EN_SET, MCR_WHLPCR, NULL);
        sdio_release_host(sdio->func);
+
+       mt76_connac_pm_unref(&dev->mphy, &dev->pm);
 }
 
 void mt7663s_sdio_irq(struct sdio_func *func)