Skip to content

Commit 1132d1c

Browse files
LorenzoBianconiKalle Valo
authored andcommitted
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: cd372b8 ("wifi: mt76: add WED RX support to mt76_dma_{add,get}_buf") Signed-off-by: Lorenzo Bianconi <[email protected]> Signed-off-by: Felix Fietkau <[email protected]> (cherry picked from commit fe13dad) Signed-off-by: Kalle Valo <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent b870e73 commit 1132d1c

File tree

1 file changed

+5
-4
lines changed
  • drivers/net/wireless/mediatek/mt76

1 file changed

+5
-4
lines changed

drivers/net/wireless/mediatek/mt76/dma.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -212,14 +212,14 @@ mt76_dma_add_buf(struct mt76_dev *dev, struct mt76_queue *q,
212212
{
213213
struct mt76_queue_entry *entry;
214214
struct mt76_desc *desc;
215-
u32 ctrl;
216215
int i, idx = -1;
216+
u32 ctrl, next;
217217

218218
for (i = 0; i < nbufs; i += 2, buf += 2) {
219219
u32 buf0 = buf[0].addr, buf1 = 0;
220220

221221
idx = q->head;
222-
q->head = (q->head + 1) % q->ndesc;
222+
next = (q->head + 1) % q->ndesc;
223223

224224
desc = &q->desc[idx];
225225
entry = &q->entry[idx];
@@ -239,8 +239,8 @@ mt76_dma_add_buf(struct mt76_dev *dev, struct mt76_queue *q,
239239
MT_DMA_CTL_TO_HOST;
240240
} else {
241241
if (txwi) {
242-
q->entry[q->head].txwi = DMA_DUMMY_DATA;
243-
q->entry[q->head].skip_buf0 = true;
242+
q->entry[next].txwi = DMA_DUMMY_DATA;
243+
q->entry[next].skip_buf0 = true;
244244
}
245245

246246
if (buf[0].skip_unmap)
@@ -271,6 +271,7 @@ mt76_dma_add_buf(struct mt76_dev *dev, struct mt76_queue *q,
271271
WRITE_ONCE(desc->info, cpu_to_le32(info));
272272
WRITE_ONCE(desc->ctrl, cpu_to_le32(ctrl));
273273

274+
q->head = next;
274275
q->queued++;
275276
}
276277

0 commit comments

Comments
 (0)