summaryrefslogtreecommitdiff
path: root/drivers/crypto/fsl
diff options
context:
space:
mode:
authorTom Rini <trini@konsulko.com>2018-01-23 21:48:53 -0500
committerTom Rini <trini@konsulko.com>2018-01-23 21:48:53 -0500
commit16121280188d3daa57b18ad623d0845bbbb5a90a (patch)
tree1eced38d4dbbb8aa8813ed7095aedd06f0226ec1 /drivers/crypto/fsl
parenta516416d75a9b0f52e9d63d47f8a7bd53239767c (diff)
parent6c8945ec41cb7bff27fbacc88316e3e557c20240 (diff)
Merge git://git.denx.de/u-boot-fsl-qoriq
Diffstat (limited to 'drivers/crypto/fsl')
-rw-r--r--drivers/crypto/fsl/fsl_hash.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/drivers/crypto/fsl/fsl_hash.c b/drivers/crypto/fsl/fsl_hash.c
index a63eba389d..9373a39931 100644
--- a/drivers/crypto/fsl/fsl_hash.c
+++ b/drivers/crypto/fsl/fsl_hash.c
@@ -7,6 +7,7 @@
#include <common.h>
#include <malloc.h>
+#include <memalign.h>
#include "jobdesc.h"
#include "desc.h"
#include "jr.h"
@@ -163,20 +164,37 @@ int caam_hash(const unsigned char *pbuf, unsigned int buf_len,
{
int ret = 0;
uint32_t *desc;
+ unsigned int size;
- desc = malloc(sizeof(int) * MAX_CAAM_DESCSIZE);
+ desc = malloc_cache_aligned(sizeof(int) * MAX_CAAM_DESCSIZE);
if (!desc) {
debug("Not enough memory for descriptor allocation\n");
return -ENOMEM;
}
+ if (!IS_ALIGNED((uintptr_t)pbuf, ARCH_DMA_MINALIGN) ||
+ !IS_ALIGNED((uintptr_t)pout, ARCH_DMA_MINALIGN)) {
+ puts("Error: Address arguments are not aligned\n");
+ return -EINVAL;
+ }
+
+ size = ALIGN(buf_len, ARCH_DMA_MINALIGN);
+ flush_dcache_range((unsigned long)pbuf, (unsigned long)pbuf + size);
+
inline_cnstr_jobdesc_hash(desc, pbuf, buf_len, pout,
driver_hash[algo].alg_type,
driver_hash[algo].digestsize,
0);
+ size = ALIGN(sizeof(int) * MAX_CAAM_DESCSIZE, ARCH_DMA_MINALIGN);
+ flush_dcache_range((unsigned long)desc, (unsigned long)desc + size);
+
ret = run_descriptor_jr(desc);
+ size = ALIGN(driver_hash[algo].digestsize, ARCH_DMA_MINALIGN);
+ invalidate_dcache_range((unsigned long)pout,
+ (unsigned long)pout + size);
+
free(desc);
return ret;
}