summaryrefslogtreecommitdiff
path: root/src/soc/intel/common/block
diff options
context:
space:
mode:
authorJulien Viard de Galbert <jviarddegalbert@online.net>2018-11-06 09:28:03 +0100
committerPatrick Georgi <pgeorgi@google.com>2019-01-24 13:58:24 +0000
commitc2540a958b5e8f4ad4ea0db24c408387ae1cb5f8 (patch)
tree1385b9322c95a70d42df80b90e127c7002de0233 /src/soc/intel/common/block
parent016ef9e9bc36c60101b707a8c1c926e78350befa (diff)
soc/intel/common/block/acpi: fix P-States extra entry
The ratio_max step is appearing twice when (ratio_max - ratio_min) is evenly divisible by the ratio step. This is because in this case there are no rounding down of ratio_max in the for loop. Thanks Jay Talbott for the step calculation algorithm. Change-Id: I91090b4d87eb82b57055c24271d679d1cbb3b7a7 Signed-off-by: Julien Viard de Galbert <jviarddegalbert@online.net> Reviewed-on: https://review.coreboot.org/c/25429 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Patrick Georgi <pgeorgi@google.com>
Diffstat (limited to 'src/soc/intel/common/block')
-rw-r--r--src/soc/intel/common/block/acpi/acpi.c26
1 files changed, 16 insertions, 10 deletions
diff --git a/src/soc/intel/common/block/acpi/acpi.c b/src/soc/intel/common/block/acpi/acpi.c
index 0ea6cb9d70..21d877b162 100644
--- a/src/soc/intel/common/block/acpi/acpi.c
+++ b/src/soc/intel/common/block/acpi/acpi.c
@@ -299,11 +299,13 @@ void generate_p_state_entries(int core, int cores_per_package)
int ratio_min, ratio_max, ratio_turbo, ratio_step;
int coord_type, power_max, num_entries;
int ratio, power, clock, clock_max;
+ bool turbo;
coord_type = cpu_get_coord_type();
ratio_min = cpu_get_min_ratio();
ratio_max = cpu_get_max_ratio();
clock_max = (ratio_max * cpu_get_bus_clock()) / KHz;
+ turbo = (get_turbo_state() == TURBO_ENABLED);
/* Calculate CPU TDP in mW */
power_max = cpu_get_power_max();
@@ -321,16 +323,21 @@ void generate_p_state_entries(int core, int cores_per_package)
/* Determine ratio points */
ratio_step = PSS_RATIO_STEP;
- num_entries = ((ratio_max - ratio_min) / ratio_step) + 1;
- if (num_entries > PSS_MAX_ENTRIES) {
- ratio_step += 1;
+ do {
num_entries = ((ratio_max - ratio_min) / ratio_step) + 1;
- }
+ if (((ratio_max - ratio_min) % ratio_step) > 0)
+ num_entries += 1;
+ if (turbo)
+ num_entries += 1;
+ if (num_entries > PSS_MAX_ENTRIES)
+ ratio_step += 1;
+ } while (num_entries > PSS_MAX_ENTRIES);
+
+ /* _PSS package count depends on Turbo */
+ acpigen_write_package(num_entries);
/* P[T] is Turbo state if enabled */
- if (get_turbo_state() == TURBO_ENABLED) {
- /* _PSS package count including Turbo */
- acpigen_write_package(num_entries + 2);
+ if (turbo) {
ratio_turbo = cpu_get_max_turbo_ratio();
/* Add entry for Turbo ratio */
@@ -340,9 +347,7 @@ void generate_p_state_entries(int core, int cores_per_package)
PSS_LATENCY_BUSMASTER,/* lat2 */
ratio_turbo << 8, /* control */
ratio_turbo << 8); /* status */
- } else {
- /* _PSS package count without Turbo */
- acpigen_write_package(num_entries + 1);
+ num_entries -= 1;
}
/* First regular entry is max non-turbo ratio */
@@ -352,6 +357,7 @@ void generate_p_state_entries(int core, int cores_per_package)
PSS_LATENCY_BUSMASTER,/* lat2 */
ratio_max << 8, /* control */
ratio_max << 8); /* status */
+ num_entries -= 1;
/* Generate the remaining entries */
for (ratio = ratio_min + ((num_entries - 1) * ratio_step);