Kyösti Mälkki has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/42614 )
Change subject: APCI S3: Split arch-agnostic parts ......................................................................
APCI S3: Split arch-agnostic parts
Change-Id: I9fc2d1cdbb280f781045882bc4ac98c67946953e Signed-off-by: Kyösti Mälkki kyosti.malkki@gmail.com --- M src/acpi/Makefile.inc A src/acpi/acpi_pm.c M src/arch/x86/Makefile.inc M src/arch/x86/acpi_s3.c 4 files changed, 48 insertions(+), 46 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/14/42614/1
diff --git a/src/acpi/Makefile.inc b/src/acpi/Makefile.inc index 7e37e1a..108f427 100644 --- a/src/acpi/Makefile.inc +++ b/src/acpi/Makefile.inc @@ -3,6 +3,7 @@ ifeq ($(CONFIG_HAVE_ACPI_TABLES),y)
ramstage-y += acpi.c +ramstage-y += acpi_pm.c ramstage-y += acpigen.c ramstage-y += acpigen_dsm.c ramstage-y += acpigen_ps2_keybd.c @@ -12,6 +13,8 @@ ramstage-y += sata.c ramstage-y += soundwire.c
+postcar-y += acpi_pm.c + ifneq ($(wildcard src/mainboard/$(MAINBOARDDIR)/acpi_tables.c),) ramstage-srcs += src/mainboard/$(MAINBOARDDIR)/acpi_tables.c endif diff --git a/src/acpi/acpi_pm.c b/src/acpi/acpi_pm.c new file mode 100644 index 0000000..b88b761 --- /dev/null +++ b/src/acpi/acpi_pm.c @@ -0,0 +1,44 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#include <acpi/acpi.h> +#include <console/console.h> +#include <romstage_handoff.h> + +/* This is filled with acpi_is_wakeup() call early in ramstage. */ +static int acpi_slp_type = -1; + +static void acpi_handoff_wakeup(void) +{ + if (acpi_slp_type < 0) { + if (romstage_handoff_is_resume()) { + printk(BIOS_DEBUG, "S3 Resume\n"); + acpi_slp_type = ACPI_S3; + } else { + printk(BIOS_DEBUG, "Normal boot\n"); + acpi_slp_type = ACPI_S0; + } + } +} + +int acpi_is_wakeup(void) +{ + acpi_handoff_wakeup(); + /* Both resume from S2 and resume from S3 restart at CPU reset */ + return (acpi_slp_type == ACPI_S3 || acpi_slp_type == ACPI_S2); +} + +int acpi_is_wakeup_s3(void) +{ + acpi_handoff_wakeup(); + return (acpi_slp_type == ACPI_S3); +} + +int acpi_is_wakeup_s4(void) +{ + acpi_handoff_wakeup(); + return (acpi_slp_type == ACPI_S4); +} + +void __weak mainboard_suspend_resume(void) +{ +} diff --git a/src/arch/x86/Makefile.inc b/src/arch/x86/Makefile.inc index 6297384..6773b270 100644 --- a/src/arch/x86/Makefile.inc +++ b/src/arch/x86/Makefile.inc @@ -157,7 +157,6 @@
ifeq ($(CONFIG_ARCH_ROMSTAGE_X86_32)$(CONFIG_ARCH_ROMSTAGE_X86_64),y)
-romstage-$(CONFIG_HAVE_ACPI_RESUME) += acpi_s3.c romstage-y += boot.c romstage-y += post.c # gdt_init.S is included by entry32.inc when romstage is the first C @@ -198,7 +197,6 @@ $(eval $(call create_class_compiler,postcar,x86_32)) postcar-generic-ccopts += -D__POSTCAR__
-postcar-$(CONFIG_HAVE_ACPI_RESUME) += acpi_s3.c postcar-y += boot.c postcar-y += post.c postcar-y += gdt_init.S @@ -235,7 +233,7 @@
ifeq ($(CONFIG_ARCH_RAMSTAGE_X86_32)$(CONFIG_ARCH_RAMSTAGE_X86_64),y)
-ramstage-$(CONFIG_HAVE_ACPI_RESUME) += acpi_s3.c +ramstage-y += acpi_s3.c ramstage-$(CONFIG_ACPI_BERT) += acpi_bert_storage.c ramstage-y += boot.c ramstage-y += post.c diff --git a/src/arch/x86/acpi_s3.c b/src/arch/x86/acpi_s3.c index 814719a..8017dff 100644 --- a/src/arch/x86/acpi_s3.c +++ b/src/arch/x86/acpi_s3.c @@ -9,45 +9,6 @@ #include <cpu/x86/smm.h> #include <fallback.h> #include <timestamp.h> -#include <romstage_handoff.h> - -#if ENV_RAMSTAGE || ENV_POSTCAR - -/* This is filled with acpi_is_wakeup() call early in ramstage. */ -static int acpi_slp_type = -1; - -static void acpi_handoff_wakeup(void) -{ - if (acpi_slp_type < 0) { - if (romstage_handoff_is_resume()) { - printk(BIOS_DEBUG, "S3 Resume\n"); - acpi_slp_type = ACPI_S3; - } else { - printk(BIOS_DEBUG, "Normal boot\n"); - acpi_slp_type = ACPI_S0; - } - } -} - -int acpi_is_wakeup(void) -{ - acpi_handoff_wakeup(); - /* Both resume from S2 and resume from S3 restart at CPU reset */ - return (acpi_slp_type == ACPI_S3 || acpi_slp_type == ACPI_S2); -} - -int acpi_is_wakeup_s3(void) -{ - acpi_handoff_wakeup(); - return (acpi_slp_type == ACPI_S3); -} - -int acpi_is_wakeup_s4(void) -{ - acpi_handoff_wakeup(); - return (acpi_slp_type == ACPI_S4); -} -#endif /* ENV_RAMSTAGE */
#define WAKEUP_BASE 0x600
@@ -56,10 +17,6 @@ extern unsigned char __wakeup; extern unsigned int __wakeup_size;
-void __weak mainboard_suspend_resume(void) -{ -} - void __noreturn acpi_resume(void *wake_vec) { if (CONFIG(HAVE_SMI_HANDLER)) {
Angel Pons has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/42614 )
Change subject: APCI S3: Split arch-agnostic parts ......................................................................
Patch Set 1:
(1 comment)
https://review.coreboot.org/c/coreboot/+/42614/1//COMMIT_MSG Commit Message:
https://review.coreboot.org/c/coreboot/+/42614/1//COMMIT_MSG@7 PS1, Line 7: APCI ACPI
Kyösti Mälkki has abandoned this change. ( https://review.coreboot.org/c/coreboot/+/42614 )
Change subject: APCI S3: Split arch-agnostic parts ......................................................................
Abandoned
Kyösti Mälkki has restored this change. ( https://review.coreboot.org/c/coreboot/+/42614 )
Change subject: APCI S3: Split arch-agnostic parts ......................................................................
Restored
Hello build bot (Jenkins), Patrick Georgi, Martin Roth,
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/coreboot/+/42614
to look at the new patch set (#2).
Change subject: ACPI S3: Split arch-agnostic parts ......................................................................
ACPI S3: Split arch-agnostic parts
Change-Id: I9fc2d1cdbb280f781045882bc4ac98c67946953e Signed-off-by: Kyösti Mälkki kyosti.malkki@gmail.com --- M src/acpi/Makefile.inc A src/acpi/acpi_pm.c M src/arch/x86/Makefile.inc M src/arch/x86/acpi_s3.c M src/include/acpi/acpi.h 5 files changed, 60 insertions(+), 60 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/14/42614/2
Angel Pons has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/42614 )
Change subject: ACPI S3: Split arch-agnostic parts ......................................................................
Patch Set 2: Code-Review+2
(1 comment)
https://review.coreboot.org/c/coreboot/+/42614/1//COMMIT_MSG Commit Message:
https://review.coreboot.org/c/coreboot/+/42614/1//COMMIT_MSG@7 PS1, Line 7: APCI
ACPI
Done
Hello build bot (Jenkins), Patrick Georgi, Martin Roth, Angel Pons,
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/coreboot/+/42614
to look at the new patch set (#3).
Change subject: ACPI S3: Split arch-agnostic parts ......................................................................
ACPI S3: Split arch-agnostic parts
Change-Id: I9fc2d1cdbb280f781045882bc4ac98c67946953e Signed-off-by: Kyösti Mälkki kyosti.malkki@gmail.com --- M src/acpi/Makefile.inc A src/acpi/acpi_pm.c M src/arch/x86/Makefile.inc M src/arch/x86/acpi_s3.c M src/include/acpi/acpi.h 5 files changed, 42 insertions(+), 44 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/14/42614/3
Angel Pons has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/42614 )
Change subject: ACPI S3: Split arch-agnostic parts ......................................................................
Patch Set 3: Code-Review+2
Felix Held has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/42614 )
Change subject: ACPI S3: Split arch-agnostic parts ......................................................................
Patch Set 3:
FYI: the patches look good to me, but didn't have the time to properly verify them, so I'll wait with submitting them until the release which will probably happen tomorrow. if someone else wants to submit them earlier, I won't object though
Angel Pons has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/42614 )
Change subject: ACPI S3: Split arch-agnostic parts ......................................................................
Patch Set 3:
Patch Set 3:
FYI: the patches look good to me, but didn't have the time to properly verify them, so I'll wait with submitting them until the release which will probably happen tomorrow. if someone else wants to submit them earlier, I won't object though
I tested on Asus P8H61-M PRO, it still boots and resumes from S3.
Angel Pons has submitted this change. ( https://review.coreboot.org/c/coreboot/+/42614 )
Change subject: ACPI S3: Split arch-agnostic parts ......................................................................
ACPI S3: Split arch-agnostic parts
Change-Id: I9fc2d1cdbb280f781045882bc4ac98c67946953e Signed-off-by: Kyösti Mälkki kyosti.malkki@gmail.com Reviewed-on: https://review.coreboot.org/c/coreboot/+/42614 Tested-by: build bot (Jenkins) no-reply@coreboot.org Reviewed-by: Angel Pons th3fanbus@gmail.com --- M src/acpi/Makefile.inc A src/acpi/acpi_pm.c M src/arch/x86/Makefile.inc M src/arch/x86/acpi_s3.c M src/include/acpi/acpi.h 5 files changed, 42 insertions(+), 44 deletions(-)
Approvals: build bot (Jenkins): Verified Angel Pons: Looks good to me, approved
diff --git a/src/acpi/Makefile.inc b/src/acpi/Makefile.inc index f70b23f..2f06be1 100644 --- a/src/acpi/Makefile.inc +++ b/src/acpi/Makefile.inc @@ -3,6 +3,7 @@ ifeq ($(CONFIG_HAVE_ACPI_TABLES),y)
ramstage-y += acpi.c +ramstage-y += acpi_pm.c ramstage-y += acpigen.c ramstage-y += acpigen_dptf.c ramstage-y += acpigen_dsm.c @@ -15,6 +16,8 @@ ramstage-y += sata.c ramstage-y += soundwire.c
+postcar-y += acpi_pm.c + ifneq ($(wildcard src/mainboard/$(MAINBOARDDIR)/acpi_tables.c),) ramstage-srcs += src/mainboard/$(MAINBOARDDIR)/acpi_tables.c endif diff --git a/src/acpi/acpi_pm.c b/src/acpi/acpi_pm.c new file mode 100644 index 0000000..cecf878 --- /dev/null +++ b/src/acpi/acpi_pm.c @@ -0,0 +1,31 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#include <acpi/acpi.h> +#include <console/console.h> +#include <romstage_handoff.h> + +/* This is filled with acpi_handoff_wakeup_s3() call early in ramstage. */ +static int acpi_slp_type = -1; + +static void acpi_handoff_wakeup(void) +{ + if (acpi_slp_type < 0) { + if (romstage_handoff_is_resume()) { + printk(BIOS_DEBUG, "S3 Resume\n"); + acpi_slp_type = ACPI_S3; + } else { + printk(BIOS_DEBUG, "Normal boot\n"); + acpi_slp_type = ACPI_S0; + } + } +} + +int acpi_handoff_wakeup_s3(void) +{ + acpi_handoff_wakeup(); + return (acpi_slp_type == ACPI_S3); +} + +void __weak mainboard_suspend_resume(void) +{ +} diff --git a/src/arch/x86/Makefile.inc b/src/arch/x86/Makefile.inc index a5c3309..5157564 100644 --- a/src/arch/x86/Makefile.inc +++ b/src/arch/x86/Makefile.inc @@ -158,7 +158,6 @@
ifeq ($(CONFIG_ARCH_ROMSTAGE_X86_32)$(CONFIG_ARCH_ROMSTAGE_X86_64),y)
-romstage-$(CONFIG_HAVE_ACPI_RESUME) += acpi_s3.c romstage-y += boot.c romstage-y += post.c # gdt_init.S is included by entry32.inc when romstage is the first C @@ -202,7 +201,6 @@ endif postcar-generic-ccopts += -D__POSTCAR__
-postcar-$(CONFIG_HAVE_ACPI_RESUME) += acpi_s3.c postcar-y += boot.c postcar-y += post.c postcar-y += gdt_init.S diff --git a/src/arch/x86/acpi_s3.c b/src/arch/x86/acpi_s3.c index 1c30432..43a68f9 100644 --- a/src/arch/x86/acpi_s3.c +++ b/src/arch/x86/acpi_s3.c @@ -8,33 +8,6 @@ #include <cpu/x86/smm.h> #include <fallback.h> #include <timestamp.h> -#include <romstage_handoff.h> - -#if ENV_RAMSTAGE || ENV_POSTCAR - -/* This is filled with acpi_is_wakeup_s3() call early in ramstage. */ -static int acpi_slp_type = -1; - -static void acpi_handoff_wakeup(void) -{ - if (acpi_slp_type < 0) { - if (romstage_handoff_is_resume()) { - printk(BIOS_DEBUG, "S3 Resume\n"); - acpi_slp_type = ACPI_S3; - } else { - printk(BIOS_DEBUG, "Normal boot\n"); - acpi_slp_type = ACPI_S0; - } - } -} - -int acpi_is_wakeup_s3(void) -{ - acpi_handoff_wakeup(); - return (acpi_slp_type == ACPI_S3); -} - -#endif /* ENV_RAMSTAGE */
#define WAKEUP_BASE 0x600
@@ -43,10 +16,6 @@ extern unsigned char __wakeup; extern unsigned int __wakeup_size;
-void __weak mainboard_suspend_resume(void) -{ -} - void __noreturn acpi_resume(void *wake_vec) { /* Restore GNVS pointer in SMM if found. */ diff --git a/src/include/acpi/acpi.h b/src/include/acpi/acpi.h index bdea467..839d485 100644 --- a/src/include/acpi/acpi.h +++ b/src/include/acpi/acpi.h @@ -1017,6 +1017,7 @@ void __noreturn acpi_resume(void *wake_vec); void mainboard_suspend_resume(void); void *acpi_find_wakeup_vector(void); +int acpi_handoff_wakeup_s3(void);
/* ACPI_Sn assignments are defined to always equal the sleep state numbers */ enum { @@ -1062,20 +1063,16 @@ return CONFIG(HAVE_ACPI_RESUME); }
-#if CONFIG(HAVE_ACPI_RESUME) - -#if ENV_ROMSTAGE_OR_BEFORE static inline int acpi_is_wakeup_s3(void) { - return (acpi_get_sleep_type() == ACPI_S3); -} -#else -int acpi_is_wakeup_s3(void); -#endif + if (!acpi_s3_resume_allowed()) + return 0;
-#else -static inline int acpi_is_wakeup_s3(void) { return 0; } -#endif + if (ENV_ROMSTAGE_OR_BEFORE) + return (acpi_get_sleep_type() == ACPI_S3); + + return acpi_handoff_wakeup_s3(); +}
static inline uintptr_t acpi_align_current(uintptr_t current) {