Skip to content

Commit

Permalink
mt76: attempt to free up more room when filling the tx queue
Browse files Browse the repository at this point in the history
Run dma cleanup immediately if the queue is almost full, instead of waiting
for the tx interrupt

Signed-off-by: Felix Fietkau <[email protected]>
  • Loading branch information
nbd168 committed Nov 21, 2020
1 parent fb24e5f commit 066cc44
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
3 changes: 3 additions & 0 deletions dma.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ mt76_dma_alloc_queue(struct mt76_dev *dev, struct mt76_queue *q,
int i;

spin_lock_init(&q->lock);
spin_lock_init(&q->cleanup_lock);

q->regs = dev->mmio.regs + ring_base + idx * MT_RING_SIZE;
q->ndesc = n_desc;
Expand Down Expand Up @@ -225,6 +226,7 @@ mt76_dma_tx_cleanup(struct mt76_dev *dev, struct mt76_queue *q, bool flush)
if (!q)
return;

spin_lock_bh(&q->cleanup_lock);
if (flush)
last = -1;
else
Expand All @@ -243,6 +245,7 @@ mt76_dma_tx_cleanup(struct mt76_dev *dev, struct mt76_queue *q, bool flush)
last = readl(&q->regs->dma_idx);

}
spin_unlock_bh(&q->cleanup_lock);

if (flush) {
spin_lock_bh(&q->lock);
Expand Down
1 change: 1 addition & 0 deletions mt76.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ struct mt76_queue {
struct mt76_queue_regs __iomem *regs;

spinlock_t lock;
spinlock_t cleanup_lock;
struct mt76_queue_entry *entry;
struct mt76_desc *desc;

Expand Down
8 changes: 8 additions & 0 deletions tx.c
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,7 @@ static int
mt76_txq_schedule_list(struct mt76_phy *phy, enum mt76_txq_id qid)
{
struct mt76_queue *q = phy->q_tx[qid];
struct mt76_dev *dev = phy->dev;
struct ieee80211_txq *txq;
struct mt76_txq *mtxq;
struct mt76_wcid *wcid;
Expand All @@ -460,6 +461,13 @@ mt76_txq_schedule_list(struct mt76_phy *phy, enum mt76_txq_id qid)
if (q->stopped || q->blocked)
break;

if (dev->queue_ops->tx_cleanup &&
q->queued + 2 * MT_TXQ_FREE_THR >= q->ndesc) {
spin_unlock_bh(&q->lock);
dev->queue_ops->tx_cleanup(dev, q, false);
spin_lock_bh(&q->lock);
}

if (q->queued + MT_TXQ_FREE_THR >= q->ndesc)
break;

Expand Down

0 comments on commit 066cc44

Please sign in to comment.