ACPICA: Fix extraneous warning if _DSM returns a package
[safe/jmp/linux-2.6] / drivers / acpi / osl.c
index b3193ec..5691f16 100644 (file)
@@ -79,6 +79,7 @@ static acpi_osd_handler acpi_irq_handler;
 static void *acpi_irq_context;
 static struct workqueue_struct *kacpid_wq;
 static struct workqueue_struct *kacpi_notify_wq;
+static struct workqueue_struct *kacpi_hotplug_wq;
 
 struct acpi_res_list {
        resource_size_t start;
@@ -188,12 +189,39 @@ acpi_status __init acpi_os_initialize(void)
        return AE_OK;
 }
 
+static void bind_to_cpu0(struct work_struct *work)
+{
+       set_cpus_allowed(current, cpumask_of_cpu(0));
+       kfree(work);
+}
+
+static void bind_workqueue(struct workqueue_struct *wq)
+{
+       struct work_struct *work;
+
+       work = kzalloc(sizeof(struct work_struct), GFP_KERNEL);
+       INIT_WORK(work, bind_to_cpu0);
+       queue_work(wq, work);
+}
+
 acpi_status acpi_os_initialize1(void)
 {
+       /*
+        * On some machines, a software-initiated SMI causes corruption unless
+        * the SMI runs on CPU 0.  An SMI can be initiated by any AML, but
+        * typically it's done in GPE-related methods that are run via
+        * workqueues, so we can avoid the known corruption cases by binding
+        * the workqueues to CPU 0.
+        */
        kacpid_wq = create_singlethread_workqueue("kacpid");
+       bind_workqueue(kacpid_wq);
        kacpi_notify_wq = create_singlethread_workqueue("kacpi_notify");
+       bind_workqueue(kacpi_notify_wq);
+       kacpi_hotplug_wq = create_singlethread_workqueue("kacpi_hotplug");
+       bind_workqueue(kacpi_hotplug_wq);
        BUG_ON(!kacpid_wq);
        BUG_ON(!kacpi_notify_wq);
+       BUG_ON(!kacpi_hotplug_wq);
        return AE_OK;
 }
 
@@ -206,6 +234,7 @@ acpi_status acpi_os_terminate(void)
 
        destroy_workqueue(kacpid_wq);
        destroy_workqueue(kacpi_notify_wq);
+       destroy_workqueue(kacpi_hotplug_wq);
 
        return AE_OK;
 }
@@ -272,14 +301,21 @@ acpi_os_map_memory(acpi_physical_address phys, acpi_size size)
 }
 EXPORT_SYMBOL_GPL(acpi_os_map_memory);
 
-void acpi_os_unmap_memory(void __iomem * virt, acpi_size size)
+void __ref acpi_os_unmap_memory(void __iomem *virt, acpi_size size)
 {
-       if (acpi_gbl_permanent_mmap) {
+       if (acpi_gbl_permanent_mmap)
                iounmap(virt);
-       }
+       else
+               __acpi_unmap_table(virt, size);
 }
 EXPORT_SYMBOL_GPL(acpi_os_unmap_memory);
 
+void __init early_acpi_os_unmap_memory(void __iomem *virt, acpi_size size)
+{
+       if (!acpi_gbl_permanent_mmap)
+               __acpi_unmap_table(virt, size);
+}
+
 #ifdef ACPI_FUTURE_USAGE
 acpi_status
 acpi_os_get_physical_address(void *virt, acpi_physical_address * phys)
@@ -346,8 +382,10 @@ static irqreturn_t acpi_irq(int irq, void *dev_id)
        if (handled) {
                acpi_irq_handled++;
                return IRQ_HANDLED;
-       } else
+       } else {
+               acpi_irq_not_handled++;
                return IRQ_NONE;
+       }
 }
 
 acpi_status
