blob: 3f11331c27755f835a228cfdc91e5f05cf808042 [file] [log] [blame]
Alexander Beregalov071327e2009-04-03 01:49:22 +00001/*
Linus Torvalds1da177e2005-04-16 15:20:36 -07002 * 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 *
Helge Deller67a5a592006-03-27 19:52:14 +00006 * Copyright (C) 1999-2006 Helge Deller <deller@gmx.de> (07-13-1999)
Linus Torvalds1da177e2005-04-16 15:20:36 -07007 * Copyright (C) 1999 SuSE GmbH Nuernberg
8 * Copyright (C) 2000 Philipp Rumpf (prumpf@tux.org)
9 *
10 * Cache and TLB management
11 *
12 */
13
14#include <linux/init.h>
15#include <linux/kernel.h>
16#include <linux/mm.h>
17#include <linux/module.h>
18#include <linux/seq_file.h>
19#include <linux/pagemap.h>
Alexey Dobriyane8edc6e2007-05-21 01:22:52 +040020#include <linux/sched.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070021#include <asm/pdc.h>
22#include <asm/cache.h>
23#include <asm/cacheflush.h>
24#include <asm/tlbflush.h>
25#include <asm/system.h>
26#include <asm/page.h>
27#include <asm/pgalloc.h>
28#include <asm/processor.h>
Stuart Brady24642122005-10-21 22:44:14 -040029#include <asm/sections.h>
James Bottomleyf3118472010-12-22 10:22:11 -060030#include <asm/shmparam.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070031
Helge Deller8039de12006-01-10 20:35:03 -050032int split_tlb __read_mostly;
33int dcache_stride __read_mostly;
34int icache_stride __read_mostly;
Linus Torvalds1da177e2005-04-16 15:20:36 -070035EXPORT_SYMBOL(dcache_stride);
36
James Bottomleyf3118472010-12-22 10:22:11 -060037void flush_dcache_page_asm(unsigned long phys_addr, unsigned long vaddr);
38EXPORT_SYMBOL(flush_dcache_page_asm);
39void flush_icache_page_asm(unsigned long phys_addr, unsigned long vaddr);
40
Linus Torvalds1da177e2005-04-16 15:20:36 -070041
Linus Torvalds1da177e2005-04-16 15:20:36 -070042/* On some machines (e.g. ones with the Merced bus), there can be
43 * only a single PxTLB broadcast at a time; this must be guaranteed
44 * by software. We put a spinlock around all TLB flushes to
45 * ensure this.
46 */
47DEFINE_SPINLOCK(pa_tlb_lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -070048
Helge Deller8039de12006-01-10 20:35:03 -050049struct pdc_cache_info cache_info __read_mostly;
Linus Torvalds1da177e2005-04-16 15:20:36 -070050#ifndef CONFIG_PA20
Helge Deller8039de12006-01-10 20:35:03 -050051static struct pdc_btlb_info btlb_info __read_mostly;
Linus Torvalds1da177e2005-04-16 15:20:36 -070052#endif
53
54#ifdef CONFIG_SMP
55void
56flush_data_cache(void)
57{
Jens Axboe15c8b6c2008-05-09 09:39:44 +020058 on_each_cpu(flush_data_cache_local, NULL, 1);
Linus Torvalds1da177e2005-04-16 15:20:36 -070059}
60void
61flush_instruction_cache(void)
62{
Jens Axboe15c8b6c2008-05-09 09:39:44 +020063 on_each_cpu(flush_instruction_cache_local, NULL, 1);
Linus Torvalds1da177e2005-04-16 15:20:36 -070064}
65#endif
66
67void
68flush_cache_all_local(void)
69{
Matthew Wilcox1b2425e2006-01-10 20:47:49 -050070 flush_instruction_cache_local(NULL);
71 flush_data_cache_local(NULL);
Linus Torvalds1da177e2005-04-16 15:20:36 -070072}
73EXPORT_SYMBOL(flush_cache_all_local);
74
Linus Torvalds1da177e2005-04-16 15:20:36 -070075void
Russell King4b3073e2009-12-18 16:40:18 +000076update_mmu_cache(struct vm_area_struct *vma, unsigned long address, pte_t *ptep)
Linus Torvalds1da177e2005-04-16 15:20:36 -070077{
Russell King4b3073e2009-12-18 16:40:18 +000078 struct page *page = pte_page(*ptep);
Linus Torvalds1da177e2005-04-16 15:20:36 -070079
80 if (pfn_valid(page_to_pfn(page)) && page_mapping(page) &&
81 test_bit(PG_dcache_dirty, &page->flags)) {
82
James Bottomleyba575832006-03-22 09:42:04 -070083 flush_kernel_dcache_page(page);
Linus Torvalds1da177e2005-04-16 15:20:36 -070084 clear_bit(PG_dcache_dirty, &page->flags);
James Bottomley20f4d3c2006-08-23 09:00:04 -070085 } else if (parisc_requires_coherency())
86 flush_kernel_dcache_page(page);
Linus Torvalds1da177e2005-04-16 15:20:36 -070087}
88
89void
90show_cache_info(struct seq_file *m)
91{
Kyle McMartine5a2e7f2006-06-14 20:26:25 +000092 char buf[32];
93
Linus Torvalds1da177e2005-04-16 15:20:36 -070094 seq_printf(m, "I-cache\t\t: %ld KB\n",
95 cache_info.ic_size/1024 );
Helge Deller2f75c122007-01-23 21:24:20 +010096 if (cache_info.dc_loop != 1)
Kyle McMartine5a2e7f2006-06-14 20:26:25 +000097 snprintf(buf, 32, "%lu-way associative", cache_info.dc_loop);
98 seq_printf(m, "D-cache\t\t: %ld KB (%s%s, %s)\n",
Linus Torvalds1da177e2005-04-16 15:20:36 -070099 cache_info.dc_size/1024,
100 (cache_info.dc_conf.cc_wt ? "WT":"WB"),
101 (cache_info.dc_conf.cc_sh ? ", shared I/D":""),
Kyle McMartine5a2e7f2006-06-14 20:26:25 +0000102 ((cache_info.dc_loop == 1) ? "direct mapped" : buf));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700103 seq_printf(m, "ITLB entries\t: %ld\n" "DTLB entries\t: %ld%s\n",
104 cache_info.it_size,
105 cache_info.dt_size,
106 cache_info.dt_conf.tc_sh ? " - shared with ITLB":""
107 );
108
109#ifndef CONFIG_PA20
110 /* BTLB - Block TLB */
111 if (btlb_info.max_size==0) {
112 seq_printf(m, "BTLB\t\t: not supported\n" );
113 } else {
114 seq_printf(m,
115 "BTLB fixed\t: max. %d pages, pagesize=%d (%dMB)\n"
116 "BTLB fix-entr.\t: %d instruction, %d data (%d combined)\n"
117 "BTLB var-entr.\t: %d instruction, %d data (%d combined)\n",
118 btlb_info.max_size, (int)4096,
119 btlb_info.max_size>>8,
120 btlb_info.fixed_range_info.num_i,
121 btlb_info.fixed_range_info.num_d,
122 btlb_info.fixed_range_info.num_comb,
123 btlb_info.variable_range_info.num_i,
124 btlb_info.variable_range_info.num_d,
125 btlb_info.variable_range_info.num_comb
126 );
127 }
128#endif
129}
130
131void __init
132parisc_cache_init(void)
133{
134 if (pdc_cache_info(&cache_info) < 0)
135 panic("parisc_cache_init: pdc_cache_info failed");
136
137#if 0
138 printk("ic_size %lx dc_size %lx it_size %lx\n",
139 cache_info.ic_size,
140 cache_info.dc_size,
141 cache_info.it_size);
142
143 printk("DC base 0x%lx stride 0x%lx count 0x%lx loop 0x%lx\n",
144 cache_info.dc_base,
145 cache_info.dc_stride,
146 cache_info.dc_count,
147 cache_info.dc_loop);
148
149 printk("dc_conf = 0x%lx alias %d blk %d line %d shift %d\n",
150 *(unsigned long *) (&cache_info.dc_conf),
151 cache_info.dc_conf.cc_alias,
152 cache_info.dc_conf.cc_block,
153 cache_info.dc_conf.cc_line,
154 cache_info.dc_conf.cc_shift);
Kyle McMartine5a2e7f2006-06-14 20:26:25 +0000155 printk(" wt %d sh %d cst %d hv %d\n",
Linus Torvalds1da177e2005-04-16 15:20:36 -0700156 cache_info.dc_conf.cc_wt,
157 cache_info.dc_conf.cc_sh,
158 cache_info.dc_conf.cc_cst,
Kyle McMartine5a2e7f2006-06-14 20:26:25 +0000159 cache_info.dc_conf.cc_hv);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700160
161 printk("IC base 0x%lx stride 0x%lx count 0x%lx loop 0x%lx\n",
162 cache_info.ic_base,
163 cache_info.ic_stride,
164 cache_info.ic_count,
165 cache_info.ic_loop);
166
167 printk("ic_conf = 0x%lx alias %d blk %d line %d shift %d\n",
168 *(unsigned long *) (&cache_info.ic_conf),
169 cache_info.ic_conf.cc_alias,
170 cache_info.ic_conf.cc_block,
171 cache_info.ic_conf.cc_line,
172 cache_info.ic_conf.cc_shift);
Kyle McMartine5a2e7f2006-06-14 20:26:25 +0000173 printk(" wt %d sh %d cst %d hv %d\n",
Linus Torvalds1da177e2005-04-16 15:20:36 -0700174 cache_info.ic_conf.cc_wt,
175 cache_info.ic_conf.cc_sh,
176 cache_info.ic_conf.cc_cst,
Kyle McMartine5a2e7f2006-06-14 20:26:25 +0000177 cache_info.ic_conf.cc_hv);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700178
Frans Popa3bee032010-02-06 17:47:14 +0000179 printk("D-TLB conf: sh %d page %d cst %d aid %d pad1 %d\n",
Linus Torvalds1da177e2005-04-16 15:20:36 -0700180 cache_info.dt_conf.tc_sh,
181 cache_info.dt_conf.tc_page,
182 cache_info.dt_conf.tc_cst,
183 cache_info.dt_conf.tc_aid,
184 cache_info.dt_conf.tc_pad1);
185
Frans Popa3bee032010-02-06 17:47:14 +0000186 printk("I-TLB conf: sh %d page %d cst %d aid %d pad1 %d\n",
Linus Torvalds1da177e2005-04-16 15:20:36 -0700187 cache_info.it_conf.tc_sh,
188 cache_info.it_conf.tc_page,
189 cache_info.it_conf.tc_cst,
190 cache_info.it_conf.tc_aid,
191 cache_info.it_conf.tc_pad1);
192#endif
193
194 split_tlb = 0;
195 if (cache_info.dt_conf.tc_sh == 0 || cache_info.dt_conf.tc_sh == 2) {
196 if (cache_info.dt_conf.tc_sh == 2)
197 printk(KERN_WARNING "Unexpected TLB configuration. "
198 "Will flush I/D separately (could be optimized).\n");
199
200 split_tlb = 1;
201 }
202
203 /* "New and Improved" version from Jim Hull
204 * (1 << (cc_block-1)) * (cc_line << (4 + cnf.cc_shift))
Stuart Brady24642122005-10-21 22:44:14 -0400205 * The following CAFL_STRIDE is an optimized version, see
206 * http://lists.parisc-linux.org/pipermail/parisc-linux/2004-June/023625.html
207 * http://lists.parisc-linux.org/pipermail/parisc-linux/2004-June/023671.html
Linus Torvalds1da177e2005-04-16 15:20:36 -0700208 */
209#define CAFL_STRIDE(cnf) (cnf.cc_line << (3 + cnf.cc_block + cnf.cc_shift))
210 dcache_stride = CAFL_STRIDE(cache_info.dc_conf);
211 icache_stride = CAFL_STRIDE(cache_info.ic_conf);
212#undef CAFL_STRIDE
213
214#ifndef CONFIG_PA20
215 if (pdc_btlb_info(&btlb_info) < 0) {
216 memset(&btlb_info, 0, sizeof btlb_info);
217 }
218#endif
219
220 if ((boot_cpu_data.pdc.capabilities & PDC_MODEL_NVA_MASK) ==
221 PDC_MODEL_NVA_UNSUPPORTED) {
222 printk(KERN_WARNING "parisc_cache_init: Only equivalent aliasing supported!\n");
223#if 0
224 panic("SMP kernel required to avoid non-equivalent aliasing");
225#endif
226 }
227}
228
229void disable_sr_hashing(void)
230{
Kyle McMartina9d2d382006-06-16 18:20:00 -0400231 int srhash_type, retval;
232 unsigned long space_bits;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700233
234 switch (boot_cpu_data.cpu_type) {
235 case pcx: /* We shouldn't get this far. setup.c should prevent it. */
236 BUG();
237 return;
238
239 case pcxs:
240 case pcxt:
241 case pcxt_:
242 srhash_type = SRHASH_PCXST;
243 break;
244
245 case pcxl:
246 srhash_type = SRHASH_PCXL;
247 break;
248
249 case pcxl2: /* pcxl2 doesn't support space register hashing */
250 return;
251
252 default: /* Currently all PA2.0 machines use the same ins. sequence */
253 srhash_type = SRHASH_PA20;
254 break;
255 }
256
257 disable_sr_hashing_asm(srhash_type);
Kyle McMartina9d2d382006-06-16 18:20:00 -0400258
259 retval = pdc_spaceid_bits(&space_bits);
260 /* If this procedure isn't implemented, don't panic. */
261 if (retval < 0 && retval != PDC_BAD_OPTION)
262 panic("pdc_spaceid_bits call failed.\n");
263 if (space_bits != 0)
264 panic("SpaceID hashing is still on!\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700265}
266
Randolph Chungd6ce8622006-12-12 05:51:54 -0800267static inline void
James Bottomleyf3118472010-12-22 10:22:11 -0600268__flush_cache_page(struct vm_area_struct *vma, unsigned long vmaddr,
269 unsigned long physaddr)
Randolph Chungd6ce8622006-12-12 05:51:54 -0800270{
James Bottomleyf3118472010-12-22 10:22:11 -0600271 flush_dcache_page_asm(physaddr, vmaddr);
272 if (vma->vm_flags & VM_EXEC)
273 flush_icache_page_asm(physaddr, vmaddr);
Randolph Chungd6ce8622006-12-12 05:51:54 -0800274}
275
Linus Torvalds1da177e2005-04-16 15:20:36 -0700276void flush_dcache_page(struct page *page)
277{
278 struct address_space *mapping = page_mapping(page);
279 struct vm_area_struct *mpnt;
280 struct prio_tree_iter iter;
281 unsigned long offset;
James Bottomleyf3118472010-12-22 10:22:11 -0600282 unsigned long addr, old_addr = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700283 pgoff_t pgoff;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700284
285 if (mapping && !mapping_mapped(mapping)) {
286 set_bit(PG_dcache_dirty, &page->flags);
287 return;
288 }
289
James Bottomleyba575832006-03-22 09:42:04 -0700290 flush_kernel_dcache_page(page);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700291
292 if (!mapping)
293 return;
294
295 pgoff = page->index << (PAGE_CACHE_SHIFT - PAGE_SHIFT);
296
297 /* We have carefully arranged in arch_get_unmapped_area() that
298 * *any* mappings of a file are always congruently mapped (whether
299 * declared as MAP_PRIVATE or MAP_SHARED), so we only need
300 * to flush one address here for them all to become coherent */
301
302 flush_dcache_mmap_lock(mapping);
303 vma_prio_tree_foreach(mpnt, &iter, &mapping->i_mmap, pgoff, pgoff) {
304 offset = (pgoff - mpnt->vm_pgoff) << PAGE_SHIFT;
305 addr = mpnt->vm_start + offset;
306
James Bottomleyf3118472010-12-22 10:22:11 -0600307 if (old_addr == 0 || (old_addr & (SHMLBA - 1)) != (addr & (SHMLBA - 1))) {
308 __flush_cache_page(mpnt, addr, page_to_phys(page));
309 if (old_addr)
310 printk(KERN_ERR "INEQUIVALENT ALIASES 0x%lx and 0x%lx in file %s\n", old_addr, addr, mpnt->vm_file ? mpnt->vm_file->f_path.dentry->d_name.name : "(null)");
311 old_addr = addr;
Hugh Dickins92dc6fc2005-10-29 18:16:36 -0700312 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700313 }
314 flush_dcache_mmap_unlock(mapping);
315}
316EXPORT_SYMBOL(flush_dcache_page);
317
318/* Defined in arch/parisc/kernel/pacache.S */
319EXPORT_SYMBOL(flush_kernel_dcache_range_asm);
James Bottomleyba575832006-03-22 09:42:04 -0700320EXPORT_SYMBOL(flush_kernel_dcache_page_asm);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700321EXPORT_SYMBOL(flush_data_cache_local);
322EXPORT_SYMBOL(flush_kernel_icache_range_asm);
323
324void clear_user_page_asm(void *page, unsigned long vaddr)
325{
Helge Dellere82a3b72009-06-16 20:51:48 +0000326 unsigned long flags;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700327 /* This function is implemented in assembly in pacache.S */
328 extern void __clear_user_page_asm(void *page, unsigned long vaddr);
329
Helge Dellere82a3b72009-06-16 20:51:48 +0000330 purge_tlb_start(flags);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700331 __clear_user_page_asm(page, vaddr);
Helge Dellere82a3b72009-06-16 20:51:48 +0000332 purge_tlb_end(flags);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700333}
334
335#define FLUSH_THRESHOLD 0x80000 /* 0.5MB */
Helge Deller8039de12006-01-10 20:35:03 -0500336int parisc_cache_flush_threshold __read_mostly = FLUSH_THRESHOLD;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700337
Randolph Chungd6ce8622006-12-12 05:51:54 -0800338void __init parisc_setup_cache_timing(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700339{
340 unsigned long rangetime, alltime;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700341 unsigned long size;
342
343 alltime = mfctl(16);
344 flush_data_cache();
345 alltime = mfctl(16) - alltime;
346
Stuart Brady24642122005-10-21 22:44:14 -0400347 size = (unsigned long)(_end - _text);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700348 rangetime = mfctl(16);
Stuart Brady24642122005-10-21 22:44:14 -0400349 flush_kernel_dcache_range((unsigned long)_text, size);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700350 rangetime = mfctl(16) - rangetime;
351
352 printk(KERN_DEBUG "Whole cache flush %lu cycles, flushing %lu bytes %lu cycles\n",
353 alltime, size, rangetime);
354
355 /* Racy, but if we see an intermediate value, it's ok too... */
356 parisc_cache_flush_threshold = size * alltime / rangetime;
357
358 parisc_cache_flush_threshold = (parisc_cache_flush_threshold + L1_CACHE_BYTES - 1) &~ (L1_CACHE_BYTES - 1);
359 if (!parisc_cache_flush_threshold)
360 parisc_cache_flush_threshold = FLUSH_THRESHOLD;
361
Randolph Chungd6ce8622006-12-12 05:51:54 -0800362 if (parisc_cache_flush_threshold > cache_info.dc_size)
363 parisc_cache_flush_threshold = cache_info.dc_size;
364
Helge Deller67a5a592006-03-27 19:52:14 +0000365 printk(KERN_INFO "Setting cache flush threshold to %x (%d CPUs online)\n", parisc_cache_flush_threshold, num_online_cpus());
Linus Torvalds1da177e2005-04-16 15:20:36 -0700366}
James Bottomley20f4d3c2006-08-23 09:00:04 -0700367
368extern void purge_kernel_dcache_page(unsigned long);
369extern void clear_user_page_asm(void *page, unsigned long vaddr);
370
Matthew Wilcox8d0b7d12006-09-20 21:44:09 -0600371void clear_user_page(void *page, unsigned long vaddr, struct page *pg)
James Bottomley20f4d3c2006-08-23 09:00:04 -0700372{
Helge Dellere82a3b72009-06-16 20:51:48 +0000373 unsigned long flags;
374
James Bottomley20f4d3c2006-08-23 09:00:04 -0700375 purge_kernel_dcache_page((unsigned long)page);
Helge Dellere82a3b72009-06-16 20:51:48 +0000376 purge_tlb_start(flags);
James Bottomley20f4d3c2006-08-23 09:00:04 -0700377 pdtlb_kernel(page);
Helge Dellere82a3b72009-06-16 20:51:48 +0000378 purge_tlb_end(flags);
James Bottomley20f4d3c2006-08-23 09:00:04 -0700379 clear_user_page_asm(page, vaddr);
380}
Matthew Wilcox8d0b7d12006-09-20 21:44:09 -0600381EXPORT_SYMBOL(clear_user_page);
James Bottomley20f4d3c2006-08-23 09:00:04 -0700382
383void flush_kernel_dcache_page_addr(void *addr)
384{
Helge Dellere82a3b72009-06-16 20:51:48 +0000385 unsigned long flags;
386
James Bottomley20f4d3c2006-08-23 09:00:04 -0700387 flush_kernel_dcache_page_asm(addr);
Helge Dellere82a3b72009-06-16 20:51:48 +0000388 purge_tlb_start(flags);
James Bottomley20f4d3c2006-08-23 09:00:04 -0700389 pdtlb_kernel(addr);
Helge Dellere82a3b72009-06-16 20:51:48 +0000390 purge_tlb_end(flags);
James Bottomley20f4d3c2006-08-23 09:00:04 -0700391}
392EXPORT_SYMBOL(flush_kernel_dcache_page_addr);
393
394void copy_user_page(void *vto, void *vfrom, unsigned long vaddr,
395 struct page *pg)
396{
397 /* no coherency needed (all in kmap/kunmap) */
398 copy_user_page_asm(vto, vfrom);
399 if (!parisc_requires_coherency())
400 flush_kernel_dcache_page_asm(vto);
401}
402EXPORT_SYMBOL(copy_user_page);
403
404#ifdef CONFIG_PA8X00
405
406void kunmap_parisc(void *addr)
407{
408 if (parisc_requires_coherency())
409 flush_kernel_dcache_page_addr(addr);
410}
411EXPORT_SYMBOL(kunmap_parisc);
412#endif
Randolph Chungd6ce8622006-12-12 05:51:54 -0800413
414void __flush_tlb_range(unsigned long sid, unsigned long start,
415 unsigned long end)
416{
417 unsigned long npages;
418
419 npages = ((end - (start & PAGE_MASK)) + (PAGE_SIZE - 1)) >> PAGE_SHIFT;
420 if (npages >= 512) /* 2MB of space: arbitrary, should be tuned */
421 flush_tlb_all();
422 else {
Helge Dellere82a3b72009-06-16 20:51:48 +0000423 unsigned long flags;
424
Randolph Chungd6ce8622006-12-12 05:51:54 -0800425 mtsp(sid, 1);
Helge Dellere82a3b72009-06-16 20:51:48 +0000426 purge_tlb_start(flags);
Randolph Chungd6ce8622006-12-12 05:51:54 -0800427 if (split_tlb) {
428 while (npages--) {
429 pdtlb(start);
430 pitlb(start);
431 start += PAGE_SIZE;
432 }
433 } else {
434 while (npages--) {
435 pdtlb(start);
436 start += PAGE_SIZE;
437 }
438 }
Helge Dellere82a3b72009-06-16 20:51:48 +0000439 purge_tlb_end(flags);
Randolph Chungd6ce8622006-12-12 05:51:54 -0800440 }
441}
442
443static void cacheflush_h_tmp_function(void *dummy)
444{
445 flush_cache_all_local();
446}
447
448void flush_cache_all(void)
449{
Jens Axboe15c8b6c2008-05-09 09:39:44 +0200450 on_each_cpu(cacheflush_h_tmp_function, NULL, 1);
Randolph Chungd6ce8622006-12-12 05:51:54 -0800451}
452
453void flush_cache_mm(struct mm_struct *mm)
454{
455#ifdef CONFIG_SMP
456 flush_cache_all();
457#else
458 flush_cache_all_local();
459#endif
460}
461
462void
463flush_user_dcache_range(unsigned long start, unsigned long end)
464{
465 if ((end - start) < parisc_cache_flush_threshold)
466 flush_user_dcache_range_asm(start,end);
467 else
468 flush_data_cache();
469}
470
471void
472flush_user_icache_range(unsigned long start, unsigned long end)
473{
474 if ((end - start) < parisc_cache_flush_threshold)
475 flush_user_icache_range_asm(start,end);
476 else
477 flush_instruction_cache();
478}
479
480
481void flush_cache_range(struct vm_area_struct *vma,
482 unsigned long start, unsigned long end)
483{
484 int sr3;
485
Helge Deller8980a7b2009-01-06 12:57:01 +0100486 BUG_ON(!vma->vm_mm->context);
Randolph Chungd6ce8622006-12-12 05:51:54 -0800487
488 sr3 = mfsp(3);
489 if (vma->vm_mm->context == sr3) {
490 flush_user_dcache_range(start,end);
491 flush_user_icache_range(start,end);
492 } else {
493 flush_cache_all();
494 }
495}
496
497void
498flush_cache_page(struct vm_area_struct *vma, unsigned long vmaddr, unsigned long pfn)
499{
500 BUG_ON(!vma->vm_mm->context);
501
James Bottomleyf3118472010-12-22 10:22:11 -0600502 __flush_cache_page(vma, vmaddr, page_to_phys(pfn_to_page(pfn)));
Randolph Chungd6ce8622006-12-12 05:51:54 -0800503
504}