diff options
author | Lv Zheng <lv.zheng@intel.com> | 2015-02-05 02:20:29 -0500 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2015-02-05 09:31:38 -0500 |
commit | 7c43312af8b363b679d1e7840858ff8d204a4d91 (patch) | |
tree | cf76717eb2a03d23f6f1dccd0cb416929624c4f7 | |
parent | 779ba5a39214f0e3112bd2b94c26df03dc518a29 (diff) |
ACPICA: Events: Cleanup GPE dispatcher type obtaining code
ACPICA commit 7926d5ca9452c87f866938dcea8f12e1efb58f89
There is an issue in acpi_install_gpe_handler() and acpi_remove_gpe_handler().
The code to obtain the GPE dispatcher type from the Handler->original_flags
is wrong:
if (((Handler->original_flags & ACPI_GPE_DISPATCH_METHOD) ||
(Handler->original_flags & ACPI_GPE_DISPATCH_NOTIFY)) &&
ACPI_GPE_DISPATCH_NOTIFY is 0x03 and ACPI_GPE_DISPATCH_METHOD is 0x02, thus
this statement is TRUE for the following dispatcher types:
0x01 (ACPI_GPE_DISPATCH_HANDLER): not expected
0x02 (ACPI_GPE_DISPATCH_METHOD): expected
0x03 (ACPI_GPE_DISPATCH_NOTIFY): expected
There is no functional issue due to this because Handler->original_flags is
only set in acpi_install_gpe_handler(), and an earlier checker has excluded
the ACPI_GPE_DISPATCH_HANDLER:
if ((gpe_event_info->Flags & ACPI_GPE_DISPATCH_MASK) ==
ACPI_GPE_DISPATCH_HANDLER)
{
Status = AE_ALREADY_EXISTS;
goto free_and_exit;
}
...
Handler->original_flags = (u8) (gpe_event_info->Flags &
(ACPI_GPE_XRUPT_TYPE_MASK | ACPI_GPE_DISPATCH_MASK));
We need to clean this up before modifying the GPE dispatcher type values.
In order to prevent such issue from happening in the future, this patch
introduces ACPI_GPE_DISPATCH_TYPE() macro to be used to obtain the GPE
dispatcher types. Lv Zheng.
Link: https://github.com/acpica/acpica/commit/7926d5ca
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Signed-off-by: David E. Box <david.e.box@linux.intel.com>
Signed-off-by: Bob Moore <robert.moore@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
-rw-r--r-- | drivers/acpi/acpica/evgpe.c | 4 | ||||
-rw-r--r-- | drivers/acpi/acpica/evgpeblk.c | 6 | ||||
-rw-r--r-- | drivers/acpi/acpica/evgpeinit.c | 4 | ||||
-rw-r--r-- | drivers/acpi/acpica/evgpeutil.c | 8 | ||||
-rw-r--r-- | drivers/acpi/acpica/evxface.c | 18 | ||||
-rw-r--r-- | drivers/acpi/acpica/evxfgpe.c | 6 | ||||
-rw-r--r-- | drivers/acpi/acpica/hwgpe.c | 2 | ||||
-rw-r--r-- | include/acpi/actypes.h | 1 |
8 files changed, 25 insertions, 24 deletions
diff --git a/drivers/acpi/acpica/evgpe.c b/drivers/acpi/acpica/evgpe.c index 4a4f41a2822e..fccdfb2f73df 100644 --- a/drivers/acpi/acpica/evgpe.c +++ b/drivers/acpi/acpica/evgpe.c | |||
@@ -503,7 +503,7 @@ static void ACPI_SYSTEM_XFACE acpi_ev_asynch_execute_gpe_method(void *context) | |||
503 | 503 | ||
504 | /* Do the correct dispatch - normal method or implicit notify */ | 504 | /* Do the correct dispatch - normal method or implicit notify */ |
505 | 505 | ||
506 | switch (gpe_event_info->flags & ACPI_GPE_DISPATCH_MASK) { | 506 | switch (ACPI_GPE_DISPATCH_TYPE(gpe_event_info->flags)) { |
507 | case ACPI_GPE_DISPATCH_NOTIFY: | 507 | case ACPI_GPE_DISPATCH_NOTIFY: |
508 | /* | 508 | /* |
509 | * Implicit notify. | 509 | * Implicit notify. |
@@ -707,7 +707,7 @@ acpi_ev_gpe_dispatch(struct acpi_namespace_node *gpe_device, | |||
707 | * If there is neither a handler nor a method, leave the GPE | 707 | * If there is neither a handler nor a method, leave the GPE |
708 | * disabled. | 708 | * disabled. |
709 | */ | 709 | */ |
710 | switch (gpe_event_info->flags & ACPI_GPE_DISPATCH_MASK) { | 710 | switch (ACPI_GPE_DISPATCH_TYPE(gpe_event_info->flags)) { |
711 | case ACPI_GPE_DISPATCH_HANDLER: | 711 | case ACPI_GPE_DISPATCH_HANDLER: |
712 | 712 | ||
713 | /* Invoke the installed handler (at interrupt level) */ | 713 | /* Invoke the installed handler (at interrupt level) */ |
diff --git a/drivers/acpi/acpica/evgpeblk.c b/drivers/acpi/acpica/evgpeblk.c index d86699eea33c..d0a6024ae628 100644 --- a/drivers/acpi/acpica/evgpeblk.c +++ b/drivers/acpi/acpica/evgpeblk.c | |||
@@ -474,10 +474,10 @@ acpi_ev_initialize_gpe_block(struct acpi_gpe_xrupt_info *gpe_xrupt_info, | |||
474 | * Ignore GPEs that have no corresponding _Lxx/_Exx method | 474 | * Ignore GPEs that have no corresponding _Lxx/_Exx method |
475 | * and GPEs that are used to wake the system | 475 | * and GPEs that are used to wake the system |
476 | */ | 476 | */ |
477 | if (((gpe_event_info->flags & ACPI_GPE_DISPATCH_MASK) == | 477 | if ((ACPI_GPE_DISPATCH_TYPE(gpe_event_info->flags) == |
478 | ACPI_GPE_DISPATCH_NONE) | 478 | ACPI_GPE_DISPATCH_NONE) |
479 | || ((gpe_event_info->flags & ACPI_GPE_DISPATCH_MASK) | 479 | || (ACPI_GPE_DISPATCH_TYPE(gpe_event_info->flags) == |
480 | == ACPI_GPE_DISPATCH_HANDLER) | 480 | ACPI_GPE_DISPATCH_HANDLER) |
481 | || (gpe_event_info->flags & ACPI_GPE_CAN_WAKE)) { | 481 | || (gpe_event_info->flags & ACPI_GPE_CAN_WAKE)) { |
482 | continue; | 482 | continue; |
483 | } | 483 | } |
diff --git a/drivers/acpi/acpica/evgpeinit.c b/drivers/acpi/acpica/evgpeinit.c index 7be928379879..ebfd40d77d10 100644 --- a/drivers/acpi/acpica/evgpeinit.c +++ b/drivers/acpi/acpica/evgpeinit.c | |||
@@ -401,7 +401,7 @@ acpi_ev_match_gpe_method(acpi_handle obj_handle, | |||
401 | return_ACPI_STATUS(AE_OK); | 401 | return_ACPI_STATUS(AE_OK); |
402 | } | 402 | } |
403 | 403 | ||
404 | if ((gpe_event_info->flags & ACPI_GPE_DISPATCH_MASK) == | 404 | if (ACPI_GPE_DISPATCH_TYPE(gpe_event_info->flags) == |
405 | ACPI_GPE_DISPATCH_HANDLER) { | 405 | ACPI_GPE_DISPATCH_HANDLER) { |
406 | 406 | ||
407 | /* If there is already a handler, ignore this GPE method */ | 407 | /* If there is already a handler, ignore this GPE method */ |
@@ -409,7 +409,7 @@ acpi_ev_match_gpe_method(acpi_handle obj_handle, | |||
409 | return_ACPI_STATUS(AE_OK); | 409 | return_ACPI_STATUS(AE_OK); |
410 | } | 410 | } |
411 | 411 | ||
412 | if ((gpe_event_info->flags & ACPI_GPE_DISPATCH_MASK) == | 412 | if (ACPI_GPE_DISPATCH_TYPE(gpe_event_info->flags) == |
413 | ACPI_GPE_DISPATCH_METHOD) { | 413 | ACPI_GPE_DISPATCH_METHOD) { |
414 | /* | 414 | /* |
415 | * If there is already a method, ignore this method. But check | 415 | * If there is already a method, ignore this method. But check |
diff --git a/drivers/acpi/acpica/evgpeutil.c b/drivers/acpi/acpica/evgpeutil.c index 3f1c5aa682a5..b1978122f6a9 100644 --- a/drivers/acpi/acpica/evgpeutil.c +++ b/drivers/acpi/acpica/evgpeutil.c | |||
@@ -324,7 +324,7 @@ acpi_ev_delete_gpe_handlers(struct acpi_gpe_xrupt_info *gpe_xrupt_info, | |||
324 | ACPI_GPE_REGISTER_WIDTH) | 324 | ACPI_GPE_REGISTER_WIDTH) |
325 | + j]; | 325 | + j]; |
326 | 326 | ||
327 | if ((gpe_event_info->flags & ACPI_GPE_DISPATCH_MASK) == | 327 | if (ACPI_GPE_DISPATCH_TYPE(gpe_event_info->flags) == |
328 | ACPI_GPE_DISPATCH_HANDLER) { | 328 | ACPI_GPE_DISPATCH_HANDLER) { |
329 | 329 | ||
330 | /* Delete an installed handler block */ | 330 | /* Delete an installed handler block */ |
@@ -333,10 +333,8 @@ acpi_ev_delete_gpe_handlers(struct acpi_gpe_xrupt_info *gpe_xrupt_info, | |||
333 | gpe_event_info->dispatch.handler = NULL; | 333 | gpe_event_info->dispatch.handler = NULL; |
334 | gpe_event_info->flags &= | 334 | gpe_event_info->flags &= |
335 | ~ACPI_GPE_DISPATCH_MASK; | 335 | ~ACPI_GPE_DISPATCH_MASK; |
336 | } else | 336 | } else if (ACPI_GPE_DISPATCH_TYPE(gpe_event_info->flags) |
337 | if ((gpe_event_info-> | 337 | == ACPI_GPE_DISPATCH_NOTIFY) { |
338 | flags & ACPI_GPE_DISPATCH_MASK) == | ||
339 | ACPI_GPE_DISPATCH_NOTIFY) { | ||
340 | 338 | ||
341 | /* Delete the implicit notification device list */ | 339 | /* Delete the implicit notification device list */ |
342 | 340 | ||
diff --git a/drivers/acpi/acpica/evxface.c b/drivers/acpi/acpica/evxface.c index b6b0c2341d29..61b0261dd137 100644 --- a/drivers/acpi/acpica/evxface.c +++ b/drivers/acpi/acpica/evxface.c | |||
@@ -775,7 +775,7 @@ acpi_install_gpe_handler(acpi_handle gpe_device, | |||
775 | 775 | ||
776 | /* Make sure that there isn't a handler there already */ | 776 | /* Make sure that there isn't a handler there already */ |
777 | 777 | ||
778 | if ((gpe_event_info->flags & ACPI_GPE_DISPATCH_MASK) == | 778 | if (ACPI_GPE_DISPATCH_TYPE(gpe_event_info->flags) == |
779 | ACPI_GPE_DISPATCH_HANDLER) { | 779 | ACPI_GPE_DISPATCH_HANDLER) { |
780 | status = AE_ALREADY_EXISTS; | 780 | status = AE_ALREADY_EXISTS; |
781 | goto free_and_exit; | 781 | goto free_and_exit; |
@@ -793,9 +793,10 @@ acpi_install_gpe_handler(acpi_handle gpe_device, | |||
793 | * automatically during initialization, in which case it has to be | 793 | * automatically during initialization, in which case it has to be |
794 | * disabled now to avoid spurious execution of the handler. | 794 | * disabled now to avoid spurious execution of the handler. |
795 | */ | 795 | */ |
796 | if (((handler->original_flags & ACPI_GPE_DISPATCH_METHOD) || | 796 | if (((ACPI_GPE_DISPATCH_TYPE(handler->original_flags) == |
797 | (handler->original_flags & ACPI_GPE_DISPATCH_NOTIFY)) && | 797 | ACPI_GPE_DISPATCH_METHOD) || |
798 | gpe_event_info->runtime_count) { | 798 | (ACPI_GPE_DISPATCH_TYPE(handler->original_flags) == |
799 | ACPI_GPE_DISPATCH_NOTIFY)) && gpe_event_info->runtime_count) { | ||
799 | handler->originally_enabled = TRUE; | 800 | handler->originally_enabled = TRUE; |
800 | (void)acpi_ev_remove_gpe_reference(gpe_event_info); | 801 | (void)acpi_ev_remove_gpe_reference(gpe_event_info); |
801 | 802 | ||
@@ -880,7 +881,7 @@ acpi_remove_gpe_handler(acpi_handle gpe_device, | |||
880 | 881 | ||
881 | /* Make sure that a handler is indeed installed */ | 882 | /* Make sure that a handler is indeed installed */ |
882 | 883 | ||
883 | if ((gpe_event_info->flags & ACPI_GPE_DISPATCH_MASK) != | 884 | if (ACPI_GPE_DISPATCH_TYPE(gpe_event_info->flags) != |
884 | ACPI_GPE_DISPATCH_HANDLER) { | 885 | ACPI_GPE_DISPATCH_HANDLER) { |
885 | status = AE_NOT_EXIST; | 886 | status = AE_NOT_EXIST; |
886 | goto unlock_and_exit; | 887 | goto unlock_and_exit; |
@@ -910,9 +911,10 @@ acpi_remove_gpe_handler(acpi_handle gpe_device, | |||
910 | * enabled, it should be enabled at this point to restore the | 911 | * enabled, it should be enabled at this point to restore the |
911 | * post-initialization configuration. | 912 | * post-initialization configuration. |
912 | */ | 913 | */ |
913 | if (((handler->original_flags & ACPI_GPE_DISPATCH_METHOD) || | 914 | if (((ACPI_GPE_DISPATCH_TYPE(handler->original_flags) == |
914 | (handler->original_flags & ACPI_GPE_DISPATCH_NOTIFY)) && | 915 | ACPI_GPE_DISPATCH_METHOD) || |
915 | handler->originally_enabled) { | 916 | (ACPI_GPE_DISPATCH_TYPE(handler->original_flags) == |
917 | ACPI_GPE_DISPATCH_NOTIFY)) && handler->originally_enabled) { | ||
916 | (void)acpi_ev_add_gpe_reference(gpe_event_info); | 918 | (void)acpi_ev_add_gpe_reference(gpe_event_info); |
917 | } | 919 | } |
918 | 920 | ||
diff --git a/drivers/acpi/acpica/evxfgpe.c b/drivers/acpi/acpica/evxfgpe.c index c637666e7174..b836139e13bb 100644 --- a/drivers/acpi/acpica/evxfgpe.c +++ b/drivers/acpi/acpica/evxfgpe.c | |||
@@ -132,7 +132,7 @@ acpi_status acpi_enable_gpe(acpi_handle gpe_device, u32 gpe_number) | |||
132 | */ | 132 | */ |
133 | gpe_event_info = acpi_ev_get_gpe_event_info(gpe_device, gpe_number); | 133 | gpe_event_info = acpi_ev_get_gpe_event_info(gpe_device, gpe_number); |
134 | if (gpe_event_info) { | 134 | if (gpe_event_info) { |
135 | if ((gpe_event_info->flags & ACPI_GPE_DISPATCH_MASK) != | 135 | if (ACPI_GPE_DISPATCH_TYPE(gpe_event_info->flags) != |
136 | ACPI_GPE_DISPATCH_NONE) { | 136 | ACPI_GPE_DISPATCH_NONE) { |
137 | status = acpi_ev_add_gpe_reference(gpe_event_info); | 137 | status = acpi_ev_add_gpe_reference(gpe_event_info); |
138 | } else { | 138 | } else { |
@@ -313,7 +313,7 @@ acpi_setup_gpe_for_wake(acpi_handle wake_device, | |||
313 | * known as an "implicit notify". Note: The GPE is assumed to be | 313 | * known as an "implicit notify". Note: The GPE is assumed to be |
314 | * level-triggered (for windows compatibility). | 314 | * level-triggered (for windows compatibility). |
315 | */ | 315 | */ |
316 | if ((gpe_event_info->flags & ACPI_GPE_DISPATCH_MASK) == | 316 | if (ACPI_GPE_DISPATCH_TYPE(gpe_event_info->flags) == |
317 | ACPI_GPE_DISPATCH_NONE) { | 317 | ACPI_GPE_DISPATCH_NONE) { |
318 | /* | 318 | /* |
319 | * This is the first device for implicit notify on this GPE. | 319 | * This is the first device for implicit notify on this GPE. |
@@ -327,7 +327,7 @@ acpi_setup_gpe_for_wake(acpi_handle wake_device, | |||
327 | * If we already have an implicit notify on this GPE, add | 327 | * If we already have an implicit notify on this GPE, add |
328 | * this device to the notify list. | 328 | * this device to the notify list. |
329 | */ | 329 | */ |
330 | if ((gpe_event_info->flags & ACPI_GPE_DISPATCH_MASK) == | 330 | if (ACPI_GPE_DISPATCH_TYPE(gpe_event_info->flags) == |
331 | ACPI_GPE_DISPATCH_NOTIFY) { | 331 | ACPI_GPE_DISPATCH_NOTIFY) { |
332 | 332 | ||
333 | /* Ensure that the device is not already in the list */ | 333 | /* Ensure that the device is not already in the list */ |
diff --git a/drivers/acpi/acpica/hwgpe.c b/drivers/acpi/acpica/hwgpe.c index 6a955a939843..ed85fe7494ae 100644 --- a/drivers/acpi/acpica/hwgpe.c +++ b/drivers/acpi/acpica/hwgpe.c | |||
@@ -225,7 +225,7 @@ acpi_hw_get_gpe_status(struct acpi_gpe_event_info * gpe_event_info, | |||
225 | 225 | ||
226 | /* GPE currently handled? */ | 226 | /* GPE currently handled? */ |
227 | 227 | ||
228 | if ((gpe_event_info->flags & ACPI_GPE_DISPATCH_MASK) != | 228 | if (ACPI_GPE_DISPATCH_TYPE(gpe_event_info->flags) != |
229 | ACPI_GPE_DISPATCH_NONE) { | 229 | ACPI_GPE_DISPATCH_NONE) { |
230 | local_event_status |= ACPI_EVENT_FLAG_HAS_HANDLER; | 230 | local_event_status |= ACPI_EVENT_FLAG_HAS_HANDLER; |
231 | } | 231 | } |
diff --git a/include/acpi/actypes.h b/include/acpi/actypes.h index bbef17368e49..401705df516d 100644 --- a/include/acpi/actypes.h +++ b/include/acpi/actypes.h | |||
@@ -757,6 +757,7 @@ typedef u32 acpi_event_status; | |||
757 | #define ACPI_GPE_DISPATCH_HANDLER (u8) 0x02 | 757 | #define ACPI_GPE_DISPATCH_HANDLER (u8) 0x02 |
758 | #define ACPI_GPE_DISPATCH_NOTIFY (u8) 0x03 | 758 | #define ACPI_GPE_DISPATCH_NOTIFY (u8) 0x03 |
759 | #define ACPI_GPE_DISPATCH_MASK (u8) 0x03 | 759 | #define ACPI_GPE_DISPATCH_MASK (u8) 0x03 |
760 | #define ACPI_GPE_DISPATCH_TYPE(flags) ((u8) ((flags) & ACPI_GPE_DISPATCH_MASK)) | ||
760 | 761 | ||
761 | #define ACPI_GPE_LEVEL_TRIGGERED (u8) 0x04 | 762 | #define ACPI_GPE_LEVEL_TRIGGERED (u8) 0x04 |
762 | #define ACPI_GPE_EDGE_TRIGGERED (u8) 0x00 | 763 | #define ACPI_GPE_EDGE_TRIGGERED (u8) 0x00 |