net: stmmac: Apply new page pool parameters when SPH is enabled
Subsystems (5)
PATCH 1/1 net: stmmac: Apply new page pool parameters when SPH is enabled
Commit df542f669307 ("net: stmmac: Switch to zero-copy in non-XDP RX path") makes DMA write received frame into buffer at offset of NET_SKB_PAD and sets page pool parameters to sync from offset of NET_SKB_PAD. But when Header Payload Split is enabled, the header is written at offset of NET_SKB_PAD, while the payload is written at offset of zero. Uncorrect offset parameter for the payload breaks dma coherence [1] since both CPU and DMA touch the page buffer from offset of zero which is not handled by the page pool sync parameter.
And in case the DMA cannot split the received frame, for example, a large L2 frame, pp_params.max_len should grow to match the tail of entire frame.
[1] https://lore.kernel.org/netdev/[email protected]/
--- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +5 -0
@@ -2094,6 +2094,11 @@ static int __alloc_dma_rx_desc_resources(struct stmmac_priv *priv, pp_params.offset =stmmac_rx_offset (priv); pp_params.max_len = dma_conf->dma_buf_sz; +if (priv->sph) { + pp_params.offset =0 ; + pp_params.max_len +=stmmac_rx_offset (priv); + } + rx_q->page_pool =page_pool_create (&pp_params);if (IS_ERR (rx_q->page_pool)) { ret =PTR_ERR (rx_q->page_pool);
Signature · 1 line
2.34.1
Hi Furong,
Quoted 30 lines · Furong Xu
Commit
df542f669307("net: stmmac: Switch to zero-copy in non-XDP RX path") makes DMA write received frame into buffer at offset ofNET_SKB_PADand sets page pool parameters to sync from offset ofNET_SKB_PAD. But when Header Payload Split is enabled, the header is written at offset ofNET_SKB_PAD, while the payload is written at offset of zero. Uncorrect offset parameter for the payload breaks dma coherence [1] since both CPU and DMA touch the page buffer from offset of zero which is not handled by the page pool sync parameter.And in case the DMA cannot split the received frame, for example, a large L2 frame, pp_params.max_len should grow to match the tail of entire frame.
[1] https://lore.kernel.org/netdev/[email protected]/
Reported-by Jon Hunter <[email protected]>Reported-by Brad Griffis <[email protected]>Suggested-by Ido Schimmel <[email protected]>Fixes df542f669307 ("net: stmmac: Switch to zero-copy in non-XDP RX path")Signed-off-by Furong Xu <[email protected]>--- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 5 +++++ 1 file changed, 5 insertions(+)drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +0
-0@@ -2094,6 +2094,11 @@ static int __alloc_dma_rx_desc_resources(struct stmmac_priv *priv, pp_params.offset =stmmac_rx_offset (priv);
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c static int __alloc_dma_rx_desc_resources(struct stmmac_priv *priv, · line 2104
Quoted 10 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +5
-0pp_params.max_len = dma_conf->dma_buf_sz; +if (priv->sph) { + pp_params.offset =0 ; + pp_params.max_len +=stmmac_rx_offset (priv); + } + rx_q->page_pool =page_pool_create (&pp_params);if (IS_ERR (rx_q->page_pool)) { ret =PTR_ERR (rx_q->page_pool);
Thanks for sending this. I can confirm that it fixes the issue we are seeing and so ...
Cheers
Jon
Signature · 1 line
nvpublic
Thierry Reding
Tested-byQuoted 47 lines · Jon Hunter
Hi Furong,
Quoted 29 lines · Furong Xu
Commit
df542f669307("net: stmmac: Switch to zero-copy in non-XDP RX path") makes DMA write received frame into buffer at offset ofNET_SKB_PADand sets page pool parameters to sync from offset ofNET_SKB_PAD. But when Header Payload Split is enabled, the header is written at offset ofNET_SKB_PAD, while the payload is written at offset of zero. Uncorrect offset parameter for the payload breaks dma coherence [1] since both CPU and DMA touch the page buffer from offset of zero which is not handled by the page pool sync parameter.And in case the DMA cannot split the received frame, for example, a large L2 frame, pp_params.max_len should grow to match the tail of entire frame.
[1] https://lore.kernel.org/netdev/[email protected]/
Reported-by Jon Hunter <[email protected]>Reported-by Brad Griffis <[email protected]>Suggested-by Ido Schimmel <[email protected]>Fixes df542f669307 ("net: stmmac: Switch to zero-copy in non-XDP RX path")Signed-off-by Furong Xu <[email protected]>--- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 5 +++++ 1 file changed, 5 insertions(+)drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +0
-0drivers/net/ethernet/stmicro/stmmac/stmmac_main.c static int __alloc_dma_rx_desc_resources(struct stmmac_priv *priv, · line 2103
Quoted 10 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +5
-0@@ -2094,6 +2094,11 @@ static int __alloc_dma_rx_desc_resources(struct stmmac_priv *priv, pp_params.offset =stmmac_rx_offset (priv); pp_params.max_len = dma_conf->dma_buf_sz; +if (priv->sph) { + pp_params.offset =0 ; + pp_params.max_len +=stmmac_rx_offset (priv); + } + rx_q->page_pool =page_pool_create (&pp_params);if (IS_ERR (rx_q->page_pool)) { ret =PTR_ERR (rx_q->page_pool);Thanks for sending this. I can confirm that it fixes the issue we are seeing and so ...
Quoted 1 line
Tested-by Jon Hunter <[email protected]>
Yes, I can confirm as well. I've tested based on the discussion in the earlier thread and had the equivalent of this patch (modulo the ->sph check, but that's always true on this system), so:
Quoted 13 lines · Furong Xu
Commit
df542f669307("net: stmmac: Switch to zero-copy in non-XDP RX path") makes DMA write received frame into buffer at offset ofNET_SKB_PADand sets page pool parameters to sync from offset ofNET_SKB_PAD. But when Header Payload Split is enabled, the header is written at offset ofNET_SKB_PAD, while the payload is written at offset of zero. Uncorrect offset parameter for the payload breaks dma coherence [1] since both CPU and DMA touch the page buffer from offset of zero which is not handled by the page pool sync parameter.And in case the DMA cannot split the received frame, for example, a large L2 frame, pp_params.max_len should grow to match the tail of entire frame.
Quoted 7 lines
[1] https://lore.kernel.org/netdev/[email protected]/
Reported-by Jon Hunter <[email protected]>Reported-by Brad Griffis <[email protected]>Suggested-by Ido Schimmel <[email protected]>Fixes df542f669307 ("net: stmmac: Switch to zero-copy in non-XDP RX path")Signed-off-by Furong Xu <[email protected]>
This patch was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:
Quoted 10 lines · On Fri, 7 Feb 2025 16:56:39 +0800 you wrote:
Commit
df542f669307("net: stmmac: Switch to zero-copy in non-XDP RX path") makes DMA write received frame into buffer at offset ofNET_SKB_PADand sets page pool parameters to sync from offset ofNET_SKB_PAD. But when Header Payload Split is enabled, the header is written at offset ofNET_SKB_PAD, while the payload is written at offset of zero. Uncorrect offset parameter for the payload breaks dma coherence [1] since both CPU and DMA touch the page buffer from offset of zero which is not handled by the page pool sync parameter.[...]
Here is the summary with links:
- [net,v1] net: stmmac: Apply new page pool parameters when SPH is enabled
https://git.kernel.org/netdev/net/c/cb6cc8ed7717
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html