mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Rouven Czerwinski <r.czerwinski@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Rouven Czerwinski <r.czerwinski@pengutronix.de>
Subject: [PATCH 2/2] crypto: caam: caamrng: map desc and buffer
Date: Thu,  7 Mar 2024 09:39:36 +0100	[thread overview]
Message-ID: <20240307083936.1195215-2-r.czerwinski@pengutronix.de> (raw)
In-Reply-To: <20240307083936.1195215-1-r.czerwinski@pengutronix.de>

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

Signed-off-by: Rouven Czerwinski <r.czerwinski@pengutronix.de>
---
 drivers/crypto/caam/caamrng.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/crypto/caam/caamrng.c b/drivers/crypto/caam/caamrng.c
index ea154913ca..1b5713f978 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,6 +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_map_single(jrdev, (void *)desc, desc_bytes(desc), DMA_TO_DEVICE);
 	dma_sync_single_for_device(jrdev, (unsigned long)desc, desc_bytes(desc),
 				   DMA_TO_DEVICE);
 
@@ -180,6 +182,7 @@ static inline int rng_create_sh_desc(struct caam_rng_ctx *ctx)
 
 	ctx->sh_desc_dma = (dma_addr_t)desc;
 
+	dma_map_single(ctx->jrdev, desc, desc_bytes(desc), DMA_TO_DEVICE);
 	dma_sync_single_for_device(ctx->jrdev, (unsigned long)desc, desc_bytes(desc),
 				   DMA_TO_DEVICE);
 
@@ -210,6 +213,7 @@ static int caam_init_buf(struct caam_rng_ctx *ctx, int buf_id)
 	int err;
 
 	bd->buf = dma_alloc_coherent(RN_BUF_SIZE, &bd->addr);
+	dma_map_single(ctx->jrdev, (void *)bd->addr, RN_BUF_SIZE, DMA_FROM_DEVICE);
 
 	err = rng_create_job_desc(ctx, buf_id);
 	if (err)
-- 
2.39.2




  reply	other threads:[~2024-03-07  8:40 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-07  8:39 [PATCH 1/2] crypto: caam: map DMA buffers before sync Rouven Czerwinski
2024-03-07  8:39 ` Rouven Czerwinski [this message]
2024-03-07  9:13   ` [PATCH 2/2] crypto: caam: caamrng: map desc and buffer Lucas Stach
2024-03-07  9:09 ` [PATCH 1/2] crypto: caam: map DMA buffers before sync Lucas Stach

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240307083936.1195215-2-r.czerwinski@pengutronix.de \
    --to=r.czerwinski@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox