summaryrefslogtreecommitdiffstats
path: root/import/chips/p9/procedures/ppe
diff options
context:
space:
mode:
authorYue Du <daviddu@us.ibm.com>2017-02-20 10:45:56 -0600
committerJoshua Hunsberger <jahunsbe@us.ibm.com>2017-10-23 17:09:25 -0500
commitb20515f2a07cd6818ed859575d7e8796d6606489 (patch)
tree8afa0219171f470c476e37dc21cd1c0ba8299ca7 /import/chips/p9/procedures/ppe
parent8dc39c9d0c7dadfdec87a8a9e915b98894845670 (diff)
downloadtalos-hcode-b20515f2a07cd6818ed859575d7e8796d6606489.tar.gz
talos-hcode-b20515f2a07cd6818ed859575d7e8796d6606489.zip
Fapi2/PPE plat: fix timebase incrementer in delay implementation
Change-Id: I8c813b317a6015e504abf3dbc936d3eae1d96930 Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/36723 Tested-by: Jenkins Server <pfd-jenkins+hostboot@us.ibm.com> Reviewed-by: ASHISH A. MORE <ashish.more@in.ibm.com> Reviewed-by: JAMES DEZELLE <jdezelle@us.ibm.com> Reviewed-by: Gregory S. Still <stillgs@us.ibm.com>
Diffstat (limited to 'import/chips/p9/procedures/ppe')
-rw-r--r--import/chips/p9/procedures/ppe/hwpf/src/plat/plat_utils.C31
1 files changed, 21 insertions, 10 deletions
diff --git a/import/chips/p9/procedures/ppe/hwpf/src/plat/plat_utils.C b/import/chips/p9/procedures/ppe/hwpf/src/plat/plat_utils.C
index 6339e3c5..2ae542d2 100644
--- a/import/chips/p9/procedures/ppe/hwpf/src/plat/plat_utils.C
+++ b/import/chips/p9/procedures/ppe/hwpf/src/plat/plat_utils.C
@@ -150,10 +150,11 @@ ReturnCode delay(uint64_t i_nanoSeconds, uint64_t i_simCycles, bool i_fixed = fa
#define PK_NANOSECONDS_SBE(n) ((PkInterval)((PK_BASE_FREQ_HZ * (PkInterval)(n)) / (1024*1024*1024)))
- PkTimebase target_time;
- PkTimebase current_time;
PkMachineContext ctx;
-
+ PkTimebase stamp_time = 0;
+ PkTimebase target_time = 0;
+ PkTimebase current_time_high = 0;
+ PkTimebase current_time_low = 0;
// Only execute if nanoSeconds is non-zero (eg a real wait)
if (i_nanoSeconds)
@@ -170,19 +171,29 @@ ReturnCode delay(uint64_t i_nanoSeconds, uint64_t i_simCycles, bool i_fixed = fa
// The "accurate" version is the next line.
// target_time = pk_timebase32_get() + PK_INTERVAL_SCALE(PK_NANOSECONDS(i_nanoSeconds));
- target_time = pk_timebase32_get() + PK_INTERVAL_SCALE(PK_NANOSECONDS_SBE(i_nanoSeconds));
+ stamp_time = pk_timebase32_get();
+ target_time = stamp_time + PK_INTERVAL_SCALE(PK_NANOSECONDS_SBE(i_nanoSeconds));
do
{
- current_time = pk_timebase32_get();
- // if target time > 0xFFFFFFFF
- current_time += (target_time & 0xFFFFFFFF00000000ull);
+ current_time_low = pk_timebase32_get();
+
+ // Lower 32-bit HW timebase wraps if the old sample is bigger than new one
+ // If this occurs, increment the local upper 32-bit timebase bits
+ // This assumes the timebase is sampled faster than it can rollover
+ if (stamp_time >= current_time_low)
+ {
+ current_time_high += 0x100000000ull;
+ }
+
+ // remember the current time to compare against for the next loop
+ stamp_time = current_time_low;
}
- while (target_time > current_time);
-
- pk_critical_section_exit(&ctx);
+ // form a new 64-bit number to compare against using the high and low halves
+ while (target_time > (current_time_low | current_time_high));
+ pk_critical_section_exit(&ctx);
}
#else
OpenPOWER on IntegriCloud