]> xenbits.xensource.com Git - people/aperard/xen-unstable.git/commitdiff
x86/cpufreq: separate powernow/hwp/acpi cpufreq code
authorSergiy Kibrik <Sergiy_Kibrik@epam.com>
Thu, 1 Aug 2024 07:41:03 +0000 (09:41 +0200)
committerJan Beulich <jbeulich@suse.com>
Thu, 1 Aug 2024 07:41:03 +0000 (09:41 +0200)
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>
Reviewed-by: Jason Andryuk <jason.andryuk@amd.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
xen/arch/x86/acpi/cpufreq/Makefile
xen/arch/x86/acpi/cpufreq/cpufreq.c
xen/drivers/acpi/pmstat.c
xen/drivers/cpufreq/cpufreq.c
xen/include/acpi/cpufreq/cpufreq.h

index 44d4c0b49705e96cf23d58ab381258f072cff4e2..e7dbe434a88c7b936015a21751982c3428bab908 100644 (file)
@@ -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
index 6244d294969d492ae9e1d0ec15ab6f4563361bad..61e98b67bd820def938ddd5ab0f5bb2cebd8ad2d 100644 (file)
@@ -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;
         }
     }
index 998d2e3c656bd71004e35f3a0420c1e0e08e6b13..df309e27b4a54c99707f96aaec4ba641fa71b869 100644 (file)
@@ -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
     {
index 8659ad3aee51038dc7ea2fd391be6c8ba823298b..4a103c6de91c6406adf39e67f2cf8d9e5ce4bb6b 100644 (file)
@@ -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;
index ec7e1390006e0255cf1128fb5a3e90321cf9ea44..b6cff825ce1e144da0478c94d4659670c4c845c9 100644 (file)
@@ -254,7 +254,12 @@ 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,