From 29e9c22eb71f0a7dcbeaa6fbf2a049dbc56b7c05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ky=C3=B6sti=20M=C3=A4lkki?= Date: Sun, 13 Oct 2013 13:27:56 +0300 Subject: timestamps: Fix some lost timestamps for romstage MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Timestamps from cbfs_and_run, TS_START_COPYRAM and TS_END_COPYRAM, were lost with commit b766b1c7. Reason is variable ts_table was referencing CAR storage after CAR is torn doesn. Add use of car_get_var() / car_set_var() so the references go to migrated storage in CBMEM. Change-Id: I5a942ad7fd59a04e3a5255f4a3636d37dcfc1591 Signed-off-by: Kyösti Mälkki Reviewed-on: http://review.coreboot.org/3967 Tested-by: build bot (Jenkins) Reviewed-by: Aaron Durbin --- src/lib/timestamp.c | 50 +++++++++++++++++++++++++++++--------------------- 1 file changed, 29 insertions(+), 21 deletions(-) (limited to 'src/lib/timestamp.c') diff --git a/src/lib/timestamp.c b/src/lib/timestamp.c index 8942649099..678f38e094 100644 --- a/src/lib/timestamp.c +++ b/src/lib/timestamp.c @@ -27,7 +27,7 @@ #define MAX_TIMESTAMPS 30 -static struct timestamp_table* ts_table CAR_GLOBAL = NULL; +static struct timestamp_table* ts_table_p CAR_GLOBAL = NULL; static tsc_t ts_basetime CAR_GLOBAL = { .lo = 0, .hi =0 }; static void timestamp_stash(enum timestamp_id id, tsc_t ts_time); @@ -54,16 +54,18 @@ static void timestamp_real_init(tsc_t base) tst->max_entries = MAX_TIMESTAMPS; tst->num_entries = 0; - ts_table = tst; + car_set_var(ts_table_p, tst); } void timestamp_add(enum timestamp_id id, tsc_t ts_time) { struct timestamp_entry *tse; + struct timestamp_table *ts_table = NULL; if (!boot_cpu()) return; + ts_table = car_get_var(ts_table_p); if (!ts_table) { timestamp_stash(id, ts_time); return; @@ -90,30 +92,36 @@ struct timestamp_cache { static int timestamp_entries CAR_GLOBAL = 0; /** - * timestamp_stash() allows to temporarily cache time stamps. - * This is needed when time stamping before the CBMEM area - * is initialized. The function timestamp_sync() is used to - * write the time stamps to the CBMEM area. This is done in - * ram stage main() + * timestamp_stash() allows to temporarily cache timestamps. + * This is needed when timestamping before the CBMEM area + * is initialized. The function timestamp_do_sync() is used to + * write the timestamps to the CBMEM area and this is done as + * part of CAR migration for romstage, and in ramstage main(). */ static void timestamp_stash(enum timestamp_id id, tsc_t ts_time) { - if (timestamp_entries >= MAX_TIMESTAMP_CACHE) { + struct timestamp_cache *ts_cache = car_get_var(timestamp_cache); + int ts_entries = car_get_var(timestamp_entries); + + if (ts_entries >= MAX_TIMESTAMP_CACHE) { printk(BIOS_ERR, "ERROR: failed to add timestamp to cache\n"); return; } - timestamp_cache[timestamp_entries].id = id; - timestamp_cache[timestamp_entries].time = ts_time; - timestamp_entries++; + ts_cache[ts_entries].id = id; + ts_cache[ts_entries].time = ts_time; + car_set_var(timestamp_entries, ++ts_entries); } static void timestamp_do_sync(void) { + struct timestamp_cache *ts_cache = car_get_var(timestamp_cache); + int ts_entries = car_get_var(timestamp_entries); + int i; - for (i = 0; i < timestamp_entries; i++) - timestamp_add(timestamp_cache[i].id, timestamp_cache[i].time); - timestamp_entries = 0; + for (i = 0; i < ts_entries; i++) + timestamp_add(ts_cache[i].id, ts_cache[i].time); + car_set_var(timestamp_entries, 0); } void timestamp_init(tsc_t base) @@ -123,19 +131,19 @@ void timestamp_init(tsc_t base) #ifdef __PRE_RAM__ /* Copy of basetime, it is too early for CBMEM. */ - ts_basetime = base; + car_set_var(ts_basetime, base); #else struct timestamp_table* tst; /* Locate and use an already existing table. */ tst = cbmem_find(CBMEM_ID_TIMESTAMP); if (tst) { - ts_table = tst; + car_set_var(ts_table_p, tst); return; } /* Copy of basetime, may be too early for CBMEM. */ - ts_basetime = base; + car_set_var(ts_basetime, base); timestamp_real_init(base); #endif } @@ -146,12 +154,12 @@ void timestamp_reinit(void) return; #ifdef __PRE_RAM__ - timestamp_real_init(ts_basetime); + timestamp_real_init(car_get_var(ts_basetime)); #else - if (!ts_table) - timestamp_init(ts_basetime); + if (!car_get_var(ts_table_p)) + timestamp_init(car_get_var(ts_basetime)); #endif - if (ts_table) + if (car_get_var(ts_table_p)) timestamp_do_sync(); } -- cgit v1.2.3