[U-Boot] [PATCH 0/3] arm: K3: Make sure to clean caches before jumping to Linux

This series make sure that on K3 devices, Linux image is completely written to DDR from L3 and then control is given to Linux from U-Boot.
Lokesh Vutla (3): boot: arm: Enable support for custom board_prep_linux cmd: booti: Store OS start and end info in images structure arm: K3: Clean and invalidate Linux Image before jumping to Linux
arch/arm/lib/bootm.c | 4 ++++ arch/arm/mach-k3/common.c | 11 +++++++++++ cmd/booti.c | 3 +++ 3 files changed, 18 insertions(+)

Once the arch specific boot_prepare_linux completes, boards wants to have a custom preparation for linux. Add support for a custom board_prep_linux.
Signed-off-by: Lokesh Vutla lokeshvutla@ti.com --- - This is similar to hook available in arch/arc/ https://gitlab.denx.de/u-boot/u-boot/blob/master/arch/arc/lib/bootm.c#L48
arch/arm/lib/bootm.c | 4 ++++ 1 file changed, 4 insertions(+)
diff --git a/arch/arm/lib/bootm.c b/arch/arm/lib/bootm.c index 1638f1e81d..488358a331 100644 --- a/arch/arm/lib/bootm.c +++ b/arch/arm/lib/bootm.c @@ -224,6 +224,8 @@ static void do_nonsec_virt_switch(void) } #endif
+__weak void board_prep_linux(bootm_headers_t *images) { } + /* Subcommand: PREP */ static void boot_prep_linux(bootm_headers_t *images) { @@ -270,6 +272,8 @@ static void boot_prep_linux(bootm_headers_t *images) printf("FDT and ATAGS support not compiled in - hanging\n"); hang(); } + + board_prep_linux(images); }
__weak bool armv7_boot_nonsec_default(void)

On Mon, Oct 07, 2019 at 01:52:15PM +0530, Lokesh Vutla wrote:
Once the arch specific boot_prepare_linux completes, boards wants to have a custom preparation for linux. Add support for a custom board_prep_linux.
Signed-off-by: Lokesh Vutla lokeshvutla@ti.com
Applied to u-boot/master, thanks!

Store the start and end of the OS image that is loaded in images structure.
Signed-off-by: Lokesh Vutla lokeshvutla@ti.com --- cmd/booti.c | 3 +++ 1 file changed, 3 insertions(+)
diff --git a/cmd/booti.c b/cmd/booti.c index c36b0235df..841eff10d1 100644 --- a/cmd/booti.c +++ b/cmd/booti.c @@ -48,6 +48,9 @@ static int booti_start(cmd_tbl_t *cmdtp, int flag, int argc, }
images->ep = relocated_addr; + images->os.start = relocated_addr; + images->os.end = relocated_addr + image_size; + lmb_reserve(&images->lmb, images->ep, le32_to_cpu(image_size));
/*

On Mon, Oct 07, 2019 at 01:52:16PM +0530, Lokesh Vutla wrote:
Store the start and end of the OS image that is loaded in images structure.
Signed-off-by: Lokesh Vutla lokeshvutla@ti.com
Applied to u-boot/master, thanks!

U-Boot cleans and invalidate L1 and L2 caches before jumping to Linux by set/way in cleanup_before_linux(). Additionally there is a custom hook provided to clean and invalidate L3 cache.
Unfortunately on K3 devices(having a coherent architecture), there is no easy way to quickly clean all the cache lines for L3. The entire address range needs to be cleaned and invalidated by Virtual Address. This can be implemented using the L3 custom hook but it take lot of time to clean the entire address range. In the interest of boot time this might not be a viable solution.
The best hit is to make sure the loaded Linux image is flushed so that the entire image is written to DDR from L3. When Linux starts running with caches disabled the full image is available from DDR.
Reported-by: Andrew F. Davis afd@ti.com Reported-by: Faiz Abbas faiz_abbas@ti.com Signed-off-by: Lokesh Vutla lokeshvutla@ti.com --- arch/arm/mach-k3/common.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
diff --git a/arch/arm/mach-k3/common.c b/arch/arm/mach-k3/common.c index 276f2f63e6..e5f27187d6 100644 --- a/arch/arm/mach-k3/common.c +++ b/arch/arm/mach-k3/common.c @@ -207,3 +207,14 @@ int print_cpuinfo(void) return 0; } #endif + +#ifdef CONFIG_ARM64 +void board_prep_linux(bootm_headers_t *images) +{ + debug("Linux kernel Image start = 0x%lx end = 0x%lx\n", + images->os.start, images->os.end); + __asm_flush_dcache_range(images->os.start, + ROUND(images->os.end, + CONFIG_SYS_CACHELINE_SIZE)); +} +#endif

On Mon, Oct 07, 2019 at 01:52:17PM +0530, Lokesh Vutla wrote:
U-Boot cleans and invalidate L1 and L2 caches before jumping to Linux by set/way in cleanup_before_linux(). Additionally there is a custom hook provided to clean and invalidate L3 cache.
Unfortunately on K3 devices(having a coherent architecture), there is no easy way to quickly clean all the cache lines for L3. The entire address range needs to be cleaned and invalidated by Virtual Address. This can be implemented using the L3 custom hook but it take lot of time to clean the entire address range. In the interest of boot time this might not be a viable solution.
The best hit is to make sure the loaded Linux image is flushed so that the entire image is written to DDR from L3. When Linux starts running with caches disabled the full image is available from DDR.
Reported-by: Andrew F. Davis afd@ti.com Reported-by: Faiz Abbas faiz_abbas@ti.com Signed-off-by: Lokesh Vutla lokeshvutla@ti.com
Applied to u-boot/master, thanks!
participants (2)
-
Lokesh Vutla
-
Tom Rini