arm: mach-k3: security: Use dma-mapping for cache ops
Subsystems (2)
PATCH 1/1 arm: mach-k3: security: Use dma-mapping for cache ops
This matches how this would be done in Linux and these functions do the alignment for us which makes the code look cleaner.
Signed-off-by Andrew Davis <[email protected]>
--- arch/arm/mach-k3/security.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-)
arch/arm/mach-k3/security.c +6 -8
@@ -18,6 +18,7 @@#include <mach/spl.h> #include <spl.h> #include <asm/arch/sys_proto.h> +#include <linux/dma-mapping.h> #include "common.h"
@@ -47,7 +48,6 @@ void ti_secure_image_post_process(void **p_image, size_t *p_size)u32 image_size;int ret; - image_addr = (uintptr_t )*p_image; image_size = *p_size;if (!image_size)
@@ -80,13 +80,12 @@ void ti_secure_image_post_process(void **p_image, size_t *p_size)return ; } +/* Clean out image so it can be seen by system firmware */ + image_addr =dma_map_single (*p_image, *p_size,DMA_BIDIRECTIONAL ); +debug ("Authenticating image at address 0x%016llx\n" , image_addr);debug ("Authenticating image of size %d bytes\n" , image_size); -flush_dcache_range ((unsigned long )image_addr, -ALIGN ((unsigned long )image_addr + image_size, -ARCH_DMA_MINALIGN )); -/* Authenticate image */ ret = proc_ops->proc_auth_boot_image (ti_sci, &image_addr, &image_size);if (ret) {
@@ -94,10 +93,9 @@ void ti_secure_image_post_process(void **p_image, size_t *p_size)hang (); } +/* Invalidate any stale lines over data written by system firmware */ if (image_size) -invalidate_dcache_range ((unsigned long )image_addr, -ALIGN ((unsigned long )image_addr + - image_size,ARCH_DMA_MINALIGN )); +dma_unmap_single (image_addr, image_size,DMA_BIDIRECTIONAL );/* * The image_size returned may be 0 when the authentication process has
Signature · 1 line
2.37.3
Quoted 4 lines · Andrew Davis
This matches how this would be done in Linux and these functions do the alignment for us which makes the code look cleaner.
Signed-off-by Andrew Davis <[email protected]>
Applied to u-boot/master, thanks!
Signature · 1 line
Tom