diff mbox series

[wireless,1/3] wifi: mt76: dma: do not increment queue head if mt76_dma_add_buf fails

Message ID 20230113105848.34642-1-nbd@nbd.name (mailing list archive)
State Accepted
Commit 1132d1c834d6185c89aef07c860fc143a6f2db93
Delegated to: Kalle Valo
Headers show
Series [wireless,1/3] wifi: mt76: dma: do not increment queue head if mt76_dma_add_buf fails | expand

Commit Message

Felix Fietkau Jan. 13, 2023, 10:58 a.m. UTC
From: Lorenzo Bianconi <lorenzo@kernel.org>

Do not increment queue head if mt76_dma_add_buf fails for Wireless
Ethernet Dispatcher rx queues.

Fixes: cd372b8c99c5 ("wifi: mt76: add WED RX support to mt76_dma_{add,get}_buf")
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
(cherry picked from commit fe13dad8992be0b26c1be390bcd111acf9892c17)
---
 drivers/net/wireless/mediatek/mt76/dma.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

Comments

Kalle Valo Jan. 16, 2023, 3:27 p.m. UTC | #1
Felix Fietkau <nbd@nbd.name> wrote:

> From: Lorenzo Bianconi <lorenzo@kernel.org>
> 
> Do not increment queue head if mt76_dma_add_buf fails for Wireless
> Ethernet Dispatcher rx queues.
> 
> Fixes: cd372b8c99c5 ("wifi: mt76: add WED RX support to mt76_dma_{add,get}_buf")
> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
> Signed-off-by: Felix Fietkau <nbd@nbd.name>
> (cherry picked from commit fe13dad8992be0b26c1be390bcd111acf9892c17)

3 patches applied to wireless.git, thanks.

1132d1c834d6 wifi: mt76: dma: do not increment queue head if mt76_dma_add_buf fails
e5c3ac895750 wifi: mt76: handle possible mt76_rx_token_consume failures
953519b35227 wifi: mt76: dma: fix a regression in adding rx buffers
diff mbox series

Patch

diff --git a/drivers/net/wireless/mediatek/mt76/dma.c b/drivers/net/wireless/mediatek/mt76/dma.c
index f795548562f5..c058a02e9ba5 100644
--- a/drivers/net/wireless/mediatek/mt76/dma.c
+++ b/drivers/net/wireless/mediatek/mt76/dma.c
@@ -212,14 +212,14 @@  mt76_dma_add_buf(struct mt76_dev *dev, struct mt76_queue *q,
 {
 	struct mt76_queue_entry *entry;
 	struct mt76_desc *desc;
-	u32 ctrl;
 	int i, idx = -1;
+	u32 ctrl, next;
 
 	for (i = 0; i < nbufs; i += 2, buf += 2) {
 		u32 buf0 = buf[0].addr, buf1 = 0;
 
 		idx = q->head;
-		q->head = (q->head + 1) % q->ndesc;
+		next = (q->head + 1) % q->ndesc;
 
 		desc = &q->desc[idx];
 		entry = &q->entry[idx];
@@ -239,8 +239,8 @@  mt76_dma_add_buf(struct mt76_dev *dev, struct mt76_queue *q,
 			       MT_DMA_CTL_TO_HOST;
 		} else {
 			if (txwi) {
-				q->entry[q->head].txwi = DMA_DUMMY_DATA;
-				q->entry[q->head].skip_buf0 = true;
+				q->entry[next].txwi = DMA_DUMMY_DATA;
+				q->entry[next].skip_buf0 = true;
 			}
 
 			if (buf[0].skip_unmap)
@@ -271,6 +271,7 @@  mt76_dma_add_buf(struct mt76_dev *dev, struct mt76_queue *q,
 		WRITE_ONCE(desc->info, cpu_to_le32(info));
 		WRITE_ONCE(desc->ctrl, cpu_to_le32(ctrl));
 
+		q->head = next;
 		q->queued++;
 	}