Pull lameter-rwsem-limit into release branch
[linux-2.6-block.git] / drivers / acpi / events / evgpe.c
CommitLineData
1da177e4
LT
1/******************************************************************************
2 *
3 * Module Name: evgpe - General Purpose Event handling and dispatch
4 *
5 *****************************************************************************/
6
7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore
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 <acpi/acevents.h>
46#include <acpi/acnamesp.h>
47
48#define _COMPONENT ACPI_EVENTS
49 ACPI_MODULE_NAME ("evgpe")
50
44f6c012
RM
51/* Local prototypes */
52
53static void ACPI_SYSTEM_XFACE
54acpi_ev_asynch_execute_gpe_method (
55 void *context);
56
1da177e4
LT
57
58/*******************************************************************************
59 *
60 * FUNCTION: acpi_ev_set_gpe_type
61 *
62 * PARAMETERS: gpe_event_info - GPE to set
63 * Type - New type
64 *
65 * RETURN: Status
66 *
67 * DESCRIPTION: Sets the new type for the GPE (wake, run, or wake/run)
68 *
69 ******************************************************************************/
70
71acpi_status
72acpi_ev_set_gpe_type (
73 struct acpi_gpe_event_info *gpe_event_info,
74 u8 type)
75{
76 acpi_status status;
77
78
79 ACPI_FUNCTION_TRACE ("ev_set_gpe_type");
80
81
82 /* Validate type and update register enable masks */
83
84 switch (type) {
85 case ACPI_GPE_TYPE_WAKE:
86 case ACPI_GPE_TYPE_RUNTIME:
87 case ACPI_GPE_TYPE_WAKE_RUN:
88 break;
89
90 default:
91 return_ACPI_STATUS (AE_BAD_PARAMETER);
92 }
93
94 /* Disable the GPE if currently enabled */
95
96 status = acpi_ev_disable_gpe (gpe_event_info);
97
98 /* Type was validated above */
99
100 gpe_event_info->flags &= ~ACPI_GPE_TYPE_MASK; /* Clear type bits */
101 gpe_event_info->flags |= type; /* Insert type */
102 return_ACPI_STATUS (status);
103}
104
105
106/*******************************************************************************
107 *
108 * FUNCTION: acpi_ev_update_gpe_enable_masks
109 *
110 * PARAMETERS: gpe_event_info - GPE to update
111 * Type - What to do: ACPI_GPE_DISABLE or
112 * ACPI_GPE_ENABLE
113 *
114 * RETURN: Status
115 *
116 * DESCRIPTION: Updates GPE register enable masks based on the GPE type
117 *
118 ******************************************************************************/
119
120acpi_status
121acpi_ev_update_gpe_enable_masks (
122 struct acpi_gpe_event_info *gpe_event_info,
123 u8 type)
124{
125 struct acpi_gpe_register_info *gpe_register_info;
126 u8 register_bit;
127
128
129 ACPI_FUNCTION_TRACE ("ev_update_gpe_enable_masks");
130
131
132 gpe_register_info = gpe_event_info->register_info;
133 if (!gpe_register_info) {
134 return_ACPI_STATUS (AE_NOT_EXIST);
135 }
136 register_bit = gpe_event_info->register_bit;
137
138 /* 1) Disable case. Simply clear all enable bits */
139
140 if (type == ACPI_GPE_DISABLE) {
141 ACPI_CLEAR_BIT (gpe_register_info->enable_for_wake, register_bit);
142 ACPI_CLEAR_BIT (gpe_register_info->enable_for_run, register_bit);
143 return_ACPI_STATUS (AE_OK);
144 }
145
146 /* 2) Enable case. Set/Clear the appropriate enable bits */
147
148 switch (gpe_event_info->flags & ACPI_GPE_TYPE_MASK) {
149 case ACPI_GPE_TYPE_WAKE:
150 ACPI_SET_BIT (gpe_register_info->enable_for_wake, register_bit);
151 ACPI_CLEAR_BIT (gpe_register_info->enable_for_run, register_bit);
152 break;
153
154 case ACPI_GPE_TYPE_RUNTIME:
155 ACPI_CLEAR_BIT (gpe_register_info->enable_for_wake, register_bit);
156 ACPI_SET_BIT (gpe_register_info->enable_for_run, register_bit);
157 break;
158
159 case ACPI_GPE_TYPE_WAKE_RUN:
160 ACPI_SET_BIT (gpe_register_info->enable_for_wake, register_bit);
161 ACPI_SET_BIT (gpe_register_info->enable_for_run, register_bit);
162 break;
163
164 default:
165 return_ACPI_STATUS (AE_BAD_PARAMETER);
166 }
167
168 return_ACPI_STATUS (AE_OK);
169}
170
171
172/*******************************************************************************
173 *
174 * FUNCTION: acpi_ev_enable_gpe
175 *
176 * PARAMETERS: gpe_event_info - GPE to enable
177 * write_to_hardware - Enable now, or just mark data structs
178 * (WAKE GPEs should be deferred)
179 *
180 * RETURN: Status
181 *
182 * DESCRIPTION: Enable a GPE based on the GPE type
183 *
184 ******************************************************************************/
185
186acpi_status
187acpi_ev_enable_gpe (
188 struct acpi_gpe_event_info *gpe_event_info,
189 u8 write_to_hardware)
190{
191 acpi_status status;
192
193
194 ACPI_FUNCTION_TRACE ("ev_enable_gpe");
195
196
197 /* Make sure HW enable masks are updated */
198
199 status = acpi_ev_update_gpe_enable_masks (gpe_event_info, ACPI_GPE_ENABLE);
200 if (ACPI_FAILURE (status)) {
201 return_ACPI_STATUS (status);
202 }
203
204 /* Mark wake-enabled or HW enable, or both */
205
206 switch (gpe_event_info->flags & ACPI_GPE_TYPE_MASK) {
207 case ACPI_GPE_TYPE_WAKE:
208
209 ACPI_SET_BIT (gpe_event_info->flags, ACPI_GPE_WAKE_ENABLED);
210 break;
211
212 case ACPI_GPE_TYPE_WAKE_RUN:
213
214 ACPI_SET_BIT (gpe_event_info->flags, ACPI_GPE_WAKE_ENABLED);
215
216 /*lint -fallthrough */
217
218 case ACPI_GPE_TYPE_RUNTIME:
219
220 ACPI_SET_BIT (gpe_event_info->flags, ACPI_GPE_RUN_ENABLED);
221
222 if (write_to_hardware) {
223 /* Clear the GPE (of stale events), then enable it */
224
225 status = acpi_hw_clear_gpe (gpe_event_info);
226 if (ACPI_FAILURE (status)) {
227 return_ACPI_STATUS (status);
228 }
229
230 /* Enable the requested runtime GPE */
231
232 status = acpi_hw_write_gpe_enable_reg (gpe_event_info);
233 }
234 break;
235
236 default:
237 return_ACPI_STATUS (AE_BAD_PARAMETER);
238 }
239
240 return_ACPI_STATUS (AE_OK);
241}
242
243
244/*******************************************************************************
245 *
246 * FUNCTION: acpi_ev_disable_gpe
247 *
248 * PARAMETERS: gpe_event_info - GPE to disable
249 *
250 * RETURN: Status
251 *
252 * DESCRIPTION: Disable a GPE based on the GPE type
253 *
254 ******************************************************************************/
255
256acpi_status
257acpi_ev_disable_gpe (
258 struct acpi_gpe_event_info *gpe_event_info)
259{
260 acpi_status status;
261
262
263 ACPI_FUNCTION_TRACE ("ev_disable_gpe");
264
265
266 if (!(gpe_event_info->flags & ACPI_GPE_ENABLE_MASK)) {
267 return_ACPI_STATUS (AE_OK);
268 }
269
270 /* Make sure HW enable masks are updated */
271
272 status = acpi_ev_update_gpe_enable_masks (gpe_event_info, ACPI_GPE_DISABLE);
273 if (ACPI_FAILURE (status)) {
274 return_ACPI_STATUS (status);
275 }
276
277 /* Mark wake-disabled or HW disable, or both */
278
279 switch (gpe_event_info->flags & ACPI_GPE_TYPE_MASK) {
280 case ACPI_GPE_TYPE_WAKE:
281 ACPI_CLEAR_BIT (gpe_event_info->flags, ACPI_GPE_WAKE_ENABLED);
282 break;
283
284 case ACPI_GPE_TYPE_WAKE_RUN:
285 ACPI_CLEAR_BIT (gpe_event_info->flags, ACPI_GPE_WAKE_ENABLED);
286
287 /*lint -fallthrough */
288
289 case ACPI_GPE_TYPE_RUNTIME:
290
291 /* Disable the requested runtime GPE */
292
293 ACPI_CLEAR_BIT (gpe_event_info->flags, ACPI_GPE_RUN_ENABLED);
294 status = acpi_hw_write_gpe_enable_reg (gpe_event_info);
295 break;
296
297 default:
298 return_ACPI_STATUS (AE_BAD_PARAMETER);
299 }
300
301 return_ACPI_STATUS (AE_OK);
302}
303
304
305/*******************************************************************************
306 *
307 * FUNCTION: acpi_ev_get_gpe_event_info
308 *
309 * PARAMETERS: gpe_device - Device node. NULL for GPE0/GPE1
310 * gpe_number - Raw GPE number
311 *
312 * RETURN: A GPE event_info struct. NULL if not a valid GPE
313 *
314 * DESCRIPTION: Returns the event_info struct associated with this GPE.
315 * Validates the gpe_block and the gpe_number
316 *
317 * Should be called only when the GPE lists are semaphore locked
318 * and not subject to change.
319 *
320 ******************************************************************************/
321
322struct acpi_gpe_event_info *
323acpi_ev_get_gpe_event_info (
324 acpi_handle gpe_device,
325 u32 gpe_number)
326{
327 union acpi_operand_object *obj_desc;
328 struct acpi_gpe_block_info *gpe_block;
329 acpi_native_uint i;
330
331
332 ACPI_FUNCTION_ENTRY ();
333
334
335 /* A NULL gpe_block means use the FADT-defined GPE block(s) */
336
337 if (!gpe_device) {
338 /* Examine GPE Block 0 and 1 (These blocks are permanent) */
339
340 for (i = 0; i < ACPI_MAX_GPE_BLOCKS; i++) {
341 gpe_block = acpi_gbl_gpe_fadt_blocks[i];
342 if (gpe_block) {
343 if ((gpe_number >= gpe_block->block_base_number) &&
44f6c012
RM
344 (gpe_number < gpe_block->block_base_number +
345 (gpe_block->register_count * 8))) {
346 return (&gpe_block->event_info[gpe_number -
347 gpe_block->block_base_number]);
1da177e4
LT
348 }
349 }
350 }
351
352 /* The gpe_number was not in the range of either FADT GPE block */
353
354 return (NULL);
355 }
356
357 /* A Non-NULL gpe_device means this is a GPE Block Device */
358
359 obj_desc = acpi_ns_get_attached_object ((struct acpi_namespace_node *) gpe_device);
360 if (!obj_desc ||
361 !obj_desc->device.gpe_block) {
362 return (NULL);
363 }
364
365 gpe_block = obj_desc->device.gpe_block;
366
367 if ((gpe_number >= gpe_block->block_base_number) &&
368 (gpe_number < gpe_block->block_base_number + (gpe_block->register_count * 8))) {
369 return (&gpe_block->event_info[gpe_number - gpe_block->block_base_number]);
370 }
371
372 return (NULL);
373}
374
375
376/*******************************************************************************
377 *
378 * FUNCTION: acpi_ev_gpe_detect
379 *
380 * PARAMETERS: gpe_xrupt_list - Interrupt block for this interrupt.
381 * Can have multiple GPE blocks attached.
382 *
383 * RETURN: INTERRUPT_HANDLED or INTERRUPT_NOT_HANDLED
384 *
385 * DESCRIPTION: Detect if any GP events have occurred. This function is
386 * executed at interrupt level.
387 *
388 ******************************************************************************/
389
390u32
391acpi_ev_gpe_detect (
392 struct acpi_gpe_xrupt_info *gpe_xrupt_list)
393{
394 u32 int_status = ACPI_INTERRUPT_NOT_HANDLED;
395 u8 enabled_status_byte;
396 struct acpi_gpe_register_info *gpe_register_info;
397 u32 status_reg;
398 u32 enable_reg;
399 acpi_status status;
400 struct acpi_gpe_block_info *gpe_block;
401 acpi_native_uint i;
402 acpi_native_uint j;
403
404
405 ACPI_FUNCTION_NAME ("ev_gpe_detect");
406
407 /* Check for the case where there are no GPEs */
408
409 if (!gpe_xrupt_list) {
410 return (int_status);
411 }
412
413 /* Examine all GPE blocks attached to this interrupt level */
414
415 acpi_os_acquire_lock (acpi_gbl_gpe_lock, ACPI_ISR);
416 gpe_block = gpe_xrupt_list->gpe_block_list_head;
417 while (gpe_block) {
418 /*
419 * Read all of the 8-bit GPE status and enable registers
420 * in this GPE block, saving all of them.
421 * Find all currently active GP events.
422 */
423 for (i = 0; i < gpe_block->register_count; i++) {
424 /* Get the next status/enable pair */
425
426 gpe_register_info = &gpe_block->register_info[i];
427
428 /* Read the Status Register */
429
430 status = acpi_hw_low_level_read (ACPI_GPE_REGISTER_WIDTH, &status_reg,
431 &gpe_register_info->status_address);
432 if (ACPI_FAILURE (status)) {
433 goto unlock_and_exit;
434 }
435
436 /* Read the Enable Register */
437
438 status = acpi_hw_low_level_read (ACPI_GPE_REGISTER_WIDTH, &enable_reg,
439 &gpe_register_info->enable_address);
440 if (ACPI_FAILURE (status)) {
441 goto unlock_and_exit;
442 }
443
444 ACPI_DEBUG_PRINT ((ACPI_DB_INTERRUPTS,
445 "Read GPE Register at GPE%X: Status=%02X, Enable=%02X\n",
446 gpe_register_info->base_gpe_number, status_reg, enable_reg));
447
44f6c012 448 /* Check if there is anything active at all in this register */
1da177e4
LT
449
450 enabled_status_byte = (u8) (status_reg & enable_reg);
451 if (!enabled_status_byte) {
452 /* No active GPEs in this register, move on */
453
454 continue;
455 }
456
457 /* Now look at the individual GPEs in this byte register */
458
459 for (j = 0; j < ACPI_GPE_REGISTER_WIDTH; j++) {
460 /* Examine one GPE bit */
461
462 if (enabled_status_byte & acpi_gbl_decode_to8bit[j]) {
463 /*
464 * Found an active GPE. Dispatch the event to a handler
465 * or method.
466 */
467 int_status |= acpi_ev_gpe_dispatch (
44f6c012
RM
468 &gpe_block->event_info[(i * ACPI_GPE_REGISTER_WIDTH) + j],
469 (u32) j + gpe_register_info->base_gpe_number);
1da177e4
LT
470 }
471 }
472 }
473
474 gpe_block = gpe_block->next;
475 }
476
477unlock_and_exit:
478
479 acpi_os_release_lock (acpi_gbl_gpe_lock, ACPI_ISR);
480 return (int_status);
481}
482
483
484/*******************************************************************************
485 *
486 * FUNCTION: acpi_ev_asynch_execute_gpe_method
487 *
488 * PARAMETERS: Context (gpe_event_info) - Info for this GPE
489 *
490 * RETURN: None
491 *
492 * DESCRIPTION: Perform the actual execution of a GPE control method. This
493 * function is called from an invocation of acpi_os_queue_for_execution
494 * (and therefore does NOT execute at interrupt level) so that
495 * the control method itself is not executed in the context of
496 * an interrupt handler.
497 *
498 ******************************************************************************/
499
500static void ACPI_SYSTEM_XFACE
501acpi_ev_asynch_execute_gpe_method (
502 void *context)
503{
504 struct acpi_gpe_event_info *gpe_event_info = (void *) context;
505 u32 gpe_number = 0;
506 acpi_status status;
507 struct acpi_gpe_event_info local_gpe_event_info;
508 struct acpi_parameter_info info;
509
510
511 ACPI_FUNCTION_TRACE ("ev_asynch_execute_gpe_method");
512
513
514 status = acpi_ut_acquire_mutex (ACPI_MTX_EVENTS);
515 if (ACPI_FAILURE (status)) {
516 return_VOID;
517 }
518
519 /* Must revalidate the gpe_number/gpe_block */
520
521 if (!acpi_ev_valid_gpe_event (gpe_event_info)) {
522 status = acpi_ut_release_mutex (ACPI_MTX_EVENTS);
523 return_VOID;
524 }
525
526 /* Set the GPE flags for return to enabled state */
527
528 (void) acpi_ev_enable_gpe (gpe_event_info, FALSE);
529
530 /*
531 * Take a snapshot of the GPE info for this level - we copy the
532 * info to prevent a race condition with remove_handler/remove_block.
533 */
44f6c012
RM
534 ACPI_MEMCPY (&local_gpe_event_info, gpe_event_info,
535 sizeof (struct acpi_gpe_event_info));
1da177e4
LT
536
537 status = acpi_ut_release_mutex (ACPI_MTX_EVENTS);
538 if (ACPI_FAILURE (status)) {
539 return_VOID;
540 }
541
542 /*
543 * Must check for control method type dispatch one more
544 * time to avoid race with ev_gpe_install_handler
545 */
44f6c012
RM
546 if ((local_gpe_event_info.flags & ACPI_GPE_DISPATCH_MASK) ==
547 ACPI_GPE_DISPATCH_METHOD) {
1da177e4
LT
548 /*
549 * Invoke the GPE Method (_Lxx, _Exx) i.e., evaluate the _Lxx/_Exx
550 * control method that corresponds to this GPE
551 */
552 info.node = local_gpe_event_info.dispatch.method_node;
553 info.parameters = ACPI_CAST_PTR (union acpi_operand_object *, gpe_event_info);
554 info.parameter_type = ACPI_PARAM_GPE;
555
556 status = acpi_ns_evaluate_by_handle (&info);
557 if (ACPI_FAILURE (status)) {
558 ACPI_REPORT_ERROR ((
559 "%s while evaluating method [%4.4s] for GPE[%2X]\n",
560 acpi_format_exception (status),
561 acpi_ut_get_node_name (local_gpe_event_info.dispatch.method_node),
562 gpe_number));
563 }
564 }
565
44f6c012
RM
566 if ((local_gpe_event_info.flags & ACPI_GPE_XRUPT_TYPE_MASK) ==
567 ACPI_GPE_LEVEL_TRIGGERED) {
1da177e4
LT
568 /*
569 * GPE is level-triggered, we clear the GPE status bit after
570 * handling the event.
571 */
572 status = acpi_hw_clear_gpe (&local_gpe_event_info);
573 if (ACPI_FAILURE (status)) {
574 return_VOID;
575 }
576 }
577
578 /* Enable this GPE */
579
580 (void) acpi_hw_write_gpe_enable_reg (&local_gpe_event_info);
581 return_VOID;
582}
583
584
585/*******************************************************************************
586 *
587 * FUNCTION: acpi_ev_gpe_dispatch
588 *
44f6c012 589 * PARAMETERS: gpe_event_info - Info for this GPE
1da177e4
LT
590 * gpe_number - Number relative to the parent GPE block
591 *
592 * RETURN: INTERRUPT_HANDLED or INTERRUPT_NOT_HANDLED
593 *
594 * DESCRIPTION: Dispatch a General Purpose Event to either a function (e.g. EC)
595 * or method (e.g. _Lxx/_Exx) handler.
596 *
597 * This function executes at interrupt level.
598 *
599 ******************************************************************************/
600
601u32
602acpi_ev_gpe_dispatch (
603 struct acpi_gpe_event_info *gpe_event_info,
604 u32 gpe_number)
605{
606 acpi_status status;
607
608
609 ACPI_FUNCTION_TRACE ("ev_gpe_dispatch");
610
611
612 /*
613 * If edge-triggered, clear the GPE status bit now. Note that
614 * level-triggered events are cleared after the GPE is serviced.
615 */
44f6c012
RM
616 if ((gpe_event_info->flags & ACPI_GPE_XRUPT_TYPE_MASK) ==
617 ACPI_GPE_EDGE_TRIGGERED) {
1da177e4
LT
618 status = acpi_hw_clear_gpe (gpe_event_info);
619 if (ACPI_FAILURE (status)) {
44f6c012
RM
620 ACPI_REPORT_ERROR ((
621 "acpi_ev_gpe_dispatch: %s, Unable to clear GPE[%2X]\n",
1da177e4
LT
622 acpi_format_exception (status), gpe_number));
623 return_VALUE (ACPI_INTERRUPT_NOT_HANDLED);
624 }
625 }
626
627 /* Save current system state */
628
629 if (acpi_gbl_system_awake_and_running) {
630 ACPI_SET_BIT (gpe_event_info->flags, ACPI_GPE_SYSTEM_RUNNING);
631 }
632 else {
633 ACPI_CLEAR_BIT (gpe_event_info->flags, ACPI_GPE_SYSTEM_RUNNING);
634 }
635
636 /*
637 * Dispatch the GPE to either an installed handler, or the control
638 * method associated with this GPE (_Lxx or _Exx).
639 * If a handler exists, we invoke it and do not attempt to run the method.
640 * If there is neither a handler nor a method, we disable the level to
641 * prevent further events from coming in here.
642 */
643 switch (gpe_event_info->flags & ACPI_GPE_DISPATCH_MASK) {
644 case ACPI_GPE_DISPATCH_HANDLER:
645
646 /*
647 * Invoke the installed handler (at interrupt level)
648 * Ignore return status for now. TBD: leave GPE disabled on error?
649 */
650 (void) gpe_event_info->dispatch.handler->address (
651 gpe_event_info->dispatch.handler->context);
652
653 /* It is now safe to clear level-triggered events. */
654
44f6c012
RM
655 if ((gpe_event_info->flags & ACPI_GPE_XRUPT_TYPE_MASK) ==
656 ACPI_GPE_LEVEL_TRIGGERED) {
1da177e4
LT
657 status = acpi_hw_clear_gpe (gpe_event_info);
658 if (ACPI_FAILURE (status)) {
659 ACPI_REPORT_ERROR ((
660 "acpi_ev_gpe_dispatch: %s, Unable to clear GPE[%2X]\n",
661 acpi_format_exception (status), gpe_number));
662 return_VALUE (ACPI_INTERRUPT_NOT_HANDLED);
663 }
664 }
665 break;
666
667 case ACPI_GPE_DISPATCH_METHOD:
668
669 /*
670 * Disable GPE, so it doesn't keep firing before the method has a
671 * chance to run.
672 */
673 status = acpi_ev_disable_gpe (gpe_event_info);
674 if (ACPI_FAILURE (status)) {
675 ACPI_REPORT_ERROR ((
676 "acpi_ev_gpe_dispatch: %s, Unable to disable GPE[%2X]\n",
677 acpi_format_exception (status), gpe_number));
678 return_VALUE (ACPI_INTERRUPT_NOT_HANDLED);
679 }
680
681 /*
682 * Execute the method associated with the GPE
683 * NOTE: Level-triggered GPEs are cleared after the method completes.
684 */
685 status = acpi_os_queue_for_execution (OSD_PRIORITY_GPE,
686 acpi_ev_asynch_execute_gpe_method, gpe_event_info);
687 if (ACPI_FAILURE (status)) {
688 ACPI_REPORT_ERROR ((
689 "acpi_ev_gpe_dispatch: %s, Unable to queue handler for GPE[%2X] - event disabled\n",
690 acpi_format_exception (status), gpe_number));
691 }
692 break;
693
694 default:
695
696 /* No handler or method to run! */
697
698 ACPI_REPORT_ERROR ((
699 "acpi_ev_gpe_dispatch: No handler or method for GPE[%2X], disabling event\n",
700 gpe_number));
701
702 /*
703 * Disable the GPE. The GPE will remain disabled until the ACPI
704 * Core Subsystem is restarted, or a handler is installed.
705 */
706 status = acpi_ev_disable_gpe (gpe_event_info);
707 if (ACPI_FAILURE (status)) {
708 ACPI_REPORT_ERROR ((
709 "acpi_ev_gpe_dispatch: %s, Unable to disable GPE[%2X]\n",
710 acpi_format_exception (status), gpe_number));
711 return_VALUE (ACPI_INTERRUPT_NOT_HANDLED);
712 }
713 break;
714 }
715
716 return_VALUE (ACPI_INTERRUPT_HANDLED);
717}
718
719
720#ifdef ACPI_GPE_NOTIFY_CHECK
1da177e4
LT
721/*******************************************************************************
722 * TBD: NOT USED, PROTOTYPE ONLY AND WILL PROBABLY BE REMOVED
723 *
724 * FUNCTION: acpi_ev_check_for_wake_only_gpe
725 *
726 * PARAMETERS: gpe_event_info - info for this GPE
727 *
728 * RETURN: Status
729 *
730 * DESCRIPTION: Determine if a a GPE is "wake-only".
731 *
732 * Called from Notify() code in interpreter when a "device_wake"
733 * Notify comes in.
734 *
735 ******************************************************************************/
736
737acpi_status
738acpi_ev_check_for_wake_only_gpe (
739 struct acpi_gpe_event_info *gpe_event_info)
740{
741 acpi_status status;
742
743
744 ACPI_FUNCTION_TRACE ("ev_check_for_wake_only_gpe");
745
746
747 if ((gpe_event_info) && /* Only >0 for _Lxx/_Exx */
748 ((gpe_event_info->flags & ACPI_GPE_SYSTEM_MASK) == ACPI_GPE_SYSTEM_RUNNING)) /* System state at GPE time */ {
749 /* This must be a wake-only GPE, disable it */
750
751 status = acpi_ev_disable_gpe (gpe_event_info);
752
753 /* Set GPE to wake-only. Do not change wake disabled/enabled status */
754
755 acpi_ev_set_gpe_type (gpe_event_info, ACPI_GPE_TYPE_WAKE);
756
757 ACPI_REPORT_INFO (("GPE %p was updated from wake/run to wake-only\n",
758 gpe_event_info));
759
760 /* This was a wake-only GPE */
761
762 return_ACPI_STATUS (AE_WAKE_ONLY_GPE);
763 }
764
765 return_ACPI_STATUS (AE_OK);
766}
767#endif
768
769