@@ -707,6 +745,7 @@ static acpi_status __acpi_os_execute(acpi_execute_type type,
        acpi_status status = AE_OK;
        struct acpi_os_dpc *dpc;
        struct workqueue_struct *queue;
+       work_func_t func;
        int ret;
        ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
                          "Scheduling function [%p(%p)] for deferred execution.\n",
@@ -731,15 +770,17 @@ static acpi_status __acpi_os_execute(acpi_execute_type type,
        dpc->function = function;
        dpc->context = context;
 
-       if (!hp) {
-               INIT_WORK(&dpc->work, acpi_os_execute_deferred);
-               queue = (type == OSL_NOTIFY_HANDLER) ?
-                       kacpi_notify_wq : kacpid_wq;
-               ret = queue_work(queue, &dpc->work);
-       } else {
-               INIT_WORK(&dpc->work, acpi_os_execute_hp_deferred);
-               ret = schedule_work(&dpc->work);
-       }
+       /*
+        * We can't run hotplug code in keventd_wq/kacpid_wq/kacpid_notify_wq
+        * because the hotplug code may call driver .remove() functions,
+        * which invoke flush_scheduled_work/acpi_os_wait_events_complete
+        * to flush these workqueues.
+        */
+       queue = hp ? kacpi_hotplug_wq :
+               (type == OSL_NOTIFY_HANDLER ? kacpi_notify_wq : kacpid_wq);
+       func = hp ? acpi_os_execute_hp_deferred : acpi_os_execute_deferred;
+       INIT_WORK(&dpc->work, func);
+       ret = queue_work(queue, &dpc->work);
 
        if (!ret) {
                printk(KERN_ERR PREFIX
@@ -1063,9 +1104,9 @@ __setup("acpi_wake_gpes_always_on", acpi_wake_gpes_always_on_setup);
  * in arbitrary AML code and can interfere with legacy drivers.
  * acpi_enforce_resources= can be set to:
  *
- *   - strict           (2)
+ *   - strict (default) (2)
  *     -> further driver trying to access the resources will not load
- *   - lax (default)    (1)
+ *   - lax              (1)
  *     -> further driver trying to access the resources will load, but you
  *     get a system message that something might go wrong...
  *
@@ -1077,7 +1118,7 @@ __setup("acpi_wake_gpes_always_on", acpi_wake_gpes_always_on_setup);
 #define ENFORCE_RESOURCES_LAX    1
 #define ENFORCE_RESOURCES_NO     0
 
-static unsigned int acpi_enforce_resources = ENFORCE_RESOURCES_LAX;
+static unsigned int acpi_enforce_resources = ENFORCE_RESOURCES_STRICT;
 
 static int __init acpi_enforce_resources_setup(char *str)
 {
@@ -1317,54 +1358,6 @@ acpi_os_validate_interface (char *interface)
        return AE_SUPPORT;
 }
 
-#ifdef CONFIG_X86
-
-struct aml_port_desc {
-       uint    start;
-       uint    end;
-       char*   name;
-       char    warned;
-};
-
-static struct aml_port_desc aml_invalid_port_list[] = {
-       {0x20, 0x21, "PIC0", 0},
-       {0xA0, 0xA1, "PIC1", 0},
-       {0x4D0, 0x4D1, "ELCR", 0}
-};
-
-/*
- * valid_aml_io_address()
- *
- * if valid, return true
- * else invalid, warn once, return false
- */
-static bool valid_aml_io_address(uint address, uint length)
-{
-       int i;
-       int entries = sizeof(aml_invalid_port_list) / sizeof(struct aml_port_desc);
-
-       for (i = 0; i < entries; ++i) {
-               if ((address >= aml_invalid_port_list[i].start &&
-                       address <= aml_invalid_port_list[i].end) ||
-                       (address + length >= aml_invalid_port_list[i].start &&
-                       address  + length <= aml_invalid_port_list[i].end))
-               {
-                       if (!aml_invalid_port_list[i].warned)
-                       {
-                               printk(KERN_ERR "ACPI: Denied BIOS AML access"
-                                       " to invalid port 0x%x+0x%x (%s)\n",
-                                       address, length,
-                                       aml_invalid_port_list[i].name);
-                               aml_invalid_port_list[i].warned = 1;
-                       }
-                       return false;   /* invalid */
-               }
-       }
-       return true;    /* valid */
-}
-#else
-static inline bool valid_aml_io_address(uint address, uint length) { return true; }
-#endif
 /******************************************************************************
  *
  * FUNCTION:    acpi_os_validate_address
@@ -1394,8 +1387,6 @@ acpi_os_validate_address (
 
        switch (space_id) {
        case ACPI_ADR_SPACE_SYSTEM_IO:
-               if (!valid_aml_io_address(address, length))
-                       return AE_AML_ILLEGAL_ADDRESS;
        case ACPI_ADR_SPACE_SYSTEM_MEMORY:
                /* Only interference checks against SystemIO and SytemMemory
                   are needed */