diff mbox series

[U-Boot] u-boot: align cache flushes in load_elf_image_shdr to line boundaries

Message ID VI1PR0602MB36329D04835239CFF173B5C1A6320@VI1PR0602MB3632.eurprd06.prod.outlook.com
State Accepted
Delegated to: Tom Rini
Headers show
Series [U-Boot] u-boot: align cache flushes in load_elf_image_shdr to line boundaries | expand

Commit Message

Neil Stainton Aug. 20, 2018, 3:46 p.m. UTC
Prevent cache warning messages when using the 'bootelf' command on an Arm target. Round down each section start address and round up the respective section end to the nearest cache line.

---
Currently when using bootelf to load an image on Arm, several warnings such as the following appear in the console:
  CACHE: Misaligned operation at range [87800000, 8783c5e0]
  CACHE: Misaligned operation at range [8783c5e0, 8784b3e0]

Signed-off-by: Neil Stainton <nstainton at asl-control.co.uk>

---
 cmd/elf.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Tom Rini Aug. 24, 2018, 8:10 p.m. UTC | #1
On Mon, Aug 20, 2018 at 03:46:19PM +0000, Neil Stainton wrote:

> Prevent cache warning messages when using the 'bootelf' command on an Arm target. Round down each section start address and round up the respective section end to the nearest cache line.

Applied to u-boot/master, thanks!
diff mbox series

Patch

diff --git a/cmd/elf.c b/cmd/elf.c
index eafea38..1199e5d 100644
--- a/cmd/elf.c
+++ b/cmd/elf.c
@@ -141,7 +141,9 @@  static unsigned long load_elf_image_shdr(unsigned long addr)
                        memcpy((void *)(uintptr_t)shdr->sh_addr,
                               (const void *)image, shdr->sh_size);
                }
-               flush_cache(shdr->sh_addr, shdr->sh_size);
+               flush_cache(rounddown(shdr->sh_addr, ARCH_DMA_MINALIGN),
+                       roundup((shdr->sh_addr + shdr->sh_size), ARCH_DMA_MINALIGN) -
+                               rounddown(shdr->sh_addr, ARCH_DMA_MINALIGN));
        }
 
        return ehdr->e_entry;