Skip to contentSkip to conversation

spl: Add D-cache support

RFC PATCH New Lokesh Vutla 3 participants 16 messages Nov 28, 2016 – Dec 13, 2016

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

cover spl: Add D-cache support

This series tries to add D-cache support in spl in order to reduce boot time either in 2stage boot or Falcon Boot.

Lokesh Vutla (3):
arch: arm: omap: Declare size of ddr very early
spl: reorder the assignment of board info to global data
spl: Add support for enabling dcache

 arch/arm/include/asm/cache.h        |  1 +
 arch/arm/lib/cache-cp15.c           | 46 +++++++++++++++++++++++++++++--------
 arch/arm/mach-omap2/am33xx/board.c  |  4 ++++
 arch/arm/mach-omap2/hwinit-common.c |  1 +
 arch/arm/mach-omap2/omap-cache.c    | 15 ++++++++++++
 common/spl/spl.c                    | 42 ++++++++++++++++++++++++++++++++-
 6 files changed, 98 insertions(+), 11 deletions(-)
Signature · 1 line
2.10.1
#1 lore raw

RFC PATCH 1/3 arch: arm: omap: Declare size of ddr very early

Declare the size of ddr very early in spl, so that this can be used to enable cache.

---
 arch/arm/mach-omap2/am33xx/board.c  | 4 ++++
 arch/arm/mach-omap2/hwinit-common.c | 1 +
 2 files changed, 5 insertions(+)
arch/arm/mach-omap2/am33xx/board.c +4 -0
index 5ebeac0..7f445ae 100644
@@ -303,6 +303,10 @@ void board_init_f(ulong dummy)
 	early_system_init();
 	board_early_init_f();
 	sdram_init();
+	/* dram_init must store complete ramsize in gd->ram_size */
+	gd->ram_size = get_ram_size(
+			(void *)CONFIG_SYS_SDRAM_BASE,
+			CONFIG_MAX_RAM_BANK_SIZE);
 }
 #endif
 
arch/arm/mach-omap2/hwinit-common.c +1 -0
index f317293..cac3274 100644
@@ -171,6 +171,7 @@ void board_init_f(ulong dummy)
 #endif
 	/* For regular u-boot sdram_init() is called from dram_init() */
 	sdram_init();
+	gd->ram_size = omap_sdram_size();
 }
 #endif
 
Signature · 1 line
2.10.1
#2 lore raw

RFC PATCH 1/3 arch: arm: omap: Declare size of ddr very early

Quoted 4 lines · Lokesh Vutla

Declare the size of ddr very early in spl, so that this can be used to enable cache.

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

RFC PATCH 2/3 spl: reorder the assignment of board info to global data

In reply to Lokesh Vutla

Move the assignment of board info to global data a bit early which is safe, so that ram details can be used to enable caches.

---
 common/spl/spl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
common/spl/spl.c +1 -1
index bdb165a..990b700 100644
@@ -394,6 +394,7 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
 	int i;
 
 	debug(">>spl:board_init_r()\n");
