[PATCH RESEND] crypto: sun8i-ss: do not use sg_dma_len before calling DMA functions

Herbert Xu herbert at gondor.apana.org.au
Sun Apr 27 20:08:49 PDT 2025


On Sun, Apr 27, 2025 at 09:23:40PM +0300, Ovidiu Panait wrote:
> 
> On the other hand, multi_v7_defconfig has CONFIG_NEED_SG_DMA_LENGTH
> enabled, so sg_dma_len(sg) defaults to sg->dma_length and it would need
> to be used after calling dma_map_sg() (as indicated in the comment from
> include/linux/scatterlist.h).

In general, only use sg_dma_len if you are mapping an entire
SG list with dma_map_sg.

If you're using dma_map_single, do not use sg_dma_len.

This is because dma_map_sg will try to merge entries together,
thus creating an sg_dma_len that is bigger than the original
(and reducing the SG list length accordingly).

OTOH dma_map_single can't possibly do that.

Cheers,
-- 
Email: Herbert Xu <herbert at gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt



More information about the linux-arm-kernel mailing list