]> git.ipfire.org Git - thirdparty/linux.git/commit
x86/cpu/cacheinfo: Simplify cacheinfo_amd_init_llc_id() using _cpuid4_info
authorK Prateek Nayak <kprateek.nayak@amd.com>
Thu, 21 Aug 2025 05:19:09 +0000 (05:19 +0000)
committerIngo Molnar <mingo@kernel.org>
Wed, 17 Sep 2025 09:22:40 +0000 (11:22 +0200)
commitaf507c6951180ae5e5edb71f56a227ffdcc54f78
tree71037cd602ffd64836289da3f3aeda42bc812e41
parent70d1d98934e723b9e463283a542b88f4f009ae82
x86/cpu/cacheinfo: Simplify cacheinfo_amd_init_llc_id() using _cpuid4_info

struct _cpuid4_info has the same layout as the CPUID leaf 0x8000001d.
Use the encoded definition and amd_fill_cpuid4_info(), get_cache_id()
helpers instead of open coding masks and shifts to calculate the llc_id.

cacheinfo_amd_init_llc_id() is only called on AMD systems that support
X86_FEATURE_TOPOEXT and amd_fill_cpuid4_info() uses the information from
CPUID leaf 0x8000001d on all these systems which is consistent with the
current open coded implementation.

While at it, avoid reading  cpu_data() every time get_cache_id() is
called and instead pass the APIC ID necessary to return the
_cpuid4_info.id from get_cache_id().

No functional changes intended.

  [ bp: do what Ahmed suggests: merge into one patch, make id4 ptr
    const. ]

Signed-off-by: K Prateek Nayak <kprateek.nayak@amd.com>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Acked-by: Ahmed S. Darwish <darwi@linutronix.de>
Link: https://lore.kernel.org/20250821051910.7351-2-kprateek.nayak@amd.com
arch/x86/kernel/cpu/cacheinfo.c