@@ -77,21 +77,19 @@ char *arc_cache_mumbojumbo(int c, char *buf, int len)
7777{
7878 int n = 0 ;
7979
80- #define PR_CACHE (p , enb , str ) \
81- { \
80+ #define PR_CACHE (p , cfg , str ) \
8281 if (!(p)->ver) \
8382 n += scnprintf(buf + n, len - n, str"\t\t: N/A\n"); \
8483 else \
8584 n += scnprintf(buf + n, len - n, \
86- str"\t\t: (%uK) VIPT, %dway set-asc, %ub Line %s\n", \
87- TO_KB((p)->sz), (p)->assoc, (p)->line_len, \
88- enb ? "" : "DISABLED (kernel-build)"); \
89- }
85+ str"\t\t: %uK, %dway/set, %uB Line, %s%s%s\n", \
86+ (p)->sz_k, (p)->assoc, (p)->line_len, \
87+ (p)->vipt ? "VIPT" : "PIPT", \
88+ (p)->alias ? " aliasing" : "", \
89+ IS_ENABLED(cfg) ? "" : " (not used)");
9090
91- PR_CACHE (& cpuinfo_arc700 [c ].icache , IS_ENABLED (CONFIG_ARC_HAS_ICACHE ),
92- "I-Cache" );
93- PR_CACHE (& cpuinfo_arc700 [c ].dcache , IS_ENABLED (CONFIG_ARC_HAS_DCACHE ),
94- "D-Cache" );
91+ PR_CACHE (& cpuinfo_arc700 [c ].icache , CONFIG_ARC_HAS_ICACHE , "I-Cache" );
92+ PR_CACHE (& cpuinfo_arc700 [c ].dcache , CONFIG_ARC_HAS_DCACHE , "D-Cache" );
9593
9694 return buf ;
9795}
@@ -116,20 +114,31 @@ void read_decode_cache_bcr(void)
116114 p_ic = & cpuinfo_arc700 [cpu ].icache ;
117115 READ_BCR (ARC_REG_IC_BCR , ibcr );
118116
117+ if (!ibcr .ver )
118+ goto dc_chk ;
119+
119120 BUG_ON (ibcr .config != 3 );
120121 p_ic -> assoc = 2 ; /* Fixed to 2w set assoc */
121122 p_ic -> line_len = 8 << ibcr .line_len ;
122- p_ic -> sz = 0x200 << ibcr .sz ;
123+ p_ic -> sz_k = 1 << ( ibcr .sz - 1 ) ;
123124 p_ic -> ver = ibcr .ver ;
125+ p_ic -> vipt = 1 ;
126+ p_ic -> alias = p_ic -> sz_k /p_ic -> assoc /TO_KB (PAGE_SIZE ) > 1 ;
124127
128+ dc_chk :
125129 p_dc = & cpuinfo_arc700 [cpu ].dcache ;
126130 READ_BCR (ARC_REG_DC_BCR , dbcr );
127131
132+ if (!dbcr .ver )
133+ return ;
134+
128135 BUG_ON (dbcr .config != 2 );
129136 p_dc -> assoc = 4 ; /* Fixed to 4w set assoc */
130137 p_dc -> line_len = 16 << dbcr .line_len ;
131- p_dc -> sz = 0x200 << dbcr .sz ;
138+ p_dc -> sz_k = 1 << ( dbcr .sz - 1 ) ;
132139 p_dc -> ver = dbcr .ver ;
140+ p_dc -> vipt = 1 ;
141+ p_dc -> alias = p_dc -> sz_k /p_dc -> assoc /TO_KB (PAGE_SIZE ) > 1 ;
133142}
134143
135144/*
@@ -142,14 +151,16 @@ void read_decode_cache_bcr(void)
142151void arc_cache_init (void )
143152{
144153 unsigned int __maybe_unused cpu = smp_processor_id ();
145- struct cpuinfo_arc_cache __maybe_unused * ic , __maybe_unused * dc ;
146154 char str [256 ];
147155
148156 printk (arc_cache_mumbojumbo (0 , str , sizeof (str )));
149157
150- #ifdef CONFIG_ARC_HAS_ICACHE
151- ic = & cpuinfo_arc700 [cpu ].icache ;
152- if (ic -> ver ) {
158+ if (IS_ENABLED (CONFIG_ARC_HAS_ICACHE )) {
159+ struct cpuinfo_arc_cache * ic = & cpuinfo_arc700 [cpu ].icache ;
160+
161+ if (!ic -> ver )
162+ panic ("cache support enabled but non-existent cache\n" );
163+
153164 if (ic -> line_len != L1_CACHE_BYTES )
154165 panic ("ICache line [%d] != kernel Config [%d]" ,
155166 ic -> line_len , L1_CACHE_BYTES );
@@ -158,26 +169,26 @@ void arc_cache_init(void)
158169 panic ("Cache ver [%d] doesn't match MMU ver [%d]\n" ,
159170 ic -> ver , CONFIG_ARC_MMU_VER );
160171 }
161- #endif
162172
163- #ifdef CONFIG_ARC_HAS_DCACHE
164- dc = & cpuinfo_arc700 [cpu ].dcache ;
165- if (dc -> ver ) {
166- unsigned int dcache_does_alias ;
173+ if (IS_ENABLED (CONFIG_ARC_HAS_DCACHE )) {
174+ struct cpuinfo_arc_cache * dc = & cpuinfo_arc700 [cpu ].dcache ;
175+ int handled ;
176+
177+ if (!dc -> ver )
178+ panic ("cache support enabled but non-existent cache\n" );
167179
168180 if (dc -> line_len != L1_CACHE_BYTES )
169181 panic ("DCache line [%d] != kernel Config [%d]" ,
170182 dc -> line_len , L1_CACHE_BYTES );
171183
172184 /* check for D-Cache aliasing */
173- dcache_does_alias = ( dc -> sz / dc -> assoc ) > PAGE_SIZE ;
185+ handled = IS_ENABLED ( CONFIG_ARC_CACHE_VIPT_ALIASING ) ;
174186
175- if (dcache_does_alias && !cache_is_vipt_aliasing () )
187+ if (dc -> alias && !handled )
176188 panic ("Enable CONFIG_ARC_CACHE_VIPT_ALIASING\n" );
177- else if (!dcache_does_alias && cache_is_vipt_aliasing () )
189+ else if (!dc -> alias && handled )
178190 panic ("Don't need CONFIG_ARC_CACHE_VIPT_ALIASING\n" );
179191 }
180- #endif
181192}
182193
183194#define OP_INV 0x1
0 commit comments