[coreboot-gerrit] New patch to review for coreboot: lib/timestamp: Do not double-initialize the timestamp cache
Alexandru Gagniuc (alexandrux.gagniuc@intel.com)
gerrit at coreboot.org
Tue May 17 01:58:50 CEST 2016
Alexandru Gagniuc (alexandrux.gagniuc at intel.com) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/14862
-gerrit
commit 372b3148bf5ad33b9ad85718bf2bc79f3d4642f8
Author: Alexandru Gagniuc <alexandrux.gagniuc at intel.com>
Date: Mon May 16 16:17:39 2016 -0700
lib/timestamp: Do not double-initialize the timestamp cache
In some situations, more than one caller might call timestamp_init().
When that happens, do not re-initialize the timestamp cache, and keep
the original base timestamp that already exists.
This is useful, for example, in the bootblock, when a timestamp is
available which predates the call to main() in lib/bootblock.c
Change-Id: I17bb0add9f2d8721504b2e534dd6904d1201989c
Signed-off-by: Alexandru Gagniuc <alexandrux.gagniuc at intel.com>
---
src/include/timestamp.h | 2 +-
src/lib/timestamp.c | 4 ++++
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/src/include/timestamp.h b/src/include/timestamp.h
index 7e51d80..edb4f1d 100644
--- a/src/include/timestamp.h
+++ b/src/include/timestamp.h
@@ -25,7 +25,7 @@
* 2. !__PRE_RAM__ (ramstage)
* The latter is taken care of by the generic coreboot infrastructure so
* it's up to the chipset/arch to call timestamp_init() in *one* of
- * the __PRE_RAM__ stages. If multiple calls are made timestamps will be lost.
+ * the __PRE_RAM__ stages.
*/
void timestamp_init(uint64_t base);
/*
diff --git a/src/lib/timestamp.c b/src/lib/timestamp.c
index 372076c..3face87 100644
--- a/src/lib/timestamp.c
+++ b/src/lib/timestamp.c
@@ -207,6 +207,10 @@ void timestamp_init(uint64_t base)
ts_cache->cache_state != TIMESTAMP_CACHE_UNINITIALIZED)
return;
+ /* Do not double-initialize a cache that is already initialized. */
+ if (ts_cache->cache_state == TIMESTAMP_CACHE_INITIALIZED)
+ return;
+
timestamp_cache_init(ts_cache, base);
}
More information about the coreboot-gerrit
mailing list