OSDN Git Service

mt76: mt7921: update statistic in active mode only
authorDeren Wu <deren.wu@mediatek.com>
Thu, 27 May 2021 17:05:33 +0000 (01:05 +0800)
committerFelix Fietkau <nbd@nbd.name>
Sat, 19 Jun 2021 07:22:47 +0000 (09:22 +0200)
wakeup chip every 250ms may cause huge power consumption

try to update statistic counter only if in active status only,
and it would lead fewer power cost

Signed-off-by: Deren Wu <deren.wu@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
drivers/net/wireless/mediatek/mt76/mt7921/mac.c

index 99bf20d..882bb74 100644 (file)
@@ -1483,13 +1483,15 @@ void mt7921_pm_power_save_work(struct work_struct *work)
 {
        struct mt7921_dev *dev;
        unsigned long delta;
+       struct mt76_phy *mphy;
 
        dev = (struct mt7921_dev *)container_of(work, struct mt7921_dev,
                                                pm.ps_work.work);
+       mphy = dev->phy.mt76;
 
        delta = dev->pm.idle_timeout;
-       if (test_bit(MT76_HW_SCANNING, &dev->mphy.state) ||
-           test_bit(MT76_HW_SCHED_SCANNING, &dev->mphy.state))
+       if (test_bit(MT76_HW_SCANNING, &mphy->state) ||
+           test_bit(MT76_HW_SCHED_SCANNING, &mphy->state))
                goto out;
 
        if (time_is_after_jiffies(dev->pm.last_activity + delta)) {
@@ -1497,8 +1499,10 @@ void mt7921_pm_power_save_work(struct work_struct *work)
                goto out;
        }
 
-       if (!mt7921_mcu_fw_pmctrl(dev))
+       if (!mt7921_mcu_fw_pmctrl(dev)) {
+               cancel_delayed_work_sync(&mphy->mac_work);
                return;
+       }
 out:
        queue_delayed_work(dev->mt76.wq, &dev->pm.ps_work, delta);
 }