x86: separate powernow/hwp/acpi cpufreq code
v3 cover x86: separate powernow/hwp/acpi cpufreq code
This is another version of a short patch series to make platform-specific parts of cpufreq optional and dependant on INTEL & AMD config options. This is to allow for tuning the build for either AMD or Intel platform exclusively and hence to drop the code that would be left unused.
Per-patch changelog provided to track what changed since v2.
v2 series & related discussion are here:
https://lore.kernel.org/xen-devel/[email protected]/
Sergiy Kibrik (2):
x86/cpufreq: move ACPI cpufreq driver into separate file x86/cpufreq: separate powernow/hwp/acpi cpufreq code
xen/arch/x86/acpi/cpufreq/Makefile | 5 +- xen/arch/x86/acpi/cpufreq/acpi.c | 518 ++++++++++++++++++++++++++++ xen/arch/x86/acpi/cpufreq/cpufreq.c | 512 +-------------------------- xen/drivers/acpi/pmstat.c | 5 +- xen/drivers/cpufreq/cpufreq.c | 3 +- xen/include/acpi/cpufreq/cpufreq.h | 10 + 6 files changed, 542 insertions(+), 511 deletions(-) create mode 100644 xen/arch/x86/acpi/cpufreq/acpi.c
Signature · 1 line
2.25.1
PATCH v3 1/2 x86/cpufreq: move ACPI cpufreq driver into separate file
Separate ACPI driver from generic initialization cpufreq code. This way acpi-cpufreq can become optional in the future and be disabled from non-Intel builds.
no changes to code were introduced, except:
acpi_cpufreq_register() helper added
clean up a list of included headers
license transformed into an SPDX line
---
changes in v3:
- do not move generic get_measured_perf() & related code
- license transformed into an SPDX line
--- xen/arch/x86/acpi/cpufreq/Makefile | 1 + xen/arch/x86/acpi/cpufreq/acpi.c | 518 ++++++++++++++++++++++++++++ xen/arch/x86/acpi/cpufreq/cpufreq.c | 506 +-------------------------- xen/include/acpi/cpufreq/cpufreq.h | 2 + 4 files changed, 523 insertions(+), 504 deletions(-) create mode 100644 xen/arch/x86/acpi/cpufreq/acpi.c
xen/arch/x86/acpi/cpufreq/Makefile +1 -0
@@ -1,3 +1,4 @@ +obj-y += acpi.o obj-y += cpufreq.o obj-y += hwp.o obj-y += powernow.o
xen/arch/x86/acpi/cpufreq/acpi.c new file +518 -0
518 lines not on this page · raw message
xen/arch/x86/acpi/cpufreq/cpufreq.c +2 -504
538 lines not on this page · raw message
xen/include/acpi/cpufreq/cpufreq.h +2 -0
@@ -260,4 +260,6 @@ int get_hwp_para(unsigned int cpu,int set_hwp_para (struct cpufreq_policy *policy,struct xen_set_cppc_para *set_cppc); +int acpi_cpufreq_register (void ); +#endif /* __XEN_CPUFREQ_PM_H__ */
Signature · 1 line
2.25.1
Re: [XEN PATCH v3 1/2] x86/cpufreq: move ACPI cpufreq driver into separate file
Quoted 10 lines · Sergiy Kibrik
Separate ACPI driver from generic initialization cpufreq code. This way acpi-cpufreq can become optional in the future and be disabled from non-Intel builds.
no changes to code were introduced, except:
acpi_cpufreq_register()helper added
clean up a list of included headers
license transformed into an SPDX lineSigned-off-by Sergiy Kibrik <[email protected]>
with perhaps two tiny further adjustments, which I'd be happy to do while committing:
Quoted 10 lines
xen/arch/x86/acpi/cpufreq/acpi.c new file +7
-0@@ -0,0 +1,518 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* +* cpufreq.c - ACPI Processor P-States Driver ($Revision: 1.4 $) +* +* Copyright (C) 2001, 2002 Andy Grover <[email protected]> +* Copyright (C) 2001, 2002 Paul Diefenbaugh <[email protected]> +* Copyright (C) 2002 - 2004 Dominik Brodowski <[email protected]>
xen/arch/x86/acpi/cpufreq/acpi.c line 17
Quoted 10 lines
xen/arch/x86/acpi/cpufreq/acpi.c new file +10
-0+* Copyright (C) 2006 Denis Sadykov <[email protected]> +* +* Feb 2008 - Liu Jinsong <[email protected]> +* porting acpi-cpufreq.c from Linux 2.6.23 to Xen hypervisor +*/ + +#include <xen/types.h> +#include <xen/errno.h> +#include <xen/delay.h> +#include <xen/param.h>
Would be nice if in the new file xen/ #include-s were sorted.
xen/arch/x86/acpi/cpufreq/acpi.c line 21
Quoted 4 lines
xen/arch/x86/acpi/cpufreq/acpi.c new file +4
-0+#include <acpi/acpi.h> +#include <acpi/cpufreq/cpufreq.h> + +
No double blank lines please.
Jan
PATCH v3 2/2 x86/cpufreq: separate powernow/hwp/acpi cpufreq code
In reply to Sergiy KibrikBuild 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.
---
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(-)
xen/arch/x86/acpi/cpufreq/Makefile +3 -3
@@ -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
xen/arch/x86/acpi/cpufreq/cpufreq.c +5 -3
@@ -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 ; } }
xen/drivers/acpi/pmstat.c +3 -2
@@ -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 {
xen/drivers/cpufreq/cpufreq.c +2 -1
@@ -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;
xen/include/acpi/cpufreq/cpufreq.h +8 -0
@@ -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,
Signature · 1 line
2.25.1
Re: [XEN PATCH v3 2/2] x86/cpufreq: separate powernow/hwp/acpi cpufreq code
Quoted 7 lines · Sergiy Kibrik
Build AMD Architectural P-state driver when
CONFIG_AMDis on, and Intel Hardware P-States driver together with ACPI Processor P-States driver whenCONFIG_INTELis on respectively, allowing for a platform-specific build.Signed-off-by Sergiy Kibrik <[email protected]>CC Jason Andryuk <[email protected]>CC Jan Beulich <[email protected]>
Thanks,
Jason
Jan Beulich
Acked-byRe: [XEN PATCH v3 2/2] x86/cpufreq: separate powernow/hwp/acpi cpufreq code
Quoted 10 lines · Jason Andryuk
Quoted 7 lines · Sergiy Kibrik
Build AMD Architectural P-state driver when
CONFIG_AMDis on, and Intel Hardware P-States driver together with ACPI Processor P-States driver whenCONFIG_INTELis on respectively, allowing for a platform-specific build.Signed-off-by Sergiy Kibrik <[email protected]>CC Jason Andryuk <[email protected]>CC Jan Beulich <[email protected]>Reviewed-by Jason Andryuk <[email protected]>
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