aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/lib
diff options
context:
space:
mode:
Diffstat (limited to 'arch/powerpc/lib')
-rw-r--r--arch/powerpc/lib/feature-fixups-test.S15
-rw-r--r--arch/powerpc/lib/feature-fixups.c36
2 files changed, 51 insertions, 0 deletions
diff --git a/arch/powerpc/lib/feature-fixups-test.S b/arch/powerpc/lib/feature-fixups-test.S
index 0549be04399c..cb737484c5aa 100644
--- a/arch/powerpc/lib/feature-fixups-test.S
+++ b/arch/powerpc/lib/feature-fixups-test.S
@@ -10,6 +10,7 @@
10 10
11#include <asm/feature-fixups.h> 11#include <asm/feature-fixups.h>
12#include <asm/ppc_asm.h> 12#include <asm/ppc_asm.h>
13#include <asm/synch.h>
13 14
14 .text 15 .text
15 16
@@ -725,3 +726,17 @@ MAKE_MACRO_TEST_EXPECTED(FTR);
725MAKE_MACRO_TEST(FW_FTR); 726MAKE_MACRO_TEST(FW_FTR);
726MAKE_MACRO_TEST_EXPECTED(FW_FTR); 727MAKE_MACRO_TEST_EXPECTED(FW_FTR);
727#endif 728#endif
729
730globl(lwsync_fixup_test)
7311: or 1,1,1
732 LWSYNC
733globl(end_lwsync_fixup_test)
734
735globl(lwsync_fixup_test_expected_LWSYNC)
7361: or 1,1,1
737 lwsync
738
739globl(lwsync_fixup_test_expected_SYNC)
7401: or 1,1,1
741 sync
742
diff --git a/arch/powerpc/lib/feature-fixups.c b/arch/powerpc/lib/feature-fixups.c
index 48e1ed89052d..4e43702b9813 100644
--- a/arch/powerpc/lib/feature-fixups.c
+++ b/arch/powerpc/lib/feature-fixups.c
@@ -110,6 +110,22 @@ void do_feature_fixups(unsigned long value, void *fixup_start, void *fixup_end)
110 } 110 }
111} 111}
112 112
113void do_lwsync_fixups(unsigned long value, void *fixup_start, void *fixup_end)
114{
115 unsigned int *start, *end, *dest;
116
117 if (!(value & CPU_FTR_LWSYNC))
118 return ;
119
120 start = fixup_start;
121 end = fixup_end;
122
123 for (; start < end; start++) {
124 dest = (void *)start + *start;
125 patch_instruction(dest, PPC_LWSYNC_INSTR);
126 }
127}
128
113#ifdef CONFIG_FTR_FIXUP_SELFTEST 129#ifdef CONFIG_FTR_FIXUP_SELFTEST
114 130
115#define check(x) \ 131#define check(x) \
@@ -295,6 +311,25 @@ static void test_fw_macros(void)
295#endif 311#endif
296} 312}
297 313
314static void test_lwsync_macros(void)
315{
316 extern void lwsync_fixup_test;
317 extern void end_lwsync_fixup_test;
318 extern void lwsync_fixup_test_expected_LWSYNC;
319 extern void lwsync_fixup_test_expected_SYNC;
320 unsigned long size = &end_lwsync_fixup_test -
321 &lwsync_fixup_test;
322
323 /* The fixups have already been done for us during boot */
324 if (cur_cpu_spec->cpu_features & CPU_FTR_LWSYNC) {
325 check(memcmp(&lwsync_fixup_test,
326 &lwsync_fixup_test_expected_LWSYNC, size) == 0);
327 } else {
328 check(memcmp(&lwsync_fixup_test,
329 &lwsync_fixup_test_expected_SYNC, size) == 0);
330 }
331}
332
298static int __init test_feature_fixups(void) 333static int __init test_feature_fixups(void)
299{ 334{
300 printk(KERN_DEBUG "Running feature fixup self-tests ...\n"); 335 printk(KERN_DEBUG "Running feature fixup self-tests ...\n");
@@ -307,6 +342,7 @@ static int __init test_feature_fixups(void)
307 test_alternative_case_with_external_branch(); 342 test_alternative_case_with_external_branch();
308 test_cpu_macros(); 343 test_cpu_macros();
309 test_fw_macros(); 344 test_fw_macros();
345 test_lwsync_macros();
310 346
311 return 0; 347 return 0;
312} 348}