aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arc
diff options
context:
space:
mode:
authorVineet Gupta <vgupta@synopsys.com>2013-06-15 00:51:51 -0400
committerVineet Gupta <vgupta@synopsys.com>2013-06-22 04:16:43 -0400
commit30499186602afa1d62c2e5d354d02214a0ee00b7 (patch)
treed0e928b54b995702822c70a32b3479625ff30c1f /arch/arc
parent6546415226f2fc3ab0a820464774e02a1679f90a (diff)
ARC: cache detection code bitrot
* Number of (i|d)cache ways can be retrieved from BCRs and hence no need to cross check with with built-in constants * Use of IS_ENABLED() to check for a Kconfig option * is_not_cache_aligned() not used anymore Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
Diffstat (limited to 'arch/arc')
-rw-r--r--arch/arc/include/asm/arcregs.h2
-rw-r--r--arch/arc/include/asm/cache.h11
-rw-r--r--arch/arc/include/asm/cacheflush.h6
-rw-r--r--arch/arc/mm/cache_arc700.c31
4 files changed, 13 insertions, 37 deletions
diff --git a/arch/arc/include/asm/arcregs.h b/arch/arc/include/asm/arcregs.h
index 20002c46e3bc..6addeec34a7c 100644
--- a/arch/arc/include/asm/arcregs.h
+++ b/arch/arc/include/asm/arcregs.h
@@ -287,7 +287,7 @@ struct cpuinfo_arc_mmu {
287}; 287};
288 288
289struct cpuinfo_arc_cache { 289struct cpuinfo_arc_cache {
290 unsigned int has_aliasing, sz, line_len, assoc, ver; 290 unsigned int sz, line_len, assoc, ver;
291}; 291};
292 292
293struct cpuinfo_arc_ccm { 293struct cpuinfo_arc_ccm {
diff --git a/arch/arc/include/asm/cache.h b/arch/arc/include/asm/cache.h
index 44eb07eb92e5..5802849a6cae 100644
--- a/arch/arc/include/asm/cache.h
+++ b/arch/arc/include/asm/cache.h
@@ -18,22 +18,13 @@
18 18
19#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT) 19#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
20 20
21#define ARC_ICACHE_WAYS 2 21/* For a rare case where customers have differently config I/D */
22#define ARC_DCACHE_WAYS 4
23
24/* Helpers */
25#define ARC_ICACHE_LINE_LEN L1_CACHE_BYTES 22#define ARC_ICACHE_LINE_LEN L1_CACHE_BYTES
26#define ARC_DCACHE_LINE_LEN L1_CACHE_BYTES 23#define ARC_DCACHE_LINE_LEN L1_CACHE_BYTES
27 24
28#define ICACHE_LINE_MASK (~(ARC_ICACHE_LINE_LEN - 1)) 25#define ICACHE_LINE_MASK (~(ARC_ICACHE_LINE_LEN - 1))
29#define DCACHE_LINE_MASK (~(ARC_DCACHE_LINE_LEN - 1)) 26#define DCACHE_LINE_MASK (~(ARC_DCACHE_LINE_LEN - 1))
30 27
31#if ARC_ICACHE_LINE_LEN != ARC_DCACHE_LINE_LEN
32#error "Need to fix some code as I/D cache lines not same"
33#else
34#define is_not_cache_aligned(p) ((unsigned long)p & (~DCACHE_LINE_MASK))
35#endif
36
37/* 28/*
38 * ARC700 doesn't cache any access in top 256M. 29 * ARC700 doesn't cache any access in top 256M.
39 * Ideal for wiring memory mapped peripherals as we don't need to do 30 * Ideal for wiring memory mapped peripherals as we don't need to do
diff --git a/arch/arc/include/asm/cacheflush.h b/arch/arc/include/asm/cacheflush.h
index ef62682e8d95..185dfd03dcdb 100644
--- a/arch/arc/include/asm/cacheflush.h
+++ b/arch/arc/include/asm/cacheflush.h
@@ -86,11 +86,7 @@ void flush_anon_page(struct vm_area_struct *vma,
86 */ 86 */
87static inline int cache_is_vipt_aliasing(void) 87static inline int cache_is_vipt_aliasing(void)
88{ 88{
89#ifdef CONFIG_ARC_CACHE_VIPT_ALIASING 89 return IS_ENABLED(CONFIG_ARC_CACHE_VIPT_ALIASING);
90 return 1;
91#else
92 return 0;
93#endif
94} 90}
95 91
96#define CACHE_COLOR(addr) (((unsigned long)(addr) >> (PAGE_SHIFT)) & 1) 92#define CACHE_COLOR(addr) (((unsigned long)(addr) >> (PAGE_SHIFT)) & 1)
diff --git a/arch/arc/mm/cache_arc700.c b/arch/arc/mm/cache_arc700.c
index e9c7a66817ca..0a56682e0c94 100644
--- a/arch/arc/mm/cache_arc700.c
+++ b/arch/arc/mm/cache_arc700.c
@@ -144,8 +144,8 @@ void __cpuinit read_decode_cache_bcr(void)
144 p_ic = &cpuinfo_arc700[cpu].icache; 144 p_ic = &cpuinfo_arc700[cpu].icache;
145 READ_BCR(ARC_REG_IC_BCR, ibcr); 145 READ_BCR(ARC_REG_IC_BCR, ibcr);
146 146
147 if (ibcr.config == 0x3) 147 BUG_ON(ibcr.config != 3);
148 p_ic->assoc = 2; 148 p_ic->assoc = 2; /* Fixed to 2w set assoc */
149 p_ic->line_len = 8 << ibcr.line_len; 149 p_ic->line_len = 8 << ibcr.line_len;
150 p_ic->sz = 0x200 << ibcr.sz; 150 p_ic->sz = 0x200 << ibcr.sz;
151 p_ic->ver = ibcr.ver; 151 p_ic->ver = ibcr.ver;
@@ -153,8 +153,8 @@ void __cpuinit read_decode_cache_bcr(void)
153 p_dc = &cpuinfo_arc700[cpu].dcache; 153 p_dc = &cpuinfo_arc700[cpu].dcache;
154 READ_BCR(ARC_REG_DC_BCR, dbcr); 154 READ_BCR(ARC_REG_DC_BCR, dbcr);
155 155
156 if (dbcr.config == 0x2) 156 BUG_ON(dbcr.config != 2);
157 p_dc->assoc = 4; 157 p_dc->assoc = 4; /* Fixed to 4w set assoc */
158 p_dc->line_len = 16 << dbcr.line_len; 158 p_dc->line_len = 16 << dbcr.line_len;
159 p_dc->sz = 0x200 << dbcr.sz; 159 p_dc->sz = 0x200 << dbcr.sz;
160 p_dc->ver = dbcr.ver; 160 p_dc->ver = dbcr.ver;
@@ -182,20 +182,11 @@ void __cpuinit arc_cache_init(void)
182 182
183#ifdef CONFIG_ARC_HAS_ICACHE 183#ifdef CONFIG_ARC_HAS_ICACHE
184 /* 1. Confirm some of I-cache params which Linux assumes */ 184 /* 1. Confirm some of I-cache params which Linux assumes */
185 if ((ic->assoc != ARC_ICACHE_WAYS) || 185 if (ic->line_len != ARC_ICACHE_LINE_LEN)
186 (ic->line_len != ARC_ICACHE_LINE_LEN)) {
187 panic("Cache H/W doesn't match kernel Config"); 186 panic("Cache H/W doesn't match kernel Config");
188 }
189#if (CONFIG_ARC_MMU_VER > 2)
190 if (ic->ver != 3) {
191 if (running_on_hw)
192 panic("Cache ver doesn't match MMU ver\n");
193 187
194 /* For ISS - suggest the toggles to use */ 188 if (ic->ver != CONFIG_ARC_MMU_VER)
195 pr_err("Use -prop=icache_version=3,-prop=dcache_version=3\n"); 189 panic("Cache ver doesn't match MMU ver\n");
196
197 }
198#endif
199#endif 190#endif
200 191
201 /* Enable/disable I-Cache */ 192 /* Enable/disable I-Cache */
@@ -214,14 +205,12 @@ chk_dc:
214 return; 205 return;
215 206
216#ifdef CONFIG_ARC_HAS_DCACHE 207#ifdef CONFIG_ARC_HAS_DCACHE
217 if ((dc->assoc != ARC_DCACHE_WAYS) || 208 if (dc->line_len != ARC_DCACHE_LINE_LEN)
218 (dc->line_len != ARC_DCACHE_LINE_LEN)) {
219 panic("Cache H/W doesn't match kernel Config"); 209 panic("Cache H/W doesn't match kernel Config");
220 }
221
222 dcache_does_alias = (dc->sz / ARC_DCACHE_WAYS) > PAGE_SIZE;
223 210
224 /* check for D-Cache aliasing */ 211 /* check for D-Cache aliasing */
212 dcache_does_alias = (dc->sz / dc->assoc) > PAGE_SIZE;
213
225 if (dcache_does_alias && !cache_is_vipt_aliasing()) 214 if (dcache_does_alias && !cache_is_vipt_aliasing())
226 panic("Enable CONFIG_ARC_CACHE_VIPT_ALIASING\n"); 215 panic("Enable CONFIG_ARC_CACHE_VIPT_ALIASING\n");
227 else if (!dcache_does_alias && cache_is_vipt_aliasing()) 216 else if (!dcache_does_alias && cache_is_vipt_aliasing())