From 2daadf8f576363c6d215409b4d7899990344f3b5 Mon Sep 17 00:00:00 2001 From: Aaron Durbin Date: Fri, 1 May 2015 16:48:54 -0500 Subject: timestamp: refine boot CPU test The timestamp code's restriction to run only on the BSP is for AMD systems. No need to run it everywhere, so tighten the test (and only run boot_cpu() when required). Change-Id: I800e817cc89e8688a671672961cab15c7f788ba8 Signed-off-by: Aaron Durbin Signed-off-by: Patrick Georgi Reviewed-on: http://review.coreboot.org/10102 Tested-by: build bot (Jenkins) Reviewed-by: Paul Menzel --- src/lib/timestamp.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/lib/timestamp.c b/src/lib/timestamp.c index 5846781706..9a0e631b0b 100644 --- a/src/lib/timestamp.c +++ b/src/lib/timestamp.c @@ -21,8 +21,10 @@ #include #include #include +#include #include #include +#include #include #define MAX_TIMESTAMPS 60 @@ -52,12 +54,24 @@ static void timestamp_real_init(uint64_t base) car_set_var(ts_table_p, tst); } +/* Determine if one should proceed into timestamp code. This is for protecting + * systems that have multiple processors running in romstage -- namely AMD + * based x86 platforms. */ +static int timestamp_should_run(void) +{ + /* Only check boot_cpu() in other stages than ramstage on x86. */ + if ((!ENV_RAMSTAGE && IS_ENABLED(CONFIG_ARCH_X86)) && !boot_cpu()) + return 0; + + return 1; +} + void timestamp_add(enum timestamp_id id, uint64_t ts_time) { struct timestamp_entry *tse; struct timestamp_table *ts_table = NULL; - if (!boot_cpu()) + if (!timestamp_should_run()) return; ts_table = car_get_var(ts_table_p); @@ -121,7 +135,7 @@ static void timestamp_do_sync(void) void timestamp_init(uint64_t base) { - if (!boot_cpu()) + if (!timestamp_should_run()) return; #ifdef __PRE_RAM__ @@ -145,7 +159,7 @@ void timestamp_init(uint64_t base) void timestamp_reinit(void) { - if (!boot_cpu()) + if (!timestamp_should_run()) return; #ifdef __PRE_RAM__ -- cgit v1.2.3