Patrick Rudolph has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/48691 )
Change subject: soc/intel/common/block/acpi: Fix get_cores_per_package ......................................................................
soc/intel/common/block/acpi: Fix get_cores_per_package
Current implementation uses CPUID 0Bh function that returns the number of logical cores of requested level. The problem with this approach is that this value doesn't change when HyperThreading is disabled (it's in the Intel docs), so it breaks generate_cpu_entries().
- Use MSR 0x35 instead, which returns the correct number of logical processors with and without HT.
- Rename the function to get_logical_cores_per_package, which is more accurate.
Tested on Prodrive Hermes, the ACPI code is now generated even with HyperThreading disabled.
Change-Id: Id9b985a07cd3f99a823622f766c80ff240ac1188 Signed-off-by: Patrick Rudolph patrick.rudolph@9elements.com --- M src/soc/intel/common/block/acpi/acpi.c 1 file changed, 7 insertions(+), 15 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/91/48691/1
diff --git a/src/soc/intel/common/block/acpi/acpi.c b/src/soc/intel/common/block/acpi/acpi.c index d2177294..f25cb1d 100644 --- a/src/soc/intel/common/block/acpi/acpi.c +++ b/src/soc/intel/common/block/acpi/acpi.c @@ -12,6 +12,7 @@ #include <cpu/intel/turbo.h> #include <cpu/intel/common/common.h> #include <cpu/x86/smm.h> +#include <cpu/x86/msr.h> #include <intelblocks/acpi.h> #include <intelblocks/lpc_lib.h> #include <intelblocks/msr.h> @@ -263,20 +264,11 @@ return power; }
-static int get_cores_per_package(void) +static int get_logical_cores_per_package(void) { - struct cpuinfo_x86 c; - struct cpuid_result result; - int cores = 1; - - get_fms(&c, cpuid_eax(1)); - if (c.x86 != 6) - return 1; - - result = cpuid_ext(0xb, 1); - cores = result.ebx & 0xff; - - return cores; + msr_t msr = rdmsr(MSR_CORE_THREAD_COUNT); + /* Note: SDM is wrong, this is correct */ + return msr.lo & 0xffff; }
static void generate_c_state_entries(void) @@ -429,10 +421,10 @@ int core_id, cpu_id, pcontrol_blk = ACPI_BASE_ADDRESS; int plen = 6; int totalcores = dev_count_cpu(); - int cores_per_package = get_cores_per_package(); + int cores_per_package = get_logical_cores_per_package(); int numcpus = totalcores / cores_per_package;
- printk(BIOS_DEBUG, "Found %d CPU(s) with %d core(s) each.\n", + printk(BIOS_DEBUG, "Found %d CPU(s) with %d logical core(s) each.\n", numcpus, cores_per_package);
for (cpu_id = 0; cpu_id < numcpus; cpu_id++) {