Skip to contentSkip to conversation

arm: K3: Make sure to clean caches before jumping to Linux

PATCH New Lokesh Vutla 2 participants 7 messages Oct 7, 2019 – Oct 26, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover 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(+)
Signature · 1 line
2.23.0
#1 lore raw

PATCH 1/3 boot: arm: Enable support for custom board_prep_linux

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.

---
- 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(+)
arch/arm/lib/bootm.c +4 -0
index 1638f1e81d..488358a331 100644
@@ -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)
Signature · 1 line
2.23.0
#2 lore raw

PATCH 1/3 boot: arm: Enable support for custom board_prep_linux

Quoted 5 lines · Lokesh Vutla

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.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20191025/b7fd3e9f/attachment.sig>
#3 lore raw

PATCH 2/3 cmd: booti: Store OS start and end info in images structure

In reply to Lokesh Vutla

Store the start and end of the OS image that is loaded in images structure.

---
 cmd/booti.c | 3 +++
 1 file changed, 3 insertions(+)
cmd/booti.c +3 -0
index c36b0235df..841eff10d1 100644
@@ -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));
 
 	/*
Signature · 1 line
2.23.0
#4 lore raw

PATCH 2/3 cmd: booti: Store OS start and end info in images structure

Quoted 4 lines · Lokesh Vutla

Store the start and end of the OS image that is loaded in images structure.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20191025/3c598541/attachment.sig>
#5 lore raw

PATCH 3/3 arm: K3: Clean and invalidate Linux Image before jumping to Linux

In reply to Lokesh Vutla

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.

---
 arch/arm/mach-k3/common.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
arch/arm/mach-k3/common.c +11 -0
index 276f2f63e6..e5f27187d6 100644
@@ -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
Signature · 1 line
2.23.0
#6 lore raw

PATCH 3/3 arm: K3: Clean and invalidate Linux Image before jumping to Linux

Quoted 11 lines · Lokesh Vutla

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.

Quoted 7 lines

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.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20191025/107c0d03/attachment.sig>