[PATCH 1/2] crypto: caam: map DMA buffers before sync

Lucas Stach l.stach at pengutronix.de
Thu Mar 7 01:09:24 PST 2024


Am Donnerstag, dem 07.03.2024 um 09:39 +0100 schrieb Rouven Czerwinski:
> With dma api debugging enabled, Barebox complains correctly that the
> result and desc buffer are never mapped correctly. Add the correct map
> and unmap sequence.
> 
> Signed-off-by: Rouven Czerwinski <r.czerwinski at pengutronix.de>
> ---
>  drivers/crypto/caam/rng_self_test.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/drivers/crypto/caam/rng_self_test.c b/drivers/crypto/caam/rng_self_test.c
> index b6fcc3bc09..f5ab974a98 100644
> --- a/drivers/crypto/caam/rng_self_test.c
> +++ b/drivers/crypto/caam/rng_self_test.c
> @@ -186,6 +186,8 @@ int caam_rng_self_test(struct device *dev, const u8 caam_era, const u8 rngvid,
>  
>  	construct_rng_self_test_jobdesc(desc, rng_st_dsc, result, desc_size);
>  
> +	dma_map_single(dev, desc, desc_size * sizeof(*desc), DMA_TO_DEVICE);
> +	dma_map_single(dev, result, result_size * sizeof(*result), DMA_FROM_DEVICE);
>  	dma_sync_single_for_device(dev, (unsigned long)desc,
>  			desc_size * sizeof(*desc), DMA_TO_DEVICE);
>  	dma_sync_single_for_device(dev, (unsigned long)result,

While harmless, those syncs are not needed anymore after the dma_map is
added, as they do the same cache maintenance operations as the map
right before.

Regards,
Lucas

> @@ -218,6 +220,8 @@ int caam_rng_self_test(struct device *dev, const u8 caam_era, const u8 rngvid,
>  	ret = 0;
>  
>  err:
> +	dma_unmap_single(dev, (dma_addr_t)desc, desc_size * sizeof(*desc), DMA_TO_DEVICE);
> +	dma_unmap_single(dev, (dma_addr_t)result, result_size * sizeof(*result), DMA_FROM_DEVICE);
>  	dma_free(desc);
>  	dma_free(result);
>  	return ret;




More information about the barebox mailing list