mt76: connac: use waitqueue for runtime-pm

Simplify the code using a wait_queue_head_t instead of a completion to
wait the chip is fully awake in mt76_connac_pm_wake routine

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
This commit is contained in:
Lorenzo Bianconi 2021-04-18 18:45:42 +02:00 committed by Felix Fietkau
parent 310718ba6a
commit e5f35576c8
6 changed files with 9 additions and 9 deletions

View File

@ -508,7 +508,7 @@ void mt7615_init_device(struct mt7615_dev *dev)
INIT_WORK(&dev->pm.wake_work, mt7615_pm_wake_work); INIT_WORK(&dev->pm.wake_work, mt7615_pm_wake_work);
spin_lock_init(&dev->pm.wake.lock); spin_lock_init(&dev->pm.wake.lock);
mutex_init(&dev->pm.mutex); mutex_init(&dev->pm.mutex);
init_completion(&dev->pm.wake_cmpl); init_waitqueue_head(&dev->pm.wait);
spin_lock_init(&dev->pm.txq_lock); spin_lock_init(&dev->pm.txq_lock);
set_bit(MT76_STATE_PM, &dev->mphy.state); set_bit(MT76_STATE_PM, &dev->mphy.state);
INIT_DELAYED_WORK(&dev->mphy.mac_work, mt7615_mac_work); INIT_DELAYED_WORK(&dev->mphy.mac_work, mt7615_mac_work);

View File

@ -1919,7 +1919,7 @@ void mt7615_pm_wake_work(struct work_struct *work)
} }
ieee80211_wake_queues(mphy->hw); ieee80211_wake_queues(mphy->hw);
complete_all(&dev->pm.wake_cmpl); wake_up(&dev->pm.wait);
} }
void mt7615_pm_power_save_work(struct work_struct *work) void mt7615_pm_power_save_work(struct work_struct *work)

View File

@ -53,7 +53,7 @@ struct mt76_connac_pm {
} tx_q[IEEE80211_NUM_ACS]; } tx_q[IEEE80211_NUM_ACS];
struct work_struct wake_work; struct work_struct wake_work;
struct completion wake_cmpl; wait_queue_head_t wait;
struct { struct {
spinlock_t lock; spinlock_t lock;

View File

@ -17,10 +17,10 @@ int mt76_connac_pm_wake(struct mt76_phy *phy, struct mt76_connac_pm *pm)
if (!test_bit(MT76_STATE_PM, &phy->state)) if (!test_bit(MT76_STATE_PM, &phy->state))
return 0; return 0;
if (queue_work(dev->wq, &pm->wake_work)) queue_work(dev->wq, &pm->wake_work);
reinit_completion(&pm->wake_cmpl); if (!wait_event_timeout(pm->wait,
!test_bit(MT76_STATE_PM, &phy->state),
if (!wait_for_completion_timeout(&pm->wake_cmpl, 3 * HZ)) { 3 * HZ)) {
ieee80211_wake_queues(phy->hw); ieee80211_wake_queues(phy->hw);
return -ETIMEDOUT; return -ETIMEDOUT;
} }

View File

@ -225,7 +225,7 @@ int mt7921_register_device(struct mt7921_dev *dev)
INIT_WORK(&dev->pm.wake_work, mt7921_pm_wake_work); INIT_WORK(&dev->pm.wake_work, mt7921_pm_wake_work);
spin_lock_init(&dev->pm.wake.lock); spin_lock_init(&dev->pm.wake.lock);
mutex_init(&dev->pm.mutex); mutex_init(&dev->pm.mutex);
init_completion(&dev->pm.wake_cmpl); init_waitqueue_head(&dev->pm.wait);
spin_lock_init(&dev->pm.txq_lock); spin_lock_init(&dev->pm.txq_lock);
set_bit(MT76_STATE_PM, &dev->mphy.state); set_bit(MT76_STATE_PM, &dev->mphy.state);
INIT_LIST_HEAD(&dev->phy.stats_list); INIT_LIST_HEAD(&dev->phy.stats_list);

View File

@ -1530,7 +1530,7 @@ void mt7921_pm_wake_work(struct work_struct *work)
} }
ieee80211_wake_queues(mphy->hw); ieee80211_wake_queues(mphy->hw);
complete_all(&dev->pm.wake_cmpl); wake_up(&dev->pm.wait);
} }
void mt7921_pm_power_save_work(struct work_struct *work) void mt7921_pm_power_save_work(struct work_struct *work)