[PATCH v7 032/120] x86/cacheinfo: Pass a 'struct cpuinfo_x86' reference to CPUID(0x4) code
"Ahmed S. Darwish" <[email protected]> Thu, 28 May 2026 17:37:54 +0200
| Newsgroups | dev.linux.lists.x86-cpuid,org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <[email protected]> |
Prepare the CPUID(0x4) cache topology code for using the parsed CPUID API instead of invoking direct CPUID queries. Since the CPUID API requires a 'struct cpuinfo_x86' reference, trickle it from <linux/cacheinfo.h>'s populate_cache_leaves() x86 implementation down to fill_cpuid4_info() and its Intel-specific CPUID(0x4) code. No functional change intended. Suggested-by: Ingo Molnar <[email protected]> Signed-off-by: Ahmed S. Darwish <[email protected]> Link: https://lore.kernel.org/lkml/[email protected] --- arch/x86/kernel/cpu/cacheinfo.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/arch/x86/kernel/cpu/cacheinfo.c b/arch/x86/kernel/cpu/cacheinfo.c index d933d58a5a61..07f7e7b667ed 100644 --- a/arch/x86/kernel/cpu/cacheinfo.c +++ b/arch/x86/kernel/cpu/cacheinfo.c @@ -252,7 +252,7 @@ static int amd_fill_cpuid4_info(int index, struct _cpuid4_info *id4) return cpuid4_info_fill_done(id4, eax, ebx, ecx); } -static int intel_fill_cpuid4_info(int index, struct _cpuid4_info *id4) +static int intel_fill_cpuid4_info(struct cpuinfo_x86 *unused, int index, struct _cpuid4_info *id4) { union _cpuid4_leaf_eax eax; union _cpuid4_leaf_ebx ebx; @@ -264,13 +264,13 @@ static int intel_fill_cpuid4_info(int index, struct _cpuid4_info *id4) return cpuid4_info_fill_done(id4, eax, ebx, ecx); } -static int fill_cpuid4_info(int index, struct _cpuid4_info *id4) +static int fill_cpuid4_info(struct cpuinfo_x86 *c, int index, struct _cpuid4_info *id4) { u8 cpu_vendor = boot_cpu_data.x86_vendor; return (cpu_vendor == X86_VENDOR_AMD || cpu_vendor == X86_VENDOR_HYGON) ? amd_fill_cpuid4_info(index, id4) : - intel_fill_cpuid4_info(index, id4); + intel_fill_cpuid4_info(c, index, id4); } static int find_num_cache_leaves(struct cpuinfo_x86 *c) @@ -443,7 +443,7 @@ static bool intel_cacheinfo_0x4(struct cpuinfo_x86 *c) struct _cpuid4_info id4 = {}; int ret; - ret = intel_fill_cpuid4_info(i, &id4); + ret = intel_fill_cpuid4_info(c, i, &id4); if (ret < 0) continue; @@ -612,17 +612,17 @@ int populate_cache_leaves(unsigned int cpu) struct cpu_cacheinfo *this_cpu_ci = get_cpu_cacheinfo(cpu); struct cacheinfo *ci = this_cpu_ci->info_list; u8 cpu_vendor = boot_cpu_data.x86_vendor; - u32 apicid = cpu_data(cpu).topo.apicid; + struct cpuinfo_x86 *c = &cpu_data(cpu); struct amd_northbridge *nb = NULL; struct _cpuid4_info id4 = {}; int idx, ret; for (idx = 0; idx < this_cpu_ci->num_leaves; idx++) { - ret = fill_cpuid4_info(idx, &id4); + ret = fill_cpuid4_info(c, idx, &id4); if (ret) return ret; - id4.id = get_cache_id(apicid, &id4); + id4.id = get_cache_id(c->topo.apicid, &id4); if (cpu_vendor == X86_VENDOR_AMD || cpu_vendor == X86_VENDOR_HYGON) nb = amd_init_l3_cache(idx); -- 2.54.0