summaryrefslogtreecommitdiffstats
path: root/include/asm-powerpc/time.h
diff options
context:
space:
mode:
authorBenjamin Herrenschmidt <benh@kernel.crashing.org>2006-10-20 14:37:05 +1000
committerPaul Mackerras <paulus@samba.org>2006-10-25 11:54:18 +1000
commit859deea949c382d9ccb6397fe33df3703ecef45d (patch)
treeb0fe2d7a814143f3ff61a73a0727522a1a3dd6e4 /include/asm-powerpc/time.h
parent21c4ff80cba5e24932f3ef79c8482c0491630b2b (diff)
downloadop-kernel-dev-859deea949c382d9ccb6397fe33df3703ecef45d.zip
op-kernel-dev-859deea949c382d9ccb6397fe33df3703ecef45d.tar.gz
[POWERPC] Cell timebase bug workaround
The Cell CPU timebase has an erratum. When reading the entire 64 bits of the timebase with one mftb instruction, there is a handful of cycles window during which one might read a value with the low order 32 bits already reset to 0x00000000 but the high order bits not yet incremeted by one. This fixes it by reading the timebase again until the low order 32 bits is no longer 0. That might introduce occasional latencies if hitting mftb just at the wrong time, but no more than 70ns on a cell blade, and that was considered acceptable. Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org> Acked-by: Olof Johansson <olof@lixom.net> Signed-off-by: Paul Mackerras <paulus@samba.org>
Diffstat (limited to 'include/asm-powerpc/time.h')
-rw-r--r--include/asm-powerpc/time.h27
1 files changed, 16 insertions, 11 deletions
diff --git a/include/asm-powerpc/time.h b/include/asm-powerpc/time.h
index b051d4c..a782850 100644
--- a/include/asm-powerpc/time.h
+++ b/include/asm-powerpc/time.h
@@ -82,30 +82,35 @@ struct div_result {
#define __USE_RTC() 0
#endif
-/* On ppc64 this gets us the whole timebase; on ppc32 just the lower half */
+#ifdef CONFIG_PPC64
+
+/* For compatibility, get_tbl() is defined as get_tb() on ppc64 */
+#define get_tbl get_tb
+
+#else
+
static inline unsigned long get_tbl(void)
{
- unsigned long tbl;
-
#if defined(CONFIG_403GCX)
+ unsigned long tbl;
asm volatile("mfspr %0, 0x3dd" : "=r" (tbl));
+ return tbl;
#else
- asm volatile("mftb %0" : "=r" (tbl));
+ return mftbl();
#endif
- return tbl;
}
static inline unsigned int get_tbu(void)
{
+#ifdef CONFIG_403GCX
unsigned int tbu;
-
-#if defined(CONFIG_403GCX)
asm volatile("mfspr %0, 0x3dc" : "=r" (tbu));
+ return tbu;
#else
- asm volatile("mftbu %0" : "=r" (tbu));
+ return mftbu();
#endif
- return tbu;
}
+#endif /* !CONFIG_PPC64 */
static inline unsigned int get_rtcl(void)
{
@@ -131,7 +136,7 @@ static inline u64 get_tb(void)
{
return mftb();
}
-#else
+#else /* CONFIG_PPC64 */
static inline u64 get_tb(void)
{
unsigned int tbhi, tblo, tbhi2;
@@ -144,7 +149,7 @@ static inline u64 get_tb(void)
return ((u64)tbhi << 32) | tblo;
}
-#endif
+#endif /* !CONFIG_PPC64 */
static inline void set_tb(unsigned int upper, unsigned int lower)
{
OpenPOWER on IntegriCloud