[PATCH v2 34/42] ACPICA: events: Fix GPE cleanup return after changing program state
From: Maciej Wieczor-Retman
Date: Fri Nov 20 2026 - 12:23:36 EST
If a GPE dispatch method or notify is currently getting executed or is
set to polling etc. its table can't be freed. However the original
commit ("ACPICA: Events: Clear GPE dispatch by owner during table
unload") that tried to fix this problem would check this condition while
some GPE methods already got disabled.
First parse all the GPE blocks and look if at least one element is
blocked from being freed. If so abort the cleanup operation.
Link: https://github.com/acpica/acpica/commit/97f12aaf72cc
Signed-off-by: Maciej Wieczor-Retman <maciej.wieczor-retman@xxxxxxxxx>
---
drivers/acpi/acpica/evgpe.c | 49 +++++++++++++++++++++++++++++--------
1 file changed, 39 insertions(+), 10 deletions(-)
diff --git a/drivers/acpi/acpica/evgpe.c b/drivers/acpi/acpica/evgpe.c
index d45926ad3261..5c283a2faaf0 100644
--- a/drivers/acpi/acpica/evgpe.c
+++ b/drivers/acpi/acpica/evgpe.c
@@ -636,6 +636,43 @@ acpi_status acpi_ev_clear_gpe_dispatch_by_owner(acpi_owner_id owner_id)
/* Walk all GPE interrupt blocks */
+ gpe_xrupt_info = acpi_gbl_gpe_xrupt_list_head;
+ while (gpe_xrupt_info) {
+ gpe_block = gpe_xrupt_info->gpe_block_list_head;
+ while (gpe_block) {
+ /*
+ * Walk all GPEs in this block to make sure none are blocked from
+ * getting cleared with disable_for_dispatch
+ */
+
+ for (gpe_number = 0; gpe_number < gpe_block->gpe_count;
+ gpe_number++) {
+ gpe_event_info =
+ &gpe_block->event_info[gpe_number];
+ gpe_dispatch_type =
+ acpi_ev_dispatch_type_hidden_handler(
+ gpe_event_info, owner_id);
+ if ((gpe_dispatch_type ==
+ ACPI_GPE_DISPATCH_METHOD ||
+ gpe_dispatch_type ==
+ ACPI_GPE_DISPATCH_NOTIFY) &&
+ gpe_event_info->disable_for_dispatch) {
+ /* At least one handler is polling or executing, cannot clear */
+ status = AE_ABORT_METHOD;
+ acpi_os_release_lock(acpi_gbl_gpe_lock,
+ flags);
+ (void)acpi_ut_release_mutex(
+ ACPI_MTX_EVENTS);
+ return_ACPI_STATUS(status);
+ }
+ }
+
+ gpe_block = gpe_block->next;
+ }
+
+ gpe_xrupt_info = gpe_xrupt_info->next;
+ }
+
gpe_xrupt_info = acpi_gbl_gpe_xrupt_list_head;
while (gpe_xrupt_info) {
gpe_block = gpe_xrupt_info->gpe_block_list_head;
@@ -656,17 +693,10 @@ acpi_status acpi_ev_clear_gpe_dispatch_by_owner(acpi_owner_id owner_id)
* GPE method belongs to table being unloaded. Clear
* only the dispatch type, preserve other flags.
*/
-
- if (gpe_event_info
- ->disable_for_dispatch) {
- /* Handler is executing, cannot clear */
- status = AE_ABORT_METHOD;
- } else {
- /* Clear only the dispatch type, preserve other flags */
gpe_event_info->flags &=
~ACPI_GPE_DISPATCH_MASK;
- gpe_event_info->dispatch
- .method_node = NULL;
+ gpe_event_info->dispatch.method_node =
+ NULL;
/*
* Hardware-disable the GPE so a late interrupt
@@ -676,7 +706,6 @@ acpi_status acpi_ev_clear_gpe_dispatch_by_owner(acpi_owner_id owner_id)
(void)acpi_hw_low_set_gpe(
gpe_event_info,
ACPI_GPE_DISABLE);
- }
break;
case ACPI_GPE_DISPATCH_HANDLER:
--
2.56.0