OSDN Git Service

mt76: set dma-done flag for flushed descriptors
authorFelix Fietkau <nbd@nbd.name>
Mon, 20 Jan 2020 11:07:09 +0000 (12:07 +0100)
committerFelix Fietkau <nbd@nbd.name>
Fri, 14 Feb 2020 09:06:06 +0000 (10:06 +0100)
Avoids a theoretical corner case where the hardware could try to process
a stale descriptor after a watchdog reset

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

index 9e03a78..e69329f 100644 (file)
@@ -246,7 +246,9 @@ mt76_dma_dequeue(struct mt76_dev *dev, struct mt76_queue *q, bool flush,
        if (!q->queued)
                return NULL;
 
-       if (!flush && !(q->desc[idx].ctrl & cpu_to_le32(MT_DMA_CTL_DMA_DONE)))
+       if (flush)
+               q->desc[idx].ctrl |= cpu_to_le32(MT_DMA_CTL_DMA_DONE);
+       else if (!(q->desc[idx].ctrl & cpu_to_le32(MT_DMA_CTL_DMA_DONE)))
                return NULL;
 
        q->tail = (q->tail + 1) % q->ndesc;