pxa: mark as broken
[openwrt/svn-archive/archive.git] / target / linux / generic / patches-3.3 / 003-MIPS-Refactor-clear_page-and-copy_page-functions.patch
1 From c022630633624a75b3b58f43dd3c6cc896a56cff Mon Sep 17 00:00:00 2001
2 From: "Steven J. Hill" <sjhill@mips.com>
3 Date: Fri, 6 Jul 2012 21:56:01 +0200
4 Subject: [PATCH] MIPS: Refactor 'clear_page' and 'copy_page' functions.
5
6 Remove usage of the '__attribute__((alias("...")))' hack that aliased
7 to integer arrays containing micro-assembled instructions. This hack
8 breaks when building a microMIPS kernel. It also makes the code much
9 easier to understand.
10
11 [ralf@linux-mips.org: Added back export of the clear_page and copy_page
12 symbols so certain modules will work again. Also fixed build with
13 CONFIG_SIBYTE_DMA_PAGEOPS enabled.]
14
15 Signed-off-by: Steven J. Hill <sjhill@mips.com>
16 Cc: linux-mips@linux-mips.org
17 Patchwork: https://patchwork.linux-mips.org/patch/3866/
18 Acked-by: David Daney <david.daney@cavium.com>
19 Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
20 ---
21 arch/mips/kernel/mips_ksyms.c | 8 ++++-
22 arch/mips/mm/Makefile | 4 +--
23 arch/mips/mm/page-funcs.S | 50 ++++++++++++++++++++++++++++++
24 arch/mips/mm/page.c | 67 +++++++++++------------------------------
25 4 files changed, 77 insertions(+), 52 deletions(-)
26 create mode 100644 arch/mips/mm/page-funcs.S
27
28 --- a/arch/mips/kernel/mips_ksyms.c
29 +++ b/arch/mips/kernel/mips_ksyms.c
30 @@ -5,7 +5,7 @@
31 * License. See the file "COPYING" in the main directory of this archive
32 * for more details.
33 *
34 - * Copyright (C) 1996, 97, 98, 99, 2000, 01, 03, 04, 05 by Ralf Baechle
35 + * Copyright (C) 1996, 97, 98, 99, 2000, 01, 03, 04, 05, 12 by Ralf Baechle
36 * Copyright (C) 1999, 2000, 01 Silicon Graphics, Inc.
37 */
38 #include <linux/interrupt.h>
39 @@ -35,6 +35,12 @@ EXPORT_SYMBOL(memmove);
40 EXPORT_SYMBOL(kernel_thread);
41
42 /*
43 + * Functions that operate on entire pages. Mostly used by memory management.
44 + */
45 +EXPORT_SYMBOL(clear_page);
46 +EXPORT_SYMBOL(copy_page);
47 +
48 +/*
49 * Userspace access stuff.
50 */
51 EXPORT_SYMBOL(__copy_user);
52 --- a/arch/mips/mm/Makefile
53 +++ b/arch/mips/mm/Makefile
54 @@ -3,8 +3,8 @@
55 #
56
57 obj-y += cache.o dma-default.o extable.o fault.o \
58 - gup.o init.o mmap.o page.o tlbex.o \
59 - tlbex-fault.o uasm.o
60 + gup.o init.o mmap.o page.o page-funcs.o \
61 + tlbex.o tlbex-fault.o uasm.o
62
63 obj-$(CONFIG_32BIT) += ioremap.o pgtable-32.o
64 obj-$(CONFIG_64BIT) += pgtable-64.o
65 --- /dev/null
66 +++ b/arch/mips/mm/page-funcs.S
67 @@ -0,0 +1,50 @@
68 +/*
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
71 + * for more details.
72 + *
73 + * Micro-assembler generated clear_page/copy_page functions.
74 + *
75 + * Copyright (C) 2012 MIPS Technologies, Inc.
76 + * Copyright (C) 2012 Ralf Baechle <ralf@linux-mips.org>
77 + */
78 +#include <asm/asm.h>
79 +#include <asm/regdef.h>
80 +
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
84 +#else
85 +#define cpu_clear_page_function_name clear_page
86 +#define cpu_copy_page_function_name copy_page
87 +#endif
88 +
89 +/*
90 + * Maximum sizes:
91 + *
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
96 + */
97 +EXPORT(__clear_page_start)
98 +LEAF(cpu_clear_page_function_name)
99 +1: j 1b /* Dummy, will be replaced. */
100 + .space 288
101 +END(cpu_clear_page_function_name)
102 +EXPORT(__clear_page_end)
103 +
104 +/*
105 + * Maximum sizes:
106 + *
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
111 + */
112 +EXPORT(__copy_page_start)
113 +LEAF(cpu_copy_page_function_name)
114 +1: j 1b /* Dummy, will be replaced. */
115 + .space 1344
116 +END(cpu_copy_page_function_name)
117 +EXPORT(__copy_page_end)
118 --- a/arch/mips/mm/page.c
119 +++ b/arch/mips/mm/page.c
120 @@ -6,6 +6,7 @@
121 * Copyright (C) 2003, 04, 05 Ralf Baechle (ralf@linux-mips.org)
122 * Copyright (C) 2007 Maciej W. Rozycki
123 * Copyright (C) 2008 Thiemo Seufer
124 + * Copyright (C) 2012 MIPS Technologies, Inc.
125 */
126 #include <linux/init.h>
127 #include <linux/kernel.h>
128 @@ -72,45 +73,6 @@ static struct uasm_reloc __cpuinitdata r
129 #define cpu_is_r4600_v1_x() ((read_c0_prid() & 0xfffffff0) == 0x00002010)
130 #define cpu_is_r4600_v2_x() ((read_c0_prid() & 0xfffffff0) == 0x00002020)
131
132 -/*
133 - * Maximum sizes:
134 - *
135 - * R4000 128 bytes S-cache: 0x058 bytes
136 - * R4600 v1.7: 0x05c bytes
137 - * R4600 v2.0: 0x060 bytes
138 - * With prefetching, 16 word strides 0x120 bytes
139 - */
140 -
141 -static u32 clear_page_array[0x120 / 4];
142 -
143 -#ifdef CONFIG_SIBYTE_DMA_PAGEOPS
144 -void clear_page_cpu(void *page) __attribute__((alias("clear_page_array")));
145 -#else
146 -void clear_page(void *page) __attribute__((alias("clear_page_array")));
147 -#endif
148 -
149 -EXPORT_SYMBOL(clear_page);
150 -
151 -/*
152 - * Maximum sizes:
153 - *
154 - * R4000 128 bytes S-cache: 0x11c bytes
155 - * R4600 v1.7: 0x080 bytes
156 - * R4600 v2.0: 0x07c bytes
157 - * With prefetching, 16 word strides 0x540 bytes
158 - */
159 -static u32 copy_page_array[0x540 / 4];
160 -
161 -#ifdef CONFIG_SIBYTE_DMA_PAGEOPS
162 -void
163 -copy_page_cpu(void *to, void *from) __attribute__((alias("copy_page_array")));
164 -#else
165 -void copy_page(void *to, void *from) __attribute__((alias("copy_page_array")));
166 -#endif
167 -
168 -EXPORT_SYMBOL(copy_page);
169 -
170 -
171 static int pref_bias_clear_store __cpuinitdata;
172 static int pref_bias_copy_load __cpuinitdata;
173 static int pref_bias_copy_store __cpuinitdata;
174 @@ -283,10 +245,15 @@ static inline void __cpuinit build_clear
175 }
176 }
177
178 +extern u32 __clear_page_start;
179 +extern u32 __clear_page_end;
180 +extern u32 __copy_page_start;
181 +extern u32 __copy_page_end;
182 +
183 void __cpuinit build_clear_page(void)
184 {
185 int off;
186 - u32 *buf = (u32 *)&clear_page_array;
187 + u32 *buf = &__clear_page_start;
188 struct uasm_label *l = labels;
189 struct uasm_reloc *r = relocs;
190 int i;
191 @@ -357,17 +324,17 @@ void __cpuinit build_clear_page(void)
192 uasm_i_jr(&buf, RA);
193 uasm_i_nop(&buf);
194
195 - BUG_ON(buf > clear_page_array + ARRAY_SIZE(clear_page_array));
196 + BUG_ON(buf > &__clear_page_end);
197
198 uasm_resolve_relocs(relocs, labels);
199
200 pr_debug("Synthesized clear page handler (%u instructions).\n",
201 - (u32)(buf - clear_page_array));
202 + (u32)(buf - &__clear_page_start));
203
204 pr_debug("\t.set push\n");
205 pr_debug("\t.set noreorder\n");
206 - for (i = 0; i < (buf - clear_page_array); i++)
207 - pr_debug("\t.word 0x%08x\n", clear_page_array[i]);
208 + for (i = 0; i < (buf - &__clear_page_start); i++)
209 + pr_debug("\t.word 0x%08x\n", (&__clear_page_start)[i]);
210 pr_debug("\t.set pop\n");
211 }
212
213 @@ -428,7 +395,7 @@ static inline void build_copy_store_pref
214 void __cpuinit build_copy_page(void)
215 {
216 int off;
217 - u32 *buf = (u32 *)&copy_page_array;
218 + u32 *buf = &__copy_page_start;
219 struct uasm_label *l = labels;
220 struct uasm_reloc *r = relocs;
221 int i;
222 @@ -596,21 +563,23 @@ void __cpuinit build_copy_page(void)
223 uasm_i_jr(&buf, RA);
224 uasm_i_nop(&buf);
225
226 - BUG_ON(buf > copy_page_array + ARRAY_SIZE(copy_page_array));
227 + BUG_ON(buf > &__copy_page_end);
228
229 uasm_resolve_relocs(relocs, labels);
230
231 pr_debug("Synthesized copy page handler (%u instructions).\n",
232 - (u32)(buf - copy_page_array));
233 + (u32)(buf - &__copy_page_start));
234
235 pr_debug("\t.set push\n");
236 pr_debug("\t.set noreorder\n");
237 - for (i = 0; i < (buf - copy_page_array); i++)
238 - pr_debug("\t.word 0x%08x\n", copy_page_array[i]);
239 + for (i = 0; i < (buf - &__copy_page_start); i++)
240 + pr_debug("\t.word 0x%08x\n", (&__copy_page_start)[i]);
241 pr_debug("\t.set pop\n");
242 }
243
244 #ifdef CONFIG_SIBYTE_DMA_PAGEOPS
245 +extern void clear_page_cpu(void *page);
246 +extern void copy_page_cpu(void *to, void *from);
247
248 /*
249 * Pad descriptors to cacheline, since each is exclusively owned by a