@@ -28,85 +28,35 @@ int slc_enable = 1, ioc_enable = 1;
28
28
unsigned long perip_base = ARC_UNCACHED_ADDR_SPACE ; /* legacy value for boot */
29
29
unsigned long perip_end = 0xFFFFFFFF ; /* legacy value */
30
30
31
+ static struct cpuinfo_arc_cache {
32
+ unsigned int sz_k , line_len , colors ;
33
+ } ic_info , dc_info , slc_info ;
34
+
31
35
void (* _cache_line_loop_ic_fn )(phys_addr_t paddr , unsigned long vaddr ,
32
36
unsigned long sz , const int op , const int full_page );
33
37
34
38
void (* __dma_cache_wback_inv )(phys_addr_t start , unsigned long sz );
35
39
void (* __dma_cache_inv )(phys_addr_t start , unsigned long sz );
36
40
void (* __dma_cache_wback )(phys_addr_t start , unsigned long sz );
37
41
38
- char * arc_cache_mumbojumbo (int c , char * buf , int len )
42
+ static char * read_decode_cache_bcr_arcv2 (int c , char * buf , int len )
39
43
{
40
- int n = 0 ;
41
- struct cpuinfo_arc_cache * p ;
42
-
43
- #define PR_CACHE (p , cfg , str ) \
44
- if (!(p)->line_len) \
45
- n += scnprintf(buf + n, len - n, str"\t\t: N/A\n"); \
46
- else \
47
- n += scnprintf(buf + n, len - n, \
48
- str"\t\t: %uK, %dway/set, %uB Line, %s%s%s\n", \
49
- (p)->sz_k, (p)->assoc, (p)->line_len, \
50
- (p)->vipt ? "VIPT" : "PIPT", \
51
- (p)->alias ? " aliasing" : "", \
52
- IS_USED_CFG(cfg));
53
-
54
- PR_CACHE (& cpuinfo_arc700 [c ].icache , CONFIG_ARC_HAS_ICACHE , "I-Cache" );
55
- PR_CACHE (& cpuinfo_arc700 [c ].dcache , CONFIG_ARC_HAS_DCACHE , "D-Cache" );
56
-
57
- p = & cpuinfo_arc700 [c ].slc ;
58
- if (p -> line_len )
59
- n += scnprintf (buf + n , len - n ,
60
- "SLC\t\t: %uK, %uB Line%s\n" ,
61
- p -> sz_k , p -> line_len , IS_USED_RUN (slc_enable ));
62
-
63
- n += scnprintf (buf + n , len - n , "Peripherals\t: %#lx%s%s\n" ,
64
- perip_base ,
65
- IS_AVAIL3 (ioc_exists , ioc_enable , ", IO-Coherency (per-device) " ));
66
-
67
- return buf ;
68
- }
69
-
70
- /*
71
- * Read the Cache Build Confuration Registers, Decode them and save into
72
- * the cpuinfo structure for later use.
73
- * No Validation done here, simply read/convert the BCRs
74
- */
75
- static void read_decode_cache_bcr_arcv2 (int cpu )
76
- {
77
- struct cpuinfo_arc_cache * p_slc = & cpuinfo_arc700 [cpu ].slc ;
44
+ struct cpuinfo_arc_cache * p_slc = & slc_info ;
45
+ struct bcr_identity ident ;
78
46
struct bcr_generic sbcr ;
79
-
80
- struct bcr_slc_cfg {
81
- #ifdef CONFIG_CPU_BIG_ENDIAN
82
- unsigned int pad :24 , way :2 , lsz :2 , sz :4 ;
83
- #else
84
- unsigned int sz :4 , lsz :2 , way :2 , pad :24 ;
85
- #endif
86
- } slc_cfg ;
87
-
88
- struct bcr_clust_cfg {
89
- #ifdef CONFIG_CPU_BIG_ENDIAN
90
- unsigned int pad :7 , c :1 , num_entries :8 , num_cores :8 , ver :8 ;
91
- #else
92
- unsigned int ver :8 , num_cores :8 , num_entries :8 , c :1 , pad :7 ;
93
- #endif
94
- } cbcr ;
95
-
96
- struct bcr_volatile {
97
- #ifdef CONFIG_CPU_BIG_ENDIAN
98
- unsigned int start :4 , limit :4 , pad :22 , order :1 , disable :1 ;
99
- #else
100
- unsigned int disable :1 , order :1 , pad :22 , limit :4 , start :4 ;
101
- #endif
102
- } vol ;
103
-
47
+ struct bcr_clust_cfg cbcr ;
48
+ struct bcr_volatile vol ;
49
+ int n = 0 ;
104
50
105
51
READ_BCR (ARC_REG_SLC_BCR , sbcr );
106
52
if (sbcr .ver ) {
53
+ struct bcr_slc_cfg slc_cfg ;
107
54
READ_BCR (ARC_REG_SLC_CFG , slc_cfg );
108
55
p_slc -> sz_k = 128 << slc_cfg .sz ;
109
56
l2_line_sz = p_slc -> line_len = (slc_cfg .lsz == 0 ) ? 128 : 64 ;
57
+ n += scnprintf (buf + n , len - n ,
58
+ "SLC\t\t: %uK, %uB Line%s\n" ,
59
+ p_slc -> sz_k , p_slc -> line_len , IS_USED_RUN (slc_enable ));
110
60
}
111
61
112
62
READ_BCR (ARC_REG_CLUSTER_BCR , cbcr );
@@ -129,70 +79,83 @@ static void read_decode_cache_bcr_arcv2(int cpu)
129
79
ioc_enable = 0 ;
130
80
}
131
81
82
+ READ_BCR (AUX_IDENTITY , ident );
83
+
132
84
/* HS 2.0 didn't have AUX_VOL */
133
- if (cpuinfo_arc700 [ cpu ]. core .family > 0x51 ) {
85
+ if (ident .family > 0x51 ) {
134
86
READ_BCR (AUX_VOL , vol );
135
87
perip_base = vol .start << 28 ;
136
88
/* HS 3.0 has limit and strict-ordering fields */
137
- if (cpuinfo_arc700 [ cpu ]. core .family > 0x52 )
89
+ if (ident .family > 0x52 )
138
90
perip_end = (vol .limit << 28 ) - 1 ;
139
91
}
92
+
93
+ n += scnprintf (buf + n , len - n , "Peripherals\t: %#lx%s%s\n" ,
94
+ perip_base ,
95
+ IS_AVAIL3 (ioc_exists , ioc_enable , ", IO-Coherency (per-device) " ));
96
+
97
+ return buf ;
140
98
}
141
99
142
- void read_decode_cache_bcr ( void )
100
+ char * arc_cache_mumbojumbo ( int c , char * buf , int len )
143
101
{
144
- struct cpuinfo_arc_cache * p_ic , * p_dc ;
145
- unsigned int cpu = smp_processor_id ();
146
- struct bcr_cache {
147
- #ifdef CONFIG_CPU_BIG_ENDIAN
148
- unsigned int pad :12 , line_len :4 , sz :4 , config :4 , ver :8 ;
149
- #else
150
- unsigned int ver :8 , config :4 , sz :4 , line_len :4 , pad :12 ;
151
- #endif
152
- } ibcr , dbcr ;
102
+ struct cpuinfo_arc_cache * p_ic = & ic_info , * p_dc = & dc_info ;
103
+ struct bcr_cache ibcr , dbcr ;
104
+ int vipt , assoc ;
105
+ int n = 0 ;
153
106
154
- p_ic = & cpuinfo_arc700 [cpu ].icache ;
155
107
READ_BCR (ARC_REG_IC_BCR , ibcr );
156
-
157
108
if (!ibcr .ver )
158
109
goto dc_chk ;
159
110
160
- if (ibcr .ver <= 3 ) {
111
+ if (is_isa_arcompact () && ( ibcr .ver <= 3 ) ) {
161
112
BUG_ON (ibcr .config != 3 );
162
- p_ic -> assoc = 2 ; /* Fixed to 2w set assoc */
163
- } else if (ibcr .ver >= 4 ) {
164
- p_ic -> assoc = 1 << ibcr .config ; /* 1,2,4,8 */
113
+ assoc = 2 ; /* Fixed to 2w set assoc */
114
+ } else if (is_isa_arcv2 () && ( ibcr .ver >= 4 ) ) {
115
+ assoc = 1 << ibcr .config ; /* 1,2,4,8 */
165
116
}
166
117
167
118
p_ic -> line_len = 8 << ibcr .line_len ;
168
119
p_ic -> sz_k = 1 << (ibcr .sz - 1 );
169
- p_ic -> vipt = 1 ;
170
- p_ic -> alias = p_ic -> sz_k /p_ic -> assoc /TO_KB (PAGE_SIZE ) > 1 ;
120
+ p_ic -> colors = p_ic -> sz_k /assoc /TO_KB (PAGE_SIZE );
121
+
122
+ n += scnprintf (buf + n , len - n ,
123
+ "I-Cache\t\t: %uK, %dway/set, %uB Line, VIPT%s%s\n" ,
124
+ p_ic -> sz_k , assoc , p_ic -> line_len ,
125
+ p_ic -> colors > 1 ? " aliasing" : "" ,
126
+ IS_USED_CFG (CONFIG_ARC_HAS_ICACHE ));
171
127
172
128
dc_chk :
173
- p_dc = & cpuinfo_arc700 [cpu ].dcache ;
174
129
READ_BCR (ARC_REG_DC_BCR , dbcr );
175
-
176
130
if (!dbcr .ver )
177
131
goto slc_chk ;
178
132
179
- if (dbcr .ver <= 3 ) {
133
+ if (is_isa_arcompact () && ( dbcr .ver <= 3 ) ) {
180
134
BUG_ON (dbcr .config != 2 );
181
- p_dc -> assoc = 4 ; /* Fixed to 4w set assoc */
182
- p_dc -> vipt = 1 ;
183
- p_dc -> alias = p_dc -> sz_k /p_dc -> assoc /TO_KB (PAGE_SIZE ) > 1 ;
184
- } else if (dbcr .ver >= 4 ) {
185
- p_dc -> assoc = 1 << dbcr . config ; /* 1,2,4,8 */
186
- p_dc -> vipt = 0 ;
187
- p_dc -> alias = 0 ; /* PIPT so can't VIPT alias */
135
+ vipt = 1 ;
136
+ assoc = 4 ; /* Fixed to 4w set assoc */
137
+ p_dc -> colors = p_dc -> sz_k /assoc /TO_KB (PAGE_SIZE );
138
+ } else if (is_isa_arcv2 () && ( dbcr .ver >= 4 ) ) {
139
+ vipt = 0 ;
140
+ assoc = 1 << dbcr . config ; /* 1,2,4,8 */
141
+ p_dc -> colors = 1 ; /* PIPT so can't VIPT alias */
188
142
}
189
143
190
144
p_dc -> line_len = 16 << dbcr .line_len ;
191
145
p_dc -> sz_k = 1 << (dbcr .sz - 1 );
192
146
147
+ n += scnprintf (buf + n , len - n ,
148
+ "D-Cache\t\t: %uK, %dway/set, %uB Line, %s%s%s\n" ,
149
+ p_dc -> sz_k , assoc , p_dc -> line_len ,
150
+ vipt ? "VIPT" : "PIPT" ,
151
+ p_dc -> colors > 1 ? " aliasing" : "" ,
152
+ IS_USED_CFG (CONFIG_ARC_HAS_DCACHE ));
153
+
193
154
slc_chk :
194
155
if (is_isa_arcv2 ())
195
- read_decode_cache_bcr_arcv2 (cpu );
156
+ read_decode_cache_bcr_arcv2 (c , buf + n , len - n );
157
+
158
+ return buf ;
196
159
}
197
160
198
161
/*
@@ -1133,10 +1096,8 @@ static noinline void __init arc_ioc_setup(void)
1133
1096
*/
1134
1097
static noinline void __init arc_cache_init_master (void )
1135
1098
{
1136
- unsigned int __maybe_unused cpu = smp_processor_id ();
1137
-
1138
1099
if (IS_ENABLED (CONFIG_ARC_HAS_ICACHE )) {
1139
- struct cpuinfo_arc_cache * ic = & cpuinfo_arc700 [ cpu ]. icache ;
1100
+ struct cpuinfo_arc_cache * ic = & ic_info ;
1140
1101
1141
1102
if (!ic -> line_len )
1142
1103
panic ("cache support enabled but non-existent cache\n" );
@@ -1149,14 +1110,14 @@ static noinline void __init arc_cache_init_master(void)
1149
1110
* In MMU v4 (HS38x) the aliasing icache config uses IVIL/PTAG
1150
1111
* pair to provide vaddr/paddr respectively, just as in MMU v3
1151
1112
*/
1152
- if (is_isa_arcv2 () && ic -> alias )
1113
+ if (is_isa_arcv2 () && ic -> colors > 1 )
1153
1114
_cache_line_loop_ic_fn = __cache_line_loop_v3 ;
1154
1115
else
1155
1116
_cache_line_loop_ic_fn = __cache_line_loop ;
1156
1117
}
1157
1118
1158
1119
if (IS_ENABLED (CONFIG_ARC_HAS_DCACHE )) {
1159
- struct cpuinfo_arc_cache * dc = & cpuinfo_arc700 [ cpu ]. dcache ;
1120
+ struct cpuinfo_arc_cache * dc = & dc_info ;
1160
1121
1161
1122
if (!dc -> line_len )
1162
1123
panic ("cache support enabled but non-existent cache\n" );
@@ -1168,14 +1129,13 @@ static noinline void __init arc_cache_init_master(void)
1168
1129
/* check for D-Cache aliasing on ARCompact: ARCv2 has PIPT */
1169
1130
if (is_isa_arcompact ()) {
1170
1131
int handled = IS_ENABLED (CONFIG_ARC_CACHE_VIPT_ALIASING );
1171
- int num_colors = dc -> sz_k /dc -> assoc /TO_KB (PAGE_SIZE );
1172
1132
1173
- if (dc -> alias ) {
1133
+ if (dc -> colors > 1 ) {
1174
1134
if (!handled )
1175
1135
panic ("Enable CONFIG_ARC_CACHE_VIPT_ALIASING\n" );
1176
- if (CACHE_COLORS_NUM != num_colors )
1136
+ if (CACHE_COLORS_NUM != dc -> colors )
1177
1137
panic ("CACHE_COLORS_NUM not optimized for config\n" );
1178
- } else if (! dc -> alias && handled ) {
1138
+ } else if (handled && dc -> colors == 1 ) {
1179
1139
panic ("Disable CONFIG_ARC_CACHE_VIPT_ALIASING\n" );
1180
1140
}
1181
1141
}
@@ -1218,9 +1178,6 @@ static noinline void __init arc_cache_init_master(void)
1218
1178
void __ref arc_cache_init (void )
1219
1179
{
1220
1180
unsigned int __maybe_unused cpu = smp_processor_id ();
1221
- char str [256 ];
1222
-
1223
- pr_info ("%s" , arc_cache_mumbojumbo (0 , str , sizeof (str )));
1224
1181
1225
1182
if (!cpu )
1226
1183
arc_cache_init_master ();
0 commit comments