1 commit c022630633624a75b3b58f43dd3c6cc896a56cff
2 Author: Steven J. Hill <sjhill@mips.com>
3 Date: Fri Jul 6 21:56:01 2012 +0200
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 57ba13e..3fc1691 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,12 @@ EXPORT_SYMBOL(memmove);
36 EXPORT_SYMBOL(kernel_thread);
39 + * Functions that operate on entire pages. Mostly used by memory management.
41 +EXPORT_SYMBOL(clear_page);
42 +EXPORT_SYMBOL(copy_page);
45 * Userspace access stuff.
47 EXPORT_SYMBOL(__copy_user);
48 diff --git a/arch/mips/mm/Makefile b/arch/mips/mm/Makefile
49 index 4aa2028..fd6203f 100644
50 --- a/arch/mips/mm/Makefile
51 +++ b/arch/mips/mm/Makefile
55 obj-y += cache.o dma-default.o extable.o fault.o \
56 - gup.o init.o mmap.o page.o tlbex.o \
57 - tlbex-fault.o uasm.o
58 + gup.o init.o mmap.o page.o page-funcs.o \
59 + tlbex.o tlbex-fault.o uasm.o
61 obj-$(CONFIG_32BIT) += ioremap.o pgtable-32.o
62 obj-$(CONFIG_64BIT) += pgtable-64.o
63 diff --git a/arch/mips/mm/page-funcs.S b/arch/mips/mm/page-funcs.S
65 index 0000000..48a6b38
67 +++ b/arch/mips/mm/page-funcs.S
70 + * This file is subject to the terms and conditions of the GNU General Public
71 + * License. See the file "COPYING" in the main directory of this archive
74 + * Micro-assembler generated clear_page/copy_page functions.
76 + * Copyright (C) 2012 MIPS Technologies, Inc.
77 + * Copyright (C) 2012 Ralf Baechle <ralf@linux-mips.org>
80 +#include <asm/regdef.h>
82 +#ifdef CONFIG_SIBYTE_DMA_PAGEOPS
83 +#define cpu_clear_page_function_name clear_page_cpu
84 +#define cpu_copy_page_function_name copy_page_cpu
86 +#define cpu_clear_page_function_name clear_page
87 +#define cpu_copy_page_function_name copy_page
93 + * R4000 128 bytes S-cache: 0x058 bytes
94 + * R4600 v1.7: 0x05c bytes
95 + * R4600 v2.0: 0x060 bytes
96 + * With prefetching, 16 word strides 0x120 bytes
98 +EXPORT(__clear_page_start)
99 +LEAF(cpu_clear_page_function_name)
100 +1: j 1b /* Dummy, will be replaced. */
102 +END(cpu_clear_page_function_name)
103 +EXPORT(__clear_page_end)
108 + * R4000 128 bytes S-cache: 0x11c bytes
109 + * R4600 v1.7: 0x080 bytes
110 + * R4600 v2.0: 0x07c bytes
111 + * With prefetching, 16 word strides 0x540 bytes
113 +EXPORT(__copy_page_start)
114 +LEAF(cpu_copy_page_function_name)
115 +1: j 1b /* Dummy, will be replaced. */
117 +END(cpu_copy_page_function_name)
118 +EXPORT(__copy_page_end)
119 diff --git a/arch/mips/mm/page.c b/arch/mips/mm/page.c
120 index cc0b626..98f530e 100644
121 --- a/arch/mips/mm/page.c
122 +++ b/arch/mips/mm/page.c
124 * Copyright (C) 2003, 04, 05 Ralf Baechle (ralf@linux-mips.org)
125 * Copyright (C) 2007 Maciej W. Rozycki
126 * Copyright (C) 2008 Thiemo Seufer
127 + * Copyright (C) 2012 MIPS Technologies, Inc.
129 #include <linux/init.h>
130 #include <linux/kernel.h>
131 @@ -71,45 +72,6 @@ static struct uasm_reloc __cpuinitdata relocs[5];
132 #define cpu_is_r4600_v1_x() ((read_c0_prid() & 0xfffffff0) == 0x00002010)
133 #define cpu_is_r4600_v2_x() ((read_c0_prid() & 0xfffffff0) == 0x00002020)
138 - * R4000 128 bytes S-cache: 0x058 bytes
139 - * R4600 v1.7: 0x05c bytes
140 - * R4600 v2.0: 0x060 bytes
141 - * With prefetching, 16 word strides 0x120 bytes
144 -static u32 clear_page_array[0x120 / 4];
146 -#ifdef CONFIG_SIBYTE_DMA_PAGEOPS
147 -void clear_page_cpu(void *page) __attribute__((alias("clear_page_array")));
149 -void clear_page(void *page) __attribute__((alias("clear_page_array")));
152 -EXPORT_SYMBOL(clear_page);
157 - * R4000 128 bytes S-cache: 0x11c bytes
158 - * R4600 v1.7: 0x080 bytes
159 - * R4600 v2.0: 0x07c bytes
160 - * With prefetching, 16 word strides 0x540 bytes
162 -static u32 copy_page_array[0x540 / 4];
164 -#ifdef CONFIG_SIBYTE_DMA_PAGEOPS
166 -copy_page_cpu(void *to, void *from) __attribute__((alias("copy_page_array")));
168 -void copy_page(void *to, void *from) __attribute__((alias("copy_page_array")));
171 -EXPORT_SYMBOL(copy_page);
174 static int pref_bias_clear_store __cpuinitdata;
175 static int pref_bias_copy_load __cpuinitdata;
176 static int pref_bias_copy_store __cpuinitdata;
177 @@ -282,10 +244,15 @@ static inline void __cpuinit build_clear_pref(u32 **buf, int off)
181 +extern u32 __clear_page_start;
182 +extern u32 __clear_page_end;
183 +extern u32 __copy_page_start;
184 +extern u32 __copy_page_end;
186 void __cpuinit build_clear_page(void)
189 - u32 *buf = (u32 *)&clear_page_array;
190 + u32 *buf = &__clear_page_start;
191 struct uasm_label *l = labels;
192 struct uasm_reloc *r = relocs;
194 @@ -356,17 +323,17 @@ void __cpuinit build_clear_page(void)
198 - BUG_ON(buf > clear_page_array + ARRAY_SIZE(clear_page_array));
199 + BUG_ON(buf > &__clear_page_end);
201 uasm_resolve_relocs(relocs, labels);
203 pr_debug("Synthesized clear page handler (%u instructions).\n",
204 - (u32)(buf - clear_page_array));
205 + (u32)(buf - &__clear_page_start));
207 pr_debug("\t.set push\n");
208 pr_debug("\t.set noreorder\n");
209 - for (i = 0; i < (buf - clear_page_array); i++)
210 - pr_debug("\t.word 0x%08x\n", clear_page_array[i]);
211 + for (i = 0; i < (buf - &__clear_page_start); i++)
212 + pr_debug("\t.word 0x%08x\n", (&__clear_page_start)[i]);
213 pr_debug("\t.set pop\n");
216 @@ -427,7 +394,7 @@ static inline void build_copy_store_pref(u32 **buf, int off)
217 void __cpuinit build_copy_page(void)
220 - u32 *buf = (u32 *)©_page_array;
221 + u32 *buf = &__copy_page_start;
222 struct uasm_label *l = labels;
223 struct uasm_reloc *r = relocs;
225 @@ -595,21 +562,23 @@ void __cpuinit build_copy_page(void)
229 - BUG_ON(buf > copy_page_array + ARRAY_SIZE(copy_page_array));
230 + BUG_ON(buf > &__copy_page_end);
232 uasm_resolve_relocs(relocs, labels);
234 pr_debug("Synthesized copy page handler (%u instructions).\n",
235 - (u32)(buf - copy_page_array));
236 + (u32)(buf - &__copy_page_start));
238 pr_debug("\t.set push\n");
239 pr_debug("\t.set noreorder\n");
240 - for (i = 0; i < (buf - copy_page_array); i++)
241 - pr_debug("\t.word 0x%08x\n", copy_page_array[i]);
242 + for (i = 0; i < (buf - &__copy_page_start); i++)
243 + pr_debug("\t.word 0x%08x\n", (&__copy_page_start)[i]);
244 pr_debug("\t.set pop\n");
247 #ifdef CONFIG_SIBYTE_DMA_PAGEOPS
248 +extern void clear_page_cpu(void *page);
249 +extern void copy_page_cpu(void *to, void *from);
252 * Pad descriptors to cacheline, since each is exclusively owned by a