[coreboot-gerrit] Patch set updated for coreboot: soc/apollolake: Place new romstage stack in CAR instead of RAM

Alexandru Gagniuc (mr.nuke.me@gmail.com) gerrit at coreboot.org
Tue Jan 26 19:57:53 CET 2016


Alexandru Gagniuc (mr.nuke.me at gmail.com) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/13357

-gerrit

commit adb2482a9ffbbd84700a1d30655a251079f8c5c0
Author: Alexandru Gagniuc <alexandrux.gagniuc at intel.com>
Date:   Fri Nov 13 17:15:03 2015 -0800

    soc/apollolake: Place new romstage stack in CAR instead of RAM
    
    We can allocate a new romstage stack in CAR because we don't tear down
    CAR in romstage. This simple change improves ramstage loading time by
    about 30%.
    
    Change-Id: I5762c74cdc0ea8cb0aade3fdf8071cb86ec3fe0e
    Signed-off-by: Alexandru Gagniuc <alexandrux.gagniuc at intel.com>
---
 src/soc/intel/apollolake/Kconfig             | 13 +------------
 src/soc/intel/apollolake/romstage/entry.inc  |  6 +++---
 src/soc/intel/apollolake/romstage/romstage.c | 29 ++++++++++++----------------
 3 files changed, 16 insertions(+), 32 deletions(-)

diff --git a/src/soc/intel/apollolake/Kconfig b/src/soc/intel/apollolake/Kconfig
index eb9bd79..1b60bcf 100644
--- a/src/soc/intel/apollolake/Kconfig
+++ b/src/soc/intel/apollolake/Kconfig
@@ -12,7 +12,6 @@ config CPU_SPECIFIC_OPTIONS
 	select ARCH_ROMSTAGE_X86_32
 	select ARCH_VERSTAGE_X86_32
 	# CPU specific options
-	select CPU_INTEL_FIRMWARE_INTERFACE_TABLE
 	select IOAPIC
 	select SMP
 	select SSE2
@@ -70,17 +69,7 @@ config DCACHE_RAM_BOOTBLOCK_STACK_SIZE
 	default 0x800
 	help
 	  The amount of anticipated stack usage from the bootblock during
-	  pre-romstage initialization.
-
-config ROMSTAGE_RAM_STACK_SIZE
-	hex
-	default 0x5000
-	help
-	   The size of the romstage stack after memory is available. Because CAR
-	   space is very crowded, only a very limited part of CAR is available
-	   for stack. More than that is needed to decompress ramstage. This
-	   variable indicates how much RAM to reserve for the stack after
-	   raminit. The stack is automatically switched after romstage_main().
+	  pre-romstage initialization..
 
 config IFD_BIOS_START
 	hex
diff --git a/src/soc/intel/apollolake/romstage/entry.inc b/src/soc/intel/apollolake/romstage/entry.inc
index 8c0670c..2c6dfd6 100644
--- a/src/soc/intel/apollolake/romstage/entry.inc
+++ b/src/soc/intel/apollolake/romstage/entry.inc
@@ -21,9 +21,9 @@ apollolake_entry:
 	call	romstage_entry
 
 	/*
-	 * eax contains pointer to a region in RAM that we've been given the go
-	 * ahead to use as stack. The old stack is empty at this point, so we
-	 * don't have to relocate anything.
+	 * eax contains pointer to a region that we've been given the go ahead
+	 * to use as stack. The old stack is empty at this point, so we don't
+	 * have to relocate anything.
 	 */
 	mov	esp, eax
 
diff --git a/src/soc/intel/apollolake/romstage/romstage.c b/src/soc/intel/apollolake/romstage/romstage.c
index b7ffd3a..24fad92 100644
--- a/src/soc/intel/apollolake/romstage/romstage.c
+++ b/src/soc/intel/apollolake/romstage/romstage.c
@@ -54,23 +54,18 @@ static void soc_early_romstage_init(void)
 	pci_write_config32(PCI_DEV(0, 13, 0), 0x60, 1<<7);
 }
 
-static void *alloc_stack_in_ram(void)
+/*
+ * Now that FSP is done consuming large amounts of CAR, we can use a much
+ * larger portion of CAR for the stack. The larger stack is needed for
+ * decompressing ramstage. It turns out that setting the stack pointer to top
+ * of CAR gives us the largest uninterrupted stack.
+ */
+static void *realloc_stack(void)
 {
-	uint8_t *ram_stack = cbmem_add(CBMEM_ID_ROMSTAGE_RAM_STACK,
-				    CONFIG_ROMSTAGE_RAM_STACK_SIZE);
-
-	/*
-	 * If cbmem fails to give us a memory window, try to get a stack at
-	 * 2 MiB, and hope we can go forward. The 2 MiB address is arbitrary.
-	 */
-	if (ram_stack == NULL) {
-		printk(BIOS_ALERT, "Could not find place for stack\n");
-		return (void *)(2 * MiB);
-	}
-
-	/* The initial stack pointer should point at the top of the region */
-	ram_stack += CONFIG_ROMSTAGE_RAM_STACK_SIZE - sizeof(size_t);
-	return ram_stack;
+	uintptr_t new_stack = CONFIG_DCACHE_RAM_BASE + CONFIG_DCACHE_RAM_SIZE;
+	new_stack -= sizeof(size_t);
+	printk(BIOS_DEBUG, "Placing new stack at 0x%lx\n", new_stack);
+	return (void *)new_stack;
 }
 
 asmlinkage void* romstage_entry(void)
@@ -100,7 +95,7 @@ asmlinkage void* romstage_entry(void)
 	if (fsp_mem.base != (uintptr_t)cbmem_find(CBMEM_ID_FSP_RESERVED_MEMORY))
 		die("Failed to accommodate FSP reserved memory request");
 
-	return alloc_stack_in_ram();
+	return realloc_stack();
 }
 
 asmlinkage void romstage_after_raminit(void)



More information about the coreboot-gerrit mailing list