diff options
author | Paul Mundt <lethal@linux-sh.org> | 2009-08-14 22:11:16 -0400 |
---|---|---|
committer | Paul Mundt <lethal@linux-sh.org> | 2009-08-14 22:11:16 -0400 |
commit | 27d59ec1709817a90aa3ab7169f60994a89ad2f5 (patch) | |
tree | c9aca1b3474d1ef076cecb07a4ccb42c126c4acf /arch | |
parent | ecba1060583635ab55092072441ff903b5e9a659 (diff) |
sh: Move alias computation to shared cache init.
This migrates the alias computation and printing of probed cache
parameters from the SH-4 code to the shared cpu_cache_init().
This permits other platforms with aliases to make use of the same
probe logic without having to roll their own, and also produces
consistent output regardless of platform.
Signed-off-by: Paul Mundt <lethal@linux-sh.org>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/sh/mm/cache-sh4.c | 58 | ||||
-rw-r--r-- | arch/sh/mm/cache.c | 46 |
2 files changed, 51 insertions, 53 deletions
diff --git a/arch/sh/mm/cache-sh4.c b/arch/sh/mm/cache-sh4.c index df2eb87f1524..4ac844b1432f 100644 --- a/arch/sh/mm/cache-sh4.c +++ b/arch/sh/mm/cache-sh4.c | |||
@@ -44,61 +44,15 @@ static void __flush_cache_4096(unsigned long addr, unsigned long phys, | |||
44 | static void (*__flush_dcache_segment_fn)(unsigned long, unsigned long) = | 44 | static void (*__flush_dcache_segment_fn)(unsigned long, unsigned long) = |
45 | (void (*)(unsigned long, unsigned long))0xdeadbeef; | 45 | (void (*)(unsigned long, unsigned long))0xdeadbeef; |
46 | 46 | ||
47 | static void compute_alias(struct cache_info *c) | ||
48 | { | ||
49 | c->alias_mask = ((c->sets - 1) << c->entry_shift) & ~(PAGE_SIZE - 1); | ||
50 | c->n_aliases = c->alias_mask ? (c->alias_mask >> PAGE_SHIFT) + 1 : 0; | ||
51 | } | ||
52 | |||
53 | static void __init emit_cache_params(void) | ||
54 | { | ||
55 | printk("PVR=%08x CVR=%08x PRR=%08x\n", | ||
56 | ctrl_inl(CCN_PVR), | ||
57 | ctrl_inl(CCN_CVR), | ||
58 | ctrl_inl(CCN_PRR)); | ||
59 | printk("I-cache : n_ways=%d n_sets=%d way_incr=%d\n", | ||
60 | boot_cpu_data.icache.ways, | ||
61 | boot_cpu_data.icache.sets, | ||
62 | boot_cpu_data.icache.way_incr); | ||
63 | printk("I-cache : entry_mask=0x%08x alias_mask=0x%08x n_aliases=%d\n", | ||
64 | boot_cpu_data.icache.entry_mask, | ||
65 | boot_cpu_data.icache.alias_mask, | ||
66 | boot_cpu_data.icache.n_aliases); | ||
67 | printk("D-cache : n_ways=%d n_sets=%d way_incr=%d\n", | ||
68 | boot_cpu_data.dcache.ways, | ||
69 | boot_cpu_data.dcache.sets, | ||
70 | boot_cpu_data.dcache.way_incr); | ||
71 | printk("D-cache : entry_mask=0x%08x alias_mask=0x%08x n_aliases=%d\n", | ||
72 | boot_cpu_data.dcache.entry_mask, | ||
73 | boot_cpu_data.dcache.alias_mask, | ||
74 | boot_cpu_data.dcache.n_aliases); | ||
75 | |||
76 | /* | ||
77 | * Emit Secondary Cache parameters if the CPU has a probed L2. | ||
78 | */ | ||
79 | if (boot_cpu_data.flags & CPU_HAS_L2_CACHE) { | ||
80 | printk("S-cache : n_ways=%d n_sets=%d way_incr=%d\n", | ||
81 | boot_cpu_data.scache.ways, | ||
82 | boot_cpu_data.scache.sets, | ||
83 | boot_cpu_data.scache.way_incr); | ||
84 | printk("S-cache : entry_mask=0x%08x alias_mask=0x%08x n_aliases=%d\n", | ||
85 | boot_cpu_data.scache.entry_mask, | ||
86 | boot_cpu_data.scache.alias_mask, | ||
87 | boot_cpu_data.scache.n_aliases); | ||
88 | } | ||
89 | |||
90 | if (!__flush_dcache_segment_fn) | ||
91 | panic("unknown number of cache ways\n"); | ||
92 | } | ||
93 | |||
94 | /* | 47 | /* |
95 | * SH-4 has virtually indexed and physically tagged cache. | 48 | * SH-4 has virtually indexed and physically tagged cache. |
96 | */ | 49 | */ |
97 | void __init sh4_cache_init(void) | 50 | void __init sh4_cache_init(void) |
98 | { | 51 | { |
99 | compute_alias(&boot_cpu_data.icache); | 52 | printk("PVR=%08x CVR=%08x PRR=%08x\n", |
100 | compute_alias(&boot_cpu_data.dcache); | 53 | ctrl_inl(CCN_PVR), |
101 | compute_alias(&boot_cpu_data.scache); | 54 | ctrl_inl(CCN_CVR), |
55 | ctrl_inl(CCN_PRR)); | ||
102 | 56 | ||
103 | switch (boot_cpu_data.dcache.ways) { | 57 | switch (boot_cpu_data.dcache.ways) { |
104 | case 1: | 58 | case 1: |
@@ -111,11 +65,9 @@ void __init sh4_cache_init(void) | |||
111 | __flush_dcache_segment_fn = __flush_dcache_segment_4way; | 65 | __flush_dcache_segment_fn = __flush_dcache_segment_4way; |
112 | break; | 66 | break; |
113 | default: | 67 | default: |
114 | __flush_dcache_segment_fn = NULL; | 68 | panic("unknown number of cache ways\n"); |
115 | break; | 69 | break; |
116 | } | 70 | } |
117 | |||
118 | emit_cache_params(); | ||
119 | } | 71 | } |
120 | 72 | ||
121 | /* | 73 | /* |
diff --git a/arch/sh/mm/cache.c b/arch/sh/mm/cache.c index 659981ffae24..a31e5c46e7a6 100644 --- a/arch/sh/mm/cache.c +++ b/arch/sh/mm/cache.c | |||
@@ -128,8 +128,52 @@ void __flush_anon_page(struct page *page, unsigned long vmaddr) | |||
128 | } | 128 | } |
129 | } | 129 | } |
130 | 130 | ||
131 | static void compute_alias(struct cache_info *c) | ||
132 | { | ||
133 | c->alias_mask = ((c->sets - 1) << c->entry_shift) & ~(PAGE_SIZE - 1); | ||
134 | c->n_aliases = c->alias_mask ? (c->alias_mask >> PAGE_SHIFT) + 1 : 0; | ||
135 | } | ||
136 | |||
137 | static void __init emit_cache_params(void) | ||
138 | { | ||
139 | printk(KERN_NOTICE "I-cache : n_ways=%d n_sets=%d way_incr=%d\n", | ||
140 | boot_cpu_data.icache.ways, | ||
141 | boot_cpu_data.icache.sets, | ||
142 | boot_cpu_data.icache.way_incr); | ||
143 | printk(KERN_NOTICE "I-cache : entry_mask=0x%08x alias_mask=0x%08x n_aliases=%d\n", | ||
144 | boot_cpu_data.icache.entry_mask, | ||
145 | boot_cpu_data.icache.alias_mask, | ||
146 | boot_cpu_data.icache.n_aliases); | ||
147 | printk(KERN_NOTICE "D-cache : n_ways=%d n_sets=%d way_incr=%d\n", | ||
148 | boot_cpu_data.dcache.ways, | ||
149 | boot_cpu_data.dcache.sets, | ||
150 | boot_cpu_data.dcache.way_incr); | ||
151 | printk(KERN_NOTICE "D-cache : entry_mask=0x%08x alias_mask=0x%08x n_aliases=%d\n", | ||
152 | boot_cpu_data.dcache.entry_mask, | ||
153 | boot_cpu_data.dcache.alias_mask, | ||
154 | boot_cpu_data.dcache.n_aliases); | ||
155 | |||
156 | /* | ||
157 | * Emit Secondary Cache parameters if the CPU has a probed L2. | ||
158 | */ | ||
159 | if (boot_cpu_data.flags & CPU_HAS_L2_CACHE) { | ||
160 | printk(KERN_NOTICE "S-cache : n_ways=%d n_sets=%d way_incr=%d\n", | ||
161 | boot_cpu_data.scache.ways, | ||
162 | boot_cpu_data.scache.sets, | ||
163 | boot_cpu_data.scache.way_incr); | ||
164 | printk(KERN_NOTICE "S-cache : entry_mask=0x%08x alias_mask=0x%08x n_aliases=%d\n", | ||
165 | boot_cpu_data.scache.entry_mask, | ||
166 | boot_cpu_data.scache.alias_mask, | ||
167 | boot_cpu_data.scache.n_aliases); | ||
168 | } | ||
169 | } | ||
170 | |||
131 | void __init cpu_cache_init(void) | 171 | void __init cpu_cache_init(void) |
132 | { | 172 | { |
173 | compute_alias(&boot_cpu_data.icache); | ||
174 | compute_alias(&boot_cpu_data.dcache); | ||
175 | compute_alias(&boot_cpu_data.scache); | ||
176 | |||
133 | if ((boot_cpu_data.family == CPU_FAMILY_SH4) || | 177 | if ((boot_cpu_data.family == CPU_FAMILY_SH4) || |
134 | (boot_cpu_data.family == CPU_FAMILY_SH4A) || | 178 | (boot_cpu_data.family == CPU_FAMILY_SH4A) || |
135 | (boot_cpu_data.family == CPU_FAMILY_SH4AL_DSP)) { | 179 | (boot_cpu_data.family == CPU_FAMILY_SH4AL_DSP)) { |
@@ -137,4 +181,6 @@ void __init cpu_cache_init(void) | |||
137 | 181 | ||
138 | sh4_cache_init(); | 182 | sh4_cache_init(); |
139 | } | 183 | } |
184 | |||
185 | emit_cache_params(); | ||
140 | } | 186 | } |