c-r4k.c 32 KB

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