diff options
author | Lorenzo Bianconi <lorenzo@kernel.org> | 2021-06-02 23:25:28 +0200 |
---|---|---|
committer | Felix Fietkau <nbd@nbd.name> | 2021-06-19 09:22:48 +0200 |
commit | 6ab079e2aba283e3e356cc60dd3d0648adc15b1d (patch) | |
tree | 27614a59d7a8b3f99a5fa93704629d50e4aab787 | |
parent | 82453b1cbf9ef166364c12b5464251f16bac5f51 (diff) |
mt76: connac: add mt76_connac_power_save_sched in mt76_connac_pm_unref
Schedule power_save work running mt76_connac_pm_unref in order to reduce
power consumption
Tested-by: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
6 files changed, 16 insertions, 12 deletions
diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/dma.c b/drivers/net/wireless/mediatek/mt76/mt7615/dma.c index 8004ae5c16a9..b6184234cad2 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7615/dma.c +++ b/drivers/net/wireless/mediatek/mt76/mt7615/dma.c @@ -81,7 +81,7 @@ static int mt7615_poll_tx(struct napi_struct *napi, int budget) if (napi_complete(napi)) mt7615_irq_enable(dev, mt7615_tx_mcu_int_mask(dev)); - mt76_connac_pm_unref(&dev->pm); + mt76_connac_pm_unref(&dev->mphy, &dev->pm); return 0; } @@ -99,7 +99,7 @@ static int mt7615_poll_rx(struct napi_struct *napi, int budget) return 0; } done = mt76_dma_rx_poll(napi, budget); - mt76_connac_pm_unref(&dev->pm); + mt76_connac_pm_unref(&dev->mphy, &dev->pm); return done; } diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/main.c b/drivers/net/wireless/mediatek/mt76/mt7615/main.c index 7c9a55c57578..bd2f42ef5ad7 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7615/main.c +++ b/drivers/net/wireless/mediatek/mt76/mt7615/main.c @@ -693,7 +693,7 @@ static void mt7615_sta_rate_tbl_update(struct ieee80211_hw *hw, msta->n_rates = i; if (mt76_connac_pm_ref(phy->mt76, &dev->pm)) { mt7615_mac_set_rates(phy, msta, NULL, msta->rates); - mt76_connac_pm_unref(&dev->pm); + mt76_connac_pm_unref(phy->mt76, &dev->pm); } spin_unlock_bh(&dev->mt76.lock); } @@ -709,7 +709,7 @@ void mt7615_tx_worker(struct mt76_worker *w) } mt76_tx_worker_run(&dev->mt76); - mt76_connac_pm_unref(&dev->pm); + mt76_connac_pm_unref(&dev->mphy, &dev->pm); } static void mt7615_tx(struct ieee80211_hw *hw, @@ -739,7 +739,7 @@ static void mt7615_tx(struct ieee80211_hw *hw, if (mt76_connac_pm_ref(mphy, &dev->pm)) { mt76_tx(mphy, control->sta, wcid, skb); - mt76_connac_pm_unref(&dev->pm); + mt76_connac_pm_unref(mphy, &dev->pm); return; } diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/pci_init.c b/drivers/net/wireless/mediatek/mt76/mt7615/pci_init.c index 261cff78de40..a2465b49ecd0 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7615/pci_init.c +++ b/drivers/net/wireless/mediatek/mt76/mt7615/pci_init.c @@ -98,7 +98,7 @@ mt7615_led_set_config(struct led_classdev *led_cdev, addr = mt7615_reg_map(dev, MT_LED_CTRL); mt76_wr(dev, addr, val); - mt76_connac_pm_unref(&dev->pm); + mt76_connac_pm_unref(&dev->mphy, &dev->pm); } static int diff --git a/drivers/net/wireless/mediatek/mt76/mt76_connac.h b/drivers/net/wireless/mediatek/mt76/mt76_connac.h index 63c1d1a68a70..0dfa09902ffd 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76_connac.h +++ b/drivers/net/wireless/mediatek/mt76/mt76_connac.h @@ -117,11 +117,15 @@ out: } static inline void -mt76_connac_pm_unref(struct mt76_connac_pm *pm) +mt76_connac_pm_unref(struct mt76_phy *phy, struct mt76_connac_pm *pm) { spin_lock_bh(&pm->wake.lock); - pm->wake.count--; + pm->last_activity = jiffies; + if (--pm->wake.count == 0 && + test_bit(MT76_STATE_MCU_RUNNING, &phy->state)) + mt76_connac_power_save_sched(phy, pm); + spin_unlock_bh(&pm->wake.lock); } diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/dma.c b/drivers/net/wireless/mediatek/mt76/mt7921/dma.c index 7fca7dc466b8..5e745e9c2185 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7921/dma.c +++ b/drivers/net/wireless/mediatek/mt76/mt7921/dma.c @@ -74,7 +74,7 @@ static int mt7921_poll_tx(struct napi_struct *napi, int budget) mt7921_tx_cleanup(dev); if (napi_complete(napi)) mt7921_irq_enable(dev, MT_INT_TX_DONE_ALL); - mt76_connac_pm_unref(&dev->pm); + mt76_connac_pm_unref(&dev->mphy, &dev->pm); return 0; } @@ -92,7 +92,7 @@ static int mt7921_poll_rx(struct napi_struct *napi, int budget) return 0; } done = mt76_dma_rx_poll(napi, budget); - mt76_connac_pm_unref(&dev->pm); + mt76_connac_pm_unref(&dev->mphy, &dev->pm); return done; } diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/main.c b/drivers/net/wireless/mediatek/mt76/mt7921/main.c index a6cf4a0e286a..0cd519f6dc00 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7921/main.c +++ b/drivers/net/wireless/mediatek/mt76/mt7921/main.c @@ -679,7 +679,7 @@ void mt7921_tx_worker(struct mt76_worker *w) } mt76_txq_schedule_all(&dev->mphy); - mt76_connac_pm_unref(&dev->pm); + mt76_connac_pm_unref(&dev->mphy, &dev->pm); } static void mt7921_tx(struct ieee80211_hw *hw, @@ -709,7 +709,7 @@ static void mt7921_tx(struct ieee80211_hw *hw, if (mt76_connac_pm_ref(mphy, &dev->pm)) { mt76_tx(mphy, control->sta, wcid, skb); - mt76_connac_pm_unref(&dev->pm); + mt76_connac_pm_unref(mphy, &dev->pm); return; } |