159-cpu_fixes.patch 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509
  1. --- a/arch/mips/include/asm/r4kcache.h
  2. +++ b/arch/mips/include/asm/r4kcache.h
  3. @@ -25,6 +25,38 @@
  4. extern void (*r4k_blast_dcache)(void);
  5. extern void (*r4k_blast_icache)(void);
  6. +#if defined(CONFIG_BCM47XX) && !defined(CONFIG_CPU_MIPS32_R2)
  7. +#include <asm/paccess.h>
  8. +#include <linux/ssb/ssb.h>
  9. +#define BCM4710_DUMMY_RREG() bcm4710_dummy_rreg()
  10. +
  11. +static inline unsigned long bcm4710_dummy_rreg(void)
  12. +{
  13. + return *(volatile unsigned long *)(KSEG1ADDR(SSB_ENUM_BASE));
  14. +}
  15. +
  16. +#define BCM4710_FILL_TLB(addr) bcm4710_fill_tlb((void *)(addr))
  17. +
  18. +static inline unsigned long bcm4710_fill_tlb(void *addr)
  19. +{
  20. + return *(unsigned long *)addr;
  21. +}
  22. +
  23. +#define BCM4710_PROTECTED_FILL_TLB(addr) bcm4710_protected_fill_tlb((void *)(addr))
  24. +
  25. +static inline void bcm4710_protected_fill_tlb(void *addr)
  26. +{
  27. + unsigned long x;
  28. + get_dbe(x, (unsigned long *)addr);;
  29. +}
  30. +
  31. +#else
  32. +#define BCM4710_DUMMY_RREG()
  33. +
  34. +#define BCM4710_FILL_TLB(addr)
  35. +#define BCM4710_PROTECTED_FILL_TLB(addr)
  36. +#endif
  37. +
  38. /*
  39. * This macro return a properly sign-extended address suitable as base address
  40. * for indexed cache operations. Two issues here:
  41. @@ -98,6 +130,7 @@ static inline void flush_icache_line_ind
  42. static inline void flush_dcache_line_indexed(unsigned long addr)
  43. {
  44. __dflush_prologue
  45. + BCM4710_DUMMY_RREG();
  46. cache_op(Index_Writeback_Inv_D, addr);
  47. __dflush_epilogue
  48. }
  49. @@ -125,6 +158,7 @@ static inline void flush_icache_line(uns
  50. static inline void flush_dcache_line(unsigned long addr)
  51. {
  52. __dflush_prologue
  53. + BCM4710_DUMMY_RREG();
  54. cache_op(Hit_Writeback_Inv_D, addr);
  55. __dflush_epilogue
  56. }
  57. @@ -132,6 +166,7 @@ static inline void flush_dcache_line(uns
  58. static inline void invalidate_dcache_line(unsigned long addr)
  59. {
  60. __dflush_prologue
  61. + BCM4710_DUMMY_RREG();
  62. cache_op(Hit_Invalidate_D, addr);
  63. __dflush_epilogue
  64. }
  65. @@ -187,6 +222,7 @@ static inline void protected_flush_icach
  66. #ifdef CONFIG_EVA
  67. protected_cachee_op(Hit_Invalidate_I, addr);
  68. #else
  69. + BCM4710_DUMMY_RREG();
  70. protected_cache_op(Hit_Invalidate_I, addr);
  71. #endif
  72. break;
  73. @@ -201,6 +237,7 @@ static inline void protected_flush_icach
  74. */
  75. static inline void protected_writeback_dcache_line(unsigned long addr)
  76. {
  77. + BCM4710_DUMMY_RREG();
  78. #ifdef CONFIG_EVA
  79. protected_cachee_op(Hit_Writeback_Inv_D, addr);
  80. #else
  81. @@ -558,8 +595,51 @@ static inline void invalidate_tcache_pag
  82. : "r" (base), \
  83. "i" (op));
  84. +static inline void blast_dcache(void)
  85. +{
  86. + unsigned long start = KSEG0;
  87. + unsigned long dcache_size = current_cpu_data.dcache.waysize * current_cpu_data.dcache.ways;
  88. + unsigned long end = (start + dcache_size);
  89. +
  90. + do {
  91. + BCM4710_DUMMY_RREG();
  92. + cache_op(Index_Writeback_Inv_D, start);
  93. + start += current_cpu_data.dcache.linesz;
  94. + } while(start < end);
  95. +}
  96. +
  97. +static inline void blast_dcache_page(unsigned long page)
  98. +{
  99. + unsigned long start = page;
  100. + unsigned long end = start + PAGE_SIZE;
  101. +
  102. + BCM4710_FILL_TLB(start);
  103. + do {
  104. + BCM4710_DUMMY_RREG();
  105. + cache_op(Hit_Writeback_Inv_D, start);
  106. + start += current_cpu_data.dcache.linesz;
  107. + } while(start < end);
  108. +}
  109. +
  110. +static inline void blast_dcache_page_indexed(unsigned long page)
  111. +{
  112. + unsigned long start = page;
  113. + unsigned long end = start + PAGE_SIZE;
  114. + unsigned long ws_inc = 1UL << current_cpu_data.dcache.waybit;
  115. + unsigned long ws_end = current_cpu_data.dcache.ways <<
  116. + current_cpu_data.dcache.waybit;
  117. + unsigned long ws, addr;
  118. + for (ws = 0; ws < ws_end; ws += ws_inc) {
  119. + start = page + ws;
  120. + for (addr = start; addr < end; addr += current_cpu_data.dcache.linesz) {
  121. + BCM4710_DUMMY_RREG();
  122. + cache_op(Index_Writeback_Inv_D, addr);
  123. + }
  124. + }
  125. +}
  126. +
  127. /* build blast_xxx, blast_xxx_page, blast_xxx_page_indexed */
  128. -#define __BUILD_BLAST_CACHE(pfx, desc, indexop, hitop, lsize, extra) \
  129. +#define __BUILD_BLAST_CACHE(pfx, desc, indexop, hitop, lsize, extra, war) \
  130. static inline void extra##blast_##pfx##cache##lsize(void) \
  131. { \
  132. unsigned long start = INDEX_BASE; \
  133. @@ -571,6 +651,7 @@ static inline void extra##blast_##pfx##c
  134. \
  135. __##pfx##flush_prologue \
  136. \
  137. + war \
  138. for (ws = 0; ws < ws_end; ws += ws_inc) \
  139. for (addr = start; addr < end; addr += lsize * 32) \
  140. cache##lsize##_unroll32(addr|ws, indexop); \
  141. @@ -585,6 +666,7 @@ static inline void extra##blast_##pfx##c
  142. \
  143. __##pfx##flush_prologue \
  144. \
  145. + war \
  146. do { \
  147. cache##lsize##_unroll32(start, hitop); \
  148. start += lsize * 32; \
  149. @@ -603,6 +685,8 @@ static inline void extra##blast_##pfx##c
  150. current_cpu_data.desc.waybit; \
  151. unsigned long ws, addr; \
  152. \
  153. + war \
  154. + \
  155. __##pfx##flush_prologue \
  156. \
  157. for (ws = 0; ws < ws_end; ws += ws_inc) \
  158. @@ -612,26 +696,26 @@ static inline void extra##blast_##pfx##c
  159. __##pfx##flush_epilogue \
  160. }
  161. -__BUILD_BLAST_CACHE(d, dcache, Index_Writeback_Inv_D, Hit_Writeback_Inv_D, 16, )
  162. -__BUILD_BLAST_CACHE(i, icache, Index_Invalidate_I, Hit_Invalidate_I, 16, )
  163. -__BUILD_BLAST_CACHE(s, scache, Index_Writeback_Inv_SD, Hit_Writeback_Inv_SD, 16, )
  164. -__BUILD_BLAST_CACHE(d, dcache, Index_Writeback_Inv_D, Hit_Writeback_Inv_D, 32, )
  165. -__BUILD_BLAST_CACHE(i, icache, Index_Invalidate_I, Hit_Invalidate_I, 32, )
  166. -__BUILD_BLAST_CACHE(i, icache, Index_Invalidate_I, Hit_Invalidate_I_Loongson2, 32, loongson2_)
  167. -__BUILD_BLAST_CACHE(s, scache, Index_Writeback_Inv_SD, Hit_Writeback_Inv_SD, 32, )
  168. -__BUILD_BLAST_CACHE(d, dcache, Index_Writeback_Inv_D, Hit_Writeback_Inv_D, 64, )
  169. -__BUILD_BLAST_CACHE(i, icache, Index_Invalidate_I, Hit_Invalidate_I, 64, )
  170. -__BUILD_BLAST_CACHE(s, scache, Index_Writeback_Inv_SD, Hit_Writeback_Inv_SD, 64, )
  171. -__BUILD_BLAST_CACHE(d, dcache, Index_Writeback_Inv_D, Hit_Writeback_Inv_D, 128, )
  172. -__BUILD_BLAST_CACHE(i, icache, Index_Invalidate_I, Hit_Invalidate_I, 128, )
  173. -__BUILD_BLAST_CACHE(s, scache, Index_Writeback_Inv_SD, Hit_Writeback_Inv_SD, 128, )
  174. -
  175. -__BUILD_BLAST_CACHE(inv_d, dcache, Index_Writeback_Inv_D, Hit_Invalidate_D, 16, )
  176. -__BUILD_BLAST_CACHE(inv_d, dcache, Index_Writeback_Inv_D, Hit_Invalidate_D, 32, )
  177. -__BUILD_BLAST_CACHE(inv_s, scache, Index_Writeback_Inv_SD, Hit_Invalidate_SD, 16, )
  178. -__BUILD_BLAST_CACHE(inv_s, scache, Index_Writeback_Inv_SD, Hit_Invalidate_SD, 32, )
  179. -__BUILD_BLAST_CACHE(inv_s, scache, Index_Writeback_Inv_SD, Hit_Invalidate_SD, 64, )
  180. -__BUILD_BLAST_CACHE(inv_s, scache, Index_Writeback_Inv_SD, Hit_Invalidate_SD, 128, )
  181. +__BUILD_BLAST_CACHE(d, dcache, Index_Writeback_Inv_D, Hit_Writeback_Inv_D, 16, , )
  182. +__BUILD_BLAST_CACHE(i, icache, Index_Invalidate_I, Hit_Invalidate_I, 16, , BCM4710_FILL_TLB(start);)
  183. +__BUILD_BLAST_CACHE(s, scache, Index_Writeback_Inv_SD, Hit_Writeback_Inv_SD, 16, , )
  184. +__BUILD_BLAST_CACHE(d, dcache, Index_Writeback_Inv_D, Hit_Writeback_Inv_D, 32, , )
  185. +__BUILD_BLAST_CACHE(i, icache, Index_Invalidate_I, Hit_Invalidate_I, 32, , BCM4710_FILL_TLB(start);)
  186. +__BUILD_BLAST_CACHE(i, icache, Index_Invalidate_I, Hit_Invalidate_I_Loongson2, 32, loongson2_, BCM4710_FILL_TLB(start);)
  187. +__BUILD_BLAST_CACHE(s, scache, Index_Writeback_Inv_SD, Hit_Writeback_Inv_SD, 32, , )
  188. +__BUILD_BLAST_CACHE(d, dcache, Index_Writeback_Inv_D, Hit_Writeback_Inv_D, 64, , )
  189. +__BUILD_BLAST_CACHE(i, icache, Index_Invalidate_I, Hit_Invalidate_I, 64, , BCM4710_FILL_TLB(start);)
  190. +__BUILD_BLAST_CACHE(s, scache, Index_Writeback_Inv_SD, Hit_Writeback_Inv_SD, 64, , )
  191. +__BUILD_BLAST_CACHE(d, dcache, Index_Writeback_Inv_D, Hit_Writeback_Inv_D, 128, , )
  192. +__BUILD_BLAST_CACHE(i, icache, Index_Invalidate_I, Hit_Invalidate_I, 128, , )
  193. +__BUILD_BLAST_CACHE(s, scache, Index_Writeback_Inv_SD, Hit_Writeback_Inv_SD, 128, , )
  194. +
  195. +__BUILD_BLAST_CACHE(inv_d, dcache, Index_Writeback_Inv_D, Hit_Invalidate_D, 16, , )
  196. +__BUILD_BLAST_CACHE(inv_d, dcache, Index_Writeback_Inv_D, Hit_Invalidate_D, 32, , )
  197. +__BUILD_BLAST_CACHE(inv_s, scache, Index_Writeback_Inv_SD, Hit_Invalidate_SD, 16, , )
  198. +__BUILD_BLAST_CACHE(inv_s, scache, Index_Writeback_Inv_SD, Hit_Invalidate_SD, 32, , )
  199. +__BUILD_BLAST_CACHE(inv_s, scache, Index_Writeback_Inv_SD, Hit_Invalidate_SD, 64, , )
  200. +__BUILD_BLAST_CACHE(inv_s, scache, Index_Writeback_Inv_SD, Hit_Invalidate_SD, 128, , )
  201. #define __BUILD_BLAST_USER_CACHE(pfx, desc, indexop, hitop, lsize) \
  202. static inline void blast_##pfx##cache##lsize##_user_page(unsigned long page) \
  203. @@ -660,53 +744,23 @@ __BUILD_BLAST_USER_CACHE(d, dcache, Inde
  204. __BUILD_BLAST_USER_CACHE(i, icache, Index_Invalidate_I, Hit_Invalidate_I, 64)
  205. /* build blast_xxx_range, protected_blast_xxx_range */
  206. -#define __BUILD_BLAST_CACHE_RANGE(pfx, desc, hitop, prot, extra) \
  207. +#define __BUILD_BLAST_CACHE_RANGE(pfx, desc, hitop, prot, extra, war, war2) \
  208. static inline void prot##extra##blast_##pfx##cache##_range(unsigned long start, \
  209. unsigned long end) \
  210. { \
  211. unsigned long lsize = cpu_##desc##_line_size(); \
  212. - unsigned long lsize_2 = lsize * 2; \
  213. - unsigned long lsize_3 = lsize * 3; \
  214. - unsigned long lsize_4 = lsize * 4; \
  215. - unsigned long lsize_5 = lsize * 5; \
  216. - unsigned long lsize_6 = lsize * 6; \
  217. - unsigned long lsize_7 = lsize * 7; \
  218. - unsigned long lsize_8 = lsize * 8; \
  219. unsigned long addr = start & ~(lsize - 1); \
  220. - unsigned long aend = (end + lsize - 1) & ~(lsize - 1); \
  221. - int lines = (aend - addr) / lsize; \
  222. + unsigned long aend = (end - 1) & ~(lsize - 1); \
  223. + war \
  224. \
  225. __##pfx##flush_prologue \
  226. \
  227. - while (lines >= 8) { \
  228. - prot##cache_op(hitop, addr); \
  229. - prot##cache_op(hitop, addr + lsize); \
  230. - prot##cache_op(hitop, addr + lsize_2); \
  231. - prot##cache_op(hitop, addr + lsize_3); \
  232. - prot##cache_op(hitop, addr + lsize_4); \
  233. - prot##cache_op(hitop, addr + lsize_5); \
  234. - prot##cache_op(hitop, addr + lsize_6); \
  235. - prot##cache_op(hitop, addr + lsize_7); \
  236. - addr += lsize_8; \
  237. - lines -= 8; \
  238. - } \
  239. - \
  240. - if (lines & 0x4) { \
  241. - prot##cache_op(hitop, addr); \
  242. - prot##cache_op(hitop, addr + lsize); \
  243. - prot##cache_op(hitop, addr + lsize_2); \
  244. - prot##cache_op(hitop, addr + lsize_3); \
  245. - addr += lsize_4; \
  246. - } \
  247. - \
  248. - if (lines & 0x2) { \
  249. - prot##cache_op(hitop, addr); \
  250. - prot##cache_op(hitop, addr + lsize); \
  251. - addr += lsize_2; \
  252. - } \
  253. - \
  254. - if (lines & 0x1) { \
  255. + while (1) { \
  256. + war2 \
  257. prot##cache_op(hitop, addr); \
  258. + if (addr == aend) \
  259. + break; \
  260. + addr += lsize; \
  261. } \
  262. \
  263. __##pfx##flush_epilogue \
  264. @@ -714,8 +768,8 @@ static inline void prot##extra##blast_##
  265. #ifndef CONFIG_EVA
  266. -__BUILD_BLAST_CACHE_RANGE(d, dcache, Hit_Writeback_Inv_D, protected_, )
  267. -__BUILD_BLAST_CACHE_RANGE(i, icache, Hit_Invalidate_I, protected_, )
  268. +__BUILD_BLAST_CACHE_RANGE(d, dcache, Hit_Writeback_Inv_D, protected_, , BCM4710_PROTECTED_FILL_TLB(addr); BCM4710_PROTECTED_FILL_TLB(aend);, BCM4710_DUMMY_RREG();)
  269. +__BUILD_BLAST_CACHE_RANGE(i, icache, Hit_Invalidate_I, protected_, , , )
  270. #else
  271. @@ -752,14 +806,14 @@ __BUILD_PROT_BLAST_CACHE_RANGE(d, dcache
  272. __BUILD_PROT_BLAST_CACHE_RANGE(i, icache, Hit_Invalidate_I)
  273. #endif
  274. -__BUILD_BLAST_CACHE_RANGE(s, scache, Hit_Writeback_Inv_SD, protected_, )
  275. +__BUILD_BLAST_CACHE_RANGE(s, scache, Hit_Writeback_Inv_SD, protected_, , , )
  276. __BUILD_BLAST_CACHE_RANGE(i, icache, Hit_Invalidate_I_Loongson2, \
  277. - protected_, loongson2_)
  278. -__BUILD_BLAST_CACHE_RANGE(d, dcache, Hit_Writeback_Inv_D, , )
  279. -__BUILD_BLAST_CACHE_RANGE(i, icache, Hit_Invalidate_I, , )
  280. -__BUILD_BLAST_CACHE_RANGE(s, scache, Hit_Writeback_Inv_SD, , )
  281. + protected_, loongson2_, , )
  282. +__BUILD_BLAST_CACHE_RANGE(d, dcache, Hit_Writeback_Inv_D, , , BCM4710_FILL_TLB(addr); BCM4710_FILL_TLB(aend);, BCM4710_DUMMY_RREG();)
  283. +__BUILD_BLAST_CACHE_RANGE(i, icache, Hit_Invalidate_I, , , , )
  284. +__BUILD_BLAST_CACHE_RANGE(s, scache, Hit_Writeback_Inv_SD, , , , )
  285. /* blast_inv_dcache_range */
  286. -__BUILD_BLAST_CACHE_RANGE(inv_d, dcache, Hit_Invalidate_D, , )
  287. -__BUILD_BLAST_CACHE_RANGE(inv_s, scache, Hit_Invalidate_SD, , )
  288. +__BUILD_BLAST_CACHE_RANGE(inv_d, dcache, Hit_Invalidate_D, , , , BCM4710_DUMMY_RREG();)
  289. +__BUILD_BLAST_CACHE_RANGE(inv_s, scache, Hit_Invalidate_SD, , , , )
  290. #endif /* _ASM_R4KCACHE_H */
  291. --- a/arch/mips/include/asm/stackframe.h
  292. +++ b/arch/mips/include/asm/stackframe.h
  293. @@ -365,6 +365,10 @@
  294. .macro RESTORE_SP_AND_RET
  295. LONG_L sp, PT_R29(sp)
  296. .set arch=r4000
  297. +#ifdef CONFIG_BCM47XX
  298. + nop
  299. + nop
  300. +#endif
  301. eret
  302. .set mips0
  303. .endm
  304. --- a/arch/mips/kernel/genex.S
  305. +++ b/arch/mips/kernel/genex.S
  306. @@ -21,6 +21,19 @@
  307. #include <asm/war.h>
  308. #include <asm/thread_info.h>
  309. +#ifdef CONFIG_BCM47XX
  310. +# ifdef eret
  311. +# undef eret
  312. +# endif
  313. +# define eret \
  314. + .set push; \
  315. + .set noreorder; \
  316. + nop; \
  317. + nop; \
  318. + eret; \
  319. + .set pop;
  320. +#endif
  321. +
  322. __INIT
  323. /*
  324. @@ -32,6 +45,9 @@
  325. NESTED(except_vec3_generic, 0, sp)
  326. .set push
  327. .set noat
  328. +#ifdef CONFIG_BCM47XX
  329. + nop
  330. +#endif
  331. #if R5432_CP0_INTERRUPT_WAR
  332. mfc0 k0, CP0_INDEX
  333. #endif
  334. @@ -55,6 +71,9 @@ NESTED(except_vec3_r4000, 0, sp)
  335. .set push
  336. .set arch=r4000
  337. .set noat
  338. +#ifdef CONFIG_BCM47XX
  339. + nop
  340. +#endif
  341. mfc0 k1, CP0_CAUSE
  342. li k0, 31<<2
  343. andi k1, k1, 0x7c
  344. --- a/arch/mips/mm/c-r4k.c
  345. +++ b/arch/mips/mm/c-r4k.c
  346. @@ -39,6 +39,9 @@
  347. #include <asm/dma-coherence.h>
  348. #include <asm/mips-cm.h>
  349. +/* For enabling BCM4710 cache workarounds */
  350. +static int bcm4710 = 0;
  351. +
  352. /*
  353. * Bits describing what cache ops an SMP callback function may perform.
  354. *
  355. @@ -190,6 +193,9 @@ static void r4k_blast_dcache_user_page_s
  356. {
  357. unsigned long dc_lsize = cpu_dcache_line_size();
  358. + if (bcm4710)
  359. + r4k_blast_dcache_page = blast_dcache_page;
  360. + else
  361. if (dc_lsize == 0)
  362. r4k_blast_dcache_user_page = (void *)cache_noop;
  363. else if (dc_lsize == 16)
  364. @@ -208,6 +214,9 @@ static void r4k_blast_dcache_page_indexe
  365. {
  366. unsigned long dc_lsize = cpu_dcache_line_size();
  367. + if (bcm4710)
  368. + r4k_blast_dcache_page_indexed = blast_dcache_page_indexed;
  369. + else
  370. if (dc_lsize == 0)
  371. r4k_blast_dcache_page_indexed = (void *)cache_noop;
  372. else if (dc_lsize == 16)
  373. @@ -227,6 +236,9 @@ static void r4k_blast_dcache_setup(void)
  374. {
  375. unsigned long dc_lsize = cpu_dcache_line_size();
  376. + if (bcm4710)
  377. + r4k_blast_dcache = blast_dcache;
  378. + else
  379. if (dc_lsize == 0)
  380. r4k_blast_dcache = (void *)cache_noop;
  381. else if (dc_lsize == 16)
  382. @@ -955,6 +967,8 @@ static void local_r4k_flush_cache_sigtra
  383. }
  384. R4600_HIT_CACHEOP_WAR_IMPL;
  385. + BCM4710_PROTECTED_FILL_TLB(addr);
  386. + BCM4710_PROTECTED_FILL_TLB(addr + 4);
  387. if (!cpu_has_ic_fills_f_dc) {
  388. if (dc_lsize)
  389. vaddr ? flush_dcache_line(addr & ~(dc_lsize - 1))
  390. @@ -1843,6 +1857,17 @@ static void coherency_setup(void)
  391. * silly idea of putting something else there ...
  392. */
  393. switch (current_cpu_type()) {
  394. + case CPU_BMIPS3300:
  395. + {
  396. + u32 cm;
  397. + cm = read_c0_diag();
  398. + /* Enable icache */
  399. + cm |= (1 << 31);
  400. + /* Enable dcache */
  401. + cm |= (1 << 30);
  402. + write_c0_diag(cm);
  403. + }
  404. + break;
  405. case CPU_R4000PC:
  406. case CPU_R4000SC:
  407. case CPU_R4000MC:
  408. @@ -1889,6 +1914,15 @@ void r4k_cache_init(void)
  409. extern void build_copy_page(void);
  410. struct cpuinfo_mips *c = &current_cpu_data;
  411. + /* Check if special workarounds are required */
  412. +#if defined(CONFIG_BCM47XX) && !defined(CONFIG_CPU_MIPS32_R2)
  413. + if (current_cpu_data.cputype == CPU_BMIPS32 && (current_cpu_data.processor_id & 0xff) == 0) {
  414. + printk("Enabling BCM4710A0 cache workarounds.\n");
  415. + bcm4710 = 1;
  416. + } else
  417. +#endif
  418. + bcm4710 = 0;
  419. +
  420. probe_pcache();
  421. probe_vcache();
  422. setup_scache();
  423. @@ -1966,7 +2000,15 @@ void r4k_cache_init(void)
  424. */
  425. local_r4k___flush_cache_all(NULL);
  426. +#ifdef CONFIG_BCM47XX
  427. + {
  428. + static void (*_coherency_setup)(void);
  429. + _coherency_setup = (void (*)(void)) KSEG1ADDR(coherency_setup);
  430. + _coherency_setup();
  431. + }
  432. +#else
  433. coherency_setup();
  434. +#endif
  435. board_cache_error_setup = r4k_cache_error_setup;
  436. /*
  437. --- a/arch/mips/mm/tlbex.c
  438. +++ b/arch/mips/mm/tlbex.c
  439. @@ -968,6 +968,9 @@ build_get_pgde32(u32 **p, unsigned int t
  440. uasm_i_srl(p, ptr, ptr, SMP_CPUID_PTRSHIFT);
  441. uasm_i_addu(p, ptr, tmp, ptr);
  442. #else
  443. +#ifdef CONFIG_BCM47XX
  444. + uasm_i_nop(p);
  445. +#endif
  446. UASM_i_LA_mostly(p, ptr, pgdc);
  447. #endif
  448. uasm_i_mfc0(p, tmp, C0_BADVADDR); /* get faulting address */
  449. @@ -1310,6 +1313,9 @@ static void build_r4000_tlb_refill_handl
  450. #ifdef CONFIG_64BIT
  451. build_get_pmde64(&p, &l, &r, K0, K1); /* get pmd in K1 */
  452. #else
  453. +# ifdef CONFIG_BCM47XX
  454. + uasm_i_nop(&p);
  455. +# endif
  456. build_get_pgde32(&p, K0, K1); /* get pgd in K1 */
  457. #endif
  458. @@ -1321,6 +1327,9 @@ static void build_r4000_tlb_refill_handl
  459. build_update_entries(&p, K0, K1);
  460. build_tlb_write_entry(&p, &l, &r, tlb_random);
  461. uasm_l_leave(&l, p);
  462. +#ifdef CONFIG_BCM47XX
  463. + uasm_i_nop(&p);
  464. +#endif
  465. uasm_i_eret(&p); /* return from trap */
  466. }
  467. #ifdef CONFIG_MIPS_HUGE_TLB_SUPPORT
  468. @@ -2003,6 +2012,9 @@ build_r4000_tlbchange_handler_head(u32 *
  469. #ifdef CONFIG_64BIT
  470. build_get_pmde64(p, l, r, wr.r1, wr.r2); /* get pmd in ptr */
  471. #else
  472. +# ifdef CONFIG_BCM47XX
  473. + uasm_i_nop(p);
  474. +# endif
  475. build_get_pgde32(p, wr.r1, wr.r2); /* get pgd in ptr */
  476. #endif
  477. @@ -2049,6 +2061,9 @@ build_r4000_tlbchange_handler_tail(u32 *
  478. build_tlb_write_entry(p, l, r, tlb_indexed);
  479. uasm_l_leave(l, *p);
  480. build_restore_work_registers(p);
  481. +#ifdef CONFIG_BCM47XX
  482. + uasm_i_nop(p);
  483. +#endif
  484. uasm_i_eret(p); /* return from trap */
  485. #ifdef CONFIG_64BIT