Skip to content

Commit 3309965

Browse files
LorenzoBianconiPaolo Abeni
authored andcommitted
net: airoha: Add missing bits in airoha_qdma_cleanup_tx_queue()
Similar to airoha_qdma_cleanup_rx_queue(), reset DMA TX descriptors in airoha_qdma_cleanup_tx_queue routine. Moreover, reset TX_DMA_IDX to TX_CPU_IDX to notify the NIC the QDMA TX ring is empty. Fixes: 23020f0 ("net: airoha: Introduce ethernet support for EN7581 SoC") Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> Link: https://patch.msgid.link/20260417-airoha_qdma_cleanup_tx_queue-fix-net-v4-2-e04bcc2c9642@kernel.org Reviewed-by: Simon Horman <horms@kernel.org> Signed-off-by: Paolo Abeni <pabeni@redhat.com>
1 parent f329924 commit 3309965

1 file changed

Lines changed: 30 additions & 2 deletions

File tree

drivers/net/ethernet/airoha/airoha_eth.c

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1063,12 +1063,15 @@ static int airoha_qdma_init_tx(struct airoha_qdma *qdma)
10631063

10641064
static void airoha_qdma_cleanup_tx_queue(struct airoha_queue *q)
10651065
{
1066-
struct airoha_eth *eth = q->qdma->eth;
1067-
int i;
1066+
struct airoha_qdma *qdma = q->qdma;
1067+
struct airoha_eth *eth = qdma->eth;
1068+
int i, qid = q - &qdma->q_tx[0];
1069+
u16 index = 0;
10681070

10691071
spin_lock_bh(&q->lock);
10701072
for (i = 0; i < q->ndesc; i++) {
10711073
struct airoha_queue_entry *e = &q->entry[i];
1074+
struct airoha_qdma_desc *desc = &q->desc[i];
10721075

10731076
if (!e->dma_addr)
10741077
continue;
@@ -1079,8 +1082,33 @@ static void airoha_qdma_cleanup_tx_queue(struct airoha_queue *q)
10791082
e->dma_addr = 0;
10801083
e->skb = NULL;
10811084
list_add_tail(&e->list, &q->tx_list);
1085+
1086+
/* Reset DMA descriptor */
1087+
WRITE_ONCE(desc->ctrl, 0);
1088+
WRITE_ONCE(desc->addr, 0);
1089+
WRITE_ONCE(desc->data, 0);
1090+
WRITE_ONCE(desc->msg0, 0);
1091+
WRITE_ONCE(desc->msg1, 0);
1092+
WRITE_ONCE(desc->msg2, 0);
1093+
10821094
q->queued--;
10831095
}
1096+
1097+
if (!list_empty(&q->tx_list)) {
1098+
struct airoha_queue_entry *e;
1099+
1100+
e = list_first_entry(&q->tx_list, struct airoha_queue_entry,
1101+
list);
1102+
index = e - q->entry;
1103+
}
1104+
/* Set TX_DMA_IDX to TX_CPU_IDX to notify the hw the QDMA TX ring is
1105+
* empty.
1106+
*/
1107+
airoha_qdma_rmw(qdma, REG_TX_CPU_IDX(qid), TX_RING_CPU_IDX_MASK,
1108+
FIELD_PREP(TX_RING_CPU_IDX_MASK, index));
1109+
airoha_qdma_rmw(qdma, REG_TX_DMA_IDX(qid), TX_RING_DMA_IDX_MASK,
1110+
FIELD_PREP(TX_RING_DMA_IDX_MASK, index));
1111+
10841112
spin_unlock_bh(&q->lock);
10851113
}
10861114

0 commit comments

Comments
 (0)