From 0a96a1ca0613e5d7b624e5e608aaeb679ef56dbf Mon Sep 17 00:00:00 2001 From: Matt DeVillier Date: Wed, 19 Jul 2023 12:06:06 -0500 Subject: soc/amd/common/pi: Ensure AGESA S3 resume called before SMM lock AGESA S3 restore needs to occur before SMM finalization/locking, but it's a crapshoot as to which runs first since both use the same BS_OS_RESUME/BS_ON_ENTRY boot state callback, and there's no way to prioritize/force ordering. To work around this, move the AGESA S3 resume call to the preceding boot state (BS_OS_RESUME_CHECK) to ensure it runs first, and guard it to ensure it only runs on the S3 resume path. BUG=none TEST=build/boot google/liara, verify S3 resume successful. Change-Id: I765db140c6708a0b129f79fb7d3dc8a4ab3095bd Signed-off-by: Matt DeVillier Reviewed-on: https://review.coreboot.org/c/coreboot/+/76592 Reviewed-by: Fred Reitberger Tested-by: build bot (Jenkins) Reviewed-by: Marshall Dawson --- src/soc/amd/common/pi/amd_resume_final.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/soc/amd/common/pi') diff --git a/src/soc/amd/common/pi/amd_resume_final.c b/src/soc/amd/common/pi/amd_resume_final.c index 380ffc8b1a..995ac4654d 100644 --- a/src/soc/amd/common/pi/amd_resume_final.c +++ b/src/soc/amd/common/pi/amd_resume_final.c @@ -1,12 +1,14 @@ /* SPDX-License-Identifier: GPL-2.0-only */ +#include #include #include static void agesawrapper_s3finalrestore(void *unused) { - do_agesawrapper(AMD_S3FINAL_RESTORE, "amds3finalrestore"); + /* Needed since running on BS_OS_RESUME_CHECK to ensure execution before SMM lock */ + if (acpi_is_wakeup_s3()) + do_agesawrapper(AMD_S3FINAL_RESTORE, "amds3finalrestore"); } -BOOT_STATE_INIT_ENTRY(BS_OS_RESUME, BS_ON_ENTRY, - agesawrapper_s3finalrestore, NULL); +BOOT_STATE_INIT_ENTRY(BS_OS_RESUME_CHECK, BS_ON_EXIT, agesawrapper_s3finalrestore, NULL); -- cgit v1.2.3