Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'release' of git://git.kernel.org/pub/scm/linux/kernel/git/lenb/linux-acpi-2.6

* 'release' of git://git.kernel.org/pub/scm/linux/kernel/git/lenb/linux-acpi-2.6:
ACPI EC: remove redundant code
ACPI: Add D3 cold state
ACPI: processor: fix processor_physically_present in UP kernel
ACPI: Split out custom_method functionality into an own driver
ACPI: Cleanup custom_method debug stuff
ACPI EC: enable MSI workaround for Quanta laptops
ACPICA: Update to version 20110413
ACPICA: Execute an orphan _REG method under the EC device
ACPICA: Move ACPI_NUM_PREDEFINED_REGIONS to a more appropriate place
ACPICA: Update internal address SpaceID for DataTable regions
ACPICA: Add more methods eligible for NULL package element removal
ACPICA: Split all internal Global Lock functions to new file - evglock
ACPI: EC: add another DMI check for ASUS hardware
ACPI EC: remove dead code
ACPICA: Fix code divergence of global lock handling
ACPICA: Use acpi_os_create_lock interface
ACPI: osl, add acpi_os_create_lock interface
ACPI:Fix goto flows in thermal-sys

+729 -498
+5
Documentation/acpi/method-customizing.txt
··· 66 66 But each individual write to debugfs can implement a SINGLE 67 67 method override. i.e. if we want to insert/override multiple 68 68 ACPI methods, we need to redo step c) ~ g) for multiple times. 69 + 70 + Note: Be aware that root can mis-use this driver to modify arbitrary 71 + memory and gain additional rights, if root's privileges got 72 + restricted (for example if root is not allowed to load additional 73 + modules after boot).
+15
drivers/acpi/Kconfig
··· 369 369 which is used to report some hardware errors notified via 370 370 SCI, mainly the corrected errors. 371 371 372 + config ACPI_CUSTOM_METHOD 373 + tristate "Allow ACPI methods to be inserted/replaced at run time" 374 + depends on DEBUG_FS 375 + default n 376 + help 377 + This debug facility allows ACPI AML methods to me inserted and/or 378 + replaced without rebooting the system. For details refer to: 379 + Documentation/acpi/method-customizing.txt. 380 + 381 + NOTE: This option is security sensitive, because it allows arbitrary 382 + kernel memory to be written to by root (uid=0) users, allowing them 383 + to bypass certain security measures (e.g. if root is not allowed to 384 + load additional kernel modules after boot, this feature may be used 385 + to override that restriction). 386 + 372 387 source "drivers/acpi/apei/Kconfig" 373 388 374 389 endif # ACPI
+1
drivers/acpi/Makefile
··· 61 61 obj-$(CONFIG_ACPI_SBS) += sbs.o 62 62 obj-$(CONFIG_ACPI_HED) += hed.o 63 63 obj-$(CONFIG_ACPI_EC_DEBUGFS) += ec_sys.o 64 + obj-$(CONFIG_ACPI_CUSTOM_METHOD)+= custom_method.o 64 65 65 66 # processor has its own "processor." module_param namespace 66 67 processor-y := processor_driver.o processor_throttling.o
+1 -1
drivers/acpi/acpica/Makefile
··· 14 14 15 15 acpi-y += evevent.o evregion.o evsci.o evxfevnt.o \ 16 16 evmisc.o evrgnini.o evxface.o evxfregn.o \ 17 - evgpe.o evgpeblk.o evgpeinit.o evgpeutil.o evxfgpe.o 17 + evgpe.o evgpeblk.o evgpeinit.o evgpeutil.o evxfgpe.o evglock.o 18 18 19 19 acpi-y += exconfig.o exfield.o exnames.o exoparg6.o exresolv.o exstorob.o\ 20 20 exconvrt.o exfldio.o exoparg1.o exprep.o exresop.o exsystem.o\
-1
drivers/acpi/acpica/acconfig.h
··· 187 187 188 188 /* Operation regions */ 189 189 190 - #define ACPI_NUM_PREDEFINED_REGIONS 9 191 190 #define ACPI_USER_REGION_BEGIN 0x80 192 191 193 192 /* Maximum space_ids for Operation Regions */
+11 -6
drivers/acpi/acpica/acevents.h
··· 58 58 */ 59 59 u8 acpi_ev_is_notify_object(struct acpi_namespace_node *node); 60 60 61 - acpi_status acpi_ev_acquire_global_lock(u16 timeout); 62 - 63 - acpi_status acpi_ev_release_global_lock(void); 64 - 65 - acpi_status acpi_ev_init_global_lock_handler(void); 66 - 67 61 u32 acpi_ev_get_gpe_number_index(u32 gpe_number); 68 62 69 63 acpi_status 70 64 acpi_ev_queue_notify_request(struct acpi_namespace_node *node, 71 65 u32 notify_value); 66 + 67 + /* 68 + * evglock - Global Lock support 69 + */ 70 + acpi_status acpi_ev_init_global_lock_handler(void); 71 + 72 + acpi_status acpi_ev_acquire_global_lock(u16 timeout); 73 + 74 + acpi_status acpi_ev_release_global_lock(void); 75 + 76 + acpi_status acpi_ev_remove_global_lock_handler(void); 72 77 73 78 /* 74 79 * evgpe - Low-level GPE support
+6 -7
drivers/acpi/acpica/acglobal.h
··· 214 214 215 215 /* 216 216 * Global lock mutex is an actual AML mutex object 217 - * Global lock semaphore works in conjunction with the HW global lock 217 + * Global lock semaphore works in conjunction with the actual global lock 218 + * Global lock spinlock is used for "pending" handshake 218 219 */ 219 220 ACPI_EXTERN union acpi_operand_object *acpi_gbl_global_lock_mutex; 220 221 ACPI_EXTERN acpi_semaphore acpi_gbl_global_lock_semaphore; 222 + ACPI_EXTERN acpi_spinlock acpi_gbl_global_lock_pending_lock; 221 223 ACPI_EXTERN u16 acpi_gbl_global_lock_handle; 222 224 ACPI_EXTERN u8 acpi_gbl_global_lock_acquired; 223 225 ACPI_EXTERN u8 acpi_gbl_global_lock_present; 226 + ACPI_EXTERN u8 acpi_gbl_global_lock_pending; 224 227 225 228 /* 226 229 * Spinlocks are used for interfaces that can be possibly called at 227 230 * interrupt level 228 231 */ 229 - ACPI_EXTERN spinlock_t _acpi_gbl_gpe_lock; /* For GPE data structs and registers */ 230 - ACPI_EXTERN spinlock_t _acpi_gbl_hardware_lock; /* For ACPI H/W except GPE registers */ 231 - ACPI_EXTERN spinlock_t _acpi_ev_global_lock_pending_lock; /* For global lock */ 232 - #define acpi_gbl_gpe_lock &_acpi_gbl_gpe_lock 233 - #define acpi_gbl_hardware_lock &_acpi_gbl_hardware_lock 234 - #define acpi_ev_global_lock_pending_lock &_acpi_ev_global_lock_pending_lock 232 + ACPI_EXTERN acpi_spinlock acpi_gbl_gpe_lock; /* For GPE data structs and registers */ 233 + ACPI_EXTERN acpi_spinlock acpi_gbl_hardware_lock; /* For ACPI H/W except GPE registers */ 235 234 236 235 /***************************************************************************** 237 236 *
-15
drivers/acpi/acpica/amlcode.h
··· 394 394 #define AML_CLASS_METHOD_CALL 0x09 395 395 #define AML_CLASS_UNKNOWN 0x0A 396 396 397 - /* Predefined Operation Region space_iDs */ 398 - 399 - typedef enum { 400 - REGION_MEMORY = 0, 401 - REGION_IO, 402 - REGION_PCI_CONFIG, 403 - REGION_EC, 404 - REGION_SMBUS, 405 - REGION_CMOS, 406 - REGION_PCI_BAR, 407 - REGION_IPMI, 408 - REGION_DATA_TABLE, /* Internal use only */ 409 - REGION_FIXED_HW = 0x7F 410 - } AML_REGION_TYPES; 411 - 412 397 /* Comparison operation codes for match_op operator */ 413 398 414 399 typedef enum {
+1 -1
drivers/acpi/acpica/dswload.c
··· 450 450 status = 451 451 acpi_ex_create_region(op->named.data, 452 452 op->named.length, 453 - REGION_DATA_TABLE, 453 + ACPI_ADR_SPACE_DATA_TABLE, 454 454 walk_state); 455 455 if (ACPI_FAILURE(status)) { 456 456 return_ACPI_STATUS(status);
+1 -1
drivers/acpi/acpica/dswload2.c
··· 562 562 ((op->common.value.arg)->common.value. 563 563 integer); 564 564 } else { 565 - region_space = REGION_DATA_TABLE; 565 + region_space = ACPI_ADR_SPACE_DATA_TABLE; 566 566 } 567 567 568 568 /*
+335
drivers/acpi/acpica/evglock.c
··· 1 + /****************************************************************************** 2 + * 3 + * Module Name: evglock - Global Lock support 4 + * 5 + *****************************************************************************/ 6 + 7 + /* 8 + * Copyright (C) 2000 - 2011, Intel Corp. 9 + * All rights reserved. 10 + * 11 + * Redistribution and use in source and binary forms, with or without 12 + * modification, are permitted provided that the following conditions 13 + * are met: 14 + * 1. Redistributions of source code must retain the above copyright 15 + * notice, this list of conditions, and the following disclaimer, 16 + * without modification. 17 + * 2. Redistributions in binary form must reproduce at minimum a disclaimer 18 + * substantially similar to the "NO WARRANTY" disclaimer below 19 + * ("Disclaimer") and any redistribution must be conditioned upon 20 + * including a substantially similar Disclaimer requirement for further 21 + * binary redistribution. 22 + * 3. Neither the names of the above-listed copyright holders nor the names 23 + * of any contributors may be used to endorse or promote products derived 24 + * from this software without specific prior written permission. 25 + * 26 + * Alternatively, this software may be distributed under the terms of the 27 + * GNU General Public License ("GPL") version 2 as published by the Free 28 + * Software Foundation. 29 + * 30 + * NO WARRANTY 31 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 32 + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 33 + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR 34 + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 35 + * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 36 + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 37 + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 38 + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 39 + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 40 + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 41 + * POSSIBILITY OF SUCH DAMAGES. 42 + */ 43 + 44 + #include <acpi/acpi.h> 45 + #include "accommon.h" 46 + #include "acevents.h" 47 + #include "acinterp.h" 48 + 49 + #define _COMPONENT ACPI_EVENTS 50 + ACPI_MODULE_NAME("evglock") 51 + 52 + /* Local prototypes */ 53 + static u32 acpi_ev_global_lock_handler(void *context); 54 + 55 + /******************************************************************************* 56 + * 57 + * FUNCTION: acpi_ev_init_global_lock_handler 58 + * 59 + * PARAMETERS: None 60 + * 61 + * RETURN: Status 62 + * 63 + * DESCRIPTION: Install a handler for the global lock release event 64 + * 65 + ******************************************************************************/ 66 + 67 + acpi_status acpi_ev_init_global_lock_handler(void) 68 + { 69 + acpi_status status; 70 + 71 + ACPI_FUNCTION_TRACE(ev_init_global_lock_handler); 72 + 73 + /* Attempt installation of the global lock handler */ 74 + 75 + status = acpi_install_fixed_event_handler(ACPI_EVENT_GLOBAL, 76 + acpi_ev_global_lock_handler, 77 + NULL); 78 + 79 + /* 80 + * If the global lock does not exist on this platform, the attempt to 81 + * enable GBL_STATUS will fail (the GBL_ENABLE bit will not stick). 82 + * Map to AE_OK, but mark global lock as not present. Any attempt to 83 + * actually use the global lock will be flagged with an error. 84 + */ 85 + acpi_gbl_global_lock_present = FALSE; 86 + if (status == AE_NO_HARDWARE_RESPONSE) { 87 + ACPI_ERROR((AE_INFO, 88 + "No response from Global Lock hardware, disabling lock")); 89 + 90 + return_ACPI_STATUS(AE_OK); 91 + } 92 + 93 + status = acpi_os_create_lock(&acpi_gbl_global_lock_pending_lock); 94 + if (ACPI_FAILURE(status)) { 95 + return_ACPI_STATUS(status); 96 + } 97 + 98 + acpi_gbl_global_lock_pending = FALSE; 99 + acpi_gbl_global_lock_present = TRUE; 100 + return_ACPI_STATUS(status); 101 + } 102 + 103 + /******************************************************************************* 104 + * 105 + * FUNCTION: acpi_ev_remove_global_lock_handler 106 + * 107 + * PARAMETERS: None 108 + * 109 + * RETURN: Status 110 + * 111 + * DESCRIPTION: Remove the handler for the Global Lock 112 + * 113 + ******************************************************************************/ 114 + 115 + acpi_status acpi_ev_remove_global_lock_handler(void) 116 + { 117 + acpi_status status; 118 + 119 + ACPI_FUNCTION_TRACE(ev_remove_global_lock_handler); 120 + 121 + acpi_gbl_global_lock_present = FALSE; 122 + status = acpi_remove_fixed_event_handler(ACPI_EVENT_GLOBAL, 123 + acpi_ev_global_lock_handler); 124 + 125 + return_ACPI_STATUS(status); 126 + } 127 + 128 + /******************************************************************************* 129 + * 130 + * FUNCTION: acpi_ev_global_lock_handler 131 + * 132 + * PARAMETERS: Context - From thread interface, not used 133 + * 134 + * RETURN: ACPI_INTERRUPT_HANDLED 135 + * 136 + * DESCRIPTION: Invoked directly from the SCI handler when a global lock 137 + * release interrupt occurs. If there is actually a pending 138 + * request for the lock, signal the waiting thread. 139 + * 140 + ******************************************************************************/ 141 + 142 + static u32 acpi_ev_global_lock_handler(void *context) 143 + { 144 + acpi_status status; 145 + acpi_cpu_flags flags; 146 + 147 + flags = acpi_os_acquire_lock(acpi_gbl_global_lock_pending_lock); 148 + 149 + /* 150 + * If a request for the global lock is not actually pending, 151 + * we are done. This handles "spurious" global lock interrupts 152 + * which are possible (and have been seen) with bad BIOSs. 153 + */ 154 + if (!acpi_gbl_global_lock_pending) { 155 + goto cleanup_and_exit; 156 + } 157 + 158 + /* 159 + * Send a unit to the global lock semaphore. The actual acquisition 160 + * of the global lock will be performed by the waiting thread. 161 + */ 162 + status = acpi_os_signal_semaphore(acpi_gbl_global_lock_semaphore, 1); 163 + if (ACPI_FAILURE(status)) { 164 + ACPI_ERROR((AE_INFO, "Could not signal Global Lock semaphore")); 165 + } 166 + 167 + acpi_gbl_global_lock_pending = FALSE; 168 + 169 + cleanup_and_exit: 170 + 171 + acpi_os_release_lock(acpi_gbl_global_lock_pending_lock, flags); 172 + return (ACPI_INTERRUPT_HANDLED); 173 + } 174 + 175 + /****************************************************************************** 176 + * 177 + * FUNCTION: acpi_ev_acquire_global_lock 178 + * 179 + * PARAMETERS: Timeout - Max time to wait for the lock, in millisec. 180 + * 181 + * RETURN: Status 182 + * 183 + * DESCRIPTION: Attempt to gain ownership of the Global Lock. 184 + * 185 + * MUTEX: Interpreter must be locked 186 + * 187 + * Note: The original implementation allowed multiple threads to "acquire" the 188 + * Global Lock, and the OS would hold the lock until the last thread had 189 + * released it. However, this could potentially starve the BIOS out of the 190 + * lock, especially in the case where there is a tight handshake between the 191 + * Embedded Controller driver and the BIOS. Therefore, this implementation 192 + * allows only one thread to acquire the HW Global Lock at a time, and makes 193 + * the global lock appear as a standard mutex on the OS side. 194 + * 195 + *****************************************************************************/ 196 + 197 + acpi_status acpi_ev_acquire_global_lock(u16 timeout) 198 + { 199 + acpi_cpu_flags flags; 200 + acpi_status status; 201 + u8 acquired = FALSE; 202 + 203 + ACPI_FUNCTION_TRACE(ev_acquire_global_lock); 204 + 205 + /* 206 + * Only one thread can acquire the GL at a time, the global_lock_mutex 207 + * enforces this. This interface releases the interpreter if we must wait. 208 + */ 209 + status = 210 + acpi_ex_system_wait_mutex(acpi_gbl_global_lock_mutex->mutex. 211 + os_mutex, timeout); 212 + if (ACPI_FAILURE(status)) { 213 + return_ACPI_STATUS(status); 214 + } 215 + 216 + /* 217 + * Update the global lock handle and check for wraparound. The handle is 218 + * only used for the external global lock interfaces, but it is updated 219 + * here to properly handle the case where a single thread may acquire the 220 + * lock via both the AML and the acpi_acquire_global_lock interfaces. The 221 + * handle is therefore updated on the first acquire from a given thread 222 + * regardless of where the acquisition request originated. 223 + */ 224 + acpi_gbl_global_lock_handle++; 225 + if (acpi_gbl_global_lock_handle == 0) { 226 + acpi_gbl_global_lock_handle = 1; 227 + } 228 + 229 + /* 230 + * Make sure that a global lock actually exists. If not, just 231 + * treat the lock as a standard mutex. 232 + */ 233 + if (!acpi_gbl_global_lock_present) { 234 + acpi_gbl_global_lock_acquired = TRUE; 235 + return_ACPI_STATUS(AE_OK); 236 + } 237 + 238 + flags = acpi_os_acquire_lock(acpi_gbl_global_lock_pending_lock); 239 + 240 + do { 241 + 242 + /* Attempt to acquire the actual hardware lock */ 243 + 244 + ACPI_ACQUIRE_GLOBAL_LOCK(acpi_gbl_FACS, acquired); 245 + if (acquired) { 246 + acpi_gbl_global_lock_acquired = TRUE; 247 + ACPI_DEBUG_PRINT((ACPI_DB_EXEC, 248 + "Acquired hardware Global Lock\n")); 249 + break; 250 + } 251 + 252 + /* 253 + * Did not get the lock. The pending bit was set above, and 254 + * we must now wait until we receive the global lock 255 + * released interrupt. 256 + */ 257 + acpi_gbl_global_lock_pending = TRUE; 258 + acpi_os_release_lock(acpi_gbl_global_lock_pending_lock, flags); 259 + 260 + ACPI_DEBUG_PRINT((ACPI_DB_EXEC, 261 + "Waiting for hardware Global Lock\n")); 262 + 263 + /* 264 + * Wait for handshake with the global lock interrupt handler. 265 + * This interface releases the interpreter if we must wait. 266 + */ 267 + status = 268 + acpi_ex_system_wait_semaphore 269 + (acpi_gbl_global_lock_semaphore, ACPI_WAIT_FOREVER); 270 + 271 + flags = acpi_os_acquire_lock(acpi_gbl_global_lock_pending_lock); 272 + 273 + } while (ACPI_SUCCESS(status)); 274 + 275 + acpi_gbl_global_lock_pending = FALSE; 276 + acpi_os_release_lock(acpi_gbl_global_lock_pending_lock, flags); 277 + 278 + return_ACPI_STATUS(status); 279 + } 280 + 281 + /******************************************************************************* 282 + * 283 + * FUNCTION: acpi_ev_release_global_lock 284 + * 285 + * PARAMETERS: None 286 + * 287 + * RETURN: Status 288 + * 289 + * DESCRIPTION: Releases ownership of the Global Lock. 290 + * 291 + ******************************************************************************/ 292 + 293 + acpi_status acpi_ev_release_global_lock(void) 294 + { 295 + u8 pending = FALSE; 296 + acpi_status status = AE_OK; 297 + 298 + ACPI_FUNCTION_TRACE(ev_release_global_lock); 299 + 300 + /* Lock must be already acquired */ 301 + 302 + if (!acpi_gbl_global_lock_acquired) { 303 + ACPI_WARNING((AE_INFO, 304 + "Cannot release the ACPI Global Lock, it has not been acquired")); 305 + return_ACPI_STATUS(AE_NOT_ACQUIRED); 306 + } 307 + 308 + if (acpi_gbl_global_lock_present) { 309 + 310 + /* Allow any thread to release the lock */ 311 + 312 + ACPI_RELEASE_GLOBAL_LOCK(acpi_gbl_FACS, pending); 313 + 314 + /* 315 + * If the pending bit was set, we must write GBL_RLS to the control 316 + * register 317 + */ 318 + if (pending) { 319 + status = 320 + acpi_write_bit_register 321 + (ACPI_BITREG_GLOBAL_LOCK_RELEASE, 322 + ACPI_ENABLE_EVENT); 323 + } 324 + 325 + ACPI_DEBUG_PRINT((ACPI_DB_EXEC, 326 + "Released hardware Global Lock\n")); 327 + } 328 + 329 + acpi_gbl_global_lock_acquired = FALSE; 330 + 331 + /* Release the local GL mutex */ 332 + 333 + acpi_os_release_mutex(acpi_gbl_global_lock_mutex->mutex.os_mutex); 334 + return_ACPI_STATUS(status); 335 + }
-303
drivers/acpi/acpica/evmisc.c
··· 45 45 #include "accommon.h" 46 46 #include "acevents.h" 47 47 #include "acnamesp.h" 48 - #include "acinterp.h" 49 48 50 49 #define _COMPONENT ACPI_EVENTS 51 50 ACPI_MODULE_NAME("evmisc") 52 51 53 52 /* Local prototypes */ 54 53 static void ACPI_SYSTEM_XFACE acpi_ev_notify_dispatch(void *context); 55 - 56 - static u32 acpi_ev_global_lock_handler(void *context); 57 - 58 - static acpi_status acpi_ev_remove_global_lock_handler(void); 59 54 60 55 /******************************************************************************* 61 56 * ··· 268 273 /* All done with the info object */ 269 274 270 275 acpi_ut_delete_generic_state(notify_info); 271 - } 272 - 273 - /******************************************************************************* 274 - * 275 - * FUNCTION: acpi_ev_global_lock_handler 276 - * 277 - * PARAMETERS: Context - From thread interface, not used 278 - * 279 - * RETURN: ACPI_INTERRUPT_HANDLED 280 - * 281 - * DESCRIPTION: Invoked directly from the SCI handler when a global lock 282 - * release interrupt occurs. If there's a thread waiting for 283 - * the global lock, signal it. 284 - * 285 - * NOTE: Assumes that the semaphore can be signaled from interrupt level. If 286 - * this is not possible for some reason, a separate thread will have to be 287 - * scheduled to do this. 288 - * 289 - ******************************************************************************/ 290 - static u8 acpi_ev_global_lock_pending; 291 - 292 - static u32 acpi_ev_global_lock_handler(void *context) 293 - { 294 - acpi_status status; 295 - acpi_cpu_flags flags; 296 - 297 - flags = acpi_os_acquire_lock(acpi_ev_global_lock_pending_lock); 298 - 299 - if (!acpi_ev_global_lock_pending) { 300 - goto out; 301 - } 302 - 303 - /* Send a unit to the semaphore */ 304 - 305 - status = acpi_os_signal_semaphore(acpi_gbl_global_lock_semaphore, 1); 306 - if (ACPI_FAILURE(status)) { 307 - ACPI_ERROR((AE_INFO, "Could not signal Global Lock semaphore")); 308 - } 309 - 310 - acpi_ev_global_lock_pending = FALSE; 311 - 312 - out: 313 - acpi_os_release_lock(acpi_ev_global_lock_pending_lock, flags); 314 - 315 - return (ACPI_INTERRUPT_HANDLED); 316 - } 317 - 318 - /******************************************************************************* 319 - * 320 - * FUNCTION: acpi_ev_init_global_lock_handler 321 - * 322 - * PARAMETERS: None 323 - * 324 - * RETURN: Status 325 - * 326 - * DESCRIPTION: Install a handler for the global lock release event 327 - * 328 - ******************************************************************************/ 329 - 330 - acpi_status acpi_ev_init_global_lock_handler(void) 331 - { 332 - acpi_status status; 333 - 334 - ACPI_FUNCTION_TRACE(ev_init_global_lock_handler); 335 - 336 - /* Attempt installation of the global lock handler */ 337 - 338 - status = acpi_install_fixed_event_handler(ACPI_EVENT_GLOBAL, 339 - acpi_ev_global_lock_handler, 340 - NULL); 341 - 342 - /* 343 - * If the global lock does not exist on this platform, the attempt to 344 - * enable GBL_STATUS will fail (the GBL_ENABLE bit will not stick). 345 - * Map to AE_OK, but mark global lock as not present. Any attempt to 346 - * actually use the global lock will be flagged with an error. 347 - */ 348 - if (status == AE_NO_HARDWARE_RESPONSE) { 349 - ACPI_ERROR((AE_INFO, 350 - "No response from Global Lock hardware, disabling lock")); 351 - 352 - acpi_gbl_global_lock_present = FALSE; 353 - return_ACPI_STATUS(AE_OK); 354 - } 355 - 356 - acpi_gbl_global_lock_present = TRUE; 357 - return_ACPI_STATUS(status); 358 - } 359 - 360 - /******************************************************************************* 361 - * 362 - * FUNCTION: acpi_ev_remove_global_lock_handler 363 - * 364 - * PARAMETERS: None 365 - * 366 - * RETURN: Status 367 - * 368 - * DESCRIPTION: Remove the handler for the Global Lock 369 - * 370 - ******************************************************************************/ 371 - 372 - static acpi_status acpi_ev_remove_global_lock_handler(void) 373 - { 374 - acpi_status status; 375 - 376 - ACPI_FUNCTION_TRACE(ev_remove_global_lock_handler); 377 - 378 - acpi_gbl_global_lock_present = FALSE; 379 - status = acpi_remove_fixed_event_handler(ACPI_EVENT_GLOBAL, 380 - acpi_ev_global_lock_handler); 381 - 382 - return_ACPI_STATUS(status); 383 - } 384 - 385 - /****************************************************************************** 386 - * 387 - * FUNCTION: acpi_ev_acquire_global_lock 388 - * 389 - * PARAMETERS: Timeout - Max time to wait for the lock, in millisec. 390 - * 391 - * RETURN: Status 392 - * 393 - * DESCRIPTION: Attempt to gain ownership of the Global Lock. 394 - * 395 - * MUTEX: Interpreter must be locked 396 - * 397 - * Note: The original implementation allowed multiple threads to "acquire" the 398 - * Global Lock, and the OS would hold the lock until the last thread had 399 - * released it. However, this could potentially starve the BIOS out of the 400 - * lock, especially in the case where there is a tight handshake between the 401 - * Embedded Controller driver and the BIOS. Therefore, this implementation 402 - * allows only one thread to acquire the HW Global Lock at a time, and makes 403 - * the global lock appear as a standard mutex on the OS side. 404 - * 405 - *****************************************************************************/ 406 - static acpi_thread_id acpi_ev_global_lock_thread_id; 407 - static int acpi_ev_global_lock_acquired; 408 - 409 - acpi_status acpi_ev_acquire_global_lock(u16 timeout) 410 - { 411 - acpi_cpu_flags flags; 412 - acpi_status status = AE_OK; 413 - u8 acquired = FALSE; 414 - 415 - ACPI_FUNCTION_TRACE(ev_acquire_global_lock); 416 - 417 - /* 418 - * Only one thread can acquire the GL at a time, the global_lock_mutex 419 - * enforces this. This interface releases the interpreter if we must wait. 420 - */ 421 - status = acpi_ex_system_wait_mutex( 422 - acpi_gbl_global_lock_mutex->mutex.os_mutex, 0); 423 - if (status == AE_TIME) { 424 - if (acpi_ev_global_lock_thread_id == acpi_os_get_thread_id()) { 425 - acpi_ev_global_lock_acquired++; 426 - return AE_OK; 427 - } 428 - } 429 - 430 - if (ACPI_FAILURE(status)) { 431 - status = acpi_ex_system_wait_mutex( 432 - acpi_gbl_global_lock_mutex->mutex.os_mutex, 433 - timeout); 434 - } 435 - if (ACPI_FAILURE(status)) { 436 - return_ACPI_STATUS(status); 437 - } 438 - 439 - acpi_ev_global_lock_thread_id = acpi_os_get_thread_id(); 440 - acpi_ev_global_lock_acquired++; 441 - 442 - /* 443 - * Update the global lock handle and check for wraparound. The handle is 444 - * only used for the external global lock interfaces, but it is updated 445 - * here to properly handle the case where a single thread may acquire the 446 - * lock via both the AML and the acpi_acquire_global_lock interfaces. The 447 - * handle is therefore updated on the first acquire from a given thread 448 - * regardless of where the acquisition request originated. 449 - */ 450 - acpi_gbl_global_lock_handle++; 451 - if (acpi_gbl_global_lock_handle == 0) { 452 - acpi_gbl_global_lock_handle = 1; 453 - } 454 - 455 - /* 456 - * Make sure that a global lock actually exists. If not, just treat the 457 - * lock as a standard mutex. 458 - */ 459 - if (!acpi_gbl_global_lock_present) { 460 - acpi_gbl_global_lock_acquired = TRUE; 461 - return_ACPI_STATUS(AE_OK); 462 - } 463 - 464 - flags = acpi_os_acquire_lock(acpi_ev_global_lock_pending_lock); 465 - 466 - do { 467 - 468 - /* Attempt to acquire the actual hardware lock */ 469 - 470 - ACPI_ACQUIRE_GLOBAL_LOCK(acpi_gbl_FACS, acquired); 471 - if (acquired) { 472 - acpi_gbl_global_lock_acquired = TRUE; 473 - 474 - ACPI_DEBUG_PRINT((ACPI_DB_EXEC, 475 - "Acquired hardware Global Lock\n")); 476 - break; 477 - } 478 - 479 - acpi_ev_global_lock_pending = TRUE; 480 - 481 - acpi_os_release_lock(acpi_ev_global_lock_pending_lock, flags); 482 - 483 - /* 484 - * Did not get the lock. The pending bit was set above, and we 485 - * must wait until we get the global lock released interrupt. 486 - */ 487 - ACPI_DEBUG_PRINT((ACPI_DB_EXEC, 488 - "Waiting for hardware Global Lock\n")); 489 - 490 - /* 491 - * Wait for handshake with the global lock interrupt handler. 492 - * This interface releases the interpreter if we must wait. 493 - */ 494 - status = acpi_ex_system_wait_semaphore( 495 - acpi_gbl_global_lock_semaphore, 496 - ACPI_WAIT_FOREVER); 497 - 498 - flags = acpi_os_acquire_lock(acpi_ev_global_lock_pending_lock); 499 - 500 - } while (ACPI_SUCCESS(status)); 501 - 502 - acpi_ev_global_lock_pending = FALSE; 503 - 504 - acpi_os_release_lock(acpi_ev_global_lock_pending_lock, flags); 505 - 506 - return_ACPI_STATUS(status); 507 - } 508 - 509 - /******************************************************************************* 510 - * 511 - * FUNCTION: acpi_ev_release_global_lock 512 - * 513 - * PARAMETERS: None 514 - * 515 - * RETURN: Status 516 - * 517 - * DESCRIPTION: Releases ownership of the Global Lock. 518 - * 519 - ******************************************************************************/ 520 - 521 - acpi_status acpi_ev_release_global_lock(void) 522 - { 523 - u8 pending = FALSE; 524 - acpi_status status = AE_OK; 525 - 526 - ACPI_FUNCTION_TRACE(ev_release_global_lock); 527 - 528 - /* Lock must be already acquired */ 529 - 530 - if (!acpi_gbl_global_lock_acquired) { 531 - ACPI_WARNING((AE_INFO, 532 - "Cannot release the ACPI Global Lock, it has not been acquired")); 533 - return_ACPI_STATUS(AE_NOT_ACQUIRED); 534 - } 535 - 536 - acpi_ev_global_lock_acquired--; 537 - if (acpi_ev_global_lock_acquired > 0) { 538 - return AE_OK; 539 - } 540 - 541 - if (acpi_gbl_global_lock_present) { 542 - 543 - /* Allow any thread to release the lock */ 544 - 545 - ACPI_RELEASE_GLOBAL_LOCK(acpi_gbl_FACS, pending); 546 - 547 - /* 548 - * If the pending bit was set, we must write GBL_RLS to the control 549 - * register 550 - */ 551 - if (pending) { 552 - status = 553 - acpi_write_bit_register 554 - (ACPI_BITREG_GLOBAL_LOCK_RELEASE, 555 - ACPI_ENABLE_EVENT); 556 - } 557 - 558 - ACPI_DEBUG_PRINT((ACPI_DB_EXEC, 559 - "Released hardware Global Lock\n")); 560 - } 561 - 562 - acpi_gbl_global_lock_acquired = FALSE; 563 - 564 - /* Release the local GL mutex */ 565 - acpi_ev_global_lock_thread_id = 0; 566 - acpi_ev_global_lock_acquired = 0; 567 - acpi_os_release_mutex(acpi_gbl_global_lock_mutex->mutex.os_mutex); 568 - return_ACPI_STATUS(status); 569 276 } 570 277 571 278 /******************************************************************************
+119 -2
drivers/acpi/acpica/evregion.c
··· 55 55 acpi_ev_has_default_handler(struct acpi_namespace_node *node, 56 56 acpi_adr_space_type space_id); 57 57 58 + static void acpi_ev_orphan_ec_reg_method(void); 59 + 58 60 static acpi_status 59 61 acpi_ev_reg_run(acpi_handle obj_handle, 60 62 u32 level, void *context, void **return_value); ··· 563 561 564 562 /* Now stop region accesses by executing the _REG method */ 565 563 566 - status = acpi_ev_execute_reg_method(region_obj, 0); 564 + status = 565 + acpi_ev_execute_reg_method(region_obj, 566 + ACPI_REG_DISCONNECT); 567 567 if (ACPI_FAILURE(status)) { 568 568 ACPI_EXCEPTION((AE_INFO, status, 569 569 "from region _REG, [%s]", ··· 1066 1062 ACPI_NS_WALK_UNLOCK, acpi_ev_reg_run, 1067 1063 NULL, &space_id, NULL); 1068 1064 1065 + /* Special case for EC: handle "orphan" _REG methods with no region */ 1066 + 1067 + if (space_id == ACPI_ADR_SPACE_EC) { 1068 + acpi_ev_orphan_ec_reg_method(); 1069 + } 1070 + 1069 1071 return_ACPI_STATUS(status); 1070 1072 } 1071 1073 ··· 1130 1120 return (AE_OK); 1131 1121 } 1132 1122 1133 - status = acpi_ev_execute_reg_method(obj_desc, 1); 1123 + status = acpi_ev_execute_reg_method(obj_desc, ACPI_REG_CONNECT); 1134 1124 return (status); 1125 + } 1126 + 1127 + /******************************************************************************* 1128 + * 1129 + * FUNCTION: acpi_ev_orphan_ec_reg_method 1130 + * 1131 + * PARAMETERS: None 1132 + * 1133 + * RETURN: None 1134 + * 1135 + * DESCRIPTION: Execute an "orphan" _REG method that appears under the EC 1136 + * device. This is a _REG method that has no corresponding region 1137 + * within the EC device scope. The orphan _REG method appears to 1138 + * have been enabled by the description of the ECDT in the ACPI 1139 + * specification: "The availability of the region space can be 1140 + * detected by providing a _REG method object underneath the 1141 + * Embedded Controller device." 1142 + * 1143 + * To quickly access the EC device, we use the EC_ID that appears 1144 + * within the ECDT. Otherwise, we would need to perform a time- 1145 + * consuming namespace walk, executing _HID methods to find the 1146 + * EC device. 1147 + * 1148 + ******************************************************************************/ 1149 + 1150 + static void acpi_ev_orphan_ec_reg_method(void) 1151 + { 1152 + struct acpi_table_ecdt *table; 1153 + acpi_status status; 1154 + struct acpi_object_list args; 1155 + union acpi_object objects[2]; 1156 + struct acpi_namespace_node *ec_device_node; 1157 + struct acpi_namespace_node *reg_method; 1158 + struct acpi_namespace_node *next_node; 1159 + 1160 + ACPI_FUNCTION_TRACE(ev_orphan_ec_reg_method); 1161 + 1162 + /* Get the ECDT (if present in system) */ 1163 + 1164 + status = acpi_get_table(ACPI_SIG_ECDT, 0, 1165 + ACPI_CAST_INDIRECT_PTR(struct acpi_table_header, 1166 + &table)); 1167 + if (ACPI_FAILURE(status)) { 1168 + return_VOID; 1169 + } 1170 + 1171 + /* We need a valid EC_ID string */ 1172 + 1173 + if (!(*table->id)) { 1174 + return_VOID; 1175 + } 1176 + 1177 + /* Namespace is currently locked, must release */ 1178 + 1179 + (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); 1180 + 1181 + /* Get a handle to the EC device referenced in the ECDT */ 1182 + 1183 + status = acpi_get_handle(NULL, 1184 + ACPI_CAST_PTR(char, table->id), 1185 + ACPI_CAST_PTR(acpi_handle, &ec_device_node)); 1186 + if (ACPI_FAILURE(status)) { 1187 + goto exit; 1188 + } 1189 + 1190 + /* Get a handle to a _REG method immediately under the EC device */ 1191 + 1192 + status = acpi_get_handle(ec_device_node, 1193 + METHOD_NAME__REG, ACPI_CAST_PTR(acpi_handle, 1194 + &reg_method)); 1195 + if (ACPI_FAILURE(status)) { 1196 + goto exit; 1197 + } 1198 + 1199 + /* 1200 + * Execute the _REG method only if there is no Operation Region in 1201 + * this scope with the Embedded Controller space ID. Otherwise, it 1202 + * will already have been executed. Note, this allows for Regions 1203 + * with other space IDs to be present; but the code below will then 1204 + * execute the _REG method with the EC space ID argument. 1205 + */ 1206 + next_node = acpi_ns_get_next_node(ec_device_node, NULL); 1207 + while (next_node) { 1208 + if ((next_node->type == ACPI_TYPE_REGION) && 1209 + (next_node->object) && 1210 + (next_node->object->region.space_id == ACPI_ADR_SPACE_EC)) { 1211 + goto exit; /* Do not execute _REG */ 1212 + } 1213 + next_node = acpi_ns_get_next_node(ec_device_node, next_node); 1214 + } 1215 + 1216 + /* Evaluate the _REG(EC,Connect) method */ 1217 + 1218 + args.count = 2; 1219 + args.pointer = objects; 1220 + objects[0].type = ACPI_TYPE_INTEGER; 1221 + objects[0].integer.value = ACPI_ADR_SPACE_EC; 1222 + objects[1].type = ACPI_TYPE_INTEGER; 1223 + objects[1].integer.value = ACPI_REG_CONNECT; 1224 + 1225 + status = acpi_evaluate_object(reg_method, NULL, &args, NULL); 1226 + 1227 + exit: 1228 + /* We ignore all errors from above, don't care */ 1229 + 1230 + status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE); 1231 + return_VOID; 1135 1232 }
+1 -1
drivers/acpi/acpica/evrgnini.c
··· 637 637 638 638 status = 639 639 acpi_ev_execute_reg_method 640 - (region_obj, 1); 640 + (region_obj, ACPI_REG_CONNECT); 641 641 642 642 if (acpi_ns_locked) { 643 643 status =
+7 -6
drivers/acpi/acpica/evxfregn.c
··· 130 130 case ACPI_ADR_SPACE_PCI_CONFIG: 131 131 case ACPI_ADR_SPACE_DATA_TABLE: 132 132 133 - if (acpi_gbl_reg_methods_executed) { 133 + if (!acpi_gbl_reg_methods_executed) { 134 134 135 - /* Run all _REG methods for this address space */ 136 - 137 - status = acpi_ev_execute_reg_methods(node, space_id); 135 + /* We will defer execution of the _REG methods for this space */ 136 + goto unlock_and_exit; 138 137 } 139 138 break; 140 139 141 140 default: 142 - 143 - status = acpi_ev_execute_reg_methods(node, space_id); 144 141 break; 145 142 } 143 + 144 + /* Run all _REG methods for this address space */ 145 + 146 + status = acpi_ev_execute_reg_methods(node, space_id); 146 147 147 148 unlock_and_exit: 148 149 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
+2 -1
drivers/acpi/acpica/excreate.c
··· 305 305 * range 306 306 */ 307 307 if ((region_space >= ACPI_NUM_PREDEFINED_REGIONS) && 308 - (region_space < ACPI_USER_REGION_BEGIN)) { 308 + (region_space < ACPI_USER_REGION_BEGIN) && 309 + (region_space != ACPI_ADR_SPACE_DATA_TABLE)) { 309 310 ACPI_ERROR((AE_INFO, "Invalid AddressSpace type 0x%X", 310 311 region_space)); 311 312 return_ACPI_STATUS(AE_AML_INVALID_SPACE_ID);
+5 -8
drivers/acpi/acpica/nsrepair.c
··· 74 74 * 75 75 * Additional possible repairs: 76 76 * 77 - * Optional/unnecessary NULL package elements removed 78 77 * Required package elements that are NULL replaced by Integer/String/Buffer 79 78 * Incorrect standalone package wrapped with required outer package 80 79 * ··· 622 623 ACPI_FUNCTION_NAME(ns_remove_null_elements); 623 624 624 625 /* 625 - * PTYPE1 packages contain no subpackages. 626 - * PTYPE2 packages contain a variable number of sub-packages. We can 627 - * safely remove all NULL elements from the PTYPE2 packages. 626 + * We can safely remove all NULL elements from these package types: 627 + * PTYPE1_VAR packages contain a variable number of simple data types. 628 + * PTYPE2 packages contain a variable number of sub-packages. 628 629 */ 629 630 switch (package_type) { 630 - case ACPI_PTYPE1_FIXED: 631 631 case ACPI_PTYPE1_VAR: 632 - case ACPI_PTYPE1_OPTION: 633 - return; 634 - 635 632 case ACPI_PTYPE2: 636 633 case ACPI_PTYPE2_COUNT: 637 634 case ACPI_PTYPE2_PKG_COUNT: ··· 637 642 break; 638 643 639 644 default: 645 + case ACPI_PTYPE1_FIXED: 646 + case ACPI_PTYPE1_OPTION: 640 647 return; 641 648 } 642 649
+3 -2
drivers/acpi/acpica/utdecode.c
··· 170 170 "SMBus", 171 171 "SystemCMOS", 172 172 "PCIBARTarget", 173 - "IPMI", 174 - "DataTable" 173 + "IPMI" 175 174 }; 176 175 177 176 char *acpi_ut_get_region_name(u8 space_id) ··· 178 179 179 180 if (space_id >= ACPI_USER_REGION_BEGIN) { 180 181 return ("UserDefinedRegion"); 182 + } else if (space_id == ACPI_ADR_SPACE_DATA_TABLE) { 183 + return ("DataTable"); 181 184 } else if (space_id == ACPI_ADR_SPACE_FIXED_HARDWARE) { 182 185 return ("FunctionalFixedHW"); 183 186 } else if (space_id >= ACPI_NUM_PREDEFINED_REGIONS) {
+9 -3
drivers/acpi/acpica/utmutex.c
··· 83 83 84 84 /* Create the spinlocks for use at interrupt level */ 85 85 86 - spin_lock_init(acpi_gbl_gpe_lock); 87 - spin_lock_init(acpi_gbl_hardware_lock); 88 - spin_lock_init(acpi_ev_global_lock_pending_lock); 86 + status = acpi_os_create_lock (&acpi_gbl_gpe_lock); 87 + if (ACPI_FAILURE (status)) { 88 + return_ACPI_STATUS (status); 89 + } 90 + 91 + status = acpi_os_create_lock (&acpi_gbl_hardware_lock); 92 + if (ACPI_FAILURE (status)) { 93 + return_ACPI_STATUS (status); 94 + } 89 95 90 96 /* Mutex for _OSI support */ 91 97 status = acpi_os_create_mutex(&acpi_gbl_osi_mutex);
+1 -1
drivers/acpi/bus.c
··· 227 227 acpi_status status = AE_OK; 228 228 char object_name[5] = { '_', 'P', 'S', '0' + state, '\0' }; 229 229 230 - if (!device || (state < ACPI_STATE_D0) || (state > ACPI_STATE_D3)) 230 + if (!device || (state < ACPI_STATE_D0) || (state > ACPI_STATE_D3_COLD)) 231 231 return -EINVAL; 232 232 233 233 /* Make sure this is a valid target state */
+100
drivers/acpi/custom_method.c
··· 1 + /* 2 + * debugfs.c - ACPI debugfs interface to userspace. 3 + */ 4 + 5 + #include <linux/init.h> 6 + #include <linux/module.h> 7 + #include <linux/kernel.h> 8 + #include <linux/uaccess.h> 9 + #include <linux/debugfs.h> 10 + #include <acpi/acpi_drivers.h> 11 + 12 + #include "internal.h" 13 + 14 + #define _COMPONENT ACPI_SYSTEM_COMPONENT 15 + ACPI_MODULE_NAME("custom_method"); 16 + MODULE_LICENSE("GPL"); 17 + 18 + static struct dentry *cm_dentry; 19 + 20 + /* /sys/kernel/debug/acpi/custom_method */ 21 + 22 + static ssize_t cm_write(struct file *file, const char __user * user_buf, 23 + size_t count, loff_t *ppos) 24 + { 25 + static char *buf; 26 + static u32 max_size; 27 + static u32 uncopied_bytes; 28 + 29 + struct acpi_table_header table; 30 + acpi_status status; 31 + 32 + if (!(*ppos)) { 33 + /* parse the table header to get the table length */ 34 + if (count <= sizeof(struct acpi_table_header)) 35 + return -EINVAL; 36 + if (copy_from_user(&table, user_buf, 37 + sizeof(struct acpi_table_header))) 38 + return -EFAULT; 39 + uncopied_bytes = max_size = table.length; 40 + buf = kzalloc(max_size, GFP_KERNEL); 41 + if (!buf) 42 + return -ENOMEM; 43 + } 44 + 45 + if (buf == NULL) 46 + return -EINVAL; 47 + 48 + if ((*ppos > max_size) || 49 + (*ppos + count > max_size) || 50 + (*ppos + count < count) || 51 + (count > uncopied_bytes)) 52 + return -EINVAL; 53 + 54 + if (copy_from_user(buf + (*ppos), user_buf, count)) { 55 + kfree(buf); 56 + buf = NULL; 57 + return -EFAULT; 58 + } 59 + 60 + uncopied_bytes -= count; 61 + *ppos += count; 62 + 63 + if (!uncopied_bytes) { 64 + status = acpi_install_method(buf); 65 + kfree(buf); 66 + buf = NULL; 67 + if (ACPI_FAILURE(status)) 68 + return -EINVAL; 69 + add_taint(TAINT_OVERRIDDEN_ACPI_TABLE); 70 + } 71 + 72 + return count; 73 + } 74 + 75 + static const struct file_operations cm_fops = { 76 + .write = cm_write, 77 + .llseek = default_llseek, 78 + }; 79 + 80 + static int __init acpi_custom_method_init(void) 81 + { 82 + if (acpi_debugfs_dir == NULL) 83 + return -ENOENT; 84 + 85 + cm_dentry = debugfs_create_file("custom_method", S_IWUSR, 86 + acpi_debugfs_dir, NULL, &cm_fops); 87 + if (cm_dentry == NULL) 88 + return -ENODEV; 89 + 90 + return 0; 91 + } 92 + 93 + static void __exit acpi_custom_method_exit(void) 94 + { 95 + if (cm_dentry) 96 + debugfs_remove(cm_dentry); 97 + } 98 + 99 + module_init(acpi_custom_method_init); 100 + module_exit(acpi_custom_method_exit);
+4 -88
drivers/acpi/debugfs.c
··· 3 3 */ 4 4 5 5 #include <linux/init.h> 6 - #include <linux/module.h> 7 - #include <linux/kernel.h> 8 - #include <linux/uaccess.h> 9 6 #include <linux/debugfs.h> 10 7 #include <acpi/acpi_drivers.h> 11 8 12 9 #define _COMPONENT ACPI_SYSTEM_COMPONENT 13 10 ACPI_MODULE_NAME("debugfs"); 14 11 12 + struct dentry *acpi_debugfs_dir; 13 + EXPORT_SYMBOL_GPL(acpi_debugfs_dir); 15 14 16 - /* /sys/modules/acpi/parameters/aml_debug_output */ 17 - 18 - module_param_named(aml_debug_output, acpi_gbl_enable_aml_debug_object, 19 - bool, 0644); 20 - MODULE_PARM_DESC(aml_debug_output, 21 - "To enable/disable the ACPI Debug Object output."); 22 - 23 - /* /sys/kernel/debug/acpi/custom_method */ 24 - 25 - static ssize_t cm_write(struct file *file, const char __user * user_buf, 26 - size_t count, loff_t *ppos) 15 + void __init acpi_debugfs_init(void) 27 16 { 28 - static char *buf; 29 - static u32 max_size; 30 - static u32 uncopied_bytes; 31 - 32 - struct acpi_table_header table; 33 - acpi_status status; 34 - 35 - if (!(*ppos)) { 36 - /* parse the table header to get the table length */ 37 - if (count <= sizeof(struct acpi_table_header)) 38 - return -EINVAL; 39 - if (copy_from_user(&table, user_buf, 40 - sizeof(struct acpi_table_header))) 41 - return -EFAULT; 42 - uncopied_bytes = max_size = table.length; 43 - buf = kzalloc(max_size, GFP_KERNEL); 44 - if (!buf) 45 - return -ENOMEM; 46 - } 47 - 48 - if (buf == NULL) 49 - return -EINVAL; 50 - 51 - if ((*ppos > max_size) || 52 - (*ppos + count > max_size) || 53 - (*ppos + count < count) || 54 - (count > uncopied_bytes)) 55 - return -EINVAL; 56 - 57 - if (copy_from_user(buf + (*ppos), user_buf, count)) { 58 - kfree(buf); 59 - buf = NULL; 60 - return -EFAULT; 61 - } 62 - 63 - uncopied_bytes -= count; 64 - *ppos += count; 65 - 66 - if (!uncopied_bytes) { 67 - status = acpi_install_method(buf); 68 - kfree(buf); 69 - buf = NULL; 70 - if (ACPI_FAILURE(status)) 71 - return -EINVAL; 72 - add_taint(TAINT_OVERRIDDEN_ACPI_TABLE); 73 - } 74 - 75 - return count; 76 - } 77 - 78 - static const struct file_operations cm_fops = { 79 - .write = cm_write, 80 - .llseek = default_llseek, 81 - }; 82 - 83 - int __init acpi_debugfs_init(void) 84 - { 85 - struct dentry *acpi_dir, *cm_dentry; 86 - 87 - acpi_dir = debugfs_create_dir("acpi", NULL); 88 - if (!acpi_dir) 89 - goto err; 90 - 91 - cm_dentry = debugfs_create_file("custom_method", S_IWUSR, 92 - acpi_dir, NULL, &cm_fops); 93 - if (!cm_dentry) 94 - goto err; 95 - 96 - return 0; 97 - 98 - err: 99 - if (acpi_dir) 100 - debugfs_remove(acpi_dir); 101 - return -EINVAL; 17 + acpi_debugfs_dir = debugfs_create_dir("acpi", NULL); 102 18 }
+12 -7
drivers/acpi/ec.c
··· 69 69 70 70 #define ACPI_EC_DELAY 500 /* Wait 500ms max. during EC ops */ 71 71 #define ACPI_EC_UDELAY_GLK 1000 /* Wait 1ms max. to get global lock */ 72 - #define ACPI_EC_CDELAY 10 /* Wait 10us before polling EC */ 73 72 #define ACPI_EC_MSI_UDELAY 550 /* Wait 550us for MSI EC */ 74 73 75 74 #define ACPI_EC_STORM_THRESHOLD 8 /* number of false interrupts ··· 432 433 433 434 int ec_transaction(u8 command, 434 435 const u8 * wdata, unsigned wdata_len, 435 - u8 * rdata, unsigned rdata_len, 436 - int force_poll) 436 + u8 * rdata, unsigned rdata_len) 437 437 { 438 438 struct transaction t = {.command = command, 439 439 .wdata = wdata, .rdata = rdata, ··· 589 591 acpi_ec_sync_query(ec); 590 592 mutex_unlock(&ec->lock); 591 593 } 592 - 593 - static void acpi_ec_gpe_query(void *ec_cxt); 594 594 595 595 static int ec_check_sci(struct acpi_ec *ec, u8 state) 596 596 { ··· 804 808 return -EINVAL; 805 809 } 806 810 807 - ec->handle = device->handle; 808 - 809 811 /* Find and register all query methods */ 810 812 acpi_walk_namespace(ACPI_TYPE_METHOD, ec->handle, 1, 811 813 acpi_ec_register_query_methods, NULL, ec, NULL); ··· 932 938 ec_flag_msi, "MSI hardware", { 933 939 DMI_MATCH(DMI_CHASSIS_VENDOR, "MICRO-STAR")}, NULL}, 934 940 { 941 + ec_flag_msi, "Quanta hardware", { 942 + DMI_MATCH(DMI_SYS_VENDOR, "Quanta"), 943 + DMI_MATCH(DMI_PRODUCT_NAME, "TW8/SW8/DW8"),}, NULL}, 944 + { 945 + ec_flag_msi, "Quanta hardware", { 946 + DMI_MATCH(DMI_SYS_VENDOR, "Quanta"), 947 + DMI_MATCH(DMI_PRODUCT_NAME, "TW9/SW9"),}, NULL}, 948 + { 935 949 ec_validate_ecdt, "ASUS hardware", { 936 950 DMI_MATCH(DMI_BIOS_VENDOR, "ASUS") }, NULL}, 951 + { 952 + ec_validate_ecdt, "ASUS hardware", { 953 + DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer Inc.") }, NULL}, 937 954 {}, 938 955 }; 939 956
+2 -1
drivers/acpi/internal.h
··· 28 28 int acpi_sysfs_init(void); 29 29 30 30 #ifdef CONFIG_DEBUG_FS 31 + extern struct dentry *acpi_debugfs_dir; 31 32 int acpi_debugfs_init(void); 32 33 #else 33 - static inline int acpi_debugfs_init(void) { return 0; } 34 + static inline void acpi_debugfs_init(void) { return; } 34 35 #endif 35 36 36 37 /* --------------------------------------------------------------------------
+25 -8
drivers/acpi/osl.c
··· 902 902 903 903 EXPORT_SYMBOL(acpi_os_wait_events_complete); 904 904 905 - /* 906 - * Deallocate the memory for a spinlock. 907 - */ 908 - void acpi_os_delete_lock(acpi_spinlock handle) 909 - { 910 - return; 911 - } 912 - 913 905 acpi_status 914 906 acpi_os_create_semaphore(u32 max_units, u32 initial_units, acpi_handle * handle) 915 907 { ··· 1331 1339 return acpi_enforce_resources == ENFORCE_RESOURCES_STRICT; 1332 1340 } 1333 1341 EXPORT_SYMBOL(acpi_resources_are_enforced); 1342 + 1343 + /* 1344 + * Create and initialize a spinlock. 1345 + */ 1346 + acpi_status 1347 + acpi_os_create_lock(acpi_spinlock *out_handle) 1348 + { 1349 + spinlock_t *lock; 1350 + 1351 + lock = ACPI_ALLOCATE(sizeof(spinlock_t)); 1352 + if (!lock) 1353 + return AE_NO_MEMORY; 1354 + spin_lock_init(lock); 1355 + *out_handle = lock; 1356 + 1357 + return AE_OK; 1358 + } 1359 + 1360 + /* 1361 + * Deallocate the memory for a spinlock. 1362 + */ 1363 + void acpi_os_delete_lock(acpi_spinlock handle) 1364 + { 1365 + ACPI_FREE(handle); 1366 + } 1334 1367 1335 1368 /* 1336 1369 * Acquire a spinlock.
+9 -3
drivers/acpi/processor_core.c
··· 37 37 {}, 38 38 }; 39 39 40 - #ifdef CONFIG_SMP 41 40 static int map_lapic_id(struct acpi_subtable_header *entry, 42 41 u32 acpi_id, int *apic_id) 43 42 { ··· 164 165 165 166 int acpi_get_cpuid(acpi_handle handle, int type, u32 acpi_id) 166 167 { 168 + #ifdef CONFIG_SMP 167 169 int i; 170 + #endif 168 171 int apic_id = -1; 169 172 170 173 apic_id = map_mat_entry(handle, type, acpi_id); ··· 175 174 if (apic_id == -1) 176 175 return apic_id; 177 176 177 + #ifdef CONFIG_SMP 178 178 for_each_possible_cpu(i) { 179 179 if (cpu_physical_id(i) == apic_id) 180 180 return i; 181 181 } 182 + #else 183 + /* In UP kernel, only processor 0 is valid */ 184 + if (apic_id == 0) 185 + return apic_id; 186 + #endif 182 187 return -1; 183 188 } 184 189 EXPORT_SYMBOL_GPL(acpi_get_cpuid); 185 - #endif 186 190 187 191 static bool __init processor_physically_present(acpi_handle handle) 188 192 { ··· 223 217 type = (acpi_type == ACPI_TYPE_DEVICE) ? 1 : 0; 224 218 cpuid = acpi_get_cpuid(handle, type, acpi_id); 225 219 226 - if ((cpuid == -1) && (num_possible_cpus() > 1)) 220 + if (cpuid == -1) 227 221 return false; 228 222 229 223 return true;
+8
drivers/acpi/sysfs.c
··· 220 220 NULL, 0644); 221 221 #endif /* CONFIG_ACPI_DEBUG */ 222 222 223 + 224 + /* /sys/modules/acpi/parameters/aml_debug_output */ 225 + 226 + module_param_named(aml_debug_output, acpi_gbl_enable_aml_debug_object, 227 + bool, 0644); 228 + MODULE_PARM_DESC(aml_debug_output, 229 + "To enable/disable the ACPI Debug Object output."); 230 + 223 231 /* /sys/module/acpi/parameters/acpica_version */ 224 232 static int param_get_acpica_version(char *buffer, struct kernel_param *kp) 225 233 {
+2
drivers/pci/pci-acpi.c
··· 195 195 return PCI_D2; 196 196 case ACPI_STATE_D3: 197 197 return PCI_D3hot; 198 + case ACPI_STATE_D3_COLD: 199 + return PCI_D3cold; 198 200 } 199 201 return PCI_POWER_ERROR; 200 202 }
+7 -7
drivers/platform/x86/compal-laptop.c
··· 200 200 * watching the output of address 0x4F (do an ec_transaction writing 0x33 201 201 * into 0x4F and read a few bytes from the output, like so: 202 202 * u8 writeData = 0x33; 203 - * ec_transaction(0x4F, &writeData, 1, buffer, 32, 0); 204 - * That address is labelled "fan1 table information" in the service manual. 203 + * ec_transaction(0x4F, &writeData, 1, buffer, 32); 204 + * That address is labeled "fan1 table information" in the service manual. 205 205 * It should be clear which value in 'buffer' changes). This seems to be 206 206 * related to fan speed. It isn't a proper 'realtime' fan speed value 207 207 * though, because physically stopping or speeding up the fan doesn't ··· 286 286 static void set_backlight_state(bool on) 287 287 { 288 288 u8 data = on ? BACKLIGHT_STATE_ON_DATA : BACKLIGHT_STATE_OFF_DATA; 289 - ec_transaction(BACKLIGHT_STATE_ADDR, &data, 1, NULL, 0, 0); 289 + ec_transaction(BACKLIGHT_STATE_ADDR, &data, 1, NULL, 0); 290 290 } 291 291 292 292 ··· 294 294 static void pwm_enable_control(void) 295 295 { 296 296 unsigned char writeData = PWM_ENABLE_DATA; 297 - ec_transaction(PWM_ENABLE_ADDR, &writeData, 1, NULL, 0, 0); 297 + ec_transaction(PWM_ENABLE_ADDR, &writeData, 1, NULL, 0); 298 298 } 299 299 300 300 static void pwm_disable_control(void) 301 301 { 302 302 unsigned char writeData = PWM_DISABLE_DATA; 303 - ec_transaction(PWM_DISABLE_ADDR, &writeData, 1, NULL, 0, 0); 303 + ec_transaction(PWM_DISABLE_ADDR, &writeData, 1, NULL, 0); 304 304 } 305 305 306 306 static void set_pwm(int pwm) 307 307 { 308 - ec_transaction(PWM_ADDRESS, &pwm_lookup_table[pwm], 1, NULL, 0, 0); 308 + ec_transaction(PWM_ADDRESS, &pwm_lookup_table[pwm], 1, NULL, 0); 309 309 } 310 310 311 311 static int get_fan_rpm(void) 312 312 { 313 313 u8 value, data = FAN_DATA; 314 - ec_transaction(FAN_ADDRESS, &data, 1, &value, 1, 0); 314 + ec_transaction(FAN_ADDRESS, &data, 1, &value, 1); 315 315 return 100 * (int)value; 316 316 } 317 317
+6 -6
drivers/platform/x86/msi-laptop.c
··· 135 135 buf[1] = (u8) (level*31); 136 136 137 137 return ec_transaction(MSI_EC_COMMAND_LCD_LEVEL, buf, sizeof(buf), 138 - NULL, 0, 1); 138 + NULL, 0); 139 139 } 140 140 141 141 static int get_lcd_level(void) ··· 144 144 int result; 145 145 146 146 result = ec_transaction(MSI_EC_COMMAND_LCD_LEVEL, &wdata, 1, 147 - &rdata, 1, 1); 147 + &rdata, 1); 148 148 if (result < 0) 149 149 return result; 150 150 ··· 157 157 int result; 158 158 159 159 result = ec_transaction(MSI_EC_COMMAND_LCD_LEVEL, &wdata, 1, 160 - &rdata, 1, 1); 160 + &rdata, 1); 161 161 if (result < 0) 162 162 return result; 163 163 ··· 172 172 wdata[0] = 4; 173 173 174 174 result = ec_transaction(MSI_EC_COMMAND_LCD_LEVEL, wdata, 1, 175 - &rdata, 1, 1); 175 + &rdata, 1); 176 176 if (result < 0) 177 177 return result; 178 178 ··· 180 180 wdata[1] = (rdata & 0xF7) | (enable ? 8 : 0); 181 181 182 182 return ec_transaction(MSI_EC_COMMAND_LCD_LEVEL, wdata, 2, 183 - NULL, 0, 1); 183 + NULL, 0); 184 184 } 185 185 186 186 static ssize_t set_device_state(const char *buf, size_t count, u8 mask) ··· 217 217 u8 wdata = 0, rdata; 218 218 int result; 219 219 220 - result = ec_transaction(MSI_EC_COMMAND_WIRELESS, &wdata, 1, &rdata, 1, 1); 220 + result = ec_transaction(MSI_EC_COMMAND_WIRELESS, &wdata, 1, &rdata, 1); 221 221 if (result < 0) 222 222 return -1; 223 223
+5 -5
drivers/thermal/thermal_sys.c
··· 499 499 dev_set_drvdata(hwmon->device, hwmon); 500 500 result = device_create_file(hwmon->device, &dev_attr_name); 501 501 if (result) 502 - goto unregister_hwmon_device; 502 + goto free_mem; 503 503 504 504 register_sys_interface: 505 505 tz->hwmon = hwmon; ··· 513 513 sysfs_attr_init(&tz->temp_input.attr.attr); 514 514 result = device_create_file(hwmon->device, &tz->temp_input.attr); 515 515 if (result) 516 - goto unregister_hwmon_device; 516 + goto unregister_name; 517 517 518 518 if (tz->ops->get_crit_temp) { 519 519 unsigned long temperature; ··· 527 527 result = device_create_file(hwmon->device, 528 528 &tz->temp_crit.attr); 529 529 if (result) 530 - goto unregister_hwmon_device; 530 + goto unregister_input; 531 531 } 532 532 } 533 533 ··· 539 539 540 540 return 0; 541 541 542 - unregister_hwmon_device: 543 - device_remove_file(hwmon->device, &tz->temp_crit.attr); 542 + unregister_input: 544 543 device_remove_file(hwmon->device, &tz->temp_input.attr); 544 + unregister_name: 545 545 if (new_hwmon_device) { 546 546 device_remove_file(hwmon->device, &dev_attr_name); 547 547 hwmon_device_unregister(hwmon->device);
+3
include/acpi/acpiosxf.h
··· 98 98 /* 99 99 * Spinlock primitives 100 100 */ 101 + acpi_status 102 + acpi_os_create_lock(acpi_spinlock *out_handle); 103 + 101 104 void acpi_os_delete_lock(acpi_spinlock handle); 102 105 103 106 acpi_cpu_flags acpi_os_acquire_lock(acpi_spinlock handle);
+1 -1
include/acpi/acpixf.h
··· 47 47 48 48 /* Current ACPICA subsystem version in YYYYMMDD format */ 49 49 50 - #define ACPI_CA_VERSION 0x20110316 50 + #define ACPI_CA_VERSION 0x20110413 51 51 52 52 #include "actypes.h" 53 53 #include "actbl.h"
+21 -4
include/acpi/actypes.h
··· 501 501 #define ACPI_STATE_D1 (u8) 1 502 502 #define ACPI_STATE_D2 (u8) 2 503 503 #define ACPI_STATE_D3 (u8) 3 504 - #define ACPI_D_STATES_MAX ACPI_STATE_D3 505 - #define ACPI_D_STATE_COUNT 4 504 + #define ACPI_STATE_D3_COLD (u8) 4 505 + #define ACPI_D_STATES_MAX ACPI_STATE_D3_COLD 506 + #define ACPI_D_STATE_COUNT 5 506 507 507 508 #define ACPI_STATE_C0 (u8) 0 508 509 #define ACPI_STATE_C1 (u8) 1 ··· 713 712 #define ACPI_ADR_SPACE_CMOS (acpi_adr_space_type) 5 714 713 #define ACPI_ADR_SPACE_PCI_BAR_TARGET (acpi_adr_space_type) 6 715 714 #define ACPI_ADR_SPACE_IPMI (acpi_adr_space_type) 7 716 - #define ACPI_ADR_SPACE_DATA_TABLE (acpi_adr_space_type) 8 717 - #define ACPI_ADR_SPACE_FIXED_HARDWARE (acpi_adr_space_type) 127 715 + 716 + #define ACPI_NUM_PREDEFINED_REGIONS 8 717 + 718 + /* 719 + * Special Address Spaces 720 + * 721 + * Note: A Data Table region is a special type of operation region 722 + * that has its own AML opcode. However, internally, the AML 723 + * interpreter simply creates an operation region with an an address 724 + * space type of ACPI_ADR_SPACE_DATA_TABLE. 725 + */ 726 + #define ACPI_ADR_SPACE_DATA_TABLE (acpi_adr_space_type) 0x7E /* Internal to ACPICA only */ 727 + #define ACPI_ADR_SPACE_FIXED_HARDWARE (acpi_adr_space_type) 0x7F 728 + 729 + /* Values for _REG connection code */ 730 + 731 + #define ACPI_REG_DISCONNECT 0 732 + #define ACPI_REG_CONNECT 1 718 733 719 734 /* 720 735 * bit_register IDs
-7
include/acpi/processor.h
··· 310 310 311 311 /* in processor_core.c */ 312 312 void acpi_processor_set_pdc(acpi_handle handle); 313 - #ifdef CONFIG_SMP 314 313 int acpi_get_cpuid(acpi_handle, int type, u32 acpi_id); 315 - #else 316 - static inline int acpi_get_cpuid(acpi_handle handle, int type, u32 acpi_id) 317 - { 318 - return -1; 319 - } 320 - #endif 321 314 322 315 /* in processor_throttling.c */ 323 316 int acpi_processor_tstate_has_changed(struct acpi_processor *pr);
+1 -2
include/linux/acpi.h
··· 150 150 extern int ec_write(u8 addr, u8 val); 151 151 extern int ec_transaction(u8 command, 152 152 const u8 *wdata, unsigned wdata_len, 153 - u8 *rdata, unsigned rdata_len, 154 - int force_poll); 153 + u8 *rdata, unsigned rdata_len); 155 154 156 155 #if defined(CONFIG_ACPI_WMI) || defined(CONFIG_ACPI_WMI_MODULE) 157 156