MIPS: cpu-features: Enable octeon_cache by cpu_type
authorJiaxun Yang <jiaxun.yang@flygoat.com>
Tue, 4 Apr 2023 09:33:44 +0000 (10:33 +0100)
committerThomas Bogendoerfer <tsbogend@alpha.franken.de>
Wed, 5 Apr 2023 07:45:09 +0000 (09:45 +0200)
cpu_has_octeon_cache was tied to 0 for generic cpu-features,
whith this generic kernel built for octeon CPU won't boot.

Just enable this flag by cpu_type. It won't hurt orther platforms
because compiler will eliminate the code path on other processors.

Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
arch/mips/include/asm/cpu-features.h

index c613426..51a1737 100644 (file)
 #define cpu_has_4k_cache       __opt(MIPS_CPU_4K_CACHE)
 #endif
 #ifndef cpu_has_octeon_cache
-#define cpu_has_octeon_cache   0
+#define cpu_has_octeon_cache                                           \
+({                                                                     \
+       int __res;                                                      \
+                                                                       \
+       switch (current_cpu_type()) {                                   \
+       case CPU_CAVIUM_OCTEON:                                         \
+       case CPU_CAVIUM_OCTEON_PLUS:                                    \
+       case CPU_CAVIUM_OCTEON2:                                        \
+       case CPU_CAVIUM_OCTEON3:                                        \
+               __res = 1;                                              \
+               break;                                                  \
+                                                                       \
+       default:                                                        \
+               __res = 0;                                              \
+       }                                                               \
+                                                                       \
+       __res;                                                          \
+})
 #endif
 /* Don't override `cpu_has_fpu' to 1 or the "nofpu" option won't work.  */
 #ifndef cpu_has_fpu