summaryrefslogtreecommitdiff
path: root/src/soc/intel
diff options
context:
space:
mode:
authorPatrick Rudolph <patrick.rudolph@9elements.com>2020-12-17 14:42:29 +0100
committerTim Wawrzynczak <twawrzynczak@chromium.org>2020-12-22 22:22:21 +0000
commit7a66ffb34aba44453c5a7fea75aff4d58322e94d (patch)
tree002daa79525d3a3c810c02e4f3cfe98e8c2ea1a8 /src/soc/intel
parent8d127846bc944fb416689ca1c93fd24f487f0bee (diff)
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() because `numcpus` ends up being zero due to integer division truncation. - Use MSR 0x35 instead, which returns the correct number of logical processors with and without HT. - Use cpu_read_topology() to gather the required information 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> Reviewed-on: https://review.coreboot.org/c/coreboot/+/48691 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Angel Pons <th3fanbus@gmail.com>
Diffstat (limited to 'src/soc/intel')
-rw-r--r--src/soc/intel/common/block/acpi/acpi.c39
1 files changed, 13 insertions, 26 deletions
diff --git a/src/soc/intel/common/block/acpi/acpi.c b/src/soc/intel/common/block/acpi/acpi.c
index 934a92f7c5..e3e72fddd4 100644
--- a/src/soc/intel/common/block/acpi/acpi.c
+++ b/src/soc/intel/common/block/acpi/acpi.c
@@ -14,7 +14,6 @@
#include <cpu/x86/smm.h>
#include <intelblocks/acpi.h>
#include <intelblocks/lpc_lib.h>
-#include <intelblocks/msr.h>
#include <intelblocks/pmclib.h>
#include <intelblocks/uart.h>
#include <soc/gpio.h>
@@ -284,22 +283,6 @@ int common_calculate_power_ratio(int tdp, int p1_ratio, int ratio)
return power;
}
-static int get_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;
-}
-
static void generate_c_state_entries(void)
{
acpi_cstate_t *c_state_map;
@@ -450,21 +433,25 @@ void generate_cpu_entries(const struct device *device)
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 numcpus = totalcores / cores_per_package;
+ unsigned int num_virt;
+ unsigned int num_phys;
+
+ cpu_read_topology(&num_phys, &num_virt);
+
+ int numcpus = totalcores / num_virt;
- printk(BIOS_DEBUG, "Found %d CPU(s) with %d core(s) each.\n",
- numcpus, cores_per_package);
+ printk(BIOS_DEBUG, "Found %d CPU(s) with %d/%d physical/logical core(s) each.\n",
+ numcpus, num_phys, num_virt);
for (cpu_id = 0; cpu_id < numcpus; cpu_id++) {
- for (core_id = 0; core_id < cores_per_package; core_id++) {
+ for (core_id = 0; core_id < num_virt; core_id++) {
if (core_id > 0) {
pcontrol_blk = 0;
plen = 0;
}
/* Generate processor \_SB.CPUx */
- acpigen_write_processor((cpu_id) * cores_per_package +
+ acpigen_write_processor((cpu_id) * num_virt +
core_id, pcontrol_blk, plen);
/* Generate C-state tables */
@@ -473,17 +460,17 @@ void generate_cpu_entries(const struct device *device)
generate_cppc_entries(core_id);
/* Soc specific power states generation */
- soc_power_states_generation(core_id, cores_per_package);
+ soc_power_states_generation(core_id, num_virt);
acpigen_pop_len();
}
}
/* PPKG is usually used for thermal management
of the first and only package. */
- acpigen_write_processor_package("PPKG", 0, cores_per_package);
+ acpigen_write_processor_package("PPKG", 0, num_virt);
/* Add a method to notify processor nodes */
- acpigen_write_processor_cnot(cores_per_package);
+ acpigen_write_processor_cnot(num_virt);
}
#if CONFIG(SOC_INTEL_COMMON_ACPI_WAKE_SOURCE)