aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorScott Wood <scottwood@freescale.com>2013-07-23 21:21:11 -0400
committerScott Wood <scottwood@freescale.com>2013-08-20 16:45:49 -0400
commitd52459ca3047435aa5d7957e50857fc7ba193411 (patch)
treeb0e14ee68283d438d4ee5baa89d4a652f753a8b2 /arch
parentafbcdd97bf117bc2d01b865a32f78f662437a4d8 (diff)
powerpc/fsl-booke: Work around erratum A-006958
Erratum A-006598 says that 64-bit mftb is not atomic -- it's subject to a similar race condition as doing mftbu/mftbl on 32-bit. The lower half of timebase is updated before the upper half; thus, we can share the workaround for a similar bug on Cell. This workaround involves looping if the lower half of timebase is zero, thus avoiding the need for a scratch register (other than CR0). This workaround must be avoided when the timebase is frozen, such as during the timebase sync code. This deals with kernel and vdso accesses, but other userspace accesses will of course need to be fixed elsewhere. Signed-off-by: Scott Wood <scottwood@freescale.com>
Diffstat (limited to 'arch')
-rw-r--r--arch/powerpc/include/asm/cputable.h9
-rw-r--r--arch/powerpc/include/asm/ppc_asm.h2
-rw-r--r--arch/powerpc/include/asm/reg.h2
-rw-r--r--arch/powerpc/platforms/85xx/smp.c23
4 files changed, 32 insertions, 4 deletions
diff --git a/arch/powerpc/include/asm/cputable.h b/arch/powerpc/include/asm/cputable.h
index 6f3887d884d2..0d4939ba48e7 100644
--- a/arch/powerpc/include/asm/cputable.h
+++ b/arch/powerpc/include/asm/cputable.h
@@ -371,14 +371,19 @@ extern const char *powerpc_base_platform;
371#define CPU_FTRS_E500MC (CPU_FTR_USE_TB | CPU_FTR_NODSISRALIGN | \ 371#define CPU_FTRS_E500MC (CPU_FTR_USE_TB | CPU_FTR_NODSISRALIGN | \
372 CPU_FTR_L2CSR | CPU_FTR_LWSYNC | CPU_FTR_NOEXECUTE | \ 372 CPU_FTR_L2CSR | CPU_FTR_LWSYNC | CPU_FTR_NOEXECUTE | \
373 CPU_FTR_DBELL | CPU_FTR_DEBUG_LVL_EXC | CPU_FTR_EMB_HV) 373 CPU_FTR_DBELL | CPU_FTR_DEBUG_LVL_EXC | CPU_FTR_EMB_HV)
374/*
375 * e5500/e6500 erratum A-006958 is a timebase bug that can use the
376 * same workaround as CPU_FTR_CELL_TB_BUG.
377 */
374#define CPU_FTRS_E5500 (CPU_FTR_USE_TB | CPU_FTR_NODSISRALIGN | \ 378#define CPU_FTRS_E5500 (CPU_FTR_USE_TB | CPU_FTR_NODSISRALIGN | \
375 CPU_FTR_L2CSR | CPU_FTR_LWSYNC | CPU_FTR_NOEXECUTE | \ 379 CPU_FTR_L2CSR | CPU_FTR_LWSYNC | CPU_FTR_NOEXECUTE | \
376 CPU_FTR_DBELL | CPU_FTR_POPCNTB | CPU_FTR_POPCNTD | \ 380 CPU_FTR_DBELL | CPU_FTR_POPCNTB | CPU_FTR_POPCNTD | \
377 CPU_FTR_DEBUG_LVL_EXC | CPU_FTR_EMB_HV) 381 CPU_FTR_DEBUG_LVL_EXC | CPU_FTR_EMB_HV | CPU_FTR_CELL_TB_BUG)
378#define CPU_FTRS_E6500 (CPU_FTR_USE_TB | CPU_FTR_NODSISRALIGN | \ 382#define CPU_FTRS_E6500 (CPU_FTR_USE_TB | CPU_FTR_NODSISRALIGN | \
379 CPU_FTR_L2CSR | CPU_FTR_LWSYNC | CPU_FTR_NOEXECUTE | \ 383 CPU_FTR_L2CSR | CPU_FTR_LWSYNC | CPU_FTR_NOEXECUTE | \
380 CPU_FTR_DBELL | CPU_FTR_POPCNTB | CPU_FTR_POPCNTD | \ 384 CPU_FTR_DBELL | CPU_FTR_POPCNTB | CPU_FTR_POPCNTD | \
381 CPU_FTR_DEBUG_LVL_EXC | CPU_FTR_EMB_HV | CPU_FTR_ALTIVEC_COMP) 385 CPU_FTR_DEBUG_LVL_EXC | CPU_FTR_EMB_HV | CPU_FTR_ALTIVEC_COMP | \
386 CPU_FTR_CELL_TB_BUG)
382#define CPU_FTRS_GENERIC_32 (CPU_FTR_COMMON | CPU_FTR_NODSISRALIGN) 387#define CPU_FTRS_GENERIC_32 (CPU_FTR_COMMON | CPU_FTR_NODSISRALIGN)
383 388
384/* 64-bit CPUs */ 389/* 64-bit CPUs */
diff --git a/arch/powerpc/include/asm/ppc_asm.h b/arch/powerpc/include/asm/ppc_asm.h
index 4ebb4f8f4188..8fdd3da134e0 100644
--- a/arch/powerpc/include/asm/ppc_asm.h
+++ b/arch/powerpc/include/asm/ppc_asm.h
@@ -431,7 +431,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_601)
431#define ISYNC_601 431#define ISYNC_601
432#endif 432#endif
433 433
434#ifdef CONFIG_PPC_CELL 434#if defined(CONFIG_PPC_CELL) || defined(CONFIG_PPC_FSL_BOOK3E)
435#define MFTB(dest) \ 435#define MFTB(dest) \
43690: mftb dest; \ 43690: mftb dest; \
437BEGIN_FTR_SECTION_NESTED(96); \ 437BEGIN_FTR_SECTION_NESTED(96); \
diff --git a/arch/powerpc/include/asm/reg.h b/arch/powerpc/include/asm/reg.h
index a312e0c8cef4..55b03079d197 100644
--- a/arch/powerpc/include/asm/reg.h
+++ b/arch/powerpc/include/asm/reg.h
@@ -1117,7 +1117,7 @@
1117 : "memory") 1117 : "memory")
1118 1118
1119#ifdef __powerpc64__ 1119#ifdef __powerpc64__
1120#ifdef CONFIG_PPC_CELL 1120#if defined(CONFIG_PPC_CELL) || defined(CONFIG_PPC_FSL_BOOK3E)
1121#define mftb() ({unsigned long rval; \ 1121#define mftb() ({unsigned long rval; \
1122 asm volatile( \ 1122 asm volatile( \
1123 "90: mftb %0;\n" \ 1123 "90: mftb %0;\n" \
diff --git a/arch/powerpc/platforms/85xx/smp.c b/arch/powerpc/platforms/85xx/smp.c
index ea9c6269ead0..ea7e62910891 100644
--- a/arch/powerpc/platforms/85xx/smp.c
+++ b/arch/powerpc/platforms/85xx/smp.c
@@ -69,7 +69,30 @@ static void mpc85xx_give_timebase(void)
69 tb_req = 0; 69 tb_req = 0;
70 70
71 mpc85xx_timebase_freeze(1); 71 mpc85xx_timebase_freeze(1);
72#ifdef CONFIG_PPC64
73 /*
74 * e5500/e6500 have a workaround for erratum A-006958 in place
75 * that will reread the timebase until TBL is non-zero.
76 * That would be a bad thing when the timebase is frozen.
77 *
78 * Thus, we read it manually, and instead of checking that
79 * TBL is non-zero, we ensure that TB does not change. We don't
80 * do that for the main mftb implementation, because it requires
81 * a scratch register
82 */
83 {
84 u64 prev;
85
86 asm volatile("mftb %0" : "=r" (timebase));
87
88 do {
89 prev = timebase;
90 asm volatile("mftb %0" : "=r" (timebase));
91 } while (prev != timebase);
92 }
93#else
72 timebase = get_tb(); 94 timebase = get_tb();
95#endif
73 mb(); 96 mb();
74 tb_valid = 1; 97 tb_valid = 1;
75 98