[coreboot-gerrit] New patch to review for coreboot: 4cc31dc timestamp: refine boot CPU test

Patrick Georgi (pgeorgi@google.com) gerrit at coreboot.org
Tue May 5 15:15:32 CEST 2015


Patrick Georgi (pgeorgi at google.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/10102

-gerrit

commit 4cc31dc680b1fe28e0d0924c83618fcead77d62b
Author: Aaron Durbin <adurbin at chromium.org>
Date:   Fri May 1 16:48:54 2015 -0500

    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 <adurbin at chromium.org>
    Signed-off-by: Patrick Georgi <pgeorgi at chromium.org>
---
 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 5846781..9a0e631 100644
--- a/src/lib/timestamp.c
+++ b/src/lib/timestamp.c
@@ -21,8 +21,10 @@
 #include <stdint.h>
 #include <console/console.h>
 #include <cbmem.h>
+#include <timer.h>
 #include <timestamp.h>
 #include <arch/early_variables.h>
+#include <rules.h>
 #include <smp/node.h>
 
 #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__



More information about the coreboot-gerrit mailing list