[U-Boot,v2,07/22] x86: fsp: Mark memory used by U-Boot as reserved in the E820 table for S3

Submitted by Bin Meng on April 21, 2017, 2:24 p.m.

Details

Message ID 1492784689-15701-8-git-send-email-bmeng.cn@gmail.com
State Accepted
Delegated to: Bin Meng
Headers show

Commit Message

Bin Meng April 21, 2017, 2:24 p.m.
U-Boot itself as well as everything that is consumed by U-Boot (like
heap, stack, dtb, etc) needs to be reserved and reported in the E820
table when S3 resume is on.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
---

Changes in v2: None

 arch/x86/Kconfig            |  8 ++++++++
 arch/x86/lib/fsp/fsp_dram.c | 12 ++++++++++++
 2 files changed, 20 insertions(+)

Comments

Bin Meng April 26, 2017, 7:34 a.m.
On Fri, Apr 21, 2017 at 10:24 PM, Bin Meng <bmeng.cn@gmail.com> wrote:
> U-Boot itself as well as everything that is consumed by U-Boot (like
> heap, stack, dtb, etc) needs to be reserved and reported in the E820
> table when S3 resume is on.
>
> Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
> Reviewed-by: Simon Glass <sjg@chromium.org>
> ---
>
> Changes in v2: None
>
>  arch/x86/Kconfig            |  8 ++++++++
>  arch/x86/lib/fsp/fsp_dram.c | 12 ++++++++++++
>  2 files changed, 20 insertions(+)
>

applied to u-boot-x86/next, thanks!

Patch hide | download patch | download mbox

diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index b568852..5322eff 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -601,6 +601,14 @@  config HAVE_ACPI_RESUME
 	  is done, U-Boot needs to find out the wakeup vector provided by OSes
 	  and jump there.
 
+config STACK_SIZE
+	hex
+	depends on HAVE_ACPI_RESUME
+	default 0x1000
+	help
+	  Estimated U-Boot's runtime stack size that needs to be reserved
+	  during an ACPI S3 resume.
+
 config MAX_PIRQ_LINKS
 	int
 	default 8
diff --git a/arch/x86/lib/fsp/fsp_dram.c b/arch/x86/lib/fsp/fsp_dram.c
index 8b880cd..1a7af57 100644
--- a/arch/x86/lib/fsp/fsp_dram.c
+++ b/arch/x86/lib/fsp/fsp_dram.c
@@ -92,5 +92,17 @@  unsigned install_e820_map(unsigned max_entries, struct e820entry *entries)
 	entries[num_entries].type = E820_RESERVED;
 	num_entries++;
 
+#ifdef CONFIG_HAVE_ACPI_RESUME
+	/*
+	 * Everything between U-Boot's stack and ram top needs to be
+	 * reserved in order for ACPI S3 resume to work.
+	 */
+	entries[num_entries].addr = gd->start_addr_sp - CONFIG_STACK_SIZE;
+	entries[num_entries].size = gd->ram_top - gd->start_addr_sp + \
+		CONFIG_STACK_SIZE;
+	entries[num_entries].type = E820_RESERVED;
+	num_entries++;
+#endif
+
 	return num_entries;
 }