Blame view
arch/sh/mm/cache-sh7705.c
4.85 KB
1da177e4c Linux-2.6.12-rc2 |
1 2 3 4 5 6 7 8 9 |
/* * arch/sh/mm/cache-sh7705.c * * Copyright (C) 1999, 2000 Niibe Yutaka * Copyright (C) 2004 Alex Song * * This file is subject to the terms and conditions of the GNU General Public * License. See the file "COPYING" in the main directory of this archive * for more details. |
39e688a94 sh: Revert lazy d... |
10 |
* |
1da177e4c Linux-2.6.12-rc2 |
11 |
*/ |
1da177e4c Linux-2.6.12-rc2 |
12 13 14 |
#include <linux/init.h> #include <linux/mman.h> #include <linux/mm.h> |
2277ab4a1 sh: Migrate from ... |
15 |
#include <linux/fs.h> |
1da177e4c Linux-2.6.12-rc2 |
16 17 18 19 20 21 22 23 24 25 26 |
#include <linux/threads.h> #include <asm/addrspace.h> #include <asm/page.h> #include <asm/pgtable.h> #include <asm/processor.h> #include <asm/cache.h> #include <asm/io.h> #include <asm/uaccess.h> #include <asm/pgalloc.h> #include <asm/mmu_context.h> #include <asm/cacheflush.h> |
0f08f3380 sh: More cosmetic... |
27 28 29 30 |
/* * The 32KB cache on the SH7705 suffers from the same synonym problem * as SH4 CPUs */ |
1da177e4c Linux-2.6.12-rc2 |
31 32 33 |
static inline void cache_wback_all(void) { unsigned long ways, waysize, addrstart; |
11c196568 sh: Fixup cpu_dat... |
34 35 36 |
ways = current_cpu_data.dcache.ways; waysize = current_cpu_data.dcache.sets; waysize <<= current_cpu_data.dcache.entry_shift; |
1da177e4c Linux-2.6.12-rc2 |
37 38 39 40 41 42 43 44 |
addrstart = CACHE_OC_ADDRESS_ARRAY; do { unsigned long addr; for (addr = addrstart; addr < addrstart + waysize; |
11c196568 sh: Fixup cpu_dat... |
45 |
addr += current_cpu_data.dcache.linesz) { |
1da177e4c Linux-2.6.12-rc2 |
46 47 |
unsigned long data; int v = SH_CACHE_UPDATED | SH_CACHE_VALID; |
9d56dd3b0 sh: Mass ctrl_in/... |
48 |
data = __raw_readl(addr); |
1da177e4c Linux-2.6.12-rc2 |
49 50 |
if ((data & v) == v) |
9d56dd3b0 sh: Mass ctrl_in/... |
51 |
__raw_writel(data & ~v, addr); |
39e688a94 sh: Revert lazy d... |
52 |
|
1da177e4c Linux-2.6.12-rc2 |
53 |
} |
11c196568 sh: Fixup cpu_dat... |
54 |
addrstart += current_cpu_data.dcache.way_incr; |
1da177e4c Linux-2.6.12-rc2 |
55 56 57 58 59 60 61 62 |
} while (--ways); } /* * Write back the range of D-cache, and purge the I-cache. * * Called from kernel/module.c:sys_init_module and routine for a.out format. */ |
f26b2a562 sh: Make cache fl... |
63 |
static void sh7705_flush_icache_range(void *args) |
1da177e4c Linux-2.6.12-rc2 |
64 |
{ |
f26b2a562 sh: Make cache fl... |
65 66 67 68 69 |
struct flusher_data *data = args; unsigned long start, end; start = data->addr1; end = data->addr2; |
1da177e4c Linux-2.6.12-rc2 |
70 71 |
__flush_wback_region((void *)start, end - start); } |
1da177e4c Linux-2.6.12-rc2 |
72 73 74 |
/* * Writeback&Invalidate the D-cache of the page */ |
2dc2f8e0c sh: Kill off the ... |
75 |
static void __flush_dcache_page(unsigned long phys) |
1da177e4c Linux-2.6.12-rc2 |
76 77 |
{ unsigned long ways, waysize, addrstart; |
983f4c514 Revert "sh: Kill ... |
78 |
unsigned long flags; |
1da177e4c Linux-2.6.12-rc2 |
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
phys |= SH_CACHE_VALID; /* * Here, phys is the physical address of the page. We check all the * tags in the cache for those with the same page number as this page * (by masking off the lowest 2 bits of the 19-bit tag; these bits are * derived from the offset within in the 4k page). Matching valid * entries are invalidated. * * Since 2 bits of the cache index are derived from the virtual page * number, knowing this would reduce the number of cache entries to be * searched by a factor of 4. However this function exists to deal with * potential cache aliasing, therefore the optimisation is probably not * possible. */ |
983f4c514 Revert "sh: Kill ... |
95 |
local_irq_save(flags); |
cbaa118ec sh: Preparation f... |
96 |
jump_to_uncached(); |
1da177e4c Linux-2.6.12-rc2 |
97 |
|
11c196568 sh: Fixup cpu_dat... |
98 99 100 |
ways = current_cpu_data.dcache.ways; waysize = current_cpu_data.dcache.sets; waysize <<= current_cpu_data.dcache.entry_shift; |
1da177e4c Linux-2.6.12-rc2 |
101 102 103 104 105 106 107 108 |
addrstart = CACHE_OC_ADDRESS_ARRAY; do { unsigned long addr; for (addr = addrstart; addr < addrstart + waysize; |
11c196568 sh: Fixup cpu_dat... |
109 |
addr += current_cpu_data.dcache.linesz) { |
1da177e4c Linux-2.6.12-rc2 |
110 |
unsigned long data; |
9d56dd3b0 sh: Mass ctrl_in/... |
111 |
data = __raw_readl(addr) & (0x1ffffC00 | SH_CACHE_VALID); |
1da177e4c Linux-2.6.12-rc2 |
112 113 |
if (data == phys) { data &= ~(SH_CACHE_VALID | SH_CACHE_UPDATED); |
9d56dd3b0 sh: Mass ctrl_in/... |
114 |
__raw_writel(data, addr); |
1da177e4c Linux-2.6.12-rc2 |
115 116 |
} } |
11c196568 sh: Fixup cpu_dat... |
117 |
addrstart += current_cpu_data.dcache.way_incr; |
1da177e4c Linux-2.6.12-rc2 |
118 |
} while (--ways); |
cbaa118ec sh: Preparation f... |
119 |
back_to_cached(); |
983f4c514 Revert "sh: Kill ... |
120 |
local_irq_restore(flags); |
1da177e4c Linux-2.6.12-rc2 |
121 |
} |
1da177e4c Linux-2.6.12-rc2 |
122 123 124 125 |
/* * Write back & invalidate the D-cache of the page. * (To avoid "alias" issues) */ |
c8c2df905 sh: Fix up sh7705... |
126 |
static void sh7705_flush_dcache_page(void *arg) |
1da177e4c Linux-2.6.12-rc2 |
127 |
{ |
c8c2df905 sh: Fix up sh7705... |
128 |
struct page *page = arg; |
2277ab4a1 sh: Migrate from ... |
129 130 131 |
struct address_space *mapping = page_mapping(page); if (mapping && !mapping_mapped(mapping)) |
55661fc1f sh: Assume new pa... |
132 |
clear_bit(PG_dcache_clean, &page->flags); |
2277ab4a1 sh: Migrate from ... |
133 |
else |
8bd642b17 sh: Obliterate th... |
134 |
__flush_dcache_page(__pa(page_address(page))); |
1da177e4c Linux-2.6.12-rc2 |
135 |
} |
2dc2f8e0c sh: Kill off the ... |
136 |
static void sh7705_flush_cache_all(void *args) |
1da177e4c Linux-2.6.12-rc2 |
137 |
{ |
983f4c514 Revert "sh: Kill ... |
138 139 140 |
unsigned long flags; local_irq_save(flags); |
cbaa118ec sh: Preparation f... |
141 |
jump_to_uncached(); |
983f4c514 Revert "sh: Kill ... |
142 |
|
1da177e4c Linux-2.6.12-rc2 |
143 |
cache_wback_all(); |
cbaa118ec sh: Preparation f... |
144 |
back_to_cached(); |
983f4c514 Revert "sh: Kill ... |
145 |
local_irq_restore(flags); |
1da177e4c Linux-2.6.12-rc2 |
146 |
} |
1da177e4c Linux-2.6.12-rc2 |
147 148 149 150 151 |
/* * Write back and invalidate I/D-caches for the page. * * ADDRESS: Virtual Address (U0 address) */ |
f26b2a562 sh: Make cache fl... |
152 |
static void sh7705_flush_cache_page(void *args) |
1da177e4c Linux-2.6.12-rc2 |
153 |
{ |
f26b2a562 sh: Make cache fl... |
154 155 |
struct flusher_data *data = args; unsigned long pfn = data->addr2; |
1da177e4c Linux-2.6.12-rc2 |
156 157 158 159 160 161 162 163 164 165 166 |
__flush_dcache_page(pfn << PAGE_SHIFT); } /* * This is called when a page-cache page is about to be mapped into a * user process' address space. It offers an opportunity for a * port to ensure d-cache/i-cache coherency if necessary. * * Not entirely sure why this is necessary on SH3 with 32K cache but * without it we get occasional "Memory fault" when loading a program. */ |
f26b2a562 sh: Make cache fl... |
167 |
static void sh7705_flush_icache_page(void *page) |
1da177e4c Linux-2.6.12-rc2 |
168 169 170 |
{ __flush_purge_region(page_address(page), PAGE_SIZE); } |
0d051d90b sh: Convert SH770... |
171 172 173 |
void __init sh7705_cache_init(void) { |
f26b2a562 sh: Make cache fl... |
174 175 176 177 178 179 180 181 |
local_flush_icache_range = sh7705_flush_icache_range; local_flush_dcache_page = sh7705_flush_dcache_page; local_flush_cache_all = sh7705_flush_cache_all; local_flush_cache_mm = sh7705_flush_cache_all; local_flush_cache_dup_mm = sh7705_flush_cache_all; local_flush_cache_range = sh7705_flush_cache_all; local_flush_cache_page = sh7705_flush_cache_page; local_flush_icache_page = sh7705_flush_icache_page; |
0d051d90b sh: Convert SH770... |
182 |
} |