diff options
Diffstat (limited to 'drivers/acpi/acpica/evgpeblk.c')
-rw-r--r-- | drivers/acpi/acpica/evgpeblk.c | 766 |
1 files changed, 51 insertions, 715 deletions
diff --git a/drivers/acpi/acpica/evgpeblk.c b/drivers/acpi/acpica/evgpeblk.c index fef721917ea..7c28f2d9fd3 100644 --- a/drivers/acpi/acpica/evgpeblk.c +++ b/drivers/acpi/acpica/evgpeblk.c | |||
@@ -51,20 +51,6 @@ ACPI_MODULE_NAME("evgpeblk") | |||
51 | 51 | ||
52 | /* Local prototypes */ | 52 | /* Local prototypes */ |
53 | static acpi_status | 53 | static acpi_status |
54 | acpi_ev_save_method_info(acpi_handle obj_handle, | ||
55 | u32 level, void *obj_desc, void **return_value); | ||
56 | |||
57 | static acpi_status | ||
58 | acpi_ev_match_prw_and_gpe(acpi_handle obj_handle, | ||
59 | u32 level, void *info, void **return_value); | ||
60 | |||
61 | static struct acpi_gpe_xrupt_info *acpi_ev_get_gpe_xrupt_block(u32 | ||
62 | interrupt_number); | ||
63 | |||
64 | static acpi_status | ||
65 | acpi_ev_delete_gpe_xrupt(struct acpi_gpe_xrupt_info *gpe_xrupt); | ||
66 | |||
67 | static acpi_status | ||
68 | acpi_ev_install_gpe_block(struct acpi_gpe_block_info *gpe_block, | 54 | acpi_ev_install_gpe_block(struct acpi_gpe_block_info *gpe_block, |
69 | u32 interrupt_number); | 55 | u32 interrupt_number); |
70 | 56 | ||
@@ -73,527 +59,6 @@ acpi_ev_create_gpe_info_blocks(struct acpi_gpe_block_info *gpe_block); | |||
73 | 59 | ||
74 | /******************************************************************************* | 60 | /******************************************************************************* |
75 | * | 61 | * |
76 | * FUNCTION: acpi_ev_valid_gpe_event | ||
77 | * | ||
78 | * PARAMETERS: gpe_event_info - Info for this GPE | ||
79 | * | ||
80 | * RETURN: TRUE if the gpe_event is valid | ||
81 | * | ||
82 | * DESCRIPTION: Validate a GPE event. DO NOT CALL FROM INTERRUPT LEVEL. | ||
83 | * Should be called only when the GPE lists are semaphore locked | ||
84 | * and not subject to change. | ||
85 | * | ||
86 | ******************************************************************************/ | ||
87 | |||
88 | u8 acpi_ev_valid_gpe_event(struct acpi_gpe_event_info *gpe_event_info) | ||
89 | { | ||
90 | struct acpi_gpe_xrupt_info *gpe_xrupt_block; | ||
91 | struct acpi_gpe_block_info *gpe_block; | ||
92 | |||
93 | ACPI_FUNCTION_ENTRY(); | ||
94 | |||
95 | /* No need for spin lock since we are not changing any list elements */ | ||
96 | |||
97 | /* Walk the GPE interrupt levels */ | ||
98 | |||
99 | gpe_xrupt_block = acpi_gbl_gpe_xrupt_list_head; | ||
100 | while (gpe_xrupt_block) { | ||
101 | gpe_block = gpe_xrupt_block->gpe_block_list_head; | ||
102 | |||
103 | /* Walk the GPE blocks on this interrupt level */ | ||
104 | |||
105 | while (gpe_block) { | ||
106 | if ((&gpe_block->event_info[0] <= gpe_event_info) && | ||
107 | (&gpe_block->event_info[((acpi_size) | ||
108 | gpe_block-> | ||
109 | register_count) * 8] > | ||
110 | gpe_event_info)) { | ||
111 | return (TRUE); | ||
112 | } | ||
113 | |||
114 | gpe_block = gpe_block->next; | ||
115 | } | ||
116 | |||
117 | gpe_xrupt_block = gpe_xrupt_block->next; | ||
118 | } | ||
119 | |||
120 | return (FALSE); | ||
121 | } | ||
122 | |||
123 | /******************************************************************************* | ||
124 | * | ||
125 | * FUNCTION: acpi_ev_walk_gpe_list | ||
126 | * | ||
127 | * PARAMETERS: gpe_walk_callback - Routine called for each GPE block | ||
128 | * Context - Value passed to callback | ||
129 | * | ||
130 | * RETURN: Status | ||
131 | * | ||
132 | * DESCRIPTION: Walk the GPE lists. | ||
133 | * | ||
134 | ******************************************************************************/ | ||
135 | |||
136 | acpi_status | ||
137 | acpi_ev_walk_gpe_list(acpi_gpe_callback gpe_walk_callback, void *context) | ||
138 | { | ||
139 | struct acpi_gpe_block_info *gpe_block; | ||
140 | struct acpi_gpe_xrupt_info *gpe_xrupt_info; | ||
141 | acpi_status status = AE_OK; | ||
142 | acpi_cpu_flags flags; | ||
143 | |||
144 | ACPI_FUNCTION_TRACE(ev_walk_gpe_list); | ||
145 | |||
146 | flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock); | ||
147 | |||
148 | /* Walk the interrupt level descriptor list */ | ||
149 | |||
150 | gpe_xrupt_info = acpi_gbl_gpe_xrupt_list_head; | ||
151 | while (gpe_xrupt_info) { | ||
152 | |||
153 | /* Walk all Gpe Blocks attached to this interrupt level */ | ||
154 | |||
155 | gpe_block = gpe_xrupt_info->gpe_block_list_head; | ||
156 | while (gpe_block) { | ||
157 | |||
158 | /* One callback per GPE block */ | ||
159 | |||
160 | status = | ||
161 | gpe_walk_callback(gpe_xrupt_info, gpe_block, | ||
162 | context); | ||
163 | if (ACPI_FAILURE(status)) { | ||
164 | if (status == AE_CTRL_END) { /* Callback abort */ | ||
165 | status = AE_OK; | ||
166 | } | ||
167 | goto unlock_and_exit; | ||
168 | } | ||
169 | |||
170 | gpe_block = gpe_block->next; | ||
171 | } | ||
172 | |||
173 | gpe_xrupt_info = gpe_xrupt_info->next; | ||
174 | } | ||
175 | |||
176 | unlock_and_exit: | ||
177 | acpi_os_release_lock(acpi_gbl_gpe_lock, flags); | ||
178 | return_ACPI_STATUS(status); | ||
179 | } | ||
180 | |||
181 | /******************************************************************************* | ||
182 | * | ||
183 | * FUNCTION: acpi_ev_delete_gpe_handlers | ||
184 | * | ||
185 | * PARAMETERS: gpe_xrupt_info - GPE Interrupt info | ||
186 | * gpe_block - Gpe Block info | ||
187 | * | ||
188 | * RETURN: Status | ||
189 | * | ||
190 | * DESCRIPTION: Delete all Handler objects found in the GPE data structs. | ||
191 | * Used only prior to termination. | ||
192 | * | ||
193 | ******************************************************************************/ | ||
194 | |||
195 | acpi_status | ||
196 | acpi_ev_delete_gpe_handlers(struct acpi_gpe_xrupt_info *gpe_xrupt_info, | ||
197 | struct acpi_gpe_block_info *gpe_block, | ||
198 | void *context) | ||
199 | { | ||
200 | struct acpi_gpe_event_info *gpe_event_info; | ||
201 | u32 i; | ||
202 | u32 j; | ||
203 | |||
204 | ACPI_FUNCTION_TRACE(ev_delete_gpe_handlers); | ||
205 | |||
206 | /* Examine each GPE Register within the block */ | ||
207 | |||
208 | for (i = 0; i < gpe_block->register_count; i++) { | ||
209 | |||
210 | /* Now look at the individual GPEs in this byte register */ | ||
211 | |||
212 | for (j = 0; j < ACPI_GPE_REGISTER_WIDTH; j++) { | ||
213 | gpe_event_info = &gpe_block->event_info[((acpi_size) i * | ||
214 | ACPI_GPE_REGISTER_WIDTH) | ||
215 | + j]; | ||
216 | |||
217 | if ((gpe_event_info->flags & ACPI_GPE_DISPATCH_MASK) == | ||
218 | ACPI_GPE_DISPATCH_HANDLER) { | ||
219 | ACPI_FREE(gpe_event_info->dispatch.handler); | ||
220 | gpe_event_info->dispatch.handler = NULL; | ||
221 | gpe_event_info->flags &= | ||
222 | ~ACPI_GPE_DISPATCH_MASK; | ||
223 | } | ||
224 | } | ||
225 | } | ||
226 | |||
227 | return_ACPI_STATUS(AE_OK); | ||
228 | } | ||
229 | |||
230 | /******************************************************************************* | ||
231 | * | ||
232 | * FUNCTION: acpi_ev_save_method_info | ||
233 | * | ||
234 | * PARAMETERS: Callback from walk_namespace | ||
235 | * | ||
236 | * RETURN: Status | ||
237 | * | ||
238 | * DESCRIPTION: Called from acpi_walk_namespace. Expects each object to be a | ||
239 | * control method under the _GPE portion of the namespace. | ||
240 | * Extract the name and GPE type from the object, saving this | ||
241 | * information for quick lookup during GPE dispatch | ||
242 | * | ||
243 | * The name of each GPE control method is of the form: | ||
244 | * "_Lxx" or "_Exx" | ||
245 | * Where: | ||
246 | * L - means that the GPE is level triggered | ||
247 | * E - means that the GPE is edge triggered | ||
248 | * xx - is the GPE number [in HEX] | ||
249 | * | ||
250 | ******************************************************************************/ | ||
251 | |||
252 | static acpi_status | ||
253 | acpi_ev_save_method_info(acpi_handle obj_handle, | ||
254 | u32 level, void *obj_desc, void **return_value) | ||
255 | { | ||
256 | struct acpi_gpe_block_info *gpe_block = (void *)obj_desc; | ||
257 | struct acpi_gpe_event_info *gpe_event_info; | ||
258 | u32 gpe_number; | ||
259 | char name[ACPI_NAME_SIZE + 1]; | ||
260 | u8 type; | ||
261 | |||
262 | ACPI_FUNCTION_TRACE(ev_save_method_info); | ||
263 | |||
264 | /* | ||
265 | * _Lxx and _Exx GPE method support | ||
266 | * | ||
267 | * 1) Extract the name from the object and convert to a string | ||
268 | */ | ||
269 | ACPI_MOVE_32_TO_32(name, | ||
270 | &((struct acpi_namespace_node *)obj_handle)->name. | ||
271 | integer); | ||
272 | name[ACPI_NAME_SIZE] = 0; | ||
273 | |||
274 | /* | ||
275 | * 2) Edge/Level determination is based on the 2nd character | ||
276 | * of the method name | ||
277 | * | ||
278 | * NOTE: Default GPE type is RUNTIME. May be changed later to WAKE | ||
279 | * if a _PRW object is found that points to this GPE. | ||
280 | */ | ||
281 | switch (name[1]) { | ||
282 | case 'L': | ||
283 | type = ACPI_GPE_LEVEL_TRIGGERED; | ||
284 | break; | ||
285 | |||
286 | case 'E': | ||
287 | type = ACPI_GPE_EDGE_TRIGGERED; | ||
288 | break; | ||
289 | |||
290 | default: | ||
291 | /* Unknown method type, just ignore it! */ | ||
292 | |||
293 | ACPI_DEBUG_PRINT((ACPI_DB_LOAD, | ||
294 | "Ignoring unknown GPE method type: %s " | ||
295 | "(name not of form _Lxx or _Exx)", name)); | ||
296 | return_ACPI_STATUS(AE_OK); | ||
297 | } | ||
298 | |||
299 | /* Convert the last two characters of the name to the GPE Number */ | ||
300 | |||
301 | gpe_number = ACPI_STRTOUL(&name[2], NULL, 16); | ||
302 | if (gpe_number == ACPI_UINT32_MAX) { | ||
303 | |||
304 | /* Conversion failed; invalid method, just ignore it */ | ||
305 | |||
306 | ACPI_DEBUG_PRINT((ACPI_DB_LOAD, | ||
307 | "Could not extract GPE number from name: %s " | ||
308 | "(name is not of form _Lxx or _Exx)", name)); | ||
309 | return_ACPI_STATUS(AE_OK); | ||
310 | } | ||
311 | |||
312 | /* Ensure that we have a valid GPE number for this GPE block */ | ||
313 | |||
314 | if ((gpe_number < gpe_block->block_base_number) || | ||
315 | (gpe_number >= (gpe_block->block_base_number + | ||
316 | (gpe_block->register_count * 8)))) { | ||
317 | /* | ||
318 | * Not valid for this GPE block, just ignore it. However, it may be | ||
319 | * valid for a different GPE block, since GPE0 and GPE1 methods both | ||
320 | * appear under \_GPE. | ||
321 | */ | ||
322 | return_ACPI_STATUS(AE_OK); | ||
323 | } | ||
324 | |||
325 | /* | ||
326 | * Now we can add this information to the gpe_event_info block for use | ||
327 | * during dispatch of this GPE. | ||
328 | */ | ||
329 | gpe_event_info = | ||
330 | &gpe_block->event_info[gpe_number - gpe_block->block_base_number]; | ||
331 | |||
332 | gpe_event_info->flags = (u8) (type | ACPI_GPE_DISPATCH_METHOD); | ||
333 | |||
334 | gpe_event_info->dispatch.method_node = | ||
335 | (struct acpi_namespace_node *)obj_handle; | ||
336 | |||
337 | ACPI_DEBUG_PRINT((ACPI_DB_LOAD, | ||
338 | "Registered GPE method %s as GPE number 0x%.2X\n", | ||
339 | name, gpe_number)); | ||
340 | return_ACPI_STATUS(AE_OK); | ||
341 | } | ||
342 | |||
343 | /******************************************************************************* | ||
344 | * | ||
345 | * FUNCTION: acpi_ev_match_prw_and_gpe | ||
346 | * | ||
347 | * PARAMETERS: Callback from walk_namespace | ||
348 | * | ||
349 | * RETURN: Status. NOTE: We ignore errors so that the _PRW walk is | ||
350 | * not aborted on a single _PRW failure. | ||
351 | * | ||
352 | * DESCRIPTION: Called from acpi_walk_namespace. Expects each object to be a | ||
353 | * Device. Run the _PRW method. If present, extract the GPE | ||
354 | * number and mark the GPE as a WAKE GPE. | ||
355 | * | ||
356 | ******************************************************************************/ | ||
357 | |||
358 | static acpi_status | ||
359 | acpi_ev_match_prw_and_gpe(acpi_handle obj_handle, | ||
360 | u32 level, void *info, void **return_value) | ||
361 | { | ||
362 | struct acpi_gpe_walk_info *gpe_info = (void *)info; | ||
363 | struct acpi_namespace_node *gpe_device; | ||
364 | struct acpi_gpe_block_info *gpe_block; | ||
365 | struct acpi_namespace_node *target_gpe_device; | ||
366 | struct acpi_gpe_event_info *gpe_event_info; | ||
367 | union acpi_operand_object *pkg_desc; | ||
368 | union acpi_operand_object *obj_desc; | ||
369 | u32 gpe_number; | ||
370 | acpi_status status; | ||
371 | |||
372 | ACPI_FUNCTION_TRACE(ev_match_prw_and_gpe); | ||
373 | |||
374 | /* Check for a _PRW method under this device */ | ||
375 | |||
376 | status = acpi_ut_evaluate_object(obj_handle, METHOD_NAME__PRW, | ||
377 | ACPI_BTYPE_PACKAGE, &pkg_desc); | ||
378 | if (ACPI_FAILURE(status)) { | ||
379 | |||
380 | /* Ignore all errors from _PRW, we don't want to abort the subsystem */ | ||
381 | |||
382 | return_ACPI_STATUS(AE_OK); | ||
383 | } | ||
384 | |||
385 | /* The returned _PRW package must have at least two elements */ | ||
386 | |||
387 | if (pkg_desc->package.count < 2) { | ||
388 | goto cleanup; | ||
389 | } | ||
390 | |||
391 | /* Extract pointers from the input context */ | ||
392 | |||
393 | gpe_device = gpe_info->gpe_device; | ||
394 | gpe_block = gpe_info->gpe_block; | ||
395 | |||
396 | /* | ||
397 | * The _PRW object must return a package, we are only interested in the | ||
398 | * first element | ||
399 | */ | ||
400 | obj_desc = pkg_desc->package.elements[0]; | ||
401 | |||
402 | if (obj_desc->common.type == ACPI_TYPE_INTEGER) { | ||
403 | |||
404 | /* Use FADT-defined GPE device (from definition of _PRW) */ | ||
405 | |||
406 | target_gpe_device = acpi_gbl_fadt_gpe_device; | ||
407 | |||
408 | /* Integer is the GPE number in the FADT described GPE blocks */ | ||
409 | |||
410 | gpe_number = (u32) obj_desc->integer.value; | ||
411 | } else if (obj_desc->common.type == ACPI_TYPE_PACKAGE) { | ||
412 | |||
413 | /* Package contains a GPE reference and GPE number within a GPE block */ | ||
414 | |||
415 | if ((obj_desc->package.count < 2) || | ||
416 | ((obj_desc->package.elements[0])->common.type != | ||
417 | ACPI_TYPE_LOCAL_REFERENCE) || | ||
418 | ((obj_desc->package.elements[1])->common.type != | ||
419 | ACPI_TYPE_INTEGER)) { | ||
420 | goto cleanup; | ||
421 | } | ||
422 | |||
423 | /* Get GPE block reference and decode */ | ||
424 | |||
425 | target_gpe_device = | ||
426 | obj_desc->package.elements[0]->reference.node; | ||
427 | gpe_number = (u32) obj_desc->package.elements[1]->integer.value; | ||
428 | } else { | ||
429 | /* Unknown type, just ignore it */ | ||
430 | |||
431 | goto cleanup; | ||
432 | } | ||
433 | |||
434 | /* | ||
435 | * Is this GPE within this block? | ||
436 | * | ||
437 | * TRUE if and only if these conditions are true: | ||
438 | * 1) The GPE devices match. | ||
439 | * 2) The GPE index(number) is within the range of the Gpe Block | ||
440 | * associated with the GPE device. | ||
441 | */ | ||
442 | if ((gpe_device == target_gpe_device) && | ||
443 | (gpe_number >= gpe_block->block_base_number) && | ||
444 | (gpe_number < gpe_block->block_base_number + | ||
445 | (gpe_block->register_count * 8))) { | ||
446 | gpe_event_info = &gpe_block->event_info[gpe_number - | ||
447 | gpe_block-> | ||
448 | block_base_number]; | ||
449 | |||
450 | gpe_event_info->flags |= ACPI_GPE_CAN_WAKE; | ||
451 | } | ||
452 | |||
453 | cleanup: | ||
454 | acpi_ut_remove_reference(pkg_desc); | ||
455 | return_ACPI_STATUS(AE_OK); | ||
456 | } | ||
457 | |||
458 | /******************************************************************************* | ||
459 | * | ||
460 | * FUNCTION: acpi_ev_get_gpe_xrupt_block | ||
461 | * | ||
462 | * PARAMETERS: interrupt_number - Interrupt for a GPE block | ||
463 | * | ||
464 | * RETURN: A GPE interrupt block | ||
465 | * | ||
466 | * DESCRIPTION: Get or Create a GPE interrupt block. There is one interrupt | ||
467 | * block per unique interrupt level used for GPEs. Should be | ||
468 | * called only when the GPE lists are semaphore locked and not | ||
469 | * subject to change. | ||
470 | * | ||
471 | ******************************************************************************/ | ||
472 | |||
473 | static struct acpi_gpe_xrupt_info *acpi_ev_get_gpe_xrupt_block(u32 | ||
474 | interrupt_number) | ||
475 | { | ||
476 | struct acpi_gpe_xrupt_info *next_gpe_xrupt; | ||
477 | struct acpi_gpe_xrupt_info *gpe_xrupt; | ||
478 | acpi_status status; | ||
479 | acpi_cpu_flags flags; | ||
480 | |||
481 | ACPI_FUNCTION_TRACE(ev_get_gpe_xrupt_block); | ||
482 | |||
483 | /* No need for lock since we are not changing any list elements here */ | ||
484 | |||
485 | next_gpe_xrupt = acpi_gbl_gpe_xrupt_list_head; | ||
486 | while (next_gpe_xrupt) { | ||
487 | if (next_gpe_xrupt->interrupt_number == interrupt_number) { | ||
488 | return_PTR(next_gpe_xrupt); | ||
489 | } | ||
490 | |||
491 | next_gpe_xrupt = next_gpe_xrupt->next; | ||
492 | } | ||
493 | |||
494 | /* Not found, must allocate a new xrupt descriptor */ | ||
495 | |||
496 | gpe_xrupt = ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_gpe_xrupt_info)); | ||
497 | if (!gpe_xrupt) { | ||
498 | return_PTR(NULL); | ||
499 | } | ||
500 | |||
501 | gpe_xrupt->interrupt_number = interrupt_number; | ||
502 | |||
503 | /* Install new interrupt descriptor with spin lock */ | ||
504 | |||
505 | flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock); | ||
506 | if (acpi_gbl_gpe_xrupt_list_head) { | ||
507 | next_gpe_xrupt = acpi_gbl_gpe_xrupt_list_head; | ||
508 | while (next_gpe_xrupt->next) { | ||
509 | next_gpe_xrupt = next_gpe_xrupt->next; | ||
510 | } | ||
511 | |||
512 | next_gpe_xrupt->next = gpe_xrupt; | ||
513 | gpe_xrupt->previous = next_gpe_xrupt; | ||
514 | } else { | ||
515 | acpi_gbl_gpe_xrupt_list_head = gpe_xrupt; | ||
516 | } | ||
517 | acpi_os_release_lock(acpi_gbl_gpe_lock, flags); | ||
518 | |||
519 | /* Install new interrupt handler if not SCI_INT */ | ||
520 | |||
521 | if (interrupt_number != acpi_gbl_FADT.sci_interrupt) { | ||
522 | status = acpi_os_install_interrupt_handler(interrupt_number, | ||
523 | acpi_ev_gpe_xrupt_handler, | ||
524 | gpe_xrupt); | ||
525 | if (ACPI_FAILURE(status)) { | ||
526 | ACPI_ERROR((AE_INFO, | ||
527 | "Could not install GPE interrupt handler at level 0x%X", | ||
528 | interrupt_number)); | ||
529 | return_PTR(NULL); | ||
530 | } | ||
531 | } | ||
532 | |||
533 | return_PTR(gpe_xrupt); | ||
534 | } | ||
535 | |||
536 | /******************************************************************************* | ||
537 | * | ||
538 | * FUNCTION: acpi_ev_delete_gpe_xrupt | ||
539 | * | ||
540 | * PARAMETERS: gpe_xrupt - A GPE interrupt info block | ||
541 | * | ||
542 | * RETURN: Status | ||
543 | * | ||
544 | * DESCRIPTION: Remove and free a gpe_xrupt block. Remove an associated | ||
545 | * interrupt handler if not the SCI interrupt. | ||
546 | * | ||
547 | ******************************************************************************/ | ||
548 | |||
549 | static acpi_status | ||
550 | acpi_ev_delete_gpe_xrupt(struct acpi_gpe_xrupt_info *gpe_xrupt) | ||
551 | { | ||
552 | acpi_status status; | ||
553 | acpi_cpu_flags flags; | ||
554 | |||
555 | ACPI_FUNCTION_TRACE(ev_delete_gpe_xrupt); | ||
556 | |||
557 | /* We never want to remove the SCI interrupt handler */ | ||
558 | |||
559 | if (gpe_xrupt->interrupt_number == acpi_gbl_FADT.sci_interrupt) { | ||
560 | gpe_xrupt->gpe_block_list_head = NULL; | ||
561 | return_ACPI_STATUS(AE_OK); | ||
562 | } | ||
563 | |||
564 | /* Disable this interrupt */ | ||
565 | |||
566 | status = | ||
567 | acpi_os_remove_interrupt_handler(gpe_xrupt->interrupt_number, | ||
568 | acpi_ev_gpe_xrupt_handler); | ||
569 | if (ACPI_FAILURE(status)) { | ||
570 | return_ACPI_STATUS(status); | ||
571 | } | ||
572 | |||
573 | /* Unlink the interrupt block with lock */ | ||
574 | |||
575 | flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock); | ||
576 | if (gpe_xrupt->previous) { | ||
577 | gpe_xrupt->previous->next = gpe_xrupt->next; | ||
578 | } else { | ||
579 | /* No previous, update list head */ | ||
580 | |||
581 | acpi_gbl_gpe_xrupt_list_head = gpe_xrupt->next; | ||
582 | } | ||
583 | |||
584 | if (gpe_xrupt->next) { | ||
585 | gpe_xrupt->next->previous = gpe_xrupt->previous; | ||
586 | } | ||
587 | acpi_os_release_lock(acpi_gbl_gpe_lock, flags); | ||
588 | |||
589 | /* Free the block */ | ||
590 | |||
591 | ACPI_FREE(gpe_xrupt); | ||
592 | return_ACPI_STATUS(AE_OK); | ||
593 | } | ||
594 | |||
595 | /******************************************************************************* | ||
596 | * | ||
597 | * FUNCTION: acpi_ev_install_gpe_block | 62 | * FUNCTION: acpi_ev_install_gpe_block |
598 | * | 63 | * |
599 | * PARAMETERS: gpe_block - New GPE block | 64 | * PARAMETERS: gpe_block - New GPE block |
@@ -705,8 +170,7 @@ acpi_status acpi_ev_delete_gpe_block(struct acpi_gpe_block_info *gpe_block) | |||
705 | acpi_os_release_lock(acpi_gbl_gpe_lock, flags); | 170 | acpi_os_release_lock(acpi_gbl_gpe_lock, flags); |
706 | } | 171 | } |
707 | 172 | ||
708 | acpi_current_gpe_count -= | 173 | acpi_current_gpe_count -= gpe_block->gpe_count; |
709 | gpe_block->register_count * ACPI_GPE_REGISTER_WIDTH; | ||
710 | 174 | ||
711 | /* Free the gpe_block */ | 175 | /* Free the gpe_block */ |
712 | 176 | ||
@@ -760,9 +224,7 @@ acpi_ev_create_gpe_info_blocks(struct acpi_gpe_block_info *gpe_block) | |||
760 | * Allocate the GPE event_info block. There are eight distinct GPEs | 224 | * Allocate the GPE event_info block. There are eight distinct GPEs |
761 | * per register. Initialization to zeros is sufficient. | 225 | * per register. Initialization to zeros is sufficient. |
762 | */ | 226 | */ |
763 | gpe_event_info = ACPI_ALLOCATE_ZEROED(((acpi_size) gpe_block-> | 227 | gpe_event_info = ACPI_ALLOCATE_ZEROED((acpi_size) gpe_block->gpe_count * |
764 | register_count * | ||
765 | ACPI_GPE_REGISTER_WIDTH) * | ||
766 | sizeof(struct | 228 | sizeof(struct |
767 | acpi_gpe_event_info)); | 229 | acpi_gpe_event_info)); |
768 | if (!gpe_event_info) { | 230 | if (!gpe_event_info) { |
@@ -880,6 +342,7 @@ acpi_ev_create_gpe_block(struct acpi_namespace_node *gpe_device, | |||
880 | { | 342 | { |
881 | acpi_status status; | 343 | acpi_status status; |
882 | struct acpi_gpe_block_info *gpe_block; | 344 | struct acpi_gpe_block_info *gpe_block; |
345 | struct acpi_gpe_walk_info walk_info; | ||
883 | 346 | ||
884 | ACPI_FUNCTION_TRACE(ev_create_gpe_block); | 347 | ACPI_FUNCTION_TRACE(ev_create_gpe_block); |
885 | 348 | ||
@@ -897,6 +360,7 @@ acpi_ev_create_gpe_block(struct acpi_namespace_node *gpe_device, | |||
897 | /* Initialize the new GPE block */ | 360 | /* Initialize the new GPE block */ |
898 | 361 | ||
899 | gpe_block->node = gpe_device; | 362 | gpe_block->node = gpe_device; |
363 | gpe_block->gpe_count = (u16)(register_count * ACPI_GPE_REGISTER_WIDTH); | ||
900 | gpe_block->register_count = register_count; | 364 | gpe_block->register_count = register_count; |
901 | gpe_block->block_base_number = gpe_block_base_number; | 365 | gpe_block->block_base_number = gpe_block_base_number; |
902 | 366 | ||
@@ -921,12 +385,17 @@ acpi_ev_create_gpe_block(struct acpi_namespace_node *gpe_device, | |||
921 | return_ACPI_STATUS(status); | 385 | return_ACPI_STATUS(status); |
922 | } | 386 | } |
923 | 387 | ||
924 | /* Find all GPE methods (_Lxx, _Exx) for this block */ | 388 | /* Find all GPE methods (_Lxx or_Exx) for this block */ |
389 | |||
390 | walk_info.gpe_block = gpe_block; | ||
391 | walk_info.gpe_device = gpe_device; | ||
392 | walk_info.enable_this_gpe = FALSE; | ||
393 | walk_info.execute_by_owner_id = FALSE; | ||
925 | 394 | ||
926 | status = acpi_ns_walk_namespace(ACPI_TYPE_METHOD, gpe_device, | 395 | status = acpi_ns_walk_namespace(ACPI_TYPE_METHOD, gpe_device, |
927 | ACPI_UINT32_MAX, ACPI_NS_WALK_NO_UNLOCK, | 396 | ACPI_UINT32_MAX, ACPI_NS_WALK_NO_UNLOCK, |
928 | acpi_ev_save_method_info, NULL, | 397 | acpi_ev_match_gpe_method, NULL, |
929 | gpe_block, NULL); | 398 | &walk_info, NULL); |
930 | 399 | ||
931 | /* Return the new block */ | 400 | /* Return the new block */ |
932 | 401 | ||
@@ -938,14 +407,13 @@ acpi_ev_create_gpe_block(struct acpi_namespace_node *gpe_device, | |||
938 | "GPE %02X to %02X [%4.4s] %u regs on int 0x%X\n", | 407 | "GPE %02X to %02X [%4.4s] %u regs on int 0x%X\n", |
939 | (u32) gpe_block->block_base_number, | 408 | (u32) gpe_block->block_base_number, |
940 | (u32) (gpe_block->block_base_number + | 409 | (u32) (gpe_block->block_base_number + |
941 | ((gpe_block->register_count * | 410 | (gpe_block->gpe_count - 1)), |
942 | ACPI_GPE_REGISTER_WIDTH) - 1)), | ||
943 | gpe_device->name.ascii, gpe_block->register_count, | 411 | gpe_device->name.ascii, gpe_block->register_count, |
944 | interrupt_number)); | 412 | interrupt_number)); |
945 | 413 | ||
946 | /* Update global count of currently available GPEs */ | 414 | /* Update global count of currently available GPEs */ |
947 | 415 | ||
948 | acpi_current_gpe_count += register_count * ACPI_GPE_REGISTER_WIDTH; | 416 | acpi_current_gpe_count += gpe_block->gpe_count; |
949 | return_ACPI_STATUS(AE_OK); | 417 | return_ACPI_STATUS(AE_OK); |
950 | } | 418 | } |
951 | 419 | ||
@@ -969,10 +437,13 @@ acpi_status | |||
969 | acpi_ev_initialize_gpe_block(struct acpi_namespace_node *gpe_device, | 437 | acpi_ev_initialize_gpe_block(struct acpi_namespace_node *gpe_device, |
970 | struct acpi_gpe_block_info *gpe_block) | 438 | struct acpi_gpe_block_info *gpe_block) |
971 | { | 439 | { |
440 | acpi_status status; | ||
972 | struct acpi_gpe_event_info *gpe_event_info; | 441 | struct acpi_gpe_event_info *gpe_event_info; |
973 | struct acpi_gpe_walk_info gpe_info; | 442 | struct acpi_gpe_walk_info walk_info; |
974 | u32 wake_gpe_count; | 443 | u32 wake_gpe_count; |
975 | u32 gpe_enabled_count; | 444 | u32 gpe_enabled_count; |
445 | u32 gpe_index; | ||
446 | u32 gpe_number; | ||
976 | u32 i; | 447 | u32 i; |
977 | u32 j; | 448 | u32 j; |
978 | 449 | ||
@@ -995,210 +466,75 @@ acpi_ev_initialize_gpe_block(struct acpi_namespace_node *gpe_device, | |||
995 | * definition a wake GPE and will not be enabled while the machine | 466 | * definition a wake GPE and will not be enabled while the machine |
996 | * is running. | 467 | * is running. |
997 | */ | 468 | */ |
998 | gpe_info.gpe_block = gpe_block; | 469 | walk_info.gpe_block = gpe_block; |
999 | gpe_info.gpe_device = gpe_device; | 470 | walk_info.gpe_device = gpe_device; |
471 | walk_info.execute_by_owner_id = FALSE; | ||
1000 | 472 | ||
1001 | acpi_ns_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, | 473 | status = |
474 | acpi_ns_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, | ||
1002 | ACPI_UINT32_MAX, ACPI_NS_WALK_UNLOCK, | 475 | ACPI_UINT32_MAX, ACPI_NS_WALK_UNLOCK, |
1003 | acpi_ev_match_prw_and_gpe, NULL, | 476 | acpi_ev_match_prw_and_gpe, NULL, |
1004 | &gpe_info, NULL); | 477 | &walk_info, NULL); |
478 | if (ACPI_FAILURE(status)) { | ||
479 | ACPI_EXCEPTION((AE_INFO, status, | ||
480 | "While executing _PRW methods")); | ||
481 | } | ||
1005 | } | 482 | } |
1006 | 483 | ||
1007 | /* | 484 | /* |
1008 | * Enable all GPEs that have a corresponding method and aren't | 485 | * Enable all GPEs that have a corresponding method and are not |
1009 | * capable of generating wakeups. Any other GPEs within this block | 486 | * capable of generating wakeups. Any other GPEs within this block |
1010 | * must be enabled via the acpi_enable_gpe() interface. | 487 | * must be enabled via the acpi_enable_gpe interface. |
1011 | */ | 488 | */ |
1012 | wake_gpe_count = 0; | 489 | wake_gpe_count = 0; |
1013 | gpe_enabled_count = 0; | 490 | gpe_enabled_count = 0; |
1014 | if (gpe_device == acpi_gbl_fadt_gpe_device) | 491 | |
492 | if (gpe_device == acpi_gbl_fadt_gpe_device) { | ||
1015 | gpe_device = NULL; | 493 | gpe_device = NULL; |
494 | } | ||
1016 | 495 | ||
1017 | for (i = 0; i < gpe_block->register_count; i++) { | 496 | for (i = 0; i < gpe_block->register_count; i++) { |
1018 | for (j = 0; j < ACPI_GPE_REGISTER_WIDTH; j++) { | 497 | for (j = 0; j < ACPI_GPE_REGISTER_WIDTH; j++) { |
1019 | acpi_status status; | ||
1020 | acpi_size gpe_index; | ||
1021 | int gpe_number; | ||
1022 | 498 | ||
1023 | /* Get the info block for this particular GPE */ | 499 | /* Get the info block for this particular GPE */ |
1024 | gpe_index = (acpi_size)i * ACPI_GPE_REGISTER_WIDTH + j; | 500 | |
501 | gpe_index = (i * ACPI_GPE_REGISTER_WIDTH) + j; | ||
1025 | gpe_event_info = &gpe_block->event_info[gpe_index]; | 502 | gpe_event_info = &gpe_block->event_info[gpe_index]; |
1026 | 503 | ||
1027 | if (gpe_event_info->flags & ACPI_GPE_CAN_WAKE) { | 504 | if (gpe_event_info->flags & ACPI_GPE_CAN_WAKE) { |
1028 | wake_gpe_count++; | 505 | wake_gpe_count++; |
1029 | if (acpi_gbl_leave_wake_gpes_disabled) | 506 | if (acpi_gbl_leave_wake_gpes_disabled) { |
1030 | continue; | 507 | continue; |
508 | } | ||
1031 | } | 509 | } |
1032 | 510 | ||
1033 | if (!(gpe_event_info->flags & ACPI_GPE_DISPATCH_METHOD)) | 511 | /* Ignore GPEs that have no corresponding _Lxx/_Exx method */ |
512 | |||
513 | if (!(gpe_event_info->flags & ACPI_GPE_DISPATCH_METHOD)) { | ||
1034 | continue; | 514 | continue; |
515 | } | ||
516 | |||
517 | /* Enable this GPE */ | ||
1035 | 518 | ||
1036 | gpe_number = gpe_index + gpe_block->block_base_number; | 519 | gpe_number = gpe_index + gpe_block->block_base_number; |
1037 | status = acpi_enable_gpe(gpe_device, gpe_number, | 520 | status = acpi_enable_gpe(gpe_device, gpe_number, |
1038 | ACPI_GPE_TYPE_RUNTIME); | 521 | ACPI_GPE_TYPE_RUNTIME); |
1039 | if (ACPI_FAILURE(status)) | ||
1040 | ACPI_ERROR((AE_INFO, | ||
1041 | "Failed to enable GPE %02X\n", | ||
1042 | gpe_number)); | ||
1043 | else | ||
1044 | gpe_enabled_count++; | ||
1045 | } | ||
1046 | } | ||
1047 | |||
1048 | ACPI_DEBUG_PRINT((ACPI_DB_INIT, | ||
1049 | "Found %u Wake, Enabled %u Runtime GPEs in this block\n", | ||
1050 | wake_gpe_count, gpe_enabled_count)); | ||
1051 | |||
1052 | return_ACPI_STATUS(AE_OK); | ||
1053 | } | ||
1054 | |||
1055 | /******************************************************************************* | ||
1056 | * | ||
1057 | * FUNCTION: acpi_ev_gpe_initialize | ||
1058 | * | ||
1059 | * PARAMETERS: None | ||
1060 | * | ||
1061 | * RETURN: Status | ||
1062 | * | ||
1063 | * DESCRIPTION: Initialize the GPE data structures | ||
1064 | * | ||
1065 | ******************************************************************************/ | ||
1066 | |||
1067 | acpi_status acpi_ev_gpe_initialize(void) | ||
1068 | { | ||
1069 | u32 register_count0 = 0; | ||
1070 | u32 register_count1 = 0; | ||
1071 | u32 gpe_number_max = 0; | ||
1072 | acpi_status status; | ||
1073 | |||
1074 | ACPI_FUNCTION_TRACE(ev_gpe_initialize); | ||
1075 | |||
1076 | status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE); | ||
1077 | if (ACPI_FAILURE(status)) { | ||
1078 | return_ACPI_STATUS(status); | ||
1079 | } | ||
1080 | |||
1081 | /* | ||
1082 | * Initialize the GPE Block(s) defined in the FADT | ||
1083 | * | ||
1084 | * Why the GPE register block lengths are divided by 2: From the ACPI | ||
1085 | * Spec, section "General-Purpose Event Registers", we have: | ||
1086 | * | ||
1087 | * "Each register block contains two registers of equal length | ||
1088 | * GPEx_STS and GPEx_EN (where x is 0 or 1). The length of the | ||
1089 | * GPE0_STS and GPE0_EN registers is equal to half the GPE0_LEN | ||
1090 | * The length of the GPE1_STS and GPE1_EN registers is equal to | ||
1091 | * half the GPE1_LEN. If a generic register block is not supported | ||
1092 | * then its respective block pointer and block length values in the | ||
1093 | * FADT table contain zeros. The GPE0_LEN and GPE1_LEN do not need | ||
1094 | * to be the same size." | ||
1095 | */ | ||
1096 | |||
1097 | /* | ||
1098 | * Determine the maximum GPE number for this machine. | ||
1099 | * | ||
1100 | * Note: both GPE0 and GPE1 are optional, and either can exist without | ||
1101 | * the other. | ||
1102 | * | ||
1103 | * If EITHER the register length OR the block address are zero, then that | ||
1104 | * particular block is not supported. | ||
1105 | */ | ||
1106 | if (acpi_gbl_FADT.gpe0_block_length && | ||
1107 | acpi_gbl_FADT.xgpe0_block.address) { | ||
1108 | |||
1109 | /* GPE block 0 exists (has both length and address > 0) */ | ||
1110 | |||
1111 | register_count0 = (u16) (acpi_gbl_FADT.gpe0_block_length / 2); | ||
1112 | |||
1113 | gpe_number_max = | ||
1114 | (register_count0 * ACPI_GPE_REGISTER_WIDTH) - 1; | ||
1115 | |||
1116 | /* Install GPE Block 0 */ | ||
1117 | |||
1118 | status = acpi_ev_create_gpe_block(acpi_gbl_fadt_gpe_device, | ||
1119 | &acpi_gbl_FADT.xgpe0_block, | ||
1120 | register_count0, 0, | ||
1121 | acpi_gbl_FADT.sci_interrupt, | ||
1122 | &acpi_gbl_gpe_fadt_blocks[0]); | ||
1123 | |||
1124 | if (ACPI_FAILURE(status)) { | ||
1125 | ACPI_EXCEPTION((AE_INFO, status, | ||
1126 | "Could not create GPE Block 0")); | ||
1127 | } | ||
1128 | } | ||
1129 | |||
1130 | if (acpi_gbl_FADT.gpe1_block_length && | ||
1131 | acpi_gbl_FADT.xgpe1_block.address) { | ||
1132 | |||
1133 | /* GPE block 1 exists (has both length and address > 0) */ | ||
1134 | |||
1135 | register_count1 = (u16) (acpi_gbl_FADT.gpe1_block_length / 2); | ||
1136 | |||
1137 | /* Check for GPE0/GPE1 overlap (if both banks exist) */ | ||
1138 | |||
1139 | if ((register_count0) && | ||
1140 | (gpe_number_max >= acpi_gbl_FADT.gpe1_base)) { | ||
1141 | ACPI_ERROR((AE_INFO, | ||
1142 | "GPE0 block (GPE 0 to %d) overlaps the GPE1 block " | ||
1143 | "(GPE %d to %d) - Ignoring GPE1", | ||
1144 | gpe_number_max, acpi_gbl_FADT.gpe1_base, | ||
1145 | acpi_gbl_FADT.gpe1_base + | ||
1146 | ((register_count1 * | ||
1147 | ACPI_GPE_REGISTER_WIDTH) - 1))); | ||
1148 | |||
1149 | /* Ignore GPE1 block by setting the register count to zero */ | ||
1150 | |||
1151 | register_count1 = 0; | ||
1152 | } else { | ||
1153 | /* Install GPE Block 1 */ | ||
1154 | |||
1155 | status = | ||
1156 | acpi_ev_create_gpe_block(acpi_gbl_fadt_gpe_device, | ||
1157 | &acpi_gbl_FADT.xgpe1_block, | ||
1158 | register_count1, | ||
1159 | acpi_gbl_FADT.gpe1_base, | ||
1160 | acpi_gbl_FADT. | ||
1161 | sci_interrupt, | ||
1162 | &acpi_gbl_gpe_fadt_blocks | ||
1163 | [1]); | ||
1164 | |||
1165 | if (ACPI_FAILURE(status)) { | 522 | if (ACPI_FAILURE(status)) { |
1166 | ACPI_EXCEPTION((AE_INFO, status, | 523 | ACPI_EXCEPTION((AE_INFO, status, |
1167 | "Could not create GPE Block 1")); | 524 | "Could not enable GPE 0x%02X", |
525 | gpe_number)); | ||
526 | continue; | ||
1168 | } | 527 | } |
1169 | 528 | ||
1170 | /* | 529 | gpe_enabled_count++; |
1171 | * GPE0 and GPE1 do not have to be contiguous in the GPE number | ||
1172 | * space. However, GPE0 always starts at GPE number zero. | ||
1173 | */ | ||
1174 | gpe_number_max = acpi_gbl_FADT.gpe1_base + | ||
1175 | ((register_count1 * ACPI_GPE_REGISTER_WIDTH) - 1); | ||
1176 | } | 530 | } |
1177 | } | 531 | } |
1178 | 532 | ||
1179 | /* Exit if there are no GPE registers */ | 533 | if (gpe_enabled_count || wake_gpe_count) { |
1180 | |||
1181 | if ((register_count0 + register_count1) == 0) { | ||
1182 | |||
1183 | /* GPEs are not required by ACPI, this is OK */ | ||
1184 | |||
1185 | ACPI_DEBUG_PRINT((ACPI_DB_INIT, | 534 | ACPI_DEBUG_PRINT((ACPI_DB_INIT, |
1186 | "There are no GPE blocks defined in the FADT\n")); | 535 | "Enabled %u Runtime GPEs, added %u Wake GPEs in this block\n", |
1187 | status = AE_OK; | 536 | gpe_enabled_count, wake_gpe_count)); |
1188 | goto cleanup; | ||
1189 | } | ||
1190 | |||
1191 | /* Check for Max GPE number out-of-range */ | ||
1192 | |||
1193 | if (gpe_number_max > ACPI_GPE_MAX) { | ||
1194 | ACPI_ERROR((AE_INFO, | ||
1195 | "Maximum GPE number from FADT is too large: 0x%X", | ||
1196 | gpe_number_max)); | ||
1197 | status = AE_BAD_VALUE; | ||
1198 | goto cleanup; | ||
1199 | } | 537 | } |
1200 | 538 | ||
1201 | cleanup: | ||
1202 | (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); | ||
1203 | return_ACPI_STATUS(AE_OK); | 539 | return_ACPI_STATUS(AE_OK); |
1204 | } | 540 | } |