diff options
author | Steven J. Hill <sjhill@mips.com> | 2012-07-06 15:56:01 -0400 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 2012-07-19 05:23:43 -0400 |
commit | c022630633624a75b3b58f43dd3c6cc896a56cff (patch) | |
tree | ef2f21c01a55962e5e2157e7eaf6e0e49f5e5585 /arch/mips/mm | |
parent | 78d4803f75277f78ab4fc3be7ad462d78f726df9 (diff) |
MIPS: Refactor 'clear_page' and 'copy_page' functions.
Remove usage of the '__attribute__((alias("...")))' hack that aliased
to integer arrays containing micro-assembled instructions. This hack
breaks when building a microMIPS kernel. It also makes the code much
easier to understand.
[ralf@linux-mips.org: Added back export of the clear_page and copy_page
symbols so certain modules will work again. Also fixed build with
CONFIG_SIBYTE_DMA_PAGEOPS enabled.]
Signed-off-by: Steven J. Hill <sjhill@mips.com>
Cc: linux-mips@linux-mips.org
Patchwork: https://patchwork.linux-mips.org/patch/3866/
Acked-by: David Daney <david.daney@cavium.com>
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'arch/mips/mm')
-rw-r--r-- | arch/mips/mm/Makefile | 4 | ||||
-rw-r--r-- | arch/mips/mm/page-funcs.S | 50 | ||||
-rw-r--r-- | arch/mips/mm/page.c | 67 |
3 files changed, 70 insertions, 51 deletions
diff --git a/arch/mips/mm/Makefile b/arch/mips/mm/Makefile index 4aa20280613e..fd6203f14f1f 100644 --- a/arch/mips/mm/Makefile +++ b/arch/mips/mm/Makefile | |||
@@ -3,8 +3,8 @@ | |||
3 | # | 3 | # |
4 | 4 | ||
5 | obj-y += cache.o dma-default.o extable.o fault.o \ | 5 | obj-y += cache.o dma-default.o extable.o fault.o \ |
6 | gup.o init.o mmap.o page.o tlbex.o \ | 6 | gup.o init.o mmap.o page.o page-funcs.o \ |
7 | tlbex-fault.o uasm.o | 7 | tlbex.o tlbex-fault.o uasm.o |
8 | 8 | ||
9 | obj-$(CONFIG_32BIT) += ioremap.o pgtable-32.o | 9 | obj-$(CONFIG_32BIT) += ioremap.o pgtable-32.o |
10 | obj-$(CONFIG_64BIT) += pgtable-64.o | 10 | obj-$(CONFIG_64BIT) += pgtable-64.o |
diff --git a/arch/mips/mm/page-funcs.S b/arch/mips/mm/page-funcs.S new file mode 100644 index 000000000000..48a6b38ff13e --- /dev/null +++ b/arch/mips/mm/page-funcs.S | |||
@@ -0,0 +1,50 @@ | |||
1 | /* | ||
2 | * This file is subject to the terms and conditions of the GNU General Public | ||
3 | * License. See the file "COPYING" in the main directory of this archive | ||
4 | * for more details. | ||
5 | * | ||
6 | * Micro-assembler generated clear_page/copy_page functions. | ||
7 | * | ||
8 | * Copyright (C) 2012 MIPS Technologies, Inc. | ||
9 | * Copyright (C) 2012 Ralf Baechle <ralf@linux-mips.org> | ||
10 | */ | ||
11 | #include <asm/asm.h> | ||
12 | #include <asm/regdef.h> | ||
13 | |||
14 | #ifdef CONFIG_SIBYTE_DMA_PAGEOPS | ||
15 | #define cpu_clear_page_function_name clear_page_cpu | ||
16 | #define cpu_copy_page_function_name copy_page_cpu | ||
17 | #else | ||
18 | #define cpu_clear_page_function_name clear_page | ||
19 | #define cpu_copy_page_function_name copy_page | ||
20 | #endif | ||
21 | |||
22 | /* | ||
23 | * Maximum sizes: | ||
24 | * | ||
25 | * R4000 128 bytes S-cache: 0x058 bytes | ||
26 | * R4600 v1.7: 0x05c bytes | ||
27 | * R4600 v2.0: 0x060 bytes | ||
28 | * With prefetching, 16 word strides 0x120 bytes | ||
29 | */ | ||
30 | EXPORT(__clear_page_start) | ||
31 | LEAF(cpu_clear_page_function_name) | ||
32 | 1: j 1b /* Dummy, will be replaced. */ | ||
33 | .space 288 | ||
34 | END(cpu_clear_page_function_name) | ||
35 | EXPORT(__clear_page_end) | ||
36 | |||
37 | /* | ||
38 | * Maximum sizes: | ||
39 | * | ||
40 | * R4000 128 bytes S-cache: 0x11c bytes | ||
41 | * R4600 v1.7: 0x080 bytes | ||
42 | * R4600 v2.0: 0x07c bytes | ||
43 | * With prefetching, 16 word strides 0x540 bytes | ||
44 | */ | ||
45 | EXPORT(__copy_page_start) | ||
46 | LEAF(cpu_copy_page_function_name) | ||
47 | 1: j 1b /* Dummy, will be replaced. */ | ||
48 | .space 1344 | ||
49 | END(cpu_copy_page_function_name) | ||
50 | EXPORT(__copy_page_end) | ||
diff --git a/arch/mips/mm/page.c b/arch/mips/mm/page.c index cc0b626858b3..98f530e18216 100644 --- a/arch/mips/mm/page.c +++ b/arch/mips/mm/page.c | |||
@@ -6,6 +6,7 @@ | |||
6 | * Copyright (C) 2003, 04, 05 Ralf Baechle (ralf@linux-mips.org) | 6 | * Copyright (C) 2003, 04, 05 Ralf Baechle (ralf@linux-mips.org) |
7 | * Copyright (C) 2007 Maciej W. Rozycki | 7 | * Copyright (C) 2007 Maciej W. Rozycki |
8 | * Copyright (C) 2008 Thiemo Seufer | 8 | * Copyright (C) 2008 Thiemo Seufer |
9 | * Copyright (C) 2012 MIPS Technologies, Inc. | ||
9 | */ | 10 | */ |
10 | #include <linux/init.h> | 11 | #include <linux/init.h> |
11 | #include <linux/kernel.h> | 12 | #include <linux/kernel.h> |
@@ -71,45 +72,6 @@ static struct uasm_reloc __cpuinitdata relocs[5]; | |||
71 | #define cpu_is_r4600_v1_x() ((read_c0_prid() & 0xfffffff0) == 0x00002010) | 72 | #define cpu_is_r4600_v1_x() ((read_c0_prid() & 0xfffffff0) == 0x00002010) |
72 | #define cpu_is_r4600_v2_x() ((read_c0_prid() & 0xfffffff0) == 0x00002020) | 73 | #define cpu_is_r4600_v2_x() ((read_c0_prid() & 0xfffffff0) == 0x00002020) |
73 | 74 | ||
74 | /* | ||
75 | * Maximum sizes: | ||
76 | * | ||
77 | * R4000 128 bytes S-cache: 0x058 bytes | ||
78 | * R4600 v1.7: 0x05c bytes | ||
79 | * R4600 v2.0: 0x060 bytes | ||
80 | * With prefetching, 16 word strides 0x120 bytes | ||
81 | */ | ||
82 | |||
83 | static u32 clear_page_array[0x120 / 4]; | ||
84 | |||
85 | #ifdef CONFIG_SIBYTE_DMA_PAGEOPS | ||
86 | void clear_page_cpu(void *page) __attribute__((alias("clear_page_array"))); | ||
87 | #else | ||
88 | void clear_page(void *page) __attribute__((alias("clear_page_array"))); | ||
89 | #endif | ||
90 | |||
91 | EXPORT_SYMBOL(clear_page); | ||
92 | |||
93 | /* | ||
94 | * Maximum sizes: | ||
95 | * | ||
96 | * R4000 128 bytes S-cache: 0x11c bytes | ||
97 | * R4600 v1.7: 0x080 bytes | ||
98 | * R4600 v2.0: 0x07c bytes | ||
99 | * With prefetching, 16 word strides 0x540 bytes | ||
100 | */ | ||
101 | static u32 copy_page_array[0x540 / 4]; | ||
102 | |||
103 | #ifdef CONFIG_SIBYTE_DMA_PAGEOPS | ||
104 | void | ||
105 | copy_page_cpu(void *to, void *from) __attribute__((alias("copy_page_array"))); | ||
106 | #else | ||
107 | void copy_page(void *to, void *from) __attribute__((alias("copy_page_array"))); | ||
108 | #endif | ||
109 | |||
110 | EXPORT_SYMBOL(copy_page); | ||
111 | |||
112 | |||
113 | static int pref_bias_clear_store __cpuinitdata; | 75 | static int pref_bias_clear_store __cpuinitdata; |
114 | static int pref_bias_copy_load __cpuinitdata; | 76 | static int pref_bias_copy_load __cpuinitdata; |
115 | static int pref_bias_copy_store __cpuinitdata; | 77 | static int pref_bias_copy_store __cpuinitdata; |
@@ -282,10 +244,15 @@ static inline void __cpuinit build_clear_pref(u32 **buf, int off) | |||
282 | } | 244 | } |
283 | } | 245 | } |
284 | 246 | ||
247 | extern u32 __clear_page_start; | ||
248 | extern u32 __clear_page_end; | ||
249 | extern u32 __copy_page_start; | ||
250 | extern u32 __copy_page_end; | ||
251 | |||
285 | void __cpuinit build_clear_page(void) | 252 | void __cpuinit build_clear_page(void) |
286 | { | 253 | { |
287 | int off; | 254 | int off; |
288 | u32 *buf = (u32 *)&clear_page_array; | 255 | u32 *buf = &__clear_page_start; |
289 | struct uasm_label *l = labels; | 256 | struct uasm_label *l = labels; |
290 | struct uasm_reloc *r = relocs; | 257 | struct uasm_reloc *r = relocs; |
291 | int i; | 258 | int i; |
@@ -356,17 +323,17 @@ void __cpuinit build_clear_page(void) | |||
356 | uasm_i_jr(&buf, RA); | 323 | uasm_i_jr(&buf, RA); |
357 | uasm_i_nop(&buf); | 324 | uasm_i_nop(&buf); |
358 | 325 | ||
359 | BUG_ON(buf > clear_page_array + ARRAY_SIZE(clear_page_array)); | 326 | BUG_ON(buf > &__clear_page_end); |
360 | 327 | ||
361 | uasm_resolve_relocs(relocs, labels); | 328 | uasm_resolve_relocs(relocs, labels); |
362 | 329 | ||
363 | pr_debug("Synthesized clear page handler (%u instructions).\n", | 330 | pr_debug("Synthesized clear page handler (%u instructions).\n", |
364 | (u32)(buf - clear_page_array)); | 331 | (u32)(buf - &__clear_page_start)); |
365 | 332 | ||
366 | pr_debug("\t.set push\n"); | 333 | pr_debug("\t.set push\n"); |
367 | pr_debug("\t.set noreorder\n"); | 334 | pr_debug("\t.set noreorder\n"); |
368 | for (i = 0; i < (buf - clear_page_array); i++) | 335 | for (i = 0; i < (buf - &__clear_page_start); i++) |
369 | pr_debug("\t.word 0x%08x\n", clear_page_array[i]); | 336 | pr_debug("\t.word 0x%08x\n", (&__clear_page_start)[i]); |
370 | pr_debug("\t.set pop\n"); | 337 | pr_debug("\t.set pop\n"); |
371 | } | 338 | } |
372 | 339 | ||
@@ -427,7 +394,7 @@ static inline void build_copy_store_pref(u32 **buf, int off) | |||
427 | void __cpuinit build_copy_page(void) | 394 | void __cpuinit build_copy_page(void) |
428 | { | 395 | { |
429 | int off; | 396 | int off; |
430 | u32 *buf = (u32 *)©_page_array; | 397 | u32 *buf = &__copy_page_start; |
431 | struct uasm_label *l = labels; | 398 | struct uasm_label *l = labels; |
432 | struct uasm_reloc *r = relocs; | 399 | struct uasm_reloc *r = relocs; |
433 | int i; | 400 | int i; |
@@ -595,21 +562,23 @@ void __cpuinit build_copy_page(void) | |||
595 | uasm_i_jr(&buf, RA); | 562 | uasm_i_jr(&buf, RA); |
596 | uasm_i_nop(&buf); | 563 | uasm_i_nop(&buf); |
597 | 564 | ||
598 | BUG_ON(buf > copy_page_array + ARRAY_SIZE(copy_page_array)); | 565 | BUG_ON(buf > &__copy_page_end); |
599 | 566 | ||
600 | uasm_resolve_relocs(relocs, labels); | 567 | uasm_resolve_relocs(relocs, labels); |
601 | 568 | ||
602 | pr_debug("Synthesized copy page handler (%u instructions).\n", | 569 | pr_debug("Synthesized copy page handler (%u instructions).\n", |
603 | (u32)(buf - copy_page_array)); | 570 | (u32)(buf - &__copy_page_start)); |
604 | 571 | ||
605 | pr_debug("\t.set push\n"); | 572 | pr_debug("\t.set push\n"); |
606 | pr_debug("\t.set noreorder\n"); | 573 | pr_debug("\t.set noreorder\n"); |
607 | for (i = 0; i < (buf - copy_page_array); i++) | 574 | for (i = 0; i < (buf - &__copy_page_start); i++) |
608 | pr_debug("\t.word 0x%08x\n", copy_page_array[i]); | 575 | pr_debug("\t.word 0x%08x\n", (&__copy_page_start)[i]); |
609 | pr_debug("\t.set pop\n"); | 576 | pr_debug("\t.set pop\n"); |
610 | } | 577 | } |
611 | 578 | ||
612 | #ifdef CONFIG_SIBYTE_DMA_PAGEOPS | 579 | #ifdef CONFIG_SIBYTE_DMA_PAGEOPS |
580 | extern void clear_page_cpu(void *page); | ||
581 | extern void copy_page_cpu(void *to, void *from); | ||
613 | 582 | ||
614 | /* | 583 | /* |
615 | * Pad descriptors to cacheline, since each is exclusively owned by a | 584 | * Pad descriptors to cacheline, since each is exclusively owned by a |