[PATCH v2 2/2] crypto: caam: caamrng: dma map descriptors

Rouven Czerwinski r.czerwinski at pengutronix.de
Thu Mar 7 23:35:18 PST 2024


With DMA API debugging Barebox complains that the descriptors are never
mapped before a sync. Add the map and unmap function calls.

Signed-off-by: Rouven Czerwinski <r.czerwinski at pengutronix.de>
---
v2:
- remove dma_map_sync_single_for_device() calls
- remove dma_map_single for dma coherent memory

 drivers/crypto/caam/caamrng.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/crypto/caam/caamrng.c b/drivers/crypto/caam/caamrng.c
index ea154913ca..03e75d0b7b 100644
--- a/drivers/crypto/caam/caamrng.c
+++ b/drivers/crypto/caam/caamrng.c
@@ -91,6 +91,7 @@ static void rng_done(struct device *jrdev, u32 *desc, u32 err, void *context)
 
 	/* Buffer refilled, invalidate cache */
 	dma_sync_single_for_cpu(jrdev, bd->addr, RN_BUF_SIZE, DMA_FROM_DEVICE);
+	dma_unmap_single(jrdev, (unsigned long)desc, desc_bytes(desc), DMA_TO_DEVICE);
 }
 
 static inline int submit_job(struct caam_rng_ctx *ctx, int to_current)
@@ -102,8 +103,7 @@ static inline int submit_job(struct caam_rng_ctx *ctx, int to_current)
 
 	dev_dbg(jrdev, "submitting job %d\n", !(to_current ^ ctx->current_buf));
 
-	dma_sync_single_for_device(jrdev, (unsigned long)desc, desc_bytes(desc),
-				   DMA_TO_DEVICE);
+	dma_map_single(jrdev, (void *)desc, desc_bytes(desc), DMA_TO_DEVICE);
 
 	err = caam_jr_enqueue(jrdev, desc, rng_done, ctx);
 	if (!err)
@@ -180,8 +180,7 @@ static inline int rng_create_sh_desc(struct caam_rng_ctx *ctx)
 
 	ctx->sh_desc_dma = (dma_addr_t)desc;
 
-	dma_sync_single_for_device(ctx->jrdev, (unsigned long)desc, desc_bytes(desc),
-				   DMA_TO_DEVICE);
+	dma_map_single(ctx->jrdev, desc, desc_bytes(desc), DMA_TO_DEVICE);
 
 	print_hex_dump_debug("rng shdesc@: ", DUMP_PREFIX_OFFSET, 16, 4,
 		       desc, desc_bytes(desc), 1);
-- 
2.39.2




More information about the barebox mailing list