]>
Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | /****************************************************************************** |
2 | * | |
3 | * Module Name: evgpe - General Purpose Event handling and dispatch | |
4 | * | |
5 | *****************************************************************************/ | |
6 | ||
7 | /* | |
a8357b0c | 8 | * Copyright (C) 2000 - 2010, Intel Corp. |
1da177e4 LT |
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> | |
e2f7a777 LB |
45 | #include "accommon.h" |
46 | #include "acevents.h" | |
47 | #include "acnamesp.h" | |
1da177e4 LT |
48 | |
49 | #define _COMPONENT ACPI_EVENTS | |
4be44fcd | 50 | ACPI_MODULE_NAME("evgpe") |
1da177e4 | 51 | |
44f6c012 | 52 | /* Local prototypes */ |
4be44fcd | 53 | static void ACPI_SYSTEM_XFACE acpi_ev_asynch_execute_gpe_method(void *context); |
1da177e4 | 54 | |
1da177e4 LT |
55 | /******************************************************************************* |
56 | * | |
57 | * FUNCTION: acpi_ev_update_gpe_enable_masks | |
58 | * | |
59 | * PARAMETERS: gpe_event_info - GPE to update | |
1da177e4 LT |
60 | * |
61 | * RETURN: Status | |
62 | * | |
0f849d2c LM |
63 | * DESCRIPTION: Updates GPE register enable masks based upon whether there are |
64 | * references (either wake or run) to this GPE | |
1da177e4 LT |
65 | * |
66 | ******************************************************************************/ | |
67 | ||
68 | acpi_status | |
9630bdd9 | 69 | acpi_ev_update_gpe_enable_masks(struct acpi_gpe_event_info *gpe_event_info) |
1da177e4 | 70 | { |
4be44fcd | 71 | struct acpi_gpe_register_info *gpe_register_info; |
e4e9a735 | 72 | u32 register_bit; |
1da177e4 | 73 | |
b229cf92 | 74 | ACPI_FUNCTION_TRACE(ev_update_gpe_enable_masks); |
1da177e4 LT |
75 | |
76 | gpe_register_info = gpe_event_info->register_info; | |
77 | if (!gpe_register_info) { | |
4be44fcd | 78 | return_ACPI_STATUS(AE_NOT_EXIST); |
1da177e4 | 79 | } |
d4913dc6 | 80 | |
e4e9a735 RW |
81 | register_bit = acpi_hw_gpe_register_bit(gpe_event_info, |
82 | gpe_register_info); | |
1da177e4 | 83 | |
0f849d2c LM |
84 | /* Clear the wake/run bits up front */ |
85 | ||
9630bdd9 RW |
86 | ACPI_CLEAR_BIT(gpe_register_info->enable_for_wake, register_bit); |
87 | ACPI_CLEAR_BIT(gpe_register_info->enable_for_run, register_bit); | |
1da177e4 | 88 | |
0f849d2c LM |
89 | /* Set the mask bits only if there are references to this GPE */ |
90 | ||
91 | if (gpe_event_info->runtime_count) { | |
4be44fcd | 92 | ACPI_SET_BIT(gpe_register_info->enable_for_run, register_bit); |
0f849d2c | 93 | } |
1da177e4 | 94 | |
0f849d2c | 95 | if (gpe_event_info->wakeup_count) { |
4be44fcd | 96 | ACPI_SET_BIT(gpe_register_info->enable_for_wake, register_bit); |
0f849d2c | 97 | } |
1da177e4 | 98 | |
4be44fcd | 99 | return_ACPI_STATUS(AE_OK); |
1da177e4 LT |
100 | } |
101 | ||
0f849d2c LM |
102 | |
103 | /******************************************************************************* | |
104 | * | |
105 | * FUNCTION: acpi_ev_low_get_gpe_info | |
106 | * | |
107 | * PARAMETERS: gpe_number - Raw GPE number | |
108 | * gpe_block - A GPE info block | |
109 | * | |
110 | * RETURN: A GPE event_info struct. NULL if not a valid GPE (The gpe_number | |
111 | * is not within the specified GPE block) | |
112 | * | |
113 | * DESCRIPTION: Returns the event_info struct associated with this GPE. This is | |
114 | * the low-level implementation of ev_get_gpe_event_info. | |
115 | * | |
116 | ******************************************************************************/ | |
117 | ||
118 | struct acpi_gpe_event_info *acpi_ev_low_get_gpe_info(u32 gpe_number, | |
119 | struct acpi_gpe_block_info | |
120 | *gpe_block) | |
121 | { | |
122 | u32 gpe_index; | |
123 | ||
124 | /* | |
125 | * Validate that the gpe_number is within the specified gpe_block. | |
126 | * (Two steps) | |
127 | */ | |
128 | if (!gpe_block || (gpe_number < gpe_block->block_base_number)) { | |
129 | return (NULL); | |
130 | } | |
131 | ||
132 | gpe_index = gpe_number - gpe_block->block_base_number; | |
133 | if (gpe_index >= gpe_block->gpe_count) { | |
134 | return (NULL); | |
135 | } | |
136 | ||
137 | return (&gpe_block->event_info[gpe_index]); | |
138 | } | |
139 | ||
140 | ||
1da177e4 LT |
141 | /******************************************************************************* |
142 | * | |
143 | * FUNCTION: acpi_ev_get_gpe_event_info | |
144 | * | |
9f15fc66 | 145 | * PARAMETERS: gpe_device - Device node. NULL for GPE0/GPE1 |
1da177e4 LT |
146 | * gpe_number - Raw GPE number |
147 | * | |
148 | * RETURN: A GPE event_info struct. NULL if not a valid GPE | |
149 | * | |
150 | * DESCRIPTION: Returns the event_info struct associated with this GPE. | |
151 | * Validates the gpe_block and the gpe_number | |
152 | * | |
153 | * Should be called only when the GPE lists are semaphore locked | |
154 | * and not subject to change. | |
155 | * | |
156 | ******************************************************************************/ | |
157 | ||
4be44fcd LB |
158 | struct acpi_gpe_event_info *acpi_ev_get_gpe_event_info(acpi_handle gpe_device, |
159 | u32 gpe_number) | |
1da177e4 | 160 | { |
4be44fcd | 161 | union acpi_operand_object *obj_desc; |
0f849d2c | 162 | struct acpi_gpe_event_info *gpe_info; |
67a119f9 | 163 | u32 i; |
1da177e4 | 164 | |
4be44fcd | 165 | ACPI_FUNCTION_ENTRY(); |
1da177e4 LT |
166 | |
167 | /* A NULL gpe_block means use the FADT-defined GPE block(s) */ | |
168 | ||
169 | if (!gpe_device) { | |
52fc0b02 | 170 | |
1da177e4 LT |
171 | /* Examine GPE Block 0 and 1 (These blocks are permanent) */ |
172 | ||
173 | for (i = 0; i < ACPI_MAX_GPE_BLOCKS; i++) { | |
0f849d2c LM |
174 | gpe_info = acpi_ev_low_get_gpe_info(gpe_number, |
175 | acpi_gbl_gpe_fadt_blocks | |
176 | [i]); | |
177 | if (gpe_info) { | |
178 | return (gpe_info); | |
1da177e4 LT |
179 | } |
180 | } | |
181 | ||
182 | /* The gpe_number was not in the range of either FADT GPE block */ | |
183 | ||
184 | return (NULL); | |
185 | } | |
186 | ||
187 | /* A Non-NULL gpe_device means this is a GPE Block Device */ | |
188 | ||
fd350943 LB |
189 | obj_desc = acpi_ns_get_attached_object((struct acpi_namespace_node *) |
190 | gpe_device); | |
4be44fcd | 191 | if (!obj_desc || !obj_desc->device.gpe_block) { |
1da177e4 LT |
192 | return (NULL); |
193 | } | |
194 | ||
0f849d2c LM |
195 | return (acpi_ev_low_get_gpe_info |
196 | (gpe_number, obj_desc->device.gpe_block)); | |
1da177e4 LT |
197 | } |
198 | ||
1da177e4 LT |
199 | /******************************************************************************* |
200 | * | |
201 | * FUNCTION: acpi_ev_gpe_detect | |
202 | * | |
203 | * PARAMETERS: gpe_xrupt_list - Interrupt block for this interrupt. | |
204 | * Can have multiple GPE blocks attached. | |
205 | * | |
206 | * RETURN: INTERRUPT_HANDLED or INTERRUPT_NOT_HANDLED | |
207 | * | |
9f15fc66 | 208 | * DESCRIPTION: Detect if any GP events have occurred. This function is |
1da177e4 LT |
209 | * executed at interrupt level. |
210 | * | |
211 | ******************************************************************************/ | |
212 | ||
4be44fcd | 213 | u32 acpi_ev_gpe_detect(struct acpi_gpe_xrupt_info * gpe_xrupt_list) |
1da177e4 | 214 | { |
0897831b BM |
215 | acpi_status status; |
216 | struct acpi_gpe_block_info *gpe_block; | |
217 | struct acpi_gpe_register_info *gpe_register_info; | |
4be44fcd LB |
218 | u32 int_status = ACPI_INTERRUPT_NOT_HANDLED; |
219 | u8 enabled_status_byte; | |
4be44fcd LB |
220 | u32 status_reg; |
221 | u32 enable_reg; | |
b8e4d893 | 222 | acpi_cpu_flags flags; |
67a119f9 BM |
223 | u32 i; |
224 | u32 j; | |
4be44fcd | 225 | |
b229cf92 | 226 | ACPI_FUNCTION_NAME(ev_gpe_detect); |
1da177e4 LT |
227 | |
228 | /* Check for the case where there are no GPEs */ | |
229 | ||
230 | if (!gpe_xrupt_list) { | |
231 | return (int_status); | |
232 | } | |
233 | ||
967440e3 BM |
234 | /* |
235 | * We need to obtain the GPE lock for both the data structs and registers | |
9f15fc66 BM |
236 | * Note: Not necessary to obtain the hardware lock, since the GPE |
237 | * registers are owned by the gpe_lock. | |
967440e3 | 238 | */ |
4be44fcd | 239 | flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock); |
4c90ece2 BM |
240 | |
241 | /* Examine all GPE blocks attached to this interrupt level */ | |
242 | ||
1da177e4 LT |
243 | gpe_block = gpe_xrupt_list->gpe_block_list_head; |
244 | while (gpe_block) { | |
245 | /* | |
9f15fc66 BM |
246 | * Read all of the 8-bit GPE status and enable registers in this GPE |
247 | * block, saving all of them. Find all currently active GP events. | |
1da177e4 LT |
248 | */ |
249 | for (i = 0; i < gpe_block->register_count; i++) { | |
52fc0b02 | 250 | |
1da177e4 LT |
251 | /* Get the next status/enable pair */ |
252 | ||
253 | gpe_register_info = &gpe_block->register_info[i]; | |
254 | ||
255 | /* Read the Status Register */ | |
256 | ||
4be44fcd | 257 | status = |
c6b5774c BM |
258 | acpi_hw_read(&status_reg, |
259 | &gpe_register_info->status_address); | |
4be44fcd | 260 | if (ACPI_FAILURE(status)) { |
1da177e4 LT |
261 | goto unlock_and_exit; |
262 | } | |
263 | ||
264 | /* Read the Enable Register */ | |
265 | ||
4be44fcd | 266 | status = |
c6b5774c BM |
267 | acpi_hw_read(&enable_reg, |
268 | &gpe_register_info->enable_address); | |
4be44fcd | 269 | if (ACPI_FAILURE(status)) { |
1da177e4 LT |
270 | goto unlock_and_exit; |
271 | } | |
272 | ||
4be44fcd LB |
273 | ACPI_DEBUG_PRINT((ACPI_DB_INTERRUPTS, |
274 | "Read GPE Register at GPE%X: Status=%02X, Enable=%02X\n", | |
275 | gpe_register_info->base_gpe_number, | |
276 | status_reg, enable_reg)); | |
1da177e4 | 277 | |
44f6c012 | 278 | /* Check if there is anything active at all in this register */ |
1da177e4 LT |
279 | |
280 | enabled_status_byte = (u8) (status_reg & enable_reg); | |
281 | if (!enabled_status_byte) { | |
52fc0b02 | 282 | |
1da177e4 LT |
283 | /* No active GPEs in this register, move on */ |
284 | ||
285 | continue; | |
286 | } | |
287 | ||
288 | /* Now look at the individual GPEs in this byte register */ | |
289 | ||
290 | for (j = 0; j < ACPI_GPE_REGISTER_WIDTH; j++) { | |
52fc0b02 | 291 | |
1da177e4 LT |
292 | /* Examine one GPE bit */ |
293 | ||
69874165 | 294 | if (enabled_status_byte & (1 << j)) { |
1da177e4 LT |
295 | /* |
296 | * Found an active GPE. Dispatch the event to a handler | |
297 | * or method. | |
298 | */ | |
4be44fcd LB |
299 | int_status |= |
300 | acpi_ev_gpe_dispatch(&gpe_block-> | |
67a119f9 | 301 | event_info[((acpi_size) i * ACPI_GPE_REGISTER_WIDTH) + j], j + gpe_register_info->base_gpe_number); |
1da177e4 LT |
302 | } |
303 | } | |
304 | } | |
305 | ||
306 | gpe_block = gpe_block->next; | |
307 | } | |
308 | ||
4be44fcd | 309 | unlock_and_exit: |
1da177e4 | 310 | |
4be44fcd | 311 | acpi_os_release_lock(acpi_gbl_gpe_lock, flags); |
1da177e4 LT |
312 | return (int_status); |
313 | } | |
314 | ||
1da177e4 LT |
315 | /******************************************************************************* |
316 | * | |
317 | * FUNCTION: acpi_ev_asynch_execute_gpe_method | |
318 | * | |
319 | * PARAMETERS: Context (gpe_event_info) - Info for this GPE | |
320 | * | |
321 | * RETURN: None | |
322 | * | |
4119532c BM |
323 | * DESCRIPTION: Perform the actual execution of a GPE control method. This |
324 | * function is called from an invocation of acpi_os_execute and | |
325 | * therefore does NOT execute at interrupt level - so that | |
1da177e4 LT |
326 | * the control method itself is not executed in the context of |
327 | * an interrupt handler. | |
328 | * | |
329 | ******************************************************************************/ | |
17bc54ee | 330 | static void acpi_ev_asynch_enable_gpe(void *context); |
1da177e4 | 331 | |
4be44fcd | 332 | static void ACPI_SYSTEM_XFACE acpi_ev_asynch_execute_gpe_method(void *context) |
1da177e4 | 333 | { |
4be44fcd | 334 | struct acpi_gpe_event_info *gpe_event_info = (void *)context; |
4be44fcd LB |
335 | acpi_status status; |
336 | struct acpi_gpe_event_info local_gpe_event_info; | |
4119532c | 337 | struct acpi_evaluate_info *info; |
1da177e4 | 338 | |
b229cf92 | 339 | ACPI_FUNCTION_TRACE(ev_asynch_execute_gpe_method); |
1da177e4 | 340 | |
4be44fcd LB |
341 | status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS); |
342 | if (ACPI_FAILURE(status)) { | |
1da177e4 LT |
343 | return_VOID; |
344 | } | |
345 | ||
346 | /* Must revalidate the gpe_number/gpe_block */ | |
347 | ||
4be44fcd LB |
348 | if (!acpi_ev_valid_gpe_event(gpe_event_info)) { |
349 | status = acpi_ut_release_mutex(ACPI_MTX_EVENTS); | |
1da177e4 LT |
350 | return_VOID; |
351 | } | |
352 | ||
1da177e4 | 353 | /* |
9f15fc66 BM |
354 | * Take a snapshot of the GPE info for this level - we copy the info to |
355 | * prevent a race condition with remove_handler/remove_block. | |
1da177e4 | 356 | */ |
4be44fcd LB |
357 | ACPI_MEMCPY(&local_gpe_event_info, gpe_event_info, |
358 | sizeof(struct acpi_gpe_event_info)); | |
1da177e4 | 359 | |
4be44fcd LB |
360 | status = acpi_ut_release_mutex(ACPI_MTX_EVENTS); |
361 | if (ACPI_FAILURE(status)) { | |
1da177e4 LT |
362 | return_VOID; |
363 | } | |
364 | ||
365 | /* | |
9f15fc66 BM |
366 | * Must check for control method type dispatch one more time to avoid a |
367 | * race with ev_gpe_install_handler | |
1da177e4 | 368 | */ |
44f6c012 | 369 | if ((local_gpe_event_info.flags & ACPI_GPE_DISPATCH_MASK) == |
4be44fcd | 370 | ACPI_GPE_DISPATCH_METHOD) { |
1da177e4 | 371 | |
4119532c BM |
372 | /* Allocate the evaluation information block */ |
373 | ||
374 | info = ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_evaluate_info)); | |
375 | if (!info) { | |
376 | status = AE_NO_MEMORY; | |
377 | } else { | |
378 | /* | |
379 | * Invoke the GPE Method (_Lxx, _Exx) i.e., evaluate the _Lxx/_Exx | |
380 | * control method that corresponds to this GPE | |
381 | */ | |
382 | info->prefix_node = | |
383 | local_gpe_event_info.dispatch.method_node; | |
4119532c BM |
384 | info->flags = ACPI_IGNORE_RETURN_VALUE; |
385 | ||
386 | status = acpi_ns_evaluate(info); | |
387 | ACPI_FREE(info); | |
388 | } | |
389 | ||
4be44fcd | 390 | if (ACPI_FAILURE(status)) { |
b8e4d893 | 391 | ACPI_EXCEPTION((AE_INFO, status, |
2e42005b | 392 | "while evaluating GPE method [%4.4s]", |
b8e4d893 BM |
393 | acpi_ut_get_node_name |
394 | (local_gpe_event_info.dispatch. | |
4c90ece2 | 395 | method_node))); |
1da177e4 LT |
396 | } |
397 | } | |
17bc54ee AS |
398 | /* Defer enabling of GPE until all notify handlers are done */ |
399 | acpi_os_execute(OSL_NOTIFY_HANDLER, acpi_ev_asynch_enable_gpe, | |
400 | gpe_event_info); | |
401 | return_VOID; | |
402 | } | |
1da177e4 | 403 | |
17bc54ee AS |
404 | static void acpi_ev_asynch_enable_gpe(void *context) |
405 | { | |
406 | struct acpi_gpe_event_info *gpe_event_info = context; | |
407 | acpi_status status; | |
408 | if ((gpe_event_info->flags & ACPI_GPE_XRUPT_TYPE_MASK) == | |
4be44fcd | 409 | ACPI_GPE_LEVEL_TRIGGERED) { |
1da177e4 | 410 | /* |
9f15fc66 BM |
411 | * GPE is level-triggered, we clear the GPE status bit after handling |
412 | * the event. | |
1da177e4 | 413 | */ |
17bc54ee | 414 | status = acpi_hw_clear_gpe(gpe_event_info); |
4be44fcd | 415 | if (ACPI_FAILURE(status)) { |
1da177e4 LT |
416 | return_VOID; |
417 | } | |
418 | } | |
419 | ||
420 | /* Enable this GPE */ | |
17bc54ee | 421 | (void)acpi_hw_write_gpe_enable_reg(gpe_event_info); |
1da177e4 LT |
422 | return_VOID; |
423 | } | |
424 | ||
1da177e4 LT |
425 | /******************************************************************************* |
426 | * | |
427 | * FUNCTION: acpi_ev_gpe_dispatch | |
428 | * | |
44f6c012 | 429 | * PARAMETERS: gpe_event_info - Info for this GPE |
1da177e4 LT |
430 | * gpe_number - Number relative to the parent GPE block |
431 | * | |
432 | * RETURN: INTERRUPT_HANDLED or INTERRUPT_NOT_HANDLED | |
433 | * | |
434 | * DESCRIPTION: Dispatch a General Purpose Event to either a function (e.g. EC) | |
435 | * or method (e.g. _Lxx/_Exx) handler. | |
436 | * | |
437 | * This function executes at interrupt level. | |
438 | * | |
439 | ******************************************************************************/ | |
440 | ||
441 | u32 | |
4be44fcd | 442 | acpi_ev_gpe_dispatch(struct acpi_gpe_event_info *gpe_event_info, u32 gpe_number) |
1da177e4 | 443 | { |
4be44fcd | 444 | acpi_status status; |
1da177e4 | 445 | |
b229cf92 | 446 | ACPI_FUNCTION_TRACE(ev_gpe_dispatch); |
1da177e4 | 447 | |
5229e87d | 448 | acpi_os_gpe_count(gpe_number); |
fdffb72d | 449 | |
1da177e4 | 450 | /* |
9f15fc66 | 451 | * If edge-triggered, clear the GPE status bit now. Note that |
1da177e4 LT |
452 | * level-triggered events are cleared after the GPE is serviced. |
453 | */ | |
44f6c012 | 454 | if ((gpe_event_info->flags & ACPI_GPE_XRUPT_TYPE_MASK) == |
4be44fcd LB |
455 | ACPI_GPE_EDGE_TRIGGERED) { |
456 | status = acpi_hw_clear_gpe(gpe_event_info); | |
457 | if (ACPI_FAILURE(status)) { | |
b8e4d893 | 458 | ACPI_EXCEPTION((AE_INFO, status, |
f6a22b0b | 459 | "Unable to clear GPE[0x%2X]", |
b8e4d893 | 460 | gpe_number)); |
50eca3eb | 461 | return_UINT32(ACPI_INTERRUPT_NOT_HANDLED); |
1da177e4 LT |
462 | } |
463 | } | |
464 | ||
1da177e4 | 465 | /* |
c5a71569 BM |
466 | * Dispatch the GPE to either an installed handler, or the control method |
467 | * associated with this GPE (_Lxx or _Exx). If a handler exists, we invoke | |
468 | * it and do not attempt to run the method. If there is neither a handler | |
469 | * nor a method, we disable this GPE to prevent further such pointless | |
470 | * events from firing. | |
1da177e4 LT |
471 | */ |
472 | switch (gpe_event_info->flags & ACPI_GPE_DISPATCH_MASK) { | |
473 | case ACPI_GPE_DISPATCH_HANDLER: | |
474 | ||
475 | /* | |
476 | * Invoke the installed handler (at interrupt level) | |
9f15fc66 BM |
477 | * Ignore return status for now. |
478 | * TBD: leave GPE disabled on error? | |
1da177e4 | 479 | */ |
4be44fcd LB |
480 | (void)gpe_event_info->dispatch.handler->address(gpe_event_info-> |
481 | dispatch. | |
482 | handler-> | |
483 | context); | |
1da177e4 LT |
484 | |
485 | /* It is now safe to clear level-triggered events. */ | |
486 | ||
44f6c012 | 487 | if ((gpe_event_info->flags & ACPI_GPE_XRUPT_TYPE_MASK) == |
4be44fcd LB |
488 | ACPI_GPE_LEVEL_TRIGGERED) { |
489 | status = acpi_hw_clear_gpe(gpe_event_info); | |
490 | if (ACPI_FAILURE(status)) { | |
b8e4d893 | 491 | ACPI_EXCEPTION((AE_INFO, status, |
f6a22b0b | 492 | "Unable to clear GPE[0x%2X]", |
b8e4d893 | 493 | gpe_number)); |
50eca3eb | 494 | return_UINT32(ACPI_INTERRUPT_NOT_HANDLED); |
1da177e4 LT |
495 | } |
496 | } | |
497 | break; | |
498 | ||
499 | case ACPI_GPE_DISPATCH_METHOD: | |
500 | ||
501 | /* | |
c5a71569 BM |
502 | * Disable the GPE, so it doesn't keep firing before the method has a |
503 | * chance to run (it runs asynchronously with interrupts enabled). | |
1da177e4 | 504 | */ |
fd247447 | 505 | status = acpi_hw_low_set_gpe(gpe_event_info, ACPI_GPE_DISABLE); |
4be44fcd | 506 | if (ACPI_FAILURE(status)) { |
b8e4d893 | 507 | ACPI_EXCEPTION((AE_INFO, status, |
f6a22b0b | 508 | "Unable to disable GPE[0x%2X]", |
b8e4d893 | 509 | gpe_number)); |
50eca3eb | 510 | return_UINT32(ACPI_INTERRUPT_NOT_HANDLED); |
1da177e4 LT |
511 | } |
512 | ||
513 | /* | |
514 | * Execute the method associated with the GPE | |
515 | * NOTE: Level-triggered GPEs are cleared after the method completes. | |
516 | */ | |
958dd242 BM |
517 | status = acpi_os_execute(OSL_GPE_HANDLER, |
518 | acpi_ev_asynch_execute_gpe_method, | |
519 | gpe_event_info); | |
4be44fcd | 520 | if (ACPI_FAILURE(status)) { |
b8e4d893 | 521 | ACPI_EXCEPTION((AE_INFO, status, |
f6a22b0b | 522 | "Unable to queue handler for GPE[0x%2X] - event disabled", |
b8e4d893 | 523 | gpe_number)); |
1da177e4 LT |
524 | } |
525 | break; | |
526 | ||
527 | default: | |
528 | ||
0f849d2c LM |
529 | /* |
530 | * No handler or method to run! | |
531 | * 03/2010: This case should no longer be possible. We will not allow | |
532 | * a GPE to be enabled if it has no handler or method. | |
533 | */ | |
b8e4d893 | 534 | ACPI_ERROR((AE_INFO, |
f6a22b0b | 535 | "No handler or method for GPE[0x%2X], disabling event", |
b8e4d893 | 536 | gpe_number)); |
1da177e4 LT |
537 | |
538 | /* | |
0f849d2c LM |
539 | * Disable the GPE. The GPE will remain disabled a handler |
540 | * is installed or ACPICA is restarted. | |
1da177e4 | 541 | */ |
fd247447 | 542 | status = acpi_hw_low_set_gpe(gpe_event_info, ACPI_GPE_DISABLE); |
4be44fcd | 543 | if (ACPI_FAILURE(status)) { |
b8e4d893 | 544 | ACPI_EXCEPTION((AE_INFO, status, |
f6a22b0b | 545 | "Unable to disable GPE[0x%2X]", |
b8e4d893 | 546 | gpe_number)); |
50eca3eb | 547 | return_UINT32(ACPI_INTERRUPT_NOT_HANDLED); |
1da177e4 LT |
548 | } |
549 | break; | |
550 | } | |
551 | ||
50eca3eb | 552 | return_UINT32(ACPI_INTERRUPT_HANDLED); |
1da177e4 | 553 | } |