From 7c670695fa560dee9fd7639b0ed2a2cf56889f53 Mon Sep 17 00:00:00 2001 From: Daniel Kurtz Date: Thu, 24 May 2018 18:24:07 -0600 Subject: elog: Only log POST code from previous boot on non-S3 resume It doesn't make sense to log post codes from a previous (failed) boot if we are resuming from S3, since the previous boot has to have been successful in order to enter S3 in the first place. While we are at it, use a helper function to combine conditionals and improve readability. BUG=none TEST=boot, suspend & resume grunt Change-Id: I4f3bb8526a0c8c0ea1efd924628b33c147543b88 Signed-off-by: Daniel Kurtz Reviewed-on: https://review.coreboot.org/26528 Reviewed-by: Martin Roth Reviewed-by: Aaron Durbin Reviewed-by: Simon Glass Reviewed-by: Paul Menzel Tested-by: build bot (Jenkins) --- src/drivers/elog/elog.c | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/src/drivers/elog/elog.c b/src/drivers/elog/elog.c index ff4f0364c5..d41457d552 100644 --- a/src/drivers/elog/elog.c +++ b/src/drivers/elog/elog.c @@ -736,6 +736,21 @@ static int elog_sync_to_nv(void) return 0; } +/* + * Do not log boot count events in S3 resume or SMM. + */ +static bool elog_do_add_boot_count(void) +{ + if (ENV_SMM) + return false; + +#if IS_ENABLED(CONFIG_HAVE_ACPI_RESUME) + return !acpi_is_wakeup_s3(); +#else + return true; +#endif +} + /* * Event log main entry point */ @@ -784,20 +799,15 @@ int elog_init(void) " shrink size %d\n", region_device_sz(&nv_dev), full_threshold, shrink_size); -#if !defined(__SMM__) - /* Log boot count event except in S3 resume */ -#if IS_ENABLED(CONFIG_HAVE_ACPI_RESUME) - if (!acpi_is_wakeup_s3()) -#endif + if (elog_do_add_boot_count()) { elog_add_event_dword(ELOG_TYPE_BOOT, boot_count_read()); #if IS_ENABLED(CONFIG_ARCH_X86) - /* Check and log POST codes from previous boot */ - if (IS_ENABLED(CONFIG_CMOS_POST)) - cmos_post_log(); + /* Check and log POST codes from previous boot */ + if (IS_ENABLED(CONFIG_CMOS_POST)) + cmos_post_log(); #endif -#endif - + } return 0; } -- cgit v1.2.3