[PATCH v7 103/120] x86/cpu: amd/hygon: Use parsed CPUID(0x80000007)
"Ahmed S. Darwish" <[email protected]> Thu, 28 May 2026 17:39:05 +0200
| Newsgroups | dev.linux.lists.x86-cpuid,org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <[email protected]> |
Use parsed CPUID(0x80000007) instead of doing ugly bitwise operations on cpuinfo_x86::x86_power. The latter is backed by a direct CPUID query and will be later removed. Signed-off-by: Ahmed S. Darwish <[email protected]> --- arch/x86/kernel/cpu/amd.c | 25 +++++++++++-------------- arch/x86/kernel/cpu/hygon.c | 25 +++++++++++-------------- 2 files changed, 22 insertions(+), 28 deletions(-) diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c index 5f885fafa238..0b5d8d0c3d29 100644 --- a/arch/x86/kernel/cpu/amd.c +++ b/arch/x86/kernel/cpu/amd.c @@ -612,6 +612,7 @@ static void early_detect_mem_encrypt(struct cpuinfo_x86 *c) static void early_init_amd(struct cpuinfo_x86 *c) { + const struct leaf_0x80000007_0 *el7 = cpuid_leaf(c, 0x80000007); u32 dummy; if (c->x86 >= 0xf) @@ -619,22 +620,18 @@ static void early_init_amd(struct cpuinfo_x86 *c) rdmsr_safe(MSR_AMD64_PATCH_LEVEL, &c->microcode, &dummy); - /* - * c->x86_power is 8000_0007 edx. Bit 8 is TSC runs at constant rate - * with P/T states and does not stop in deep C-states - */ - if (c->x86_power & (1 << 8)) { - set_cpu_cap(c, X86_FEATURE_CONSTANT_TSC); - set_cpu_cap(c, X86_FEATURE_NONSTOP_TSC); - } + if (el7) { + if (el7->constant_tsc) { + set_cpu_cap(c, X86_FEATURE_CONSTANT_TSC); + set_cpu_cap(c, X86_FEATURE_NONSTOP_TSC); + } - /* Bit 12 of 8000_0007 edx is accumulated power mechanism. */ - if (c->x86_power & BIT(12)) - set_cpu_cap(c, X86_FEATURE_ACC_POWER); + if (el7->proc_power_reporting) + set_cpu_cap(c, X86_FEATURE_ACC_POWER); - /* Bit 14 indicates the Runtime Average Power Limit interface. */ - if (c->x86_power & BIT(14)) - set_cpu_cap(c, X86_FEATURE_RAPL); + if (el7->rapl_interface) + set_cpu_cap(c, X86_FEATURE_RAPL); + } #ifdef CONFIG_X86_64 set_cpu_cap(c, X86_FEATURE_SYSCALL32); diff --git a/arch/x86/kernel/cpu/hygon.c b/arch/x86/kernel/cpu/hygon.c index 4a63538c2b3f..8f31005bc802 100644 --- a/arch/x86/kernel/cpu/hygon.c +++ b/arch/x86/kernel/cpu/hygon.c @@ -125,28 +125,25 @@ static void bsp_init_hygon(struct cpuinfo_x86 *c) static void early_init_hygon(struct cpuinfo_x86 *c) { + const struct leaf_0x80000007_0 *el7 = cpuid_leaf(c, 0x80000007); u32 dummy; set_cpu_cap(c, X86_FEATURE_K8); rdmsr_safe(MSR_AMD64_PATCH_LEVEL, &c->microcode, &dummy); - /* - * c->x86_power is 8000_0007 edx. Bit 8 is TSC runs at constant rate - * with P/T states and does not stop in deep C-states - */ - if (c->x86_power & (1 << 8)) { - set_cpu_cap(c, X86_FEATURE_CONSTANT_TSC); - set_cpu_cap(c, X86_FEATURE_NONSTOP_TSC); - } + if (el7) { + if (el7->constant_tsc) { + set_cpu_cap(c, X86_FEATURE_CONSTANT_TSC); + set_cpu_cap(c, X86_FEATURE_NONSTOP_TSC); + } - /* Bit 12 of 8000_0007 edx is accumulated power mechanism. */ - if (c->x86_power & BIT(12)) - set_cpu_cap(c, X86_FEATURE_ACC_POWER); + if (el7->proc_power_reporting) + set_cpu_cap(c, X86_FEATURE_ACC_POWER); - /* Bit 14 indicates the Runtime Average Power Limit interface. */ - if (c->x86_power & BIT(14)) - set_cpu_cap(c, X86_FEATURE_RAPL); + if (el7->rapl_interface) + set_cpu_cap(c, X86_FEATURE_RAPL); + } #ifdef CONFIG_X86_64 set_cpu_cap(c, X86_FEATURE_SYSCALL32); -- 2.54.0