* [PATCH net] net: airoha: Fix page recycling in airoha_qdma_rx_process()
@ 2025-05-13 16:34 Lorenzo Bianconi
2025-05-15 2:09 ` Jakub Kicinski
0 siblings, 1 reply; 3+ messages in thread
From: Lorenzo Bianconi @ 2025-05-13 16:34 UTC (permalink / raw)
To: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Simon Horman
Cc: linux-arm-kernel, linux-mediatek, netdev
Do not recycle the page twice in airoha_qdma_rx_process routine in case
of error. Just run dev_kfree_skb() if the skb has been allocated and marked
for recycling. Run page_pool_put_full_page() directly if the skb has not
been allocated yet.
Moreover, rely on DMA address from queue entry element instead of reading
it from the DMA descriptor for DMA syncing in airoha_qdma_rx_process().
Fixes: e12182ddb6e71 ("net: airoha: Enable Rx Scatter-Gather")
---
drivers/net/ethernet/airoha/airoha_eth.c | 22 +++++++++-------------
1 file changed, 9 insertions(+), 13 deletions(-)
diff --git a/drivers/net/ethernet/airoha/airoha_eth.c b/drivers/net/ethernet/airoha/airoha_eth.c
index d748dc6de92367365db9f9548f9af52a7fdac187..1e9ab65218ff144d99b47f5d4ad5ff4f9c227418 100644
--- a/drivers/net/ethernet/airoha/airoha_eth.c
+++ b/drivers/net/ethernet/airoha/airoha_eth.c
@@ -614,7 +614,6 @@ static int airoha_qdma_rx_process(struct airoha_queue *q, int budget)
struct airoha_queue_entry *e = &q->entry[q->tail];
struct airoha_qdma_desc *desc = &q->desc[q->tail];
u32 hash, reason, msg1 = le32_to_cpu(desc->msg1);
- dma_addr_t dma_addr = le32_to_cpu(desc->addr);
struct page *page = virt_to_head_page(e->buf);
u32 desc_ctrl = le32_to_cpu(desc->ctrl);
struct airoha_gdm_port *port;
@@ -623,22 +622,16 @@ static int airoha_qdma_rx_process(struct airoha_queue *q, int budget)
if (!(desc_ctrl & QDMA_DESC_DONE_MASK))
break;
- if (!dma_addr)
- break;
-
- len = FIELD_GET(QDMA_DESC_LEN_MASK, desc_ctrl);
- if (!len)
- break;
-
q->tail = (q->tail + 1) % q->ndesc;
q->queued--;
- dma_sync_single_for_cpu(eth->dev, dma_addr,
+ dma_sync_single_for_cpu(eth->dev, e->dma_addr,
SKB_WITH_OVERHEAD(q->buf_size), dir);
+ len = FIELD_GET(QDMA_DESC_LEN_MASK, desc_ctrl);
data_len = q->skb ? q->buf_size
: SKB_WITH_OVERHEAD(q->buf_size);
- if (data_len < len)
+ if (!len || data_len < len)
goto free_frag;
p = airoha_qdma_get_gdm_port(eth, desc);
@@ -701,9 +694,12 @@ static int airoha_qdma_rx_process(struct airoha_queue *q, int budget)
q->skb = NULL;
continue;
free_frag:
- page_pool_put_full_page(q->page_pool, page, true);
- dev_kfree_skb(q->skb);
- q->skb = NULL;
+ if (q->skb) {
+ dev_kfree_skb(q->skb);
+ q->skb = NULL;
+ } else {
+ page_pool_put_full_page(q->page_pool, page, true);
+ }
}
airoha_qdma_fill_rx_queue(q);
---
base-commit: 4227ea91e2657f7965e34313448e9d0a2b67712e
change-id: 20250513-airoha-fix-rx-process-error-condition-b6e5db52fd4f
Best regards,
--
Lorenzo Bianconi <lorenzo@kernel.org>
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH net] net: airoha: Fix page recycling in airoha_qdma_rx_process()
2025-05-13 16:34 [PATCH net] net: airoha: Fix page recycling in airoha_qdma_rx_process() Lorenzo Bianconi
@ 2025-05-15 2:09 ` Jakub Kicinski
2025-05-15 6:33 ` Lorenzo Bianconi
0 siblings, 1 reply; 3+ messages in thread
From: Jakub Kicinski @ 2025-05-15 2:09 UTC (permalink / raw)
To: Lorenzo Bianconi
Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Paolo Abeni,
Simon Horman, linux-arm-kernel, linux-mediatek, netdev
On Tue, 13 May 2025 18:34:44 +0200 Lorenzo Bianconi wrote:
> Do not recycle the page twice in airoha_qdma_rx_process routine in case
> of error. Just run dev_kfree_skb() if the skb has been allocated and marked
> for recycling. Run page_pool_put_full_page() directly if the skb has not
> been allocated yet.
> Moreover, rely on DMA address from queue entry element instead of reading
> it from the DMA descriptor for DMA syncing in airoha_qdma_rx_process().
>
> Fixes: e12182ddb6e71 ("net: airoha: Enable Rx Scatter-Gather")
Missed your sign-off.
--
pw-bot: cr
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH net] net: airoha: Fix page recycling in airoha_qdma_rx_process()
2025-05-15 2:09 ` Jakub Kicinski
@ 2025-05-15 6:33 ` Lorenzo Bianconi
0 siblings, 0 replies; 3+ messages in thread
From: Lorenzo Bianconi @ 2025-05-15 6:33 UTC (permalink / raw)
To: Jakub Kicinski
Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Paolo Abeni,
Simon Horman, linux-arm-kernel, linux-mediatek, netdev
[-- Attachment #1: Type: text/plain, Size: 655 bytes --]
> On Tue, 13 May 2025 18:34:44 +0200 Lorenzo Bianconi wrote:
> > Do not recycle the page twice in airoha_qdma_rx_process routine in case
> > of error. Just run dev_kfree_skb() if the skb has been allocated and marked
> > for recycling. Run page_pool_put_full_page() directly if the skb has not
> > been allocated yet.
> > Moreover, rely on DMA address from queue entry element instead of reading
> > it from the DMA descriptor for DMA syncing in airoha_qdma_rx_process().
> >
> > Fixes: e12182ddb6e71 ("net: airoha: Enable Rx Scatter-Gather")
>
> Missed your sign-off.
ops, let me fix it in v2.
Regards,
Lorenzo
> --
> pw-bot: cr
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-05-15 6:49 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-13 16:34 [PATCH net] net: airoha: Fix page recycling in airoha_qdma_rx_process() Lorenzo Bianconi
2025-05-15 2:09 ` Jakub Kicinski
2025-05-15 6:33 ` Lorenzo Bianconi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).