1 commit 8511b7b083db01ad0538bea6a8af79f88fe02a8b
2 Author: hschang <chang@dev3>
3 Date: Wed Jan 8 20:32:42 2014 +0900
5 MIPS: Refactor 'clear_page' and 'copy_page' functions.
7 Remove usage of the '__attribute__((alias("...")))' hack that aliased
8 to integer arrays containing micro-assembled instructions. This hack
9 breaks when building a microMIPS kernel. It also makes the code much
12 [ralf@linux-mips.org: Added back export of the clear_page and copy_page
13 symbols so certain modules will work again. Also fixed build with
14 CONFIG_SIBYTE_DMA_PAGEOPS enabled.]
16 Signed-off-by: Steven J. Hill <sjhill@mips.com>
17 Cc: linux-mips@linux-mips.org
18 Patchwork: https://patchwork.linux-mips.org/patch/3866/
19 Acked-by: David Daney <david.daney@cavium.com>
20 Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
22 diff --git a/arch/mips/kernel/mips_ksyms.c b/arch/mips/kernel/mips_ksyms.c
23 index 1d04807..17160bf 100644
24 --- a/arch/mips/kernel/mips_ksyms.c
25 +++ b/arch/mips/kernel/mips_ksyms.c
27 * License. See the file "COPYING" in the main directory of this archive
30 - * Copyright (C) 1996, 97, 98, 99, 2000, 01, 03, 04, 05 by Ralf Baechle
31 + * Copyright (C) 1996, 97, 98, 99, 2000, 01, 03, 04, 05, 12 by Ralf Baechle
32 * Copyright (C) 1999, 2000, 01 Silicon Graphics, Inc.
34 #include <linux/interrupt.h>
35 @@ -35,6 +35,13 @@ EXPORT_SYMBOL(memmove);
36 EXPORT_SYMBOL(kernel_thread);
39 + * Functions that operate on entire pages. Mostly used by memory management.
42 +EXPORT_SYMBOL(clear_page);
43 +EXPORT_SYMBOL(copy_page);
46 * Userspace access stuff.
48 EXPORT_SYMBOL(__copy_user);
49 diff --git a/arch/mips/mm/Makefile b/arch/mips/mm/Makefile
50 index 95e5ccb..2f2dc25 100644
51 --- a/arch/mips/mm/Makefile
52 +++ b/arch/mips/mm/Makefile
55 obj-y += cache.o dma-default.o extable.o fault.o \
56 init.o mmap.o tlbex.o tlbex-fault.o uasm.o \
60 obj-$(CONFIG_32BIT) += ioremap.o pgtable-32.o
61 obj-$(CONFIG_64BIT) += pgtable-64.o
62 diff --git a/arch/mips/mm/page-funcs.S b/arch/mips/mm/page-funcs.S
64 index 0000000..48a6b38
66 +++ b/arch/mips/mm/page-funcs.S
69 + * This file is subject to the terms and conditions of the GNU General Public
70 + * License. See the file "COPYING" in the main directory of this archive
73 + * Micro-assembler generated clear_page/copy_page functions.
75 + * Copyright (C) 2012 MIPS Technologies, Inc.
76 + * Copyright (C) 2012 Ralf Baechle <ralf@linux-mips.org>
79 +#include <asm/regdef.h>
81 +#ifdef CONFIG_SIBYTE_DMA_PAGEOPS
82 +#define cpu_clear_page_function_name clear_page_cpu
83 +#define cpu_copy_page_function_name copy_page_cpu
85 +#define cpu_clear_page_function_name clear_page
86 +#define cpu_copy_page_function_name copy_page
92 + * R4000 128 bytes S-cache: 0x058 bytes
93 + * R4600 v1.7: 0x05c bytes
94 + * R4600 v2.0: 0x060 bytes
95 + * With prefetching, 16 word strides 0x120 bytes
97 +EXPORT(__clear_page_start)
98 +LEAF(cpu_clear_page_function_name)
99 +1: j 1b /* Dummy, will be replaced. */
101 +END(cpu_clear_page_function_name)
102 +EXPORT(__clear_page_end)
107 + * R4000 128 bytes S-cache: 0x11c bytes
108 + * R4600 v1.7: 0x080 bytes
109 + * R4600 v2.0: 0x07c bytes
110 + * With prefetching, 16 word strides 0x540 bytes
112 +EXPORT(__copy_page_start)
113 +LEAF(cpu_copy_page_function_name)
114 +1: j 1b /* Dummy, will be replaced. */
116 +END(cpu_copy_page_function_name)
117 +EXPORT(__copy_page_end)
118 diff --git a/arch/mips/mm/page.c b/arch/mips/mm/page.c
119 index 36272f7..a22bd40 100644
120 --- a/arch/mips/mm/page.c
121 +++ b/arch/mips/mm/page.c
123 * Copyright (C) 2003, 04, 05 Ralf Baechle (ralf@linux-mips.org)
124 * Copyright (C) 2007 Maciej W. Rozycki
125 * Copyright (C) 2008 Thiemo Seufer
126 + * Copyright (C) 2012 MIPS Technologies, Inc.
128 #include <linux/init.h>
129 #include <linux/kernel.h>
130 @@ -72,45 +73,6 @@ static struct uasm_reloc __cpuinitdata relocs[5];
131 #define cpu_is_r4600_v1_x() ((read_c0_prid() & 0xfffffff0) == 0x00002010)
132 #define cpu_is_r4600_v2_x() ((read_c0_prid() & 0xfffffff0) == 0x00002020)
137 - * R4000 128 bytes S-cache: 0x058 bytes
138 - * R4600 v1.7: 0x05c bytes
139 - * R4600 v2.0: 0x060 bytes
140 - * With prefetching, 16 word strides 0x120 bytes
143 -static u32 clear_page_array[0x120 / 4];
145 -#ifdef CONFIG_SIBYTE_DMA_PAGEOPS
146 -void clear_page_cpu(void *page) __attribute__((alias("clear_page_array")));
148 -void clear_page(void *page) __attribute__((alias("clear_page_array")));
151 -EXPORT_SYMBOL(clear_page);
156 - * R4000 128 bytes S-cache: 0x11c bytes
157 - * R4600 v1.7: 0x080 bytes
158 - * R4600 v2.0: 0x07c bytes
159 - * With prefetching, 16 word strides 0x540 bytes
161 -static u32 copy_page_array[0x540 / 4];
163 -#ifdef CONFIG_SIBYTE_DMA_PAGEOPS
165 -copy_page_cpu(void *to, void *from) __attribute__((alias("copy_page_array")));
167 -void copy_page(void *to, void *from) __attribute__((alias("copy_page_array")));
170 -EXPORT_SYMBOL(copy_page);
173 static int pref_bias_clear_store __cpuinitdata;
174 static int pref_bias_copy_load __cpuinitdata;
175 static int pref_bias_copy_store __cpuinitdata;
176 @@ -283,10 +245,15 @@ static inline void __cpuinit build_clear_pref(u32 **buf, int off)
180 +extern u32 __clear_page_start;
181 +extern u32 __clear_page_end;
182 +extern u32 __copy_page_start;
183 +extern u32 __copy_page_end;
185 void __cpuinit build_clear_page(void)
188 - u32 *buf = (u32 *)&clear_page_array;
189 + u32 *buf = &__clear_page_start;
190 struct uasm_label *l = labels;
191 struct uasm_reloc *r = relocs;
193 @@ -357,17 +324,17 @@ void __cpuinit build_clear_page(void)
197 - BUG_ON(buf > clear_page_array + ARRAY_SIZE(clear_page_array));
198 + BUG_ON(buf > &__clear_page_end);
200 uasm_resolve_relocs(relocs, labels);
202 pr_debug("Synthesized clear page handler (%u instructions).\n",
203 - (u32)(buf - clear_page_array));
204 + (u32)(buf - &__clear_page_start));
206 pr_debug("\t.set push\n");
207 pr_debug("\t.set noreorder\n");
208 - for (i = 0; i < (buf - clear_page_array); i++)
209 - pr_debug("\t.word 0x%08x\n", clear_page_array[i]);
210 + for (i = 0; i < (buf - &__clear_page_start); i++)
211 + pr_debug("\t.word 0x%08x\n", (&__clear_page_start)[i]);
212 pr_debug("\t.set pop\n");
215 @@ -428,7 +395,7 @@ static inline void build_copy_store_pref(u32 **buf, int off)
216 void __cpuinit build_copy_page(void)
219 - u32 *buf = (u32 *)©_page_array;
220 + u32 *buf = &__copy_page_start;
221 struct uasm_label *l = labels;
222 struct uasm_reloc *r = relocs;
224 @@ -596,21 +563,23 @@ void __cpuinit build_copy_page(void)
228 - BUG_ON(buf > copy_page_array + ARRAY_SIZE(copy_page_array));
229 + BUG_ON(buf > &__copy_page_end);
231 uasm_resolve_relocs(relocs, labels);
233 pr_debug("Synthesized copy page handler (%u instructions).\n",
234 - (u32)(buf - copy_page_array));
235 + (u32)(buf - &__copy_page_start));
237 pr_debug("\t.set push\n");
238 pr_debug("\t.set noreorder\n");
239 - for (i = 0; i < (buf - copy_page_array); i++)
240 - pr_debug("\t.word 0x%08x\n", copy_page_array[i]);
241 + for (i = 0; i < (buf - &__copy_page_start); i++)
242 + pr_debug("\t.word 0x%08x\n", (&__copy_page_start)[i]);
243 pr_debug("\t.set pop\n");
246 #ifdef CONFIG_SIBYTE_DMA_PAGEOPS
247 +extern void clear_page_cpu(void *page);
248 +extern void copy_page_cpu(void *to, void *from);
251 * Pad descriptors to cacheline, since each is exclusively owned by a