From: Felix Fietkau <nbd@nbd.name>
To: linux-wireless@vger.kernel.org
Cc: kvalo@codeaurora.org
Subject: [PATCH 4/5] mt76: wait for pending tx to complete before switching channel
Date: Sun, 20 May 2018 07:43:48 +0200 [thread overview]
Message-ID: <20180520054349.49422-4-nbd@nbd.name> (raw)
In-Reply-To: <20180520054349.49422-1-nbd@nbd.name>
Reduces interruption caused by scanning
Signed-off-by: Felix Fietkau <nbd@nbd.name>
---
drivers/net/wireless/mediatek/mt76/dma.c | 4 ++++
drivers/net/wireless/mediatek/mt76/mac80211.c | 16 ++++++++++++++++
drivers/net/wireless/mediatek/mt76/mt76.h | 2 ++
3 files changed, 22 insertions(+)
diff --git a/drivers/net/wireless/mediatek/mt76/dma.c b/drivers/net/wireless/mediatek/mt76/dma.c
index 3518703524e7..3dbedcedc2c4 100644
--- a/drivers/net/wireless/mediatek/mt76/dma.c
+++ b/drivers/net/wireless/mediatek/mt76/dma.c
@@ -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);
wake = wake && qid < IEEE80211_NUM_ACS && q->queued < q->ndesc - 8;
+
+ if (!q->queued)
+ wake_up(&dev->tx_wait);
+
spin_unlock_bh(&q->lock);
if (wake)
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);
diff --git a/drivers/net/wireless/mediatek/mt76/mt76.h b/drivers/net/wireless/mediatek/mt76/mt76.h
index bb158f867d7c..d2166fbf50ff 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76.h
+++ b/drivers/net/wireless/mediatek/mt76/mt76.h
@@ -251,6 +251,8 @@ struct mt76_dev {
struct mt76_queue q_rx[__MT_RXQ_MAX];
const struct mt76_queue_ops *queue_ops;
+ wait_queue_head_t tx_wait;
+
u8 macaddr[ETH_ALEN];
u32 rev;
unsigned long state;
--
2.17.0
next prev parent reply other threads:[~2018-05-20 5:43 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-20 5:43 [PATCH 1/5] mt76: only stop tx queues on offchannel, not during the entire scan Felix Fietkau
2018-05-20 5:43 ` [PATCH 2/5] mt76: prevent tx scheduling during channel change Felix Fietkau
2018-05-20 5:43 ` [PATCH 3/5] mt76: move ieee80211_hw allocation to common core Felix Fietkau
2018-05-20 5:43 ` Felix Fietkau [this message]
2018-05-20 5:43 ` [PATCH 5/5] mt76: use udelay instead of usleep_range in mt76x2_mac_stop Felix Fietkau
2018-05-23 7:59 ` [1/5] mt76: only stop tx queues on offchannel, not during the entire scan Kalle Valo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180520054349.49422-4-nbd@nbd.name \
--to=nbd@nbd.name \
--cc=kvalo@codeaurora.org \
--cc=linux-wireless@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox