mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Lucas Stach <l.stach@pengutronix.de>
To: Oleksij Rempel <o.rempel@pengutronix.de>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH v2] crypto: caam: use dma_alloc_coherent instead of dma_alloc
Date: Wed, 12 Jul 2017 16:54:48 +0200	[thread overview]
Message-ID: <1499871288.5060.118.camel@pengutronix.de> (raw)
In-Reply-To: <20170712044028.9309-2-o.rempel@pengutronix.de>

Am Mittwoch, den 12.07.2017, 06:40 +0200 schrieb Oleksij Rempel:
> It is a fixup for following patch:
> | commit ef4144b4ab6301d7417af3eb4d79cfc66bf0e731
> | Date:   Wed Mar 22 10:14:37 2017 +0100
> |
> |    crypto: caam - fix RNG buffer cache alignment
> 
> Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>

Thanks. I've applied this patch with the commit message changed to the
following, to add a bit more information about the failure this is
fixing:

crypto: caam: use dma_alloc_coherent instead of dma_alloc

dma_alloc return non-coherent memory, but the driver does no cache
maintenance on the buffer, causing memory corruption. Fix this by
requesting coherent memory for the DMA transfer.

Fixes: ef4144b4ab63 (crypto: caam - fix RNG buffer cache alignment)

> ---
>  drivers/crypto/caam/caamrng.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/drivers/crypto/caam/caamrng.c b/drivers/crypto/caam/caamrng.c
> index 31a92731d2..51c267e3d3 100644
> --- a/drivers/crypto/caam/caamrng.c
> +++ b/drivers/crypto/caam/caamrng.c
> @@ -203,8 +203,6 @@ static inline int rng_create_job_desc(struct caam_rng_ctx *ctx, int buf_id)
>  	init_job_desc_shared(desc, ctx->sh_desc_dma, sh_len, HDR_SHARE_DEFER |
>  			     HDR_REVERSE);
>  
> -	bd->addr = (dma_addr_t)bd->buf;
> -
>  	append_seq_out_ptr_intlen(desc, bd->addr, RN_BUF_SIZE, 0);
>  #ifdef DEBUG
>  	print_hex_dump(KERN_ERR, "rng job desc@: ", DUMP_PREFIX_OFFSET, 16, 4,
> @@ -218,7 +216,7 @@ static int caam_init_buf(struct caam_rng_ctx *ctx, int buf_id)
>  	struct buf_data *bd = &ctx->bufs[buf_id];
>  	int err;
>  
> -	bd->buf = dma_alloc(RN_BUF_SIZE);
> +	bd->buf = dma_alloc_coherent(RN_BUF_SIZE, &bd->addr);
>  
>  	err = rng_create_job_desc(ctx, buf_id);
>  	if (err)



_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  reply	other threads:[~2017-07-12 14:55 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-12  4:40 [PATCH v1] " Oleksij Rempel
2017-07-12  4:40 ` [PATCH v2] " Oleksij Rempel
2017-07-12 14:54   ` Lucas Stach [this message]
2017-07-12  4:41 ` [PATCH v1] " Oleksij Rempel

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=1499871288.5060.118.camel@pengutronix.de \
    --to=l.stach@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=o.rempel@pengutronix.de \
    /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