Re: [PATCH net-next v2] drivers: net: xgene: Fix dma_unmap_single() size
From: Andrew Lunn
Date: Thu Oct 15 2026 - 10:42:28 EST
On Thu, Oct 15, 2026 at 02:45:46PM +0200, Thomas Fourier wrote:
> In xgene_enet_refill_bufpool(), the skb->data is dma-mapped with length
> len which is set to XGENE_ENET_STD_MTU which equals 1536. However, in
> xgene_enet_delete_bufpool(), the same buffer is unmapped with length
> XGENE_ENET_MAX_MTU which is 9600. This may erroneously unmap other
> DMA buffers or cause other issues.
>
> Change unmap length to XGENE_ENET_STD_MTU.
I don't know this driver, so i could be wrong.....
map/unmap is expensive, because it needs to flush/invalidate the cache
etc. So the hot path part of the code, dealing with real frame data,
sometimes only maps/unmaps the length of the frame, which is less than
the length of the buffer, particularly when jumbo is involved.
So you could allocate a buffer for 9600 jumbo, but in the hot path
only map/unmap part of it, but when you release the buffer, you need
to unmap the full 9600 size of the buffer, to be on the safe size.
Please look at the driver and consider this. As i said, i could be
wrong...
Andrew