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

[Xen-changelog] [linux-2.6.18-xen] linux/acpi: adjust extcntl's changes to (mostly) common code, mostly for readability



# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1216819256 -3600
# Node ID f4b11ef0c6eb6e297f94da36885437369360cdbf
# Parent  72234a8ee99cb0f56c856f28ffbe2b10d2ea1ebc
linux/acpi: adjust extcntl's changes to (mostly) common code, mostly for 
readability

While I realize that it may have been upon my request that all these
#ifdef-s were introduced, I think this went too far here: With the
abstraction in include/acpi/processor.h in place, the code still
guarantees even without all these #ifdef-s that in native kernels
built from the same source the logic will not change.

The one thing that appears a little weak still is the NR_ACPI_CPUS
construct - nothing guarantees that the ACPI IDs are constrained to 8
bits, and hence using an array here doesn't seem either safe or
scalable looking forward. To make the issue explict, the patch adds a
respective BUG_ON().

Also remove a stray export.

Signed-off-by: Jan Beulich <jbeulich@xxxxxxxxxx>
---
 arch/i386/kernel/acpi/processor_extcntl_xen.c |    1 
 drivers/acpi/processor_core.c                 |   30 +++-----------------------
 drivers/acpi/processor_idle.c                 |   29 +------------------------
 drivers/acpi/processor_perflib.c              |   12 +++-------
 include/acpi/processor.h                      |   16 ++++++-------
 5 files changed, 18 insertions(+), 70 deletions(-)

diff -r 72234a8ee99c -r f4b11ef0c6eb 
arch/i386/kernel/acpi/processor_extcntl_xen.c
--- a/arch/i386/kernel/acpi/processor_extcntl_xen.c     Wed Jul 23 13:37:30 
2008 +0100
+++ b/arch/i386/kernel/acpi/processor_extcntl_xen.c     Wed Jul 23 14:20:56 
2008 +0100
@@ -40,7 +40,6 @@ static int __init set_xen_processor_pmbi
        return 1;
 }
 __setup("xen_processor_pmbits=", set_xen_processor_pmbits);
