aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/acpi/Kconfig15
-rw-r--r--drivers/acpi/Makefile1
-rw-r--r--drivers/acpi/acpica/Makefile2
-rw-r--r--drivers/acpi/acpica/acconfig.h1
-rw-r--r--drivers/acpi/acpica/acevents.h17
-rw-r--r--drivers/acpi/acpica/acglobal.h13
-rw-r--r--drivers/acpi/acpica/amlcode.h15
-rw-r--r--drivers/acpi/acpica/dswload.c2
-rw-r--r--drivers/acpi/acpica/dswload2.c2
-rw-r--r--drivers/acpi/acpica/evglock.c335
-rw-r--r--drivers/acpi/acpica/evmisc.c303
-rw-r--r--drivers/acpi/acpica/evregion.c121
-rw-r--r--drivers/acpi/acpica/evrgnini.c2
-rw-r--r--drivers/acpi/acpica/evxfregn.c13
-rw-r--r--drivers/acpi/acpica/excreate.c3
-rw-r--r--drivers/acpi/acpica/nsrepair.c13
-rw-r--r--drivers/acpi/acpica/utdecode.c5
-rw-r--r--drivers/acpi/acpica/utmutex.c12
-rw-r--r--drivers/acpi/bus.c2
-rw-r--r--drivers/acpi/custom_method.c100
-rw-r--r--drivers/acpi/debugfs.c92
-rw-r--r--drivers/acpi/ec.c11
-rw-r--r--drivers/acpi/internal.h3
-rw-r--r--drivers/acpi/osl.c33
-rw-r--r--drivers/acpi/sysfs.c8
-rw-r--r--drivers/pci/pci-acpi.c2
-rw-r--r--drivers/thermal/thermal_sys.c10
27 files changed, 675 insertions, 461 deletions
diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig
index 3a17ca5fff6f..d918e130bef3 100644
--- a/drivers/acpi/Kconfig
+++ b/drivers/acpi/Kconfig
@@ -380,6 +380,21 @@ config ACPI_HED
380 which is used to report some hardware errors notified via 380 which is used to report some hardware errors notified via
381 SCI, mainly the corrected errors. 381 SCI, mainly the corrected errors.
382 382
383config ACPI_CUSTOM_METHOD
384 tristate "Allow ACPI methods to be inserted/replaced at run time"
385 depends on DEBUG_FS
386 default n
387 help
388 This debug facility allows ACPI AML methods to me inserted and/or
389 replaced without rebooting the system. For details refer to:
390 Documentation/acpi/method-customizing.txt.
391
392 NOTE: This option is security sensitive, because it allows arbitrary
393 kernel memory to be written to by root (uid=0) users, allowing them
394 to bypass certain security measures (e.g. if root is not allowed to
395 load additional kernel modules after boot, this feature may be used
396 to override that restriction).
397
383source "drivers/acpi/apei/Kconfig" 398source "drivers/acpi/apei/Kconfig"
384 399
385endif # ACPI 400endif # ACPI
diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile
index d113fa5100b2..cba0b2334b9b 100644
--- a/drivers/acpi/Makefile
+++ b/drivers/acpi/Makefile
@@ -62,6 +62,7 @@ obj-$(CONFIG_ACPI_SBS) += sbs.o
62obj-$(CONFIG_ACPI_POWER_METER) += power_meter.o 62obj-$(CONFIG_ACPI_POWER_METER) += power_meter.o
63obj-$(CONFIG_ACPI_HED) += hed.o 63obj-$(CONFIG_ACPI_HED) += hed.o
64obj-$(CONFIG_ACPI_EC_DEBUGFS) += ec_sys.o 64obj-$(CONFIG_ACPI_EC_DEBUGFS) += ec_sys.o
65obj-$(CONFIG_ACPI_CUSTOM_METHOD)+= custom_method.o
65 66
66# processor has its own "processor." module_param namespace 67# processor has its own "processor." module_param namespace
67processor-y := processor_driver.o processor_throttling.o 68processor-y := processor_driver.o processor_throttling.o
diff --git a/drivers/acpi/acpica/Makefile b/drivers/acpi/acpica/Makefile
index a1224712fd0c..301bd2d388ad 100644
--- a/drivers/acpi/acpica/Makefile
+++ b/drivers/acpi/acpica/Makefile
@@ -14,7 +14,7 @@ acpi-y := dsfield.o dsmthdat.o dsopcode.o dswexec.o dswscope.o \
14 14
15acpi-y += evevent.o evregion.o evsci.o evxfevnt.o \ 15acpi-y += evevent.o evregion.o evsci.o evxfevnt.o \
16 evmisc.o evrgnini.o evxface.o evxfregn.o \ 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
19acpi-y += exconfig.o exfield.o exnames.o exoparg6.o exresolv.o exstorob.o\ 19acpi-y += exconfig.o exfield.o exnames.o exoparg6.o exresolv.o exstorob.o\
20 exconvrt.o exfldio.o exoparg1.o exprep.o exresop.o exsystem.o\ 20 exconvrt.o exfldio.o exoparg1.o exprep.o exresop.o exsystem.o\
diff --git a/drivers/acpi/acpica/acconfig.h b/drivers/acpi/acpica/acconfig.h
index ab87396c2c07..bc533dde16c4 100644
--- a/drivers/acpi/acpica/acconfig.h
+++ b/drivers/acpi/acpica/acconfig.h
@@ -187,7 +187,6 @@
187 187
188/* Operation regions */ 188/* Operation regions */
189 189
190#define ACPI_NUM_PREDEFINED_REGIONS 9
191#define ACPI_USER_REGION_BEGIN 0x80 190#define ACPI_USER_REGION_BEGIN 0x80
192 191
193/* Maximum space_ids for Operation Regions */ 192/* Maximum space_ids for Operation Regions */
diff --git a/drivers/acpi/acpica/acevents.h b/drivers/acpi/acpica/acevents.h
index 41d247daf461..bea3b4899183 100644
--- a/drivers/acpi/acpica/acevents.h
+++ b/drivers/acpi/acpica/acevents.h
@@ -58,12 +58,6 @@ u32 acpi_ev_fixed_event_detect(void);
58 */ 58 */
59u8 acpi_ev_is_notify_object(struct acpi_namespace_node *node); 59u8 acpi_ev_is_notify_object(struct acpi_namespace_node *node);
60 60
61acpi_status acpi_ev_acquire_global_lock(u16 timeout);
62
63acpi_status acpi_ev_release_global_lock(void);
64
65acpi_status acpi_ev_init_global_lock_handler(void);
66
67u32 acpi_ev_get_gpe_number_index(u32 gpe_number); 61u32 acpi_ev_get_gpe_number_index(u32 gpe_number);
68 62
69acpi_status 63acpi_status
@@ -71,6 +65,17 @@ acpi_ev_queue_notify_request(struct acpi_namespace_node *node,
71 u32 notify_value); 65 u32 notify_value);
72 66
73/* 67/*
68 * evglock - Global Lock support
69 */
70acpi_status acpi_ev_init_global_lock_handler(void);
71
72acpi_status acpi_ev_acquire_global_lock(u16 timeout);
73
74acpi_status acpi_ev_release_global_lock(void);
75
76acpi_status acpi_ev_remove_global_lock_handler(void);
77
78/*
74 * evgpe - Low-level GPE support 79 * evgpe - Low-level GPE support
75 */ 80 */
76u32 acpi_ev_gpe_detect(struct acpi_gpe_xrupt_info *gpe_xrupt_list); 81u32 acpi_ev_gpe_detect(struct acpi_gpe_xrupt_info *gpe_xrupt_list);
diff --git a/drivers/acpi/acpica/acglobal.h b/drivers/acpi/acpica/acglobal.h
index d69750b83b36..73863d86f022 100644
--- a/drivers/acpi/acpica/acglobal.h
+++ b/drivers/acpi/acpica/acglobal.h
@@ -214,24 +214,23 @@ ACPI_EXTERN struct acpi_mutex_info acpi_gbl_mutex_info[ACPI_NUM_MUTEX];
214 214
215/* 215/*
216 * Global lock mutex is an actual AML mutex object 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 */
219ACPI_EXTERN union acpi_operand_object *acpi_gbl_global_lock_mutex; 220ACPI_EXTERN union acpi_operand_object *acpi_gbl_global_lock_mutex;
220ACPI_EXTERN acpi_semaphore acpi_gbl_global_lock_semaphore; 221ACPI_EXTERN acpi_semaphore acpi_gbl_global_lock_semaphore;
222ACPI_EXTERN acpi_spinlock acpi_gbl_global_lock_pending_lock;
221ACPI_EXTERN u16 acpi_gbl_global_lock_handle; 223ACPI_EXTERN u16 acpi_gbl_global_lock_handle;
222ACPI_EXTERN u8 acpi_gbl_global_lock_acquired; 224ACPI_EXTERN u8 acpi_gbl_global_lock_acquired;
223ACPI_EXTERN u8 acpi_gbl_global_lock_present; 225ACPI_EXTERN u8 acpi_gbl_global_lock_present;
226ACPI_EXTERN u8 acpi_gbl_global_lock_pending;
224 227
225/* 228/*
226 * Spinlocks are used for interfaces that can be possibly called at 229 * Spinlocks are used for interfaces that can be possibly called at
227 * interrupt level 230 * interrupt level
228 */ 231 */
229ACPI_EXTERN spinlock_t _acpi_gbl_gpe_lock; /* For GPE data structs and registers */ 232ACPI_EXTERN acpi_spinlock acpi_gbl_gpe_lock; /* For GPE data structs and registers */
230ACPI_EXTERN spinlock_t _acpi_gbl_hardware_lock; /* For ACPI H/W except GPE registers */ 233ACPI_EXTERN acpi_spinlock acpi_gbl_hardware_lock; /* For ACPI H/W except GPE registers */
231ACPI_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
235 234
236/***************************************************************************** 235/*****************************************************************************
237 * 236 *
diff --git a/drivers/acpi/acpica/amlcode.h b/drivers/acpi/acpica/amlcode.h
index f4f0998d3967..1077f17859ed 100644
--- a/drivers/acpi/acpica/amlcode.h
+++ b/drivers/acpi/acpica/amlcode.h
@@ -394,21 +394,6 @@
394#define AML_CLASS_METHOD_CALL 0x09 394#define AML_CLASS_METHOD_CALL 0x09
395#define AML_CLASS_UNKNOWN 0x0A 395#define AML_CLASS_UNKNOWN 0x0A
396 396
397/* Predefined Operation Region space_iDs */
398
399typedef 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/* Comparison operation codes for match_op operator */ 397/* Comparison operation codes for match_op operator */
413 398
414typedef enum { 399typedef enum {
diff --git a/drivers/acpi/acpica/dswload.c b/drivers/acpi/acpica/dswload.c
index 23a3b1ab20c1..324acec1179a 100644
--- a/drivers/acpi/acpica/dswload.c
+++ b/drivers/acpi/acpica/dswload.c
@@ -450,7 +450,7 @@ acpi_status acpi_ds_load1_end_op(struct acpi_walk_state *walk_state)
450 status = 450 status =
451 acpi_ex_create_region(op->named.data, 451 acpi_ex_create_region(op->named.data,
452 op->named.length, 452 op->named.length,
453 REGION_DATA_TABLE, 453 ACPI_ADR_SPACE_DATA_TABLE,
454 walk_state); 454 walk_state);
455 if (ACPI_FAILURE(status)) { 455 if (ACPI_FAILURE(status)) {
456 return_ACPI_STATUS(status); 456 return_ACPI_STATUS(status);
diff --git a/drivers/acpi/acpica/dswload2.c b/drivers/acpi/acpica/dswload2.c
index 4be4e921dfe1..976318138c56 100644
--- a/drivers/acpi/acpica/dswload2.c
+++ b/drivers/acpi/acpica/dswload2.c
@@ -562,7 +562,7 @@ acpi_status acpi_ds_load2_end_op(struct acpi_walk_state *walk_state)
562 ((op->common.value.arg)->common.value. 562 ((op->common.value.arg)->common.value.
563 integer); 563 integer);
564 } else { 564 } else {
565 region_space = REGION_DATA_TABLE; 565 region_space = ACPI_ADR_SPACE_DATA_TABLE;
566 } 566 }
567 567
568 /* 568 /*
diff --git a/drivers/acpi/acpica/evglock.c b/drivers/acpi/acpica/evglock.c
new file mode 100644
index 000000000000..56a562a1e5d7
--- /dev/null
+++ b/drivers/acpi/acpica/evglock.c
@@ -0,0 +1,335 @@
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
50ACPI_MODULE_NAME("evglock")
51
52/* Local prototypes */
53static 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
67acpi_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
115acpi_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
142static 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
197acpi_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
293acpi_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}
diff --git a/drivers/acpi/acpica/evmisc.c b/drivers/acpi/acpica/evmisc.c
index 7dc80946f7bd..d0b331844427 100644
--- a/drivers/acpi/acpica/evmisc.c
+++ b/drivers/acpi/acpica/evmisc.c
@@ -45,7 +45,6 @@
45#include "accommon.h" 45#include "accommon.h"
46#include "acevents.h" 46#include "acevents.h"
47#include "acnamesp.h" 47#include "acnamesp.h"
48#include "acinterp.h"
49 48
50#define _COMPONENT ACPI_EVENTS 49#define _COMPONENT ACPI_EVENTS
51ACPI_MODULE_NAME("evmisc") 50ACPI_MODULE_NAME("evmisc")
@@ -53,10 +52,6 @@ ACPI_MODULE_NAME("evmisc")
53/* Local prototypes */ 52/* Local prototypes */
54static void ACPI_SYSTEM_XFACE acpi_ev_notify_dispatch(void *context); 53static void ACPI_SYSTEM_XFACE acpi_ev_notify_dispatch(void *context);
55 54
56static u32 acpi_ev_global_lock_handler(void *context);
57
58static acpi_status acpi_ev_remove_global_lock_handler(void);
59
60/******************************************************************************* 55/*******************************************************************************
61 * 56 *
62 * FUNCTION: acpi_ev_is_notify_object 57 * FUNCTION: acpi_ev_is_notify_object
@@ -275,304 +270,6 @@ static void ACPI_SYSTEM_XFACE acpi_ev_notify_dispatch(void *context)
275 acpi_ut_delete_generic_state(notify_info); 270 acpi_ut_delete_generic_state(notify_info);
276} 271}
277 272
278/*******************************************************************************
279 *
280 * FUNCTION: acpi_ev_global_lock_handler
281 *
282 * PARAMETERS: Context - From thread interface, not used
283 *
284 * RETURN: ACPI_INTERRUPT_HANDLED
285 *
286 * DESCRIPTION: Invoked directly from the SCI handler when a global lock
287 * release interrupt occurs. If there's a thread waiting for
288 * the global lock, signal it.
289 *
290 * NOTE: Assumes that the semaphore can be signaled from interrupt level. If
291 * this is not possible for some reason, a separate thread will have to be
292 * scheduled to do this.
293 *
294 ******************************************************************************/
295static u8 acpi_ev_global_lock_pending;
296
297static u32 acpi_ev_global_lock_handler(void *context)
298{
299 acpi_status status;
300 acpi_cpu_flags flags;
301
302 flags = acpi_os_acquire_lock(acpi_ev_global_lock_pending_lock);
303
304 if (!acpi_ev_global_lock_pending) {
305 goto out;
306 }
307
308 /* Send a unit to the semaphore */
309
310 status = acpi_os_signal_semaphore(acpi_gbl_global_lock_semaphore, 1);
311 if (ACPI_FAILURE(status)) {
312 ACPI_ERROR((AE_INFO, "Could not signal Global Lock semaphore"));
313 }
314
315 acpi_ev_global_lock_pending = FALSE;
316
317 out:
318 acpi_os_release_lock(acpi_ev_global_lock_pending_lock, flags);
319
320 return (ACPI_INTERRUPT_HANDLED);
321}
322
323/*******************************************************************************
324 *
325 * FUNCTION: acpi_ev_init_global_lock_handler
326 *
327 * PARAMETERS: None
328 *
329 * RETURN: Status
330 *
331 * DESCRIPTION: Install a handler for the global lock release event
332 *
333 ******************************************************************************/
334
335acpi_status acpi_ev_init_global_lock_handler(void)
336{
337 acpi_status status;
338
339 ACPI_FUNCTION_TRACE(ev_init_global_lock_handler);
340
341 /* Attempt installation of the global lock handler */
342
343 status = acpi_install_fixed_event_handler(ACPI_EVENT_GLOBAL,
344 acpi_ev_global_lock_handler,
345 NULL);
346
347 /*
348 * If the global lock does not exist on this platform, the attempt to
349 * enable GBL_STATUS will fail (the GBL_ENABLE bit will not stick).
350 * Map to AE_OK, but mark global lock as not present. Any attempt to
351 * actually use the global lock will be flagged with an error.
352 */
353 if (status == AE_NO_HARDWARE_RESPONSE) {
354 ACPI_ERROR((AE_INFO,
355 "No response from Global Lock hardware, disabling lock"));
356
357 acpi_gbl_global_lock_present = FALSE;
358 return_ACPI_STATUS(AE_OK);
359 }
360
361 acpi_gbl_global_lock_present = TRUE;
362 return_ACPI_STATUS(status);
363}
364
365/*******************************************************************************
366 *
367 * FUNCTION: acpi_ev_remove_global_lock_handler
368 *
369 * PARAMETERS: None
370 *
371 * RETURN: Status
372 *
373 * DESCRIPTION: Remove the handler for the Global Lock
374 *
375 ******************************************************************************/
376
377static acpi_status acpi_ev_remove_global_lock_handler(void)
378{
379 acpi_status status;
380
381 ACPI_FUNCTION_TRACE(ev_remove_global_lock_handler);
382
383 acpi_gbl_global_lock_present = FALSE;
384 status = acpi_remove_fixed_event_handler(ACPI_EVENT_GLOBAL,
385 acpi_ev_global_lock_handler);
386
387 return_ACPI_STATUS(status);
388}
389
390/******************************************************************************
391 *
392 * FUNCTION: acpi_ev_acquire_global_lock
393 *
394 * PARAMETERS: Timeout - Max time to wait for the lock, in millisec.
395 *
396 * RETURN: Status
397 *
398 * DESCRIPTION: Attempt to gain ownership of the Global Lock.
399 *
400 * MUTEX: Interpreter must be locked
401 *
402 * Note: The original implementation allowed multiple threads to "acquire" the
403 * Global Lock, and the OS would hold the lock until the last thread had
404 * released it. However, this could potentially starve the BIOS out of the
405 * lock, especially in the case where there is a tight handshake between the
406 * Embedded Controller driver and the BIOS. Therefore, this implementation
407 * allows only one thread to acquire the HW Global Lock at a time, and makes
408 * the global lock appear as a standard mutex on the OS side.
409 *
410 *****************************************************************************/
411static acpi_thread_id acpi_ev_global_lock_thread_id;
412static int acpi_ev_global_lock_acquired;
413
414acpi_status acpi_ev_acquire_global_lock(u16 timeout)
415{
416 acpi_cpu_flags flags;
417 acpi_status status = AE_OK;
418 u8 acquired = FALSE;
419
420 ACPI_FUNCTION_TRACE(ev_acquire_global_lock);
421
422 /*
423 * Only one thread can acquire the GL at a time, the global_lock_mutex
424 * enforces this. This interface releases the interpreter if we must wait.
425 */
426 status = acpi_ex_system_wait_mutex(
427 acpi_gbl_global_lock_mutex->mutex.os_mutex, 0);
428 if (status == AE_TIME) {
429 if (acpi_ev_global_lock_thread_id == acpi_os_get_thread_id()) {
430 acpi_ev_global_lock_acquired++;
431 return AE_OK;
432 }
433 }
434
435 if (ACPI_FAILURE(status)) {
436 status = acpi_ex_system_wait_mutex(
437 acpi_gbl_global_lock_mutex->mutex.os_mutex,
438 timeout);
439 }
440 if (ACPI_FAILURE(status)) {
441 return_ACPI_STATUS(status);
442 }
443
444 acpi_ev_global_lock_thread_id = acpi_os_get_thread_id();
445 acpi_ev_global_lock_acquired++;
446
447 /*
448 * Update the global lock handle and check for wraparound. The handle is
449 * only used for the external global lock interfaces, but it is updated
450 * here to properly handle the case where a single thread may acquire the
451 * lock via both the AML and the acpi_acquire_global_lock interfaces. The
452 * handle is therefore updated on the first acquire from a given thread
453 * regardless of where the acquisition request originated.
454 */
455 acpi_gbl_global_lock_handle++;
456 if (acpi_gbl_global_lock_handle == 0) {
457 acpi_gbl_global_lock_handle = 1;
458 }
459
460 /*
461 * Make sure that a global lock actually exists. If not, just treat the
462 * lock as a standard mutex.
463 */
464 if (!acpi_gbl_global_lock_present) {
465 acpi_gbl_global_lock_acquired = TRUE;
466 return_ACPI_STATUS(AE_OK);
467 }
468
469 flags = acpi_os_acquire_lock(acpi_ev_global_lock_pending_lock);
470
471 do {
472
473 /* Attempt to acquire the actual hardware lock */
474
475 ACPI_ACQUIRE_GLOBAL_LOCK(acpi_gbl_FACS, acquired);
476 if (acquired) {
477 acpi_gbl_global_lock_acquired = TRUE;
478
479 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
480 "Acquired hardware Global Lock\n"));
481 break;
482 }
483
484 acpi_ev_global_lock_pending = TRUE;
485
486 acpi_os_release_lock(acpi_ev_global_lock_pending_lock, flags);
487
488 /*
489 * Did not get the lock. The pending bit was set above, and we
490 * must wait until we get the global lock released interrupt.
491 */
492 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
493 "Waiting for hardware Global Lock\n"));
494
495 /*
496 * Wait for handshake with the global lock interrupt handler.
497 * This interface releases the interpreter if we must wait.
498 */
499 status = acpi_ex_system_wait_semaphore(
500 acpi_gbl_global_lock_semaphore,
501 ACPI_WAIT_FOREVER);
502
503 flags = acpi_os_acquire_lock(acpi_ev_global_lock_pending_lock);
504
505 } while (ACPI_SUCCESS(status));
506
507 acpi_ev_global_lock_pending = FALSE;
508
509 acpi_os_release_lock(acpi_ev_global_lock_pending_lock, flags);
510
511 return_ACPI_STATUS(status);
512}
513
514/*******************************************************************************
515 *
516 * FUNCTION: acpi_ev_release_global_lock
517 *
518 * PARAMETERS: None
519 *
520 * RETURN: Status
521 *
522 * DESCRIPTION: Releases ownership of the Global Lock.
523 *
524 ******************************************************************************/
525
526acpi_status acpi_ev_release_global_lock(void)
527{
528 u8 pending = FALSE;
529 acpi_status status = AE_OK;
530
531 ACPI_FUNCTION_TRACE(ev_release_global_lock);
532
533 /* Lock must be already acquired */
534
535 if (!acpi_gbl_global_lock_acquired) {
536 ACPI_WARNING((AE_INFO,
537 "Cannot release the ACPI Global Lock, it has not been acquired"));
538 return_ACPI_STATUS(AE_NOT_ACQUIRED);
539 }
540
541 acpi_ev_global_lock_acquired--;
542 if (acpi_ev_global_lock_acquired > 0) {
543 return AE_OK;
544 }
545
546 if (acpi_gbl_global_lock_present) {
547
548 /* Allow any thread to release the lock */
549
550 ACPI_RELEASE_GLOBAL_LOCK(acpi_gbl_FACS, pending);
551
552 /*
553 * If the pending bit was set, we must write GBL_RLS to the control
554 * register
555 */
556 if (pending) {
557 status =
558 acpi_write_bit_register
559 (ACPI_BITREG_GLOBAL_LOCK_RELEASE,
560 ACPI_ENABLE_EVENT);
561 }
562
563 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
564 "Released hardware Global Lock\n"));
565 }
566
567 acpi_gbl_global_lock_acquired = FALSE;
568
569 /* Release the local GL mutex */
570 acpi_ev_global_lock_thread_id = 0;
571 acpi_ev_global_lock_acquired = 0;
572 acpi_os_release_mutex(acpi_gbl_global_lock_mutex->mutex.os_mutex);
573 return_ACPI_STATUS(status);
574}
575
576/****************************************************************************** 273/******************************************************************************
577 * 274 *
578 * FUNCTION: acpi_ev_terminate 275 * FUNCTION: acpi_ev_terminate
diff --git a/drivers/acpi/acpica/evregion.c b/drivers/acpi/acpica/evregion.c
index bea7223d7a71..f0edf5c43c03 100644
--- a/drivers/acpi/acpica/evregion.c
+++ b/drivers/acpi/acpica/evregion.c
@@ -55,6 +55,8 @@ static u8
55acpi_ev_has_default_handler(struct acpi_namespace_node *node, 55acpi_ev_has_default_handler(struct acpi_namespace_node *node,
56 acpi_adr_space_type space_id); 56 acpi_adr_space_type space_id);
57 57
58static void acpi_ev_orphan_ec_reg_method(void);
59
58static acpi_status 60static acpi_status
59acpi_ev_reg_run(acpi_handle obj_handle, 61acpi_ev_reg_run(acpi_handle obj_handle,
60 u32 level, void *context, void **return_value); 62 u32 level, void *context, void **return_value);
@@ -561,7 +563,9 @@ acpi_ev_detach_region(union acpi_operand_object *region_obj,
561 563
562 /* Now stop region accesses by executing the _REG method */ 564 /* Now stop region accesses by executing the _REG method */
563 565
564 status = acpi_ev_execute_reg_method(region_obj, 0); 566 status =
567 acpi_ev_execute_reg_method(region_obj,
568 ACPI_REG_DISCONNECT);
565 if (ACPI_FAILURE(status)) { 569 if (ACPI_FAILURE(status)) {
566 ACPI_EXCEPTION((AE_INFO, status, 570 ACPI_EXCEPTION((AE_INFO, status,
567 "from region _REG, [%s]", 571 "from region _REG, [%s]",
@@ -1062,6 +1066,12 @@ acpi_ev_execute_reg_methods(struct acpi_namespace_node *node,
1062 ACPI_NS_WALK_UNLOCK, acpi_ev_reg_run, 1066 ACPI_NS_WALK_UNLOCK, acpi_ev_reg_run,
1063 NULL, &space_id, NULL); 1067 NULL, &space_id, NULL);
1064 1068
1069 /* Special case for EC: handle "orphan" _REG methods with no region */
1070
1071 if (space_id == ACPI_ADR_SPACE_EC) {
1072 acpi_ev_orphan_ec_reg_method();
1073 }
1074
1065 return_ACPI_STATUS(status); 1075 return_ACPI_STATUS(status);
1066} 1076}
1067 1077
@@ -1120,6 +1130,113 @@ acpi_ev_reg_run(acpi_handle obj_handle,
1120 return (AE_OK); 1130 return (AE_OK);
1121 } 1131 }
1122 1132
1123 status = acpi_ev_execute_reg_method(obj_desc, 1); 1133 status = acpi_ev_execute_reg_method(obj_desc, ACPI_REG_CONNECT);
1124 return (status); 1134 return (status);
1125} 1135}
1136
1137/*******************************************************************************
1138 *
1139 * FUNCTION: acpi_ev_orphan_ec_reg_method
1140 *
1141 * PARAMETERS: None
1142 *
1143 * RETURN: None
1144 *
1145 * DESCRIPTION: Execute an "orphan" _REG method that appears under the EC
1146 * device. This is a _REG method that has no corresponding region
1147 * within the EC device scope. The orphan _REG method appears to
1148 * have been enabled by the description of the ECDT in the ACPI
1149 * specification: "The availability of the region space can be
1150 * detected by providing a _REG method object underneath the
1151 * Embedded Controller device."
1152 *
1153 * To quickly access the EC device, we use the EC_ID that appears
1154 * within the ECDT. Otherwise, we would need to perform a time-
1155 * consuming namespace walk, executing _HID methods to find the
1156 * EC device.
1157 *
1158 ******************************************************************************/
1159
1160static void acpi_ev_orphan_ec_reg_method(void)
1161{
1162 struct acpi_table_ecdt *table;
1163 acpi_status status;
1164 struct acpi_object_list args;
1165 union acpi_object objects[2];
1166 struct acpi_namespace_node *ec_device_node;
1167 struct acpi_namespace_node *reg_method;
1168 struct acpi_namespace_node *next_node;
1169
1170 ACPI_FUNCTION_TRACE(ev_orphan_ec_reg_method);
1171
1172 /* Get the ECDT (if present in system) */
1173
1174 status = acpi_get_table(ACPI_SIG_ECDT, 0,
1175 ACPI_CAST_INDIRECT_PTR(struct acpi_table_header,
1176 &table));
1177 if (ACPI_FAILURE(status)) {
1178 return_VOID;
1179 }
1180
1181 /* We need a valid EC_ID string */
1182
1183 if (!(*table->id)) {
1184 return_VOID;
1185 }
1186
1187 /* Namespace is currently locked, must release */
1188
1189 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
1190
1191 /* Get a handle to the EC device referenced in the ECDT */
1192
1193 status = acpi_get_handle(NULL,
1194 ACPI_CAST_PTR(char, table->id),
1195 ACPI_CAST_PTR(acpi_handle, &ec_device_node));
1196 if (ACPI_FAILURE(status)) {
1197 goto exit;
1198 }
1199
1200 /* Get a handle to a _REG method immediately under the EC device */
1201
1202 status = acpi_get_handle(ec_device_node,
1203 METHOD_NAME__REG, ACPI_CAST_PTR(acpi_handle,
1204 &reg_method));
1205 if (ACPI_FAILURE(status)) {
1206 goto exit;
1207 }
1208
1209 /*
1210 * Execute the _REG method only if there is no Operation Region in
1211 * this scope with the Embedded Controller space ID. Otherwise, it
1212 * will already have been executed. Note, this allows for Regions
1213 * with other space IDs to be present; but the code below will then
1214 * execute the _REG method with the EC space ID argument.
1215 */
1216 next_node = acpi_ns_get_next_node(ec_device_node, NULL);
1217 while (next_node) {
1218 if ((next_node->type == ACPI_TYPE_REGION) &&
1219 (next_node->object) &&
1220 (next_node->object->region.space_id == ACPI_ADR_SPACE_EC)) {
1221 goto exit; /* Do not execute _REG */
1222 }
1223 next_node = acpi_ns_get_next_node(ec_device_node, next_node);
1224 }
1225
1226 /* Evaluate the _REG(EC,Connect) method */
1227
1228 args.count = 2;
1229 args.pointer = objects;
1230 objects[0].type = ACPI_TYPE_INTEGER;
1231 objects[0].integer.value = ACPI_ADR_SPACE_EC;
1232 objects[1].type = ACPI_TYPE_INTEGER;
1233 objects[1].integer.value = ACPI_REG_CONNECT;
1234
1235 status = acpi_evaluate_object(reg_method, NULL, &args, NULL);
1236
1237 exit:
1238 /* We ignore all errors from above, don't care */
1239
1240 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
1241 return_VOID;
1242}
diff --git a/drivers/acpi/acpica/evrgnini.c b/drivers/acpi/acpica/evrgnini.c
index 9659cee6093e..55a5d35ef34a 100644
--- a/drivers/acpi/acpica/evrgnini.c
+++ b/drivers/acpi/acpica/evrgnini.c
@@ -637,7 +637,7 @@ acpi_ev_initialize_region(union acpi_operand_object *region_obj,
637 637
638 status = 638 status =
639 acpi_ev_execute_reg_method 639 acpi_ev_execute_reg_method
640 (region_obj, 1); 640 (region_obj, ACPI_REG_CONNECT);
641 641
642 if (acpi_ns_locked) { 642 if (acpi_ns_locked) {
643 status = 643 status =
diff --git a/drivers/acpi/acpica/evxfregn.c b/drivers/acpi/acpica/evxfregn.c
index c85c8c45599d..00cd95692a91 100644
--- a/drivers/acpi/acpica/evxfregn.c
+++ b/drivers/acpi/acpica/evxfregn.c
@@ -130,20 +130,21 @@ acpi_install_address_space_handler(acpi_handle device,
130 case ACPI_ADR_SPACE_PCI_CONFIG: 130 case ACPI_ADR_SPACE_PCI_CONFIG:
131 case ACPI_ADR_SPACE_DATA_TABLE: 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 */ 135 /* We will defer execution of the _REG methods for this space */
136 136 goto unlock_and_exit;
137 status = acpi_ev_execute_reg_methods(node, space_id);
138 } 137 }
139 break; 138 break;
140 139
141 default: 140 default:
142
143 status = acpi_ev_execute_reg_methods(node, space_id);
144 break; 141 break;
145 } 142 }
146 143
144 /* Run all _REG methods for this address space */
145
146 status = acpi_ev_execute_reg_methods(node, space_id);
147
147 unlock_and_exit: 148 unlock_and_exit:
148 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); 149 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
149 return_ACPI_STATUS(status); 150 return_ACPI_STATUS(status);
diff --git a/drivers/acpi/acpica/excreate.c b/drivers/acpi/acpica/excreate.c
index e7b372d17667..110711afada8 100644
--- a/drivers/acpi/acpica/excreate.c
+++ b/drivers/acpi/acpica/excreate.c
@@ -305,7 +305,8 @@ acpi_ex_create_region(u8 * aml_start,
305 * range 305 * range
306 */ 306 */
307 if ((region_space >= ACPI_NUM_PREDEFINED_REGIONS) && 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 ACPI_ERROR((AE_INFO, "Invalid AddressSpace type 0x%X", 310 ACPI_ERROR((AE_INFO, "Invalid AddressSpace type 0x%X",
310 region_space)); 311 region_space));
311 return_ACPI_STATUS(AE_AML_INVALID_SPACE_ID); 312 return_ACPI_STATUS(AE_AML_INVALID_SPACE_ID);
diff --git a/drivers/acpi/acpica/nsrepair.c b/drivers/acpi/acpica/nsrepair.c
index 1d76ac85b5e7..ac7b854b0bd7 100644
--- a/drivers/acpi/acpica/nsrepair.c
+++ b/drivers/acpi/acpica/nsrepair.c
@@ -74,7 +74,6 @@ ACPI_MODULE_NAME("nsrepair")
74 * 74 *
75 * Additional possible repairs: 75 * Additional possible repairs:
76 * 76 *
77 * Optional/unnecessary NULL package elements removed
78 * Required package elements that are NULL replaced by Integer/String/Buffer 77 * Required package elements that are NULL replaced by Integer/String/Buffer
79 * Incorrect standalone package wrapped with required outer package 78 * Incorrect standalone package wrapped with required outer package
80 * 79 *
@@ -623,16 +622,12 @@ acpi_ns_remove_null_elements(struct acpi_predefined_data *data,
623 ACPI_FUNCTION_NAME(ns_remove_null_elements); 622 ACPI_FUNCTION_NAME(ns_remove_null_elements);
624 623
625 /* 624 /*
626 * PTYPE1 packages contain no subpackages. 625 * We can safely remove all NULL elements from these package types:
627 * PTYPE2 packages contain a variable number of sub-packages. We can 626 * PTYPE1_VAR packages contain a variable number of simple data types.
628 * safely remove all NULL elements from the PTYPE2 packages. 627 * PTYPE2 packages contain a variable number of sub-packages.
629 */ 628 */
630 switch (package_type) { 629 switch (package_type) {
631 case ACPI_PTYPE1_FIXED:
632 case ACPI_PTYPE1_VAR: 630 case ACPI_PTYPE1_VAR:
633 case ACPI_PTYPE1_OPTION:
634 return;
635
636 case ACPI_PTYPE2: 631 case ACPI_PTYPE2:
637 case ACPI_PTYPE2_COUNT: 632 case ACPI_PTYPE2_COUNT:
638 case ACPI_PTYPE2_PKG_COUNT: 633 case ACPI_PTYPE2_PKG_COUNT:
@@ -642,6 +637,8 @@ acpi_ns_remove_null_elements(struct acpi_predefined_data *data,
642 break; 637 break;
643 638
644 default: 639 default:
640 case ACPI_PTYPE1_FIXED:
641 case ACPI_PTYPE1_OPTION:
645 return; 642 return;
646 } 643 }
647 644
diff --git a/drivers/acpi/acpica/utdecode.c b/drivers/acpi/acpica/utdecode.c
index 136a814cec69..97cb36f85ce9 100644
--- a/drivers/acpi/acpica/utdecode.c
+++ b/drivers/acpi/acpica/utdecode.c
@@ -170,8 +170,7 @@ const char *acpi_gbl_region_types[ACPI_NUM_PREDEFINED_REGIONS] = {
170 "SMBus", 170 "SMBus",
171 "SystemCMOS", 171 "SystemCMOS",
172 "PCIBARTarget", 172 "PCIBARTarget",
173 "IPMI", 173 "IPMI"
174 "DataTable"
175}; 174};
176 175
177char *acpi_ut_get_region_name(u8 space_id) 176char *acpi_ut_get_region_name(u8 space_id)
@@ -179,6 +178,8 @@ char *acpi_ut_get_region_name(u8 space_id)
179 178
180 if (space_id >= ACPI_USER_REGION_BEGIN) { 179 if (space_id >= ACPI_USER_REGION_BEGIN) {
181 return ("UserDefinedRegion"); 180 return ("UserDefinedRegion");
181 } else if (space_id == ACPI_ADR_SPACE_DATA_TABLE) {
182 return ("DataTable");
182 } else if (space_id == ACPI_ADR_SPACE_FIXED_HARDWARE) { 183 } else if (space_id == ACPI_ADR_SPACE_FIXED_HARDWARE) {
183 return ("FunctionalFixedHW"); 184 return ("FunctionalFixedHW");
184 } else if (space_id >= ACPI_NUM_PREDEFINED_REGIONS) { 185 } else if (space_id >= ACPI_NUM_PREDEFINED_REGIONS) {
diff --git a/drivers/acpi/acpica/utmutex.c b/drivers/acpi/acpica/utmutex.c
index a946c689f03b..7d797e2baecd 100644
--- a/drivers/acpi/acpica/utmutex.c
+++ b/drivers/acpi/acpica/utmutex.c
@@ -83,9 +83,15 @@ acpi_status acpi_ut_mutex_initialize(void)
83 83
84 /* Create the spinlocks for use at interrupt level */ 84 /* Create the spinlocks for use at interrupt level */
85 85
86 spin_lock_init(acpi_gbl_gpe_lock); 86 status = acpi_os_create_lock (&acpi_gbl_gpe_lock);
87 spin_lock_init(acpi_gbl_hardware_lock); 87 if (ACPI_FAILURE (status)) {
88 spin_lock_init(acpi_ev_global_lock_pending_lock); 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 /* Mutex for _OSI support */ 96 /* Mutex for _OSI support */
91 status = acpi_os_create_mutex(&acpi_gbl_osi_mutex); 97 status = acpi_os_create_mutex(&acpi_gbl_osi_mutex);
diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c
index 9749980ca6ca..d1e06c182cdb 100644
--- a/drivers/acpi/bus.c
+++ b/drivers/acpi/bus.c
@@ -227,7 +227,7 @@ static int __acpi_bus_set_power(struct acpi_device *device, int state)
227 acpi_status status = AE_OK; 227 acpi_status status = AE_OK;
228 char object_name[5] = { '_', 'P', 'S', '0' + state, '\0' }; 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 return -EINVAL; 231 return -EINVAL;
232 232
233 /* Make sure this is a valid target state */ 233 /* Make sure this is a valid target state */
diff --git a/drivers/acpi/custom_method.c b/drivers/acpi/custom_method.c
new file mode 100644
index 000000000000..5d42c2414ae5
--- /dev/null
+++ b/drivers/acpi/custom_method.c
@@ -0,0 +1,100 @@
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
15ACPI_MODULE_NAME("custom_method");
16MODULE_LICENSE("GPL");
17
18static struct dentry *cm_dentry;
19
20/* /sys/kernel/debug/acpi/custom_method */
21
22static 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
75static const struct file_operations cm_fops = {
76 .write = cm_write,
77 .llseek = default_llseek,
78};
79
80static 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
93static void __exit acpi_custom_method_exit(void)
94{
95 if (cm_dentry)
96 debugfs_remove(cm_dentry);
97 }
98
99module_init(acpi_custom_method_init);
100module_exit(acpi_custom_method_exit);
diff --git a/drivers/acpi/debugfs.c b/drivers/acpi/debugfs.c
index 384f7abcff77..182a9fc36355 100644
--- a/drivers/acpi/debugfs.c
+++ b/drivers/acpi/debugfs.c
@@ -3,100 +3,16 @@
3 */ 3 */
4 4
5#include <linux/init.h> 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> 6#include <linux/debugfs.h>
10#include <acpi/acpi_drivers.h> 7#include <acpi/acpi_drivers.h>
11 8
12#define _COMPONENT ACPI_SYSTEM_COMPONENT 9#define _COMPONENT ACPI_SYSTEM_COMPONENT
13ACPI_MODULE_NAME("debugfs"); 10ACPI_MODULE_NAME("debugfs");
14 11
12struct dentry *acpi_debugfs_dir;
13EXPORT_SYMBOL_GPL(acpi_debugfs_dir);
15 14
16/* /sys/modules/acpi/parameters/aml_debug_output */ 15void __init acpi_debugfs_init(void)
17
18module_param_named(aml_debug_output, acpi_gbl_enable_aml_debug_object,
19 bool, 0644);
20MODULE_PARM_DESC(aml_debug_output,
21 "To enable/disable the ACPI Debug Object output.");
22
23/* /sys/kernel/debug/acpi/custom_method */
24
25static ssize_t cm_write(struct file *file, const char __user * user_buf,
26 size_t count, loff_t *ppos)
27{ 16{
28 static char *buf; 17 acpi_debugfs_dir = debugfs_create_dir("acpi", NULL);
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
78static const struct file_operations cm_fops = {
79 .write = cm_write,
80 .llseek = default_llseek,
81};
82
83int __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
98err:
99 if (acpi_dir)
100 debugfs_remove(acpi_dir);
101 return -EINVAL;
102} 18}
diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c
index fa848c4116a8..0b954c6702be 100644
--- a/drivers/acpi/ec.c
+++ b/drivers/acpi/ec.c
@@ -938,8 +938,19 @@ static struct dmi_system_id __initdata ec_dmi_table[] = {
938 ec_flag_msi, "MSI hardware", { 938 ec_flag_msi, "MSI hardware", {
939 DMI_MATCH(DMI_CHASSIS_VENDOR, "MICRO-STAR")}, NULL}, 939 DMI_MATCH(DMI_CHASSIS_VENDOR, "MICRO-STAR")}, NULL},
940 { 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 {
941 ec_validate_ecdt, "ASUS hardware", { 949 ec_validate_ecdt, "ASUS hardware", {
942 DMI_MATCH(DMI_BIOS_VENDOR, "ASUS") }, NULL}, 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},
943 {}, 954 {},
944}; 955};
945 956
diff --git a/drivers/acpi/internal.h b/drivers/acpi/internal.h
index 4bfb759deb10..ca75b9ce0489 100644
--- a/drivers/acpi/internal.h
+++ b/drivers/acpi/internal.h
@@ -28,9 +28,10 @@ int acpi_scan_init(void);
28int acpi_sysfs_init(void); 28int acpi_sysfs_init(void);
29 29
30#ifdef CONFIG_DEBUG_FS 30#ifdef CONFIG_DEBUG_FS
31extern struct dentry *acpi_debugfs_dir;
31int acpi_debugfs_init(void); 32int acpi_debugfs_init(void);
32#else 33#else
33static inline int acpi_debugfs_init(void) { return 0; } 34static inline void acpi_debugfs_init(void) { return; }
34#endif 35#endif
35 36
36/* -------------------------------------------------------------------------- 37/* --------------------------------------------------------------------------
diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c
index 45ad4ffef533..52ca9649d769 100644
--- a/drivers/acpi/osl.c
+++ b/drivers/acpi/osl.c
@@ -902,14 +902,6 @@ void acpi_os_wait_events_complete(void *context)
902 902
903EXPORT_SYMBOL(acpi_os_wait_events_complete); 903EXPORT_SYMBOL(acpi_os_wait_events_complete);
904 904
905/*
906 * Deallocate the memory for a spinlock.
907 */
908void acpi_os_delete_lock(acpi_spinlock handle)
909{
910 return;
911}
912
913acpi_status 905acpi_status
914acpi_os_create_semaphore(u32 max_units, u32 initial_units, acpi_handle * handle) 906acpi_os_create_semaphore(u32 max_units, u32 initial_units, acpi_handle * handle)
915{ 907{
@@ -1341,6 +1333,31 @@ int acpi_resources_are_enforced(void)
1341EXPORT_SYMBOL(acpi_resources_are_enforced); 1333EXPORT_SYMBOL(acpi_resources_are_enforced);
1342 1334
1343/* 1335/*
1336 * Create and initialize a spinlock.
1337 */
1338acpi_status
1339acpi_os_create_lock(acpi_spinlock *out_handle)
1340{
1341 spinlock_t *lock;
1342
1343 lock = ACPI_ALLOCATE(sizeof(spinlock_t));
1344 if (!lock)
1345 return AE_NO_MEMORY;
1346 spin_lock_init(lock);
1347 *out_handle = lock;
1348
1349 return AE_OK;
1350}
1351
1352/*
1353 * Deallocate the memory for a spinlock.
1354 */
1355void acpi_os_delete_lock(acpi_spinlock handle)
1356{
1357 ACPI_FREE(handle);
1358}
1359
1360/*
1344 * Acquire a spinlock. 1361 * Acquire a spinlock.
1345 * 1362 *
1346 * handle is a pointer to the spinlock_t. 1363 * handle is a pointer to the spinlock_t.
diff --git a/drivers/acpi/sysfs.c b/drivers/acpi/sysfs.c
index 61891e75583d..77255f250dbb 100644
--- a/drivers/acpi/sysfs.c
+++ b/drivers/acpi/sysfs.c
@@ -220,6 +220,14 @@ module_param_call(trace_state, param_set_trace_state, param_get_trace_state,
220 NULL, 0644); 220 NULL, 0644);
221#endif /* CONFIG_ACPI_DEBUG */ 221#endif /* CONFIG_ACPI_DEBUG */
222 222
223
224/* /sys/modules/acpi/parameters/aml_debug_output */
225
226module_param_named(aml_debug_output, acpi_gbl_enable_aml_debug_object,
227 bool, 0644);
228MODULE_PARM_DESC(aml_debug_output,
229 "To enable/disable the ACPI Debug Object output.");
230
223/* /sys/module/acpi/parameters/acpica_version */ 231/* /sys/module/acpi/parameters/acpica_version */
224static int param_get_acpica_version(char *buffer, struct kernel_param *kp) 232static int param_get_acpica_version(char *buffer, struct kernel_param *kp)
225{ 233{
diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c
index 7c3b18e78cee..d36f41ea8cbf 100644
--- a/drivers/pci/pci-acpi.c
+++ b/drivers/pci/pci-acpi.c
@@ -195,6 +195,8 @@ static pci_power_t acpi_pci_choose_state(struct pci_dev *pdev)
195 return PCI_D2; 195 return PCI_D2;
196 case ACPI_STATE_D3: 196 case ACPI_STATE_D3:
197 return PCI_D3hot; 197 return PCI_D3hot;
198 case ACPI_STATE_D3_COLD:
199 return PCI_D3cold;
198 } 200 }
199 return PCI_POWER_ERROR; 201 return PCI_POWER_ERROR;
200} 202}
diff --git a/drivers/thermal/thermal_sys.c b/drivers/thermal/thermal_sys.c
index fc6f2a5bde01..0b1c82ad6805 100644
--- a/drivers/thermal/thermal_sys.c
+++ b/drivers/thermal/thermal_sys.c
@@ -499,7 +499,7 @@ thermal_add_hwmon_sysfs(struct thermal_zone_device *tz)
499 dev_set_drvdata(hwmon->device, hwmon); 499 dev_set_drvdata(hwmon->device, hwmon);
500 result = device_create_file(hwmon->device, &dev_attr_name); 500 result = device_create_file(hwmon->device, &dev_attr_name);
501 if (result) 501 if (result)
502 goto unregister_hwmon_device; 502 goto free_mem;
503 503
504 register_sys_interface: 504 register_sys_interface:
505 tz->hwmon = hwmon; 505 tz->hwmon = hwmon;
@@ -513,7 +513,7 @@ thermal_add_hwmon_sysfs(struct thermal_zone_device *tz)
513 sysfs_attr_init(&tz->temp_input.attr.attr); 513 sysfs_attr_init(&tz->temp_input.attr.attr);
514 result = device_create_file(hwmon->device, &tz->temp_input.attr); 514 result = device_create_file(hwmon->device, &tz->temp_input.attr);
515 if (result) 515 if (result)
516 goto unregister_hwmon_device; 516 goto unregister_name;
517 517
518 if (tz->ops->get_crit_temp) { 518 if (tz->ops->get_crit_temp) {
519 unsigned long temperature; 519 unsigned long temperature;
@@ -527,7 +527,7 @@ thermal_add_hwmon_sysfs(struct thermal_zone_device *tz)
527 result = device_create_file(hwmon->device, 527 result = device_create_file(hwmon->device,
528 &tz->temp_crit.attr); 528 &tz->temp_crit.attr);
529 if (result) 529 if (result)
530 goto unregister_hwmon_device; 530 goto unregister_input;
531 } 531 }
532 } 532 }
533 533
@@ -539,9 +539,9 @@ thermal_add_hwmon_sysfs(struct thermal_zone_device *tz)
539 539
540 return 0; 540 return 0;
541 541
542 unregister_hwmon_device: 542 unregister_input:
543 device_remove_file(hwmon->device, &tz->temp_crit.attr);
544 device_remove_file(hwmon->device, &tz->temp_input.attr); 543 device_remove_file(hwmon->device, &tz->temp_input.attr);
544 unregister_name:
545 if (new_hwmon_device) { 545 if (new_hwmon_device) {
546 device_remove_file(hwmon->device, &dev_attr_name); 546 device_remove_file(hwmon->device, &dev_attr_name);
547 hwmon_device_unregister(hwmon->device); 547 hwmon_device_unregister(hwmon->device);