1 /* $Id: cache.c,v 1.4 2000/01/25 00:11:38 prumpf Exp $
3 * This file is subject to the terms and conditions of the GNU General Public
4 * License. See the file "COPYING" in the main directory of this archive
7 * Copyright (C) 1999 Helge Deller (07-13-1999)
8 * Copyright (C) 1999 SuSE GmbH Nuernberg
9 * Copyright (C) 2000 Philipp Rumpf (prumpf@tux.org)
11 * Cache and TLB management
15 #include <linux/init.h>
16 #include <linux/kernel.h>
18 #include <linux/module.h>
19 #include <linux/seq_file.h>
20 #include <linux/pagemap.h>
23 #include <asm/cache.h>
24 #include <asm/cacheflush.h>
25 #include <asm/tlbflush.h>
26 #include <asm/system.h>
28 #include <asm/pgalloc.h>
29 #include <asm/processor.h>
34 EXPORT_SYMBOL(dcache_stride);
36 struct pdc_cache_info cache_info;
38 static struct pdc_btlb_info btlb_info;
43 flush_data_cache(void)
45 on_each_cpu((void (*)(void *))flush_data_cache_local, NULL, 1, 1);
50 flush_cache_all_local(void)
52 flush_instruction_cache_local();
53 flush_data_cache_local();
55 EXPORT_SYMBOL(flush_cache_all_local);
57 /* flushes EVERYTHING (tlb & cache) */
60 flush_all_caches(void)
65 EXPORT_SYMBOL(flush_all_caches);
68 update_mmu_cache(struct vm_area_struct *vma, unsigned long address, pte_t pte)
70 struct page *page = pte_page(pte);
72 if (VALID_PAGE(page) && page_mapping(page) &&
73 test_bit(PG_dcache_dirty, &page->flags)) {
75 flush_kernel_dcache_page(page_address(page));
76 clear_bit(PG_dcache_dirty, &page->flags);
81 show_cache_info(struct seq_file *m)
83 seq_printf(m, "I-cache\t\t: %ld KB\n",
84 cache_info.ic_size/1024 );
85 seq_printf(m, "D-cache\t\t: %ld KB (%s)%s\n",
86 cache_info.dc_size/1024,
87 (cache_info.dc_conf.cc_wt ? "WT":"WB"),
88 (cache_info.dc_conf.cc_sh ? " - shared I/D":"")
91 seq_printf(m, "ITLB entries\t: %ld\n" "DTLB entries\t: %ld%s\n",
94 cache_info.dt_conf.tc_sh ? " - shared with ITLB":""
98 /* BTLB - Block TLB */
99 if (btlb_info.max_size==0) {
100 seq_printf(m, "BTLB\t\t: not supported\n" );
103 "BTLB fixed\t: max. %d pages, pagesize=%d (%dMB)\n"
104 "BTLB fix-entr.\t: %d instruction, %d data (%d combined)\n"
105 "BTLB var-entr.\t: %d instruction, %d data (%d combined)\n",
106 btlb_info.max_size, (int)4096,
107 btlb_info.max_size>>8,
108 btlb_info.fixed_range_info.num_i,
109 btlb_info.fixed_range_info.num_d,
110 btlb_info.fixed_range_info.num_comb,
111 btlb_info.variable_range_info.num_i,
112 btlb_info.variable_range_info.num_d,
113 btlb_info.variable_range_info.num_comb
120 parisc_cache_init(void)
122 if (pdc_cache_info(&cache_info) < 0)
123 panic("parisc_cache_init: pdc_cache_info failed");
126 printk(KERN_DEBUG "ic_size %lx dc_size %lx it_size %lx pdc_cache_info %d*long pdc_cache_cf %d\n",
130 sizeof (struct pdc_cache_info) / sizeof (long),
131 sizeof (struct pdc_cache_cf)
134 printk(KERN_DEBUG "dc base %x dc stride %x dc count %x dc loop %d\n",
136 cache_info.dc_stride,
140 printk(KERN_DEBUG "dc conf: alias %d block %d line %d wt %d sh %d cst %d assoc %d\n",
141 cache_info.dc_conf.cc_alias,
142 cache_info.dc_conf.cc_block,
143 cache_info.dc_conf.cc_line,
144 cache_info.dc_conf.cc_wt,
145 cache_info.dc_conf.cc_sh,
146 cache_info.dc_conf.cc_cst,
147 cache_info.dc_conf.cc_assoc);
149 printk(KERN_DEBUG "ic conf: alias %d block %d line %d wt %d sh %d cst %d assoc %d\n",
150 cache_info.ic_conf.cc_alias,
151 cache_info.ic_conf.cc_block,
152 cache_info.ic_conf.cc_line,
153 cache_info.ic_conf.cc_wt,
154 cache_info.ic_conf.cc_sh,
155 cache_info.ic_conf.cc_cst,
156 cache_info.ic_conf.cc_assoc);
158 printk(KERN_DEBUG "dt conf: sh %d page %d cst %d aid %d pad1 %d \n",
159 cache_info.dt_conf.tc_sh,
160 cache_info.dt_conf.tc_page,
161 cache_info.dt_conf.tc_cst,
162 cache_info.dt_conf.tc_aid,
163 cache_info.dt_conf.tc_pad1);
165 printk(KERN_DEBUG "it conf: sh %d page %d cst %d aid %d pad1 %d \n",
166 cache_info.it_conf.tc_sh,
167 cache_info.it_conf.tc_page,
168 cache_info.it_conf.tc_cst,
169 cache_info.it_conf.tc_aid,
170 cache_info.it_conf.tc_pad1);
174 if (cache_info.dt_conf.tc_sh == 0 || cache_info.dt_conf.tc_sh == 2) {
175 if (cache_info.dt_conf.tc_sh == 2)
176 printk(KERN_WARNING "Unexpected TLB configuration. "
177 "Will flush I/D separately (could be optimized).\n");
182 dcache_stride = (1 << (cache_info.dc_conf.cc_block + 3)) *
183 cache_info.dc_conf.cc_line;
184 icache_stride = (1 << (cache_info.ic_conf.cc_block + 3)) *
185 cache_info.ic_conf.cc_line;
187 if (pdc_btlb_info(&btlb_info) < 0) {
188 memset(&btlb_info, 0, sizeof btlb_info);
192 if ((boot_cpu_data.pdc.capabilities & PDC_MODEL_NVA_MASK) ==
193 PDC_MODEL_NVA_UNSUPPORTED) {
194 printk(KERN_WARNING "Only equivalent aliasing supported\n");
196 panic("SMP kernel required to avoid non-equivalent aliasing");
201 void disable_sr_hashing(void)
205 switch (boot_cpu_data.cpu_type) {
206 case pcx: /* We shouldn't get this far. setup.c should prevent it. */
213 srhash_type = SRHASH_PCXST;
217 srhash_type = SRHASH_PCXL;
220 case pcxl2: /* pcxl2 doesn't support space register hashing */
223 default: /* Currently all PA2.0 machines use the same ins. sequence */
224 srhash_type = SRHASH_PA20;
228 disable_sr_hashing_asm(srhash_type);
231 void __flush_dcache_page(struct page *page)
233 struct address_space *mapping = page_mapping(page);
234 struct vm_area_struct *mpnt = NULL;
235 struct prio_tree_iter iter;
236 unsigned long offset;
240 flush_kernel_dcache_page(page_address(page));
245 pgoff = page->index << (PAGE_CACHE_SHIFT - PAGE_SHIFT);
247 /* We have carefully arranged in arch_get_unmapped_area() that
248 * *any* mappings of a file are always congruently mapped (whether
249 * declared as MAP_PRIVATE or MAP_SHARED), so we only need
250 * to flush one address here for them all to become coherent */
252 flush_dcache_mmap_lock(mapping);
253 while ((mpnt = vma_prio_tree_next(mpnt, &mapping->i_mmap,
254 &iter, pgoff, pgoff)) != NULL) {
255 offset = (pgoff - mpnt->vm_pgoff) << PAGE_SHIFT;
256 addr = mpnt->vm_start + offset;
258 /* Flush instructions produce non access tlb misses.
259 * On PA, we nullify these instructions rather than
260 * taking a page fault if the pte doesn't exist.
261 * This is just for speed. If the page translation
262 * isn't there, there's no point exciting the
263 * nadtlb handler into a nullification frenzy */
265 if (!translation_exists(mpnt, addr))
268 __flush_cache_page(mpnt, addr);
272 flush_dcache_mmap_unlock(mapping);
274 EXPORT_SYMBOL(__flush_dcache_page);
276 /* Defined in arch/parisc/kernel/pacache.S */
277 EXPORT_SYMBOL(flush_kernel_dcache_range_asm);
278 EXPORT_SYMBOL(flush_kernel_dcache_page);
279 EXPORT_SYMBOL(flush_data_cache_local);
280 EXPORT_SYMBOL(flush_kernel_icache_range_asm);