Skip to content

Commit 084a39a

Browse files
author
Paolo Abeni
committed
Merge branch 'net-airoha-fix-airoha_qdma_cleanup_tx_queue-processing'
Lorenzo Bianconi says: ==================== net: airoha: Fix airoha_qdma_cleanup_tx_queue() processing Add missing bits in airoha_qdma_cleanup_tx_queue routine. Fix airoha_qdma_cleanup_tx_queue processing errors intorduced in commit '3f47e67dff1f7 ("net: airoha: Add the capability to consume out-of-order DMA tx descriptors")'. v3: https://lore.kernel.org/r/20260416-airoha_qdma_cleanup_tx_queue-fix-net-v3-0-2b69f5788580@kernel.org v2: https://lore.kernel.org/r/20260414-airoha_qdma_cleanup_tx_queue-fix-net-v2-1-875de57cc022@kernel.org v1: https://lore.kernel.org/r/20260410-airoha_qdma_cleanup_tx_queue-fix-net-v1-1-b7171c8f1e78@kernel.org ==================== Link: https://patch.msgid.link/20260417-airoha_qdma_cleanup_tx_queue-fix-net-v4-0-e04bcc2c9642@kernel.org Signed-off-by: Paolo Abeni <pabeni@redhat.com>
2 parents 1ada03f + 3309965 commit 084a39a

1 file changed

Lines changed: 34 additions & 6 deletions

File tree

drivers/net/ethernet/airoha/airoha_eth.c

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -978,27 +978,27 @@ static int airoha_qdma_init_tx_queue(struct airoha_queue *q,
978978
dma_addr_t dma_addr;
979979

980980
spin_lock_init(&q->lock);
981-
q->ndesc = size;
982981
q->qdma = qdma;
983982
q->free_thr = 1 + MAX_SKB_FRAGS;
984983
INIT_LIST_HEAD(&q->tx_list);
985984

986-
q->entry = devm_kzalloc(eth->dev, q->ndesc * sizeof(*q->entry),
985+
q->entry = devm_kzalloc(eth->dev, size * sizeof(*q->entry),
987986
GFP_KERNEL);
988987
if (!q->entry)
989988
return -ENOMEM;
990989

991-
q->desc = dmam_alloc_coherent(eth->dev, q->ndesc * sizeof(*q->desc),
990+
q->desc = dmam_alloc_coherent(eth->dev, size * sizeof(*q->desc),
992991
&dma_addr, GFP_KERNEL);
993992
if (!q->desc)
994993
return -ENOMEM;
995994

996-
for (i = 0; i < q->ndesc; i++) {
995+
for (i = 0; i < size; i++) {
997996
u32 val = FIELD_PREP(QDMA_DESC_DONE_MASK, 1);
998997

999998
list_add_tail(&q->entry[i].list, &q->tx_list);
1000999
WRITE_ONCE(q->desc[i].ctrl, cpu_to_le32(val));
10011000
}
1001+
q->ndesc = size;
10021002

10031003
/* xmit ring drop default setting */
10041004
airoha_qdma_set(qdma, REG_TX_RING_BLOCKING(qid),
@@ -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)