Commit 1132d1c8 authored by Lorenzo Bianconi's avatar Lorenzo Bianconi Committed by Kalle Valo

wifi: mt76: dma: do not increment queue head if mt76_dma_add_buf fails

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

Fixes: cd372b8c ("wifi: mt76: add WED RX support to mt76_dma_{add,get}_buf")
Signed-off-by: default avatarLorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: default avatarFelix Fietkau <nbd@nbd.name>
(cherry picked from commit fe13dad8)
Signed-off-by: default avatarKalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20230113105848.34642-1-nbd@nbd.name
parent b870e73a
...@@ -212,14 +212,14 @@ mt76_dma_add_buf(struct mt76_dev *dev, struct mt76_queue *q, ...@@ -212,14 +212,14 @@ mt76_dma_add_buf(struct mt76_dev *dev, struct mt76_queue *q,
{ {
struct mt76_queue_entry *entry; struct mt76_queue_entry *entry;
struct mt76_desc *desc; struct mt76_desc *desc;
u32 ctrl;
int i, idx = -1; int i, idx = -1;
u32 ctrl, next;
for (i = 0; i < nbufs; i += 2, buf += 2) { for (i = 0; i < nbufs; i += 2, buf += 2) {
u32 buf0 = buf[0].addr, buf1 = 0; u32 buf0 = buf[0].addr, buf1 = 0;
idx = q->head; idx = q->head;
q->head = (q->head + 1) % q->ndesc; next = (q->head + 1) % q->ndesc;
desc = &q->desc[idx]; desc = &q->desc[idx];
entry = &q->entry[idx]; entry = &q->entry[idx];
...@@ -239,8 +239,8 @@ mt76_dma_add_buf(struct mt76_dev *dev, struct mt76_queue *q, ...@@ -239,8 +239,8 @@ mt76_dma_add_buf(struct mt76_dev *dev, struct mt76_queue *q,
MT_DMA_CTL_TO_HOST; MT_DMA_CTL_TO_HOST;
} else { } else {
if (txwi) { if (txwi) {
q->entry[q->head].txwi = DMA_DUMMY_DATA; q->entry[next].txwi = DMA_DUMMY_DATA;
q->entry[q->head].skip_buf0 = true; q->entry[next].skip_buf0 = true;
} }
if (buf[0].skip_unmap) if (buf[0].skip_unmap)
...@@ -271,6 +271,7 @@ mt76_dma_add_buf(struct mt76_dev *dev, struct mt76_queue *q, ...@@ -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->info, cpu_to_le32(info));
WRITE_ONCE(desc->ctrl, cpu_to_le32(ctrl)); WRITE_ONCE(desc->ctrl, cpu_to_le32(ctrl));
q->head = next;
q->queued++; q->queued++;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment