]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
x86/cacheinfo: Relocate CPUID leaf 0x4 cache_type mapping
authorAhmed S. Darwish <darwi@linutronix.de>
Mon, 24 Mar 2025 13:33:22 +0000 (14:33 +0100)
committerIngo Molnar <mingo@kernel.org>
Tue, 25 Mar 2025 09:23:27 +0000 (10:23 +0100)
The cache_type_map[] array is used to map Intel leaf 0x4 cache_type
values to their corresponding types at <linux/cacheinfo.h>.

Move that array's definition after the actual CPUID leaf 0x4 structures,
instead of having it in the middle of AMD leaf 0x4 emulation code.

Signed-off-by: Ahmed S. Darwish <darwi@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Link: https://lore.kernel.org/r/20250324133324.23458-28-darwi@linutronix.de
arch/x86/kernel/cpu/cacheinfo.c

index 231470cdc1da0baa539f7fecd5c3d09d8c7531ab..e0d531e27ff37303863ddd7aa4ac0096483d2cea 100644 (file)
@@ -78,6 +78,14 @@ struct _cpuid4_info {
        unsigned long size;
 };
 
+/* Map CPUID(4) EAX.cache_type to linux/cacheinfo.h types */
+static const enum cache_type cache_type_map[] = {
+       [CTYPE_NULL]    = CACHE_TYPE_NOCACHE,
+       [CTYPE_DATA]    = CACHE_TYPE_DATA,
+       [CTYPE_INST]    = CACHE_TYPE_INST,
+       [CTYPE_UNIFIED] = CACHE_TYPE_UNIFIED,
+};
+
 /*
  * Fallback AMD CPUID(4) emulation
  * AMD CPUs with TOPOEXT can just use CPUID(0x8000001d)
@@ -131,13 +139,6 @@ static const unsigned short assocs[] = {
 static const unsigned char levels[] = { 1, 1, 2, 3 };
 static const unsigned char types[] = { 1, 2, 3, 3 };
 
-static const enum cache_type cache_type_map[] = {
-       [CTYPE_NULL] = CACHE_TYPE_NOCACHE,
-       [CTYPE_DATA] = CACHE_TYPE_DATA,
-       [CTYPE_INST] = CACHE_TYPE_INST,
-       [CTYPE_UNIFIED] = CACHE_TYPE_UNIFIED,
-};
-
 static void legacy_amd_cpuid4(int index, union _cpuid4_leaf_eax *eax,
                              union _cpuid4_leaf_ebx *ebx, union _cpuid4_leaf_ecx *ecx)
 {