Commit ec7bd7b4 authored by Lorenzo Bianconi's avatar Lorenzo Bianconi Committed by Felix Fietkau

mt76: connac: check wake refcount in mcu_fw_pmctrl

In order to avoid synchronization races between tx and rx path, rely on
mt76_connac_skip_fw_pmctrl putting the chip in sleep mode for mt7921 and
mt7663 devices
Signed-off-by: default avatarLorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: default avatarFelix Fietkau <nbd@nbd.name>
parent 4f9b3aeb
...@@ -358,7 +358,7 @@ static int mt7615_mcu_fw_pmctrl(struct mt7615_dev *dev) ...@@ -358,7 +358,7 @@ static int mt7615_mcu_fw_pmctrl(struct mt7615_dev *dev)
mutex_lock(&dev->pm.mutex); mutex_lock(&dev->pm.mutex);
if (test_and_set_bit(MT76_STATE_PM, &mphy->state)) if (mt76_connac_skip_fw_pmctrl(mphy, &dev->pm))
goto out; goto out;
mt7622_trigger_hif_int(dev, true); mt7622_trigger_hif_int(dev, true);
......
...@@ -116,6 +116,18 @@ mt76_connac_pm_unref(struct mt76_connac_pm *pm) ...@@ -116,6 +116,18 @@ mt76_connac_pm_unref(struct mt76_connac_pm *pm)
spin_unlock_bh(&pm->wake.lock); spin_unlock_bh(&pm->wake.lock);
} }
static inline bool
mt76_connac_skip_fw_pmctrl(struct mt76_phy *phy, struct mt76_connac_pm *pm)
{
bool ret;
spin_lock_bh(&pm->wake.lock);
ret = pm->wake.count || test_and_set_bit(MT76_STATE_PM, &phy->state);
spin_unlock_bh(&pm->wake.lock);
return ret;
}
static inline void static inline void
mt76_connac_mutex_acquire(struct mt76_dev *dev, struct mt76_connac_pm *pm) mt76_connac_mutex_acquire(struct mt76_dev *dev, struct mt76_connac_pm *pm)
__acquires(&dev->mutex) __acquires(&dev->mutex)
......
...@@ -1304,7 +1304,7 @@ int mt7921_mcu_fw_pmctrl(struct mt7921_dev *dev) ...@@ -1304,7 +1304,7 @@ int mt7921_mcu_fw_pmctrl(struct mt7921_dev *dev)
mutex_lock(&dev->pm.mutex); mutex_lock(&dev->pm.mutex);
if (test_and_set_bit(MT76_STATE_PM, &mphy->state)) if (mt76_connac_skip_fw_pmctrl(mphy, &dev->pm))
goto out; goto out;
for (i = 0; i < MT7921_DRV_OWN_RETRY_COUNT; i++) { for (i = 0; i < MT7921_DRV_OWN_RETRY_COUNT; i++) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment