From: Felix Fietkau <nbd@nbd.name>
To: linux-wireless@vger.kernel.org
Subject: [PATCH 3/9] mt76: dma: update q->queued immediately on cleanup
Date: Tue, 25 Aug 2020 07:29:03 +0200 [thread overview]
Message-ID: <20200825052909.36955-3-nbd@nbd.name> (raw)
In-Reply-To: <20200825052909.36955-1-nbd@nbd.name>
Tx cleanup and tx enqueuing can run in parallel. In order to avoid queue
starvation issues under load, update q->queued immediately.
Signed-off-by: Felix Fietkau <nbd@nbd.name>
---
drivers/net/wireless/mediatek/mt76/dma.c | 39 +++++++++---------------
1 file changed, 14 insertions(+), 25 deletions(-)
diff --git a/drivers/net/wireless/mediatek/mt76/dma.c b/drivers/net/wireless/mediatek/mt76/dma.c
index ade2d58b8da9..7545b552db25 100644
--- a/drivers/net/wireless/mediatek/mt76/dma.c
+++ b/drivers/net/wireless/mediatek/mt76/dma.c
@@ -152,10 +152,8 @@ mt76_dma_tx_cleanup(struct mt76_dev *dev, enum mt76_txq_id qid, bool flush)
struct mt76_sw_queue *sq = &dev->q_tx[qid];
struct mt76_queue *q = sq->q;
struct mt76_queue_entry entry;
- unsigned int n_swq_queued[8] = {};
- unsigned int n_queued = 0;
bool wake = false;
- int i, last;
+ int last;
if (!q)
return;
@@ -165,13 +163,14 @@ mt76_dma_tx_cleanup(struct mt76_dev *dev, enum mt76_txq_id qid, bool flush)
else
last = readl(&q->regs->dma_idx);
- while ((q->queued > n_queued) && q->tail != last) {
+ while (q->queued > 0 && q->tail != last) {
+ int swq_qid = -1;
+
mt76_dma_tx_cleanup_idx(dev, q, q->tail, &entry);
if (entry.schedule)
- n_swq_queued[entry.qid]++;
+ swq_qid = entry.qid;
q->tail = (q->tail + 1) % q->ndesc;
- n_queued++;
if (entry.skb)
dev->drv->tx_complete_skb(dev, qid, &entry);
@@ -184,29 +183,21 @@ mt76_dma_tx_cleanup(struct mt76_dev *dev, enum mt76_txq_id qid, bool flush)
if (!flush && q->tail == last)
last = readl(&q->regs->dma_idx);
- }
-
- spin_lock_bh(&q->lock);
-
- q->queued -= n_queued;
- for (i = 0; i < 4; i++) {
- if (!n_swq_queued[i])
- continue;
- dev->q_tx[i].swq_queued -= n_swq_queued[i];
- }
-
- /* ext PHY */
- for (i = 0; i < 4; i++) {
- if (!n_swq_queued[i])
- continue;
-
- dev->q_tx[__MT_TXQ_MAX + i].swq_queued -= n_swq_queued[4 + i];
+ spin_lock_bh(&q->lock);
+ if (swq_qid >= 4)
+ dev->q_tx[__MT_TXQ_MAX + swq_qid - 4].swq_queued--;
+ else if (swq_qid >= 0)
+ dev->q_tx[swq_qid].swq_queued--;
+ q->queued--;
+ spin_unlock_bh(&q->lock);
}
if (flush) {
+ spin_lock_bh(&q->lock);
mt76_dma_sync_idx(dev, q);
mt76_dma_kick_queue(dev, q);
+ spin_unlock_bh(&q->lock);
}
wake = wake && q->stopped &&
@@ -217,8 +208,6 @@ mt76_dma_tx_cleanup(struct mt76_dev *dev, enum mt76_txq_id qid, bool flush)
if (!q->queued)
wake_up(&dev->tx_wait);
- spin_unlock_bh(&q->lock);
-
if (wake)
ieee80211_wake_queue(dev->hw, qid);
}
--
2.28.0
next prev parent reply other threads:[~2020-08-25 5:29 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-25 5:29 [PATCH 1/9] mt76: mt7615: fix reading airtime statistics Felix Fietkau
2020-08-25 5:29 ` [PATCH 2/9] mt76: mt7915: optimize mt7915_mac_sta_poll Felix Fietkau
2020-08-25 5:29 ` Felix Fietkau [this message]
2020-08-25 5:29 ` [PATCH 4/9] mt76: mt7915: schedule tx tasklet in mt7915_mac_tx_free Felix Fietkau
2020-08-25 5:29 ` [PATCH 5/9] mt76: mt7915: significantly reduce interrupt load Felix Fietkau
2020-08-25 5:29 ` [PATCH 6/9] mt76: mt7615: " Felix Fietkau
2020-08-25 5:29 ` [PATCH 7/9] mt76: mt7915: add support for accessing mapped registers via bus ops Felix Fietkau
2020-08-25 5:29 ` [PATCH 8/9] mt76: add memory barrier to DMA queue kick Felix Fietkau
2020-08-25 5:29 ` [PATCH 9/9] mt76: mt7603: check for single-stream EEPROM configuration Felix Fietkau
2020-08-25 11:42 ` [PATCH v2 " Felix Fietkau
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=20200825052909.36955-3-nbd@nbd.name \
--to=nbd@nbd.name \
--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