[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [linux-2.6.18-xen] Isolate Xen PM related code in dom0 with #ifdef CONFIG_XEN to avoid



# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1209979061 -3600
# Node ID e39cf97647af69cd0b09f4e91e539e26194b8a9f
# Parent  26c60aa94b9f715027cf32cf5163ae9305e1abd4
Isolate Xen PM related code in dom0 with #ifdef CONFIG_XEN to avoid
breaking native.

Signed-off-by: Wei Gang <gang.wei@xxxxxxxxx>
---
 arch/i386/kernel/acpi/processor.c           |   19 +++++++----
 arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c |    2 +
 drivers/acpi/processor_core.c               |   45 ++++++++++++++++++++++++++++
 drivers/acpi/processor_idle.c               |   25 +++++++++++++++
 drivers/acpi/processor_perflib.c            |    8 +++-
 include/acpi/processor.h                    |    8 +++-
 6 files changed, 95 insertions(+), 12 deletions(-)

diff -r 26c60aa94b9f -r e39cf97647af arch/i386/kernel/acpi/processor.c
--- a/arch/i386/kernel/acpi/processor.c Mon May 05 10:14:25 2008 +0100
+++ b/arch/i386/kernel/acpi/processor.c Mon May 05 10:17:41 2008 +0100
@@ -59,16 +59,21 @@ static void init_intel_pdc(struct acpi_p
        return;
 }
 
-/* 
- * Initialize _PDC data based on the CPU vendor. As a work-around, just
- * use cpu0's cpuinfo for all processors. Further work is required 
- * to expose xen hypervisor interface of getting physical cpuinfo to dom0
- * kerneland then arch_acpi_processor_init_pdc can set _PDC parameters 
- * according to Xen's phys information.
- */
+/* Initialize _PDC data based on the CPU vendor */
 void arch_acpi_processor_init_pdc(struct acpi_processor *pr)
 {
+#ifdef CONFIG_XEN
+       /* 
+        * As a work-around, just use cpu0's cpuinfo for all processors.
+        * Further work is required to expose xen hypervisor interface of
+        * getting physical cpuinfo to dom0 kernel and then
+        * arch_acpi_processor_init_pdc can set _PDC parameters according
+        * to Xen's phys information.
+        */
        unsigned int cpu = 0;
+#else
+       unsigned int cpu = pr->id;
+#endif /* CONFIG_XEN */
        struct cpuinfo_x86 *c = cpu_data + cpu;
 
        pr->pdc = NULL;
diff -r 26c60aa94b9f -r e39cf97647af arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c
--- a/arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c       Mon May 05 10:14:25 
2008 +0100
+++ b/arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c       Mon May 05 10:17:41 
2008 +0100
@@ -568,6 +568,7 @@ acpi_cpufreq_init (void)
 {
        dprintk("acpi_cpufreq_init\n");
 
+#ifdef CONFIG_XEN
        /*
         * This effectively blocks in-kernel cpufreq driver to interfere
         * external control logic
@@ -576,6 +577,7 @@ acpi_cpufreq_init (void)
                printk("CPUFREQ is controllerd externally...exit then!\n");
                return -1;
        }
+#endif /* CONFIG_XEN */
 
        acpi_cpufreq_early_init_acpi();
 
diff -r 26c60aa94b9f -r e39cf97647af drivers/acpi/processor_core.c
--- a/drivers/acpi/processor_core.c     Mon May 05 10:14:25 2008 +0100
+++ b/drivers/acpi/processor_core.c     Mon May 05 10:17:41 2008 +0100
@@ -474,9 +474,14 @@ static int acpi_processor_get_info(struc
         *  they are physically not present.
         */
        if (cpu_index == -1) {
+#ifdef CONFIG_XEN
                if (ACPI_FAILURE
                    (acpi_processor_hotadd_init(pr->handle, &pr->id)) &&
                    !processor_cntl_external()) {
+#else
+               if (ACPI_FAILURE
+                   (acpi_processor_hotadd_init(pr->handle, &pr->id))) {
+#endif /* CONFIG_XEN */
                        printk(KERN_ERR PREFIX
                                    "Getting cpuindex for acpiid 0x%x\n",
                                    pr->acpi_id);
@@ -518,7 +523,11 @@ static int acpi_processor_get_info(struc
        return 0;
 }
 
+#ifdef CONFIG_XEN
 static void *processor_device_array[NR_ACPI_CPUS];
+#else
+static void *processor_device_array[NR_CPUS];
+#endif /* CONFIG_XEN */
 
 static int acpi_processor_start(struct acpi_device *device)
 {
@@ -530,29 +539,48 @@ static int acpi_processor_start(struct a
        pr = acpi_driver_data(device);
 
        result = acpi_processor_get_info(pr);
+#ifdef CONFIG_XEN
        if (result || 
            ((pr->id == -1) && !processor_cntl_external())) {
+#else
+       if (result) {
+#endif /* CONFIG_XEN */
                /* Processor is physically not present */
                return 0;
        }
 
+#ifdef CONFIG_XEN
        BUG_ON(!processor_cntl_external() &&
               ((pr->id >= NR_CPUS) || (pr->id < 0)));
+#else
+       BUG_ON((pr->id >= NR_CPUS) || (pr->id < 0));
+#endif /* CONFIG_XEN */
 
        /*
         * Buggy BIOS check
         * ACPI id of processors can be reported wrongly by the BIOS.
         * Don't trust it blindly
         */
+#ifdef CONFIG_XEN
        if (processor_device_array[pr->acpi_id] != NULL &&
            processor_device_array[pr->acpi_id] != (void *)device) {
+#else
+       if (processor_device_array[pr->id] != NULL &&
+           processor_device_array[pr->id] != (void *)device) {
+#endif /* CONFIG_XEN */
                printk(KERN_WARNING "BIOS reported wrong ACPI id"
                        "for the processor\n");
                return -ENODEV;
        }
+#ifdef CONFIG_XEN
        processor_device_array[pr->acpi_id] = (void *)device;
        if (pr->id != -1)
                processors[pr->id] = pr;
+#else
+       processor_device_array[pr->id] = (void *)device;
+
+       processors[pr->id] = pr;
+#endif /* CONFIG_XEN */
 
        result = acpi_processor_add_fs(device);
        if (result)
@@ -663,8 +691,13 @@ static int acpi_processor_remove(struct 
 
        acpi_processor_remove_fs(device);
 
+#ifdef CONFIG_XEN
        if (pr->id != -1)
                processors[pr->id] = NULL;
+#else
+       processors[pr->id] = NULL;
+#endif /* CONFIG_XEN */
+
 
        kfree(pr);
 
@@ -718,9 +751,11 @@ int acpi_processor_device_add(acpi_handl
        if (!pr)
                return -ENODEV;
 
+#ifdef CONFIG_XEN
        if (processor_cntl_external())
                processor_notify_external(pr,
                        PROCESSOR_HOTPLUG, HOTPLUG_TYPE_ADD);
+#endif /* CONFIG_XEN */
 
        if ((pr->id >= 0) && (pr->id < NR_CPUS)) {
                kobject_uevent(&(*device)->kobj, KOBJ_ONLINE);
@@ -760,9 +795,11 @@ acpi_processor_hotplug_notify(acpi_handl
                        break;
                }
 
+#ifdef CONFIG_XEN
                if (processor_cntl_external())
                        processor_notify_external(pr,
                                        PROCESSOR_HOTPLUG, HOTPLUG_TYPE_ADD);
+#endif /* CONFIG_XEN */
 
                if (pr->id >= 0 && (pr->id < NR_CPUS)) {
                        kobject_uevent(&device->kobj, KOBJ_OFFLINE);
@@ -793,13 +830,19 @@ acpi_processor_hotplug_notify(acpi_handl
                        return;
                }
 
+#ifdef CONFIG_XEN
                if ((pr->id >= 0) && (pr->id < NR_CPUS)
                    && (cpu_present(pr->id)))
+#else
+               if ((pr->id < NR_CPUS) && (cpu_present(pr->id)))
+#endif /* CONFIG_XEN */
                        kobject_uevent(&device->kobj, KOBJ_OFFLINE);
 
+#ifdef CONFIG_XEN
                if (processor_cntl_external())
                        processor_notify_external(pr, PROCESSOR_HOTPLUG,
                                                        HOTPLUG_TYPE_REMOVE);
+#endif /* CONFIG_XEN */
 
                break;
        default:
@@ -865,8 +908,10 @@ static acpi_status acpi_processor_hotadd
 
 static int acpi_processor_handle_eject(struct acpi_processor *pr)
 {
+#ifdef CONFIG_XEN
        if (pr->id == -1)
                return (0);
+#endif /* CONFIG_XEN */
 
        if (cpu_online(pr->id)) {
                return (-EINVAL);
diff -r 26c60aa94b9f -r e39cf97647af drivers/acpi/processor_idle.c
--- a/drivers/acpi/processor_idle.c     Mon May 05 10:14:25 2008 +0100
+++ b/drivers/acpi/processor_idle.c     Mon May 05 10:17:41 2008 +0100
@@ -714,12 +714,17 @@ static int acpi_processor_get_power_info
                    (reg->space_id != ACPI_ADR_SPACE_FIXED_HARDWARE))
                        continue;
 
+#ifdef CONFIG_XEN
                if (!processor_pm_external())
                        cx.address = (reg->space_id ==
                                      ACPI_ADR_SPACE_FIXED_HARDWARE) ?
                                      0 : reg->address;
                else
                        cx.address = reg->address;
+#else
+               cx.address = (reg->space_id == ACPI_ADR_SPACE_FIXED_HARDWARE) ?
+                   0 : reg->address;
+#endif /* CONFIG_XEN */
 
                /* There should be an easy way to extract an integer... */
                obj = (union acpi_object *)&(element->package.elements[1]);
@@ -728,11 +733,17 @@ static int acpi_processor_get_power_info
 
                cx.type = obj->integer.value;
 
+#ifdef CONFIG_XEN
                /* Following check doesn't apply to external control case */
                if (!processor_pm_external())
                        if ((cx.type != ACPI_STATE_C1) &&
                            (reg->space_id != ACPI_ADR_SPACE_SYSTEM_IO))
                                continue;
+#else
+               if ((cx.type != ACPI_STATE_C1) &&
+                   (reg->space_id != ACPI_ADR_SPACE_SYSTEM_IO))
+                       continue;
+#endif /* CONFIG_XEN */
 
                if ((cx.type < ACPI_STATE_C2) || (cx.type > ACPI_STATE_C3))
                        continue;
@@ -997,16 +1008,24 @@ int acpi_processor_cst_has_changed(struc
                return -ENODEV;
 
        /* Fall back to the default idle loop */
+#ifdef CONFIG_XEN
        if (!processor_pm_external())
                pm_idle = pm_idle_save;
+#else
+       pm_idle = pm_idle_save;
+#endif /* CONFIG_XEN */
        synchronize_sched();    /* Relies on interrupts forcing exit from idle. 
*/
 
        pr->flags.power = 0;
        result = acpi_processor_get_power_info(pr);
+#ifdef CONFIG_XEN
        if (processor_pm_external())
                processor_notify_external(pr,
                        PROCESSOR_PM_CHANGE, PM_TYPE_IDLE);
        else if ((pr->flags.power == 1) && (pr->flags.power_setup_done))
+#else
+       if ((pr->flags.power == 1) && (pr->flags.power_setup_done))
+#endif /* CONFIG_XEN */
                pm_idle = acpi_processor_idle;
 
        return result;
@@ -1138,7 +1157,11 @@ int acpi_processor_power_init(struct acp
                                       pr->power.states[i].type);
                printk(")\n");
 
+#ifdef CONFIG_XEN
                if (!processor_pm_external() && (pr->id == 0)) {
+#else
+               if (pr->id == 0) {
+#endif /* CONFIG_XEN */
                        pm_idle_save = pm_idle;
                        pm_idle = acpi_processor_idle;
                }
@@ -1157,9 +1180,11 @@ int acpi_processor_power_init(struct acp
 
        pr->flags.power_setup_done = 1;
 
+#ifdef CONFIG_XEN
        if (processor_pm_external())
                processor_notify_external(pr,
                        PROCESSOR_PM_INIT, PM_TYPE_IDLE);
+#endif /* CONFIG_XEN */
        return 0;
 }
 
diff -r 26c60aa94b9f -r e39cf97647af drivers/acpi/processor_perflib.c
--- a/drivers/acpi/processor_perflib.c  Mon May 05 10:14:25 2008 +0100
+++ b/drivers/acpi/processor_perflib.c  Mon May 05 10:17:41 2008 +0100
@@ -136,11 +136,13 @@ int acpi_processor_ppc_has_changed(struc
        int ret = acpi_processor_get_platform_limit(pr);
        if (ret < 0)
                return (ret);
-       else if (!processor_pmperf_external())
-               return cpufreq_update_policy(pr->id);
-       else
+#ifdef CONFIG_XEN
+       else if (processor_pmperf_external())
                return processor_notify_external(pr,
                                PROCESSOR_PM_CHANGE, PM_TYPE_PERF);
+#endif /* CONFIG_XEN */
+       else
+               return cpufreq_update_policy(pr->id);
 }
 
 void acpi_processor_ppc_init(void)
diff -r 26c60aa94b9f -r e39cf97647af include/acpi/processor.h
--- a/include/acpi/processor.h  Mon May 05 10:14:25 2008 +0100
+++ b/include/acpi/processor.h  Mon May 05 10:17:41 2008 +0100
@@ -21,7 +21,9 @@
 #define ACPI_PSD_REV0_REVISION         0 /* Support for _PSD as in ACPI 3.0 */
 #define ACPI_PSD_REV0_ENTRIES          5
 
+#ifdef CONFIG_XEN
 #define NR_ACPI_CPUS                   256
+#endif /* CONFIG_XEN */
 
 /*
  * Types of coordination defined in ACPI 3.0. Same macros can be used across
@@ -294,6 +296,7 @@ static inline void acpi_thermal_cpufreq_
 }
 #endif
 
+#ifdef CONFIG_XEN
 /* 
  * Following are interfaces geared to external processor PM control
  * logic like a VMM
@@ -365,5 +368,6 @@ static inline int processor_extcntl_init
        return -EINVAL;
 }
 #endif /* CONFIG_PROCESSOR_EXTERNAL_CONTROL */
-
-#endif
+#endif /* CONFIG_XEN */
+
+#endif

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.