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 <djkurtz@chromium.org>
Reviewed-on: https://review.coreboot.org/26528
Reviewed-by: Martin Roth <martinroth@google.com>
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
This commit is contained in:
Daniel Kurtz 2018-05-24 18:24:07 -06:00 committed by Martin Roth
parent 12173feef8
commit 7c670695fa

View file

@ -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,11 +799,7 @@ 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)
@ -796,8 +807,7 @@ int elog_init(void)
if (IS_ENABLED(CONFIG_CMOS_POST))
cmos_post_log();
#endif
#endif
}
return 0;
}