summaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/mediatek/mt76/mac80211.c
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@nbd.name>2018-05-20 07:43:48 +0200
committerKalle Valo <kvalo@codeaurora.org>2018-05-23 09:58:14 +0200
commit26e40d4c0b52c60f13b074d9d6144eb3ac7fb61b (patch)
treeb27792f1af7ec62c2d5917b7c2bcaf6fda723d5a /drivers/net/wireless/mediatek/mt76/mac80211.c
parentmt76: move ieee80211_hw allocation to common core (diff)
downloadlinux-26e40d4c0b52c60f13b074d9d6144eb3ac7fb61b.tar.xz
linux-26e40d4c0b52c60f13b074d9d6144eb3ac7fb61b.zip
mt76: wait for pending tx to complete before switching channel
Reduces interruption caused by scanning Signed-off-by: Felix Fietkau <nbd@nbd.name> Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
Diffstat (limited to 'drivers/net/wireless/mediatek/mt76/mac80211.c')
-rw-r--r--drivers/net/wireless/mediatek/mt76/mac80211.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/drivers/net/wireless/mediatek/mt76/mac80211.c b/drivers/net/wireless/mediatek/mt76/mac80211.c
index d1044e5b25db..fcd079a96782 100644
--- a/drivers/net/wireless/mediatek/mt76/mac80211.c
+++ b/drivers/net/wireless/mediatek/mt76/mac80211.c
@@ -283,6 +283,7 @@ mt76_alloc_device(unsigned int size, const struct ieee80211_ops *ops)
spin_lock_init(&dev->rx_lock);
spin_lock_init(&dev->lock);
spin_lock_init(&dev->cc_lock);
+ init_waitqueue_head(&dev->tx_wait);
return dev;
}
@@ -377,18 +378,33 @@ void mt76_rx(struct mt76_dev *dev, enum mt76_rxq_id q, struct sk_buff *skb)
}
EXPORT_SYMBOL_GPL(mt76_rx);
+static bool mt76_has_tx_pending(struct mt76_dev *dev)
+{
+ int i;
+
+ for (i = 0; i < ARRAY_SIZE(dev->q_tx); i++) {
+ if (dev->q_tx[i].queued)
+ return true;
+ }
+
+ return false;
+}
+
void mt76_set_channel(struct mt76_dev *dev)
{
struct ieee80211_hw *hw = dev->hw;
struct cfg80211_chan_def *chandef = &hw->conf.chandef;
struct mt76_channel_state *state;
bool offchannel = hw->conf.flags & IEEE80211_CONF_OFFCHANNEL;
+ int timeout = HZ / 5;
if (offchannel)
set_bit(MT76_OFFCHANNEL, &dev->state);
else
clear_bit(MT76_OFFCHANNEL, &dev->state);
+ wait_event_timeout(dev->tx_wait, !mt76_has_tx_pending(dev), timeout);
+
if (dev->drv->update_survey)
dev->drv->update_survey(dev);