Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 | * |
Justin P. Mattock | 79add62 | 2011-04-04 14:15:29 -0700 | [diff] [blame] | 6 | * Copyright (C) 1996 David S. Miller (davem@davemloft.net) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7 | * Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 Ralf Baechle (ralf@gnu.org) |
| 8 | * Copyright (C) 1999, 2000 Silicon Graphics, Inc. |
| 9 | */ |
James Hogan | 61d7304 | 2014-03-04 10:23:57 +0000 | [diff] [blame] | 10 | #include <linux/cpu_pm.h> |
Ralf Baechle | a754f70 | 2007-11-03 01:01:37 +0000 | [diff] [blame] | 11 | #include <linux/hardirq.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 12 | #include <linux/init.h> |
Ralf Baechle | db813fe | 2007-09-27 18:26:43 +0100 | [diff] [blame] | 13 | #include <linux/highmem.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 14 | #include <linux/kernel.h> |
Ralf Baechle | 641e97f | 2007-10-11 23:46:05 +0100 | [diff] [blame] | 15 | #include <linux/linkage.h> |
Ralf Baechle | ff52205 | 2013-09-17 12:44:31 +0200 | [diff] [blame] | 16 | #include <linux/preempt.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 17 | #include <linux/sched.h> |
Ralf Baechle | 631330f | 2009-06-19 14:05:26 +0100 | [diff] [blame] | 18 | #include <linux/smp.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 19 | #include <linux/mm.h> |
Chris Dearman | 3513369 | 2007-09-19 00:58:24 +0100 | [diff] [blame] | 20 | #include <linux/module.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 21 | #include <linux/bitops.h> |
| 22 | |
| 23 | #include <asm/bcache.h> |
| 24 | #include <asm/bootinfo.h> |
Ralf Baechle | ec74e36 | 2005-07-13 11:48:45 +0000 | [diff] [blame] | 25 | #include <asm/cache.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 26 | #include <asm/cacheops.h> |
| 27 | #include <asm/cpu.h> |
| 28 | #include <asm/cpu-features.h> |
Ralf Baechle | 69f24d1 | 2013-09-17 10:25:47 +0200 | [diff] [blame] | 29 | #include <asm/cpu-type.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 30 | #include <asm/io.h> |
| 31 | #include <asm/page.h> |
| 32 | #include <asm/pgtable.h> |
| 33 | #include <asm/r4kcache.h> |
Ralf Baechle | e001e52 | 2007-07-28 12:45:47 +0100 | [diff] [blame] | 34 | #include <asm/sections.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 35 | #include <asm/mmu_context.h> |
| 36 | #include <asm/war.h> |
Thiemo Seufer | ba5187d | 2005-04-25 16:36:23 +0000 | [diff] [blame] | 37 | #include <asm/cacheflush.h> /* for run_uncached() */ |
David Daney | 9cd9669b | 2012-05-15 00:04:49 -0700 | [diff] [blame] | 38 | #include <asm/traps.h> |
Steven J. Hill | b6d92b4 | 2013-03-25 13:47:29 -0500 | [diff] [blame] | 39 | #include <asm/dma-coherence.h> |
Markos Chandras | cccf34e | 2015-07-10 09:29:10 +0100 | [diff] [blame] | 40 | #include <asm/mips-cm.h> |
Ralf Baechle | 7f3f1d0 | 2006-05-12 13:20:06 +0100 | [diff] [blame] | 41 | |
| 42 | /* |
| 43 | * Special Variant of smp_call_function for use by cache functions: |
| 44 | * |
| 45 | * o No return value |
| 46 | * o collapses to normal function call on UP kernels |
| 47 | * o collapses to normal function call on systems with a single shared |
| 48 | * primary cache. |
Ralf Baechle | c8c5f3f | 2010-10-29 19:08:25 +0100 | [diff] [blame] | 49 | * o doesn't disable interrupts on the local CPU |
Ralf Baechle | 7f3f1d0 | 2006-05-12 13:20:06 +0100 | [diff] [blame] | 50 | */ |
Ralf Baechle | 48a26e6 | 2010-10-29 19:08:25 +0100 | [diff] [blame] | 51 | static inline void r4k_on_each_cpu(void (*func) (void *info), void *info) |
Ralf Baechle | 7f3f1d0 | 2006-05-12 13:20:06 +0100 | [diff] [blame] | 52 | { |
| 53 | preempt_disable(); |
| 54 | |
Markos Chandras | cccf34e | 2015-07-10 09:29:10 +0100 | [diff] [blame] | 55 | /* |
| 56 | * The Coherent Manager propagates address-based cache ops to other |
| 57 | * cores but not index-based ops. However, r4k_on_each_cpu is used |
| 58 | * in both cases so there is no easy way to tell what kind of op is |
| 59 | * executed to the other cores. The best we can probably do is |
| 60 | * to restrict that call when a CM is not present because both |
| 61 | * CM-based SMP protocols (CMP & CPS) restrict index-based cache ops. |
| 62 | */ |
| 63 | if (!mips_cm_present()) |
| 64 | smp_call_function_many(&cpu_foreign_map, func, info, 1); |
Ralf Baechle | 7f3f1d0 | 2006-05-12 13:20:06 +0100 | [diff] [blame] | 65 | func(info); |
| 66 | preempt_enable(); |
| 67 | } |
| 68 | |
Paul Burton | 0ee958e | 2014-01-15 10:31:53 +0000 | [diff] [blame] | 69 | #if defined(CONFIG_MIPS_CMP) || defined(CONFIG_MIPS_CPS) |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 70 | #define cpu_has_safe_index_cacheops 0 |
| 71 | #else |
| 72 | #define cpu_has_safe_index_cacheops 1 |
| 73 | #endif |
| 74 | |
Ralf Baechle | ec74e36 | 2005-07-13 11:48:45 +0000 | [diff] [blame] | 75 | /* |
| 76 | * Must die. |
| 77 | */ |
| 78 | static unsigned long icache_size __read_mostly; |
| 79 | static unsigned long dcache_size __read_mostly; |
Huacai Chen | b2edcfc | 2016-03-03 09:45:09 +0800 | [diff] [blame] | 80 | static unsigned long vcache_size __read_mostly; |
Ralf Baechle | ec74e36 | 2005-07-13 11:48:45 +0000 | [diff] [blame] | 81 | static unsigned long scache_size __read_mostly; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 82 | |
| 83 | /* |
| 84 | * Dummy cache handling routines for machines without boardcaches |
| 85 | */ |
Chris Dearman | 73f4035 | 2006-06-20 18:06:52 +0100 | [diff] [blame] | 86 | static void cache_noop(void) {} |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 87 | |
| 88 | static struct bcache_ops no_sc_ops = { |
Chris Dearman | 73f4035 | 2006-06-20 18:06:52 +0100 | [diff] [blame] | 89 | .bc_enable = (void *)cache_noop, |
| 90 | .bc_disable = (void *)cache_noop, |
| 91 | .bc_wback_inv = (void *)cache_noop, |
| 92 | .bc_inv = (void *)cache_noop |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 93 | }; |
| 94 | |
| 95 | struct bcache_ops *bcops = &no_sc_ops; |
| 96 | |
Thiemo Seufer | 330cfe0 | 2005-09-01 18:33:58 +0000 | [diff] [blame] | 97 | #define cpu_is_r4600_v1_x() ((read_c0_prid() & 0xfffffff0) == 0x00002010) |
| 98 | #define cpu_is_r4600_v2_x() ((read_c0_prid() & 0xfffffff0) == 0x00002020) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 99 | |
| 100 | #define R4600_HIT_CACHEOP_WAR_IMPL \ |
| 101 | do { \ |
| 102 | if (R4600_V2_HIT_CACHEOP_WAR && cpu_is_r4600_v2_x()) \ |
| 103 | *(volatile unsigned long *)CKSEG1; \ |
| 104 | if (R4600_V1_HIT_CACHEOP_WAR) \ |
| 105 | __asm__ __volatile__("nop;nop;nop;nop"); \ |
| 106 | } while (0) |
| 107 | |
| 108 | static void (*r4k_blast_dcache_page)(unsigned long addr); |
| 109 | |
| 110 | static inline void r4k_blast_dcache_page_dc32(unsigned long addr) |
| 111 | { |
| 112 | R4600_HIT_CACHEOP_WAR_IMPL; |
| 113 | blast_dcache32_page(addr); |
| 114 | } |
| 115 | |
Kevin Cernekee | 605b7ef | 2009-04-23 17:36:53 -0700 | [diff] [blame] | 116 | static inline void r4k_blast_dcache_page_dc64(unsigned long addr) |
| 117 | { |
Kevin Cernekee | 605b7ef | 2009-04-23 17:36:53 -0700 | [diff] [blame] | 118 | blast_dcache64_page(addr); |
| 119 | } |
| 120 | |
David Daney | 18a8cd6 | 2014-05-28 23:52:09 +0200 | [diff] [blame] | 121 | static inline void r4k_blast_dcache_page_dc128(unsigned long addr) |
| 122 | { |
| 123 | blast_dcache128_page(addr); |
| 124 | } |
| 125 | |
Paul Gortmaker | 078a55f | 2013-06-18 13:38:59 +0000 | [diff] [blame] | 126 | static void r4k_blast_dcache_page_setup(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 127 | { |
| 128 | unsigned long dc_lsize = cpu_dcache_line_size(); |
| 129 | |
David Daney | 18a8cd6 | 2014-05-28 23:52:09 +0200 | [diff] [blame] | 130 | switch (dc_lsize) { |
| 131 | case 0: |
Chris Dearman | 73f4035 | 2006-06-20 18:06:52 +0100 | [diff] [blame] | 132 | r4k_blast_dcache_page = (void *)cache_noop; |
David Daney | 18a8cd6 | 2014-05-28 23:52:09 +0200 | [diff] [blame] | 133 | break; |
| 134 | case 16: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 135 | r4k_blast_dcache_page = blast_dcache16_page; |
David Daney | 18a8cd6 | 2014-05-28 23:52:09 +0200 | [diff] [blame] | 136 | break; |
| 137 | case 32: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 138 | r4k_blast_dcache_page = r4k_blast_dcache_page_dc32; |
David Daney | 18a8cd6 | 2014-05-28 23:52:09 +0200 | [diff] [blame] | 139 | break; |
| 140 | case 64: |
Kevin Cernekee | 605b7ef | 2009-04-23 17:36:53 -0700 | [diff] [blame] | 141 | r4k_blast_dcache_page = r4k_blast_dcache_page_dc64; |
David Daney | 18a8cd6 | 2014-05-28 23:52:09 +0200 | [diff] [blame] | 142 | break; |
| 143 | case 128: |
| 144 | r4k_blast_dcache_page = r4k_blast_dcache_page_dc128; |
| 145 | break; |
| 146 | default: |
| 147 | break; |
| 148 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 149 | } |
| 150 | |
Leonid Yegoshin | 4caa906 | 2014-01-15 14:47:28 +0000 | [diff] [blame] | 151 | #ifndef CONFIG_EVA |
| 152 | #define r4k_blast_dcache_user_page r4k_blast_dcache_page |
| 153 | #else |
| 154 | |
| 155 | static void (*r4k_blast_dcache_user_page)(unsigned long addr); |
| 156 | |
| 157 | static void r4k_blast_dcache_user_page_setup(void) |
| 158 | { |
| 159 | unsigned long dc_lsize = cpu_dcache_line_size(); |
| 160 | |
| 161 | if (dc_lsize == 0) |
| 162 | r4k_blast_dcache_user_page = (void *)cache_noop; |
| 163 | else if (dc_lsize == 16) |
| 164 | r4k_blast_dcache_user_page = blast_dcache16_user_page; |
| 165 | else if (dc_lsize == 32) |
| 166 | r4k_blast_dcache_user_page = blast_dcache32_user_page; |
| 167 | else if (dc_lsize == 64) |
| 168 | r4k_blast_dcache_user_page = blast_dcache64_user_page; |
| 169 | } |
| 170 | |
| 171 | #endif |
| 172 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 173 | static void (* r4k_blast_dcache_page_indexed)(unsigned long addr); |
| 174 | |
Paul Gortmaker | 078a55f | 2013-06-18 13:38:59 +0000 | [diff] [blame] | 175 | static void r4k_blast_dcache_page_indexed_setup(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 176 | { |
| 177 | unsigned long dc_lsize = cpu_dcache_line_size(); |
| 178 | |
Chris Dearman | 73f4035 | 2006-06-20 18:06:52 +0100 | [diff] [blame] | 179 | if (dc_lsize == 0) |
| 180 | r4k_blast_dcache_page_indexed = (void *)cache_noop; |
| 181 | else if (dc_lsize == 16) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 182 | r4k_blast_dcache_page_indexed = blast_dcache16_page_indexed; |
| 183 | else if (dc_lsize == 32) |
| 184 | r4k_blast_dcache_page_indexed = blast_dcache32_page_indexed; |
Kevin Cernekee | 605b7ef | 2009-04-23 17:36:53 -0700 | [diff] [blame] | 185 | else if (dc_lsize == 64) |
| 186 | r4k_blast_dcache_page_indexed = blast_dcache64_page_indexed; |
David Daney | 18a8cd6 | 2014-05-28 23:52:09 +0200 | [diff] [blame] | 187 | else if (dc_lsize == 128) |
| 188 | r4k_blast_dcache_page_indexed = blast_dcache128_page_indexed; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 189 | } |
| 190 | |
Sanjay Lal | f2e3656 | 2012-11-21 18:34:10 -0800 | [diff] [blame] | 191 | void (* r4k_blast_dcache)(void); |
| 192 | EXPORT_SYMBOL(r4k_blast_dcache); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 193 | |
Paul Gortmaker | 078a55f | 2013-06-18 13:38:59 +0000 | [diff] [blame] | 194 | static void r4k_blast_dcache_setup(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 195 | { |
| 196 | unsigned long dc_lsize = cpu_dcache_line_size(); |
| 197 | |
Chris Dearman | 73f4035 | 2006-06-20 18:06:52 +0100 | [diff] [blame] | 198 | if (dc_lsize == 0) |
| 199 | r4k_blast_dcache = (void *)cache_noop; |
| 200 | else if (dc_lsize == 16) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 201 | r4k_blast_dcache = blast_dcache16; |
| 202 | else if (dc_lsize == 32) |
| 203 | r4k_blast_dcache = blast_dcache32; |
Kevin Cernekee | 605b7ef | 2009-04-23 17:36:53 -0700 | [diff] [blame] | 204 | else if (dc_lsize == 64) |
| 205 | r4k_blast_dcache = blast_dcache64; |
David Daney | 18a8cd6 | 2014-05-28 23:52:09 +0200 | [diff] [blame] | 206 | else if (dc_lsize == 128) |
| 207 | r4k_blast_dcache = blast_dcache128; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 208 | } |
| 209 | |
| 210 | /* force code alignment (used for TX49XX_ICACHE_INDEX_INV_WAR) */ |
| 211 | #define JUMP_TO_ALIGN(order) \ |
| 212 | __asm__ __volatile__( \ |
| 213 | "b\t1f\n\t" \ |
| 214 | ".align\t" #order "\n\t" \ |
| 215 | "1:\n\t" \ |
| 216 | ) |
| 217 | #define CACHE32_UNROLL32_ALIGN JUMP_TO_ALIGN(10) /* 32 * 32 = 1024 */ |
Ralf Baechle | 7034228 | 2013-01-22 12:59:30 +0100 | [diff] [blame] | 218 | #define CACHE32_UNROLL32_ALIGN2 JUMP_TO_ALIGN(11) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 219 | |
| 220 | static inline void blast_r4600_v1_icache32(void) |
| 221 | { |
| 222 | unsigned long flags; |
| 223 | |
| 224 | local_irq_save(flags); |
| 225 | blast_icache32(); |
| 226 | local_irq_restore(flags); |
| 227 | } |
| 228 | |
| 229 | static inline void tx49_blast_icache32(void) |
| 230 | { |
| 231 | unsigned long start = INDEX_BASE; |
| 232 | unsigned long end = start + current_cpu_data.icache.waysize; |
| 233 | unsigned long ws_inc = 1UL << current_cpu_data.icache.waybit; |
| 234 | unsigned long ws_end = current_cpu_data.icache.ways << |
Ralf Baechle | 7034228 | 2013-01-22 12:59:30 +0100 | [diff] [blame] | 235 | current_cpu_data.icache.waybit; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 236 | unsigned long ws, addr; |
| 237 | |
| 238 | CACHE32_UNROLL32_ALIGN2; |
| 239 | /* I'm in even chunk. blast odd chunks */ |
Ralf Baechle | 42a3b4f | 2005-09-03 15:56:17 -0700 | [diff] [blame] | 240 | for (ws = 0; ws < ws_end; ws += ws_inc) |
| 241 | for (addr = start + 0x400; addr < end; addr += 0x400 * 2) |
Ralf Baechle | 21a151d | 2007-10-11 23:46:15 +0100 | [diff] [blame] | 242 | cache32_unroll32(addr|ws, Index_Invalidate_I); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 243 | CACHE32_UNROLL32_ALIGN; |
| 244 | /* I'm in odd chunk. blast even chunks */ |
Ralf Baechle | 42a3b4f | 2005-09-03 15:56:17 -0700 | [diff] [blame] | 245 | for (ws = 0; ws < ws_end; ws += ws_inc) |
| 246 | for (addr = start; addr < end; addr += 0x400 * 2) |
Ralf Baechle | 21a151d | 2007-10-11 23:46:15 +0100 | [diff] [blame] | 247 | cache32_unroll32(addr|ws, Index_Invalidate_I); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 248 | } |
| 249 | |
| 250 | static inline void blast_icache32_r4600_v1_page_indexed(unsigned long page) |
| 251 | { |
| 252 | unsigned long flags; |
| 253 | |
| 254 | local_irq_save(flags); |
| 255 | blast_icache32_page_indexed(page); |
| 256 | local_irq_restore(flags); |
| 257 | } |
| 258 | |
| 259 | static inline void tx49_blast_icache32_page_indexed(unsigned long page) |
| 260 | { |
Atsushi Nemoto | 67a3f6de | 2006-04-04 17:34:14 +0900 | [diff] [blame] | 261 | unsigned long indexmask = current_cpu_data.icache.waysize - 1; |
| 262 | unsigned long start = INDEX_BASE + (page & indexmask); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 263 | unsigned long end = start + PAGE_SIZE; |
| 264 | unsigned long ws_inc = 1UL << current_cpu_data.icache.waybit; |
| 265 | unsigned long ws_end = current_cpu_data.icache.ways << |
Ralf Baechle | 7034228 | 2013-01-22 12:59:30 +0100 | [diff] [blame] | 266 | current_cpu_data.icache.waybit; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 267 | unsigned long ws, addr; |
| 268 | |
| 269 | CACHE32_UNROLL32_ALIGN2; |
| 270 | /* I'm in even chunk. blast odd chunks */ |
Ralf Baechle | 42a3b4f | 2005-09-03 15:56:17 -0700 | [diff] [blame] | 271 | for (ws = 0; ws < ws_end; ws += ws_inc) |
| 272 | for (addr = start + 0x400; addr < end; addr += 0x400 * 2) |
Ralf Baechle | 21a151d | 2007-10-11 23:46:15 +0100 | [diff] [blame] | 273 | cache32_unroll32(addr|ws, Index_Invalidate_I); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 274 | CACHE32_UNROLL32_ALIGN; |
| 275 | /* I'm in odd chunk. blast even chunks */ |
Ralf Baechle | 42a3b4f | 2005-09-03 15:56:17 -0700 | [diff] [blame] | 276 | for (ws = 0; ws < ws_end; ws += ws_inc) |
| 277 | for (addr = start; addr < end; addr += 0x400 * 2) |
Ralf Baechle | 21a151d | 2007-10-11 23:46:15 +0100 | [diff] [blame] | 278 | cache32_unroll32(addr|ws, Index_Invalidate_I); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 279 | } |
| 280 | |
| 281 | static void (* r4k_blast_icache_page)(unsigned long addr); |
| 282 | |
Paul Gortmaker | 078a55f | 2013-06-18 13:38:59 +0000 | [diff] [blame] | 283 | static void r4k_blast_icache_page_setup(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 284 | { |
| 285 | unsigned long ic_lsize = cpu_icache_line_size(); |
| 286 | |
Chris Dearman | 73f4035 | 2006-06-20 18:06:52 +0100 | [diff] [blame] | 287 | if (ic_lsize == 0) |
| 288 | r4k_blast_icache_page = (void *)cache_noop; |
| 289 | else if (ic_lsize == 16) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 290 | r4k_blast_icache_page = blast_icache16_page; |
Aaro Koskinen | 43a0684 | 2014-01-14 17:56:38 -0800 | [diff] [blame] | 291 | else if (ic_lsize == 32 && current_cpu_type() == CPU_LOONGSON2) |
| 292 | r4k_blast_icache_page = loongson2_blast_icache32_page; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 293 | else if (ic_lsize == 32) |
| 294 | r4k_blast_icache_page = blast_icache32_page; |
| 295 | else if (ic_lsize == 64) |
| 296 | r4k_blast_icache_page = blast_icache64_page; |
David Daney | 18a8cd6 | 2014-05-28 23:52:09 +0200 | [diff] [blame] | 297 | else if (ic_lsize == 128) |
| 298 | r4k_blast_icache_page = blast_icache128_page; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 299 | } |
| 300 | |
Leonid Yegoshin | 4caa906 | 2014-01-15 14:47:28 +0000 | [diff] [blame] | 301 | #ifndef CONFIG_EVA |
| 302 | #define r4k_blast_icache_user_page r4k_blast_icache_page |
| 303 | #else |
| 304 | |
| 305 | static void (*r4k_blast_icache_user_page)(unsigned long addr); |
| 306 | |
Paul Gortmaker | 9a8f4ea | 2015-04-27 18:47:57 -0400 | [diff] [blame] | 307 | static void r4k_blast_icache_user_page_setup(void) |
Leonid Yegoshin | 4caa906 | 2014-01-15 14:47:28 +0000 | [diff] [blame] | 308 | { |
| 309 | unsigned long ic_lsize = cpu_icache_line_size(); |
| 310 | |
| 311 | if (ic_lsize == 0) |
| 312 | r4k_blast_icache_user_page = (void *)cache_noop; |
| 313 | else if (ic_lsize == 16) |
| 314 | r4k_blast_icache_user_page = blast_icache16_user_page; |
| 315 | else if (ic_lsize == 32) |
| 316 | r4k_blast_icache_user_page = blast_icache32_user_page; |
| 317 | else if (ic_lsize == 64) |
| 318 | r4k_blast_icache_user_page = blast_icache64_user_page; |
| 319 | } |
| 320 | |
| 321 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 322 | |
| 323 | static void (* r4k_blast_icache_page_indexed)(unsigned long addr); |
| 324 | |
Paul Gortmaker | 078a55f | 2013-06-18 13:38:59 +0000 | [diff] [blame] | 325 | static void r4k_blast_icache_page_indexed_setup(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 326 | { |
| 327 | unsigned long ic_lsize = cpu_icache_line_size(); |
| 328 | |
Chris Dearman | 73f4035 | 2006-06-20 18:06:52 +0100 | [diff] [blame] | 329 | if (ic_lsize == 0) |
| 330 | r4k_blast_icache_page_indexed = (void *)cache_noop; |
| 331 | else if (ic_lsize == 16) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 332 | r4k_blast_icache_page_indexed = blast_icache16_page_indexed; |
| 333 | else if (ic_lsize == 32) { |
Thiemo Seufer | 02fe2c9 | 2005-09-09 19:45:41 +0000 | [diff] [blame] | 334 | if (R4600_V1_INDEX_ICACHEOP_WAR && cpu_is_r4600_v1_x()) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 335 | r4k_blast_icache_page_indexed = |
| 336 | blast_icache32_r4600_v1_page_indexed; |
Thiemo Seufer | 02fe2c9 | 2005-09-09 19:45:41 +0000 | [diff] [blame] | 337 | else if (TX49XX_ICACHE_INDEX_INV_WAR) |
| 338 | r4k_blast_icache_page_indexed = |
| 339 | tx49_blast_icache32_page_indexed; |
Aaro Koskinen | 43a0684 | 2014-01-14 17:56:38 -0800 | [diff] [blame] | 340 | else if (current_cpu_type() == CPU_LOONGSON2) |
| 341 | r4k_blast_icache_page_indexed = |
| 342 | loongson2_blast_icache32_page_indexed; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 343 | else |
| 344 | r4k_blast_icache_page_indexed = |
| 345 | blast_icache32_page_indexed; |
| 346 | } else if (ic_lsize == 64) |
| 347 | r4k_blast_icache_page_indexed = blast_icache64_page_indexed; |
| 348 | } |
| 349 | |
Sanjay Lal | f2e3656 | 2012-11-21 18:34:10 -0800 | [diff] [blame] | 350 | void (* r4k_blast_icache)(void); |
| 351 | EXPORT_SYMBOL(r4k_blast_icache); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 352 | |
Paul Gortmaker | 078a55f | 2013-06-18 13:38:59 +0000 | [diff] [blame] | 353 | static void r4k_blast_icache_setup(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 354 | { |
| 355 | unsigned long ic_lsize = cpu_icache_line_size(); |
| 356 | |
Chris Dearman | 73f4035 | 2006-06-20 18:06:52 +0100 | [diff] [blame] | 357 | if (ic_lsize == 0) |
| 358 | r4k_blast_icache = (void *)cache_noop; |
| 359 | else if (ic_lsize == 16) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 360 | r4k_blast_icache = blast_icache16; |
| 361 | else if (ic_lsize == 32) { |
| 362 | if (R4600_V1_INDEX_ICACHEOP_WAR && cpu_is_r4600_v1_x()) |
| 363 | r4k_blast_icache = blast_r4600_v1_icache32; |
| 364 | else if (TX49XX_ICACHE_INDEX_INV_WAR) |
| 365 | r4k_blast_icache = tx49_blast_icache32; |
Aaro Koskinen | 43a0684 | 2014-01-14 17:56:38 -0800 | [diff] [blame] | 366 | else if (current_cpu_type() == CPU_LOONGSON2) |
| 367 | r4k_blast_icache = loongson2_blast_icache32; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 368 | else |
| 369 | r4k_blast_icache = blast_icache32; |
| 370 | } else if (ic_lsize == 64) |
| 371 | r4k_blast_icache = blast_icache64; |
David Daney | 18a8cd6 | 2014-05-28 23:52:09 +0200 | [diff] [blame] | 372 | else if (ic_lsize == 128) |
| 373 | r4k_blast_icache = blast_icache128; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 374 | } |
| 375 | |
| 376 | static void (* r4k_blast_scache_page)(unsigned long addr); |
| 377 | |
Paul Gortmaker | 078a55f | 2013-06-18 13:38:59 +0000 | [diff] [blame] | 378 | static void r4k_blast_scache_page_setup(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 379 | { |
| 380 | unsigned long sc_lsize = cpu_scache_line_size(); |
| 381 | |
Ralf Baechle | 4debe4f | 2006-02-27 19:05:55 +0000 | [diff] [blame] | 382 | if (scache_size == 0) |
Chris Dearman | 73f4035 | 2006-06-20 18:06:52 +0100 | [diff] [blame] | 383 | r4k_blast_scache_page = (void *)cache_noop; |
Ralf Baechle | 4debe4f | 2006-02-27 19:05:55 +0000 | [diff] [blame] | 384 | else if (sc_lsize == 16) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 385 | r4k_blast_scache_page = blast_scache16_page; |
| 386 | else if (sc_lsize == 32) |
| 387 | r4k_blast_scache_page = blast_scache32_page; |
| 388 | else if (sc_lsize == 64) |
| 389 | r4k_blast_scache_page = blast_scache64_page; |
| 390 | else if (sc_lsize == 128) |
| 391 | r4k_blast_scache_page = blast_scache128_page; |
| 392 | } |
| 393 | |
| 394 | static void (* r4k_blast_scache_page_indexed)(unsigned long addr); |
| 395 | |
Paul Gortmaker | 078a55f | 2013-06-18 13:38:59 +0000 | [diff] [blame] | 396 | static void r4k_blast_scache_page_indexed_setup(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 397 | { |
| 398 | unsigned long sc_lsize = cpu_scache_line_size(); |
| 399 | |
Ralf Baechle | 4debe4f | 2006-02-27 19:05:55 +0000 | [diff] [blame] | 400 | if (scache_size == 0) |
Chris Dearman | 73f4035 | 2006-06-20 18:06:52 +0100 | [diff] [blame] | 401 | r4k_blast_scache_page_indexed = (void *)cache_noop; |
Ralf Baechle | 4debe4f | 2006-02-27 19:05:55 +0000 | [diff] [blame] | 402 | else if (sc_lsize == 16) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 403 | r4k_blast_scache_page_indexed = blast_scache16_page_indexed; |
| 404 | else if (sc_lsize == 32) |
| 405 | r4k_blast_scache_page_indexed = blast_scache32_page_indexed; |
| 406 | else if (sc_lsize == 64) |
| 407 | r4k_blast_scache_page_indexed = blast_scache64_page_indexed; |
| 408 | else if (sc_lsize == 128) |
| 409 | r4k_blast_scache_page_indexed = blast_scache128_page_indexed; |
| 410 | } |
| 411 | |
| 412 | static void (* r4k_blast_scache)(void); |
| 413 | |
Paul Gortmaker | 078a55f | 2013-06-18 13:38:59 +0000 | [diff] [blame] | 414 | static void r4k_blast_scache_setup(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 415 | { |
| 416 | unsigned long sc_lsize = cpu_scache_line_size(); |
| 417 | |
Ralf Baechle | 4debe4f | 2006-02-27 19:05:55 +0000 | [diff] [blame] | 418 | if (scache_size == 0) |
Chris Dearman | 73f4035 | 2006-06-20 18:06:52 +0100 | [diff] [blame] | 419 | r4k_blast_scache = (void *)cache_noop; |
Ralf Baechle | 4debe4f | 2006-02-27 19:05:55 +0000 | [diff] [blame] | 420 | else if (sc_lsize == 16) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 421 | r4k_blast_scache = blast_scache16; |
| 422 | else if (sc_lsize == 32) |
| 423 | r4k_blast_scache = blast_scache32; |
| 424 | else if (sc_lsize == 64) |
| 425 | r4k_blast_scache = blast_scache64; |
| 426 | else if (sc_lsize == 128) |
| 427 | r4k_blast_scache = blast_scache128; |
| 428 | } |
| 429 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 430 | static inline void local_r4k___flush_cache_all(void * args) |
| 431 | { |
Ralf Baechle | 10cc352 | 2007-10-11 23:46:15 +0100 | [diff] [blame] | 432 | switch (current_cpu_type()) { |
Ralf Baechle | 14bd8c0 | 2013-09-25 18:21:26 +0200 | [diff] [blame] | 433 | case CPU_LOONGSON2: |
Huacai Chen | c579d31 | 2014-03-21 18:44:00 +0800 | [diff] [blame] | 434 | case CPU_LOONGSON3: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 435 | case CPU_R4000SC: |
| 436 | case CPU_R4000MC: |
| 437 | case CPU_R4400SC: |
| 438 | case CPU_R4400MC: |
| 439 | case CPU_R10000: |
| 440 | case CPU_R12000: |
Kumba | 44d921b | 2006-05-16 22:23:59 -0400 | [diff] [blame] | 441 | case CPU_R14000: |
Joshua Kinard | 3057739 | 2015-01-21 07:59:45 -0500 | [diff] [blame] | 442 | case CPU_R16000: |
Ralf Baechle | 14bd8c0 | 2013-09-25 18:21:26 +0200 | [diff] [blame] | 443 | /* |
| 444 | * These caches are inclusive caches, that is, if something |
| 445 | * is not cached in the S-cache, we know it also won't be |
| 446 | * in one of the primary caches. |
| 447 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 448 | r4k_blast_scache(); |
Ralf Baechle | 14bd8c0 | 2013-09-25 18:21:26 +0200 | [diff] [blame] | 449 | break; |
| 450 | |
Florian Fainelli | f675843 | 2016-04-04 10:55:36 -0700 | [diff] [blame] | 451 | case CPU_BMIPS5000: |
| 452 | r4k_blast_scache(); |
| 453 | __sync(); |
| 454 | break; |
| 455 | |
Ralf Baechle | 14bd8c0 | 2013-09-25 18:21:26 +0200 | [diff] [blame] | 456 | default: |
| 457 | r4k_blast_dcache(); |
| 458 | r4k_blast_icache(); |
| 459 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 460 | } |
| 461 | } |
| 462 | |
| 463 | static void r4k___flush_cache_all(void) |
| 464 | { |
Ralf Baechle | 48a26e6 | 2010-10-29 19:08:25 +0100 | [diff] [blame] | 465 | r4k_on_each_cpu(local_r4k___flush_cache_all, NULL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 466 | } |
| 467 | |
Ralf Baechle | a76ab5c | 2007-10-08 16:38:37 +0100 | [diff] [blame] | 468 | static inline int has_valid_asid(const struct mm_struct *mm) |
| 469 | { |
Ralf Baechle | b633648 | 2014-05-23 16:29:44 +0200 | [diff] [blame] | 470 | #ifdef CONFIG_MIPS_MT_SMP |
Ralf Baechle | a76ab5c | 2007-10-08 16:38:37 +0100 | [diff] [blame] | 471 | int i; |
| 472 | |
| 473 | for_each_online_cpu(i) |
| 474 | if (cpu_context(i, mm)) |
| 475 | return 1; |
| 476 | |
| 477 | return 0; |
| 478 | #else |
| 479 | return cpu_context(smp_processor_id(), mm); |
| 480 | #endif |
| 481 | } |
| 482 | |
Ralf Baechle | 9c5a3d7 | 2008-04-05 15:13:23 +0100 | [diff] [blame] | 483 | static void r4k__flush_cache_vmap(void) |
| 484 | { |
| 485 | r4k_blast_dcache(); |
| 486 | } |
| 487 | |
| 488 | static void r4k__flush_cache_vunmap(void) |
| 489 | { |
| 490 | r4k_blast_dcache(); |
| 491 | } |
| 492 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 493 | static inline void local_r4k_flush_cache_range(void * args) |
| 494 | { |
| 495 | struct vm_area_struct *vma = args; |
Ralf Baechle | 2eaa7ec | 2008-02-11 14:51:40 +0000 | [diff] [blame] | 496 | int exec = vma->vm_flags & VM_EXEC; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 497 | |
Ralf Baechle | a76ab5c | 2007-10-08 16:38:37 +0100 | [diff] [blame] | 498 | if (!(has_valid_asid(vma->vm_mm))) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 499 | return; |
| 500 | |
James Hogan | b2a3c5b | 2016-01-22 10:58:25 +0000 | [diff] [blame] | 501 | /* |
| 502 | * If dcache can alias, we must blast it since mapping is changing. |
| 503 | * If executable, we must ensure any dirty lines are written back far |
| 504 | * enough to be visible to icache. |
| 505 | */ |
| 506 | if (cpu_has_dc_aliases || (exec && !cpu_has_ic_fills_f_dc)) |
| 507 | r4k_blast_dcache(); |
| 508 | /* If executable, blast stale lines from icache */ |
Ralf Baechle | 2eaa7ec | 2008-02-11 14:51:40 +0000 | [diff] [blame] | 509 | if (exec) |
| 510 | r4k_blast_icache(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 511 | } |
| 512 | |
| 513 | static void r4k_flush_cache_range(struct vm_area_struct *vma, |
| 514 | unsigned long start, unsigned long end) |
| 515 | { |
Ralf Baechle | 2eaa7ec | 2008-02-11 14:51:40 +0000 | [diff] [blame] | 516 | int exec = vma->vm_flags & VM_EXEC; |
Atsushi Nemoto | 0550d9d | 2006-08-22 21:15:47 +0900 | [diff] [blame] | 517 | |
James Hogan | b2a3c5b | 2016-01-22 10:58:25 +0000 | [diff] [blame] | 518 | if (cpu_has_dc_aliases || exec) |
Ralf Baechle | 48a26e6 | 2010-10-29 19:08:25 +0100 | [diff] [blame] | 519 | r4k_on_each_cpu(local_r4k_flush_cache_range, vma); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 520 | } |
| 521 | |
| 522 | static inline void local_r4k_flush_cache_mm(void * args) |
| 523 | { |
| 524 | struct mm_struct *mm = args; |
| 525 | |
Ralf Baechle | a76ab5c | 2007-10-08 16:38:37 +0100 | [diff] [blame] | 526 | if (!has_valid_asid(mm)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 527 | return; |
| 528 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 529 | /* |
| 530 | * Kludge alert. For obscure reasons R4000SC and R4400SC go nuts if we |
Joshua Kinard | 3057739 | 2015-01-21 07:59:45 -0500 | [diff] [blame] | 531 | * only flush the primary caches but R1x000 behave sane ... |
Ralf Baechle | 617667b | 2006-11-30 01:14:48 +0000 | [diff] [blame] | 532 | * R4000SC and R4400SC indexed S-cache ops also invalidate primary |
| 533 | * caches, so we can bail out early. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 534 | */ |
Ralf Baechle | 10cc352 | 2007-10-11 23:46:15 +0100 | [diff] [blame] | 535 | if (current_cpu_type() == CPU_R4000SC || |
| 536 | current_cpu_type() == CPU_R4000MC || |
| 537 | current_cpu_type() == CPU_R4400SC || |
| 538 | current_cpu_type() == CPU_R4400MC) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 539 | r4k_blast_scache(); |
Ralf Baechle | 617667b | 2006-11-30 01:14:48 +0000 | [diff] [blame] | 540 | return; |
| 541 | } |
| 542 | |
| 543 | r4k_blast_dcache(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 544 | } |
| 545 | |
| 546 | static void r4k_flush_cache_mm(struct mm_struct *mm) |
| 547 | { |
| 548 | if (!cpu_has_dc_aliases) |
| 549 | return; |
| 550 | |
Ralf Baechle | 48a26e6 | 2010-10-29 19:08:25 +0100 | [diff] [blame] | 551 | r4k_on_each_cpu(local_r4k_flush_cache_mm, mm); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 552 | } |
| 553 | |
| 554 | struct flush_cache_page_args { |
| 555 | struct vm_area_struct *vma; |
Ralf Baechle | 6ec2580 | 2005-10-12 00:02:34 +0100 | [diff] [blame] | 556 | unsigned long addr; |
Atsushi Nemoto | de62893 | 2006-03-13 18:23:03 +0900 | [diff] [blame] | 557 | unsigned long pfn; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 558 | }; |
| 559 | |
| 560 | static inline void local_r4k_flush_cache_page(void *args) |
| 561 | { |
| 562 | struct flush_cache_page_args *fcp_args = args; |
| 563 | struct vm_area_struct *vma = fcp_args->vma; |
Ralf Baechle | 6ec2580 | 2005-10-12 00:02:34 +0100 | [diff] [blame] | 564 | unsigned long addr = fcp_args->addr; |
Ralf Baechle | db813fe | 2007-09-27 18:26:43 +0100 | [diff] [blame] | 565 | struct page *page = pfn_to_page(fcp_args->pfn); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 566 | int exec = vma->vm_flags & VM_EXEC; |
| 567 | struct mm_struct *mm = vma->vm_mm; |
Ralf Baechle | c9c5023 | 2008-06-14 22:22:08 +0100 | [diff] [blame] | 568 | int map_coherent = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 569 | pgd_t *pgdp; |
Ralf Baechle | c6e8b58 | 2005-02-10 12:19:59 +0000 | [diff] [blame] | 570 | pud_t *pudp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 571 | pmd_t *pmdp; |
| 572 | pte_t *ptep; |
Ralf Baechle | db813fe | 2007-09-27 18:26:43 +0100 | [diff] [blame] | 573 | void *vaddr; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 574 | |
Ralf Baechle | 79acf83 | 2005-02-10 13:54:37 +0000 | [diff] [blame] | 575 | /* |
| 576 | * If ownes no valid ASID yet, cannot possibly have gotten |
| 577 | * this page into the cache. |
| 578 | */ |
Ralf Baechle | a76ab5c | 2007-10-08 16:38:37 +0100 | [diff] [blame] | 579 | if (!has_valid_asid(mm)) |
Ralf Baechle | 79acf83 | 2005-02-10 13:54:37 +0000 | [diff] [blame] | 580 | return; |
| 581 | |
Ralf Baechle | 6ec2580 | 2005-10-12 00:02:34 +0100 | [diff] [blame] | 582 | addr &= PAGE_MASK; |
| 583 | pgdp = pgd_offset(mm, addr); |
| 584 | pudp = pud_offset(pgdp, addr); |
| 585 | pmdp = pmd_offset(pudp, addr); |
| 586 | ptep = pte_offset(pmdp, addr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 587 | |
| 588 | /* |
| 589 | * If the page isn't marked valid, the page cannot possibly be |
| 590 | * in the cache. |
| 591 | */ |
Ralf Baechle | 526af35 | 2008-01-29 10:14:55 +0000 | [diff] [blame] | 592 | if (!(pte_present(*ptep))) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 593 | return; |
| 594 | |
Ralf Baechle | db813fe | 2007-09-27 18:26:43 +0100 | [diff] [blame] | 595 | if ((mm == current->active_mm) && (pte_val(*ptep) & _PAGE_VALID)) |
| 596 | vaddr = NULL; |
| 597 | else { |
| 598 | /* |
| 599 | * Use kmap_coherent or kmap_atomic to do flushes for |
| 600 | * another ASID than the current one. |
| 601 | */ |
Ralf Baechle | c9c5023 | 2008-06-14 22:22:08 +0100 | [diff] [blame] | 602 | map_coherent = (cpu_has_dc_aliases && |
Kirill A. Shutemov | e1534ae | 2016-01-15 16:53:46 -0800 | [diff] [blame] | 603 | page_mapcount(page) && |
| 604 | !Page_dcache_dirty(page)); |
Ralf Baechle | c9c5023 | 2008-06-14 22:22:08 +0100 | [diff] [blame] | 605 | if (map_coherent) |
Ralf Baechle | db813fe | 2007-09-27 18:26:43 +0100 | [diff] [blame] | 606 | vaddr = kmap_coherent(page, addr); |
| 607 | else |
Cong Wang | 9c02048 | 2011-11-25 23:14:15 +0800 | [diff] [blame] | 608 | vaddr = kmap_atomic(page); |
Ralf Baechle | db813fe | 2007-09-27 18:26:43 +0100 | [diff] [blame] | 609 | addr = (unsigned long)vaddr; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 610 | } |
| 611 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 612 | if (cpu_has_dc_aliases || (exec && !cpu_has_ic_fills_f_dc)) { |
Markos Chandras | 80ca69f | 2014-01-16 13:11:08 +0000 | [diff] [blame] | 613 | vaddr ? r4k_blast_dcache_page(addr) : |
| 614 | r4k_blast_dcache_user_page(addr); |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 615 | if (exec && !cpu_icache_snoops_remote_store) |
| 616 | r4k_blast_scache_page(addr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 617 | } |
| 618 | if (exec) { |
Ralf Baechle | db813fe | 2007-09-27 18:26:43 +0100 | [diff] [blame] | 619 | if (vaddr && cpu_has_vtag_icache && mm == current->active_mm) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 620 | int cpu = smp_processor_id(); |
| 621 | |
Thiemo Seufer | 26a51b2 | 2005-02-19 13:32:02 +0000 | [diff] [blame] | 622 | if (cpu_context(cpu, mm) != 0) |
| 623 | drop_mmu_context(mm, cpu); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 624 | } else |
Markos Chandras | 80ca69f | 2014-01-16 13:11:08 +0000 | [diff] [blame] | 625 | vaddr ? r4k_blast_icache_page(addr) : |
| 626 | r4k_blast_icache_user_page(addr); |
Ralf Baechle | db813fe | 2007-09-27 18:26:43 +0100 | [diff] [blame] | 627 | } |
| 628 | |
| 629 | if (vaddr) { |
Ralf Baechle | c9c5023 | 2008-06-14 22:22:08 +0100 | [diff] [blame] | 630 | if (map_coherent) |
Ralf Baechle | db813fe | 2007-09-27 18:26:43 +0100 | [diff] [blame] | 631 | kunmap_coherent(); |
| 632 | else |
Cong Wang | 9c02048 | 2011-11-25 23:14:15 +0800 | [diff] [blame] | 633 | kunmap_atomic(vaddr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 634 | } |
| 635 | } |
| 636 | |
Ralf Baechle | 6ec2580 | 2005-10-12 00:02:34 +0100 | [diff] [blame] | 637 | static void r4k_flush_cache_page(struct vm_area_struct *vma, |
| 638 | unsigned long addr, unsigned long pfn) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 639 | { |
| 640 | struct flush_cache_page_args args; |
| 641 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 642 | args.vma = vma; |
Ralf Baechle | 6ec2580 | 2005-10-12 00:02:34 +0100 | [diff] [blame] | 643 | args.addr = addr; |
Atsushi Nemoto | de62893 | 2006-03-13 18:23:03 +0900 | [diff] [blame] | 644 | args.pfn = pfn; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 645 | |
Ralf Baechle | 48a26e6 | 2010-10-29 19:08:25 +0100 | [diff] [blame] | 646 | r4k_on_each_cpu(local_r4k_flush_cache_page, &args); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 647 | } |
| 648 | |
| 649 | static inline void local_r4k_flush_data_cache_page(void * addr) |
| 650 | { |
| 651 | r4k_blast_dcache_page((unsigned long) addr); |
| 652 | } |
| 653 | |
| 654 | static void r4k_flush_data_cache_page(unsigned long addr) |
| 655 | { |
Ralf Baechle | a754f70 | 2007-11-03 01:01:37 +0000 | [diff] [blame] | 656 | if (in_atomic()) |
| 657 | local_r4k_flush_data_cache_page((void *)addr); |
| 658 | else |
Ralf Baechle | 48a26e6 | 2010-10-29 19:08:25 +0100 | [diff] [blame] | 659 | r4k_on_each_cpu(local_r4k_flush_data_cache_page, (void *) addr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 660 | } |
| 661 | |
| 662 | struct flush_icache_range_args { |
Atsushi Nemoto | d4264f1 | 2006-01-29 02:27:51 +0900 | [diff] [blame] | 663 | unsigned long start; |
| 664 | unsigned long end; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 665 | }; |
| 666 | |
Thomas Bogendoerfer | e0cee3e | 2008-08-04 20:53:57 +0200 | [diff] [blame] | 667 | static inline void local_r4k_flush_icache_range(unsigned long start, unsigned long end) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 668 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 669 | if (!cpu_has_ic_fills_f_dc) { |
Chris Dearman | 73f4035 | 2006-06-20 18:06:52 +0100 | [diff] [blame] | 670 | if (end - start >= dcache_size) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 671 | r4k_blast_dcache(); |
| 672 | } else { |
Thiemo Seufer | 10a3dab | 2005-09-09 20:26:54 +0000 | [diff] [blame] | 673 | R4600_HIT_CACHEOP_WAR_IMPL; |
Atsushi Nemoto | 41700e7 | 2006-02-10 00:39:06 +0900 | [diff] [blame] | 674 | protected_blast_dcache_range(start, end); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 675 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 676 | } |
| 677 | |
| 678 | if (end - start > icache_size) |
| 679 | r4k_blast_icache(); |
Ralf Baechle | 14bd8c0 | 2013-09-25 18:21:26 +0200 | [diff] [blame] | 680 | else { |
| 681 | switch (boot_cpu_type()) { |
| 682 | case CPU_LOONGSON2: |
Huacai Chen | bad009f | 2014-01-14 17:56:37 -0800 | [diff] [blame] | 683 | protected_loongson2_blast_icache_range(start, end); |
Ralf Baechle | 14bd8c0 | 2013-09-25 18:21:26 +0200 | [diff] [blame] | 684 | break; |
| 685 | |
| 686 | default: |
Huacai Chen | bad009f | 2014-01-14 17:56:37 -0800 | [diff] [blame] | 687 | protected_blast_icache_range(start, end); |
Ralf Baechle | 14bd8c0 | 2013-09-25 18:21:26 +0200 | [diff] [blame] | 688 | break; |
| 689 | } |
| 690 | } |
Leonid Yegoshin | 4676f93 | 2014-01-21 09:48:48 +0000 | [diff] [blame] | 691 | #ifdef CONFIG_EVA |
| 692 | /* |
| 693 | * Due to all possible segment mappings, there might cache aliases |
| 694 | * caused by the bootloader being in non-EVA mode, and the CPU switching |
| 695 | * to EVA during early kernel init. It's best to flush the scache |
| 696 | * to avoid having secondary cores fetching stale data and lead to |
| 697 | * kernel crashes. |
| 698 | */ |
| 699 | bc_wback_inv(start, (end - start)); |
| 700 | __sync(); |
| 701 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 702 | } |
| 703 | |
Thomas Bogendoerfer | e0cee3e | 2008-08-04 20:53:57 +0200 | [diff] [blame] | 704 | static inline void local_r4k_flush_icache_range_ipi(void *args) |
| 705 | { |
| 706 | struct flush_icache_range_args *fir_args = args; |
| 707 | unsigned long start = fir_args->start; |
| 708 | unsigned long end = fir_args->end; |
| 709 | |
| 710 | local_r4k_flush_icache_range(start, end); |
| 711 | } |
| 712 | |
Atsushi Nemoto | d4264f1 | 2006-01-29 02:27:51 +0900 | [diff] [blame] | 713 | static void r4k_flush_icache_range(unsigned long start, unsigned long end) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 714 | { |
| 715 | struct flush_icache_range_args args; |
| 716 | |
| 717 | args.start = start; |
| 718 | args.end = end; |
| 719 | |
Ralf Baechle | 48a26e6 | 2010-10-29 19:08:25 +0100 | [diff] [blame] | 720 | r4k_on_each_cpu(local_r4k_flush_icache_range_ipi, &args); |
Ralf Baechle | cc61c1f | 2005-07-12 18:35:38 +0000 | [diff] [blame] | 721 | instruction_hazard(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 722 | } |
| 723 | |
Manuel Lauss | 8005711 | 2014-02-20 14:59:22 +0100 | [diff] [blame] | 724 | #if defined(CONFIG_DMA_NONCOHERENT) || defined(CONFIG_DMA_MAYBE_COHERENT) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 725 | |
| 726 | static void r4k_dma_cache_wback_inv(unsigned long addr, unsigned long size) |
| 727 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 728 | /* Catch bad driver code */ |
| 729 | BUG_ON(size == 0); |
| 730 | |
Ralf Baechle | ff52205 | 2013-09-17 12:44:31 +0200 | [diff] [blame] | 731 | preempt_disable(); |
Ralf Baechle | fc5d2d2 | 2006-07-06 13:04:01 +0100 | [diff] [blame] | 732 | if (cpu_has_inclusive_pcaches) { |
Atsushi Nemoto | 41700e7 | 2006-02-10 00:39:06 +0900 | [diff] [blame] | 733 | if (size >= scache_size) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 734 | r4k_blast_scache(); |
Atsushi Nemoto | 41700e7 | 2006-02-10 00:39:06 +0900 | [diff] [blame] | 735 | else |
| 736 | blast_scache_range(addr, addr + size); |
Yoichi Yuasa | 5596b0b | 2013-10-02 15:03:03 +0900 | [diff] [blame] | 737 | preempt_enable(); |
Kevin Cernekee | d0023c4 | 2010-09-06 21:03:46 -0700 | [diff] [blame] | 738 | __sync(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 739 | return; |
| 740 | } |
| 741 | |
| 742 | /* |
| 743 | * Either no secondary cache or the available caches don't have the |
| 744 | * subset property so we have to flush the primary caches |
| 745 | * explicitly |
| 746 | */ |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 747 | if (cpu_has_safe_index_cacheops && size >= dcache_size) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 748 | r4k_blast_dcache(); |
| 749 | } else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 750 | R4600_HIT_CACHEOP_WAR_IMPL; |
Atsushi Nemoto | 41700e7 | 2006-02-10 00:39:06 +0900 | [diff] [blame] | 751 | blast_dcache_range(addr, addr + size); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 752 | } |
Ralf Baechle | ff52205 | 2013-09-17 12:44:31 +0200 | [diff] [blame] | 753 | preempt_enable(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 754 | |
| 755 | bc_wback_inv(addr, size); |
Kevin Cernekee | d0023c4 | 2010-09-06 21:03:46 -0700 | [diff] [blame] | 756 | __sync(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 757 | } |
| 758 | |
| 759 | static void r4k_dma_cache_inv(unsigned long addr, unsigned long size) |
| 760 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 761 | /* Catch bad driver code */ |
| 762 | BUG_ON(size == 0); |
| 763 | |
Ralf Baechle | ff52205 | 2013-09-17 12:44:31 +0200 | [diff] [blame] | 764 | preempt_disable(); |
Ralf Baechle | fc5d2d2 | 2006-07-06 13:04:01 +0100 | [diff] [blame] | 765 | if (cpu_has_inclusive_pcaches) { |
Atsushi Nemoto | 41700e7 | 2006-02-10 00:39:06 +0900 | [diff] [blame] | 766 | if (size >= scache_size) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 767 | r4k_blast_scache(); |
Ralf Baechle | a8ca8b6 | 2009-01-11 18:44:49 +0000 | [diff] [blame] | 768 | else { |
Ralf Baechle | a8ca8b6 | 2009-01-11 18:44:49 +0000 | [diff] [blame] | 769 | /* |
| 770 | * There is no clearly documented alignment requirement |
| 771 | * for the cache instruction on MIPS processors and |
| 772 | * some processors, among them the RM5200 and RM7000 |
| 773 | * QED processors will throw an address error for cache |
Ralf Baechle | 7034228 | 2013-01-22 12:59:30 +0100 | [diff] [blame] | 774 | * hit ops with insufficient alignment. Solved by |
Ralf Baechle | a8ca8b6 | 2009-01-11 18:44:49 +0000 | [diff] [blame] | 775 | * aligning the address to cache line size. |
| 776 | */ |
Thomas Bogendoerfer | e9c3357 | 2007-11-26 23:40:01 +0100 | [diff] [blame] | 777 | blast_inv_scache_range(addr, addr + size); |
Ralf Baechle | a8ca8b6 | 2009-01-11 18:44:49 +0000 | [diff] [blame] | 778 | } |
Yoichi Yuasa | 5596b0b | 2013-10-02 15:03:03 +0900 | [diff] [blame] | 779 | preempt_enable(); |
Kevin Cernekee | d0023c4 | 2010-09-06 21:03:46 -0700 | [diff] [blame] | 780 | __sync(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 781 | return; |
| 782 | } |
| 783 | |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 784 | if (cpu_has_safe_index_cacheops && size >= dcache_size) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 785 | r4k_blast_dcache(); |
| 786 | } else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 787 | R4600_HIT_CACHEOP_WAR_IMPL; |
Thomas Bogendoerfer | e9c3357 | 2007-11-26 23:40:01 +0100 | [diff] [blame] | 788 | blast_inv_dcache_range(addr, addr + size); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 789 | } |
Ralf Baechle | ff52205 | 2013-09-17 12:44:31 +0200 | [diff] [blame] | 790 | preempt_enable(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 791 | |
| 792 | bc_inv(addr, size); |
Kevin Cernekee | d0023c4 | 2010-09-06 21:03:46 -0700 | [diff] [blame] | 793 | __sync(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 794 | } |
Manuel Lauss | 8005711 | 2014-02-20 14:59:22 +0100 | [diff] [blame] | 795 | #endif /* CONFIG_DMA_NONCOHERENT || CONFIG_DMA_MAYBE_COHERENT */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 796 | |
| 797 | /* |
| 798 | * While we're protected against bad userland addresses we don't care |
| 799 | * very much about what happens in that case. Usually a segmentation |
| 800 | * fault will dump the process later on anyway ... |
| 801 | */ |
| 802 | static void local_r4k_flush_cache_sigtramp(void * arg) |
| 803 | { |
Thiemo Seufer | 02fe2c9 | 2005-09-09 19:45:41 +0000 | [diff] [blame] | 804 | unsigned long ic_lsize = cpu_icache_line_size(); |
| 805 | unsigned long dc_lsize = cpu_dcache_line_size(); |
| 806 | unsigned long sc_lsize = cpu_scache_line_size(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 807 | unsigned long addr = (unsigned long) arg; |
| 808 | |
| 809 | R4600_HIT_CACHEOP_WAR_IMPL; |
Chris Dearman | 73f4035 | 2006-06-20 18:06:52 +0100 | [diff] [blame] | 810 | if (dc_lsize) |
| 811 | protected_writeback_dcache_line(addr & ~(dc_lsize - 1)); |
Ralf Baechle | 4debe4f | 2006-02-27 19:05:55 +0000 | [diff] [blame] | 812 | if (!cpu_icache_snoops_remote_store && scache_size) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 813 | protected_writeback_scache_line(addr & ~(sc_lsize - 1)); |
Chris Dearman | 73f4035 | 2006-06-20 18:06:52 +0100 | [diff] [blame] | 814 | if (ic_lsize) |
| 815 | protected_flush_icache_line(addr & ~(ic_lsize - 1)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 816 | if (MIPS4K_ICACHE_REFILL_WAR) { |
| 817 | __asm__ __volatile__ ( |
| 818 | ".set push\n\t" |
| 819 | ".set noat\n\t" |
Markos Chandras | 4ee4862 | 2014-12-02 15:30:19 +0000 | [diff] [blame] | 820 | ".set "MIPS_ISA_LEVEL"\n\t" |
Ralf Baechle | 875d43e | 2005-09-03 15:56:16 -0700 | [diff] [blame] | 821 | #ifdef CONFIG_32BIT |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 822 | "la $at,1f\n\t" |
| 823 | #endif |
Ralf Baechle | 875d43e | 2005-09-03 15:56:16 -0700 | [diff] [blame] | 824 | #ifdef CONFIG_64BIT |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 825 | "dla $at,1f\n\t" |
| 826 | #endif |
| 827 | "cache %0,($at)\n\t" |
| 828 | "nop; nop; nop\n" |
| 829 | "1:\n\t" |
| 830 | ".set pop" |
| 831 | : |
| 832 | : "i" (Hit_Invalidate_I)); |
| 833 | } |
| 834 | if (MIPS_CACHE_SYNC_WAR) |
| 835 | __asm__ __volatile__ ("sync"); |
| 836 | } |
| 837 | |
| 838 | static void r4k_flush_cache_sigtramp(unsigned long addr) |
| 839 | { |
Ralf Baechle | 48a26e6 | 2010-10-29 19:08:25 +0100 | [diff] [blame] | 840 | r4k_on_each_cpu(local_r4k_flush_cache_sigtramp, (void *) addr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 841 | } |
| 842 | |
| 843 | static void r4k_flush_icache_all(void) |
| 844 | { |
| 845 | if (cpu_has_vtag_icache) |
| 846 | r4k_blast_icache(); |
| 847 | } |
| 848 | |
Ralf Baechle | d9cdc901 | 2011-06-17 16:20:28 +0100 | [diff] [blame] | 849 | struct flush_kernel_vmap_range_args { |
| 850 | unsigned long vaddr; |
| 851 | int size; |
| 852 | }; |
| 853 | |
| 854 | static inline void local_r4k_flush_kernel_vmap_range(void *args) |
| 855 | { |
| 856 | struct flush_kernel_vmap_range_args *vmra = args; |
| 857 | unsigned long vaddr = vmra->vaddr; |
| 858 | int size = vmra->size; |
| 859 | |
| 860 | /* |
| 861 | * Aliases only affect the primary caches so don't bother with |
| 862 | * S-caches or T-caches. |
| 863 | */ |
| 864 | if (cpu_has_safe_index_cacheops && size >= dcache_size) |
| 865 | r4k_blast_dcache(); |
| 866 | else { |
| 867 | R4600_HIT_CACHEOP_WAR_IMPL; |
| 868 | blast_dcache_range(vaddr, vaddr + size); |
| 869 | } |
| 870 | } |
| 871 | |
| 872 | static void r4k_flush_kernel_vmap_range(unsigned long vaddr, int size) |
| 873 | { |
| 874 | struct flush_kernel_vmap_range_args args; |
| 875 | |
| 876 | args.vaddr = (unsigned long) vaddr; |
| 877 | args.size = size; |
| 878 | |
| 879 | r4k_on_each_cpu(local_r4k_flush_kernel_vmap_range, &args); |
| 880 | } |
| 881 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 882 | static inline void rm7k_erratum31(void) |
| 883 | { |
| 884 | const unsigned long ic_lsize = 32; |
| 885 | unsigned long addr; |
| 886 | |
| 887 | /* RM7000 erratum #31. The icache is screwed at startup. */ |
| 888 | write_c0_taglo(0); |
| 889 | write_c0_taghi(0); |
| 890 | |
| 891 | for (addr = INDEX_BASE; addr <= INDEX_BASE + 4096; addr += ic_lsize) { |
| 892 | __asm__ __volatile__ ( |
Thiemo Seufer | d8748a3 | 2005-09-02 09:56:12 +0000 | [diff] [blame] | 893 | ".set push\n\t" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 894 | ".set noreorder\n\t" |
| 895 | ".set mips3\n\t" |
| 896 | "cache\t%1, 0(%0)\n\t" |
| 897 | "cache\t%1, 0x1000(%0)\n\t" |
| 898 | "cache\t%1, 0x2000(%0)\n\t" |
| 899 | "cache\t%1, 0x3000(%0)\n\t" |
| 900 | "cache\t%2, 0(%0)\n\t" |
| 901 | "cache\t%2, 0x1000(%0)\n\t" |
| 902 | "cache\t%2, 0x2000(%0)\n\t" |
| 903 | "cache\t%2, 0x3000(%0)\n\t" |
| 904 | "cache\t%1, 0(%0)\n\t" |
| 905 | "cache\t%1, 0x1000(%0)\n\t" |
| 906 | "cache\t%1, 0x2000(%0)\n\t" |
| 907 | "cache\t%1, 0x3000(%0)\n\t" |
Thiemo Seufer | d8748a3 | 2005-09-02 09:56:12 +0000 | [diff] [blame] | 908 | ".set pop\n" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 909 | : |
| 910 | : "r" (addr), "i" (Index_Store_Tag_I), "i" (Fill)); |
| 911 | } |
| 912 | } |
| 913 | |
Maciej W. Rozycki | e2e7f29 | 2014-11-16 01:02:29 +0000 | [diff] [blame] | 914 | static inline int alias_74k_erratum(struct cpuinfo_mips *c) |
Steven J. Hill | 006a851 | 2012-06-26 04:11:03 +0000 | [diff] [blame] | 915 | { |
Maciej W. Rozycki | 9213ad7 | 2013-09-18 19:08:15 +0100 | [diff] [blame] | 916 | unsigned int imp = c->processor_id & PRID_IMP_MASK; |
| 917 | unsigned int rev = c->processor_id & PRID_REV_MASK; |
Maciej W. Rozycki | e2e7f29 | 2014-11-16 01:02:29 +0000 | [diff] [blame] | 918 | int present = 0; |
Maciej W. Rozycki | 9213ad7 | 2013-09-18 19:08:15 +0100 | [diff] [blame] | 919 | |
Steven J. Hill | 006a851 | 2012-06-26 04:11:03 +0000 | [diff] [blame] | 920 | /* |
| 921 | * Early versions of the 74K do not update the cache tags on a |
| 922 | * vtag miss/ptag hit which can occur in the case of KSEG0/KUSEG |
Maciej W. Rozycki | e2e7f29 | 2014-11-16 01:02:29 +0000 | [diff] [blame] | 923 | * aliases. In this case it is better to treat the cache as always |
| 924 | * having aliases. Also disable the synonym tag update feature |
| 925 | * where available. In this case no opportunistic tag update will |
| 926 | * happen where a load causes a virtual address miss but a physical |
| 927 | * address hit during a D-cache look-up. |
Steven J. Hill | 006a851 | 2012-06-26 04:11:03 +0000 | [diff] [blame] | 928 | */ |
Maciej W. Rozycki | 9213ad7 | 2013-09-18 19:08:15 +0100 | [diff] [blame] | 929 | switch (imp) { |
| 930 | case PRID_IMP_74K: |
| 931 | if (rev <= PRID_REV_ENCODE_332(2, 4, 0)) |
Maciej W. Rozycki | e2e7f29 | 2014-11-16 01:02:29 +0000 | [diff] [blame] | 932 | present = 1; |
Maciej W. Rozycki | 9213ad7 | 2013-09-18 19:08:15 +0100 | [diff] [blame] | 933 | if (rev == PRID_REV_ENCODE_332(2, 4, 0)) |
| 934 | write_c0_config6(read_c0_config6() | MIPS_CONF6_SYND); |
| 935 | break; |
| 936 | case PRID_IMP_1074K: |
| 937 | if (rev <= PRID_REV_ENCODE_332(1, 1, 0)) { |
Maciej W. Rozycki | e2e7f29 | 2014-11-16 01:02:29 +0000 | [diff] [blame] | 938 | present = 1; |
Maciej W. Rozycki | 9213ad7 | 2013-09-18 19:08:15 +0100 | [diff] [blame] | 939 | write_c0_config6(read_c0_config6() | MIPS_CONF6_SYND); |
| 940 | } |
| 941 | break; |
| 942 | default: |
| 943 | BUG(); |
Steven J. Hill | 006a851 | 2012-06-26 04:11:03 +0000 | [diff] [blame] | 944 | } |
Maciej W. Rozycki | e2e7f29 | 2014-11-16 01:02:29 +0000 | [diff] [blame] | 945 | |
| 946 | return present; |
Steven J. Hill | 006a851 | 2012-06-26 04:11:03 +0000 | [diff] [blame] | 947 | } |
| 948 | |
Kevin Cernekee | d74b017 | 2014-10-20 21:28:00 -0700 | [diff] [blame] | 949 | static void b5k_instruction_hazard(void) |
| 950 | { |
| 951 | __sync(); |
| 952 | __sync(); |
| 953 | __asm__ __volatile__( |
| 954 | " nop; nop; nop; nop; nop; nop; nop; nop\n" |
| 955 | " nop; nop; nop; nop; nop; nop; nop; nop\n" |
| 956 | " nop; nop; nop; nop; nop; nop; nop; nop\n" |
| 957 | " nop; nop; nop; nop; nop; nop; nop; nop\n" |
| 958 | : : : "memory"); |
| 959 | } |
| 960 | |
Paul Gortmaker | 078a55f | 2013-06-18 13:38:59 +0000 | [diff] [blame] | 961 | static char *way_string[] = { NULL, "direct mapped", "2-way", |
Paul Burton | 1e18ac7 | 2015-07-09 10:40:41 +0100 | [diff] [blame] | 962 | "3-way", "4-way", "5-way", "6-way", "7-way", "8-way", |
| 963 | "9-way", "10-way", "11-way", "12-way", |
| 964 | "13-way", "14-way", "15-way", "16-way", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 965 | }; |
| 966 | |
Paul Gortmaker | 078a55f | 2013-06-18 13:38:59 +0000 | [diff] [blame] | 967 | static void probe_pcache(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 968 | { |
| 969 | struct cpuinfo_mips *c = ¤t_cpu_data; |
| 970 | unsigned int config = read_c0_config(); |
| 971 | unsigned int prid = read_c0_prid(); |
Maciej W. Rozycki | e2e7f29 | 2014-11-16 01:02:29 +0000 | [diff] [blame] | 972 | int has_74k_erratum = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 973 | unsigned long config1; |
| 974 | unsigned int lsize; |
| 975 | |
Ralf Baechle | 69f24d1 | 2013-09-17 10:25:47 +0200 | [diff] [blame] | 976 | switch (current_cpu_type()) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 977 | case CPU_R4600: /* QED style two way caches? */ |
| 978 | case CPU_R4700: |
| 979 | case CPU_R5000: |
| 980 | case CPU_NEVADA: |
| 981 | icache_size = 1 << (12 + ((config & CONF_IC) >> 9)); |
| 982 | c->icache.linesz = 16 << ((config & CONF_IB) >> 5); |
| 983 | c->icache.ways = 2; |
Atsushi Nemoto | 3c68da7 | 2006-04-08 01:33:31 +0900 | [diff] [blame] | 984 | c->icache.waybit = __ffs(icache_size/2); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 985 | |
| 986 | dcache_size = 1 << (12 + ((config & CONF_DC) >> 6)); |
| 987 | c->dcache.linesz = 16 << ((config & CONF_DB) >> 4); |
| 988 | c->dcache.ways = 2; |
Atsushi Nemoto | 3c68da7 | 2006-04-08 01:33:31 +0900 | [diff] [blame] | 989 | c->dcache.waybit= __ffs(dcache_size/2); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 990 | |
| 991 | c->options |= MIPS_CPU_CACHE_CDEX_P; |
| 992 | break; |
| 993 | |
| 994 | case CPU_R5432: |
| 995 | case CPU_R5500: |
| 996 | icache_size = 1 << (12 + ((config & CONF_IC) >> 9)); |
| 997 | c->icache.linesz = 16 << ((config & CONF_IB) >> 5); |
| 998 | c->icache.ways = 2; |
| 999 | c->icache.waybit= 0; |
| 1000 | |
| 1001 | dcache_size = 1 << (12 + ((config & CONF_DC) >> 6)); |
| 1002 | c->dcache.linesz = 16 << ((config & CONF_DB) >> 4); |
| 1003 | c->dcache.ways = 2; |
| 1004 | c->dcache.waybit = 0; |
| 1005 | |
Shinya Kuribayashi | 5864810 | 2009-03-18 09:04:01 +0900 | [diff] [blame] | 1006 | c->options |= MIPS_CPU_CACHE_CDEX_P | MIPS_CPU_PREFETCH; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1007 | break; |
| 1008 | |
| 1009 | case CPU_TX49XX: |
| 1010 | icache_size = 1 << (12 + ((config & CONF_IC) >> 9)); |
| 1011 | c->icache.linesz = 16 << ((config & CONF_IB) >> 5); |
| 1012 | c->icache.ways = 4; |
| 1013 | c->icache.waybit= 0; |
| 1014 | |
| 1015 | dcache_size = 1 << (12 + ((config & CONF_DC) >> 6)); |
| 1016 | c->dcache.linesz = 16 << ((config & CONF_DB) >> 4); |
| 1017 | c->dcache.ways = 4; |
| 1018 | c->dcache.waybit = 0; |
| 1019 | |
| 1020 | c->options |= MIPS_CPU_CACHE_CDEX_P; |
Atsushi Nemoto | de862b4 | 2006-03-17 12:59:22 +0900 | [diff] [blame] | 1021 | c->options |= MIPS_CPU_PREFETCH; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1022 | break; |
| 1023 | |
| 1024 | case CPU_R4000PC: |
| 1025 | case CPU_R4000SC: |
| 1026 | case CPU_R4000MC: |
| 1027 | case CPU_R4400PC: |
| 1028 | case CPU_R4400SC: |
| 1029 | case CPU_R4400MC: |
| 1030 | case CPU_R4300: |
| 1031 | icache_size = 1 << (12 + ((config & CONF_IC) >> 9)); |
| 1032 | c->icache.linesz = 16 << ((config & CONF_IB) >> 5); |
| 1033 | c->icache.ways = 1; |
Ralf Baechle | 7034228 | 2013-01-22 12:59:30 +0100 | [diff] [blame] | 1034 | c->icache.waybit = 0; /* doesn't matter */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1035 | |
| 1036 | dcache_size = 1 << (12 + ((config & CONF_DC) >> 6)); |
| 1037 | c->dcache.linesz = 16 << ((config & CONF_DB) >> 4); |
| 1038 | c->dcache.ways = 1; |
| 1039 | c->dcache.waybit = 0; /* does not matter */ |
| 1040 | |
| 1041 | c->options |= MIPS_CPU_CACHE_CDEX_P; |
| 1042 | break; |
| 1043 | |
| 1044 | case CPU_R10000: |
| 1045 | case CPU_R12000: |
Kumba | 44d921b | 2006-05-16 22:23:59 -0400 | [diff] [blame] | 1046 | case CPU_R14000: |
Joshua Kinard | 3057739 | 2015-01-21 07:59:45 -0500 | [diff] [blame] | 1047 | case CPU_R16000: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1048 | icache_size = 1 << (12 + ((config & R10K_CONF_IC) >> 29)); |
| 1049 | c->icache.linesz = 64; |
| 1050 | c->icache.ways = 2; |
| 1051 | c->icache.waybit = 0; |
| 1052 | |
| 1053 | dcache_size = 1 << (12 + ((config & R10K_CONF_DC) >> 26)); |
| 1054 | c->dcache.linesz = 32; |
| 1055 | c->dcache.ways = 2; |
| 1056 | c->dcache.waybit = 0; |
| 1057 | |
| 1058 | c->options |= MIPS_CPU_PREFETCH; |
| 1059 | break; |
| 1060 | |
| 1061 | case CPU_VR4133: |
Yoichi Yuasa | 2874fe5 | 2006-07-08 00:42:12 +0900 | [diff] [blame] | 1062 | write_c0_config(config & ~VR41_CONF_P4K); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1063 | case CPU_VR4131: |
| 1064 | /* Workaround for cache instruction bug of VR4131 */ |
| 1065 | if (c->processor_id == 0x0c80U || c->processor_id == 0x0c81U || |
| 1066 | c->processor_id == 0x0c82U) { |
Yoichi Yuasa | 4e8ab36 | 2006-07-04 22:59:41 +0900 | [diff] [blame] | 1067 | config |= 0x00400000U; |
| 1068 | if (c->processor_id == 0x0c80U) |
| 1069 | config |= VR41_CONF_BP; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1070 | write_c0_config(config); |
Yoichi Yuasa | 1058ecd | 2006-07-08 00:42:01 +0900 | [diff] [blame] | 1071 | } else |
| 1072 | c->options |= MIPS_CPU_CACHE_CDEX_P; |
| 1073 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1074 | icache_size = 1 << (10 + ((config & CONF_IC) >> 9)); |
| 1075 | c->icache.linesz = 16 << ((config & CONF_IB) >> 5); |
| 1076 | c->icache.ways = 2; |
Atsushi Nemoto | 3c68da7 | 2006-04-08 01:33:31 +0900 | [diff] [blame] | 1077 | c->icache.waybit = __ffs(icache_size/2); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1078 | |
| 1079 | dcache_size = 1 << (10 + ((config & CONF_DC) >> 6)); |
| 1080 | c->dcache.linesz = 16 << ((config & CONF_DB) >> 4); |
| 1081 | c->dcache.ways = 2; |
Atsushi Nemoto | 3c68da7 | 2006-04-08 01:33:31 +0900 | [diff] [blame] | 1082 | c->dcache.waybit = __ffs(dcache_size/2); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1083 | break; |
| 1084 | |
| 1085 | case CPU_VR41XX: |
| 1086 | case CPU_VR4111: |
| 1087 | case CPU_VR4121: |
| 1088 | case CPU_VR4122: |
| 1089 | case CPU_VR4181: |
| 1090 | case CPU_VR4181A: |
| 1091 | icache_size = 1 << (10 + ((config & CONF_IC) >> 9)); |
| 1092 | c->icache.linesz = 16 << ((config & CONF_IB) >> 5); |
| 1093 | c->icache.ways = 1; |
Ralf Baechle | 7034228 | 2013-01-22 12:59:30 +0100 | [diff] [blame] | 1094 | c->icache.waybit = 0; /* doesn't matter */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1095 | |
| 1096 | dcache_size = 1 << (10 + ((config & CONF_DC) >> 6)); |
| 1097 | c->dcache.linesz = 16 << ((config & CONF_DB) >> 4); |
| 1098 | c->dcache.ways = 1; |
| 1099 | c->dcache.waybit = 0; /* does not matter */ |
| 1100 | |
| 1101 | c->options |= MIPS_CPU_CACHE_CDEX_P; |
| 1102 | break; |
| 1103 | |
| 1104 | case CPU_RM7000: |
| 1105 | rm7k_erratum31(); |
| 1106 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1107 | icache_size = 1 << (12 + ((config & CONF_IC) >> 9)); |
| 1108 | c->icache.linesz = 16 << ((config & CONF_IB) >> 5); |
| 1109 | c->icache.ways = 4; |
Atsushi Nemoto | 3c68da7 | 2006-04-08 01:33:31 +0900 | [diff] [blame] | 1110 | c->icache.waybit = __ffs(icache_size / c->icache.ways); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1111 | |
| 1112 | dcache_size = 1 << (12 + ((config & CONF_DC) >> 6)); |
| 1113 | c->dcache.linesz = 16 << ((config & CONF_DB) >> 4); |
| 1114 | c->dcache.ways = 4; |
Atsushi Nemoto | 3c68da7 | 2006-04-08 01:33:31 +0900 | [diff] [blame] | 1115 | c->dcache.waybit = __ffs(dcache_size / c->dcache.ways); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1116 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1117 | c->options |= MIPS_CPU_CACHE_CDEX_P; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1118 | c->options |= MIPS_CPU_PREFETCH; |
| 1119 | break; |
| 1120 | |
Fuxin Zhang | 2a21c73 | 2007-06-06 14:52:43 +0800 | [diff] [blame] | 1121 | case CPU_LOONGSON2: |
| 1122 | icache_size = 1 << (12 + ((config & CONF_IC) >> 9)); |
| 1123 | c->icache.linesz = 16 << ((config & CONF_IB) >> 5); |
| 1124 | if (prid & 0x3) |
| 1125 | c->icache.ways = 4; |
| 1126 | else |
| 1127 | c->icache.ways = 2; |
| 1128 | c->icache.waybit = 0; |
| 1129 | |
| 1130 | dcache_size = 1 << (12 + ((config & CONF_DC) >> 6)); |
| 1131 | c->dcache.linesz = 16 << ((config & CONF_DB) >> 4); |
| 1132 | if (prid & 0x3) |
| 1133 | c->dcache.ways = 4; |
| 1134 | else |
| 1135 | c->dcache.ways = 2; |
| 1136 | c->dcache.waybit = 0; |
| 1137 | break; |
| 1138 | |
Huacai Chen | c579d31 | 2014-03-21 18:44:00 +0800 | [diff] [blame] | 1139 | case CPU_LOONGSON3: |
| 1140 | config1 = read_c0_config1(); |
| 1141 | lsize = (config1 >> 19) & 7; |
| 1142 | if (lsize) |
| 1143 | c->icache.linesz = 2 << lsize; |
| 1144 | else |
| 1145 | c->icache.linesz = 0; |
| 1146 | c->icache.sets = 64 << ((config1 >> 22) & 7); |
| 1147 | c->icache.ways = 1 + ((config1 >> 16) & 7); |
| 1148 | icache_size = c->icache.sets * |
| 1149 | c->icache.ways * |
| 1150 | c->icache.linesz; |
| 1151 | c->icache.waybit = 0; |
| 1152 | |
| 1153 | lsize = (config1 >> 10) & 7; |
| 1154 | if (lsize) |
| 1155 | c->dcache.linesz = 2 << lsize; |
| 1156 | else |
| 1157 | c->dcache.linesz = 0; |
| 1158 | c->dcache.sets = 64 << ((config1 >> 13) & 7); |
| 1159 | c->dcache.ways = 1 + ((config1 >> 7) & 7); |
| 1160 | dcache_size = c->dcache.sets * |
| 1161 | c->dcache.ways * |
| 1162 | c->dcache.linesz; |
| 1163 | c->dcache.waybit = 0; |
Huacai Chen | 1e820da3 | 2016-03-03 09:45:13 +0800 | [diff] [blame] | 1164 | if ((prid & PRID_REV_MASK) >= PRID_REV_LOONGSON3A_R2) |
| 1165 | c->options |= MIPS_CPU_PREFETCH; |
Huacai Chen | c579d31 | 2014-03-21 18:44:00 +0800 | [diff] [blame] | 1166 | break; |
| 1167 | |
David Daney | 18a8cd6 | 2014-05-28 23:52:09 +0200 | [diff] [blame] | 1168 | case CPU_CAVIUM_OCTEON3: |
| 1169 | /* For now lie about the number of ways. */ |
| 1170 | c->icache.linesz = 128; |
| 1171 | c->icache.sets = 16; |
| 1172 | c->icache.ways = 8; |
| 1173 | c->icache.flags |= MIPS_CACHE_VTAG; |
| 1174 | icache_size = c->icache.sets * c->icache.ways * c->icache.linesz; |
| 1175 | |
| 1176 | c->dcache.linesz = 128; |
| 1177 | c->dcache.ways = 8; |
| 1178 | c->dcache.sets = 8; |
| 1179 | dcache_size = c->dcache.sets * c->dcache.ways * c->dcache.linesz; |
| 1180 | c->options |= MIPS_CPU_PREFETCH; |
| 1181 | break; |
| 1182 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1183 | default: |
| 1184 | if (!(config & MIPS_CONF_M)) |
| 1185 | panic("Don't know how to probe P-caches on this cpu."); |
| 1186 | |
| 1187 | /* |
| 1188 | * So we seem to be a MIPS32 or MIPS64 CPU |
| 1189 | * So let's probe the I-cache ... |
| 1190 | */ |
| 1191 | config1 = read_c0_config1(); |
| 1192 | |
Markos Chandras | 175cba8 | 2013-09-19 18:18:41 +0100 | [diff] [blame] | 1193 | lsize = (config1 >> 19) & 7; |
| 1194 | |
| 1195 | /* IL == 7 is reserved */ |
| 1196 | if (lsize == 7) |
| 1197 | panic("Invalid icache line size"); |
| 1198 | |
| 1199 | c->icache.linesz = lsize ? 2 << lsize : 0; |
| 1200 | |
Douglas Leung | dc34b05 | 2012-07-19 09:11:13 +0200 | [diff] [blame] | 1201 | c->icache.sets = 32 << (((config1 >> 22) + 1) & 7); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1202 | c->icache.ways = 1 + ((config1 >> 16) & 7); |
| 1203 | |
| 1204 | icache_size = c->icache.sets * |
Ralf Baechle | 7034228 | 2013-01-22 12:59:30 +0100 | [diff] [blame] | 1205 | c->icache.ways * |
| 1206 | c->icache.linesz; |
Atsushi Nemoto | 3c68da7 | 2006-04-08 01:33:31 +0900 | [diff] [blame] | 1207 | c->icache.waybit = __ffs(icache_size/c->icache.ways); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1208 | |
| 1209 | if (config & 0x8) /* VI bit */ |
| 1210 | c->icache.flags |= MIPS_CACHE_VTAG; |
| 1211 | |
| 1212 | /* |
| 1213 | * Now probe the MIPS32 / MIPS64 data cache. |
| 1214 | */ |
| 1215 | c->dcache.flags = 0; |
| 1216 | |
Markos Chandras | 175cba8 | 2013-09-19 18:18:41 +0100 | [diff] [blame] | 1217 | lsize = (config1 >> 10) & 7; |
| 1218 | |
| 1219 | /* DL == 7 is reserved */ |
| 1220 | if (lsize == 7) |
| 1221 | panic("Invalid dcache line size"); |
| 1222 | |
| 1223 | c->dcache.linesz = lsize ? 2 << lsize : 0; |
| 1224 | |
Douglas Leung | dc34b05 | 2012-07-19 09:11:13 +0200 | [diff] [blame] | 1225 | c->dcache.sets = 32 << (((config1 >> 13) + 1) & 7); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1226 | c->dcache.ways = 1 + ((config1 >> 7) & 7); |
| 1227 | |
| 1228 | dcache_size = c->dcache.sets * |
Ralf Baechle | 7034228 | 2013-01-22 12:59:30 +0100 | [diff] [blame] | 1229 | c->dcache.ways * |
| 1230 | c->dcache.linesz; |
Atsushi Nemoto | 3c68da7 | 2006-04-08 01:33:31 +0900 | [diff] [blame] | 1231 | c->dcache.waybit = __ffs(dcache_size/c->dcache.ways); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1232 | |
| 1233 | c->options |= MIPS_CPU_PREFETCH; |
| 1234 | break; |
| 1235 | } |
| 1236 | |
| 1237 | /* |
| 1238 | * Processor configuration sanity check for the R4000SC erratum |
Ralf Baechle | 7034228 | 2013-01-22 12:59:30 +0100 | [diff] [blame] | 1239 | * #5. With page sizes larger than 32kB there is no possibility |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1240 | * to get a VCE exception anymore so we don't care about this |
| 1241 | * misconfiguration. The case is rather theoretical anyway; |
| 1242 | * presumably no vendor is shipping his hardware in the "bad" |
| 1243 | * configuration. |
| 1244 | */ |
Maciej W. Rozycki | 8ff374b | 2013-09-17 16:58:10 +0100 | [diff] [blame] | 1245 | if ((prid & PRID_IMP_MASK) == PRID_IMP_R4000 && |
| 1246 | (prid & PRID_REV_MASK) < PRID_REV_R4400 && |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1247 | !(config & CONF_SC) && c->icache.linesz != 16 && |
| 1248 | PAGE_SIZE <= 0x8000) |
| 1249 | panic("Improper R4000SC processor configuration detected"); |
| 1250 | |
| 1251 | /* compute a couple of other cache variables */ |
| 1252 | c->icache.waysize = icache_size / c->icache.ways; |
| 1253 | c->dcache.waysize = dcache_size / c->dcache.ways; |
| 1254 | |
Chris Dearman | 73f4035 | 2006-06-20 18:06:52 +0100 | [diff] [blame] | 1255 | c->icache.sets = c->icache.linesz ? |
| 1256 | icache_size / (c->icache.linesz * c->icache.ways) : 0; |
| 1257 | c->dcache.sets = c->dcache.linesz ? |
| 1258 | dcache_size / (c->dcache.linesz * c->dcache.ways) : 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1259 | |
| 1260 | /* |
Joshua Kinard | 3057739 | 2015-01-21 07:59:45 -0500 | [diff] [blame] | 1261 | * R1x000 P-caches are odd in a positive way. They're 32kB 2-way |
| 1262 | * virtually indexed so normally would suffer from aliases. So |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1263 | * normally they'd suffer from aliases but magic in the hardware deals |
| 1264 | * with that for us so we don't need to take care ourselves. |
| 1265 | */ |
Ralf Baechle | 69f24d1 | 2013-09-17 10:25:47 +0200 | [diff] [blame] | 1266 | switch (current_cpu_type()) { |
Ralf Baechle | a95970f | 2005-02-07 21:41:32 +0000 | [diff] [blame] | 1267 | case CPU_20KC: |
Ralf Baechle | 505403b | 2005-02-07 21:53:39 +0000 | [diff] [blame] | 1268 | case CPU_25KF: |
Ralf Baechle | 641e97f | 2007-10-11 23:46:05 +0100 | [diff] [blame] | 1269 | case CPU_SB1: |
| 1270 | case CPU_SB1A: |
Jayachandran C | efa0f81 | 2011-05-07 01:36:21 +0530 | [diff] [blame] | 1271 | case CPU_XLR: |
Atsushi Nemoto | de62893 | 2006-03-13 18:23:03 +0900 | [diff] [blame] | 1272 | c->dcache.flags |= MIPS_CACHE_PINDEX; |
Ralf Baechle | 641e97f | 2007-10-11 23:46:05 +0100 | [diff] [blame] | 1273 | break; |
| 1274 | |
Ralf Baechle | d1e344e | 2005-02-04 15:51:26 +0000 | [diff] [blame] | 1275 | case CPU_R10000: |
| 1276 | case CPU_R12000: |
Kumba | 44d921b | 2006-05-16 22:23:59 -0400 | [diff] [blame] | 1277 | case CPU_R14000: |
Joshua Kinard | 3057739 | 2015-01-21 07:59:45 -0500 | [diff] [blame] | 1278 | case CPU_R16000: |
Ralf Baechle | d1e344e | 2005-02-04 15:51:26 +0000 | [diff] [blame] | 1279 | break; |
Ralf Baechle | 641e97f | 2007-10-11 23:46:05 +0100 | [diff] [blame] | 1280 | |
Maciej W. Rozycki | bf4aac0 | 2014-06-28 23:28:08 +0100 | [diff] [blame] | 1281 | case CPU_74K: |
| 1282 | case CPU_1074K: |
Maciej W. Rozycki | e2e7f29 | 2014-11-16 01:02:29 +0000 | [diff] [blame] | 1283 | has_74k_erratum = alias_74k_erratum(c); |
Maciej W. Rozycki | bf4aac0 | 2014-06-28 23:28:08 +0100 | [diff] [blame] | 1284 | /* Fall through. */ |
Steven J. Hill | 113c62d | 2012-07-06 23:56:00 +0200 | [diff] [blame] | 1285 | case CPU_M14KC: |
Steven J. Hill | f8fa481 | 2012-12-07 03:51:35 +0000 | [diff] [blame] | 1286 | case CPU_M14KEC: |
Ralf Baechle | d1e344e | 2005-02-04 15:51:26 +0000 | [diff] [blame] | 1287 | case CPU_24K: |
Nigel Stephens | 98a41de | 2006-04-27 15:50:32 +0100 | [diff] [blame] | 1288 | case CPU_34K: |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 1289 | case CPU_1004K: |
Leonid Yegoshin | 26ab96d | 2013-11-27 10:07:53 +0000 | [diff] [blame] | 1290 | case CPU_INTERAPTIV: |
James Hogan | aced4cb | 2014-01-22 16:19:38 +0000 | [diff] [blame] | 1291 | case CPU_P5600: |
Leonid Yegoshin | 708ac4b | 2013-11-14 16:12:27 +0000 | [diff] [blame] | 1292 | case CPU_PROAPTIV: |
Leonid Yegoshin | f36c472 | 2014-03-04 13:34:43 +0000 | [diff] [blame] | 1293 | case CPU_M5150: |
Leonid Yegoshin | 4695089 | 2014-11-24 12:59:01 +0000 | [diff] [blame] | 1294 | case CPU_QEMU_GENERIC: |
Markos Chandras | 4e88a86 | 2015-07-09 10:40:36 +0100 | [diff] [blame] | 1295 | case CPU_I6400: |
Paul Burton | 1091bfa | 2016-02-03 03:26:38 +0000 | [diff] [blame] | 1296 | case CPU_P6600: |
Paul Burton | 1dbf6a8 | 2016-02-03 16:17:29 +0000 | [diff] [blame] | 1297 | case CPU_M6250: |
Markos Chandras | 02dc6bf | 2014-01-30 17:21:29 +0000 | [diff] [blame] | 1298 | if (!(read_c0_config7() & MIPS_CONF7_IAR) && |
| 1299 | (c->icache.waysize > PAGE_SIZE)) |
| 1300 | c->icache.flags |= MIPS_CACHE_ALIASES; |
Maciej W. Rozycki | e2e7f29 | 2014-11-16 01:02:29 +0000 | [diff] [blame] | 1301 | if (!has_74k_erratum && (read_c0_config7() & MIPS_CONF7_AR)) { |
Markos Chandras | 02dc6bf | 2014-01-30 17:21:29 +0000 | [diff] [blame] | 1302 | /* |
| 1303 | * Effectively physically indexed dcache, |
| 1304 | * thus no virtual aliases. |
| 1305 | */ |
Ralf Baechle | beab375 | 2006-06-19 21:56:25 +0100 | [diff] [blame] | 1306 | c->dcache.flags |= MIPS_CACHE_PINDEX; |
| 1307 | break; |
| 1308 | } |
Ralf Baechle | d1e344e | 2005-02-04 15:51:26 +0000 | [diff] [blame] | 1309 | default: |
Maciej W. Rozycki | e2e7f29 | 2014-11-16 01:02:29 +0000 | [diff] [blame] | 1310 | if (has_74k_erratum || c->dcache.waysize > PAGE_SIZE) |
Ralf Baechle | beab375 | 2006-06-19 21:56:25 +0100 | [diff] [blame] | 1311 | c->dcache.flags |= MIPS_CACHE_ALIASES; |
Ralf Baechle | d1e344e | 2005-02-04 15:51:26 +0000 | [diff] [blame] | 1312 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1313 | |
Ralf Baechle | 69f24d1 | 2013-09-17 10:25:47 +0200 | [diff] [blame] | 1314 | switch (current_cpu_type()) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1315 | case CPU_20KC: |
| 1316 | /* |
| 1317 | * Some older 20Kc chips doesn't have the 'VI' bit in |
| 1318 | * the config register. |
| 1319 | */ |
| 1320 | c->icache.flags |= MIPS_CACHE_VTAG; |
| 1321 | break; |
| 1322 | |
Manuel Lauss | 270717a | 2009-03-25 17:49:28 +0100 | [diff] [blame] | 1323 | case CPU_ALCHEMY: |
James Hogan | 47f2ac5 | 2016-01-22 10:58:26 +0000 | [diff] [blame] | 1324 | case CPU_I6400: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1325 | c->icache.flags |= MIPS_CACHE_IC_F_DC; |
| 1326 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1327 | |
Florian Fainelli | c130d2f | 2016-04-04 10:55:34 -0700 | [diff] [blame] | 1328 | case CPU_BMIPS5000: |
| 1329 | c->icache.flags |= MIPS_CACHE_IC_F_DC; |
Florian Fainelli | 73c4ca0 | 2016-04-04 10:55:35 -0700 | [diff] [blame] | 1330 | /* Cache aliases are handled in hardware; allow HIGHMEM */ |
| 1331 | c->dcache.flags &= ~MIPS_CACHE_ALIASES; |
Florian Fainelli | c130d2f | 2016-04-04 10:55:34 -0700 | [diff] [blame] | 1332 | break; |
| 1333 | |
Ralf Baechle | 14bd8c0 | 2013-09-25 18:21:26 +0200 | [diff] [blame] | 1334 | case CPU_LOONGSON2: |
| 1335 | /* |
| 1336 | * LOONGSON2 has 4 way icache, but when using indexed cache op, |
| 1337 | * one op will act on all 4 ways |
| 1338 | */ |
| 1339 | c->icache.ways = 1; |
| 1340 | } |
Fuxin Zhang | 2a21c73 | 2007-06-06 14:52:43 +0800 | [diff] [blame] | 1341 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1342 | printk("Primary instruction cache %ldkB, %s, %s, linesize %d bytes.\n", |
| 1343 | icache_size >> 10, |
Ralf Baechle | 7fc7316 | 2009-04-01 16:11:53 +0200 | [diff] [blame] | 1344 | c->icache.flags & MIPS_CACHE_VTAG ? "VIVT" : "VIPT", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1345 | way_string[c->icache.ways], c->icache.linesz); |
| 1346 | |
Ralf Baechle | 64bfca5 | 2007-10-15 16:35:45 +0100 | [diff] [blame] | 1347 | printk("Primary data cache %ldkB, %s, %s, %s, linesize %d bytes\n", |
| 1348 | dcache_size >> 10, way_string[c->dcache.ways], |
| 1349 | (c->dcache.flags & MIPS_CACHE_PINDEX) ? "PIPT" : "VIPT", |
| 1350 | (c->dcache.flags & MIPS_CACHE_ALIASES) ? |
| 1351 | "cache aliases" : "no aliases", |
| 1352 | c->dcache.linesz); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1353 | } |
| 1354 | |
Huacai Chen | b2edcfc | 2016-03-03 09:45:09 +0800 | [diff] [blame] | 1355 | static void probe_vcache(void) |
| 1356 | { |
| 1357 | struct cpuinfo_mips *c = ¤t_cpu_data; |
| 1358 | unsigned int config2, lsize; |
| 1359 | |
| 1360 | if (current_cpu_type() != CPU_LOONGSON3) |
| 1361 | return; |
| 1362 | |
| 1363 | config2 = read_c0_config2(); |
| 1364 | if ((lsize = ((config2 >> 20) & 15))) |
| 1365 | c->vcache.linesz = 2 << lsize; |
| 1366 | else |
| 1367 | c->vcache.linesz = lsize; |
| 1368 | |
| 1369 | c->vcache.sets = 64 << ((config2 >> 24) & 15); |
| 1370 | c->vcache.ways = 1 + ((config2 >> 16) & 15); |
| 1371 | |
| 1372 | vcache_size = c->vcache.sets * c->vcache.ways * c->vcache.linesz; |
| 1373 | |
| 1374 | c->vcache.waybit = 0; |
| 1375 | |
| 1376 | pr_info("Unified victim cache %ldkB %s, linesize %d bytes.\n", |
| 1377 | vcache_size >> 10, way_string[c->vcache.ways], c->vcache.linesz); |
| 1378 | } |
| 1379 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1380 | /* |
| 1381 | * If you even _breathe_ on this function, look at the gcc output and make sure |
| 1382 | * it does not pop things on and off the stack for the cache sizing loop that |
| 1383 | * executes in KSEG1 space or else you will crash and burn badly. You have |
| 1384 | * been warned. |
| 1385 | */ |
Paul Gortmaker | 078a55f | 2013-06-18 13:38:59 +0000 | [diff] [blame] | 1386 | static int probe_scache(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1387 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1388 | unsigned long flags, addr, begin, end, pow2; |
| 1389 | unsigned int config = read_c0_config(); |
| 1390 | struct cpuinfo_mips *c = ¤t_cpu_data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1391 | |
| 1392 | if (config & CONF_SC) |
| 1393 | return 0; |
| 1394 | |
Ralf Baechle | e001e52 | 2007-07-28 12:45:47 +0100 | [diff] [blame] | 1395 | begin = (unsigned long) &_stext; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1396 | begin &= ~((4 * 1024 * 1024) - 1); |
| 1397 | end = begin + (4 * 1024 * 1024); |
| 1398 | |
| 1399 | /* |
| 1400 | * This is such a bitch, you'd think they would make it easy to do |
| 1401 | * this. Away you daemons of stupidity! |
| 1402 | */ |
| 1403 | local_irq_save(flags); |
| 1404 | |
| 1405 | /* Fill each size-multiple cache line with a valid tag. */ |
| 1406 | pow2 = (64 * 1024); |
| 1407 | for (addr = begin; addr < end; addr = (begin + pow2)) { |
| 1408 | unsigned long *p = (unsigned long *) addr; |
| 1409 | __asm__ __volatile__("nop" : : "r" (*p)); /* whee... */ |
| 1410 | pow2 <<= 1; |
| 1411 | } |
| 1412 | |
| 1413 | /* Load first line with zero (therefore invalid) tag. */ |
| 1414 | write_c0_taglo(0); |
| 1415 | write_c0_taghi(0); |
| 1416 | __asm__ __volatile__("nop; nop; nop; nop;"); /* avoid the hazard */ |
| 1417 | cache_op(Index_Store_Tag_I, begin); |
| 1418 | cache_op(Index_Store_Tag_D, begin); |
| 1419 | cache_op(Index_Store_Tag_SD, begin); |
| 1420 | |
| 1421 | /* Now search for the wrap around point. */ |
| 1422 | pow2 = (128 * 1024); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1423 | for (addr = begin + (128 * 1024); addr < end; addr = begin + pow2) { |
| 1424 | cache_op(Index_Load_Tag_SD, addr); |
| 1425 | __asm__ __volatile__("nop; nop; nop; nop;"); /* hazard... */ |
| 1426 | if (!read_c0_taglo()) |
| 1427 | break; |
| 1428 | pow2 <<= 1; |
| 1429 | } |
| 1430 | local_irq_restore(flags); |
| 1431 | addr -= begin; |
| 1432 | |
| 1433 | scache_size = addr; |
| 1434 | c->scache.linesz = 16 << ((config & R4K_CONF_SB) >> 22); |
| 1435 | c->scache.ways = 1; |
Joshua Kinard | 755af33 | 2015-06-02 16:55:22 -0400 | [diff] [blame] | 1436 | c->scache.waybit = 0; /* does not matter */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1437 | |
| 1438 | return 1; |
| 1439 | } |
| 1440 | |
Fuxin Zhang | 2a21c73 | 2007-06-06 14:52:43 +0800 | [diff] [blame] | 1441 | static void __init loongson2_sc_init(void) |
| 1442 | { |
| 1443 | struct cpuinfo_mips *c = ¤t_cpu_data; |
| 1444 | |
| 1445 | scache_size = 512*1024; |
| 1446 | c->scache.linesz = 32; |
| 1447 | c->scache.ways = 4; |
| 1448 | c->scache.waybit = 0; |
| 1449 | c->scache.waysize = scache_size / (c->scache.ways); |
| 1450 | c->scache.sets = scache_size / (c->scache.linesz * c->scache.ways); |
| 1451 | pr_info("Unified secondary cache %ldkB %s, linesize %d bytes.\n", |
| 1452 | scache_size >> 10, way_string[c->scache.ways], c->scache.linesz); |
| 1453 | |
| 1454 | c->options |= MIPS_CPU_INCLUSIVE_CACHES; |
| 1455 | } |
Fuxin Zhang | 2a21c73 | 2007-06-06 14:52:43 +0800 | [diff] [blame] | 1456 | |
Huacai Chen | c579d31 | 2014-03-21 18:44:00 +0800 | [diff] [blame] | 1457 | static void __init loongson3_sc_init(void) |
| 1458 | { |
| 1459 | struct cpuinfo_mips *c = ¤t_cpu_data; |
| 1460 | unsigned int config2, lsize; |
| 1461 | |
| 1462 | config2 = read_c0_config2(); |
| 1463 | lsize = (config2 >> 4) & 15; |
| 1464 | if (lsize) |
| 1465 | c->scache.linesz = 2 << lsize; |
| 1466 | else |
| 1467 | c->scache.linesz = 0; |
| 1468 | c->scache.sets = 64 << ((config2 >> 8) & 15); |
| 1469 | c->scache.ways = 1 + (config2 & 15); |
| 1470 | |
| 1471 | scache_size = c->scache.sets * |
| 1472 | c->scache.ways * |
| 1473 | c->scache.linesz; |
| 1474 | /* Loongson-3 has 4 cores, 1MB scache for each. scaches are shared */ |
| 1475 | scache_size *= 4; |
| 1476 | c->scache.waybit = 0; |
| 1477 | pr_info("Unified secondary cache %ldkB %s, linesize %d bytes.\n", |
| 1478 | scache_size >> 10, way_string[c->scache.ways], c->scache.linesz); |
| 1479 | if (scache_size) |
| 1480 | c->options |= MIPS_CPU_INCLUSIVE_CACHES; |
| 1481 | return; |
| 1482 | } |
| 1483 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1484 | extern int r5k_sc_init(void); |
| 1485 | extern int rm7k_sc_init(void); |
Chris Dearman | 9318c51 | 2006-06-20 17:15:20 +0100 | [diff] [blame] | 1486 | extern int mips_sc_init(void); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1487 | |
Paul Gortmaker | 078a55f | 2013-06-18 13:38:59 +0000 | [diff] [blame] | 1488 | static void setup_scache(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1489 | { |
| 1490 | struct cpuinfo_mips *c = ¤t_cpu_data; |
| 1491 | unsigned int config = read_c0_config(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1492 | int sc_present = 0; |
| 1493 | |
| 1494 | /* |
| 1495 | * Do the probing thing on R4000SC and R4400SC processors. Other |
| 1496 | * processors don't have a S-cache that would be relevant to the |
Joe Perches | 603e82e | 2008-02-03 16:54:53 +0200 | [diff] [blame] | 1497 | * Linux memory management. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1498 | */ |
Ralf Baechle | 69f24d1 | 2013-09-17 10:25:47 +0200 | [diff] [blame] | 1499 | switch (current_cpu_type()) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1500 | case CPU_R4000SC: |
| 1501 | case CPU_R4000MC: |
| 1502 | case CPU_R4400SC: |
| 1503 | case CPU_R4400MC: |
Thiemo Seufer | ba5187d | 2005-04-25 16:36:23 +0000 | [diff] [blame] | 1504 | sc_present = run_uncached(probe_scache); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1505 | if (sc_present) |
| 1506 | c->options |= MIPS_CPU_CACHE_CDEX_S; |
| 1507 | break; |
| 1508 | |
| 1509 | case CPU_R10000: |
| 1510 | case CPU_R12000: |
Kumba | 44d921b | 2006-05-16 22:23:59 -0400 | [diff] [blame] | 1511 | case CPU_R14000: |
Joshua Kinard | 3057739 | 2015-01-21 07:59:45 -0500 | [diff] [blame] | 1512 | case CPU_R16000: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1513 | scache_size = 0x80000 << ((config & R10K_CONF_SS) >> 16); |
| 1514 | c->scache.linesz = 64 << ((config >> 13) & 1); |
| 1515 | c->scache.ways = 2; |
| 1516 | c->scache.waybit= 0; |
| 1517 | sc_present = 1; |
| 1518 | break; |
| 1519 | |
| 1520 | case CPU_R5000: |
| 1521 | case CPU_NEVADA: |
| 1522 | #ifdef CONFIG_R5000_CPU_SCACHE |
| 1523 | r5k_sc_init(); |
| 1524 | #endif |
Ralf Baechle | 7034228 | 2013-01-22 12:59:30 +0100 | [diff] [blame] | 1525 | return; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1526 | |
| 1527 | case CPU_RM7000: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1528 | #ifdef CONFIG_RM7000_CPU_SCACHE |
| 1529 | rm7k_sc_init(); |
| 1530 | #endif |
| 1531 | return; |
| 1532 | |
Fuxin Zhang | 2a21c73 | 2007-06-06 14:52:43 +0800 | [diff] [blame] | 1533 | case CPU_LOONGSON2: |
| 1534 | loongson2_sc_init(); |
| 1535 | return; |
Ralf Baechle | 14bd8c0 | 2013-09-25 18:21:26 +0200 | [diff] [blame] | 1536 | |
Huacai Chen | c579d31 | 2014-03-21 18:44:00 +0800 | [diff] [blame] | 1537 | case CPU_LOONGSON3: |
| 1538 | loongson3_sc_init(); |
| 1539 | return; |
| 1540 | |
David Daney | 18a8cd6 | 2014-05-28 23:52:09 +0200 | [diff] [blame] | 1541 | case CPU_CAVIUM_OCTEON3: |
Jayachandran C | a3d4fb2 | 2011-11-16 00:21:20 +0000 | [diff] [blame] | 1542 | case CPU_XLP: |
| 1543 | /* don't need to worry about L2, fully coherent */ |
| 1544 | return; |
Fuxin Zhang | 2a21c73 | 2007-06-06 14:52:43 +0800 | [diff] [blame] | 1545 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1546 | default: |
Deng-Cheng Zhu | adb3789 | 2013-04-01 18:14:28 +0000 | [diff] [blame] | 1547 | if (c->isa_level & (MIPS_CPU_ISA_M32R1 | MIPS_CPU_ISA_M32R2 | |
Markos Chandras | b5ad2c2 | 2015-01-15 10:28:29 +0000 | [diff] [blame] | 1548 | MIPS_CPU_ISA_M32R6 | MIPS_CPU_ISA_M64R1 | |
| 1549 | MIPS_CPU_ISA_M64R2 | MIPS_CPU_ISA_M64R6)) { |
Chris Dearman | 9318c51 | 2006-06-20 17:15:20 +0100 | [diff] [blame] | 1550 | #ifdef CONFIG_MIPS_CPU_SCACHE |
| 1551 | if (mips_sc_init ()) { |
| 1552 | scache_size = c->scache.ways * c->scache.sets * c->scache.linesz; |
| 1553 | printk("MIPS secondary cache %ldkB, %s, linesize %d bytes.\n", |
| 1554 | scache_size >> 10, |
| 1555 | way_string[c->scache.ways], c->scache.linesz); |
| 1556 | } |
| 1557 | #else |
| 1558 | if (!(c->scache.flags & MIPS_CACHE_NOT_PRESENT)) |
| 1559 | panic("Dunno how to handle MIPS32 / MIPS64 second level cache"); |
| 1560 | #endif |
| 1561 | return; |
| 1562 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1563 | sc_present = 0; |
| 1564 | } |
| 1565 | |
| 1566 | if (!sc_present) |
| 1567 | return; |
| 1568 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1569 | /* compute a couple of other cache variables */ |
| 1570 | c->scache.waysize = scache_size / c->scache.ways; |
| 1571 | |
| 1572 | c->scache.sets = scache_size / (c->scache.linesz * c->scache.ways); |
| 1573 | |
| 1574 | printk("Unified secondary cache %ldkB %s, linesize %d bytes.\n", |
| 1575 | scache_size >> 10, way_string[c->scache.ways], c->scache.linesz); |
| 1576 | |
Ralf Baechle | fc5d2d2 | 2006-07-06 13:04:01 +0100 | [diff] [blame] | 1577 | c->options |= MIPS_CPU_INCLUSIVE_CACHES; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1578 | } |
| 1579 | |
Sergei Shtylyov | 9370b35 | 2006-05-26 19:44:54 +0400 | [diff] [blame] | 1580 | void au1x00_fixup_config_od(void) |
| 1581 | { |
| 1582 | /* |
| 1583 | * c0_config.od (bit 19) was write only (and read as 0) |
| 1584 | * on the early revisions of Alchemy SOCs. It disables the bus |
| 1585 | * transaction overlapping and needs to be set to fix various errata. |
| 1586 | */ |
| 1587 | switch (read_c0_prid()) { |
| 1588 | case 0x00030100: /* Au1000 DA */ |
| 1589 | case 0x00030201: /* Au1000 HA */ |
| 1590 | case 0x00030202: /* Au1000 HB */ |
| 1591 | case 0x01030200: /* Au1500 AB */ |
| 1592 | /* |
| 1593 | * Au1100 errata actually keeps silence about this bit, so we set it |
| 1594 | * just in case for those revisions that require it to be set according |
Manuel Lauss | 270717a | 2009-03-25 17:49:28 +0100 | [diff] [blame] | 1595 | * to the (now gone) cpu table. |
Sergei Shtylyov | 9370b35 | 2006-05-26 19:44:54 +0400 | [diff] [blame] | 1596 | */ |
| 1597 | case 0x02030200: /* Au1100 AB */ |
| 1598 | case 0x02030201: /* Au1100 BA */ |
| 1599 | case 0x02030202: /* Au1100 BC */ |
| 1600 | set_c0_config(1 << 19); |
| 1601 | break; |
| 1602 | } |
| 1603 | } |
| 1604 | |
Ralf Baechle | 89052bd | 2008-06-12 17:26:02 +0100 | [diff] [blame] | 1605 | /* CP0 hazard avoidance. */ |
| 1606 | #define NXP_BARRIER() \ |
| 1607 | __asm__ __volatile__( \ |
| 1608 | ".set noreorder\n\t" \ |
| 1609 | "nop; nop; nop; nop; nop; nop;\n\t" \ |
| 1610 | ".set reorder\n\t") |
| 1611 | |
| 1612 | static void nxp_pr4450_fixup_config(void) |
| 1613 | { |
| 1614 | unsigned long config0; |
| 1615 | |
| 1616 | config0 = read_c0_config(); |
| 1617 | |
| 1618 | /* clear all three cache coherency fields */ |
| 1619 | config0 &= ~(0x7 | (7 << 25) | (7 << 28)); |
| 1620 | config0 |= (((_page_cachable_default >> _CACHE_SHIFT) << 0) | |
| 1621 | ((_page_cachable_default >> _CACHE_SHIFT) << 25) | |
| 1622 | ((_page_cachable_default >> _CACHE_SHIFT) << 28)); |
| 1623 | write_c0_config(config0); |
| 1624 | NXP_BARRIER(); |
| 1625 | } |
| 1626 | |
Paul Gortmaker | 078a55f | 2013-06-18 13:38:59 +0000 | [diff] [blame] | 1627 | static int cca = -1; |
Chris Dearman | 3513369 | 2007-09-19 00:58:24 +0100 | [diff] [blame] | 1628 | |
| 1629 | static int __init cca_setup(char *str) |
| 1630 | { |
| 1631 | get_option(&str, &cca); |
| 1632 | |
Shane McDonald | b5b64f2 | 2012-06-14 02:26:40 +0000 | [diff] [blame] | 1633 | return 0; |
Chris Dearman | 3513369 | 2007-09-19 00:58:24 +0100 | [diff] [blame] | 1634 | } |
| 1635 | |
Shane McDonald | b5b64f2 | 2012-06-14 02:26:40 +0000 | [diff] [blame] | 1636 | early_param("cca", cca_setup); |
Chris Dearman | 3513369 | 2007-09-19 00:58:24 +0100 | [diff] [blame] | 1637 | |
Paul Gortmaker | 078a55f | 2013-06-18 13:38:59 +0000 | [diff] [blame] | 1638 | static void coherency_setup(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1639 | { |
Chris Dearman | 3513369 | 2007-09-19 00:58:24 +0100 | [diff] [blame] | 1640 | if (cca < 0 || cca > 7) |
| 1641 | cca = read_c0_config() & CONF_CM_CMASK; |
| 1642 | _page_cachable_default = cca << _CACHE_SHIFT; |
| 1643 | |
| 1644 | pr_debug("Using cache attribute %d\n", cca); |
| 1645 | change_c0_config(CONF_CM_CMASK, cca); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1646 | |
| 1647 | /* |
| 1648 | * c0_status.cu=0 specifies that updates by the sc instruction use |
| 1649 | * the coherency mode specified by the TLB; 1 means cachable |
| 1650 | * coherent update on write will be used. Not all processors have |
| 1651 | * this bit and; some wire it to zero, others like Toshiba had the |
| 1652 | * silly idea of putting something else there ... |
| 1653 | */ |
Ralf Baechle | 10cc352 | 2007-10-11 23:46:15 +0100 | [diff] [blame] | 1654 | switch (current_cpu_type()) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1655 | case CPU_R4000PC: |
| 1656 | case CPU_R4000SC: |
| 1657 | case CPU_R4000MC: |
| 1658 | case CPU_R4400PC: |
| 1659 | case CPU_R4400SC: |
| 1660 | case CPU_R4400MC: |
| 1661 | clear_c0_config(CONF_CU); |
| 1662 | break; |
Sergei Shtylyov | 9370b35 | 2006-05-26 19:44:54 +0400 | [diff] [blame] | 1663 | /* |
Ralf Baechle | df586d5 | 2006-08-01 23:42:30 +0100 | [diff] [blame] | 1664 | * We need to catch the early Alchemy SOCs with |
Manuel Lauss | 270717a | 2009-03-25 17:49:28 +0100 | [diff] [blame] | 1665 | * the write-only co_config.od bit and set it back to one on: |
| 1666 | * Au1000 rev DA, HA, HB; Au1100 AB, BA, BC, Au1500 AB |
Sergei Shtylyov | 9370b35 | 2006-05-26 19:44:54 +0400 | [diff] [blame] | 1667 | */ |
Manuel Lauss | 270717a | 2009-03-25 17:49:28 +0100 | [diff] [blame] | 1668 | case CPU_ALCHEMY: |
Sergei Shtylyov | 9370b35 | 2006-05-26 19:44:54 +0400 | [diff] [blame] | 1669 | au1x00_fixup_config_od(); |
| 1670 | break; |
Ralf Baechle | 89052bd | 2008-06-12 17:26:02 +0100 | [diff] [blame] | 1671 | |
| 1672 | case PRID_IMP_PR4450: |
| 1673 | nxp_pr4450_fixup_config(); |
| 1674 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1675 | } |
| 1676 | } |
| 1677 | |
Paul Gortmaker | 078a55f | 2013-06-18 13:38:59 +0000 | [diff] [blame] | 1678 | static void r4k_cache_error_setup(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1679 | { |
Ralf Baechle | 641e97f | 2007-10-11 23:46:05 +0100 | [diff] [blame] | 1680 | extern char __weak except_vec2_generic; |
| 1681 | extern char __weak except_vec2_sb1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1682 | |
Ralf Baechle | 69f24d1 | 2013-09-17 10:25:47 +0200 | [diff] [blame] | 1683 | switch (current_cpu_type()) { |
Ralf Baechle | 641e97f | 2007-10-11 23:46:05 +0100 | [diff] [blame] | 1684 | case CPU_SB1: |
| 1685 | case CPU_SB1A: |
| 1686 | set_uncached_handler(0x100, &except_vec2_sb1, 0x80); |
| 1687 | break; |
| 1688 | |
| 1689 | default: |
| 1690 | set_uncached_handler(0x100, &except_vec2_generic, 0x80); |
| 1691 | break; |
| 1692 | } |
David Daney | 9cd9669b | 2012-05-15 00:04:49 -0700 | [diff] [blame] | 1693 | } |
| 1694 | |
Paul Gortmaker | 078a55f | 2013-06-18 13:38:59 +0000 | [diff] [blame] | 1695 | void r4k_cache_init(void) |
David Daney | 9cd9669b | 2012-05-15 00:04:49 -0700 | [diff] [blame] | 1696 | { |
| 1697 | extern void build_clear_page(void); |
| 1698 | extern void build_copy_page(void); |
| 1699 | struct cpuinfo_mips *c = ¤t_cpu_data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1700 | |
| 1701 | probe_pcache(); |
Huacai Chen | b2edcfc | 2016-03-03 09:45:09 +0800 | [diff] [blame] | 1702 | probe_vcache(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1703 | setup_scache(); |
| 1704 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1705 | r4k_blast_dcache_page_setup(); |
| 1706 | r4k_blast_dcache_page_indexed_setup(); |
| 1707 | r4k_blast_dcache_setup(); |
| 1708 | r4k_blast_icache_page_setup(); |
| 1709 | r4k_blast_icache_page_indexed_setup(); |
| 1710 | r4k_blast_icache_setup(); |
| 1711 | r4k_blast_scache_page_setup(); |
| 1712 | r4k_blast_scache_page_indexed_setup(); |
| 1713 | r4k_blast_scache_setup(); |
Leonid Yegoshin | 4caa906 | 2014-01-15 14:47:28 +0000 | [diff] [blame] | 1714 | #ifdef CONFIG_EVA |
| 1715 | r4k_blast_dcache_user_page_setup(); |
| 1716 | r4k_blast_icache_user_page_setup(); |
| 1717 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1718 | |
| 1719 | /* |
| 1720 | * Some MIPS32 and MIPS64 processors have physically indexed caches. |
| 1721 | * This code supports virtually indexed processors and will be |
| 1722 | * unnecessarily inefficient on physically indexed processors. |
| 1723 | */ |
Leonid Yegoshin | cb80b2a | 2015-11-19 17:38:21 -0800 | [diff] [blame^] | 1724 | if (c->dcache.linesz && cpu_has_dc_aliases) |
Chris Dearman | 73f4035 | 2006-06-20 18:06:52 +0100 | [diff] [blame] | 1725 | shm_align_mask = max_t( unsigned long, |
| 1726 | c->dcache.sets * c->dcache.linesz - 1, |
| 1727 | PAGE_SIZE - 1); |
| 1728 | else |
| 1729 | shm_align_mask = PAGE_SIZE-1; |
Ralf Baechle | 9c5a3d7 | 2008-04-05 15:13:23 +0100 | [diff] [blame] | 1730 | |
| 1731 | __flush_cache_vmap = r4k__flush_cache_vmap; |
| 1732 | __flush_cache_vunmap = r4k__flush_cache_vunmap; |
| 1733 | |
Ralf Baechle | db813fe | 2007-09-27 18:26:43 +0100 | [diff] [blame] | 1734 | flush_cache_all = cache_noop; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1735 | __flush_cache_all = r4k___flush_cache_all; |
| 1736 | flush_cache_mm = r4k_flush_cache_mm; |
| 1737 | flush_cache_page = r4k_flush_cache_page; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1738 | flush_cache_range = r4k_flush_cache_range; |
| 1739 | |
Ralf Baechle | d9cdc901 | 2011-06-17 16:20:28 +0100 | [diff] [blame] | 1740 | __flush_kernel_vmap_range = r4k_flush_kernel_vmap_range; |
| 1741 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1742 | flush_cache_sigtramp = r4k_flush_cache_sigtramp; |
| 1743 | flush_icache_all = r4k_flush_icache_all; |
Ralf Baechle | 7e3bfc7 | 2006-04-05 20:42:04 +0100 | [diff] [blame] | 1744 | local_flush_data_cache_page = local_r4k_flush_data_cache_page; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1745 | flush_data_cache_page = r4k_flush_data_cache_page; |
| 1746 | flush_icache_range = r4k_flush_icache_range; |
Thomas Bogendoerfer | e0cee3e | 2008-08-04 20:53:57 +0200 | [diff] [blame] | 1747 | local_flush_icache_range = local_r4k_flush_icache_range; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1748 | |
Manuel Lauss | 8005711 | 2014-02-20 14:59:22 +0100 | [diff] [blame] | 1749 | #if defined(CONFIG_DMA_NONCOHERENT) || defined(CONFIG_DMA_MAYBE_COHERENT) |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 1750 | if (coherentio) { |
| 1751 | _dma_cache_wback_inv = (void *)cache_noop; |
| 1752 | _dma_cache_wback = (void *)cache_noop; |
| 1753 | _dma_cache_inv = (void *)cache_noop; |
| 1754 | } else { |
| 1755 | _dma_cache_wback_inv = r4k_dma_cache_wback_inv; |
| 1756 | _dma_cache_wback = r4k_dma_cache_wback_inv; |
| 1757 | _dma_cache_inv = r4k_dma_cache_inv; |
| 1758 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1759 | #endif |
| 1760 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1761 | build_clear_page(); |
| 1762 | build_copy_page(); |
Steven J. Hill | b6d92b4 | 2013-03-25 13:47:29 -0500 | [diff] [blame] | 1763 | |
| 1764 | /* |
| 1765 | * We want to run CMP kernels on core with and without coherent |
| 1766 | * caches. Therefore, do not use CONFIG_MIPS_CMP to decide whether |
| 1767 | * or not to flush caches. |
| 1768 | */ |
Ralf Baechle | 1d40cfc | 2005-07-15 15:23:23 +0000 | [diff] [blame] | 1769 | local_r4k___flush_cache_all(NULL); |
Steven J. Hill | b6d92b4 | 2013-03-25 13:47:29 -0500 | [diff] [blame] | 1770 | |
Ralf Baechle | 1d40cfc | 2005-07-15 15:23:23 +0000 | [diff] [blame] | 1771 | coherency_setup(); |
David Daney | 9cd9669b | 2012-05-15 00:04:49 -0700 | [diff] [blame] | 1772 | board_cache_error_setup = r4k_cache_error_setup; |
Kevin Cernekee | d74b017 | 2014-10-20 21:28:00 -0700 | [diff] [blame] | 1773 | |
| 1774 | /* |
| 1775 | * Per-CPU overrides |
| 1776 | */ |
| 1777 | switch (current_cpu_type()) { |
| 1778 | case CPU_BMIPS4350: |
| 1779 | case CPU_BMIPS4380: |
| 1780 | /* No IPI is needed because all CPUs share the same D$ */ |
| 1781 | flush_data_cache_page = r4k_blast_dcache_page; |
| 1782 | break; |
| 1783 | case CPU_BMIPS5000: |
| 1784 | /* We lose our superpowers if L2 is disabled */ |
| 1785 | if (c->scache.flags & MIPS_CACHE_NOT_PRESENT) |
| 1786 | break; |
| 1787 | |
| 1788 | /* I$ fills from D$ just by emptying the write buffers */ |
| 1789 | flush_cache_page = (void *)b5k_instruction_hazard; |
| 1790 | flush_cache_range = (void *)b5k_instruction_hazard; |
| 1791 | flush_cache_sigtramp = (void *)b5k_instruction_hazard; |
| 1792 | local_flush_data_cache_page = (void *)b5k_instruction_hazard; |
| 1793 | flush_data_cache_page = (void *)b5k_instruction_hazard; |
| 1794 | flush_icache_range = (void *)b5k_instruction_hazard; |
| 1795 | local_flush_icache_range = (void *)b5k_instruction_hazard; |
| 1796 | |
Kevin Cernekee | d74b017 | 2014-10-20 21:28:00 -0700 | [diff] [blame] | 1797 | |
| 1798 | /* Optimization: an L2 flush implicitly flushes the L1 */ |
| 1799 | current_cpu_data.options |= MIPS_CPU_INCLUSIVE_CACHES; |
| 1800 | break; |
Huacai Chen | 37fbe8f | 2016-03-03 09:45:10 +0800 | [diff] [blame] | 1801 | case CPU_LOONGSON3: |
| 1802 | /* Loongson-3 maintains cache coherency by hardware */ |
| 1803 | __flush_cache_all = cache_noop; |
| 1804 | __flush_cache_vmap = cache_noop; |
| 1805 | __flush_cache_vunmap = cache_noop; |
| 1806 | __flush_kernel_vmap_range = (void *)cache_noop; |
| 1807 | flush_cache_mm = (void *)cache_noop; |
| 1808 | flush_cache_page = (void *)cache_noop; |
| 1809 | flush_cache_range = (void *)cache_noop; |
| 1810 | flush_cache_sigtramp = (void *)cache_noop; |
| 1811 | flush_icache_all = (void *)cache_noop; |
| 1812 | flush_data_cache_page = (void *)cache_noop; |
| 1813 | local_flush_data_cache_page = (void *)cache_noop; |
| 1814 | break; |
Kevin Cernekee | d74b017 | 2014-10-20 21:28:00 -0700 | [diff] [blame] | 1815 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1816 | } |
James Hogan | 61d7304 | 2014-03-04 10:23:57 +0000 | [diff] [blame] | 1817 | |
| 1818 | static int r4k_cache_pm_notifier(struct notifier_block *self, unsigned long cmd, |
| 1819 | void *v) |
| 1820 | { |
| 1821 | switch (cmd) { |
| 1822 | case CPU_PM_ENTER_FAILED: |
| 1823 | case CPU_PM_EXIT: |
| 1824 | coherency_setup(); |
| 1825 | break; |
| 1826 | } |
| 1827 | |
| 1828 | return NOTIFY_OK; |
| 1829 | } |
| 1830 | |
| 1831 | static struct notifier_block r4k_cache_pm_notifier_block = { |
| 1832 | .notifier_call = r4k_cache_pm_notifier, |
| 1833 | }; |
| 1834 | |
| 1835 | int __init r4k_cache_init_pm(void) |
| 1836 | { |
| 1837 | return cpu_pm_register_notifier(&r4k_cache_pm_notifier_block); |
| 1838 | } |
| 1839 | arch_initcall(r4k_cache_init_pm); |