-EXPORT_SYMBOL(xen_processor_pmbits);
 
 static int xen_cx_notifier(struct acpi_processor *pr, int action)
 {
diff -r 72234a8ee99c -r f4b11ef0c6eb drivers/acpi/processor_core.c
--- a/drivers/acpi/processor_core.c     Wed Jul 23 13:37:30 2008 +0100
+++ b/drivers/acpi/processor_core.c     Wed Jul 23 14:20:56 2008 +0100
@@ -474,14 +474,9 @@ 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);
@@ -523,11 +518,7 @@ 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)
 {
@@ -539,22 +530,14 @@ 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
@@ -562,6 +545,7 @@ static int acpi_processor_start(struct a
         * Don't trust it blindly
         */
 #ifdef CONFIG_XEN
+       BUG_ON(pr->acpi_id >= NR_ACPI_CPUS);
        if (processor_device_array[pr->acpi_id] != NULL &&
            processor_device_array[pr->acpi_id] != (void *)device) {
 #else
@@ -595,9 +579,9 @@ static int acpi_processor_start(struct a
 
        acpi_processor_power_init(pr, device);
 
-#ifdef CONFIG_PROCESSOR_EXTERNAL_CONTROL
-       processor_extcntl_init(pr);
-#endif
+       result = processor_extcntl_init(pr);
+       if (result)
+               goto end;
 
        if (pr->flags.throttling) {
                printk(KERN_INFO PREFIX "%s [%s] (supports",
@@ -751,11 +735,9 @@ 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);
@@ -795,11 +777,9 @@ 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);
@@ -838,11 +818,9 @@ acpi_processor_hotplug_notify(acpi_handl
 #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:
diff -r 72234a8ee99c -r f4b11ef0c6eb drivers/acpi/processor_idle.c
--- a/drivers/acpi/processor_idle.c     Wed Jul 23 13:37:30 2008 +0100
+++ b/drivers/acpi/processor_idle.c     Wed Jul 23 14:20:56 2008 +0100
@@ -714,17 +714,12 @@ 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]);
@@ -733,17 +728,11 @@ 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) &&
+               if (!processor_pm_external() &&
+                   (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;
@@ -1008,24 +997,16 @@ 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;
@@ -1157,11 +1138,7 @@ 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;
                }
@@ -1180,11 +1157,9 @@ 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 72234a8ee99c -r f4b11ef0c6eb drivers/acpi/processor_perflib.c
--- a/drivers/acpi/processor_perflib.c  Wed Jul 23 13:37:30 2008 +0100
+++ b/drivers/acpi/processor_perflib.c  Wed Jul 23 14:20:56 2008 +0100
@@ -136,11 +136,9 @@ int acpi_processor_ppc_has_changed(struc
        int ret = acpi_processor_get_platform_limit(pr);
        if (ret < 0)
                return (ret);
-#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);
 }
@@ -305,10 +303,9 @@ static int acpi_processor_get_performanc
 }
 
 #ifndef CONFIG_PROCESSOR_EXTERNAL_CONTROL
-static int acpi_processor_get_performance_info(struct acpi_processor *pr)
-#else
+static
+#endif
 int acpi_processor_get_performance_info(struct acpi_processor *pr)
-#endif
 {
        int result = 0;
        acpi_status status = AE_OK;
@@ -548,10 +545,9 @@ static void acpi_cpufreq_remove_file(str
 #endif                         /* CONFIG_X86_ACPI_CPUFREQ_PROC_INTF */
 
 #ifndef CONFIG_PROCESSOR_EXTERNAL_CONTROL
-static int acpi_processor_get_psd(struct acpi_processor        *pr)
-#else
+static
+#endif
 int acpi_processor_get_psd(struct acpi_processor *pr)
-#endif
 {
        int result = 0;
        acpi_status status = AE_OK;
diff -r 72234a8ee99c -r f4b11ef0c6eb include/acpi/processor.h
--- a/include/acpi/processor.h  Wed Jul 23 13:37:30 2008 +0100
+++ b/include/acpi/processor.h  Wed Jul 23 14:20:56 2008 +0100
@@ -22,7 +22,9 @@
 #define ACPI_PSD_REV0_ENTRIES          5
 
 #ifdef CONFIG_XEN
-#define NR_ACPI_CPUS                   256
+#define NR_ACPI_CPUS                   (NR_CPUS < 256 ? 256 : NR_CPUS)
+#else
+#define NR_ACPI_CPUS                   NR_CPUS
 #endif /* CONFIG_XEN */
 
 /*
@@ -296,7 +298,6 @@ static inline void acpi_thermal_cpufreq_
 }
 #endif
 
-#ifdef CONFIG_XEN
 /* 
  * Following are interfaces geared to external processor PM control
  * logic like a VMM
@@ -306,7 +307,7 @@ static inline void acpi_thermal_cpufreq_
 #define PROCESSOR_PM_CHANGE    2
 #define PROCESSOR_HOTPLUG      3
 
-/* Objects for the PM envents */
+/* Objects for the PM events */
 #define PM_TYPE_IDLE           0
 #define PM_TYPE_PERF           1
 #define PM_TYPE_THR            2
@@ -362,13 +363,12 @@ static inline int processor_notify_exter
 static inline int processor_notify_external(struct acpi_processor *pr,
                        int event, int type)
 {
-       return -EINVAL;
+       return 0;
 }
 static inline int processor_extcntl_init(struct acpi_processor *pr)
 {
-       return -EINVAL;
+       return 0;
 }
 #endif /* CONFIG_PROCESSOR_EXTERNAL_CONTROL */
-#endif /* CONFIG_XEN */
-
-#endif
+
+#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®.