aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/acpica
diff options
context:
space:
mode:
authorLv Zheng <lv.zheng@intel.com>2015-02-05 03:27:03 -0500
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2015-02-05 09:34:51 -0500
commit0d0988af81ac809b30f818f0c0f065327ff6423b (patch)
tree65330611f1d8eb82174f0ca9eb37d6efca3e45ee /drivers/acpi/acpica
parent121b7d91e902f19d21a669618f6b8966180e5131 (diff)
ACPICA: Events: Introduce ACPI_GPE_DISPATCH_RAW_HANDLER to fix 2 issues for the current GPE APIs
ACPICA commit 199cad16530a45aea2bec98e528866e20c5927e1 Since whether the GPE should be disabled/enabled/cleared should only be determined by the GPE driver's state machine: 1. GPE should be disabled if the driver wants to switch to the GPE polling mode when a GPE storm condition is indicated and should be enabled if the driver wants to switch back to the GPE interrupt mode when all of the storm conditions are cleared. The conditions should be protected by the driver's specific lock. 2. GPE should be enabled if the driver has accepted more than one request and should be disabled if the driver has completed all of the requests. The request count should be protected by the driver's specific lock. 3. GPE should be cleared either when the driver is about to handle an edge triggered GPE or when the driver has completed to handle a level triggered GPE. The handling code should be protected by the driver's specific lock. Thus the GPE enabling/disabling/clearing operations are likely to be performed with the driver's specific lock held while we currently cannot do this. This is because: 1. We have the acpi_gbl_gpe_lock held before invoking the GPE driver's handler. Driver's specific lock is likely to be held inside of the handler, thus we can see some dead lock issues due to the reversed locking order or recursive locking. In order to solve such dead lock issues, we need to unlock the acpi_gbl_gpe_lock before invoking the handler. BZ 1100. 2. Since GPE disabling/enabling/clearing should be determined by the GPE driver's state machine, we shouldn't perform such operations inside of ACPICA for a GPE handler to mess up the driver's state machine. BZ 1101. Originally this patch includes a logic to flush GPE handlers, it is dropped due to the following reasons: 1. This is a different issue; 2. Linux OSL has fixed this by flushing SCI in acpi_os_wait_events_complete(). We will pick up this topic when the Linux OSL fix turns out to be not sufficient. Note that currently the internal operations and the acpi_gbl_gpe_lock are also used by ACPI_GPE_DISPATCH_METHOD and ACPI_GPE_DISPATCH_NOTIFY. In order not to introduce regressions, we add one ACPI_GPE_DISPATCH_RAW_HANDLER type to be distiguished from ACPI_GPE_DISPATCH_HANDLER. For which the acpi_gbl_gpe_lock is unlocked before invoking the GPE handler and the internal enabling/disabling operations are bypassed to allow drivers to perform them at a proper position using the GPE APIs and ACPI_GPE_DISPATCH_RAW_HANDLER users should invoke acpi_set_gpe() instead of acpi_enable_gpe()/acpi_disable_gpe() to bypass the internal GPE clearing code in acpi_enable_gpe(). Lv Zheng. Known issues: 1. Edge-triggered GPE lost for frequent enablings On some buggy silicon platforms, GPE enable line may not be directly wired to the GPE trigger line. In that case, when GPE enabling is frequently performed for edge-triggered GPEs, GPE status may stay set without being triggered. This patch may maginify this problem as it allows GPE enabling to be parallel performed during the process the GPEs are handled. This is an existing issue, because: 1. For task context: Current ACPI_GPE_DISPATCH_METHOD practices have proven that this isn't a real issue - we can re-enable edge-triggered GPE in a work queue where the GPE status bit might already be set. 2. For IRQ context: This can even happen when the GPE enabling occurs before returning from the GPE handler and after unlocking the GPE lock. Thus currently no code is included to protect this. Link: https://github.com/acpica/acpica/commit/199cad16 Signed-off-by: Lv Zheng <lv.zheng@intel.com> Signed-off-by: Bob Moore <robert.moore@intel.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'drivers/acpi/acpica')
-rw-r--r--drivers/acpi/acpica/evgpe.c52
-rw-r--r--drivers/acpi/acpica/evgpeblk.c2
-rw-r--r--drivers/acpi/acpica/evgpeinit.c6
-rw-r--r--drivers/acpi/acpica/evgpeutil.c6
-rw-r--r--drivers/acpi/acpica/evxface.c115
5 files changed, 157 insertions, 24 deletions
diff --git a/drivers/acpi/acpica/evgpe.c b/drivers/acpi/acpica/evgpe.c
index 836c79b8cd1d..5ed064e8673c 100644
--- a/drivers/acpi/acpica/evgpe.c
+++ b/drivers/acpi/acpica/evgpe.c
@@ -332,6 +332,7 @@ u32 acpi_ev_gpe_detect(struct acpi_gpe_xrupt_info *gpe_xrupt_list)
332 struct acpi_gpe_register_info *gpe_register_info; 332 struct acpi_gpe_register_info *gpe_register_info;
333 struct acpi_gpe_event_info *gpe_event_info; 333 struct acpi_gpe_event_info *gpe_event_info;
334 u32 gpe_number; 334 u32 gpe_number;
335 struct acpi_gpe_handler_info *gpe_handler_info;
335 u32 int_status = ACPI_INTERRUPT_NOT_HANDLED; 336 u32 int_status = ACPI_INTERRUPT_NOT_HANDLED;
336 u8 enabled_status_byte; 337 u8 enabled_status_byte;
337 u32 status_reg; 338 u32 status_reg;
@@ -455,14 +456,49 @@ u32 acpi_ev_gpe_detect(struct acpi_gpe_xrupt_info *gpe_xrupt_list)
455 acpi_gbl_global_event_handler_context); 456 acpi_gbl_global_event_handler_context);
456 } 457 }
457 458
458 /* 459 /* Found an active GPE */
459 * Found an active GPE. Dispatch the event to a handler 460
460 * or method. 461 if (ACPI_GPE_DISPATCH_TYPE
461 */ 462 (gpe_event_info->flags) ==
462 int_status |= 463 ACPI_GPE_DISPATCH_RAW_HANDLER) {
463 acpi_ev_gpe_dispatch(gpe_device, 464
464 gpe_event_info, 465 /* Dispatch the event to a raw handler */
465 gpe_number); 466
467 gpe_handler_info =
468 gpe_event_info->dispatch.
469 handler;
470
471 /*
472 * There is no protection around the namespace node
473 * and the GPE handler to ensure a safe destruction
474 * because:
475 * 1. The namespace node is expected to always
476 * exist after loading a table.
477 * 2. The GPE handler is expected to be flushed by
478 * acpi_os_wait_events_complete() before the
479 * destruction.
480 */
481 acpi_os_release_lock
482 (acpi_gbl_gpe_lock, flags);
483 int_status |=
484 gpe_handler_info->
485 address(gpe_device,
486 gpe_number,
487 gpe_handler_info->
488 context);
489 flags =
490 acpi_os_acquire_lock
491 (acpi_gbl_gpe_lock);
492 } else {
493 /*
494 * Dispatch the event to a standard handler or
495 * method.
496 */
497 int_status |=
498 acpi_ev_gpe_dispatch
499 (gpe_device, gpe_event_info,
500 gpe_number);
501 }
466 } 502 }
467 } 503 }
468 } 504 }
diff --git a/drivers/acpi/acpica/evgpeblk.c b/drivers/acpi/acpica/evgpeblk.c
index ce2a7cf3a23f..e0f24c504513 100644
--- a/drivers/acpi/acpica/evgpeblk.c
+++ b/drivers/acpi/acpica/evgpeblk.c
@@ -478,6 +478,8 @@ acpi_ev_initialize_gpe_block(struct acpi_gpe_xrupt_info *gpe_xrupt_info,
478 ACPI_GPE_DISPATCH_NONE) 478 ACPI_GPE_DISPATCH_NONE)
479 || (ACPI_GPE_DISPATCH_TYPE(gpe_event_info->flags) == 479 || (ACPI_GPE_DISPATCH_TYPE(gpe_event_info->flags) ==
480 ACPI_GPE_DISPATCH_HANDLER) 480 ACPI_GPE_DISPATCH_HANDLER)
481 || (ACPI_GPE_DISPATCH_TYPE(gpe_event_info->flags) ==
482 ACPI_GPE_DISPATCH_RAW_HANDLER)
481 || (gpe_event_info->flags & ACPI_GPE_CAN_WAKE)) { 483 || (gpe_event_info->flags & ACPI_GPE_CAN_WAKE)) {
482 continue; 484 continue;
483 } 485 }
diff --git a/drivers/acpi/acpica/evgpeinit.c b/drivers/acpi/acpica/evgpeinit.c
index 76705082b3db..8840296d5b20 100644
--- a/drivers/acpi/acpica/evgpeinit.c
+++ b/drivers/acpi/acpica/evgpeinit.c
@@ -401,8 +401,10 @@ 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 (ACPI_GPE_DISPATCH_TYPE(gpe_event_info->flags) == 404 if ((ACPI_GPE_DISPATCH_TYPE(gpe_event_info->flags) ==
405 ACPI_GPE_DISPATCH_HANDLER) { 405 ACPI_GPE_DISPATCH_HANDLER) ||
406 (ACPI_GPE_DISPATCH_TYPE(gpe_event_info->flags) ==
407 ACPI_GPE_DISPATCH_RAW_HANDLER)) {
406 408
407 /* If there is already a handler, ignore this GPE method */ 409 /* If there is already a handler, ignore this GPE method */
408 410
diff --git a/drivers/acpi/acpica/evgpeutil.c b/drivers/acpi/acpica/evgpeutil.c
index c369b1997632..3a958f3612fe 100644
--- a/drivers/acpi/acpica/evgpeutil.c
+++ b/drivers/acpi/acpica/evgpeutil.c
@@ -324,8 +324,10 @@ 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 (ACPI_GPE_DISPATCH_TYPE(gpe_event_info->flags) == 327 if ((ACPI_GPE_DISPATCH_TYPE(gpe_event_info->flags) ==
328 ACPI_GPE_DISPATCH_HANDLER) { 328 ACPI_GPE_DISPATCH_HANDLER) ||
329 (ACPI_GPE_DISPATCH_TYPE(gpe_event_info->flags) ==
330 ACPI_GPE_DISPATCH_RAW_HANDLER)) {
329 331
330 /* Delete an installed handler block */ 332 /* Delete an installed handler block */
331 333
diff --git a/drivers/acpi/acpica/evxface.c b/drivers/acpi/acpica/evxface.c
index 6d04ae944bda..81f2d9e87fad 100644
--- a/drivers/acpi/acpica/evxface.c
+++ b/drivers/acpi/acpica/evxface.c
@@ -51,6 +51,16 @@
51 51
52#define _COMPONENT ACPI_EVENTS 52#define _COMPONENT ACPI_EVENTS
53ACPI_MODULE_NAME("evxface") 53ACPI_MODULE_NAME("evxface")
54#if (!ACPI_REDUCED_HARDWARE)
55/* Local prototypes */
56static acpi_status
57acpi_ev_install_gpe_handler(acpi_handle gpe_device,
58 u32 gpe_number,
59 u32 type,
60 u8 is_raw_handler,
61 acpi_gpe_handler address, void *context);
62
63#endif
54 64
55 65
56/******************************************************************************* 66/*******************************************************************************
@@ -76,6 +86,7 @@ ACPI_MODULE_NAME("evxface")
76 * handlers. 86 * handlers.
77 * 87 *
78 ******************************************************************************/ 88 ******************************************************************************/
89
79acpi_status 90acpi_status
80acpi_install_notify_handler(acpi_handle device, 91acpi_install_notify_handler(acpi_handle device,
81 u32 handler_type, 92 u32 handler_type,
@@ -717,32 +728,37 @@ ACPI_EXPORT_SYMBOL(acpi_remove_fixed_event_handler)
717 728
718/******************************************************************************* 729/*******************************************************************************
719 * 730 *
720 * FUNCTION: acpi_install_gpe_handler 731 * FUNCTION: acpi_ev_install_gpe_handler
721 * 732 *
722 * PARAMETERS: gpe_device - Namespace node for the GPE (NULL for FADT 733 * PARAMETERS: gpe_device - Namespace node for the GPE (NULL for FADT
723 * defined GPEs) 734 * defined GPEs)
724 * gpe_number - The GPE number within the GPE block 735 * gpe_number - The GPE number within the GPE block
725 * type - Whether this GPE should be treated as an 736 * type - Whether this GPE should be treated as an
726 * edge- or level-triggered interrupt. 737 * edge- or level-triggered interrupt.
738 * is_raw_handler - Whether this GPE should be handled using
739 * the special GPE handler mode.
727 * address - Address of the handler 740 * address - Address of the handler
728 * context - Value passed to the handler on each GPE 741 * context - Value passed to the handler on each GPE
729 * 742 *
730 * RETURN: Status 743 * RETURN: Status
731 * 744 *
732 * DESCRIPTION: Install a handler for a General Purpose Event. 745 * DESCRIPTION: Internal function to install a handler for a General Purpose
746 * Event.
733 * 747 *
734 ******************************************************************************/ 748 ******************************************************************************/
735acpi_status 749static acpi_status
736acpi_install_gpe_handler(acpi_handle gpe_device, 750acpi_ev_install_gpe_handler(acpi_handle gpe_device,
737 u32 gpe_number, 751 u32 gpe_number,
738 u32 type, acpi_gpe_handler address, void *context) 752 u32 type,
753 u8 is_raw_handler,
754 acpi_gpe_handler address, void *context)
739{ 755{
740 struct acpi_gpe_event_info *gpe_event_info; 756 struct acpi_gpe_event_info *gpe_event_info;
741 struct acpi_gpe_handler_info *handler; 757 struct acpi_gpe_handler_info *handler;
742 acpi_status status; 758 acpi_status status;
743 acpi_cpu_flags flags; 759 acpi_cpu_flags flags;
744 760
745 ACPI_FUNCTION_TRACE(acpi_install_gpe_handler); 761 ACPI_FUNCTION_TRACE(ev_install_gpe_handler);
746 762
747 /* Parameter validation */ 763 /* Parameter validation */
748 764
@@ -775,8 +791,10 @@ acpi_install_gpe_handler(acpi_handle gpe_device,
775 791
776 /* Make sure that there isn't a handler there already */ 792 /* Make sure that there isn't a handler there already */
777 793
778 if (ACPI_GPE_DISPATCH_TYPE(gpe_event_info->flags) == 794 if ((ACPI_GPE_DISPATCH_TYPE(gpe_event_info->flags) ==
779 ACPI_GPE_DISPATCH_HANDLER) { 795 ACPI_GPE_DISPATCH_HANDLER) ||
796 (ACPI_GPE_DISPATCH_TYPE(gpe_event_info->flags) ==
797 ACPI_GPE_DISPATCH_RAW_HANDLER)) {
780 status = AE_ALREADY_EXISTS; 798 status = AE_ALREADY_EXISTS;
781 goto free_and_exit; 799 goto free_and_exit;
782 } 800 }
@@ -817,7 +835,10 @@ acpi_install_gpe_handler(acpi_handle gpe_device,
817 835
818 gpe_event_info->flags &= 836 gpe_event_info->flags &=
819 ~(ACPI_GPE_XRUPT_TYPE_MASK | ACPI_GPE_DISPATCH_MASK); 837 ~(ACPI_GPE_XRUPT_TYPE_MASK | ACPI_GPE_DISPATCH_MASK);
820 gpe_event_info->flags |= (u8)(type | ACPI_GPE_DISPATCH_HANDLER); 838 gpe_event_info->flags |=
839 (u8)(type |
840 (is_raw_handler ? ACPI_GPE_DISPATCH_RAW_HANDLER :
841 ACPI_GPE_DISPATCH_HANDLER));
821 842
822 acpi_os_release_lock(acpi_gbl_gpe_lock, flags); 843 acpi_os_release_lock(acpi_gbl_gpe_lock, flags);
823 844
@@ -831,10 +852,78 @@ free_and_exit:
831 goto unlock_and_exit; 852 goto unlock_and_exit;
832} 853}
833 854
855/*******************************************************************************
856 *
857 * FUNCTION: acpi_install_gpe_handler
858 *
859 * PARAMETERS: gpe_device - Namespace node for the GPE (NULL for FADT
860 * defined GPEs)
861 * gpe_number - The GPE number within the GPE block
862 * type - Whether this GPE should be treated as an
863 * edge- or level-triggered interrupt.
864 * address - Address of the handler
865 * context - Value passed to the handler on each GPE
866 *
867 * RETURN: Status
868 *
869 * DESCRIPTION: Install a handler for a General Purpose Event.
870 *
871 ******************************************************************************/
872
873acpi_status
874acpi_install_gpe_handler(acpi_handle gpe_device,
875 u32 gpe_number,
876 u32 type, acpi_gpe_handler address, void *context)
877{
878 acpi_status status;
879
880 ACPI_FUNCTION_TRACE(acpi_install_gpe_handler);
881
882 status =
883 acpi_ev_install_gpe_handler(gpe_device, gpe_number, type, FALSE,
884 address, context);
885
886 return_ACPI_STATUS(status);
887}
888
834ACPI_EXPORT_SYMBOL(acpi_install_gpe_handler) 889ACPI_EXPORT_SYMBOL(acpi_install_gpe_handler)
835 890
836/******************************************************************************* 891/*******************************************************************************
837 * 892 *
893 * FUNCTION: acpi_install_gpe_raw_handler
894 *
895 * PARAMETERS: gpe_device - Namespace node for the GPE (NULL for FADT
896 * defined GPEs)
897 * gpe_number - The GPE number within the GPE block
898 * type - Whether this GPE should be treated as an
899 * edge- or level-triggered interrupt.
900 * address - Address of the handler
901 * context - Value passed to the handler on each GPE
902 *
903 * RETURN: Status
904 *
905 * DESCRIPTION: Install a handler for a General Purpose Event.
906 *
907 ******************************************************************************/
908acpi_status
909acpi_install_gpe_raw_handler(acpi_handle gpe_device,
910 u32 gpe_number,
911 u32 type, acpi_gpe_handler address, void *context)
912{
913 acpi_status status;
914
915 ACPI_FUNCTION_TRACE(acpi_install_gpe_raw_handler);
916
917 status = acpi_ev_install_gpe_handler(gpe_device, gpe_number, type, TRUE,
918 address, context);
919
920 return_ACPI_STATUS(status);
921}
922
923ACPI_EXPORT_SYMBOL(acpi_install_gpe_raw_handler)
924
925/*******************************************************************************
926 *
838 * FUNCTION: acpi_remove_gpe_handler 927 * FUNCTION: acpi_remove_gpe_handler
839 * 928 *
840 * PARAMETERS: gpe_device - Namespace node for the GPE (NULL for FADT 929 * PARAMETERS: gpe_device - Namespace node for the GPE (NULL for FADT
@@ -881,8 +970,10 @@ acpi_remove_gpe_handler(acpi_handle gpe_device,
881 970
882 /* Make sure that a handler is indeed installed */ 971 /* Make sure that a handler is indeed installed */
883 972
884 if (ACPI_GPE_DISPATCH_TYPE(gpe_event_info->flags) != 973 if ((ACPI_GPE_DISPATCH_TYPE(gpe_event_info->flags) !=
885 ACPI_GPE_DISPATCH_HANDLER) { 974 ACPI_GPE_DISPATCH_HANDLER) &&
975 (ACPI_GPE_DISPATCH_TYPE(gpe_event_info->flags) !=
976 ACPI_GPE_DISPATCH_RAW_HANDLER)) {
886 status = AE_NOT_EXIST; 977 status = AE_NOT_EXIST;
887 goto unlock_and_exit; 978 goto unlock_and_exit;
888 } 979 }