Skip to content

Commit cb6cc8e

Browse files
Furong Xukuba-moo
authored andcommitted
net: stmmac: Apply new page pool parameters when SPH is enabled
Commit df542f6 ("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]/ Reported-by: Jon Hunter <[email protected]> Reported-by: Brad Griffis <[email protected]> Suggested-by: Ido Schimmel <[email protected]> Fixes: df542f6 ("net: stmmac: Switch to zero-copy in non-XDP RX path") Signed-off-by: Furong Xu <[email protected]> Tested-by: Jon Hunter <[email protected]> Tested-by: Thierry Reding <[email protected]> Reviewed-by: Ido Schimmel <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 011b033 commit cb6cc8e

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

drivers/net/ethernet/stmicro/stmmac/stmmac_main.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2094,6 +2094,11 @@ static int __alloc_dma_rx_desc_resources(struct stmmac_priv *priv,
20942094
pp_params.offset = stmmac_rx_offset(priv);
20952095
pp_params.max_len = dma_conf->dma_buf_sz;
20962096

2097+
if (priv->sph) {
2098+
pp_params.offset = 0;
2099+
pp_params.max_len += stmmac_rx_offset(priv);
2100+
}
2101+
20972102
rx_q->page_pool = page_pool_create(&pp_params);
20982103
if (IS_ERR(rx_q->page_pool)) {
20992104
ret = PTR_ERR(rx_q->page_pool);

0 commit comments

Comments
 (0)