Skip to content

Commit

Permalink
wifi: mt76: mt7921: add mt7921_mutex_acquire at mt7921_[start, stop]_ap
Browse files Browse the repository at this point in the history
[ Upstream commit 52b4401 ]

Add mt7921_mutex_acquire at mt7921_[start, stop]_ap to fix the race
with the context holding dev->muxtex and the driver might access the
device in low power state.

Fixes: 9d958b6 ("mt76: mt7921: fix command timeout in AP stop period")
Tested-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: Sean Wang <sean.wang@mediatek.com>
Acked-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
moore-bros authored and gregkh committed Oct 21, 2022
1 parent 06c13c1 commit d01bdba
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions drivers/net/wireless/mediatek/mt76/mt7921/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1526,17 +1526,23 @@ mt7921_start_ap(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
struct mt7921_dev *dev = mt7921_hw_dev(hw);
int err;

mt7921_mutex_acquire(dev);

err = mt76_connac_mcu_uni_add_bss(phy->mt76, vif, &mvif->sta.wcid,
true);
if (err)
return err;
goto out;

err = mt7921_mcu_set_bss_pm(dev, vif, true);
if (err)
return err;
goto out;

err = mt7921_mcu_sta_update(dev, NULL, vif, true,
MT76_STA_INFO_STATE_NONE);
out:
mt7921_mutex_release(dev);

return mt7921_mcu_sta_update(dev, NULL, vif, true,
MT76_STA_INFO_STATE_NONE);
return err;
}

static void
Expand All @@ -1548,11 +1554,16 @@ mt7921_stop_ap(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
struct mt7921_dev *dev = mt7921_hw_dev(hw);
int err;

mt7921_mutex_acquire(dev);

err = mt7921_mcu_set_bss_pm(dev, vif, false);
if (err)
return;
goto out;

mt76_connac_mcu_uni_add_bss(phy->mt76, vif, &mvif->sta.wcid, false);

out:
mt7921_mutex_release(dev);
}

const struct ieee80211_ops mt7921_ops = {
Expand Down

0 comments on commit d01bdba

Please sign in to comment.