wifi: mt76: reduce spin_lock_bh held up in mt76_dma_rx_cleanup
authorSean Wang <sean.wang@mediatek.com>
Tue, 26 Sep 2023 22:20:25 +0000 (06:20 +0800)
committerFelix Fietkau <nbd@nbd.name>
Sat, 30 Sep 2023 18:17:18 +0000 (20:17 +0200)
mt76_dma_rx_cleanup would be frequenetly called up to reset the dma rings
to be freshed as new ones when switching back from the deep sleep mode to
the active mode on mt7921 and mt7922.

Shrink the scope of spin_lock_bh in mt76_dma_rx_cleanup being held up
to allow the kernel scheduler to be able to switch other tasks in time
by reducing the latency.

Signed-off-by: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
drivers/net/wireless/mediatek/mt76/dma.c

index 643e18ebb5ee61abcc0a877e4590ca8860fe9d28..5f31d4d6a640c362cbbfe531df7e9b3f4006cb27 100644 (file)
@@ -739,16 +739,18 @@ mt76_dma_rx_cleanup(struct mt76_dev *dev, struct mt76_queue *q)
        if (!q->ndesc)
                return;
 
-       spin_lock_bh(&q->lock);
-
        do {
+               spin_lock_bh(&q->lock);
                buf = mt76_dma_dequeue(dev, q, true, NULL, NULL, &more, NULL);
+               spin_unlock_bh(&q->lock);
+
                if (!buf)
                        break;
 
                mt76_put_page_pool_buf(buf, false);
        } while (1);
 
+       spin_lock_bh(&q->lock);
        if (q->rx_head) {
                dev_kfree_skb(q->rx_head);
                q->rx_head = NULL;