aboutsummaryrefslogtreecommitdiffstats
path: root/arch/microblaze/kernel/cpu
diff options
context:
space:
mode:
authorRussell King <rmk+kernel@arm.linux.org.uk>2010-05-13 04:56:24 -0400
committerRussell King <rmk+kernel@arm.linux.org.uk>2010-05-13 04:56:24 -0400
commit74b8721099992b76d3faff78cb8a5d13c65c3529 (patch)
tree2c9971160051cae98237715f791ce2b93a0720b5 /arch/microblaze/kernel/cpu
parent4bddaf66093ce0e0c1fce505f091f4cd52e73e2e (diff)
parentbaffe1699c68da5040de6b274054adc995795782 (diff)
Merge branch 'devel' of git://git.kernel.org/pub/scm/linux/kernel/git/ycmiao/pxa-linux-2.6 into devel-stable
Diffstat (limited to 'arch/microblaze/kernel/cpu')
-rw-r--r--arch/microblaze/kernel/cpu/cache.c72
-rw-r--r--arch/microblaze/kernel/cpu/mb.c10
2 files changed, 46 insertions, 36 deletions
diff --git a/arch/microblaze/kernel/cpu/cache.c b/arch/microblaze/kernel/cpu/cache.c
index f04d8a86dead..21c3a92394de 100644
--- a/arch/microblaze/kernel/cpu/cache.c
+++ b/arch/microblaze/kernel/cpu/cache.c
@@ -96,13 +96,16 @@ static inline void __disable_dcache_nomsr(void)
96} 96}
97 97
98 98
99/* Helper macro for computing the limits of cache range loops */ 99/* Helper macro for computing the limits of cache range loops
100 *
101 * End address can be unaligned which is OK for C implementation.
102 * ASM implementation align it in ASM macros
103 */
100#define CACHE_LOOP_LIMITS(start, end, cache_line_length, cache_size) \ 104#define CACHE_LOOP_LIMITS(start, end, cache_line_length, cache_size) \
101do { \ 105do { \
102 int align = ~(cache_line_length - 1); \ 106 int align = ~(cache_line_length - 1); \
103 end = min(start + cache_size, end); \ 107 end = min(start + cache_size, end); \
104 start &= align; \ 108 start &= align; \
105 end = ((end & align) + cache_line_length); \
106} while (0); 109} while (0);
107 110
108/* 111/*
@@ -111,9 +114,9 @@ do { \
111 */ 114 */
112#define CACHE_ALL_LOOP(cache_size, line_length, op) \ 115#define CACHE_ALL_LOOP(cache_size, line_length, op) \
113do { \ 116do { \
114 unsigned int len = cache_size; \ 117 unsigned int len = cache_size - line_length; \
115 int step = -line_length; \ 118 int step = -line_length; \
116 BUG_ON(step >= 0); \ 119 WARN_ON(step >= 0); \
117 \ 120 \
118 __asm__ __volatile__ (" 1: " #op " %0, r0; \ 121 __asm__ __volatile__ (" 1: " #op " %0, r0; \
119 bgtid %0, 1b; \ 122 bgtid %0, 1b; \
@@ -122,26 +125,21 @@ do { \
122 : "memory"); \ 125 : "memory"); \
123} while (0); 126} while (0);
124 127
125 128/* Used for wdc.flush/clear which can use rB for offset which is not possible
126#define CACHE_ALL_LOOP2(cache_size, line_length, op) \ 129 * to use for simple wdc or wic.
127do { \ 130 *
128 unsigned int len = cache_size; \ 131 * start address is cache aligned
129 int step = -line_length; \ 132 * end address is not aligned, if end is aligned then I have to substract
130 BUG_ON(step >= 0); \ 133 * cacheline length because I can't flush/invalidate the next cacheline.
131 \ 134 * If is not, I align it because I will flush/invalidate whole line.
132 __asm__ __volatile__ (" 1: " #op " r0, %0; \ 135 */
133 bgtid %0, 1b; \
134 addk %0, %0, %1; \
135 " : : "r" (len), "r" (step) \
136 : "memory"); \
137} while (0);
138
139/* for wdc.flush/clear */
140#define CACHE_RANGE_LOOP_2(start, end, line_length, op) \ 136#define CACHE_RANGE_LOOP_2(start, end, line_length, op) \
141do { \ 137do { \
142 int step = -line_length; \ 138 int step = -line_length; \
139 int align = ~(line_length - 1); \
140 end = ((end & align) == end) ? end - line_length : end & align; \
143 int count = end - start; \ 141 int count = end - start; \
144 BUG_ON(count <= 0); \ 142 WARN_ON(count < 0); \
145 \ 143 \
146 __asm__ __volatile__ (" 1: " #op " %0, %1; \ 144 __asm__ __volatile__ (" 1: " #op " %0, %1; \
147 bgtid %1, 1b; \ 145 bgtid %1, 1b; \
@@ -154,7 +152,9 @@ do { \
154#define CACHE_RANGE_LOOP_1(start, end, line_length, op) \ 152#define CACHE_RANGE_LOOP_1(start, end, line_length, op) \
155do { \ 153do { \
156 int volatile temp; \ 154 int volatile temp; \
157 BUG_ON(end - start <= 0); \ 155 int align = ~(line_length - 1); \
156 end = ((end & align) == end) ? end - line_length : end & align; \
157 WARN_ON(end - start < 0); \
158 \ 158 \
159 __asm__ __volatile__ (" 1: " #op " %1, r0; \ 159 __asm__ __volatile__ (" 1: " #op " %1, r0; \
160 cmpu %0, %1, %2; \ 160 cmpu %0, %1, %2; \
@@ -360,8 +360,12 @@ static void __invalidate_dcache_all_noirq_wt(void)
360#endif 360#endif
361} 361}
362 362
363/* FIXME this is weird - should be only wdc but not work 363/* FIXME It is blindly invalidation as is expected
364 * MS: I am getting bus errors and other weird things */ 364 * but can't be called on noMMU in microblaze_cache_init below
365 *
366 * MS: noMMU kernel won't boot if simple wdc is used
367 * The reason should be that there are discared data which kernel needs
368 */
365static void __invalidate_dcache_all_wb(void) 369static void __invalidate_dcache_all_wb(void)
366{ 370{
367#ifndef ASM_LOOP 371#ifndef ASM_LOOP
@@ -369,12 +373,12 @@ static void __invalidate_dcache_all_wb(void)
369#endif 373#endif
370 pr_debug("%s\n", __func__); 374 pr_debug("%s\n", __func__);
371#ifdef ASM_LOOP 375#ifdef ASM_LOOP
372 CACHE_ALL_LOOP2(cpuinfo.dcache_size, cpuinfo.dcache_line_length, 376 CACHE_ALL_LOOP(cpuinfo.dcache_size, cpuinfo.dcache_line_length,
373 wdc.clear) 377 wdc)
374#else 378#else
375 for (i = 0; i < cpuinfo.dcache_size; 379 for (i = 0; i < cpuinfo.dcache_size;
376 i += cpuinfo.dcache_line_length) 380 i += cpuinfo.dcache_line_length)
377 __asm__ __volatile__ ("wdc.clear %0, r0;" \ 381 __asm__ __volatile__ ("wdc %0, r0;" \
378 : : "r" (i)); 382 : : "r" (i));
379#endif 383#endif
380} 384}
@@ -393,7 +397,7 @@ static void __invalidate_dcache_range_wb(unsigned long start,
393#ifdef ASM_LOOP 397#ifdef ASM_LOOP
394 CACHE_RANGE_LOOP_2(start, end, cpuinfo.dcache_line_length, wdc.clear); 398 CACHE_RANGE_LOOP_2(start, end, cpuinfo.dcache_line_length, wdc.clear);
395#else 399#else
396 for (i = start; i < end; i += cpuinfo.icache_line_length) 400 for (i = start; i < end; i += cpuinfo.dcache_line_length)
397 __asm__ __volatile__ ("wdc.clear %0, r0;" \ 401 __asm__ __volatile__ ("wdc.clear %0, r0;" \
398 : : "r" (i)); 402 : : "r" (i));
399#endif 403#endif
@@ -413,7 +417,7 @@ static void __invalidate_dcache_range_nomsr_wt(unsigned long start,
413#ifdef ASM_LOOP 417#ifdef ASM_LOOP
414 CACHE_RANGE_LOOP_1(start, end, cpuinfo.dcache_line_length, wdc); 418 CACHE_RANGE_LOOP_1(start, end, cpuinfo.dcache_line_length, wdc);
415#else 419#else
416 for (i = start; i < end; i += cpuinfo.icache_line_length) 420 for (i = start; i < end; i += cpuinfo.dcache_line_length)
417 __asm__ __volatile__ ("wdc %0, r0;" \ 421 __asm__ __volatile__ ("wdc %0, r0;" \
418 : : "r" (i)); 422 : : "r" (i));
419#endif 423#endif
@@ -437,7 +441,7 @@ static void __invalidate_dcache_range_msr_irq_wt(unsigned long start,
437#ifdef ASM_LOOP 441#ifdef ASM_LOOP
438 CACHE_RANGE_LOOP_1(start, end, cpuinfo.dcache_line_length, wdc); 442 CACHE_RANGE_LOOP_1(start, end, cpuinfo.dcache_line_length, wdc);
439#else 443#else
440 for (i = start; i < end; i += cpuinfo.icache_line_length) 444 for (i = start; i < end; i += cpuinfo.dcache_line_length)
441 __asm__ __volatile__ ("wdc %0, r0;" \ 445 __asm__ __volatile__ ("wdc %0, r0;" \
442 : : "r" (i)); 446 : : "r" (i));
443#endif 447#endif
@@ -465,7 +469,7 @@ static void __invalidate_dcache_range_nomsr_irq(unsigned long start,
465#ifdef ASM_LOOP 469#ifdef ASM_LOOP
466 CACHE_RANGE_LOOP_1(start, end, cpuinfo.dcache_line_length, wdc); 470 CACHE_RANGE_LOOP_1(start, end, cpuinfo.dcache_line_length, wdc);
467#else 471#else
468 for (i = start; i < end; i += cpuinfo.icache_line_length) 472 for (i = start; i < end; i += cpuinfo.dcache_line_length)
469 __asm__ __volatile__ ("wdc %0, r0;" \ 473 __asm__ __volatile__ ("wdc %0, r0;" \
470 : : "r" (i)); 474 : : "r" (i));
471#endif 475#endif
@@ -504,7 +508,7 @@ static void __flush_dcache_range_wb(unsigned long start, unsigned long end)
504#ifdef ASM_LOOP 508#ifdef ASM_LOOP
505 CACHE_RANGE_LOOP_2(start, end, cpuinfo.dcache_line_length, wdc.flush); 509 CACHE_RANGE_LOOP_2(start, end, cpuinfo.dcache_line_length, wdc.flush);
506#else 510#else
507 for (i = start; i < end; i += cpuinfo.icache_line_length) 511 for (i = start; i < end; i += cpuinfo.dcache_line_length)
508 __asm__ __volatile__ ("wdc.flush %0, r0;" \ 512 __asm__ __volatile__ ("wdc.flush %0, r0;" \
509 : : "r" (i)); 513 : : "r" (i));
510#endif 514#endif
@@ -650,7 +654,11 @@ void microblaze_cache_init(void)
650 } 654 }
651 } 655 }
652 } 656 }
653 invalidate_dcache(); 657/* FIXME Invalidation is done in U-BOOT
658 * WT cache: Data is already written to main memory
659 * WB cache: Discard data on noMMU which caused that kernel doesn't boot
660 */
661 /* invalidate_dcache(); */
654 enable_dcache(); 662 enable_dcache();
655 663
656 invalidate_icache(); 664 invalidate_icache();
diff --git a/arch/microblaze/kernel/cpu/mb.c b/arch/microblaze/kernel/cpu/mb.c
index 0c912b2a8e03..4216eb1eaa32 100644
--- a/arch/microblaze/kernel/cpu/mb.c
+++ b/arch/microblaze/kernel/cpu/mb.c
@@ -98,15 +98,17 @@ static int show_cpuinfo(struct seq_file *m, void *v)
98 98
99 if (cpuinfo.use_icache) 99 if (cpuinfo.use_icache)
100 count += seq_printf(m, 100 count += seq_printf(m,
101 "Icache:\t\t%ukB\n", 101 "Icache:\t\t%ukB\tline length:\t%dB\n",
102 cpuinfo.icache_size >> 10); 102 cpuinfo.icache_size >> 10,
103 cpuinfo.icache_line_length);
103 else 104 else
104 count += seq_printf(m, "Icache:\t\tno\n"); 105 count += seq_printf(m, "Icache:\t\tno\n");
105 106
106 if (cpuinfo.use_dcache) { 107 if (cpuinfo.use_dcache) {
107 count += seq_printf(m, 108 count += seq_printf(m,
108 "Dcache:\t\t%ukB\n", 109 "Dcache:\t\t%ukB\tline length:\t%dB\n",
109 cpuinfo.dcache_size >> 10); 110 cpuinfo.dcache_size >> 10,
111 cpuinfo.dcache_line_length);
110 if (cpuinfo.dcache_wb) 112 if (cpuinfo.dcache_wb)
111 count += seq_printf(m, "\t\twrite-back\n"); 113 count += seq_printf(m, "\t\twrite-back\n");
112 else 114 else