Message ID | 1489674408-17498-9-git-send-email-bmeng.cn@gmail.com |
---|---|
State | Accepted |
Commit | 7d0d2efef82dcb88030a960aef09290e6e49f771 |
Delegated to: | Bin Meng |
Headers | show |
Hi Bin, On 16 March 2017 at 08:26, 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> > --- > > arch/x86/Kconfig | 8 ++++++++ > arch/x86/lib/fsp/fsp_dram.c | 12 ++++++++++++ > 2 files changed, 20 insertions(+) Reviewed-by: Simon Glass <sjg@chromium.org> Can you detect if the stack space is too small? It should be possible to measure the stack size easily enough - e.g. using cpu_get_sp(). > > diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig > index 7ea9148..95a65ff 100644 > --- a/arch/x86/Kconfig > +++ b/arch/x86/Kconfig > @@ -583,6 +583,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 fcfe693..417c611 100644 > --- a/arch/x86/lib/fsp/fsp_dram.c > +++ b/arch/x86/lib/fsp/fsp_dram.c > @@ -90,5 +90,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; > } > -- > 2.9.2 > Regaeds, Simon
Hi Simon, On Wed, Mar 22, 2017 at 4:06 AM, Simon Glass <sjg@chromium.org> wrote: > Hi Bin, > > On 16 March 2017 at 08:26, 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> >> --- >> >> arch/x86/Kconfig | 8 ++++++++ >> arch/x86/lib/fsp/fsp_dram.c | 12 ++++++++++++ >> 2 files changed, 20 insertions(+) > > Reviewed-by: Simon Glass <sjg@chromium.org> > > Can you detect if the stack space is too small? > > It should be possible to measure the stack size easily enough - e.g. > using cpu_get_sp(). I suspect we can fill the stack memory with some magic number, and then after U-Boot boots to shell check the stack to see where the pattern ends. This practice should be done periodically as U-Boot's code base changes very rapidly. Regards, Bin
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index 7ea9148..95a65ff 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -583,6 +583,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 fcfe693..417c611 100644 --- a/arch/x86/lib/fsp/fsp_dram.c +++ b/arch/x86/lib/fsp/fsp_dram.c @@ -90,5 +90,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; }
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> --- arch/x86/Kconfig | 8 ++++++++ arch/x86/lib/fsp/fsp_dram.c | 12 ++++++++++++ 2 files changed, 20 insertions(+)