summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOleksij Rempel <o.rempel@pengutronix.de>2017-03-22 10:14:37 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2017-03-30 08:23:20 +0200
commitef4144b4ab6301d7417af3eb4d79cfc66bf0e731 (patch)
treeec4cbb3881a8265937bf18acc066541e415c1ff5
parent35ca79bb22b64c4fc78691743ce42379c29fd247 (diff)
downloadbarebox-ef4144b4ab6301d7417af3eb4d79cfc66bf0e731.tar.gz
barebox-ef4144b4ab6301d7417af3eb4d79cfc66bf0e731.tar.xz
crypto: caam - fix RNG buffer cache alignment
this is alternate version of linux fix: --------------------------------------------------------------------- | commit 412c98c1bef65fe7589f1300e93735d96130307c | Author: Steve Cornelius <steve.cornelius@freescale.com> | Date: Mon Jun 15 16:52:59 2015 -0700 | | crypto: caam - fix RNG buffer cache alignment | | The hwrng output buffers (2) are cast inside of a a struct (caam_rng_ctx) | allocated in one DMA-tagged region. While the kernel's heap allocator | should place the overall struct on a cacheline aligned boundary, the 2 | buffers contained within may not necessarily align. Consenquently, the | ends of unaligned buffers may not fully flush, and if so, stale data will be | left behind, resulting in small repeating patterns. | | This fix aligns the buffers inside the struct. | | Note that not all of the data inside caam_rng_ctx necessarily needs to | be DMA-tagged, only the buffers themselves require this. However, a fix | would incur the expense of error-handling bloat in the case of allocation | failure. | | Cc: stable@vger.kernel.org | Signed-off-by: Steve Cornelius <steve.cornelius@freescale.com> | Signed-off-by: Victoria Milhoan <vicki.milhoan@freescale.com> | Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> --------------------------------------------------------------------- instead we will use just dma_alloc() Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-rw-r--r--drivers/crypto/caam/caamrng.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/drivers/crypto/caam/caamrng.c b/drivers/crypto/caam/caamrng.c
index aabad04164..31a92731d2 100644
--- a/drivers/crypto/caam/caamrng.c
+++ b/drivers/crypto/caam/caamrng.c
@@ -55,7 +55,7 @@
/* Buffer, its dma address and lock */
struct buf_data {
- u8 buf[RN_BUF_SIZE];
+ u8 *buf;
dma_addr_t addr;
u32 hw_desc[DESC_JOB_O_LEN];
#define BUF_NOT_EMPTY 0
@@ -218,6 +218,8 @@ 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);
+
err = rng_create_job_desc(ctx, buf_id);
if (err)
return err;