From d548edde4b8cb67a669cf621f506773d0a3afc73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ky=C3=B6sti=20M=C3=A4lkki?= Date: Thu, 9 Jan 2020 08:41:46 +0200 Subject: timestamps: Fix syncing, logging and comments MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit For timestamps added before CBMEM coming online and call to timestamp_sync_cache_to_cbmem(), ts_table->base_time was subtracted twice. The second time though, the value of zero was subtracted. Make the stamps logged on the console relative to base_time too, such that cbmem -1 and cbmem -c outputs will match. Remove comments about postponing initialisation of timestamps to ramstage, that does not happen anymore. Change-Id: Ia786c12c68c8921c0d09bc58a29fefdc72bf0c6d Signed-off-by: Kyösti Mälkki Reviewed-on: https://review.coreboot.org/c/coreboot/+/38301 Tested-by: build bot (Jenkins) Reviewed-by: Paul Menzel Reviewed-by: Martin Roth Reviewed-by: Nico Huber --- src/lib/timestamp.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) (limited to 'src/lib') diff --git a/src/lib/timestamp.c b/src/lib/timestamp.c index d2206f6134..9cbe30807c 100644 --- a/src/lib/timestamp.c +++ b/src/lib/timestamp.c @@ -128,7 +128,7 @@ static void timestamp_add_table_entry(struct timestamp_table *ts_table, tse = &ts_table->entries[ts_table->num_entries++]; tse->entry_id = id; - tse->entry_stamp = ts_time - ts_table->base_time; + tse->entry_stamp = ts_time; if (ts_table->num_entries == ts_table->max_entries) printk(BIOS_ERR, "ERROR: Timestamp table full\n"); @@ -148,6 +148,7 @@ void timestamp_add(enum timestamp_id id, uint64_t ts_time) return; } + ts_time -= ts_table->base_time; timestamp_add_table_entry(ts_table, id, ts_time); if (CONFIG(TIMESTAMPS_ON_CONSOLE)) @@ -206,22 +207,18 @@ static void timestamp_sync_cache_to_cbmem(struct timestamp_table *ts_cbmem_table * * If you try to initialize timestamps before ramstage but don't define * a TIMESTAMP region, all operations will fail (safely), and coreboot - * will behave as if timestamps only get initialized in ramstage. - * - * If timestamps only get initialized in ramstage, the base_time from - * timestamp_init() will get ignored and all timestamps will be 0-based. + * will behave as if timestamps collection was disabled. */ + /* Inherit cache base_time. */ + ts_cbmem_table->base_time = ts_cache_table->base_time; + for (i = 0; i < ts_cache_table->num_entries; i++) { struct timestamp_entry *tse = &ts_cache_table->entries[i]; timestamp_add_table_entry(ts_cbmem_table, tse->entry_id, tse->entry_stamp); } - /* Freshly added cbmem table has base_time 0. Inherit cache base_time */ - if (ts_cbmem_table->base_time == 0) - ts_cbmem_table->base_time = ts_cache_table->base_time; - /* Cache no longer required. */ ts_cache_table->num_entries = 0; } -- cgit v1.2.3