]> www.infradead.org Git - linux-platform-drivers-x86.git/commitdiff
mt76: connac: check wake refcount in mcu_fw_pmctrl
authorLorenzo Bianconi <lorenzo@kernel.org>
Sun, 18 Apr 2021 16:45:36 +0000 (18:45 +0200)
committerFelix Fietkau <nbd@nbd.name>
Wed, 21 Apr 2021 18:55:53 +0000 (20:55 +0200)
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: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
drivers/net/wireless/mediatek/mt76/mt7615/mcu.c
drivers/net/wireless/mediatek/mt76/mt76_connac.h
drivers/net/wireless/mediatek/mt76/mt7921/mcu.c

index 5890fee98d97565dcafc62adeb0ba4b809bc91dc..45c6fb5832b8efa0dd8c68997081ee1f399f351a 100644 (file)
@@ -358,7 +358,7 @@ static int mt7615_mcu_fw_pmctrl(struct mt7615_dev *dev)
 
        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;
 
        mt7622_trigger_hif_int(dev, true);
index 85846eab8d7d9d1004ce1de9e3fd06275f9c3cb4..116d800c9f9d01f2b029bef66ec140e1b5e8e80f 100644 (file)
@@ -116,6 +116,18 @@ mt76_connac_pm_unref(struct mt76_connac_pm *pm)
        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
 mt76_connac_mutex_acquire(struct mt76_dev *dev, struct mt76_connac_pm *pm)
        __acquires(&dev->mutex)
index 44f02cbf9cc7b3a4f2df78c66fb656c7399a2b6b..1204f5d324f87063ee7150b320c49e23222b7d09 100644 (file)
@@ -1304,7 +1304,7 @@ int mt7921_mcu_fw_pmctrl(struct mt7921_dev *dev)
 
        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;
 
        for (i = 0; i < MT7921_DRV_OWN_RETRY_COUNT; i++) {