Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * acpi_osl.c - OS-dependent functions ($Revision: 83 $) |
| 3 | * |
| 4 | * Copyright (C) 2000 Andrew Henroid |
| 5 | * Copyright (C) 2001, 2002 Andy Grover <andrew.grover@intel.com> |
| 6 | * Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com> |
Matthew Wilcox | f1241c8 | 2008-03-14 13:43:13 -0400 | [diff] [blame] | 7 | * Copyright (c) 2008 Intel Corporation |
| 8 | * Author: Matthew Wilcox <willy@linux.intel.com> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 9 | * |
| 10 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 11 | * |
| 12 | * This program is free software; you can redistribute it and/or modify |
| 13 | * it under the terms of the GNU General Public License as published by |
| 14 | * the Free Software Foundation; either version 2 of the License, or |
| 15 | * (at your option) any later version. |
| 16 | * |
| 17 | * This program is distributed in the hope that it will be useful, |
| 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 20 | * GNU General Public License for more details. |
| 21 | * |
| 22 | * You should have received a copy of the GNU General Public License |
| 23 | * along with this program; if not, write to the Free Software |
| 24 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 25 | * |
| 26 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 27 | * |
| 28 | */ |
| 29 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 30 | #include <linux/module.h> |
| 31 | #include <linux/kernel.h> |
| 32 | #include <linux/slab.h> |
| 33 | #include <linux/mm.h> |
| 34 | #include <linux/pci.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 35 | #include <linux/interrupt.h> |
| 36 | #include <linux/kmod.h> |
| 37 | #include <linux/delay.h> |
| 38 | #include <linux/workqueue.h> |
| 39 | #include <linux/nmi.h> |
Alexey Starikovskiy | ad71860a | 2007-02-02 19:48:19 +0300 | [diff] [blame] | 40 | #include <linux/acpi.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 41 | #include <linux/efi.h> |
Thomas Renninger | df92e69 | 2008-02-04 23:31:22 -0800 | [diff] [blame] | 42 | #include <linux/ioport.h> |
| 43 | #include <linux/list.h> |
Matthew Wilcox | f1241c8 | 2008-03-14 13:43:13 -0400 | [diff] [blame] | 44 | #include <linux/jiffies.h> |
| 45 | #include <linux/semaphore.h> |
| 46 | |
| 47 | #include <asm/io.h> |
| 48 | #include <asm/uaccess.h> |
| 49 | |
| 50 | #include <acpi/acpi.h> |
| 51 | #include <acpi/acpi_bus.h> |
| 52 | #include <acpi/processor.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 53 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 54 | #define _COMPONENT ACPI_OS_SERVICES |
Len Brown | f52fd66 | 2007-02-12 22:42:12 -0500 | [diff] [blame] | 55 | ACPI_MODULE_NAME("osl"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 56 | #define PREFIX "ACPI: " |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 57 | struct acpi_os_dpc { |
| 58 | acpi_osd_exec_callback function; |
| 59 | void *context; |
David Howells | 65f27f3 | 2006-11-22 14:55:48 +0000 | [diff] [blame] | 60 | struct work_struct work; |
Bjorn Helgaas | 9ac6185 | 2009-08-31 22:32:10 +0000 | [diff] [blame] | 61 | int wait; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 62 | }; |
| 63 | |
| 64 | #ifdef CONFIG_ACPI_CUSTOM_DSDT |
| 65 | #include CONFIG_ACPI_CUSTOM_DSDT_FILE |
| 66 | #endif |
| 67 | |
| 68 | #ifdef ENABLE_DEBUGGER |
| 69 | #include <linux/kdb.h> |
| 70 | |
| 71 | /* stuff for debugger support */ |
| 72 | int acpi_in_debugger; |
| 73 | EXPORT_SYMBOL(acpi_in_debugger); |
| 74 | |
| 75 | extern char line_buf[80]; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 76 | #endif /*ENABLE_DEBUGGER */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 77 | |
| 78 | static unsigned int acpi_irq_irq; |
| 79 | static acpi_osd_handler acpi_irq_handler; |
| 80 | static void *acpi_irq_context; |
| 81 | static struct workqueue_struct *kacpid_wq; |
Alexey Starikovskiy | 88db5e1 | 2007-05-09 23:31:03 -0400 | [diff] [blame] | 82 | static struct workqueue_struct *kacpi_notify_wq; |
Zhang Rui | c02256b | 2009-06-23 10:20:29 +0800 | [diff] [blame] | 83 | static struct workqueue_struct *kacpi_hotplug_wq; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 84 | |
Thomas Renninger | df92e69 | 2008-02-04 23:31:22 -0800 | [diff] [blame] | 85 | struct acpi_res_list { |
| 86 | resource_size_t start; |
| 87 | resource_size_t end; |
| 88 | acpi_adr_space_type resource_type; /* IO port, System memory, ...*/ |
| 89 | char name[5]; /* only can have a length of 4 chars, make use of this |
| 90 | one instead of res->name, no need to kalloc then */ |
| 91 | struct list_head resource_list; |
Lin Ming | a5fe1a0 | 2009-08-13 10:43:27 +0800 | [diff] [blame] | 92 | int count; |
Thomas Renninger | df92e69 | 2008-02-04 23:31:22 -0800 | [diff] [blame] | 93 | }; |
| 94 | |
| 95 | static LIST_HEAD(resource_list_head); |
| 96 | static DEFINE_SPINLOCK(acpi_res_lock); |
| 97 | |
Myron Stowe | 620242a | 2010-10-21 14:23:53 -0600 | [diff] [blame] | 98 | /* |
| 99 | * This list of permanent mappings is for memory that may be accessed from |
| 100 | * interrupt context, where we can't do the ioremap(). |
| 101 | */ |
| 102 | struct acpi_ioremap { |
| 103 | struct list_head list; |
| 104 | void __iomem *virt; |
| 105 | acpi_physical_address phys; |
| 106 | acpi_size size; |
| 107 | }; |
| 108 | |
| 109 | static LIST_HEAD(acpi_ioremaps); |
| 110 | static DEFINE_SPINLOCK(acpi_ioremap_lock); |
| 111 | |
Len Brown | ae00d81 | 2007-05-29 18:43:33 -0400 | [diff] [blame] | 112 | #define OSI_STRING_LENGTH_MAX 64 /* arbitrary */ |
| 113 | static char osi_additional_string[OSI_STRING_LENGTH_MAX]; |
| 114 | |
Len Brown | d4b7dc4 | 2008-01-23 20:50:56 -0500 | [diff] [blame] | 115 | /* |
Len Brown | a6e0887 | 2008-11-08 01:21:10 -0500 | [diff] [blame] | 116 | * The story of _OSI(Linux) |
Len Brown | d4b7dc4 | 2008-01-23 20:50:56 -0500 | [diff] [blame] | 117 | * |
Len Brown | a6e0887 | 2008-11-08 01:21:10 -0500 | [diff] [blame] | 118 | * From pre-history through Linux-2.6.22, |
| 119 | * Linux responded TRUE upon a BIOS OSI(Linux) query. |
Len Brown | d4b7dc4 | 2008-01-23 20:50:56 -0500 | [diff] [blame] | 120 | * |
Len Brown | a6e0887 | 2008-11-08 01:21:10 -0500 | [diff] [blame] | 121 | * Unfortunately, reference BIOS writers got wind of this |
| 122 | * and put OSI(Linux) in their example code, quickly exposing |
| 123 | * this string as ill-conceived and opening the door to |
| 124 | * an un-bounded number of BIOS incompatibilities. |
Len Brown | d4b7dc4 | 2008-01-23 20:50:56 -0500 | [diff] [blame] | 125 | * |
Len Brown | a6e0887 | 2008-11-08 01:21:10 -0500 | [diff] [blame] | 126 | * For example, OSI(Linux) was used on resume to re-POST a |
| 127 | * video card on one system, because Linux at that time |
| 128 | * could not do a speedy restore in its native driver. |
| 129 | * But then upon gaining quick native restore capability, |
| 130 | * Linux has no way to tell the BIOS to skip the time-consuming |
| 131 | * POST -- putting Linux at a permanent performance disadvantage. |
| 132 | * On another system, the BIOS writer used OSI(Linux) |
| 133 | * to infer native OS support for IPMI! On other systems, |
| 134 | * OSI(Linux) simply got in the way of Linux claiming to |
| 135 | * be compatible with other operating systems, exposing |
| 136 | * BIOS issues such as skipped device initialization. |
Len Brown | d4b7dc4 | 2008-01-23 20:50:56 -0500 | [diff] [blame] | 137 | * |
Len Brown | a6e0887 | 2008-11-08 01:21:10 -0500 | [diff] [blame] | 138 | * So "Linux" turned out to be a really poor chose of |
| 139 | * OSI string, and from Linux-2.6.23 onward we respond FALSE. |
Len Brown | d4b7dc4 | 2008-01-23 20:50:56 -0500 | [diff] [blame] | 140 | * |
| 141 | * BIOS writers should NOT query _OSI(Linux) on future systems. |
Len Brown | a6e0887 | 2008-11-08 01:21:10 -0500 | [diff] [blame] | 142 | * Linux will complain on the console when it sees it, and return FALSE. |
| 143 | * To get Linux to return TRUE for your system will require |
| 144 | * a kernel source update to add a DMI entry, |
| 145 | * or boot with "acpi_osi=Linux" |
Len Brown | d4b7dc4 | 2008-01-23 20:50:56 -0500 | [diff] [blame] | 146 | */ |
Len Brown | d4b7dc4 | 2008-01-23 20:50:56 -0500 | [diff] [blame] | 147 | |
Adrian Bunk | 1d15d84 | 2008-01-29 00:10:15 +0200 | [diff] [blame] | 148 | static struct osi_linux { |
Len Brown | d4b7dc4 | 2008-01-23 20:50:56 -0500 | [diff] [blame] | 149 | unsigned int enable:1; |
| 150 | unsigned int dmi:1; |
| 151 | unsigned int cmdline:1; |
| 152 | unsigned int known:1; |
Len Brown | a6e0887 | 2008-11-08 01:21:10 -0500 | [diff] [blame] | 153 | } osi_linux = { 0, 0, 0, 0}; |
Len Brown | f507654 | 2007-05-30 00:10:38 -0400 | [diff] [blame] | 154 | |
Bjorn Helgaas | 9a47cdb | 2007-01-18 16:42:55 -0700 | [diff] [blame] | 155 | static void __init acpi_request_region (struct acpi_generic_address *addr, |
| 156 | unsigned int length, char *desc) |
| 157 | { |
Bjorn Helgaas | 9a47cdb | 2007-01-18 16:42:55 -0700 | [diff] [blame] | 158 | if (!addr->address || !length) |
| 159 | return; |
| 160 | |
Andi Kleen | cfa806f | 2010-07-20 15:18:36 -0700 | [diff] [blame] | 161 | /* Resources are never freed */ |
Len Brown | eee3c85 | 2007-02-03 01:38:16 -0500 | [diff] [blame] | 162 | if (addr->space_id == ACPI_ADR_SPACE_SYSTEM_IO) |
Andi Kleen | cfa806f | 2010-07-20 15:18:36 -0700 | [diff] [blame] | 163 | request_region(addr->address, length, desc); |
Len Brown | eee3c85 | 2007-02-03 01:38:16 -0500 | [diff] [blame] | 164 | else if (addr->space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY) |
Andi Kleen | cfa806f | 2010-07-20 15:18:36 -0700 | [diff] [blame] | 165 | request_mem_region(addr->address, length, desc); |
Bjorn Helgaas | 9a47cdb | 2007-01-18 16:42:55 -0700 | [diff] [blame] | 166 | } |
| 167 | |
| 168 | static int __init acpi_reserve_resources(void) |
| 169 | { |
Len Brown | eee3c85 | 2007-02-03 01:38:16 -0500 | [diff] [blame] | 170 | acpi_request_region(&acpi_gbl_FADT.xpm1a_event_block, acpi_gbl_FADT.pm1_event_length, |
Bjorn Helgaas | 9a47cdb | 2007-01-18 16:42:55 -0700 | [diff] [blame] | 171 | "ACPI PM1a_EVT_BLK"); |
| 172 | |
Len Brown | eee3c85 | 2007-02-03 01:38:16 -0500 | [diff] [blame] | 173 | acpi_request_region(&acpi_gbl_FADT.xpm1b_event_block, acpi_gbl_FADT.pm1_event_length, |
Bjorn Helgaas | 9a47cdb | 2007-01-18 16:42:55 -0700 | [diff] [blame] | 174 | "ACPI PM1b_EVT_BLK"); |
| 175 | |
Len Brown | eee3c85 | 2007-02-03 01:38:16 -0500 | [diff] [blame] | 176 | acpi_request_region(&acpi_gbl_FADT.xpm1a_control_block, acpi_gbl_FADT.pm1_control_length, |
Bjorn Helgaas | 9a47cdb | 2007-01-18 16:42:55 -0700 | [diff] [blame] | 177 | "ACPI PM1a_CNT_BLK"); |
| 178 | |
Len Brown | eee3c85 | 2007-02-03 01:38:16 -0500 | [diff] [blame] | 179 | acpi_request_region(&acpi_gbl_FADT.xpm1b_control_block, acpi_gbl_FADT.pm1_control_length, |
Bjorn Helgaas | 9a47cdb | 2007-01-18 16:42:55 -0700 | [diff] [blame] | 180 | "ACPI PM1b_CNT_BLK"); |
| 181 | |
Len Brown | eee3c85 | 2007-02-03 01:38:16 -0500 | [diff] [blame] | 182 | if (acpi_gbl_FADT.pm_timer_length == 4) |
| 183 | acpi_request_region(&acpi_gbl_FADT.xpm_timer_block, 4, "ACPI PM_TMR"); |
Bjorn Helgaas | 9a47cdb | 2007-01-18 16:42:55 -0700 | [diff] [blame] | 184 | |
Len Brown | eee3c85 | 2007-02-03 01:38:16 -0500 | [diff] [blame] | 185 | acpi_request_region(&acpi_gbl_FADT.xpm2_control_block, acpi_gbl_FADT.pm2_control_length, |
Bjorn Helgaas | 9a47cdb | 2007-01-18 16:42:55 -0700 | [diff] [blame] | 186 | "ACPI PM2_CNT_BLK"); |
| 187 | |
| 188 | /* Length of GPE blocks must be a non-negative multiple of 2 */ |
| 189 | |
Len Brown | eee3c85 | 2007-02-03 01:38:16 -0500 | [diff] [blame] | 190 | if (!(acpi_gbl_FADT.gpe0_block_length & 0x1)) |
| 191 | acpi_request_region(&acpi_gbl_FADT.xgpe0_block, |
| 192 | acpi_gbl_FADT.gpe0_block_length, "ACPI GPE0_BLK"); |
Bjorn Helgaas | 9a47cdb | 2007-01-18 16:42:55 -0700 | [diff] [blame] | 193 | |
Len Brown | eee3c85 | 2007-02-03 01:38:16 -0500 | [diff] [blame] | 194 | if (!(acpi_gbl_FADT.gpe1_block_length & 0x1)) |
| 195 | acpi_request_region(&acpi_gbl_FADT.xgpe1_block, |
| 196 | acpi_gbl_FADT.gpe1_block_length, "ACPI GPE1_BLK"); |
Bjorn Helgaas | 9a47cdb | 2007-01-18 16:42:55 -0700 | [diff] [blame] | 197 | |
| 198 | return 0; |
| 199 | } |
| 200 | device_initcall(acpi_reserve_resources); |
| 201 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 202 | void acpi_os_printf(const char *fmt, ...) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 203 | { |
| 204 | va_list args; |
| 205 | va_start(args, fmt); |
| 206 | acpi_os_vprintf(fmt, args); |
| 207 | va_end(args); |
| 208 | } |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 209 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 210 | void acpi_os_vprintf(const char *fmt, va_list args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 211 | { |
| 212 | static char buffer[512]; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 213 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 214 | vsprintf(buffer, fmt, args); |
| 215 | |
| 216 | #ifdef ENABLE_DEBUGGER |
| 217 | if (acpi_in_debugger) { |
| 218 | kdb_printf("%s", buffer); |
| 219 | } else { |
Frank Seidel | 4d93915 | 2009-02-04 17:03:07 +0100 | [diff] [blame] | 220 | printk(KERN_CONT "%s", buffer); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 221 | } |
| 222 | #else |
Frank Seidel | 4d93915 | 2009-02-04 17:03:07 +0100 | [diff] [blame] | 223 | printk(KERN_CONT "%s", buffer); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 224 | #endif |
| 225 | } |
| 226 | |
Alexey Starikovskiy | ad71860a | 2007-02-02 19:48:19 +0300 | [diff] [blame] | 227 | acpi_physical_address __init acpi_os_get_root_pointer(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 228 | { |
| 229 | if (efi_enabled) { |
Bjorn Helgaas | b2c99e3 | 2006-03-26 01:37:08 -0800 | [diff] [blame] | 230 | if (efi.acpi20 != EFI_INVALID_TABLE_ADDR) |
Alexey Starikovskiy | ad71860a | 2007-02-02 19:48:19 +0300 | [diff] [blame] | 231 | return efi.acpi20; |
Bjorn Helgaas | b2c99e3 | 2006-03-26 01:37:08 -0800 | [diff] [blame] | 232 | else if (efi.acpi != EFI_INVALID_TABLE_ADDR) |
Alexey Starikovskiy | ad71860a | 2007-02-02 19:48:19 +0300 | [diff] [blame] | 233 | return efi.acpi; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 234 | else { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 235 | printk(KERN_ERR PREFIX |
| 236 | "System description tables not found\n"); |
Alexey Starikovskiy | ad71860a | 2007-02-02 19:48:19 +0300 | [diff] [blame] | 237 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 238 | } |
Len Brown | 239665a | 2007-11-23 20:08:02 -0500 | [diff] [blame] | 239 | } else { |
| 240 | acpi_physical_address pa = 0; |
| 241 | |
| 242 | acpi_find_root_pointer(&pa); |
| 243 | return pa; |
| 244 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 245 | } |
| 246 | |
Myron Stowe | 78cdb3e | 2010-10-21 14:24:09 -0600 | [diff] [blame^] | 247 | /* Must be called with 'acpi_ioremap_lock' or RCU read lock held. */ |
Myron Stowe | 620242a | 2010-10-21 14:23:53 -0600 | [diff] [blame] | 248 | static void __iomem * |
| 249 | acpi_map_vaddr_lookup(acpi_physical_address phys, acpi_size size) |
| 250 | { |
| 251 | struct acpi_ioremap *map; |
| 252 | |
Myron Stowe | 78cdb3e | 2010-10-21 14:24:09 -0600 | [diff] [blame^] | 253 | list_for_each_entry_rcu(map, &acpi_ioremaps, list) |
Myron Stowe | 620242a | 2010-10-21 14:23:53 -0600 | [diff] [blame] | 254 | if (map->phys <= phys && |
| 255 | phys + size <= map->phys + map->size) |
| 256 | return map->virt + (phys - map->phys); |
| 257 | |
| 258 | return NULL; |
| 259 | } |
| 260 | |
Myron Stowe | 78cdb3e | 2010-10-21 14:24:09 -0600 | [diff] [blame^] | 261 | /* Must be called with 'acpi_ioremap_lock' or RCU read lock held. */ |
Myron Stowe | 620242a | 2010-10-21 14:23:53 -0600 | [diff] [blame] | 262 | static struct acpi_ioremap * |
| 263 | acpi_map_lookup_virt(void __iomem *virt, acpi_size size) |
| 264 | { |
| 265 | struct acpi_ioremap *map; |
| 266 | |
Myron Stowe | 78cdb3e | 2010-10-21 14:24:09 -0600 | [diff] [blame^] | 267 | list_for_each_entry_rcu(map, &acpi_ioremaps, list) |
Myron Stowe | 620242a | 2010-10-21 14:23:53 -0600 | [diff] [blame] | 268 | if (map->virt == virt && map->size == size) |
| 269 | return map; |
| 270 | |
| 271 | return NULL; |
| 272 | } |
| 273 | |
Jan Beulich | 2fdf074 | 2007-12-13 08:33:59 +0000 | [diff] [blame] | 274 | void __iomem *__init_refok |
| 275 | acpi_os_map_memory(acpi_physical_address phys, acpi_size size) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 276 | { |
Myron Stowe | 620242a | 2010-10-21 14:23:53 -0600 | [diff] [blame] | 277 | struct acpi_ioremap *map; |
| 278 | unsigned long flags; |
| 279 | void __iomem *virt; |
| 280 | |
Bjorn Helgaas | 9f4fd61 | 2006-03-26 01:37:10 -0800 | [diff] [blame] | 281 | if (phys > ULONG_MAX) { |
| 282 | printk(KERN_ERR PREFIX "Cannot map memory that high\n"); |
Randy Dunlap | 70c0846 | 2007-02-13 16:11:36 -0800 | [diff] [blame] | 283 | return NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 284 | } |
Myron Stowe | 620242a | 2010-10-21 14:23:53 -0600 | [diff] [blame] | 285 | |
| 286 | if (!acpi_gbl_permanent_mmap) |
Alexey Starikovskiy | ad71860a | 2007-02-02 19:48:19 +0300 | [diff] [blame] | 287 | return __acpi_map_table((unsigned long)phys, size); |
Myron Stowe | 620242a | 2010-10-21 14:23:53 -0600 | [diff] [blame] | 288 | |
| 289 | map = kzalloc(sizeof(*map), GFP_KERNEL); |
| 290 | if (!map) |
| 291 | return NULL; |
| 292 | |
| 293 | virt = ioremap(phys, size); |
| 294 | if (!virt) { |
| 295 | kfree(map); |
| 296 | return NULL; |
| 297 | } |
| 298 | |
| 299 | INIT_LIST_HEAD(&map->list); |
| 300 | map->virt = virt; |
| 301 | map->phys = phys; |
| 302 | map->size = size; |
| 303 | |
| 304 | spin_lock_irqsave(&acpi_ioremap_lock, flags); |
Myron Stowe | 78cdb3e | 2010-10-21 14:24:09 -0600 | [diff] [blame^] | 305 | list_add_tail_rcu(&map->list, &acpi_ioremaps); |
Myron Stowe | 620242a | 2010-10-21 14:23:53 -0600 | [diff] [blame] | 306 | spin_unlock_irqrestore(&acpi_ioremap_lock, flags); |
| 307 | |
| 308 | return virt; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 309 | } |
Kylene Jo Hall | 55a82ab | 2006-01-08 01:03:15 -0800 | [diff] [blame] | 310 | EXPORT_SYMBOL_GPL(acpi_os_map_memory); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 311 | |
Jeremy Fitzhardinge | 0d3a9cf | 2009-02-22 14:58:56 -0800 | [diff] [blame] | 312 | void __ref acpi_os_unmap_memory(void __iomem *virt, acpi_size size) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 313 | { |
Myron Stowe | 620242a | 2010-10-21 14:23:53 -0600 | [diff] [blame] | 314 | struct acpi_ioremap *map; |
| 315 | unsigned long flags; |
| 316 | |
| 317 | if (!acpi_gbl_permanent_mmap) { |
Yinghai Lu | 7d97277 | 2009-02-07 15:39:41 -0800 | [diff] [blame] | 318 | __acpi_unmap_table(virt, size); |
Myron Stowe | 620242a | 2010-10-21 14:23:53 -0600 | [diff] [blame] | 319 | return; |
| 320 | } |
| 321 | |
| 322 | spin_lock_irqsave(&acpi_ioremap_lock, flags); |
| 323 | map = acpi_map_lookup_virt(virt, size); |
| 324 | if (!map) { |
| 325 | spin_unlock_irqrestore(&acpi_ioremap_lock, flags); |
| 326 | printk(KERN_ERR PREFIX "%s: bad address %p\n", __func__, virt); |
| 327 | dump_stack(); |
| 328 | return; |
| 329 | } |
| 330 | |
Myron Stowe | 78cdb3e | 2010-10-21 14:24:09 -0600 | [diff] [blame^] | 331 | list_del_rcu(&map->list); |
Myron Stowe | 620242a | 2010-10-21 14:23:53 -0600 | [diff] [blame] | 332 | spin_unlock_irqrestore(&acpi_ioremap_lock, flags); |
| 333 | |
Myron Stowe | 78cdb3e | 2010-10-21 14:24:09 -0600 | [diff] [blame^] | 334 | synchronize_rcu(); |
Myron Stowe | 620242a | 2010-10-21 14:23:53 -0600 | [diff] [blame] | 335 | iounmap(map->virt); |
| 336 | kfree(map); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 337 | } |
Kylene Jo Hall | 55a82ab | 2006-01-08 01:03:15 -0800 | [diff] [blame] | 338 | EXPORT_SYMBOL_GPL(acpi_os_unmap_memory); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 339 | |
Jeremy Fitzhardinge | 0d3a9cf | 2009-02-22 14:58:56 -0800 | [diff] [blame] | 340 | void __init early_acpi_os_unmap_memory(void __iomem *virt, acpi_size size) |
Yinghai Lu | 7d97277 | 2009-02-07 15:39:41 -0800 | [diff] [blame] | 341 | { |
| 342 | if (!acpi_gbl_permanent_mmap) |
| 343 | __acpi_unmap_table(virt, size); |
| 344 | } |
| 345 | |
Myron Stowe | 2971852 | 2010-10-21 14:23:59 -0600 | [diff] [blame] | 346 | int acpi_os_map_generic_address(struct acpi_generic_address *addr) |
| 347 | { |
| 348 | void __iomem *virt; |
| 349 | |
| 350 | if (addr->space_id != ACPI_ADR_SPACE_SYSTEM_MEMORY) |
| 351 | return 0; |
| 352 | |
| 353 | if (!addr->address || !addr->bit_width) |
| 354 | return -EINVAL; |
| 355 | |
| 356 | virt = acpi_os_map_memory(addr->address, addr->bit_width / 8); |
| 357 | if (!virt) |
| 358 | return -EIO; |
| 359 | |
| 360 | return 0; |
| 361 | } |
| 362 | EXPORT_SYMBOL_GPL(acpi_os_map_generic_address); |
| 363 | |
| 364 | void acpi_os_unmap_generic_address(struct acpi_generic_address *addr) |
| 365 | { |
| 366 | void __iomem *virt; |
| 367 | unsigned long flags; |
| 368 | acpi_size size = addr->bit_width / 8; |
| 369 | |
| 370 | if (addr->space_id != ACPI_ADR_SPACE_SYSTEM_MEMORY) |
| 371 | return; |
| 372 | |
| 373 | if (!addr->address || !addr->bit_width) |
| 374 | return; |
| 375 | |
| 376 | spin_lock_irqsave(&acpi_ioremap_lock, flags); |
| 377 | virt = acpi_map_vaddr_lookup(addr->address, size); |
| 378 | spin_unlock_irqrestore(&acpi_ioremap_lock, flags); |
| 379 | |
| 380 | acpi_os_unmap_memory(virt, size); |
| 381 | } |
| 382 | EXPORT_SYMBOL_GPL(acpi_os_unmap_generic_address); |
| 383 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 384 | #ifdef ACPI_FUTURE_USAGE |
| 385 | acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 386 | acpi_os_get_physical_address(void *virt, acpi_physical_address * phys) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 387 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 388 | if (!phys || !virt) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 389 | return AE_BAD_PARAMETER; |
| 390 | |
| 391 | *phys = virt_to_phys(virt); |
| 392 | |
| 393 | return AE_OK; |
| 394 | } |
| 395 | #endif |
| 396 | |
| 397 | #define ACPI_MAX_OVERRIDE_LEN 100 |
| 398 | |
| 399 | static char acpi_os_name[ACPI_MAX_OVERRIDE_LEN]; |
| 400 | |
| 401 | acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 402 | acpi_os_predefined_override(const struct acpi_predefined_names *init_val, |
| 403 | acpi_string * new_val) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 404 | { |
| 405 | if (!init_val || !new_val) |
| 406 | return AE_BAD_PARAMETER; |
| 407 | |
| 408 | *new_val = NULL; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 409 | if (!memcmp(init_val->name, "_OS_", 4) && strlen(acpi_os_name)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 410 | printk(KERN_INFO PREFIX "Overriding _OS definition to '%s'\n", |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 411 | acpi_os_name); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 412 | *new_val = acpi_os_name; |
| 413 | } |
| 414 | |
| 415 | return AE_OK; |
| 416 | } |
| 417 | |
| 418 | acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 419 | acpi_os_table_override(struct acpi_table_header * existing_table, |
| 420 | struct acpi_table_header ** new_table) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 421 | { |
| 422 | if (!existing_table || !new_table) |
| 423 | return AE_BAD_PARAMETER; |
| 424 | |
Markus Gaugusch | 71fc47a | 2008-02-05 00:04:06 +0100 | [diff] [blame] | 425 | *new_table = NULL; |
| 426 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 427 | #ifdef CONFIG_ACPI_CUSTOM_DSDT |
| 428 | if (strncmp(existing_table->signature, "DSDT", 4) == 0) |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 429 | *new_table = (struct acpi_table_header *)AmlCode; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 430 | #endif |
Éric Piel | 6ed31e9 | 2008-02-05 00:04:50 +0100 | [diff] [blame] | 431 | if (*new_table != NULL) { |
| 432 | printk(KERN_WARNING PREFIX "Override [%4.4s-%8.8s], " |
| 433 | "this is unsafe: tainting kernel\n", |
| 434 | existing_table->signature, |
| 435 | existing_table->oem_table_id); |
| 436 | add_taint(TAINT_OVERRIDDEN_ACPI_TABLE); |
| 437 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 438 | return AE_OK; |
| 439 | } |
| 440 | |
David Howells | 7d12e78 | 2006-10-05 14:55:46 +0100 | [diff] [blame] | 441 | static irqreturn_t acpi_irq(int irq, void *dev_id) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 442 | { |
Len Brown | 5229e87 | 2008-02-06 01:26:55 -0500 | [diff] [blame] | 443 | u32 handled; |
| 444 | |
| 445 | handled = (*acpi_irq_handler) (acpi_irq_context); |
| 446 | |
| 447 | if (handled) { |
| 448 | acpi_irq_handled++; |
| 449 | return IRQ_HANDLED; |
Len Brown | 88bea18 | 2009-04-21 00:35:47 -0400 | [diff] [blame] | 450 | } else { |
| 451 | acpi_irq_not_handled++; |
Len Brown | 5229e87 | 2008-02-06 01:26:55 -0500 | [diff] [blame] | 452 | return IRQ_NONE; |
Len Brown | 88bea18 | 2009-04-21 00:35:47 -0400 | [diff] [blame] | 453 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 454 | } |
| 455 | |
| 456 | acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 457 | acpi_os_install_interrupt_handler(u32 gsi, acpi_osd_handler handler, |
| 458 | void *context) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 459 | { |
| 460 | unsigned int irq; |
| 461 | |
Len Brown | 5229e87 | 2008-02-06 01:26:55 -0500 | [diff] [blame] | 462 | acpi_irq_stats_init(); |
| 463 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 464 | /* |
| 465 | * Ignore the GSI from the core, and use the value in our copy of the |
| 466 | * FADT. It may not be the same if an interrupt source override exists |
| 467 | * for the SCI. |
| 468 | */ |
Alexey Starikovskiy | cee324b | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 469 | gsi = acpi_gbl_FADT.sci_interrupt; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 470 | if (acpi_gsi_to_irq(gsi, &irq) < 0) { |
| 471 | printk(KERN_ERR PREFIX "SCI (ACPI GSI %d) not registered\n", |
| 472 | gsi); |
| 473 | return AE_OK; |
| 474 | } |
| 475 | |
| 476 | acpi_irq_handler = handler; |
| 477 | acpi_irq_context = context; |
Thomas Gleixner | dace145 | 2006-07-01 19:29:38 -0700 | [diff] [blame] | 478 | if (request_irq(irq, acpi_irq, IRQF_SHARED, "acpi", acpi_irq)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 479 | printk(KERN_ERR PREFIX "SCI (IRQ%d) allocation failed\n", irq); |
| 480 | return AE_NOT_ACQUIRED; |
| 481 | } |
| 482 | acpi_irq_irq = irq; |
| 483 | |
| 484 | return AE_OK; |
| 485 | } |
| 486 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 487 | acpi_status acpi_os_remove_interrupt_handler(u32 irq, acpi_osd_handler handler) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 488 | { |
| 489 | if (irq) { |
| 490 | free_irq(irq, acpi_irq); |
| 491 | acpi_irq_handler = NULL; |
| 492 | acpi_irq_irq = 0; |
| 493 | } |
| 494 | |
| 495 | return AE_OK; |
| 496 | } |
| 497 | |
| 498 | /* |
| 499 | * Running in interpreter thread context, safe to sleep |
| 500 | */ |
| 501 | |
Lin Ming | 439913f | 2010-01-28 10:53:19 +0800 | [diff] [blame] | 502 | void acpi_os_sleep(u64 ms) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 503 | { |
Nishanth Aravamudan | 01a527e | 2005-11-07 01:01:14 -0800 | [diff] [blame] | 504 | schedule_timeout_interruptible(msecs_to_jiffies(ms)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 505 | } |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 506 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 507 | void acpi_os_stall(u32 us) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 508 | { |
| 509 | while (us) { |
| 510 | u32 delay = 1000; |
| 511 | |
| 512 | if (delay > us) |
| 513 | delay = us; |
| 514 | udelay(delay); |
| 515 | touch_nmi_watchdog(); |
| 516 | us -= delay; |
| 517 | } |
| 518 | } |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 519 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 520 | /* |
| 521 | * Support ACPI 3.0 AML Timer operand |
| 522 | * Returns 64-bit free-running, monotonically increasing timer |
| 523 | * with 100ns granularity |
| 524 | */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 525 | u64 acpi_os_get_timer(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 526 | { |
| 527 | static u64 t; |
| 528 | |
| 529 | #ifdef CONFIG_HPET |
| 530 | /* TBD: use HPET if available */ |
| 531 | #endif |
| 532 | |
| 533 | #ifdef CONFIG_X86_PM_TIMER |
| 534 | /* TBD: default to PM timer if HPET was not available */ |
| 535 | #endif |
| 536 | if (!t) |
| 537 | printk(KERN_ERR PREFIX "acpi_os_get_timer() TBD\n"); |
| 538 | |
| 539 | return ++t; |
| 540 | } |
| 541 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 542 | acpi_status acpi_os_read_port(acpi_io_address port, u32 * value, u32 width) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 543 | { |
| 544 | u32 dummy; |
| 545 | |
| 546 | if (!value) |
| 547 | value = &dummy; |
| 548 | |
Zhao Yakui | 49fbabf | 2007-11-15 17:01:06 +0800 | [diff] [blame] | 549 | *value = 0; |
| 550 | if (width <= 8) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 551 | *(u8 *) value = inb(port); |
Zhao Yakui | 49fbabf | 2007-11-15 17:01:06 +0800 | [diff] [blame] | 552 | } else if (width <= 16) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 553 | *(u16 *) value = inw(port); |
Zhao Yakui | 49fbabf | 2007-11-15 17:01:06 +0800 | [diff] [blame] | 554 | } else if (width <= 32) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 555 | *(u32 *) value = inl(port); |
Zhao Yakui | 49fbabf | 2007-11-15 17:01:06 +0800 | [diff] [blame] | 556 | } else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 557 | BUG(); |
| 558 | } |
| 559 | |
| 560 | return AE_OK; |
| 561 | } |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 562 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 563 | EXPORT_SYMBOL(acpi_os_read_port); |
| 564 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 565 | acpi_status acpi_os_write_port(acpi_io_address port, u32 value, u32 width) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 566 | { |
Zhao Yakui | 49fbabf | 2007-11-15 17:01:06 +0800 | [diff] [blame] | 567 | if (width <= 8) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 568 | outb(value, port); |
Zhao Yakui | 49fbabf | 2007-11-15 17:01:06 +0800 | [diff] [blame] | 569 | } else if (width <= 16) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 570 | outw(value, port); |
Zhao Yakui | 49fbabf | 2007-11-15 17:01:06 +0800 | [diff] [blame] | 571 | } else if (width <= 32) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 572 | outl(value, port); |
Zhao Yakui | 49fbabf | 2007-11-15 17:01:06 +0800 | [diff] [blame] | 573 | } else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 574 | BUG(); |
| 575 | } |
| 576 | |
| 577 | return AE_OK; |
| 578 | } |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 579 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 580 | EXPORT_SYMBOL(acpi_os_write_port); |
| 581 | |
| 582 | acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 583 | acpi_os_read_memory(acpi_physical_address phys_addr, u32 * value, u32 width) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 584 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 585 | u32 dummy; |
| 586 | void __iomem *virt_addr; |
Myron Stowe | 620242a | 2010-10-21 14:23:53 -0600 | [diff] [blame] | 587 | int size = width / 8, unmap = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 588 | |
Myron Stowe | 78cdb3e | 2010-10-21 14:24:09 -0600 | [diff] [blame^] | 589 | rcu_read_lock(); |
Myron Stowe | 620242a | 2010-10-21 14:23:53 -0600 | [diff] [blame] | 590 | virt_addr = acpi_map_vaddr_lookup(phys_addr, size); |
Myron Stowe | 78cdb3e | 2010-10-21 14:24:09 -0600 | [diff] [blame^] | 591 | rcu_read_unlock(); |
Myron Stowe | 620242a | 2010-10-21 14:23:53 -0600 | [diff] [blame] | 592 | if (!virt_addr) { |
| 593 | virt_addr = ioremap(phys_addr, size); |
| 594 | unmap = 1; |
| 595 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 596 | if (!value) |
| 597 | value = &dummy; |
| 598 | |
| 599 | switch (width) { |
| 600 | case 8: |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 601 | *(u8 *) value = readb(virt_addr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 602 | break; |
| 603 | case 16: |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 604 | *(u16 *) value = readw(virt_addr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 605 | break; |
| 606 | case 32: |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 607 | *(u32 *) value = readl(virt_addr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 608 | break; |
| 609 | default: |
| 610 | BUG(); |
| 611 | } |
| 612 | |
Myron Stowe | 620242a | 2010-10-21 14:23:53 -0600 | [diff] [blame] | 613 | if (unmap) |
| 614 | iounmap(virt_addr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 615 | |
| 616 | return AE_OK; |
| 617 | } |
| 618 | |
| 619 | acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 620 | acpi_os_write_memory(acpi_physical_address phys_addr, u32 value, u32 width) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 621 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 622 | void __iomem *virt_addr; |
Myron Stowe | 620242a | 2010-10-21 14:23:53 -0600 | [diff] [blame] | 623 | int size = width / 8, unmap = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 624 | |
Myron Stowe | 78cdb3e | 2010-10-21 14:24:09 -0600 | [diff] [blame^] | 625 | rcu_read_lock(); |
Myron Stowe | 620242a | 2010-10-21 14:23:53 -0600 | [diff] [blame] | 626 | virt_addr = acpi_map_vaddr_lookup(phys_addr, size); |
Myron Stowe | 78cdb3e | 2010-10-21 14:24:09 -0600 | [diff] [blame^] | 627 | rcu_read_unlock(); |
Myron Stowe | 620242a | 2010-10-21 14:23:53 -0600 | [diff] [blame] | 628 | if (!virt_addr) { |
| 629 | virt_addr = ioremap(phys_addr, size); |
| 630 | unmap = 1; |
| 631 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 632 | |
| 633 | switch (width) { |
| 634 | case 8: |
| 635 | writeb(value, virt_addr); |
| 636 | break; |
| 637 | case 16: |
| 638 | writew(value, virt_addr); |
| 639 | break; |
| 640 | case 32: |
| 641 | writel(value, virt_addr); |
| 642 | break; |
| 643 | default: |
| 644 | BUG(); |
| 645 | } |
| 646 | |
Myron Stowe | 620242a | 2010-10-21 14:23:53 -0600 | [diff] [blame] | 647 | if (unmap) |
| 648 | iounmap(virt_addr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 649 | |
| 650 | return AE_OK; |
| 651 | } |
| 652 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 653 | acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 654 | acpi_os_read_pci_configuration(struct acpi_pci_id * pci_id, u32 reg, |
Linus Torvalds | 10270d4 | 2008-02-13 09:56:14 -0800 | [diff] [blame] | 655 | u32 *value, u32 width) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 656 | { |
| 657 | int result, size; |
| 658 | |
| 659 | if (!value) |
| 660 | return AE_BAD_PARAMETER; |
| 661 | |
| 662 | switch (width) { |
| 663 | case 8: |
| 664 | size = 1; |
| 665 | break; |
| 666 | case 16: |
| 667 | size = 2; |
| 668 | break; |
| 669 | case 32: |
| 670 | size = 4; |
| 671 | break; |
| 672 | default: |
| 673 | return AE_ERROR; |
| 674 | } |
| 675 | |
Matthew Wilcox | b6ce068 | 2008-02-10 09:45:28 -0500 | [diff] [blame] | 676 | result = raw_pci_read(pci_id->segment, pci_id->bus, |
| 677 | PCI_DEVFN(pci_id->device, pci_id->function), |
| 678 | reg, size, value); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 679 | |
| 680 | return (result ? AE_ERROR : AE_OK); |
| 681 | } |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 682 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 683 | acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 684 | acpi_os_write_pci_configuration(struct acpi_pci_id * pci_id, u32 reg, |
Lin Ming | 439913f | 2010-01-28 10:53:19 +0800 | [diff] [blame] | 685 | u64 value, u32 width) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 686 | { |
| 687 | int result, size; |
| 688 | |
| 689 | switch (width) { |
| 690 | case 8: |
| 691 | size = 1; |
| 692 | break; |
| 693 | case 16: |
| 694 | size = 2; |
| 695 | break; |
| 696 | case 32: |
| 697 | size = 4; |
| 698 | break; |
| 699 | default: |
| 700 | return AE_ERROR; |
| 701 | } |
| 702 | |
Matthew Wilcox | b6ce068 | 2008-02-10 09:45:28 -0500 | [diff] [blame] | 703 | result = raw_pci_write(pci_id->segment, pci_id->bus, |
| 704 | PCI_DEVFN(pci_id->device, pci_id->function), |
| 705 | reg, size, value); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 706 | |
| 707 | return (result ? AE_ERROR : AE_OK); |
| 708 | } |
| 709 | |
| 710 | /* TODO: Change code to take advantage of driver model more */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 711 | static void acpi_os_derive_pci_id_2(acpi_handle rhandle, /* upper bound */ |
| 712 | acpi_handle chandle, /* current node */ |
| 713 | struct acpi_pci_id **id, |
| 714 | int *is_bridge, u8 * bus_number) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 715 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 716 | acpi_handle handle; |
| 717 | struct acpi_pci_id *pci_id = *id; |
| 718 | acpi_status status; |
Matthew Wilcox | 27663c5 | 2008-10-10 02:22:59 -0400 | [diff] [blame] | 719 | unsigned long long temp; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 720 | acpi_object_type type; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 721 | |
| 722 | acpi_get_parent(chandle, &handle); |
| 723 | if (handle != rhandle) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 724 | acpi_os_derive_pci_id_2(rhandle, handle, &pci_id, is_bridge, |
| 725 | bus_number); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 726 | |
| 727 | status = acpi_get_type(handle, &type); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 728 | if ((ACPI_FAILURE(status)) || (type != ACPI_TYPE_DEVICE)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 729 | return; |
| 730 | |
Matthew Wilcox | 27663c5 | 2008-10-10 02:22:59 -0400 | [diff] [blame] | 731 | status = acpi_evaluate_integer(handle, METHOD_NAME__ADR, NULL, |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 732 | &temp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 733 | if (ACPI_SUCCESS(status)) { |
Linus Torvalds | 10270d4 | 2008-02-13 09:56:14 -0800 | [diff] [blame] | 734 | u32 val; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 735 | pci_id->device = ACPI_HIWORD(ACPI_LODWORD(temp)); |
| 736 | pci_id->function = ACPI_LOWORD(ACPI_LODWORD(temp)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 737 | |
| 738 | if (*is_bridge) |
| 739 | pci_id->bus = *bus_number; |
| 740 | |
| 741 | /* any nicer way to get bus number of bridge ? */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 742 | status = |
Linus Torvalds | 10270d4 | 2008-02-13 09:56:14 -0800 | [diff] [blame] | 743 | acpi_os_read_pci_configuration(pci_id, 0x0e, &val, |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 744 | 8); |
| 745 | if (ACPI_SUCCESS(status) |
Linus Torvalds | 10270d4 | 2008-02-13 09:56:14 -0800 | [diff] [blame] | 746 | && ((val & 0x7f) == 1 || (val & 0x7f) == 2)) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 747 | status = |
| 748 | acpi_os_read_pci_configuration(pci_id, 0x18, |
Linus Torvalds | 10270d4 | 2008-02-13 09:56:14 -0800 | [diff] [blame] | 749 | &val, 8); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 750 | if (!ACPI_SUCCESS(status)) { |
| 751 | /* Certainly broken... FIX ME */ |
| 752 | return; |
| 753 | } |
| 754 | *is_bridge = 1; |
Linus Torvalds | 10270d4 | 2008-02-13 09:56:14 -0800 | [diff] [blame] | 755 | pci_id->bus = val; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 756 | status = |
| 757 | acpi_os_read_pci_configuration(pci_id, 0x19, |
Linus Torvalds | 10270d4 | 2008-02-13 09:56:14 -0800 | [diff] [blame] | 758 | &val, 8); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 759 | if (ACPI_SUCCESS(status)) { |
Linus Torvalds | 10270d4 | 2008-02-13 09:56:14 -0800 | [diff] [blame] | 760 | *bus_number = val; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 761 | } |
| 762 | } else |
| 763 | *is_bridge = 0; |
| 764 | } |
| 765 | } |
| 766 | } |
| 767 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 768 | void acpi_os_derive_pci_id(acpi_handle rhandle, /* upper bound */ |
| 769 | acpi_handle chandle, /* current node */ |
| 770 | struct acpi_pci_id **id) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 771 | { |
| 772 | int is_bridge = 1; |
| 773 | u8 bus_number = (*id)->bus; |
| 774 | |
| 775 | acpi_os_derive_pci_id_2(rhandle, chandle, id, &is_bridge, &bus_number); |
| 776 | } |
| 777 | |
David Howells | 65f27f3 | 2006-11-22 14:55:48 +0000 | [diff] [blame] | 778 | static void acpi_os_execute_deferred(struct work_struct *work) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 779 | { |
David Howells | 65f27f3 | 2006-11-22 14:55:48 +0000 | [diff] [blame] | 780 | struct acpi_os_dpc *dpc = container_of(work, struct acpi_os_dpc, work); |
Alexey Starikovskiy | 88db5e1 | 2007-05-09 23:31:03 -0400 | [diff] [blame] | 781 | |
Bjorn Helgaas | 9ac6185 | 2009-08-31 22:32:10 +0000 | [diff] [blame] | 782 | if (dpc->wait) |
| 783 | acpi_os_wait_events_complete(NULL); |
Zhang Rui | 19cd847 | 2008-08-28 10:05:06 +0800 | [diff] [blame] | 784 | |
| 785 | dpc->function(dpc->context); |
| 786 | kfree(dpc); |
Zhang Rui | 19cd847 | 2008-08-28 10:05:06 +0800 | [diff] [blame] | 787 | } |
| 788 | |
Alexey Starikovskiy | b8d3519 | 2006-05-05 03:23:00 -0400 | [diff] [blame] | 789 | /******************************************************************************* |
| 790 | * |
| 791 | * FUNCTION: acpi_os_execute |
| 792 | * |
| 793 | * PARAMETERS: Type - Type of the callback |
| 794 | * Function - Function to be executed |
| 795 | * Context - Function parameters |
| 796 | * |
| 797 | * RETURN: Status |
| 798 | * |
| 799 | * DESCRIPTION: Depending on type, either queues function for deferred execution or |
| 800 | * immediately executes function on a separate thread. |
| 801 | * |
| 802 | ******************************************************************************/ |
| 803 | |
Zhang Rui | 19cd847 | 2008-08-28 10:05:06 +0800 | [diff] [blame] | 804 | static acpi_status __acpi_os_execute(acpi_execute_type type, |
| 805 | acpi_osd_exec_callback function, void *context, int hp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 806 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 807 | acpi_status status = AE_OK; |
| 808 | struct acpi_os_dpc *dpc; |
Alexey Starikovskiy | 17bc54e | 2007-11-13 13:05:45 +0300 | [diff] [blame] | 809 | struct workqueue_struct *queue; |
Zhang Rui | 19cd847 | 2008-08-28 10:05:06 +0800 | [diff] [blame] | 810 | int ret; |
Len Brown | 72945b2 | 2006-07-12 22:46:42 -0400 | [diff] [blame] | 811 | ACPI_DEBUG_PRINT((ACPI_DB_EXEC, |
| 812 | "Scheduling function [%p(%p)] for deferred execution.\n", |
| 813 | function, context)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 814 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 815 | /* |
| 816 | * Allocate/initialize DPC structure. Note that this memory will be |
David Howells | 65f27f3 | 2006-11-22 14:55:48 +0000 | [diff] [blame] | 817 | * freed by the callee. The kernel handles the work_struct list in a |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 818 | * way that allows us to also free its memory inside the callee. |
| 819 | * Because we may want to schedule several tasks with different |
| 820 | * parameters we can't use the approach some kernel code uses of |
David Howells | 65f27f3 | 2006-11-22 14:55:48 +0000 | [diff] [blame] | 821 | * having a static work_struct. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 822 | */ |
Len Brown | 72945b2 | 2006-07-12 22:46:42 -0400 | [diff] [blame] | 823 | |
David Howells | 65f27f3 | 2006-11-22 14:55:48 +0000 | [diff] [blame] | 824 | dpc = kmalloc(sizeof(struct acpi_os_dpc), GFP_ATOMIC); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 825 | if (!dpc) |
Lin Ming | 889c78b | 2008-12-31 09:23:57 +0800 | [diff] [blame] | 826 | return AE_NO_MEMORY; |
Linus Torvalds | b976fe1 | 2006-11-17 19:31:09 -0800 | [diff] [blame] | 827 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 828 | dpc->function = function; |
| 829 | dpc->context = context; |
Linus Torvalds | b976fe1 | 2006-11-17 19:31:09 -0800 | [diff] [blame] | 830 | |
Zhang Rui | c02256b | 2009-06-23 10:20:29 +0800 | [diff] [blame] | 831 | /* |
| 832 | * We can't run hotplug code in keventd_wq/kacpid_wq/kacpid_notify_wq |
| 833 | * because the hotplug code may call driver .remove() functions, |
| 834 | * which invoke flush_scheduled_work/acpi_os_wait_events_complete |
| 835 | * to flush these workqueues. |
| 836 | */ |
| 837 | queue = hp ? kacpi_hotplug_wq : |
| 838 | (type == OSL_NOTIFY_HANDLER ? kacpi_notify_wq : kacpid_wq); |
Bjorn Helgaas | 9ac6185 | 2009-08-31 22:32:10 +0000 | [diff] [blame] | 839 | dpc->wait = hp ? 1 : 0; |
Zhang Rui | bc73675 | 2010-03-22 15:48:54 +0800 | [diff] [blame] | 840 | |
| 841 | if (queue == kacpi_hotplug_wq) |
| 842 | INIT_WORK(&dpc->work, acpi_os_execute_deferred); |
| 843 | else if (queue == kacpi_notify_wq) |
| 844 | INIT_WORK(&dpc->work, acpi_os_execute_deferred); |
| 845 | else |
| 846 | INIT_WORK(&dpc->work, acpi_os_execute_deferred); |
| 847 | |
Tejun Heo | 8fec62b | 2010-06-29 10:07:09 +0200 | [diff] [blame] | 848 | /* |
| 849 | * On some machines, a software-initiated SMI causes corruption unless |
| 850 | * the SMI runs on CPU 0. An SMI can be initiated by any AML, but |
| 851 | * typically it's done in GPE-related methods that are run via |
| 852 | * workqueues, so we can avoid the known corruption cases by always |
| 853 | * queueing on CPU 0. |
| 854 | */ |
| 855 | ret = queue_work_on(0, queue, &dpc->work); |
Zhang Rui | 19cd847 | 2008-08-28 10:05:06 +0800 | [diff] [blame] | 856 | |
| 857 | if (!ret) { |
Lin Ming | 55ac9a0 | 2008-09-28 14:51:56 +0800 | [diff] [blame] | 858 | printk(KERN_ERR PREFIX |
| 859 | "Call to queue_work() failed.\n"); |
Alexey Starikovskiy | 17bc54e | 2007-11-13 13:05:45 +0300 | [diff] [blame] | 860 | status = AE_ERROR; |
| 861 | kfree(dpc); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 862 | } |
Lin Ming | 889c78b | 2008-12-31 09:23:57 +0800 | [diff] [blame] | 863 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 864 | } |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 865 | |
Zhang Rui | 19cd847 | 2008-08-28 10:05:06 +0800 | [diff] [blame] | 866 | acpi_status acpi_os_execute(acpi_execute_type type, |
| 867 | acpi_osd_exec_callback function, void *context) |
| 868 | { |
| 869 | return __acpi_os_execute(type, function, context, 0); |
| 870 | } |
Alexey Starikovskiy | b8d3519 | 2006-05-05 03:23:00 -0400 | [diff] [blame] | 871 | EXPORT_SYMBOL(acpi_os_execute); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 872 | |
Zhang Rui | 19cd847 | 2008-08-28 10:05:06 +0800 | [diff] [blame] | 873 | acpi_status acpi_os_hotplug_execute(acpi_osd_exec_callback function, |
| 874 | void *context) |
| 875 | { |
| 876 | return __acpi_os_execute(0, function, context, 1); |
| 877 | } |
| 878 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 879 | void acpi_os_wait_events_complete(void *context) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 880 | { |
| 881 | flush_workqueue(kacpid_wq); |
Zhang Rui | 2f67a06 | 2008-04-29 02:34:42 -0400 | [diff] [blame] | 882 | flush_workqueue(kacpi_notify_wq); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 883 | } |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 884 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 885 | EXPORT_SYMBOL(acpi_os_wait_events_complete); |
| 886 | |
| 887 | /* |
| 888 | * Allocate the memory for a spinlock and initialize it. |
| 889 | */ |
Bob Moore | 967440e3 | 2006-06-23 17:04:00 -0400 | [diff] [blame] | 890 | acpi_status acpi_os_create_lock(acpi_spinlock * handle) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 891 | { |
Bob Moore | 967440e3 | 2006-06-23 17:04:00 -0400 | [diff] [blame] | 892 | spin_lock_init(*handle); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 893 | |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 894 | return AE_OK; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 895 | } |
| 896 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 897 | /* |
| 898 | * Deallocate the memory for a spinlock. |
| 899 | */ |
Bob Moore | 967440e3 | 2006-06-23 17:04:00 -0400 | [diff] [blame] | 900 | void acpi_os_delete_lock(acpi_spinlock handle) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 901 | { |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 902 | return; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 903 | } |
| 904 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 905 | acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 906 | acpi_os_create_semaphore(u32 max_units, u32 initial_units, acpi_handle * handle) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 907 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 908 | struct semaphore *sem = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 909 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 910 | sem = acpi_os_allocate(sizeof(struct semaphore)); |
| 911 | if (!sem) |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 912 | return AE_NO_MEMORY; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 913 | memset(sem, 0, sizeof(struct semaphore)); |
| 914 | |
| 915 | sema_init(sem, initial_units); |
| 916 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 917 | *handle = (acpi_handle *) sem; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 918 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 919 | ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, "Creating semaphore[%p|%d].\n", |
| 920 | *handle, initial_units)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 921 | |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 922 | return AE_OK; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 923 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 924 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 925 | /* |
| 926 | * TODO: A better way to delete semaphores? Linux doesn't have a |
| 927 | * 'delete_semaphore()' function -- may result in an invalid |
| 928 | * pointer dereference for non-synchronized consumers. Should |
| 929 | * we at least check for blocked threads and signal/cancel them? |
| 930 | */ |
| 931 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 932 | acpi_status acpi_os_delete_semaphore(acpi_handle handle) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 933 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 934 | struct semaphore *sem = (struct semaphore *)handle; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 935 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 936 | if (!sem) |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 937 | return AE_BAD_PARAMETER; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 938 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 939 | ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, "Deleting semaphore[%p].\n", handle)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 940 | |
Matthew Wilcox | f1241c8 | 2008-03-14 13:43:13 -0400 | [diff] [blame] | 941 | BUG_ON(!list_empty(&sem->wait_list)); |
Len Brown | 02438d8 | 2006-06-30 03:19:10 -0400 | [diff] [blame] | 942 | kfree(sem); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 943 | sem = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 944 | |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 945 | return AE_OK; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 946 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 947 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 948 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 949 | * TODO: Support for units > 1? |
| 950 | */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 951 | acpi_status acpi_os_wait_semaphore(acpi_handle handle, u32 units, u16 timeout) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 952 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 953 | acpi_status status = AE_OK; |
| 954 | struct semaphore *sem = (struct semaphore *)handle; |
Matthew Wilcox | f1241c8 | 2008-03-14 13:43:13 -0400 | [diff] [blame] | 955 | long jiffies; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 956 | int ret = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 957 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 958 | if (!sem || (units < 1)) |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 959 | return AE_BAD_PARAMETER; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 960 | |
| 961 | if (units > 1) |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 962 | return AE_SUPPORT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 963 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 964 | ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, "Waiting for semaphore[%p|%d|%d]\n", |
| 965 | handle, units, timeout)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 966 | |
Matthew Wilcox | f1241c8 | 2008-03-14 13:43:13 -0400 | [diff] [blame] | 967 | if (timeout == ACPI_WAIT_FOREVER) |
| 968 | jiffies = MAX_SCHEDULE_TIMEOUT; |
| 969 | else |
| 970 | jiffies = msecs_to_jiffies(timeout); |
| 971 | |
| 972 | ret = down_timeout(sem, jiffies); |
| 973 | if (ret) |
| 974 | status = AE_TIME; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 975 | |
| 976 | if (ACPI_FAILURE(status)) { |
Bjorn Helgaas | 9e7e2c0 | 2006-04-27 05:25:00 -0400 | [diff] [blame] | 977 | ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, |
Thomas Renninger | a6fc672 | 2006-06-26 23:58:43 -0400 | [diff] [blame] | 978 | "Failed to acquire semaphore[%p|%d|%d], %s", |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 979 | handle, units, timeout, |
| 980 | acpi_format_exception(status))); |
| 981 | } else { |
| 982 | ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, |
Thomas Renninger | a6fc672 | 2006-06-26 23:58:43 -0400 | [diff] [blame] | 983 | "Acquired semaphore[%p|%d|%d]", handle, |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 984 | units, timeout)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 985 | } |
| 986 | |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 987 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 988 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 989 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 990 | /* |
| 991 | * TODO: Support for units > 1? |
| 992 | */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 993 | acpi_status acpi_os_signal_semaphore(acpi_handle handle, u32 units) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 994 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 995 | struct semaphore *sem = (struct semaphore *)handle; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 996 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 997 | if (!sem || (units < 1)) |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 998 | return AE_BAD_PARAMETER; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 999 | |
| 1000 | if (units > 1) |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 1001 | return AE_SUPPORT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1002 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1003 | ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, "Signaling semaphore[%p|%d]\n", handle, |
| 1004 | units)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1005 | |
| 1006 | up(sem); |
| 1007 | |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 1008 | return AE_OK; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1009 | } |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1010 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1011 | #ifdef ACPI_FUTURE_USAGE |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1012 | u32 acpi_os_get_line(char *buffer) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1013 | { |
| 1014 | |
| 1015 | #ifdef ENABLE_DEBUGGER |
| 1016 | if (acpi_in_debugger) { |
| 1017 | u32 chars; |
| 1018 | |
| 1019 | kdb_read(buffer, sizeof(line_buf)); |
| 1020 | |
| 1021 | /* remove the CR kdb includes */ |
| 1022 | chars = strlen(buffer) - 1; |
| 1023 | buffer[chars] = '\0'; |
| 1024 | } |
| 1025 | #endif |
| 1026 | |
| 1027 | return 0; |
| 1028 | } |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1029 | #endif /* ACPI_FUTURE_USAGE */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1030 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1031 | acpi_status acpi_os_signal(u32 function, void *info) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1032 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1033 | switch (function) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1034 | case ACPI_SIGNAL_FATAL: |
| 1035 | printk(KERN_ERR PREFIX "Fatal opcode executed\n"); |
| 1036 | break; |
| 1037 | case ACPI_SIGNAL_BREAKPOINT: |
| 1038 | /* |
| 1039 | * AML Breakpoint |
| 1040 | * ACPI spec. says to treat it as a NOP unless |
| 1041 | * you are debugging. So if/when we integrate |
| 1042 | * AML debugger into the kernel debugger its |
| 1043 | * hook will go here. But until then it is |
| 1044 | * not useful to print anything on breakpoints. |
| 1045 | */ |
| 1046 | break; |
| 1047 | default: |
| 1048 | break; |
| 1049 | } |
| 1050 | |
| 1051 | return AE_OK; |
| 1052 | } |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1053 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1054 | static int __init acpi_os_name_setup(char *str) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1055 | { |
| 1056 | char *p = acpi_os_name; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1057 | int count = ACPI_MAX_OVERRIDE_LEN - 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1058 | |
| 1059 | if (!str || !*str) |
| 1060 | return 0; |
| 1061 | |
| 1062 | for (; count-- && str && *str; str++) { |
| 1063 | if (isalnum(*str) || *str == ' ' || *str == ':') |
| 1064 | *p++ = *str; |
| 1065 | else if (*str == '\'' || *str == '"') |
| 1066 | continue; |
| 1067 | else |
| 1068 | break; |
| 1069 | } |
| 1070 | *p = 0; |
| 1071 | |
| 1072 | return 1; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1073 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1074 | } |
| 1075 | |
| 1076 | __setup("acpi_os_name=", acpi_os_name_setup); |
| 1077 | |
Len Brown | d4b7dc4 | 2008-01-23 20:50:56 -0500 | [diff] [blame] | 1078 | static void __init set_osi_linux(unsigned int enable) |
| 1079 | { |
| 1080 | if (osi_linux.enable != enable) { |
| 1081 | osi_linux.enable = enable; |
| 1082 | printk(KERN_NOTICE PREFIX "%sed _OSI(Linux)\n", |
| 1083 | enable ? "Add": "Delet"); |
| 1084 | } |
| 1085 | return; |
| 1086 | } |
Len Brown | f507654 | 2007-05-30 00:10:38 -0400 | [diff] [blame] | 1087 | |
Len Brown | d4b7dc4 | 2008-01-23 20:50:56 -0500 | [diff] [blame] | 1088 | static void __init acpi_cmdline_osi_linux(unsigned int enable) |
| 1089 | { |
| 1090 | osi_linux.cmdline = 1; /* cmdline set the default */ |
| 1091 | set_osi_linux(enable); |
Len Brown | f507654 | 2007-05-30 00:10:38 -0400 | [diff] [blame] | 1092 | |
Len Brown | d4b7dc4 | 2008-01-23 20:50:56 -0500 | [diff] [blame] | 1093 | return; |
| 1094 | } |
| 1095 | |
| 1096 | void __init acpi_dmi_osi_linux(int enable, const struct dmi_system_id *d) |
| 1097 | { |
| 1098 | osi_linux.dmi = 1; /* DMI knows that this box asks OSI(Linux) */ |
| 1099 | |
| 1100 | printk(KERN_NOTICE PREFIX "DMI detected: %s\n", d->ident); |
| 1101 | |
| 1102 | if (enable == -1) |
| 1103 | return; |
| 1104 | |
| 1105 | osi_linux.known = 1; /* DMI knows which OSI(Linux) default needed */ |
| 1106 | |
| 1107 | set_osi_linux(enable); |
| 1108 | |
Len Brown | f507654 | 2007-05-30 00:10:38 -0400 | [diff] [blame] | 1109 | return; |
| 1110 | } |
| 1111 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1112 | /* |
Len Brown | ae00d81 | 2007-05-29 18:43:33 -0400 | [diff] [blame] | 1113 | * Modify the list of "OS Interfaces" reported to BIOS via _OSI |
| 1114 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1115 | * empty string disables _OSI |
Len Brown | ae00d81 | 2007-05-29 18:43:33 -0400 | [diff] [blame] | 1116 | * string starting with '!' disables that string |
| 1117 | * otherwise string is added to list, augmenting built-in strings |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1118 | */ |
Len Brown | 46c1fbd | 2008-02-13 23:13:25 -0500 | [diff] [blame] | 1119 | int __init acpi_osi_setup(char *str) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1120 | { |
| 1121 | if (str == NULL || *str == '\0') { |
| 1122 | printk(KERN_INFO PREFIX "_OSI method disabled\n"); |
| 1123 | acpi_gbl_create_osi_method = FALSE; |
Len Brown | aa2e09d | 2007-07-02 23:57:45 -0400 | [diff] [blame] | 1124 | } else if (!strcmp("!Linux", str)) { |
Len Brown | d4b7dc4 | 2008-01-23 20:50:56 -0500 | [diff] [blame] | 1125 | acpi_cmdline_osi_linux(0); /* !enable */ |
Len Brown | ae00d81 | 2007-05-29 18:43:33 -0400 | [diff] [blame] | 1126 | } else if (*str == '!') { |
| 1127 | if (acpi_osi_invalidate(++str) == AE_OK) |
| 1128 | printk(KERN_INFO PREFIX "Deleted _OSI(%s)\n", str); |
Len Brown | f507654 | 2007-05-30 00:10:38 -0400 | [diff] [blame] | 1129 | } else if (!strcmp("Linux", str)) { |
Len Brown | d4b7dc4 | 2008-01-23 20:50:56 -0500 | [diff] [blame] | 1130 | acpi_cmdline_osi_linux(1); /* enable */ |
Len Brown | ae00d81 | 2007-05-29 18:43:33 -0400 | [diff] [blame] | 1131 | } else if (*osi_additional_string == '\0') { |
| 1132 | strncpy(osi_additional_string, str, OSI_STRING_LENGTH_MAX); |
| 1133 | printk(KERN_INFO PREFIX "Added _OSI(%s)\n", str); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1134 | } |
| 1135 | |
| 1136 | return 1; |
| 1137 | } |
| 1138 | |
| 1139 | __setup("acpi_osi=", acpi_osi_setup); |
| 1140 | |
| 1141 | /* enable serialization to combat AE_ALREADY_EXISTS errors */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1142 | static int __init acpi_serialize_setup(char *str) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1143 | { |
| 1144 | printk(KERN_INFO PREFIX "serialize enabled\n"); |
| 1145 | |
| 1146 | acpi_gbl_all_methods_serialized = TRUE; |
| 1147 | |
| 1148 | return 1; |
| 1149 | } |
| 1150 | |
| 1151 | __setup("acpi_serialize", acpi_serialize_setup); |
| 1152 | |
Thomas Renninger | df92e69 | 2008-02-04 23:31:22 -0800 | [diff] [blame] | 1153 | /* Check of resource interference between native drivers and ACPI |
| 1154 | * OperationRegions (SystemIO and System Memory only). |
| 1155 | * IO ports and memory declared in ACPI might be used by the ACPI subsystem |
| 1156 | * in arbitrary AML code and can interfere with legacy drivers. |
| 1157 | * acpi_enforce_resources= can be set to: |
| 1158 | * |
Luca Tettamanti | 7e90560 | 2009-03-30 00:01:27 +0200 | [diff] [blame] | 1159 | * - strict (default) (2) |
Thomas Renninger | df92e69 | 2008-02-04 23:31:22 -0800 | [diff] [blame] | 1160 | * -> further driver trying to access the resources will not load |
Luca Tettamanti | 7e90560 | 2009-03-30 00:01:27 +0200 | [diff] [blame] | 1161 | * - lax (1) |
Thomas Renninger | df92e69 | 2008-02-04 23:31:22 -0800 | [diff] [blame] | 1162 | * -> further driver trying to access the resources will load, but you |
| 1163 | * get a system message that something might go wrong... |
| 1164 | * |
| 1165 | * - no (0) |
| 1166 | * -> ACPI Operation Region resources will not be registered |
| 1167 | * |
| 1168 | */ |
| 1169 | #define ENFORCE_RESOURCES_STRICT 2 |
| 1170 | #define ENFORCE_RESOURCES_LAX 1 |
| 1171 | #define ENFORCE_RESOURCES_NO 0 |
| 1172 | |
Luca Tettamanti | 7e90560 | 2009-03-30 00:01:27 +0200 | [diff] [blame] | 1173 | static unsigned int acpi_enforce_resources = ENFORCE_RESOURCES_STRICT; |
Thomas Renninger | df92e69 | 2008-02-04 23:31:22 -0800 | [diff] [blame] | 1174 | |
| 1175 | static int __init acpi_enforce_resources_setup(char *str) |
| 1176 | { |
| 1177 | if (str == NULL || *str == '\0') |
| 1178 | return 0; |
| 1179 | |
| 1180 | if (!strcmp("strict", str)) |
| 1181 | acpi_enforce_resources = ENFORCE_RESOURCES_STRICT; |
| 1182 | else if (!strcmp("lax", str)) |
| 1183 | acpi_enforce_resources = ENFORCE_RESOURCES_LAX; |
| 1184 | else if (!strcmp("no", str)) |
| 1185 | acpi_enforce_resources = ENFORCE_RESOURCES_NO; |
| 1186 | |
| 1187 | return 1; |
| 1188 | } |
| 1189 | |
| 1190 | __setup("acpi_enforce_resources=", acpi_enforce_resources_setup); |
| 1191 | |
| 1192 | /* Check for resource conflicts between ACPI OperationRegions and native |
| 1193 | * drivers */ |
Jean Delvare | 876fba4 | 2009-11-11 15:22:15 +0100 | [diff] [blame] | 1194 | int acpi_check_resource_conflict(const struct resource *res) |
Thomas Renninger | df92e69 | 2008-02-04 23:31:22 -0800 | [diff] [blame] | 1195 | { |
| 1196 | struct acpi_res_list *res_list_elem; |
| 1197 | int ioport; |
| 1198 | int clash = 0; |
| 1199 | |
| 1200 | if (acpi_enforce_resources == ENFORCE_RESOURCES_NO) |
| 1201 | return 0; |
| 1202 | if (!(res->flags & IORESOURCE_IO) && !(res->flags & IORESOURCE_MEM)) |
| 1203 | return 0; |
| 1204 | |
| 1205 | ioport = res->flags & IORESOURCE_IO; |
| 1206 | |
| 1207 | spin_lock(&acpi_res_lock); |
| 1208 | list_for_each_entry(res_list_elem, &resource_list_head, |
| 1209 | resource_list) { |
| 1210 | if (ioport && (res_list_elem->resource_type |
| 1211 | != ACPI_ADR_SPACE_SYSTEM_IO)) |
| 1212 | continue; |
| 1213 | if (!ioport && (res_list_elem->resource_type |
| 1214 | != ACPI_ADR_SPACE_SYSTEM_MEMORY)) |
| 1215 | continue; |
| 1216 | |
| 1217 | if (res->end < res_list_elem->start |
| 1218 | || res_list_elem->end < res->start) |
| 1219 | continue; |
| 1220 | clash = 1; |
| 1221 | break; |
| 1222 | } |
| 1223 | spin_unlock(&acpi_res_lock); |
| 1224 | |
| 1225 | if (clash) { |
| 1226 | if (acpi_enforce_resources != ENFORCE_RESOURCES_NO) { |
Chase Douglas | 1638bca | 2010-03-22 15:08:09 -0400 | [diff] [blame] | 1227 | printk(KERN_WARNING "ACPI: resource %s %pR" |
| 1228 | " conflicts with ACPI region %s %pR\n", |
| 1229 | res->name, res, res_list_elem->name, |
| 1230 | res_list_elem); |
Jean Delvare | 14f0334 | 2009-09-08 15:31:46 +0200 | [diff] [blame] | 1231 | if (acpi_enforce_resources == ENFORCE_RESOURCES_LAX) |
| 1232 | printk(KERN_NOTICE "ACPI: This conflict may" |
| 1233 | " cause random problems and system" |
| 1234 | " instability\n"); |
| 1235 | printk(KERN_INFO "ACPI: If an ACPI driver is available" |
| 1236 | " for this device, you should use it instead of" |
| 1237 | " the native driver\n"); |
Thomas Renninger | df92e69 | 2008-02-04 23:31:22 -0800 | [diff] [blame] | 1238 | } |
| 1239 | if (acpi_enforce_resources == ENFORCE_RESOURCES_STRICT) |
| 1240 | return -EBUSY; |
| 1241 | } |
| 1242 | return 0; |
| 1243 | } |
Thomas Renninger | 443dea7 | 2008-02-04 23:31:23 -0800 | [diff] [blame] | 1244 | EXPORT_SYMBOL(acpi_check_resource_conflict); |
Thomas Renninger | df92e69 | 2008-02-04 23:31:22 -0800 | [diff] [blame] | 1245 | |
| 1246 | int acpi_check_region(resource_size_t start, resource_size_t n, |
| 1247 | const char *name) |
| 1248 | { |
| 1249 | struct resource res = { |
| 1250 | .start = start, |
| 1251 | .end = start + n - 1, |
| 1252 | .name = name, |
| 1253 | .flags = IORESOURCE_IO, |
| 1254 | }; |
| 1255 | |
| 1256 | return acpi_check_resource_conflict(&res); |
| 1257 | } |
| 1258 | EXPORT_SYMBOL(acpi_check_region); |
| 1259 | |
| 1260 | int acpi_check_mem_region(resource_size_t start, resource_size_t n, |
| 1261 | const char *name) |
| 1262 | { |
| 1263 | struct resource res = { |
| 1264 | .start = start, |
| 1265 | .end = start + n - 1, |
| 1266 | .name = name, |
| 1267 | .flags = IORESOURCE_MEM, |
| 1268 | }; |
| 1269 | |
| 1270 | return acpi_check_resource_conflict(&res); |
| 1271 | |
| 1272 | } |
| 1273 | EXPORT_SYMBOL(acpi_check_mem_region); |
| 1274 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1275 | /* |
Jean Delvare | 70dd6be | 2010-05-27 19:58:37 +0200 | [diff] [blame] | 1276 | * Let drivers know whether the resource checks are effective |
| 1277 | */ |
| 1278 | int acpi_resources_are_enforced(void) |
| 1279 | { |
| 1280 | return acpi_enforce_resources == ENFORCE_RESOURCES_STRICT; |
| 1281 | } |
| 1282 | EXPORT_SYMBOL(acpi_resources_are_enforced); |
| 1283 | |
| 1284 | /* |
Robert Moore | 73459f7 | 2005-06-24 00:00:00 -0400 | [diff] [blame] | 1285 | * Acquire a spinlock. |
| 1286 | * |
| 1287 | * handle is a pointer to the spinlock_t. |
Robert Moore | 73459f7 | 2005-06-24 00:00:00 -0400 | [diff] [blame] | 1288 | */ |
| 1289 | |
Bob Moore | 967440e3 | 2006-06-23 17:04:00 -0400 | [diff] [blame] | 1290 | acpi_cpu_flags acpi_os_acquire_lock(acpi_spinlock lockp) |
Robert Moore | 73459f7 | 2005-06-24 00:00:00 -0400 | [diff] [blame] | 1291 | { |
Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 1292 | acpi_cpu_flags flags; |
Bob Moore | 967440e3 | 2006-06-23 17:04:00 -0400 | [diff] [blame] | 1293 | spin_lock_irqsave(lockp, flags); |
Robert Moore | 73459f7 | 2005-06-24 00:00:00 -0400 | [diff] [blame] | 1294 | return flags; |
| 1295 | } |
| 1296 | |
| 1297 | /* |
| 1298 | * Release a spinlock. See above. |
| 1299 | */ |
| 1300 | |
Bob Moore | 967440e3 | 2006-06-23 17:04:00 -0400 | [diff] [blame] | 1301 | void acpi_os_release_lock(acpi_spinlock lockp, acpi_cpu_flags flags) |
Robert Moore | 73459f7 | 2005-06-24 00:00:00 -0400 | [diff] [blame] | 1302 | { |
Bob Moore | 967440e3 | 2006-06-23 17:04:00 -0400 | [diff] [blame] | 1303 | spin_unlock_irqrestore(lockp, flags); |
Robert Moore | 73459f7 | 2005-06-24 00:00:00 -0400 | [diff] [blame] | 1304 | } |
| 1305 | |
Robert Moore | 73459f7 | 2005-06-24 00:00:00 -0400 | [diff] [blame] | 1306 | #ifndef ACPI_USE_LOCAL_CACHE |
| 1307 | |
| 1308 | /******************************************************************************* |
| 1309 | * |
| 1310 | * FUNCTION: acpi_os_create_cache |
| 1311 | * |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 1312 | * PARAMETERS: name - Ascii name for the cache |
| 1313 | * size - Size of each cached object |
| 1314 | * depth - Maximum depth of the cache (in objects) <ignored> |
| 1315 | * cache - Where the new cache object is returned |
Robert Moore | 73459f7 | 2005-06-24 00:00:00 -0400 | [diff] [blame] | 1316 | * |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 1317 | * RETURN: status |
Robert Moore | 73459f7 | 2005-06-24 00:00:00 -0400 | [diff] [blame] | 1318 | * |
| 1319 | * DESCRIPTION: Create a cache object |
| 1320 | * |
| 1321 | ******************************************************************************/ |
| 1322 | |
| 1323 | acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1324 | acpi_os_create_cache(char *name, u16 size, u16 depth, acpi_cache_t ** cache) |
Robert Moore | 73459f7 | 2005-06-24 00:00:00 -0400 | [diff] [blame] | 1325 | { |
Paul Mundt | 20c2df8 | 2007-07-20 10:11:58 +0900 | [diff] [blame] | 1326 | *cache = kmem_cache_create(name, size, 0, 0, NULL); |
Adrian Bunk | a6fdbf9 | 2006-12-19 12:56:13 -0800 | [diff] [blame] | 1327 | if (*cache == NULL) |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 1328 | return AE_ERROR; |
| 1329 | else |
| 1330 | return AE_OK; |
Robert Moore | 73459f7 | 2005-06-24 00:00:00 -0400 | [diff] [blame] | 1331 | } |
| 1332 | |
| 1333 | /******************************************************************************* |
| 1334 | * |
| 1335 | * FUNCTION: acpi_os_purge_cache |
| 1336 | * |
| 1337 | * PARAMETERS: Cache - Handle to cache object |
| 1338 | * |
| 1339 | * RETURN: Status |
| 1340 | * |
| 1341 | * DESCRIPTION: Free all objects within the requested cache. |
| 1342 | * |
| 1343 | ******************************************************************************/ |
| 1344 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1345 | acpi_status acpi_os_purge_cache(acpi_cache_t * cache) |
Robert Moore | 73459f7 | 2005-06-24 00:00:00 -0400 | [diff] [blame] | 1346 | { |
Jan Engelhardt | 50dd096 | 2006-10-01 00:28:50 +0200 | [diff] [blame] | 1347 | kmem_cache_shrink(cache); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1348 | return (AE_OK); |
Robert Moore | 73459f7 | 2005-06-24 00:00:00 -0400 | [diff] [blame] | 1349 | } |
| 1350 | |
| 1351 | /******************************************************************************* |
| 1352 | * |
| 1353 | * FUNCTION: acpi_os_delete_cache |
| 1354 | * |
| 1355 | * PARAMETERS: Cache - Handle to cache object |
| 1356 | * |
| 1357 | * RETURN: Status |
| 1358 | * |
| 1359 | * DESCRIPTION: Free all objects within the requested cache and delete the |
| 1360 | * cache object. |
| 1361 | * |
| 1362 | ******************************************************************************/ |
| 1363 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1364 | acpi_status acpi_os_delete_cache(acpi_cache_t * cache) |
Robert Moore | 73459f7 | 2005-06-24 00:00:00 -0400 | [diff] [blame] | 1365 | { |
Alexey Dobriyan | 1a1d92c | 2006-09-27 01:49:40 -0700 | [diff] [blame] | 1366 | kmem_cache_destroy(cache); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1367 | return (AE_OK); |
Robert Moore | 73459f7 | 2005-06-24 00:00:00 -0400 | [diff] [blame] | 1368 | } |
| 1369 | |
| 1370 | /******************************************************************************* |
| 1371 | * |
| 1372 | * FUNCTION: acpi_os_release_object |
| 1373 | * |
| 1374 | * PARAMETERS: Cache - Handle to cache object |
| 1375 | * Object - The object to be released |
| 1376 | * |
| 1377 | * RETURN: None |
| 1378 | * |
| 1379 | * DESCRIPTION: Release an object to the specified cache. If cache is full, |
| 1380 | * the object is deleted. |
| 1381 | * |
| 1382 | ******************************************************************************/ |
| 1383 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1384 | acpi_status acpi_os_release_object(acpi_cache_t * cache, void *object) |
Robert Moore | 73459f7 | 2005-06-24 00:00:00 -0400 | [diff] [blame] | 1385 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1386 | kmem_cache_free(cache, object); |
| 1387 | return (AE_OK); |
Robert Moore | 73459f7 | 2005-06-24 00:00:00 -0400 | [diff] [blame] | 1388 | } |
| 1389 | |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 1390 | /****************************************************************************** |
| 1391 | * |
| 1392 | * FUNCTION: acpi_os_validate_interface |
| 1393 | * |
| 1394 | * PARAMETERS: interface - Requested interface to be validated |
| 1395 | * |
| 1396 | * RETURN: AE_OK if interface is supported, AE_SUPPORT otherwise |
| 1397 | * |
| 1398 | * DESCRIPTION: Match an interface string to the interfaces supported by the |
| 1399 | * host. Strings originate from an AML call to the _OSI method. |
| 1400 | * |
| 1401 | *****************************************************************************/ |
| 1402 | |
| 1403 | acpi_status |
| 1404 | acpi_os_validate_interface (char *interface) |
| 1405 | { |
Len Brown | ae00d81 | 2007-05-29 18:43:33 -0400 | [diff] [blame] | 1406 | if (!strncmp(osi_additional_string, interface, OSI_STRING_LENGTH_MAX)) |
| 1407 | return AE_OK; |
Len Brown | f507654 | 2007-05-30 00:10:38 -0400 | [diff] [blame] | 1408 | if (!strcmp("Linux", interface)) { |
Len Brown | d4b7dc4 | 2008-01-23 20:50:56 -0500 | [diff] [blame] | 1409 | |
| 1410 | printk(KERN_NOTICE PREFIX |
| 1411 | "BIOS _OSI(Linux) query %s%s\n", |
| 1412 | osi_linux.enable ? "honored" : "ignored", |
| 1413 | osi_linux.cmdline ? " via cmdline" : |
| 1414 | osi_linux.dmi ? " via DMI" : ""); |
| 1415 | |
Len Brown | d4b7dc4 | 2008-01-23 20:50:56 -0500 | [diff] [blame] | 1416 | if (osi_linux.enable) |
Len Brown | f507654 | 2007-05-30 00:10:38 -0400 | [diff] [blame] | 1417 | return AE_OK; |
| 1418 | } |
Len Brown | ae00d81 | 2007-05-29 18:43:33 -0400 | [diff] [blame] | 1419 | return AE_SUPPORT; |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 1420 | } |
| 1421 | |
Lin Ming | a5fe1a0 | 2009-08-13 10:43:27 +0800 | [diff] [blame] | 1422 | static inline int acpi_res_list_add(struct acpi_res_list *res) |
| 1423 | { |
| 1424 | struct acpi_res_list *res_list_elem; |
| 1425 | |
| 1426 | list_for_each_entry(res_list_elem, &resource_list_head, |
| 1427 | resource_list) { |
| 1428 | |
| 1429 | if (res->resource_type == res_list_elem->resource_type && |
| 1430 | res->start == res_list_elem->start && |
| 1431 | res->end == res_list_elem->end) { |
| 1432 | |
| 1433 | /* |
| 1434 | * The Region(addr,len) already exist in the list, |
| 1435 | * just increase the count |
| 1436 | */ |
| 1437 | |
| 1438 | res_list_elem->count++; |
| 1439 | return 0; |
| 1440 | } |
| 1441 | } |
| 1442 | |
| 1443 | res->count = 1; |
| 1444 | list_add(&res->resource_list, &resource_list_head); |
| 1445 | return 1; |
| 1446 | } |
| 1447 | |
| 1448 | static inline void acpi_res_list_del(struct acpi_res_list *res) |
| 1449 | { |
| 1450 | struct acpi_res_list *res_list_elem; |
| 1451 | |
| 1452 | list_for_each_entry(res_list_elem, &resource_list_head, |
| 1453 | resource_list) { |
| 1454 | |
| 1455 | if (res->resource_type == res_list_elem->resource_type && |
| 1456 | res->start == res_list_elem->start && |
| 1457 | res->end == res_list_elem->end) { |
| 1458 | |
| 1459 | /* |
| 1460 | * If the res count is decreased to 0, |
| 1461 | * remove and free it |
| 1462 | */ |
| 1463 | |
| 1464 | if (--res_list_elem->count == 0) { |
| 1465 | list_del(&res_list_elem->resource_list); |
| 1466 | kfree(res_list_elem); |
| 1467 | } |
| 1468 | return; |
| 1469 | } |
| 1470 | } |
| 1471 | } |
| 1472 | |
| 1473 | acpi_status |
| 1474 | acpi_os_invalidate_address( |
| 1475 | u8 space_id, |
| 1476 | acpi_physical_address address, |
| 1477 | acpi_size length) |
| 1478 | { |
| 1479 | struct acpi_res_list res; |
| 1480 | |
| 1481 | switch (space_id) { |
| 1482 | case ACPI_ADR_SPACE_SYSTEM_IO: |
| 1483 | case ACPI_ADR_SPACE_SYSTEM_MEMORY: |
Thomas Weber | 8839316 | 2010-03-16 11:47:56 +0100 | [diff] [blame] | 1484 | /* Only interference checks against SystemIO and SystemMemory |
Lin Ming | a5fe1a0 | 2009-08-13 10:43:27 +0800 | [diff] [blame] | 1485 | are needed */ |
| 1486 | res.start = address; |
| 1487 | res.end = address + length - 1; |
| 1488 | res.resource_type = space_id; |
| 1489 | spin_lock(&acpi_res_lock); |
| 1490 | acpi_res_list_del(&res); |
| 1491 | spin_unlock(&acpi_res_lock); |
| 1492 | break; |
| 1493 | case ACPI_ADR_SPACE_PCI_CONFIG: |
| 1494 | case ACPI_ADR_SPACE_EC: |
| 1495 | case ACPI_ADR_SPACE_SMBUS: |
| 1496 | case ACPI_ADR_SPACE_CMOS: |
| 1497 | case ACPI_ADR_SPACE_PCI_BAR_TARGET: |
| 1498 | case ACPI_ADR_SPACE_DATA_TABLE: |
| 1499 | case ACPI_ADR_SPACE_FIXED_HARDWARE: |
| 1500 | break; |
| 1501 | } |
| 1502 | return AE_OK; |
| 1503 | } |
| 1504 | |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 1505 | /****************************************************************************** |
| 1506 | * |
| 1507 | * FUNCTION: acpi_os_validate_address |
| 1508 | * |
| 1509 | * PARAMETERS: space_id - ACPI space ID |
| 1510 | * address - Physical address |
| 1511 | * length - Address length |
| 1512 | * |
| 1513 | * RETURN: AE_OK if address/length is valid for the space_id. Otherwise, |
| 1514 | * should return AE_AML_ILLEGAL_ADDRESS. |
| 1515 | * |
| 1516 | * DESCRIPTION: Validate a system address via the host OS. Used to validate |
| 1517 | * the addresses accessed by AML operation regions. |
| 1518 | * |
| 1519 | *****************************************************************************/ |
| 1520 | |
| 1521 | acpi_status |
| 1522 | acpi_os_validate_address ( |
| 1523 | u8 space_id, |
| 1524 | acpi_physical_address address, |
Thomas Renninger | df92e69 | 2008-02-04 23:31:22 -0800 | [diff] [blame] | 1525 | acpi_size length, |
| 1526 | char *name) |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 1527 | { |
Thomas Renninger | df92e69 | 2008-02-04 23:31:22 -0800 | [diff] [blame] | 1528 | struct acpi_res_list *res; |
Lin Ming | a5fe1a0 | 2009-08-13 10:43:27 +0800 | [diff] [blame] | 1529 | int added; |
Thomas Renninger | df92e69 | 2008-02-04 23:31:22 -0800 | [diff] [blame] | 1530 | if (acpi_enforce_resources == ENFORCE_RESOURCES_NO) |
| 1531 | return AE_OK; |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 1532 | |
Thomas Renninger | df92e69 | 2008-02-04 23:31:22 -0800 | [diff] [blame] | 1533 | switch (space_id) { |
| 1534 | case ACPI_ADR_SPACE_SYSTEM_IO: |
| 1535 | case ACPI_ADR_SPACE_SYSTEM_MEMORY: |
Thomas Weber | 8839316 | 2010-03-16 11:47:56 +0100 | [diff] [blame] | 1536 | /* Only interference checks against SystemIO and SystemMemory |
Thomas Renninger | df92e69 | 2008-02-04 23:31:22 -0800 | [diff] [blame] | 1537 | are needed */ |
| 1538 | res = kzalloc(sizeof(struct acpi_res_list), GFP_KERNEL); |
| 1539 | if (!res) |
| 1540 | return AE_OK; |
| 1541 | /* ACPI names are fixed to 4 bytes, still better use strlcpy */ |
| 1542 | strlcpy(res->name, name, 5); |
| 1543 | res->start = address; |
| 1544 | res->end = address + length - 1; |
| 1545 | res->resource_type = space_id; |
| 1546 | spin_lock(&acpi_res_lock); |
Lin Ming | a5fe1a0 | 2009-08-13 10:43:27 +0800 | [diff] [blame] | 1547 | added = acpi_res_list_add(res); |
Thomas Renninger | df92e69 | 2008-02-04 23:31:22 -0800 | [diff] [blame] | 1548 | spin_unlock(&acpi_res_lock); |
Lin Ming | a5fe1a0 | 2009-08-13 10:43:27 +0800 | [diff] [blame] | 1549 | pr_debug("%s %s resource: start: 0x%llx, end: 0x%llx, " |
| 1550 | "name: %s\n", added ? "Added" : "Already exist", |
| 1551 | (space_id == ACPI_ADR_SPACE_SYSTEM_IO) |
Thomas Renninger | df92e69 | 2008-02-04 23:31:22 -0800 | [diff] [blame] | 1552 | ? "SystemIO" : "System Memory", |
| 1553 | (unsigned long long)res->start, |
| 1554 | (unsigned long long)res->end, |
| 1555 | res->name); |
Lin Ming | a5fe1a0 | 2009-08-13 10:43:27 +0800 | [diff] [blame] | 1556 | if (!added) |
| 1557 | kfree(res); |
Thomas Renninger | df92e69 | 2008-02-04 23:31:22 -0800 | [diff] [blame] | 1558 | break; |
| 1559 | case ACPI_ADR_SPACE_PCI_CONFIG: |
| 1560 | case ACPI_ADR_SPACE_EC: |
| 1561 | case ACPI_ADR_SPACE_SMBUS: |
| 1562 | case ACPI_ADR_SPACE_CMOS: |
| 1563 | case ACPI_ADR_SPACE_PCI_BAR_TARGET: |
| 1564 | case ACPI_ADR_SPACE_DATA_TABLE: |
| 1565 | case ACPI_ADR_SPACE_FIXED_HARDWARE: |
| 1566 | break; |
| 1567 | } |
| 1568 | return AE_OK; |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 1569 | } |
Robert Moore | 73459f7 | 2005-06-24 00:00:00 -0400 | [diff] [blame] | 1570 | #endif |
Myron Stowe | d362eda | 2010-10-21 14:24:04 -0600 | [diff] [blame] | 1571 | |
| 1572 | acpi_status __init acpi_os_initialize(void) |
| 1573 | { |
| 1574 | acpi_os_map_generic_address(&acpi_gbl_FADT.xpm1a_event_block); |
| 1575 | acpi_os_map_generic_address(&acpi_gbl_FADT.xpm1b_event_block); |
| 1576 | acpi_os_map_generic_address(&acpi_gbl_FADT.xgpe0_block); |
| 1577 | acpi_os_map_generic_address(&acpi_gbl_FADT.xgpe1_block); |
| 1578 | |
| 1579 | return AE_OK; |
| 1580 | } |
| 1581 | |
| 1582 | acpi_status acpi_os_initialize1(void) |
| 1583 | { |
| 1584 | kacpid_wq = create_workqueue("kacpid"); |
| 1585 | kacpi_notify_wq = create_workqueue("kacpi_notify"); |
| 1586 | kacpi_hotplug_wq = create_workqueue("kacpi_hotplug"); |
| 1587 | BUG_ON(!kacpid_wq); |
| 1588 | BUG_ON(!kacpi_notify_wq); |
| 1589 | BUG_ON(!kacpi_hotplug_wq); |
| 1590 | return AE_OK; |
| 1591 | } |
| 1592 | |
| 1593 | acpi_status acpi_os_terminate(void) |
| 1594 | { |
| 1595 | if (acpi_irq_handler) { |
| 1596 | acpi_os_remove_interrupt_handler(acpi_irq_irq, |
| 1597 | acpi_irq_handler); |
| 1598 | } |
| 1599 | |
| 1600 | acpi_os_unmap_generic_address(&acpi_gbl_FADT.xgpe1_block); |
| 1601 | acpi_os_unmap_generic_address(&acpi_gbl_FADT.xgpe0_block); |
| 1602 | acpi_os_unmap_generic_address(&acpi_gbl_FADT.xpm1b_event_block); |
| 1603 | acpi_os_unmap_generic_address(&acpi_gbl_FADT.xpm1a_event_block); |
| 1604 | |
| 1605 | destroy_workqueue(kacpid_wq); |
| 1606 | destroy_workqueue(kacpi_notify_wq); |
| 1607 | destroy_workqueue(kacpi_hotplug_wq); |
| 1608 | |
| 1609 | return AE_OK; |
| 1610 | } |