Add CONFIG_CPUFREQ to allow CPU frequency scaling support to be disabled at build time. When disabled, this removes cpufreq code from the build.
Add stubs where necessary. Signed-off-by: Stefano Stabellini <[email protected]> --- Changes in v2: - add stubs for cpufreq_add/del_cpu - also gate hwp_active --- xen/arch/x86/acpi/Makefile | 2 +- xen/common/Kconfig | 4 ++-- xen/drivers/Makefile | 2 +- xen/drivers/cpufreq/Kconfig | 16 +++++++++++++++- xen/include/acpi/cpufreq/cpufreq.h | 13 ++++++++++++- xen/include/acpi/cpufreq/processor_perf.h | 3 --- xen/include/xen/acpi.h | 8 +++++++- xen/include/xen/pmstat.h | 15 ++++++++++++++- xen/include/xen/sched.h | 9 +++++++-- 9 files changed, 59 insertions(+), 13 deletions(-) diff --git a/xen/arch/x86/acpi/Makefile b/xen/arch/x86/acpi/Makefile index 041377e2bb..aa476f65d5 100644 --- a/xen/arch/x86/acpi/Makefile +++ b/xen/arch/x86/acpi/Makefile @@ -1,4 +1,4 @@ -obj-y += cpufreq/ +obj-$(CONFIG_CPUFREQ) += cpufreq/ obj-y += lib.o power.o cpu_idle.o cpuidle_menu.o obj-bin-y += boot.init.o wakeup_prot.o diff --git a/xen/common/Kconfig b/xen/common/Kconfig index d7e79e752a..cddd7337bb 100644 --- a/xen/common/Kconfig +++ b/xen/common/Kconfig @@ -652,7 +652,7 @@ endmenu config PM_OP bool "Enable Performance Management Operation" - depends on ACPI && HAS_CPUFREQ && SYSCTL + depends on ACPI && CPUFREQ && SYSCTL default y help This option shall enable userspace performance management control @@ -660,7 +660,7 @@ config PM_OP config PM_STATS bool "Enable Performance Management Statistics" - depends on ACPI && HAS_CPUFREQ && SYSCTL + depends on ACPI && CPUFREQ && SYSCTL default y help Enable collection of performance management statistics to aid in diff --git a/xen/drivers/Makefile b/xen/drivers/Makefile index 2a1ae8ad13..3d81b8dde4 100644 --- a/xen/drivers/Makefile +++ b/xen/drivers/Makefile @@ -1,5 +1,5 @@ obj-y += char/ -obj-$(CONFIG_HAS_CPUFREQ) += cpufreq/ +obj-$(CONFIG_CPUFREQ) += cpufreq/ obj-$(CONFIG_HAS_PCI) += pci/ obj-$(CONFIG_HAS_VPCI) += vpci/ obj-$(CONFIG_HAS_PASSTHROUGH) += passthrough/ diff --git a/xen/drivers/cpufreq/Kconfig b/xen/drivers/cpufreq/Kconfig index cce80f4aec..49631f92de 100644 --- a/xen/drivers/cpufreq/Kconfig +++ b/xen/drivers/cpufreq/Kconfig @@ -1,3 +1,17 @@ - config HAS_CPUFREQ bool + +config CPUFREQ + bool "CPU Frequency scaling" + default y + depends on HAS_CPUFREQ + help + Enable CPU frequency scaling and power management governors. + This allows Xen to dynamically adjust CPU P-states (performance + states) based on system load. + + Disabling this option removes all cpufreq governors and power + management interfaces. This is useful for real-time systems or + minimal hypervisor builds. + + If unsure, say Y. diff --git a/xen/include/acpi/cpufreq/cpufreq.h b/xen/include/acpi/cpufreq/cpufreq.h index 0171ccf0ba..9529730d9c 100644 --- a/xen/include/acpi/cpufreq/cpufreq.h +++ b/xen/include/acpi/cpufreq/cpufreq.h @@ -381,8 +381,19 @@ int write_ondemand_up_threshold(unsigned int up_threshold); int write_userspace_scaling_setspeed(unsigned int cpu, unsigned int freq); +#ifdef CONFIG_CPUFREQ +int cpufreq_add_cpu(unsigned int cpu); +int cpufreq_del_cpu(unsigned int cpu); + void cpufreq_dbs_timer_suspend(void); void cpufreq_dbs_timer_resume(void); +#else +static inline int cpufreq_add_cpu(unsigned int cpu) { return -ENOSYS; } +static inline int cpufreq_del_cpu(unsigned int cpu) { return -ENOSYS; } + +static inline void cpufreq_dbs_timer_suspend(void) {} +static inline void cpufreq_dbs_timer_resume(void) {} +#endif void intel_feature_detect(struct cpufreq_policy *policy); @@ -398,7 +409,7 @@ void intel_feature_detect(struct cpufreq_policy *policy); int hwp_cmdline_parse(const char *s, const char *e); int hwp_register_driver(void); -#ifdef CONFIG_INTEL +#if defined(CONFIG_INTEL) && defined(CONFIG_CPUFREQ) bool hwp_active(void); #else static inline bool hwp_active(void) { return false; } diff --git a/xen/include/acpi/cpufreq/processor_perf.h b/xen/include/acpi/cpufreq/processor_perf.h index 0a87bc0384..bad9d94865 100644 --- a/xen/include/acpi/cpufreq/processor_perf.h +++ b/xen/include/acpi/cpufreq/processor_perf.h @@ -36,9 +36,6 @@ static inline void cpufreq_statistic_exit(unsigned int cpu) {} int cpufreq_limit_change(unsigned int cpu); -int cpufreq_add_cpu(unsigned int cpu); -int cpufreq_del_cpu(unsigned int cpu); - struct processor_performance { uint32_t state; uint32_t platform_limit; diff --git a/xen/include/xen/acpi.h b/xen/include/xen/acpi.h index 90635ba0f3..7077c27150 100644 --- a/xen/include/xen/acpi.h +++ b/xen/include/xen/acpi.h @@ -185,8 +185,14 @@ static inline unsigned int acpi_get_csubstate_limit(void) { return 0; } static inline void acpi_set_csubstate_limit(unsigned int new_limit) { return; } #endif -#ifdef XEN_GUEST_HANDLE +#if defined(XEN_GUEST_HANDLE) && defined(CONFIG_CPUFREQ) int acpi_set_pdc_bits(unsigned int acpi_id, XEN_GUEST_HANDLE(uint32)); +#elif defined(XEN_GUEST_HANDLE) +static inline int acpi_set_pdc_bits(unsigned int acpi_id, + XEN_GUEST_HANDLE(uint32) pdc) +{ + return -ENOSYS; +} #endif int arch_acpi_set_pdc_bits(u32 acpi_id, u32 *, u32 mask); diff --git a/xen/include/xen/pmstat.h b/xen/include/xen/pmstat.h index 6096560d3c..4efddad438 100644 --- a/xen/include/xen/pmstat.h +++ b/xen/include/xen/pmstat.h @@ -5,10 +5,23 @@ #include <public/platform.h> /* for struct xen_processor_power */ #include <public/sysctl.h> /* for struct pm_cx_stat */ +#ifdef CONFIG_CPUFREQ int set_px_pminfo(uint32_t acpi_id, struct xen_processor_performance *perf); -long set_cx_pminfo(uint32_t acpi_id, struct xen_processor_power *power); int set_cppc_pminfo(unsigned int acpi_id, const struct xen_processor_cppc *cppc_data); +#else +static inline int set_px_pminfo(uint32_t acpi_id, + struct xen_processor_performance *perf) +{ + return -ENOSYS; +} +static inline int set_cppc_pminfo(unsigned int acpi_id, + const struct xen_processor_cppc *cppc_data) +{ + return -ENOSYS; +} +#endif +long set_cx_pminfo(uint32_t acpi_id, struct xen_processor_power *power); #ifdef CONFIG_COMPAT struct compat_processor_performance; diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h index 1268632344..1b431fc726 100644 --- a/xen/include/xen/sched.h +++ b/xen/include/xen/sched.h @@ -1255,9 +1255,14 @@ static always_inline bool is_iommu_enabled(const struct domain *d) extern bool sched_smt_power_savings; extern bool sched_disable_smt_switching; -extern enum cpufreq_controller { +enum cpufreq_controller { FREQCTL_none, FREQCTL_dom0_kernel, FREQCTL_xen -} cpufreq_controller; +}; +#ifdef CONFIG_CPUFREQ +extern enum cpufreq_controller cpufreq_controller; +#else +#define cpufreq_controller FREQCTL_none +#endif static always_inline bool is_cpufreq_controller(const struct domain *d) { -- 2.25.1
