hc
2024-05-10 cde9070d9970eef1f7ec2360586c802a16230ad8
kernel/arch/mips/include/asm/cpu-features.h
....@@ -15,6 +15,7 @@
1515 #include <cpu-feature-overrides.h>
1616
1717 #define __ase(ase) (cpu_data[0].ases & (ase))
18
+#define __isa(isa) (cpu_data[0].isa_level & (isa))
1819 #define __opt(opt) (cpu_data[0].options & (opt))
1920
2021 /*
....@@ -51,6 +52,20 @@
5152 */
5253 #define __isa_lt_and_ase(isa, ase) ((MIPS_ISA_REV < (isa)) && __ase(ase))
5354 #define __isa_lt_and_opt(isa, opt) ((MIPS_ISA_REV < (isa)) && __opt(opt))
55
+
56
+/*
57
+ * Similarly allow for ISA level checks that take into account knowledge of the
58
+ * ISA targeted by the kernel build, provided by MIPS_ISA_REV.
59
+ */
60
+#define __isa_ge_and_flag(isa, flag) ((MIPS_ISA_REV >= (isa)) && __isa(flag))
61
+#define __isa_ge_or_flag(isa, flag) ((MIPS_ISA_REV >= (isa)) || __isa(flag))
62
+#define __isa_lt_and_flag(isa, flag) ((MIPS_ISA_REV < (isa)) && __isa(flag))
63
+#define __isa_range(ge, lt) \
64
+ ((MIPS_ISA_REV >= (ge)) && (MIPS_ISA_REV < (lt)))
65
+#define __isa_range_or_flag(ge, lt, flag) \
66
+ (__isa_range(ge, lt) || ((MIPS_ISA_REV < (lt)) && __isa(flag)))
67
+#define __isa_range_and_ase(ge, lt, ase) \
68
+ (__isa_range(ge, lt) && __ase(ase))
5469
5570 /*
5671 * SMP assumption: Options of CPU 0 are a superset of all processors.
....@@ -111,14 +126,36 @@
111126 #define cpu_has_tx39_cache __opt(MIPS_CPU_TX39_CACHE)
112127 #endif
113128 #ifndef cpu_has_octeon_cache
114
-#define cpu_has_octeon_cache 0
129
+#define cpu_has_octeon_cache \
130
+({ \
131
+ int __res; \
132
+ \
133
+ switch (boot_cpu_type()) { \
134
+ case CPU_CAVIUM_OCTEON: \
135
+ case CPU_CAVIUM_OCTEON_PLUS: \
136
+ case CPU_CAVIUM_OCTEON2: \
137
+ case CPU_CAVIUM_OCTEON3: \
138
+ __res = 1; \
139
+ break; \
140
+ \
141
+ default: \
142
+ __res = 0; \
143
+ } \
144
+ \
145
+ __res; \
146
+})
115147 #endif
116148 /* Don't override `cpu_has_fpu' to 1 or the "nofpu" option won't work. */
117149 #ifndef cpu_has_fpu
118
-#define cpu_has_fpu (current_cpu_data.options & MIPS_CPU_FPU)
119
-#define raw_cpu_has_fpu (raw_current_cpu_data.options & MIPS_CPU_FPU)
150
+# ifdef CONFIG_MIPS_FP_SUPPORT
151
+# define cpu_has_fpu (current_cpu_data.options & MIPS_CPU_FPU)
152
+# define raw_cpu_has_fpu (raw_current_cpu_data.options & MIPS_CPU_FPU)
153
+# else
154
+# define cpu_has_fpu 0
155
+# define raw_cpu_has_fpu 0
156
+# endif
120157 #else
121
-#define raw_cpu_has_fpu cpu_has_fpu
158
+# define raw_cpu_has_fpu cpu_has_fpu
122159 #endif
123160 #ifndef cpu_has_32fpr
124161 #define cpu_has_32fpr __isa_ge_or_opt(1, MIPS_CPU_32FPR)
....@@ -152,9 +189,6 @@
152189 #endif
153190 #ifndef cpu_has_llsc
154191 #define cpu_has_llsc __isa_ge_or_opt(1, MIPS_CPU_LLSC)
155
-#endif
156
-#ifndef cpu_has_bp_ghist
157
-#define cpu_has_bp_ghist __opt(MIPS_CPU_BP_GHIST)
158192 #endif
159193 #ifndef kernel_uses_llsc
160194 #define kernel_uses_llsc cpu_has_llsc
....@@ -195,7 +229,9 @@
195229 #endif
196230
197231 #ifndef cpu_has_mmips
198
-# ifdef CONFIG_SYS_SUPPORTS_MICROMIPS
232
+# if defined(__mips_micromips)
233
+# define cpu_has_mmips 1
234
+# elif defined(CONFIG_SYS_SUPPORTS_MICROMIPS)
199235 # define cpu_has_mmips __opt(MIPS_CPU_MICROMIPS)
200236 # else
201237 # define cpu_has_mmips 0
....@@ -223,9 +259,6 @@
223259 #ifndef cpu_has_pindexed_dcache
224260 #define cpu_has_pindexed_dcache (cpu_data[0].dcache.flags & MIPS_CACHE_PINDEX)
225261 #endif
226
-#ifndef cpu_has_local_ebase
227
-#define cpu_has_local_ebase 1
228
-#endif
229262
230263 /*
231264 * I-Cache snoops remote store. This only matters on SMP. Some multiprocessors
....@@ -246,48 +279,47 @@
246279 #endif
247280 #endif
248281
249
-/* __builtin_constant_p(cpu_has_mips_r) && cpu_has_mips_r */
250
-#if !((defined(cpu_has_mips32r1) && cpu_has_mips32r1) || \
251
- (defined(cpu_has_mips32r2) && cpu_has_mips32r2) || \
252
- (defined(cpu_has_mips32r6) && cpu_has_mips32r6) || \
253
- (defined(cpu_has_mips64r1) && cpu_has_mips64r1) || \
254
- (defined(cpu_has_mips64r2) && cpu_has_mips64r2) || \
255
- (defined(cpu_has_mips64r6) && cpu_has_mips64r6))
256
-#define CPU_NO_EFFICIENT_FFS 1
257
-#endif
258
-
259282 #ifndef cpu_has_mips_1
260
-# define cpu_has_mips_1 (!cpu_has_mips_r6)
283
+# define cpu_has_mips_1 (MIPS_ISA_REV < 6)
261284 #endif
262285 #ifndef cpu_has_mips_2
263
-# define cpu_has_mips_2 (cpu_data[0].isa_level & MIPS_CPU_ISA_II)
286
+# define cpu_has_mips_2 __isa_lt_and_flag(6, MIPS_CPU_ISA_II)
264287 #endif
265288 #ifndef cpu_has_mips_3
266
-# define cpu_has_mips_3 (cpu_data[0].isa_level & MIPS_CPU_ISA_III)
289
+# define cpu_has_mips_3 __isa_lt_and_flag(6, MIPS_CPU_ISA_III)
267290 #endif
268291 #ifndef cpu_has_mips_4
269
-# define cpu_has_mips_4 (cpu_data[0].isa_level & MIPS_CPU_ISA_IV)
292
+# define cpu_has_mips_4 __isa_lt_and_flag(6, MIPS_CPU_ISA_IV)
270293 #endif
271294 #ifndef cpu_has_mips_5
272
-# define cpu_has_mips_5 (cpu_data[0].isa_level & MIPS_CPU_ISA_V)
295
+# define cpu_has_mips_5 __isa_lt_and_flag(6, MIPS_CPU_ISA_V)
273296 #endif
274297 #ifndef cpu_has_mips32r1
275
-# define cpu_has_mips32r1 (cpu_data[0].isa_level & MIPS_CPU_ISA_M32R1)
298
+# define cpu_has_mips32r1 __isa_range_or_flag(1, 6, MIPS_CPU_ISA_M32R1)
276299 #endif
277300 #ifndef cpu_has_mips32r2
278
-# define cpu_has_mips32r2 (cpu_data[0].isa_level & MIPS_CPU_ISA_M32R2)
301
+# define cpu_has_mips32r2 __isa_range_or_flag(2, 6, MIPS_CPU_ISA_M32R2)
302
+#endif
303
+#ifndef cpu_has_mips32r5
304
+# define cpu_has_mips32r5 __isa_range_or_flag(5, 6, MIPS_CPU_ISA_M32R5)
279305 #endif
280306 #ifndef cpu_has_mips32r6
281
-# define cpu_has_mips32r6 (cpu_data[0].isa_level & MIPS_CPU_ISA_M32R6)
307
+# define cpu_has_mips32r6 __isa_ge_or_flag(6, MIPS_CPU_ISA_M32R6)
282308 #endif
283309 #ifndef cpu_has_mips64r1
284
-# define cpu_has_mips64r1 (cpu_data[0].isa_level & MIPS_CPU_ISA_M64R1)
310
+# define cpu_has_mips64r1 (cpu_has_64bits && \
311
+ __isa_range_or_flag(1, 6, MIPS_CPU_ISA_M64R1))
285312 #endif
286313 #ifndef cpu_has_mips64r2
287
-# define cpu_has_mips64r2 (cpu_data[0].isa_level & MIPS_CPU_ISA_M64R2)
314
+# define cpu_has_mips64r2 (cpu_has_64bits && \
315
+ __isa_range_or_flag(2, 6, MIPS_CPU_ISA_M64R2))
316
+#endif
317
+#ifndef cpu_has_mips64r5
318
+# define cpu_has_mips64r5 (cpu_has_64bits && \
319
+ __isa_range_or_flag(5, 6, MIPS_CPU_ISA_M64R5))
288320 #endif
289321 #ifndef cpu_has_mips64r6
290
-# define cpu_has_mips64r6 (cpu_data[0].isa_level & MIPS_CPU_ISA_M64R6)
322
+# define cpu_has_mips64r6 __isa_ge_and_flag(6, MIPS_CPU_ISA_M64R6)
291323 #endif
292324
293325 /*
....@@ -306,19 +338,25 @@
306338 (cpu_has_mips_3 | cpu_has_mips_4_5_64_r2_r6)
307339 #define cpu_has_mips_4_5_64_r2_r6 \
308340 (cpu_has_mips_4_5 | cpu_has_mips64r1 | \
309
- cpu_has_mips_r2 | cpu_has_mips_r6)
341
+ cpu_has_mips_r2 | cpu_has_mips_r5 | \
342
+ cpu_has_mips_r6)
310343
311
-#define cpu_has_mips32 (cpu_has_mips32r1 | cpu_has_mips32r2 | cpu_has_mips32r6)
312
-#define cpu_has_mips64 (cpu_has_mips64r1 | cpu_has_mips64r2 | cpu_has_mips64r6)
344
+#define cpu_has_mips32 (cpu_has_mips32r1 | cpu_has_mips32r2 | \
345
+ cpu_has_mips32r5 | cpu_has_mips32r6)
346
+#define cpu_has_mips64 (cpu_has_mips64r1 | cpu_has_mips64r2 | \
347
+ cpu_has_mips64r5 | cpu_has_mips64r6)
313348 #define cpu_has_mips_r1 (cpu_has_mips32r1 | cpu_has_mips64r1)
314349 #define cpu_has_mips_r2 (cpu_has_mips32r2 | cpu_has_mips64r2)
350
+#define cpu_has_mips_r5 (cpu_has_mips32r5 | cpu_has_mips64r5)
315351 #define cpu_has_mips_r6 (cpu_has_mips32r6 | cpu_has_mips64r6)
316352 #define cpu_has_mips_r (cpu_has_mips32r1 | cpu_has_mips32r2 | \
317
- cpu_has_mips32r6 | cpu_has_mips64r1 | \
318
- cpu_has_mips64r2 | cpu_has_mips64r6)
353
+ cpu_has_mips32r5 | cpu_has_mips32r6 | \
354
+ cpu_has_mips64r1 | cpu_has_mips64r2 | \
355
+ cpu_has_mips64r5 | cpu_has_mips64r6)
319356
320
-/* MIPSR2 and MIPSR6 have a lot of similarities */
321
-#define cpu_has_mips_r2_r6 (cpu_has_mips_r2 | cpu_has_mips_r6)
357
+/* MIPSR2 - MIPSR6 have a lot of similarities */
358
+#define cpu_has_mips_r2_r6 (cpu_has_mips_r2 | cpu_has_mips_r5 | \
359
+ cpu_has_mips_r6)
322360
323361 /*
324362 * cpu_has_mips_r2_exec_hazard - return if IHB is required on current processor
....@@ -332,7 +370,7 @@
332370 ({ \
333371 int __res; \
334372 \
335
- switch (current_cpu_type()) { \
373
+ switch (boot_cpu_type()) { \
336374 case CPU_M14KC: \
337375 case CPU_74K: \
338376 case CPU_1074K: \
....@@ -404,7 +442,7 @@
404442 #endif
405443
406444 #ifndef cpu_has_mipsmt
407
-#define cpu_has_mipsmt __isa_lt_and_ase(6, MIPS_ASE_MIPSMT)
445
+#define cpu_has_mipsmt __isa_range_and_ase(2, 6, MIPS_ASE_MIPSMT)
408446 #endif
409447
410448 #ifndef cpu_has_vp
....@@ -428,9 +466,6 @@
428466 # ifndef cpu_has_64bit_gp_regs
429467 # define cpu_has_64bit_gp_regs 0
430468 # endif
431
-# ifndef cpu_has_64bit_addresses
432
-# define cpu_has_64bit_addresses 0
433
-# endif
434469 # ifndef cpu_vmbits
435470 # define cpu_vmbits 31
436471 # endif
....@@ -448,9 +483,6 @@
448483 # endif
449484 # ifndef cpu_has_64bit_gp_regs
450485 # define cpu_has_64bit_gp_regs 1
451
-# endif
452
-# ifndef cpu_has_64bit_addresses
453
-# define cpu_has_64bit_addresses 1
454486 # endif
455487 # ifndef cpu_vmbits
456488 # define cpu_vmbits cpu_data[0].vmbits
....@@ -548,6 +580,18 @@
548580 # define cpu_has_perf __opt(MIPS_CPU_PERF)
549581 #endif
550582
583
+#ifndef cpu_has_mac2008_only
584
+# define cpu_has_mac2008_only __opt(MIPS_CPU_MAC_2008_ONLY)
585
+#endif
586
+
587
+#ifndef cpu_has_ftlbparex
588
+# define cpu_has_ftlbparex __opt(MIPS_CPU_FTLBPAREX)
589
+#endif
590
+
591
+#ifndef cpu_has_gsexcex
592
+# define cpu_has_gsexcex __opt(MIPS_CPU_GSEXCEX)
593
+#endif
594
+
551595 #ifdef CONFIG_SMP
552596 /*
553597 * Some systems share FTLB RAMs between threads within a core (siblings in
....@@ -597,6 +641,27 @@
597641 #endif /* CONFIG_MIPS_MT_SMP */
598642
599643 /*
644
+ * We only enable MMID support for configurations which natively support 64 bit
645
+ * atomics because getting good performance from the allocator relies upon
646
+ * efficient atomic64_*() functions.
647
+ */
648
+#ifndef cpu_has_mmid
649
+# ifdef CONFIG_GENERIC_ATOMIC64
650
+# define cpu_has_mmid 0
651
+# else
652
+# define cpu_has_mmid __isa_ge_and_opt(6, MIPS_CPU_MMID)
653
+# endif
654
+#endif
655
+
656
+#ifndef cpu_has_mm_sysad
657
+# define cpu_has_mm_sysad __opt(MIPS_CPU_MM_SYSAD)
658
+#endif
659
+
660
+#ifndef cpu_has_mm_full
661
+# define cpu_has_mm_full __opt(MIPS_CPU_MM_FULL)
662
+#endif
663
+
664
+/*
600665 * Guest capabilities
601666 */
602667 #ifndef cpu_guest_has_conf1
....@@ -641,6 +706,9 @@
641706 #ifndef cpu_guest_has_htw
642707 #define cpu_guest_has_htw (cpu_data[0].guest.options & MIPS_CPU_HTW)
643708 #endif
709
+#ifndef cpu_guest_has_ldpte
710
+#define cpu_guest_has_ldpte (cpu_data[0].guest.options & MIPS_CPU_LDPTE)
711
+#endif
644712 #ifndef cpu_guest_has_mvh
645713 #define cpu_guest_has_mvh (cpu_data[0].guest.options & MIPS_CPU_MVH)
646714 #endif