mips-error.patch 7.5 KB

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