diff options
author | Kyösti Mälkki <kyosti.malkki@gmail.com> | 2020-01-09 08:41:46 +0200 |
---|---|---|
committer | Nico Huber <nico.h@gmx.de> | 2020-01-10 14:12:00 +0000 |
commit | d548edde4b8cb67a669cf621f506773d0a3afc73 (patch) | |
tree | f9c077f45eff3a3d5edc8d22ef7dc0bbc6bb22c0 /src | |
parent | 8b93cb756cda7437bff13a34dba1b2754e306ab8 (diff) |
timestamps: Fix syncing, logging and comments
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 <kyosti.malkki@gmail.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/38301
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net>
Reviewed-by: Martin Roth <martinroth@google.com>
Reviewed-by: Nico Huber <nico.h@gmx.de>
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/timestamp.c | 15 |
1 files changed, 6 insertions, 9 deletions
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; } |