+	gd->bd = &bdata;
 
 #if defined(CONFIG_SYS_SPL_MALLOC_START)
 	mem_malloc_init(CONFIG_SYS_SPL_MALLOC_START,
@@ -461,7 +462,6 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
  */
 void preloader_console_init(void)
 {
-	gd->bd = &bdata;
 	gd->baudrate = CONFIG_BAUDRATE;
 
 	serial_init();		/* serial communications setup */
Signature · 1 line
2.10.1
#4 lore raw

RFC PATCH 2/3 spl: reorder the assignment of board info to global data

Quoted 4 lines · Lokesh Vutla

Move the assignment of board info to global data a bit early which is safe, so that ram details can be used to enable caches.

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20161128/0d0bc11f/attachment.sig>
#6 lore raw

RFC PATCH 3/3 spl: Add support for enabling dcache

In reply to Lokesh Vutla

Add support for enabling d-cache in SPL. The sequence in SPL tries to replicate the sequence done in U-Boot except that MMU entries were added for SRAM.

---
 arch/arm/include/asm/cache.h     |  1 +
 arch/arm/lib/cache-cp15.c        | 46 +++++++++++++++++++++++++++++++---------
 arch/arm/mach-omap2/omap-cache.c | 15 +++++++++++++
 common/spl/spl.c                 | 40 ++++++++++++++++++++++++++++++++++
 4 files changed, 92 insertions(+), 10 deletions(-)
arch/arm/include/asm/cache.h +1 -0
index 5400cbe..20f6aca 100644
@@ -39,6 +39,7 @@ void arm_init_before_mmu(void);
 void arm_init_domains(void);
 void cpu_cache_initialization(void);
 void dram_bank_mmu_setup(int bank);
+void sram_bank_mmu_setup(phys_addr_t start, phys_addr_t size);
 
 #endif
 
arch/arm/lib/cache-cp15.c +36 -10

67 lines not on this page · raw message

arch/arm/mach-omap2/omap-cache.c +15 -0
index b37163a..6019e0c 100644
@@ -62,6 +62,21 @@ void dram_bank_mmu_setup(int bank)
 		set_section_dcache(i, ARMV7_DCACHE_POLICY);
 }
 
+#ifdef CONFIG_SPL_BUILD
+void sram_bank_mmu_setup(phys_addr_t start, phys_addr_t size)
+{
+	int i;
+	phys_addr_t end;
+
+	start = start >> MMU_SECTION_SHIFT;
+	size = size >> MMU_SECTION_SHIFT;
+	end = start + size;
+
+	for (i = start; i <= end; i++)
+		set_section_dcache(i, ARMV7_DCACHE_POLICY);
+}
+#endif
+
 void arm_init_domains(void)
 {
 	u32 reg;
common/spl/spl.c +40 -0
index 990b700..cdd2917 100644
@@ -381,6 +381,34 @@ static int spl_load_image(struct spl_image_info *spl_image, u32 boot_device)
 	return -ENODEV;
 }
 
+#if !(defined(CONFIG_SYS_ICACHE_OFF) && defined(CONFIG_SYS_DCACHE_OFF)) && \
+		defined(CONFIG_ARM)
+static int reserve_mmu(void)
+{
+	phys_addr_t ram_top = 0;
+	/* reserve TLB table */
+	gd->arch.tlb_size = PGTABLE_SIZE;
+
+#ifdef CONFIG_SYS_SDRAM_BASE
+	ram_top = CONFIG_SYS_SDRAM_BASE;
+#endif
+	ram_top += get_effective_memsize();
+	gd->arch.tlb_addr = ram_top - gd->arch.tlb_size;
+	debug("TLB table from %08lx to %08lx\n", gd->arch.tlb_addr,
+	      gd->arch.tlb_addr + gd->arch.tlb_size);
+	return 0;
+}
+
+__weak void dram_init_banksize(void)
+{
+#if defined(CONFIG_NR_DRAM_BANKS) && defined(CONFIG_SYS_SDRAM_BASE)
+	gd->bd->bi_dram[0].start = CONFIG_SYS_SDRAM_BASE;
+	gd->bd->bi_dram[0].size = get_effective_memsize();
+#endif
+}
+
+#endif
+
 void board_init_r(gd_t *dummy1, ulong dummy2)
 {
 	u32 spl_boot_list[] = {
@@ -396,6 +424,13 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
 	debug(">>spl:board_init_r()\n");
 	gd->bd = &bdata;
 
+#if !(defined(CONFIG_SYS_ICACHE_OFF) && defined(CONFIG_SYS_DCACHE_OFF)) && \
+		defined(CONFIG_ARM)
+	dram_init_banksize();
+	reserve_mmu();
+	enable_caches();
+#endif
+
 #if defined(CONFIG_SYS_SPL_MALLOC_START)
 	mem_malloc_init(CONFIG_SYS_SPL_MALLOC_START,
 			CONFIG_SYS_SPL_MALLOC_SIZE);
@@ -432,6 +467,11 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
 		hang();
 	}
 
+#if !(defined(CONFIG_SYS_ICACHE_OFF) && defined(CONFIG_SYS_DCACHE_OFF)) && \
+		defined(CONFIG_ARM)
+	cleanup_before_linux();
+#endif
+
 	switch (spl_image.os) {
 	case IH_OS_U_BOOT:
 		debug("Jumping to U-Boot\n");
Signature · 1 line
2.10.1
#7 lore raw

RFC PATCH 3/3 spl: Add support for enabling dcache

Quoted 5 lines · Lokesh Vutla

Add support for enabling d-cache in SPL. The sequence in SPL tries to replicate the sequence done in U-Boot except that MMU entries were added for SRAM.

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

RFC PATCH 3/3 spl: Add support for enabling dcache

In reply to Lokesh Vutla
Quoted 11 lines · Lokesh Vutla

Add support for enabling d-cache in SPL. The sequence in SPL tries to replicate the sequence done in U-Boot except that MMU entries were added for SRAM.

---
 arch/arm/include/asm/cache.h     |  1 +
 arch/arm/lib/cache-cp15.c        | 46 +++++++++++++++++++++++++++++++---------
 arch/arm/mach-omap2/omap-cache.c | 15 +++++++++++++
 common/spl/spl.c                 | 40 ++++++++++++++++++++++++++++++++++
 4 files changed, 92 insertions(+), 10 deletions(-)
#9 lore raw

cover spl: Add D-cache support

In reply to Lokesh Vutla
Quoted 2 lines · Lokesh Vutla

This series tries to add D-cache support in spl in order to reduce boot time either in 2stage boot or Falcon Boot.

I assume you've measured and confirmed that there is a speed increase? I ask since I'd tried this ages ago but..

Quoted 4 lines

Lokesh Vutla (3):
arch: arm: omap: Declare size of ddr very early
spl: reorder the assignment of board info to global data

... I didn't have changes like this, which is perhaps why it ended up not working right. Thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20161128/39086fe0/attachment.sig>
#10 lore raw

cover spl: Add D-cache support

Quoted 7 lines · Tom Rini
Quoted 2 lines · Lokesh Vutla

This series tries to add D-cache support in spl in order to reduce boot time either in 2stage boot or Falcon Boot.

I assume you've measured and confirmed that there is a speed increase? I ask since I'd tried this ages ago but..

Yes. I have verified it on all TI platforms.
On DRA7-evm with MMCSD boot:
without this series SPL took 607 ms to complete
with this series SPL took 318 ms to complete.

Quoted 9 lines
Quoted 5 lines

Lokesh Vutla (3):
arch: arm: omap: Declare size of ddr very early
spl: reorder the assignment of board info to global data

... I didn't have changes like this, which is perhaps why it ended up not working right. Thanks!

I am mainly worried about platforms other than TI(Just want to be sure that this series did not break other platforms)

Thanks and regards,
Lokesh

#11 lore raw

cover spl: Add D-cache support

In reply to Lokesh Vutla

Hi Tom,

Quoted 2 lines · Lokesh Vutla

This series tries to add D-cache support in spl in order to reduce boot time either in 2stage boot or Falcon Boot.

I hope there are no further comments on this series. Do you want me to re post this series or this is good to go?

Thanks and regards,
Lokesh

Quoted 14 lines

Lokesh Vutla (3):
arch: arm: omap: Declare size of ddr very early
spl: reorder the assignment of board info to global data
spl: Add support for enabling dcache

 arch/arm/include/asm/cache.h        |  1 +
 arch/arm/lib/cache-cp15.c           | 46 +++++++++++++++++++++++++++++--------
 arch/arm/mach-omap2/am33xx/board.c  |  4 ++++
 arch/arm/mach-omap2/hwinit-common.c |  1 +
 arch/arm/mach-omap2/omap-cache.c    | 15 ++++++++++++
 common/spl/spl.c                    | 42 ++++++++++++++++++++++++++++++++-
 6 files changed, 98 insertions(+), 11 deletions(-)
#12 lore raw

cover spl: Add D-cache support

Quoted 8 lines · Lokesh Vutla

Hi Tom,

Quoted 2 lines · Lokesh Vutla

This series tries to add D-cache support in spl in order to reduce boot time either in 2stage boot or Falcon Boot.

I hope there are no further comments on this series. Do you want me to re post this series or this is good to go?

I've thought about this a bit, and yes, it was posted before the end of the merge window, but given the wide impact of some of these changes and the general time taken off around now, I think this is more safely pushed in right after the next release to give it the most time to shake out. I will however find some time to boot test this at least on RPi3 (32bit), allwinner and imx6 beforehand. Thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20161212/4f00d18a/attachment.sig>
#13 lore raw

cover spl: Add D-cache support

In reply to Lokesh Vutla
Quoted 8 lines · Lokesh Vutla

Hi Tom,

Quoted 2 lines · Lokesh Vutla

This series tries to add D-cache support in spl in order to reduce boot time either in 2stage boot or Falcon Boot.

I hope there are no further comments on this series. Do you want me to re post this series or this is good to go?

This breaks building on a few platforms:
https://travis-ci.org/trini/u-boot/jobs/183441104
https://travis-ci.org/trini/u-boot/jobs/183441159
https://travis-ci.org/trini/u-boot/jobs/183441171

And break booting on omap4_panda:
20:02:33 U-Boot SPL 2017.01-rc1-00068-g8ae0906 (Dec 12 2016 - 19:11:20) 20:02:33 OMAP4460-GP ES1.1
20:02:33 Trying to boot from MMC1SPL: Please implement spl_start_uboot() for your board 20:02:33 SPL: Direct Linux boot not active!
20:02:33 reading u-boot.img
20:02:33 reading u-boot.img
[ hangs here ]

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20161213/88b512b0/attachment.sig>
#14 lore raw

cover spl: Add D-cache support

Quoted 11 lines · Tom Rini
Quoted 8 lines · Lokesh Vutla

Hi Tom,

Quoted 2 lines · Lokesh Vutla

This series tries to add D-cache support in spl in order to reduce boot time either in 2stage boot or Falcon Boot.

I hope there are no further comments on this series. Do you want me to re post this series or this is good to go?

This breaks building on a few platforms:

I am kind of expecting for that :)

Quoted 2 lines

https://travis-ci.org/trini/u-boot/jobs/183441104
https://travis-ci.org/trini/u-boot/jobs/183441159

These errors are mostly saying that SPL image is too big.

Quoted 1 line

https://travis-ci.org/trini/u-boot/jobs/183441171

Looks like I did not care about armv8 platforms. Ill take a look at this.

Quoted 9 lines

And break booting on omap4_panda:
20:02:33 U-Boot SPL 2017.01-rc1-00068-g8ae0906 (Dec 12 2016 - 19:11:20) 20:02:33 OMAP4460-GP ES1.1
20:02:33 Trying to boot from MMC1SPL: Please implement spl_start_uboot() for your board 20:02:33 SPL: Direct Linux boot not active!
20:02:33 reading u-boot.img
20:02:33 reading u-boot.img
[ hangs here ]

hmm...ill dig more into this.

Thanks and regards,
Lokesh

#15 lore raw

cover spl: Add D-cache support

Quoted 13 lines · Lokesh Vutla
Quoted 10 lines · Tom Rini
Quoted 8 lines · Lokesh Vutla

Hi Tom,

Quoted 2 lines · Lokesh Vutla

This series tries to add D-cache support in spl in order to reduce boot time either in 2stage boot or Falcon Boot.

I hope there are no further comments on this series. Do you want me to re post this series or this is good to go?

Quoted 8 lines
Quoted 1 line

This breaks building on a few platforms:

I am kind of expecting for that :)

Quoted 2 lines

https://travis-ci.org/trini/u-boot/jobs/183441104
https://travis-ci.org/trini/u-boot/jobs/183441159

These errors are mostly saying that SPL image is too big.

Right. But they need to build still.

Quoted 14 lines
Quoted 1 line

https://travis-ci.org/trini/u-boot/jobs/183441171

Looks like I did not care about armv8 platforms. Ill take a look at this.

Quoted 9 lines

And break booting on omap4_panda:
20:02:33 U-Boot SPL 2017.01-rc1-00068-g8ae0906 (Dec 12 2016 - 19:11:20) 20:02:33 OMAP4460-GP ES1.1
20:02:33 Trying to boot from MMC1SPL: Please implement spl_start_uboot() for your board 20:02:33 SPL: Direct Linux boot not active!
20:02:33 reading u-boot.img
20:02:33 reading u-boot.img
[ hangs here ]

Quoted 1 line

hmm...ill dig more into this.

Thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20161213/212f10ef/attachment.sig>