[coreboot-gerrit] New patch to review for coreboot: ecd997d pistachio: modify timer to account for CPU counter overflow
Stefan Reinauer (stefan.reinauer@coreboot.org)
gerrit at coreboot.org
Tue Apr 14 03:03:13 CEST 2015
Stefan Reinauer (stefan.reinauer at coreboot.org) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/9672
-gerrit
commit ecd997d8fa009d75c441bf6910c48fb3000e250b
Author: Ionela Voinescu <ionela.voinescu at imgtec.com>
Date: Tue Feb 10 18:41:47 2015 +0000
pistachio: modify timer to account for CPU counter overflow
Extended the 32bit CPU counter to 64bit by adding a static
variable that takes into account CPU counter overflow.
The varibale is updated everythime the timer_raw_value
function is called so I assume that the function is called
often enought to not miss an overflow of the CPU counter.
BUG=chrome-os-partner:31438
TEST=tested on Pistachio bring up board; works as expected
BRANCH=none
Change-Id: I98bcc56e600dcff0c6da7c140dd34faec5e00885
Signed-off-by: Stefan Reinauer <reinauer at chromium.org>
Original-Commit-Id: 972b105f950d800fa44f27bce090f6b89a5a84b9
Original-Change-Id: Id67b14e9d9c2354bc417b6587b615d466690c9b7
Original-Signed-off-by: Ionela Voinescu <ionela.voinescu at imgtec.com>
Original-Reviewed-on: https://chromium-review.googlesource.com/247642
Original-Reviewed-by: Daniel Ehrenberg <dehrenberg at chromium.org>
---
payloads/libpayload/drivers/timer/img_pistachio.c | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/payloads/libpayload/drivers/timer/img_pistachio.c b/payloads/libpayload/drivers/timer/img_pistachio.c
index ae53a9d..9257bfe 100644
--- a/payloads/libpayload/drivers/timer/img_pistachio.c
+++ b/payloads/libpayload/drivers/timer/img_pistachio.c
@@ -27,5 +27,16 @@ uint64_t timer_hz(void)
uint64_t timer_raw_value(void)
{
- return read_c0_count() * 2;
+ static uint64_t total_ticks = 0;
+ uint8_t overflow = 0;
+ uint32_t current_ticks = read_c0_count() * 2;
+
+ /* It assumes only one overflow happened since the last call */
+ if (current_ticks <= (uint32_t)total_ticks)
+ overflow = 1;
+ /* The least significant part(32 bits) of total_ticks will always
+ * become equal to current ticks */
+ total_ticks = (((total_ticks >> 32) + overflow) << 32) +
+ current_ticks;
+ return total_ticks;
}
More information about the coreboot-gerrit
mailing list