Skip to content

Commit 514aac3

Browse files
LorenzoBianconikuba-moo
authored andcommitted
net: airoha: Add missing cleanup bits in airoha_qdma_cleanup_rx_queue()
In order to properly cleanup hw rx QDMA queues and bring the device to the initial state, reset rx DMA queue head/tail index. Moreover, reset queued DMA descriptor fields. Fixes: 23020f0 ("net: airoha: Introduce ethernet support for EN7581 SoC") Tested-by: Madhur Agrawal <[email protected]> Signed-off-by: Lorenzo Bianconi <[email protected]> Link: https://patch.msgid.link/20260327-airoha_qdma_cleanup_rx_queue-fix-v1-1-369d6ab1511a@kernel.org Signed-off-by: Jakub Kicinski <[email protected]>
1 parent fd63f18 commit 514aac3

1 file changed

Lines changed: 17 additions & 1 deletion

File tree

drivers/net/ethernet/airoha/airoha_eth.c

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -794,18 +794,34 @@ static int airoha_qdma_init_rx_queue(struct airoha_queue *q,
794794

795795
static void airoha_qdma_cleanup_rx_queue(struct airoha_queue *q)
796796
{
797-
struct airoha_eth *eth = q->qdma->eth;
797+
struct airoha_qdma *qdma = q->qdma;
798+
struct airoha_eth *eth = qdma->eth;
799+
int qid = q - &qdma->q_rx[0];
798800

799801
while (q->queued) {
800802
struct airoha_queue_entry *e = &q->entry[q->tail];
803+
struct airoha_qdma_desc *desc = &q->desc[q->tail];
801804
struct page *page = virt_to_head_page(e->buf);
802805

803806
dma_sync_single_for_cpu(eth->dev, e->dma_addr, e->dma_len,
804807
page_pool_get_dma_dir(q->page_pool));
805808
page_pool_put_full_page(q->page_pool, page, false);
809+
/* Reset DMA descriptor */
810+
WRITE_ONCE(desc->ctrl, 0);
811+
WRITE_ONCE(desc->addr, 0);
812+
WRITE_ONCE(desc->data, 0);
813+
WRITE_ONCE(desc->msg0, 0);
814+
WRITE_ONCE(desc->msg1, 0);
815+
WRITE_ONCE(desc->msg2, 0);
816+
WRITE_ONCE(desc->msg3, 0);
817+
806818
q->tail = (q->tail + 1) % q->ndesc;
807819
q->queued--;
808820
}
821+
822+
q->head = q->tail;
823+
airoha_qdma_rmw(qdma, REG_RX_DMA_IDX(qid), RX_RING_DMA_IDX_MASK,
824+
FIELD_PREP(RX_RING_DMA_IDX_MASK, q->tail));
809825
}
810826

811827
static int airoha_qdma_init_rx(struct airoha_qdma *qdma)

0 commit comments

Comments
 (0)