Commit 26e40d4c authored by Felix Fietkau's avatar Felix Fietkau Committed by Kalle Valo

mt76: wait for pending tx to complete before switching channel

Reduces interruption caused by scanning
Signed-off-by: default avatarFelix Fietkau <nbd@nbd.name>
Signed-off-by: default avatarKalle Valo <kvalo@codeaurora.org>
parent a85b590c
...@@ -178,6 +178,10 @@ mt76_dma_tx_cleanup(struct mt76_dev *dev, enum mt76_txq_id qid, bool flush) ...@@ -178,6 +178,10 @@ mt76_dma_tx_cleanup(struct mt76_dev *dev, enum mt76_txq_id qid, bool flush)
mt76_dma_sync_idx(dev, q); mt76_dma_sync_idx(dev, q);
wake = wake && qid < IEEE80211_NUM_ACS && q->queued < q->ndesc - 8; wake = wake && qid < IEEE80211_NUM_ACS && q->queued < q->ndesc - 8;
if (!q->queued)
wake_up(&dev->tx_wait);
spin_unlock_bh(&q->lock); spin_unlock_bh(&q->lock);
if (wake) if (wake)
......
...@@ -283,6 +283,7 @@ mt76_alloc_device(unsigned int size, const struct ieee80211_ops *ops) ...@@ -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->rx_lock);
spin_lock_init(&dev->lock); spin_lock_init(&dev->lock);
spin_lock_init(&dev->cc_lock); spin_lock_init(&dev->cc_lock);
init_waitqueue_head(&dev->tx_wait);
return dev; return dev;
} }
...@@ -377,18 +378,33 @@ void mt76_rx(struct mt76_dev *dev, enum mt76_rxq_id q, struct sk_buff *skb) ...@@ -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); 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) void mt76_set_channel(struct mt76_dev *dev)
{ {
struct ieee80211_hw *hw = dev->hw; struct ieee80211_hw *hw = dev->hw;
struct cfg80211_chan_def *chandef = &hw->conf.chandef; struct cfg80211_chan_def *chandef = &hw->conf.chandef;
struct mt76_channel_state *state; struct mt76_channel_state *state;
bool offchannel = hw->conf.flags & IEEE80211_CONF_OFFCHANNEL; bool offchannel = hw->conf.flags & IEEE80211_CONF_OFFCHANNEL;
int timeout = HZ / 5;
if (offchannel) if (offchannel)
set_bit(MT76_OFFCHANNEL, &dev->state); set_bit(MT76_OFFCHANNEL, &dev->state);
else else
clear_bit(MT76_OFFCHANNEL, &dev->state); clear_bit(MT76_OFFCHANNEL, &dev->state);
wait_event_timeout(dev->tx_wait, !mt76_has_tx_pending(dev), timeout);
if (dev->drv->update_survey) if (dev->drv->update_survey)
dev->drv->update_survey(dev); dev->drv->update_survey(dev);
......
...@@ -251,6 +251,8 @@ struct mt76_dev { ...@@ -251,6 +251,8 @@ struct mt76_dev {
struct mt76_queue q_rx[__MT_RXQ_MAX]; struct mt76_queue q_rx[__MT_RXQ_MAX];
const struct mt76_queue_ops *queue_ops; const struct mt76_queue_ops *queue_ops;
wait_queue_head_t tx_wait;
u8 macaddr[ETH_ALEN]; u8 macaddr[ETH_ALEN];
u32 rev; u32 rev;
unsigned long state; unsigned long state;
......
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