[PATCH net] net: stmmac: fix the crash issue for zero copy XDP_TX action
Hariprasad Kelam
hkelam at marvell.com
Wed Dec 17 22:21:42 PST 2025
On 2025-12-17 at 18:19:19, Wei Fang (wei.fang at nxp.com) wrote:
> > > - res = stmmac_xdp_xmit_xdpf(priv, queue, xdpf, false);
> > > - if (res == STMMAC_XDP_TX)
> > > + /* For zero copy XDP_TX action, dma_map is true */
> > > + res = stmmac_xdp_xmit_xdpf(priv, queue, xdpf, zc);
> > Seems stmmac_xdp_xmit_xdpf is using dma_map_single if we pass zc is
> > true.
> > Ideally in case of zc, driver can use page_pool_get_dma_addr, may be
> > you
> > need pass zc param as false. Please check
> >
>
> No, the memory type of xdpf->data is MEM_TYPE_PAGE_ORDER0 rather
> than MEM_TYPE_PAGE_POOL, so we should use dma_map_single().
> Otherwise, it will lead to invalid mappings and cause the crash.
>
>
ACK, found below code bit confusing
case STMMAC_XDP_CONSUMED:
xsk_buff_free(buf->xdp);
+ fallthrough;
+ case STMMAC_XSK_CONSUMED:
rx_dropped++;
Ideally in case of STMMAC_XSK_CONSUMED, driver needs to call xsk_buff_free.
And in case of STMMAC_XDP_CONSUMED, driver needs to call xdp_return_frame.
May be you can move all buffer free logic to stmmac_rx_zc with above suggested
changes.
More information about the linux-arm-kernel
mailing list