mt76: mt7615: rework locking scheme for mt7615_set_channel
authorLorenzo Bianconi <lorenzo@kernel.org>
Sun, 28 Jul 2019 19:03:17 +0000 (21:03 +0200)
committerFelix Fietkau <nbd@nbd.name>
Thu, 5 Sep 2019 15:42:31 +0000 (17:42 +0200)
As already done for mt7603 driver, move mt76.mutex lock inside
mt7615_set_channel since we need to grab mt76.mutex in mt7615_mac_work.
This is a preliminary patch to add Smart Carrier Sense (SCS) support

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
drivers/net/wireless/mediatek/mt76/mt7615/main.c

index 6238b29170ae11a4836765b44fae0766d79b2945..c7c0b924c4f38fc08a3cb03bf05375fcf77a6721 100644 (file)
@@ -135,6 +135,8 @@ static int mt7615_set_channel(struct mt7615_dev *dev)
        int ret;
 
        cancel_delayed_work_sync(&dev->mt76.mac_work);
+
+       mutex_lock(&dev->mt76.mutex);
        set_bit(MT76_RESET, &dev->mt76.state);
 
        mt7615_dfs_check_channel(dev);
@@ -143,18 +145,18 @@ static int mt7615_set_channel(struct mt7615_dev *dev)
 
        ret = mt7615_mcu_set_channel(dev);
        if (ret)
-               return ret;
+               goto out;
 
        ret = mt7615_dfs_init_radar_detector(dev);
-       if (ret < 0)
-               return ret;
 
+out:
        clear_bit(MT76_RESET, &dev->mt76.state);
+       mutex_unlock(&dev->mt76.mutex);
 
        mt76_txq_schedule_all(&dev->mt76);
        ieee80211_queue_delayed_work(mt76_hw(dev), &dev->mt76.mac_work,
                                     MT7615_WATCHDOG_TIME);
-       return 0;
+       return ret;
 }
 
 static int mt7615_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
@@ -210,14 +212,14 @@ static int mt7615_config(struct ieee80211_hw *hw, u32 changed)
        struct mt7615_dev *dev = hw->priv;
        int ret = 0;
 
-       mutex_lock(&dev->mt76.mutex);
-
        if (changed & IEEE80211_CONF_CHANGE_CHANNEL) {
                ieee80211_stop_queues(hw);
                ret = mt7615_set_channel(dev);
                ieee80211_wake_queues(hw);
        }
 
+       mutex_lock(&dev->mt76.mutex);
+
        if (changed & IEEE80211_CONF_CHANGE_POWER)
                ret = mt7615_mcu_set_tx_power(dev);