From ac02ae15d89ecfeba580090196d8d02c24287837 Mon Sep 17 00:00:00 2001 From: Jeremy Compostella Date: Wed, 8 Jan 2025 09:17:02 -0800 Subject: [PATCH] soc/intel/common: Simply code accessing scaling factors This commit streamlines the call to the soc_read_core_scaling_factors() function. When runtime access to the core scaling factors is not available, a static fallback is used based on the CONFIG_SOC_INTEL_PERFORMANCE_CORE_SCALE_FACTOR and CONFIG_SOC_INTEL_EFFICIENT_CORE_SCALE_FACTOR options. TEST=Successfully read performance and efficient scaling factors on a fatcat board. Change-Id: I62e903bea07f2981dfcbaf61d3b918e7c332afc5 Signed-off-by: Jeremy Compostella Suggested-by: Subrata Banik Reviewed-on: https://review.coreboot.org/c/coreboot/+/85897 Tested-by: build bot (Jenkins) Reviewed-by: Subrata Banik --- src/soc/intel/common/block/acpi/cpu_hybrid.c | 18 ++---------------- .../common/block/include/intelblocks/acpi.h | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/src/soc/intel/common/block/acpi/cpu_hybrid.c b/src/soc/intel/common/block/acpi/cpu_hybrid.c index 2c3b84ceee..ee4777ae69 100644 --- a/src/soc/intel/common/block/acpi/cpu_hybrid.c +++ b/src/soc/intel/common/block/acpi/cpu_hybrid.c @@ -110,22 +110,8 @@ static void acpi_get_cpu_nomi_perf(u16 *eff_core_nom_perf, u16 *perf_core_nom_pe u8 max_non_turbo_ratio = cpu_get_max_non_turbo_ratio(); static u16 performance, efficient; - _Static_assert(CONFIG(SOC_INTEL_COMMON_BLOCK_RUNTIME_CORE_SCALING_FACTORS) || - CONFIG_SOC_INTEL_PERFORMANCE_CORE_SCALE_FACTOR != 0, - "CONFIG_SOC_INTEL_PERFORMANCE_CORE_SCALE_FACTOR must not be zero"); - - _Static_assert(CONFIG(SOC_INTEL_COMMON_BLOCK_RUNTIME_CORE_SCALING_FACTORS) || - CONFIG_SOC_INTEL_EFFICIENT_CORE_SCALE_FACTOR != 0, - "CONFIG_SOC_INTEL_EFFICIENT_CORE_SCALE_FACTOR must not be zero"); - - if (!performance) { - if (CONFIG(SOC_INTEL_COMMON_BLOCK_RUNTIME_CORE_SCALING_FACTORS)) { - soc_read_core_scaling_factors(&performance, &efficient); - } else { - performance = CONFIG_SOC_INTEL_PERFORMANCE_CORE_SCALE_FACTOR; - efficient = CONFIG_SOC_INTEL_EFFICIENT_CORE_SCALE_FACTOR; - } - } + if (!performance) + soc_read_core_scaling_factors(&performance, &efficient); *perf_core_nom_perf = (u16)((max_non_turbo_ratio * performance) / 100); *eff_core_nom_perf = (u16)((max_non_turbo_ratio * efficient) / 100); diff --git a/src/soc/intel/common/block/include/intelblocks/acpi.h b/src/soc/intel/common/block/include/intelblocks/acpi.h index a3f82481c9..de81c37062 100644 --- a/src/soc/intel/common/block/include/intelblocks/acpi.h +++ b/src/soc/intel/common/block/include/intelblocks/acpi.h @@ -26,12 +26,30 @@ enum cpu_perf_eff_type { unsigned long acpi_create_madt_lapics_with_nmis_hybrid(unsigned long current); +#if CONFIG(SOC_INTEL_COMMON_BLOCK_ACPI_CPU_HYBRID) /* * Read the performance and efficient core ratios. * This is to be implemented by the SoC specific code if * SOC_INTEL_COMMON_BLOCK_RUNTIME_CORE_SCALING_FACTORS is selected. */ +#if CONFIG(SOC_INTEL_COMMON_BLOCK_RUNTIME_CORE_SCALING_FACTORS) enum cb_err soc_read_core_scaling_factors(u16 *performance, u16 *efficient); +#else +static inline enum cb_err soc_read_core_scaling_factors(u16 *performance, u16 *efficient) +{ + _Static_assert(CONFIG_SOC_INTEL_PERFORMANCE_CORE_SCALE_FACTOR != 0, + "CONFIG_SOC_INTEL_PERFORMANCE_CORE_SCALE_FACTOR must not be zero"); + + _Static_assert(CONFIG_SOC_INTEL_EFFICIENT_CORE_SCALE_FACTOR != 0, + "CONFIG_SOC_INTEL_EFFICIENT_CORE_SCALE_FACTOR must not be zero"); + + *performance = CONFIG_SOC_INTEL_PERFORMANCE_CORE_SCALE_FACTOR; + *efficient = CONFIG_SOC_INTEL_EFFICIENT_CORE_SCALE_FACTOR; + + return CB_SUCCESS; +} +#endif +#endif /* SOC_INTEL_COMMON_BLOCK_ACPI_CPU_HYBRID */ /* Generates ACPI code to define _CPC control method */ void acpigen_write_CPPC_hybrid_method(int core_id);