c-r4k.c 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260
  1. /*
  2. * This file is subject to the terms and conditions of the GNU General Public
  3. * License. See the file "COPYING" in the main directory of this archive
  4. * for more details.
  5. *
  6. * Copyright (C) 1996 David S. Miller (dm@engr.sgi.com)
  7. * Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 Ralf Baechle (ralf@gnu.org)
  8. * Copyright (C) 1999, 2000 Silicon Graphics, Inc.
  9. */
  10. #include <linux/config.h>
  11. #include <linux/init.h>
  12. #include <linux/kernel.h>
  13. #include <linux/sched.h>
  14. #include <linux/mm.h>
  15. #include <linux/bitops.h>
  16. #include <asm/bcache.h>
  17. #include <asm/bootinfo.h>
  18. #include <asm/cacheops.h>
  19. #include <asm/cpu.h>
  20. #include <asm/cpu-features.h>
  21. #include <asm/io.h>
  22. #include <asm/page.h>
  23. #include <asm/pgtable.h>
  24. #include <asm/r4kcache.h>
  25. #include <asm/system.h>
  26. #include <asm/mmu_context.h>
  27. #include <asm/war.h>
  28. static unsigned long icache_size, dcache_size, scache_size;
  29. /*
  30. * Dummy cache handling routines for machines without boardcaches
  31. */
  32. static void no_sc_noop(void) {}
  33. static struct bcache_ops no_sc_ops = {
  34. .bc_enable = (void *)no_sc_noop,
  35. .bc_disable = (void *)no_sc_noop,
  36. .bc_wback_inv = (void *)no_sc_noop,
  37. .bc_inv = (void *)no_sc_noop
  38. };
  39. struct bcache_ops *bcops = &no_sc_ops;
  40. #define cpu_is_r4600_v1_x() ((read_c0_prid() & 0xfffffff0) == 0x2010)
  41. #define cpu_is_r4600_v2_x() ((read_c0_prid() & 0xfffffff0) == 0x2020)
  42. #define R4600_HIT_CACHEOP_WAR_IMPL \
  43. do { \
  44. if (R4600_V2_HIT_CACHEOP_WAR && cpu_is_r4600_v2_x()) \
  45. *(volatile unsigned long *)CKSEG1; \
  46. if (R4600_V1_HIT_CACHEOP_WAR) \
  47. __asm__ __volatile__("nop;nop;nop;nop"); \
  48. } while (0)
  49. static void (*r4k_blast_dcache_page)(unsigned long addr);
  50. static inline void r4k_blast_dcache_page_dc32(unsigned long addr)
  51. {
  52. R4600_HIT_CACHEOP_WAR_IMPL;
  53. blast_dcache32_page(addr);
  54. }
  55. static inline void r4k_blast_dcache_page_setup(void)
  56. {
  57. unsigned long dc_lsize = cpu_dcache_line_size();
  58. if (dc_lsize == 16)
  59. r4k_blast_dcache_page = blast_dcache16_page;
  60. else if (dc_lsize == 32)
  61. r4k_blast_dcache_page = r4k_blast_dcache_page_dc32;
  62. }
  63. static void (* r4k_blast_dcache_page_indexed)(unsigned long addr);
  64. static inline void r4k_blast_dcache_page_indexed_setup(void)
  65. {
  66. unsigned long dc_lsize = cpu_dcache_line_size();
  67. if (dc_lsize == 16)
  68. r4k_blast_dcache_page_indexed = blast_dcache16_page_indexed;
  69. else if (dc_lsize == 32)
  70. r4k_blast_dcache_page_indexed = blast_dcache32_page_indexed;
  71. }
  72. static void (* r4k_blast_dcache)(void);
  73. static inline void r4k_blast_dcache_setup(void)
  74. {
  75. unsigned long dc_lsize = cpu_dcache_line_size();
  76. if (dc_lsize == 16)
  77. r4k_blast_dcache = blast_dcache16;
  78. else if (dc_lsize == 32)
  79. r4k_blast_dcache = blast_dcache32;
  80. }
  81. /* force code alignment (used for TX49XX_ICACHE_INDEX_INV_WAR) */
  82. #define JUMP_TO_ALIGN(order) \
  83. __asm__ __volatile__( \
  84. "b\t1f\n\t" \
  85. ".align\t" #order "\n\t" \
  86. "1:\n\t" \
  87. )
  88. #define CACHE32_UNROLL32_ALIGN JUMP_TO_ALIGN(10) /* 32 * 32 = 1024 */
  89. #define CACHE32_UNROLL32_ALIGN2 JUMP_TO_ALIGN(11)
  90. static inline void blast_r4600_v1_icache32(void)
  91. {
  92. unsigned long flags;
  93. local_irq_save(flags);
  94. blast_icache32();
  95. local_irq_restore(flags);
  96. }
  97. static inline void tx49_blast_icache32(void)
  98. {
  99. unsigned long start = INDEX_BASE;
  100. unsigned long end = start + current_cpu_data.icache.waysize;
  101. unsigned long ws_inc = 1UL << current_cpu_data.icache.waybit;
  102. unsigned long ws_end = current_cpu_data.icache.ways <<
  103. current_cpu_data.icache.waybit;
  104. unsigned long ws, addr;
  105. CACHE32_UNROLL32_ALIGN2;
  106. /* I'm in even chunk. blast odd chunks */
  107. for (ws = 0; ws < ws_end; ws += ws_inc)
  108. for (addr = start + 0x400; addr < end; addr += 0x400 * 2)
  109. cache32_unroll32(addr|ws,Index_Invalidate_I);
  110. CACHE32_UNROLL32_ALIGN;
  111. /* I'm in odd chunk. blast even chunks */
  112. for (ws = 0; ws < ws_end; ws += ws_inc)
  113. for (addr = start; addr < end; addr += 0x400 * 2)
  114. cache32_unroll32(addr|ws,Index_Invalidate_I);
  115. }
  116. static inline void blast_icache32_r4600_v1_page_indexed(unsigned long page)
  117. {
  118. unsigned long flags;
  119. local_irq_save(flags);
  120. blast_icache32_page_indexed(page);
  121. local_irq_restore(flags);
  122. }
  123. static inline void tx49_blast_icache32_page_indexed(unsigned long page)
  124. {
  125. unsigned long start = page;
  126. unsigned long end = start + PAGE_SIZE;
  127. unsigned long ws_inc = 1UL << current_cpu_data.icache.waybit;
  128. unsigned long ws_end = current_cpu_data.icache.ways <<
  129. current_cpu_data.icache.waybit;
  130. unsigned long ws, addr;
  131. CACHE32_UNROLL32_ALIGN2;
  132. /* I'm in even chunk. blast odd chunks */
  133. for (ws = 0; ws < ws_end; ws += ws_inc)
  134. for (addr = start + 0x400; addr < end; addr += 0x400 * 2)
  135. cache32_unroll32(addr|ws,Index_Invalidate_I);
  136. CACHE32_UNROLL32_ALIGN;
  137. /* I'm in odd chunk. blast even chunks */
  138. for (ws = 0; ws < ws_end; ws += ws_inc)
  139. for (addr = start; addr < end; addr += 0x400 * 2)
  140. cache32_unroll32(addr|ws,Index_Invalidate_I);
  141. }
  142. static void (* r4k_blast_icache_page)(unsigned long addr);
  143. static inline void r4k_blast_icache_page_setup(void)
  144. {
  145. unsigned long ic_lsize = cpu_icache_line_size();
  146. if (ic_lsize == 16)
  147. r4k_blast_icache_page = blast_icache16_page;
  148. else if (ic_lsize == 32)
  149. r4k_blast_icache_page = blast_icache32_page;
  150. else if (ic_lsize == 64)
  151. r4k_blast_icache_page = blast_icache64_page;
  152. }
  153. static void (* r4k_blast_icache_page_indexed)(unsigned long addr);
  154. static inline void r4k_blast_icache_page_indexed_setup(void)
  155. {
  156. unsigned long ic_lsize = cpu_icache_line_size();
  157. if (ic_lsize == 16)
  158. r4k_blast_icache_page_indexed = blast_icache16_page_indexed;
  159. else if (ic_lsize == 32) {
  160. if (TX49XX_ICACHE_INDEX_INV_WAR)
  161. r4k_blast_icache_page_indexed =
  162. tx49_blast_icache32_page_indexed;
  163. else if (R4600_V1_INDEX_ICACHEOP_WAR && cpu_is_r4600_v1_x())
  164. r4k_blast_icache_page_indexed =
  165. blast_icache32_r4600_v1_page_indexed;
  166. else
  167. r4k_blast_icache_page_indexed =
  168. blast_icache32_page_indexed;
  169. } else if (ic_lsize == 64)
  170. r4k_blast_icache_page_indexed = blast_icache64_page_indexed;
  171. }
  172. static void (* r4k_blast_icache)(void);
  173. static inline void r4k_blast_icache_setup(void)
  174. {
  175. unsigned long ic_lsize = cpu_icache_line_size();
  176. if (ic_lsize == 16)
  177. r4k_blast_icache = blast_icache16;
  178. else if (ic_lsize == 32) {
  179. if (R4600_V1_INDEX_ICACHEOP_WAR && cpu_is_r4600_v1_x())
  180. r4k_blast_icache = blast_r4600_v1_icache32;
  181. else if (TX49XX_ICACHE_INDEX_INV_WAR)
  182. r4k_blast_icache = tx49_blast_icache32;
  183. else
  184. r4k_blast_icache = blast_icache32;
  185. } else if (ic_lsize == 64)
  186. r4k_blast_icache = blast_icache64;
  187. }
  188. static void (* r4k_blast_scache_page)(unsigned long addr);
  189. static inline void r4k_blast_scache_page_setup(void)
  190. {
  191. unsigned long sc_lsize = cpu_scache_line_size();
  192. if (sc_lsize == 16)
  193. r4k_blast_scache_page = blast_scache16_page;
  194. else if (sc_lsize == 32)
  195. r4k_blast_scache_page = blast_scache32_page;
  196. else if (sc_lsize == 64)
  197. r4k_blast_scache_page = blast_scache64_page;
  198. else if (sc_lsize == 128)
  199. r4k_blast_scache_page = blast_scache128_page;
  200. }
  201. static void (* r4k_blast_scache_page_indexed)(unsigned long addr);
  202. static inline void r4k_blast_scache_page_indexed_setup(void)
  203. {
  204. unsigned long sc_lsize = cpu_scache_line_size();
  205. if (sc_lsize == 16)
  206. r4k_blast_scache_page_indexed = blast_scache16_page_indexed;
  207. else if (sc_lsize == 32)
  208. r4k_blast_scache_page_indexed = blast_scache32_page_indexed;
  209. else if (sc_lsize == 64)
  210. r4k_blast_scache_page_indexed = blast_scache64_page_indexed;
  211. else if (sc_lsize == 128)
  212. r4k_blast_scache_page_indexed = blast_scache128_page_indexed;
  213. }
  214. static void (* r4k_blast_scache)(void);
  215. static inline void r4k_blast_scache_setup(void)
  216. {
  217. unsigned long sc_lsize = cpu_scache_line_size();
  218. if (sc_lsize == 16)
  219. r4k_blast_scache = blast_scache16;
  220. else if (sc_lsize == 32)
  221. r4k_blast_scache = blast_scache32;
  222. else if (sc_lsize == 64)
  223. r4k_blast_scache = blast_scache64;
  224. else if (sc_lsize == 128)
  225. r4k_blast_scache = blast_scache128;
  226. }
  227. /*
  228. * This is former mm's flush_cache_all() which really should be
  229. * flush_cache_vunmap these days ...
  230. */
  231. static inline void local_r4k_flush_cache_all(void * args)
  232. {
  233. r4k_blast_dcache();
  234. r4k_blast_icache();
  235. }
  236. static void r4k_flush_cache_all(void)
  237. {
  238. if (!cpu_has_dc_aliases)
  239. return;
  240. on_each_cpu(local_r4k_flush_cache_all, NULL, 1, 1);
  241. }
  242. static inline void local_r4k___flush_cache_all(void * args)
  243. {
  244. r4k_blast_dcache();
  245. r4k_blast_icache();
  246. switch (current_cpu_data.cputype) {
  247. case CPU_R4000SC:
  248. case CPU_R4000MC:
  249. case CPU_R4400SC:
  250. case CPU_R4400MC:
  251. case CPU_R10000:
  252. case CPU_R12000:
  253. r4k_blast_scache();
  254. }
  255. }
  256. static void r4k___flush_cache_all(void)
  257. {
  258. on_each_cpu(local_r4k___flush_cache_all, NULL, 1, 1);
  259. }
  260. static inline void local_r4k_flush_cache_range(void * args)
  261. {
  262. struct vm_area_struct *vma = args;
  263. int exec;
  264. if (!(cpu_context(smp_processor_id(), vma->vm_mm)))
  265. return;
  266. exec = vma->vm_flags & VM_EXEC;
  267. if (cpu_has_dc_aliases || exec)
  268. r4k_blast_dcache();
  269. if (exec)
  270. r4k_blast_icache();
  271. }
  272. static void r4k_flush_cache_range(struct vm_area_struct *vma,
  273. unsigned long start, unsigned long end)
  274. {
  275. on_each_cpu(local_r4k_flush_cache_range, vma, 1, 1);
  276. }
  277. static inline void local_r4k_flush_cache_mm(void * args)
  278. {
  279. struct mm_struct *mm = args;
  280. if (!cpu_context(smp_processor_id(), mm))
  281. return;
  282. r4k_blast_dcache();
  283. r4k_blast_icache();
  284. /*
  285. * Kludge alert. For obscure reasons R4000SC and R4400SC go nuts if we
  286. * only flush the primary caches but R10000 and R12000 behave sane ...
  287. */
  288. if (current_cpu_data.cputype == CPU_R4000SC ||
  289. current_cpu_data.cputype == CPU_R4000MC ||
  290. current_cpu_data.cputype == CPU_R4400SC ||
  291. current_cpu_data.cputype == CPU_R4400MC)
  292. r4k_blast_scache();
  293. }
  294. static void r4k_flush_cache_mm(struct mm_struct *mm)
  295. {
  296. if (!cpu_has_dc_aliases)
  297. return;
  298. on_each_cpu(local_r4k_flush_cache_mm, mm, 1, 1);
  299. }
  300. struct flush_cache_page_args {
  301. struct vm_area_struct *vma;
  302. unsigned long page;
  303. };
  304. static inline void local_r4k_flush_cache_page(void *args)
  305. {
  306. struct flush_cache_page_args *fcp_args = args;
  307. struct vm_area_struct *vma = fcp_args->vma;
  308. unsigned long page = fcp_args->page;
  309. int exec = vma->vm_flags & VM_EXEC;
  310. struct mm_struct *mm = vma->vm_mm;
  311. pgd_t *pgdp;
  312. pmd_t *pmdp;
  313. pte_t *ptep;
  314. page &= PAGE_MASK;
  315. pgdp = pgd_offset(mm, page);
  316. pmdp = pmd_offset(pgdp, page);
  317. ptep = pte_offset(pmdp, page);
  318. /*
  319. * If the page isn't marked valid, the page cannot possibly be
  320. * in the cache.
  321. */
  322. if (!(pte_val(*ptep) & _PAGE_PRESENT))
  323. return;
  324. /*
  325. * Doing flushes for another ASID than the current one is
  326. * too difficult since stupid R4k caches do a TLB translation
  327. * for every cache flush operation. So we do indexed flushes
  328. * in that case, which doesn't overly flush the cache too much.
  329. */
  330. if ((mm == current->active_mm) && (pte_val(*ptep) & _PAGE_VALID)) {
  331. if (cpu_has_dc_aliases || (exec && !cpu_has_ic_fills_f_dc)) {
  332. r4k_blast_dcache_page(page);
  333. if (exec && !cpu_icache_snoops_remote_store)
  334. r4k_blast_scache_page(page);
  335. }
  336. if (exec)
  337. r4k_blast_icache_page(page);
  338. return;
  339. }
  340. /*
  341. * Do indexed flush, too much work to get the (possible) TLB refills
  342. * to work correctly.
  343. */
  344. page = INDEX_BASE + (page & (dcache_size - 1));
  345. if (cpu_has_dc_aliases || (exec && !cpu_has_ic_fills_f_dc)) {
  346. r4k_blast_dcache_page_indexed(page);
  347. if (exec && !cpu_icache_snoops_remote_store)
  348. r4k_blast_scache_page_indexed(page);
  349. }
  350. if (exec) {
  351. if (cpu_has_vtag_icache) {
  352. int cpu = smp_processor_id();
  353. if (cpu_context(cpu, vma->vm_mm) != 0)
  354. drop_mmu_context(vma->vm_mm, cpu);
  355. } else
  356. r4k_blast_icache_page_indexed(page);
  357. }
  358. }
  359. static void r4k_flush_cache_page(struct vm_area_struct *vma, unsigned long page, unsigned long pfn)
  360. {
  361. struct flush_cache_page_args args;
  362. /*
  363. * If ownes no valid ASID yet, cannot possibly have gotten
  364. * this page into the cache.
  365. */
  366. if (cpu_context(smp_processor_id(), vma->vm_mm) == 0)
  367. return;
  368. args.vma = vma;
  369. args.page = page;
  370. on_each_cpu(local_r4k_flush_cache_page, &args, 1, 1);
  371. }
  372. static inline void local_r4k_flush_data_cache_page(void * addr)
  373. {
  374. r4k_blast_dcache_page((unsigned long) addr);
  375. }
  376. static void r4k_flush_data_cache_page(unsigned long addr)
  377. {
  378. on_each_cpu(local_r4k_flush_data_cache_page, (void *) addr, 1, 1);
  379. }
  380. struct flush_icache_range_args {
  381. unsigned long start;
  382. unsigned long end;
  383. };
  384. static inline void local_r4k_flush_icache_range(void *args)
  385. {
  386. struct flush_icache_range_args *fir_args = args;
  387. unsigned long dc_lsize = current_cpu_data.dcache.linesz;
  388. unsigned long ic_lsize = current_cpu_data.icache.linesz;
  389. unsigned long sc_lsize = current_cpu_data.scache.linesz;
  390. unsigned long start = fir_args->start;
  391. unsigned long end = fir_args->end;
  392. unsigned long addr, aend;
  393. if (!cpu_has_ic_fills_f_dc) {
  394. if (end - start > dcache_size) {
  395. r4k_blast_dcache();
  396. } else {
  397. addr = start & ~(dc_lsize - 1);
  398. aend = (end - 1) & ~(dc_lsize - 1);
  399. while (1) {
  400. /* Hit_Writeback_Inv_D */
  401. protected_writeback_dcache_line(addr);
  402. if (addr == aend)
  403. break;
  404. addr += dc_lsize;
  405. }
  406. }
  407. if (!cpu_icache_snoops_remote_store) {
  408. if (end - start > scache_size) {
  409. r4k_blast_scache();
  410. } else {
  411. addr = start & ~(sc_lsize - 1);
  412. aend = (end - 1) & ~(sc_lsize - 1);
  413. while (1) {
  414. /* Hit_Writeback_Inv_D */
  415. protected_writeback_scache_line(addr);
  416. if (addr == aend)
  417. break;
  418. addr += sc_lsize;
  419. }
  420. }
  421. }
  422. }
  423. if (end - start > icache_size)
  424. r4k_blast_icache();
  425. else {
  426. addr = start & ~(ic_lsize - 1);
  427. aend = (end - 1) & ~(ic_lsize - 1);
  428. while (1) {
  429. /* Hit_Invalidate_I */
  430. protected_flush_icache_line(addr);
  431. if (addr == aend)
  432. break;
  433. addr += ic_lsize;
  434. }
  435. }
  436. }
  437. static void r4k_flush_icache_range(unsigned long start, unsigned long end)
  438. {
  439. struct flush_icache_range_args args;
  440. args.start = start;
  441. args.end = end;
  442. on_each_cpu(local_r4k_flush_icache_range, &args, 1, 1);
  443. }
  444. /*
  445. * Ok, this seriously sucks. We use them to flush a user page but don't
  446. * know the virtual address, so we have to blast away the whole icache
  447. * which is significantly more expensive than the real thing. Otoh we at
  448. * least know the kernel address of the page so we can flush it
  449. * selectivly.
  450. */
  451. struct flush_icache_page_args {
  452. struct vm_area_struct *vma;
  453. struct page *page;
  454. };
  455. static inline void local_r4k_flush_icache_page(void *args)
  456. {
  457. struct flush_icache_page_args *fip_args = args;
  458. struct vm_area_struct *vma = fip_args->vma;
  459. struct page *page = fip_args->page;
  460. /*
  461. * Tricky ... Because we don't know the virtual address we've got the
  462. * choice of either invalidating the entire primary and secondary
  463. * caches or invalidating the secondary caches also. With the subset
  464. * enforcment on R4000SC, R4400SC, R10000 and R12000 invalidating the
  465. * secondary cache will result in any entries in the primary caches
  466. * also getting invalidated which hopefully is a bit more economical.
  467. */
  468. if (cpu_has_subset_pcaches) {
  469. unsigned long addr = (unsigned long) page_address(page);
  470. r4k_blast_scache_page(addr);
  471. ClearPageDcacheDirty(page);
  472. return;
  473. }
  474. if (!cpu_has_ic_fills_f_dc) {
  475. unsigned long addr = (unsigned long) page_address(page);
  476. r4k_blast_dcache_page(addr);
  477. if (!cpu_icache_snoops_remote_store)
  478. r4k_blast_scache_page(addr);
  479. ClearPageDcacheDirty(page);
  480. }
  481. /*
  482. * We're not sure of the virtual address(es) involved here, so
  483. * we have to flush the entire I-cache.
  484. */
  485. if (cpu_has_vtag_icache) {
  486. int cpu = smp_processor_id();
  487. if (cpu_context(cpu, vma->vm_mm) != 0)
  488. drop_mmu_context(vma->vm_mm, cpu);
  489. } else
  490. r4k_blast_icache();
  491. }
  492. static void r4k_flush_icache_page(struct vm_area_struct *vma,
  493. struct page *page)
  494. {
  495. struct flush_icache_page_args args;
  496. /*
  497. * If there's no context yet, or the page isn't executable, no I-cache
  498. * flush is needed.
  499. */
  500. if (!(vma->vm_flags & VM_EXEC))
  501. return;
  502. args.vma = vma;
  503. args.page = page;
  504. on_each_cpu(local_r4k_flush_icache_page, &args, 1, 1);
  505. }
  506. #ifdef CONFIG_DMA_NONCOHERENT
  507. static void r4k_dma_cache_wback_inv(unsigned long addr, unsigned long size)
  508. {
  509. unsigned long end, a;
  510. /* Catch bad driver code */
  511. BUG_ON(size == 0);
  512. if (cpu_has_subset_pcaches) {
  513. unsigned long sc_lsize = current_cpu_data.scache.linesz;
  514. if (size >= scache_size) {
  515. r4k_blast_scache();
  516. return;
  517. }
  518. a = addr & ~(sc_lsize - 1);
  519. end = (addr + size - 1) & ~(sc_lsize - 1);
  520. while (1) {
  521. flush_scache_line(a); /* Hit_Writeback_Inv_SD */
  522. if (a == end)
  523. break;
  524. a += sc_lsize;
  525. }
  526. return;
  527. }
  528. /*
  529. * Either no secondary cache or the available caches don't have the
  530. * subset property so we have to flush the primary caches
  531. * explicitly
  532. */
  533. if (size >= dcache_size) {
  534. r4k_blast_dcache();
  535. } else {
  536. unsigned long dc_lsize = current_cpu_data.dcache.linesz;
  537. R4600_HIT_CACHEOP_WAR_IMPL;
  538. a = addr & ~(dc_lsize - 1);
  539. end = (addr + size - 1) & ~(dc_lsize - 1);
  540. while (1) {
  541. flush_dcache_line(a); /* Hit_Writeback_Inv_D */
  542. if (a == end)
  543. break;
  544. a += dc_lsize;
  545. }
  546. }
  547. bc_wback_inv(addr, size);
  548. }
  549. static void r4k_dma_cache_inv(unsigned long addr, unsigned long size)
  550. {
  551. unsigned long end, a;
  552. /* Catch bad driver code */
  553. BUG_ON(size == 0);
  554. if (cpu_has_subset_pcaches) {
  555. unsigned long sc_lsize = current_cpu_data.scache.linesz;
  556. if (size >= scache_size) {
  557. r4k_blast_scache();
  558. return;
  559. }
  560. a = addr & ~(sc_lsize - 1);
  561. end = (addr + size - 1) & ~(sc_lsize - 1);
  562. while (1) {
  563. flush_scache_line(a); /* Hit_Writeback_Inv_SD */
  564. if (a == end)
  565. break;
  566. a += sc_lsize;
  567. }
  568. return;
  569. }
  570. if (size >= dcache_size) {
  571. r4k_blast_dcache();
  572. } else {
  573. unsigned long dc_lsize = current_cpu_data.dcache.linesz;
  574. R4600_HIT_CACHEOP_WAR_IMPL;
  575. a = addr & ~(dc_lsize - 1);
  576. end = (addr + size - 1) & ~(dc_lsize - 1);
  577. while (1) {
  578. flush_dcache_line(a); /* Hit_Writeback_Inv_D */
  579. if (a == end)
  580. break;
  581. a += dc_lsize;
  582. }
  583. }
  584. bc_inv(addr, size);
  585. }
  586. #endif /* CONFIG_DMA_NONCOHERENT */
  587. /*
  588. * While we're protected against bad userland addresses we don't care
  589. * very much about what happens in that case. Usually a segmentation
  590. * fault will dump the process later on anyway ...
  591. */
  592. static void local_r4k_flush_cache_sigtramp(void * arg)
  593. {
  594. unsigned long ic_lsize = current_cpu_data.icache.linesz;
  595. unsigned long dc_lsize = current_cpu_data.dcache.linesz;
  596. unsigned long sc_lsize = current_cpu_data.scache.linesz;
  597. unsigned long addr = (unsigned long) arg;
  598. R4600_HIT_CACHEOP_WAR_IMPL;
  599. protected_writeback_dcache_line(addr & ~(dc_lsize - 1));
  600. if (!cpu_icache_snoops_remote_store)
  601. protected_writeback_scache_line(addr & ~(sc_lsize - 1));
  602. protected_flush_icache_line(addr & ~(ic_lsize - 1));
  603. if (MIPS4K_ICACHE_REFILL_WAR) {
  604. __asm__ __volatile__ (
  605. ".set push\n\t"
  606. ".set noat\n\t"
  607. ".set mips3\n\t"
  608. #ifdef CONFIG_32BIT
  609. "la $at,1f\n\t"
  610. #endif
  611. #ifdef CONFIG_64BIT
  612. "dla $at,1f\n\t"
  613. #endif
  614. "cache %0,($at)\n\t"
  615. "nop; nop; nop\n"
  616. "1:\n\t"
  617. ".set pop"
  618. :
  619. : "i" (Hit_Invalidate_I));
  620. }
  621. if (MIPS_CACHE_SYNC_WAR)
  622. __asm__ __volatile__ ("sync");
  623. }
  624. static void r4k_flush_cache_sigtramp(unsigned long addr)
  625. {
  626. on_each_cpu(local_r4k_flush_cache_sigtramp, (void *) addr, 1, 1);
  627. }
  628. static void r4k_flush_icache_all(void)
  629. {
  630. if (cpu_has_vtag_icache)
  631. r4k_blast_icache();
  632. }
  633. static inline void rm7k_erratum31(void)
  634. {
  635. const unsigned long ic_lsize = 32;
  636. unsigned long addr;
  637. /* RM7000 erratum #31. The icache is screwed at startup. */
  638. write_c0_taglo(0);
  639. write_c0_taghi(0);
  640. for (addr = INDEX_BASE; addr <= INDEX_BASE + 4096; addr += ic_lsize) {
  641. __asm__ __volatile__ (
  642. ".set noreorder\n\t"
  643. ".set mips3\n\t"
  644. "cache\t%1, 0(%0)\n\t"
  645. "cache\t%1, 0x1000(%0)\n\t"
  646. "cache\t%1, 0x2000(%0)\n\t"
  647. "cache\t%1, 0x3000(%0)\n\t"
  648. "cache\t%2, 0(%0)\n\t"
  649. "cache\t%2, 0x1000(%0)\n\t"
  650. "cache\t%2, 0x2000(%0)\n\t"
  651. "cache\t%2, 0x3000(%0)\n\t"
  652. "cache\t%1, 0(%0)\n\t"
  653. "cache\t%1, 0x1000(%0)\n\t"
  654. "cache\t%1, 0x2000(%0)\n\t"
  655. "cache\t%1, 0x3000(%0)\n\t"
  656. ".set\tmips0\n\t"
  657. ".set\treorder\n\t"
  658. :
  659. : "r" (addr), "i" (Index_Store_Tag_I), "i" (Fill));
  660. }
  661. }
  662. static char *way_string[] __initdata = { NULL, "direct mapped", "2-way",
  663. "3-way", "4-way", "5-way", "6-way", "7-way", "8-way"
  664. };
  665. static void __init probe_pcache(void)
  666. {
  667. struct cpuinfo_mips *c = &current_cpu_data;
  668. unsigned int config = read_c0_config();
  669. unsigned int prid = read_c0_prid();
  670. unsigned long config1;
  671. unsigned int lsize;
  672. switch (c->cputype) {
  673. case CPU_R4600: /* QED style two way caches? */
  674. case CPU_R4700:
  675. case CPU_R5000:
  676. case CPU_NEVADA:
  677. icache_size = 1 << (12 + ((config & CONF_IC) >> 9));
  678. c->icache.linesz = 16 << ((config & CONF_IB) >> 5);
  679. c->icache.ways = 2;
  680. c->icache.waybit = ffs(icache_size/2) - 1;
  681. dcache_size = 1 << (12 + ((config & CONF_DC) >> 6));
  682. c->dcache.linesz = 16 << ((config & CONF_DB) >> 4);
  683. c->dcache.ways = 2;
  684. c->dcache.waybit= ffs(dcache_size/2) - 1;
  685. c->options |= MIPS_CPU_CACHE_CDEX_P;
  686. break;
  687. case CPU_R5432:
  688. case CPU_R5500:
  689. icache_size = 1 << (12 + ((config & CONF_IC) >> 9));
  690. c->icache.linesz = 16 << ((config & CONF_IB) >> 5);
  691. c->icache.ways = 2;
  692. c->icache.waybit= 0;
  693. dcache_size = 1 << (12 + ((config & CONF_DC) >> 6));
  694. c->dcache.linesz = 16 << ((config & CONF_DB) >> 4);
  695. c->dcache.ways = 2;
  696. c->dcache.waybit = 0;
  697. c->options |= MIPS_CPU_CACHE_CDEX_P;
  698. break;
  699. case CPU_TX49XX:
  700. icache_size = 1 << (12 + ((config & CONF_IC) >> 9));
  701. c->icache.linesz = 16 << ((config & CONF_IB) >> 5);
  702. c->icache.ways = 4;
  703. c->icache.waybit= 0;
  704. dcache_size = 1 << (12 + ((config & CONF_DC) >> 6));
  705. c->dcache.linesz = 16 << ((config & CONF_DB) >> 4);
  706. c->dcache.ways = 4;
  707. c->dcache.waybit = 0;
  708. c->options |= MIPS_CPU_CACHE_CDEX_P;
  709. break;
  710. case CPU_R4000PC:
  711. case CPU_R4000SC:
  712. case CPU_R4000MC:
  713. case CPU_R4400PC:
  714. case CPU_R4400SC:
  715. case CPU_R4400MC:
  716. case CPU_R4300:
  717. icache_size = 1 << (12 + ((config & CONF_IC) >> 9));
  718. c->icache.linesz = 16 << ((config & CONF_IB) >> 5);
  719. c->icache.ways = 1;
  720. c->icache.waybit = 0; /* doesn't matter */
  721. dcache_size = 1 << (12 + ((config & CONF_DC) >> 6));
  722. c->dcache.linesz = 16 << ((config & CONF_DB) >> 4);
  723. c->dcache.ways = 1;
  724. c->dcache.waybit = 0; /* does not matter */
  725. c->options |= MIPS_CPU_CACHE_CDEX_P;
  726. break;
  727. case CPU_R10000:
  728. case CPU_R12000:
  729. icache_size = 1 << (12 + ((config & R10K_CONF_IC) >> 29));
  730. c->icache.linesz = 64;
  731. c->icache.ways = 2;
  732. c->icache.waybit = 0;
  733. dcache_size = 1 << (12 + ((config & R10K_CONF_DC) >> 26));
  734. c->dcache.linesz = 32;
  735. c->dcache.ways = 2;
  736. c->dcache.waybit = 0;
  737. c->options |= MIPS_CPU_PREFETCH;
  738. break;
  739. case CPU_VR4133:
  740. write_c0_config(config & ~CONF_EB);
  741. case CPU_VR4131:
  742. /* Workaround for cache instruction bug of VR4131 */
  743. if (c->processor_id == 0x0c80U || c->processor_id == 0x0c81U ||
  744. c->processor_id == 0x0c82U) {
  745. config &= ~0x00000030U;
  746. config |= 0x00410000U;
  747. write_c0_config(config);
  748. }
  749. icache_size = 1 << (10 + ((config & CONF_IC) >> 9));
  750. c->icache.linesz = 16 << ((config & CONF_IB) >> 5);
  751. c->icache.ways = 2;
  752. c->icache.waybit = ffs(icache_size/2) - 1;
  753. dcache_size = 1 << (10 + ((config & CONF_DC) >> 6));
  754. c->dcache.linesz = 16 << ((config & CONF_DB) >> 4);
  755. c->dcache.ways = 2;
  756. c->dcache.waybit = ffs(dcache_size/2) - 1;
  757. c->options |= MIPS_CPU_CACHE_CDEX_P;
  758. break;
  759. case CPU_VR41XX:
  760. case CPU_VR4111:
  761. case CPU_VR4121:
  762. case CPU_VR4122:
  763. case CPU_VR4181:
  764. case CPU_VR4181A:
  765. icache_size = 1 << (10 + ((config & CONF_IC) >> 9));
  766. c->icache.linesz = 16 << ((config & CONF_IB) >> 5);
  767. c->icache.ways = 1;
  768. c->icache.waybit = 0; /* doesn't matter */
  769. dcache_size = 1 << (10 + ((config & CONF_DC) >> 6));
  770. c->dcache.linesz = 16 << ((config & CONF_DB) >> 4);
  771. c->dcache.ways = 1;
  772. c->dcache.waybit = 0; /* does not matter */
  773. c->options |= MIPS_CPU_CACHE_CDEX_P;
  774. break;
  775. case CPU_RM7000:
  776. rm7k_erratum31();
  777. case CPU_RM9000:
  778. icache_size = 1 << (12 + ((config & CONF_IC) >> 9));
  779. c->icache.linesz = 16 << ((config & CONF_IB) >> 5);
  780. c->icache.ways = 4;
  781. c->icache.waybit = ffs(icache_size / c->icache.ways) - 1;
  782. dcache_size = 1 << (12 + ((config & CONF_DC) >> 6));
  783. c->dcache.linesz = 16 << ((config & CONF_DB) >> 4);
  784. c->dcache.ways = 4;
  785. c->dcache.waybit = ffs(dcache_size / c->dcache.ways) - 1;
  786. #if !defined(CONFIG_SMP) || !defined(RM9000_CDEX_SMP_WAR)
  787. c->options |= MIPS_CPU_CACHE_CDEX_P;
  788. #endif
  789. c->options |= MIPS_CPU_PREFETCH;
  790. break;
  791. default:
  792. if (!(config & MIPS_CONF_M))
  793. panic("Don't know how to probe P-caches on this cpu.");
  794. /*
  795. * So we seem to be a MIPS32 or MIPS64 CPU
  796. * So let's probe the I-cache ...
  797. */
  798. config1 = read_c0_config1();
  799. if ((lsize = ((config1 >> 19) & 7)))
  800. c->icache.linesz = 2 << lsize;
  801. else
  802. c->icache.linesz = lsize;
  803. c->icache.sets = 64 << ((config1 >> 22) & 7);
  804. c->icache.ways = 1 + ((config1 >> 16) & 7);
  805. icache_size = c->icache.sets *
  806. c->icache.ways *
  807. c->icache.linesz;
  808. c->icache.waybit = ffs(icache_size/c->icache.ways) - 1;
  809. if (config & 0x8) /* VI bit */
  810. c->icache.flags |= MIPS_CACHE_VTAG;
  811. /*
  812. * Now probe the MIPS32 / MIPS64 data cache.
  813. */
  814. c->dcache.flags = 0;
  815. if ((lsize = ((config1 >> 10) & 7)))
  816. c->dcache.linesz = 2 << lsize;
  817. else
  818. c->dcache.linesz= lsize;
  819. c->dcache.sets = 64 << ((config1 >> 13) & 7);
  820. c->dcache.ways = 1 + ((config1 >> 7) & 7);
  821. dcache_size = c->dcache.sets *
  822. c->dcache.ways *
  823. c->dcache.linesz;
  824. c->dcache.waybit = ffs(dcache_size/c->dcache.ways) - 1;
  825. c->options |= MIPS_CPU_PREFETCH;
  826. break;
  827. }
  828. /*
  829. * Processor configuration sanity check for the R4000SC erratum
  830. * #5. With page sizes larger than 32kB there is no possibility
  831. * to get a VCE exception anymore so we don't care about this
  832. * misconfiguration. The case is rather theoretical anyway;
  833. * presumably no vendor is shipping his hardware in the "bad"
  834. * configuration.
  835. */
  836. if ((prid & 0xff00) == PRID_IMP_R4000 && (prid & 0xff) < 0x40 &&
  837. !(config & CONF_SC) && c->icache.linesz != 16 &&
  838. PAGE_SIZE <= 0x8000)
  839. panic("Improper R4000SC processor configuration detected");
  840. /* compute a couple of other cache variables */
  841. c->icache.waysize = icache_size / c->icache.ways;
  842. c->dcache.waysize = dcache_size / c->dcache.ways;
  843. c->icache.sets = icache_size / (c->icache.linesz * c->icache.ways);
  844. c->dcache.sets = dcache_size / (c->dcache.linesz * c->dcache.ways);
  845. /*
  846. * R10000 and R12000 P-caches are odd in a positive way. They're 32kB
  847. * 2-way virtually indexed so normally would suffer from aliases. So
  848. * normally they'd suffer from aliases but magic in the hardware deals
  849. * with that for us so we don't need to take care ourselves.
  850. */
  851. if (c->cputype != CPU_R10000 && c->cputype != CPU_R12000)
  852. if (c->dcache.waysize > PAGE_SIZE)
  853. c->dcache.flags |= MIPS_CACHE_ALIASES;
  854. switch (c->cputype) {
  855. case CPU_20KC:
  856. /*
  857. * Some older 20Kc chips doesn't have the 'VI' bit in
  858. * the config register.
  859. */
  860. c->icache.flags |= MIPS_CACHE_VTAG;
  861. break;
  862. case CPU_AU1500:
  863. c->icache.flags |= MIPS_CACHE_IC_F_DC;
  864. break;
  865. }
  866. printk("Primary instruction cache %ldkB, %s, %s, linesize %d bytes.\n",
  867. icache_size >> 10,
  868. cpu_has_vtag_icache ? "virtually tagged" : "physically tagged",
  869. way_string[c->icache.ways], c->icache.linesz);
  870. printk("Primary data cache %ldkB, %s, linesize %d bytes.\n",
  871. dcache_size >> 10, way_string[c->dcache.ways], c->dcache.linesz);
  872. }
  873. /*
  874. * If you even _breathe_ on this function, look at the gcc output and make sure
  875. * it does not pop things on and off the stack for the cache sizing loop that
  876. * executes in KSEG1 space or else you will crash and burn badly. You have
  877. * been warned.
  878. */
  879. static int __init probe_scache(void)
  880. {
  881. extern unsigned long stext;
  882. unsigned long flags, addr, begin, end, pow2;
  883. unsigned int config = read_c0_config();
  884. struct cpuinfo_mips *c = &current_cpu_data;
  885. int tmp;
  886. if (config & CONF_SC)
  887. return 0;
  888. begin = (unsigned long) &stext;
  889. begin &= ~((4 * 1024 * 1024) - 1);
  890. end = begin + (4 * 1024 * 1024);
  891. /*
  892. * This is such a bitch, you'd think they would make it easy to do
  893. * this. Away you daemons of stupidity!
  894. */
  895. local_irq_save(flags);
  896. /* Fill each size-multiple cache line with a valid tag. */
  897. pow2 = (64 * 1024);
  898. for (addr = begin; addr < end; addr = (begin + pow2)) {
  899. unsigned long *p = (unsigned long *) addr;
  900. __asm__ __volatile__("nop" : : "r" (*p)); /* whee... */
  901. pow2 <<= 1;
  902. }
  903. /* Load first line with zero (therefore invalid) tag. */
  904. write_c0_taglo(0);
  905. write_c0_taghi(0);
  906. __asm__ __volatile__("nop; nop; nop; nop;"); /* avoid the hazard */
  907. cache_op(Index_Store_Tag_I, begin);
  908. cache_op(Index_Store_Tag_D, begin);
  909. cache_op(Index_Store_Tag_SD, begin);
  910. /* Now search for the wrap around point. */
  911. pow2 = (128 * 1024);
  912. tmp = 0;
  913. for (addr = begin + (128 * 1024); addr < end; addr = begin + pow2) {
  914. cache_op(Index_Load_Tag_SD, addr);
  915. __asm__ __volatile__("nop; nop; nop; nop;"); /* hazard... */
  916. if (!read_c0_taglo())
  917. break;
  918. pow2 <<= 1;
  919. }
  920. local_irq_restore(flags);
  921. addr -= begin;
  922. scache_size = addr;
  923. c->scache.linesz = 16 << ((config & R4K_CONF_SB) >> 22);
  924. c->scache.ways = 1;
  925. c->dcache.waybit = 0; /* does not matter */
  926. return 1;
  927. }
  928. typedef int (*probe_func_t)(unsigned long);
  929. extern int r5k_sc_init(void);
  930. extern int rm7k_sc_init(void);
  931. static void __init setup_scache(void)
  932. {
  933. struct cpuinfo_mips *c = &current_cpu_data;
  934. unsigned int config = read_c0_config();
  935. probe_func_t probe_scache_kseg1;
  936. int sc_present = 0;
  937. /*
  938. * Do the probing thing on R4000SC and R4400SC processors. Other
  939. * processors don't have a S-cache that would be relevant to the
  940. * Linux memory managment.
  941. */
  942. switch (c->cputype) {
  943. case CPU_R4000SC:
  944. case CPU_R4000MC:
  945. case CPU_R4400SC:
  946. case CPU_R4400MC:
  947. probe_scache_kseg1 = (probe_func_t) (CKSEG1ADDR(&probe_scache));
  948. sc_present = probe_scache_kseg1(config);
  949. if (sc_present)
  950. c->options |= MIPS_CPU_CACHE_CDEX_S;
  951. break;
  952. case CPU_R10000:
  953. case CPU_R12000:
  954. scache_size = 0x80000 << ((config & R10K_CONF_SS) >> 16);
  955. c->scache.linesz = 64 << ((config >> 13) & 1);
  956. c->scache.ways = 2;
  957. c->scache.waybit= 0;
  958. sc_present = 1;
  959. break;
  960. case CPU_R5000:
  961. case CPU_NEVADA:
  962. #ifdef CONFIG_R5000_CPU_SCACHE
  963. r5k_sc_init();
  964. #endif
  965. return;
  966. case CPU_RM7000:
  967. case CPU_RM9000:
  968. #ifdef CONFIG_RM7000_CPU_SCACHE
  969. rm7k_sc_init();
  970. #endif
  971. return;
  972. default:
  973. sc_present = 0;
  974. }
  975. if (!sc_present)
  976. return;
  977. if ((c->isa_level == MIPS_CPU_ISA_M32 ||
  978. c->isa_level == MIPS_CPU_ISA_M64) &&
  979. !(c->scache.flags & MIPS_CACHE_NOT_PRESENT))
  980. panic("Dunno how to handle MIPS32 / MIPS64 second level cache");
  981. /* compute a couple of other cache variables */
  982. c->scache.waysize = scache_size / c->scache.ways;
  983. c->scache.sets = scache_size / (c->scache.linesz * c->scache.ways);
  984. printk("Unified secondary cache %ldkB %s, linesize %d bytes.\n",
  985. scache_size >> 10, way_string[c->scache.ways], c->scache.linesz);
  986. c->options |= MIPS_CPU_SUBSET_CACHES;
  987. }
  988. static inline void coherency_setup(void)
  989. {
  990. change_c0_config(CONF_CM_CMASK, CONF_CM_DEFAULT);
  991. /*
  992. * c0_status.cu=0 specifies that updates by the sc instruction use
  993. * the coherency mode specified by the TLB; 1 means cachable
  994. * coherent update on write will be used. Not all processors have
  995. * this bit and; some wire it to zero, others like Toshiba had the
  996. * silly idea of putting something else there ...
  997. */
  998. switch (current_cpu_data.cputype) {
  999. case CPU_R4000PC:
  1000. case CPU_R4000SC:
  1001. case CPU_R4000MC:
  1002. case CPU_R4400PC:
  1003. case CPU_R4400SC:
  1004. case CPU_R4400MC:
  1005. clear_c0_config(CONF_CU);
  1006. break;
  1007. }
  1008. }
  1009. void __init ld_mmu_r4xx0(void)
  1010. {
  1011. extern void build_clear_page(void);
  1012. extern void build_copy_page(void);
  1013. extern char except_vec2_generic;
  1014. struct cpuinfo_mips *c = &current_cpu_data;
  1015. /* Default cache error handler for R4000 and R5000 family */
  1016. memcpy((void *)(CAC_BASE + 0x100), &except_vec2_generic, 0x80);
  1017. memcpy((void *)(UNCAC_BASE + 0x100), &except_vec2_generic, 0x80);
  1018. probe_pcache();
  1019. setup_scache();
  1020. if (c->dcache.sets * c->dcache.ways > PAGE_SIZE)
  1021. c->dcache.flags |= MIPS_CACHE_ALIASES;
  1022. r4k_blast_dcache_page_setup();
  1023. r4k_blast_dcache_page_indexed_setup();
  1024. r4k_blast_dcache_setup();
  1025. r4k_blast_icache_page_setup();
  1026. r4k_blast_icache_page_indexed_setup();
  1027. r4k_blast_icache_setup();
  1028. r4k_blast_scache_page_setup();
  1029. r4k_blast_scache_page_indexed_setup();
  1030. r4k_blast_scache_setup();
  1031. /*
  1032. * Some MIPS32 and MIPS64 processors have physically indexed caches.
  1033. * This code supports virtually indexed processors and will be
  1034. * unnecessarily inefficient on physically indexed processors.
  1035. */
  1036. shm_align_mask = max_t( unsigned long,
  1037. c->dcache.sets * c->dcache.linesz - 1,
  1038. PAGE_SIZE - 1);
  1039. flush_cache_all = r4k_flush_cache_all;
  1040. __flush_cache_all = r4k___flush_cache_all;
  1041. flush_cache_mm = r4k_flush_cache_mm;
  1042. flush_cache_page = r4k_flush_cache_page;
  1043. flush_icache_page = r4k_flush_icache_page;
  1044. flush_cache_range = r4k_flush_cache_range;
  1045. flush_cache_sigtramp = r4k_flush_cache_sigtramp;
  1046. flush_icache_all = r4k_flush_icache_all;
  1047. flush_data_cache_page = r4k_flush_data_cache_page;
  1048. flush_icache_range = r4k_flush_icache_range;
  1049. #ifdef CONFIG_DMA_NONCOHERENT
  1050. _dma_cache_wback_inv = r4k_dma_cache_wback_inv;
  1051. _dma_cache_wback = r4k_dma_cache_wback_inv;
  1052. _dma_cache_inv = r4k_dma_cache_inv;
  1053. #endif
  1054. __flush_cache_all();
  1055. coherency_setup();
  1056. build_clear_page();
  1057. build_copy_page();
  1058. }