Message ID | 56f61a1e22ba77fb352d7a18203935c26c815646.1720596402.git.Sergiy_Kibrik@epam.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | x86: separate powernow/hwp/acpi cpufreq code | expand |
On 2024-07-10 04:30, Sergiy Kibrik wrote: > Build AMD Architectural P-state driver when CONFIG_AMD is on, and > Intel Hardware P-States driver together with ACPI Processor P-States driver > when CONFIG_INTEL is on respectively, allowing for a platform-specific build. > > Signed-off-by: Sergiy Kibrik <Sergiy_Kibrik@epam.com> > CC: Jason Andryuk <jason.andryuk@amd.com> > CC: Jan Beulich <jbeulich@suse.com> Reviewed-by: Jason Andryuk <jason.andryuk@amd.com> Thanks, Jason
On 15.07.2024 20:32, Jason Andryuk wrote: > On 2024-07-10 04:30, Sergiy Kibrik wrote: >> Build AMD Architectural P-state driver when CONFIG_AMD is on, and >> Intel Hardware P-States driver together with ACPI Processor P-States driver >> when CONFIG_INTEL is on respectively, allowing for a platform-specific build. >> >> Signed-off-by: Sergiy Kibrik <Sergiy_Kibrik@epam.com> >> CC: Jason Andryuk <jason.andryuk@amd.com> >> CC: Jan Beulich <jbeulich@suse.com> > > Reviewed-by: Jason Andryuk <jason.andryuk@amd.com> Acked-by: Jan Beulich <jbeulich@suse.com> Might be a little neater though to have the hwp_active() stub be just a single line. I may take the liberty to change that while committing. Jan
diff --git a/xen/arch/x86/acpi/cpufreq/Makefile b/xen/arch/x86/acpi/cpufreq/Makefile index 44d4c0b497..e7dbe434a8 100644 --- a/xen/arch/x86/acpi/cpufreq/Makefile +++ b/xen/arch/x86/acpi/cpufreq/Makefile @@ -1,4 +1,4 @@ -obj-y += acpi.o +obj-$(CONFIG_INTEL) += acpi.o obj-y += cpufreq.o -obj-y += hwp.o -obj-y += powernow.o +obj-$(CONFIG_INTEL) += hwp.o +obj-$(CONFIG_AMD) += powernow.o diff --git a/xen/arch/x86/acpi/cpufreq/cpufreq.c b/xen/arch/x86/acpi/cpufreq/cpufreq.c index 6244d29496..61e98b67bd 100644 --- a/xen/arch/x86/acpi/cpufreq/cpufreq.c +++ b/xen/arch/x86/acpi/cpufreq/cpufreq.c @@ -138,10 +138,12 @@ static int __init cf_check cpufreq_driver_init(void) switch ( cpufreq_xen_opts[i] ) { case CPUFREQ_xen: - ret = acpi_cpufreq_register(); + ret = IS_ENABLED(CONFIG_INTEL) ? + acpi_cpufreq_register() : -ENODEV; break; case CPUFREQ_hwp: - ret = hwp_register_driver(); + ret = IS_ENABLED(CONFIG_INTEL) ? + hwp_register_driver() : -ENODEV; break; case CPUFREQ_none: ret = 0; @@ -155,7 +157,7 @@ static int __init cf_check cpufreq_driver_init(void) case X86_VENDOR_AMD: case X86_VENDOR_HYGON: - ret = powernow_register_driver(); + ret = IS_ENABLED(CONFIG_AMD) ? powernow_register_driver() : -ENODEV; break; } } diff --git a/xen/drivers/acpi/pmstat.c b/xen/drivers/acpi/pmstat.c index 998d2e3c65..df309e27b4 100644 --- a/xen/drivers/acpi/pmstat.c +++ b/xen/drivers/acpi/pmstat.c @@ -254,8 +254,9 @@ static int get_cpufreq_para(struct xen_sysctl_pm_op *op) else strlcpy(op->u.get_para.scaling_driver, "Unknown", CPUFREQ_NAME_LEN); - if ( !strncmp(op->u.get_para.scaling_driver, XEN_HWP_DRIVER_NAME, - CPUFREQ_NAME_LEN) ) + if ( IS_ENABLED(CONFIG_INTEL) && + !strncmp(op->u.get_para.scaling_driver, XEN_HWP_DRIVER_NAME, + CPUFREQ_NAME_LEN) ) ret = get_hwp_para(policy->cpu, &op->u.get_para.u.cppc_para); else { diff --git a/xen/drivers/cpufreq/cpufreq.c b/xen/drivers/cpufreq/cpufreq.c index 8659ad3aee..4a103c6de9 100644 --- a/xen/drivers/cpufreq/cpufreq.c +++ b/xen/drivers/cpufreq/cpufreq.c @@ -120,7 +120,8 @@ static int __init cf_check setup_cpufreq_option(const char *str) if ( arg[0] && arg[1] ) ret = cpufreq_cmdline_parse(arg + 1, end); } - else if ( choice < 0 && !cmdline_strcmp(str, "hwp") ) + else if ( IS_ENABLED(CONFIG_INTEL) && choice < 0 && + !cmdline_strcmp(str, "hwp") ) { xen_processor_pmbits |= XEN_PROCESSOR_PM_PX; cpufreq_controller = FREQCTL_xen; diff --git a/xen/include/acpi/cpufreq/cpufreq.h b/xen/include/acpi/cpufreq/cpufreq.h index ec7e139000..08ee2af0f8 100644 --- a/xen/include/acpi/cpufreq/cpufreq.h +++ b/xen/include/acpi/cpufreq/cpufreq.h @@ -254,7 +254,15 @@ 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 bool hwp_active(void); +#else +static inline bool hwp_active(void) +{ + return false; +} +#endif + int get_hwp_para(unsigned int cpu, struct xen_cppc_para *cppc_para); int set_hwp_para(struct cpufreq_policy *policy,
Build AMD Architectural P-state driver when CONFIG_AMD is on, and Intel Hardware P-States driver together with ACPI Processor P-States driver when CONFIG_INTEL is on respectively, allowing for a platform-specific build. Signed-off-by: Sergiy Kibrik <Sergiy_Kibrik@epam.com> CC: Jason Andryuk <jason.andryuk@amd.com> CC: Jan Beulich <jbeulich@suse.com> --- changes in v3: - more clear wrapping of lines in conditionals + put IS_ENABLED() in front - drop unneeded change to utility.c changes in v2: - disable acpi-cpufreq driver as well when !INTEL - leave a stub for hwp_active() only when !INTEL - updated patch description --- xen/arch/x86/acpi/cpufreq/Makefile | 6 +++--- xen/arch/x86/acpi/cpufreq/cpufreq.c | 8 +++++--- xen/drivers/acpi/pmstat.c | 5 +++-- xen/drivers/cpufreq/cpufreq.c | 3 ++- xen/include/acpi/cpufreq/cpufreq.h | 8 ++++++++ 5 files changed, 21 insertions(+), 9 deletions(-)