public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] ACPICA: Events: Fix GPE enabling issues related to edge-triggered GPEs
@ 2017-08-11  5:57 Lv Zheng
  2017-08-11  5:57 ` [PATCH 1/2] ACPICA: Events: Stop unconditionally clearing ACPI IRQs during suspend/resume Lv Zheng
  2017-08-11  5:57 ` [PATCH 2/2] ACPICA: Events: Dispatch GPEs after enabling for the first time Lv Zheng
  0 siblings, 2 replies; 3+ messages in thread
From: Lv Zheng @ 2017-08-11  5:57 UTC (permalink / raw)
  To: Rafael J . Wysocki, Len Brown, Robert Moore, Lv Zheng,
	David E . Box
  Cc: Lv Zheng, linux-kernel, linux-acpi, devel

There are 2 issues related to the enabling of GPEs:
1. Currently, our code clears GPE before enabling it. In case of edge
   triggered GPEs, doing this risks GPE losses.
2. For edge-triggered GPEs, enabling it is not sufficiently to trigger an
   already triggered GPE, we need to poll the GPE once it is enabled.
This patchset fixes these 2 problems.

Lv Zheng (2):
  ACPICA: Events: Stop unconditionally clearing ACPI IRQs during
    suspend/resume
  ACPICA: Events: Dispatch GPEs after enabling for the first time

 drivers/acpi/acpica/evgpe.c     |  7 -------
 drivers/acpi/acpica/evxfgpe.c   | 22 ++++++++++++++++++++++
 drivers/acpi/acpica/hwgpe.c     |  1 -
 drivers/acpi/acpica/hwsleep.c   | 11 ++---------
 drivers/acpi/acpica/hwxfsleep.c |  2 +-
 5 files changed, 25 insertions(+), 18 deletions(-)

-- 
2.7.4

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 1/2] ACPICA: Events: Stop unconditionally clearing ACPI IRQs during suspend/resume
  2017-08-11  5:57 [PATCH 0/2] ACPICA: Events: Fix GPE enabling issues related to edge-triggered GPEs Lv Zheng
@ 2017-08-11  5:57 ` Lv Zheng
  2017-08-11  5:57 ` [PATCH 2/2] ACPICA: Events: Dispatch GPEs after enabling for the first time Lv Zheng
  1 sibling, 0 replies; 3+ messages in thread
From: Lv Zheng @ 2017-08-11  5:57 UTC (permalink / raw)
  To: Rafael J . Wysocki, Len Brown, Robert Moore, Lv Zheng,
	David E . Box
  Cc: Lv Zheng, linux-kernel, linux-acpi, devel

Unconditionally clearing ACPI IRQs during suspend/resume can lead to
unexpected IRQ losts. This patch fixes this issue by removing such IRQ
clearing code.

If this patch triggers regression, the regression should be in the GPE
handlers that cannot correctly determine some spurious triggered events as
no-ops. Please report any regression related to this commit to the ACPI
component on kernel bugzilla. Reported by Eric Bakula-Davis, fixed by Lv
Zheng.

Link: https://bugzilla.kernel.org/show_bug.cgi?id=196249
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Reported-and-tested-by: Eric Bakula-Davis <ericbakuladavis@gmail.com>
Tested-by: Mika Westerberg <mika.westerberg@linux.intel.com>
---
 drivers/acpi/acpica/evgpe.c     |  7 -------
 drivers/acpi/acpica/hwgpe.c     |  1 -
 drivers/acpi/acpica/hwsleep.c   | 11 ++---------
 drivers/acpi/acpica/hwxfsleep.c |  2 +-
 4 files changed, 3 insertions(+), 18 deletions(-)

diff --git a/drivers/acpi/acpica/evgpe.c b/drivers/acpi/acpica/evgpe.c
index 2293820..390a5ce 100644
--- a/drivers/acpi/acpica/evgpe.c
+++ b/drivers/acpi/acpica/evgpe.c
@@ -115,13 +115,6 @@ acpi_status acpi_ev_enable_gpe(struct acpi_gpe_event_info *gpe_event_info)
 
 	ACPI_FUNCTION_TRACE(ev_enable_gpe);
 
-	/* Clear the GPE (of stale events) */
-
-	status = acpi_hw_clear_gpe(gpe_event_info);
-	if (ACPI_FAILURE(status)) {
-		return_ACPI_STATUS(status);
-	}
-
 	/* Enable the requested GPE */
 
 	status = acpi_hw_low_set_gpe(gpe_event_info, ACPI_GPE_ENABLE);
diff --git a/drivers/acpi/acpica/hwgpe.c b/drivers/acpi/acpica/hwgpe.c
index 5eb11b3..e004d5f 100644
--- a/drivers/acpi/acpica/hwgpe.c
+++ b/drivers/acpi/acpica/hwgpe.c
@@ -497,7 +497,6 @@ acpi_status acpi_hw_disable_all_gpes(void)
 	ACPI_FUNCTION_TRACE(hw_disable_all_gpes);
 
 	status = acpi_ev_walk_gpe_list(acpi_hw_disable_gpe_block, NULL);
-	status = acpi_ev_walk_gpe_list(acpi_hw_clear_gpe_block, NULL);
 	return_ACPI_STATUS(status);
 }
 
diff --git a/drivers/acpi/acpica/hwsleep.c b/drivers/acpi/acpica/hwsleep.c
index 1fe7387..8f54af6 100644
--- a/drivers/acpi/acpica/hwsleep.c
+++ b/drivers/acpi/acpica/hwsleep.c
@@ -85,15 +85,8 @@ acpi_status acpi_hw_legacy_sleep(u8 sleep_state)
 		return_ACPI_STATUS(status);
 	}
 
-	/* Clear all fixed and general purpose status bits */
-
-	status = acpi_hw_clear_acpi_status();
-	if (ACPI_FAILURE(status)) {
-		return_ACPI_STATUS(status);
-	}
-
 	/*
-	 * 1) Disable/Clear all GPEs
+	 * 1) Disable all GPEs
 	 * 2) Enable all wakeup GPEs
 	 */
 	status = acpi_hw_disable_all_gpes();
@@ -299,7 +292,7 @@ acpi_status acpi_hw_legacy_wake(u8 sleep_state)
 	 * might get fired there
 	 *
 	 * Restore the GPEs:
-	 * 1) Disable/Clear all GPEs
+	 * 1) Disable all GPEs
 	 * 2) Enable all runtime GPEs
 	 */
 	status = acpi_hw_disable_all_gpes();
diff --git a/drivers/acpi/acpica/hwxfsleep.c b/drivers/acpi/acpica/hwxfsleep.c
index 7ef1393..1888107 100644
--- a/drivers/acpi/acpica/hwxfsleep.c
+++ b/drivers/acpi/acpica/hwxfsleep.c
@@ -206,7 +206,7 @@ acpi_status acpi_enter_sleep_state_s4bios(void)
 	}
 
 	/*
-	 * 1) Disable/Clear all GPEs
+	 * 1) Disable all GPEs
 	 * 2) Enable all wakeup GPEs
 	 */
 	status = acpi_hw_disable_all_gpes();
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 2/2] ACPICA: Events: Dispatch GPEs after enabling for the first time
  2017-08-11  5:57 [PATCH 0/2] ACPICA: Events: Fix GPE enabling issues related to edge-triggered GPEs Lv Zheng
  2017-08-11  5:57 ` [PATCH 1/2] ACPICA: Events: Stop unconditionally clearing ACPI IRQs during suspend/resume Lv Zheng
@ 2017-08-11  5:57 ` Lv Zheng
  1 sibling, 0 replies; 3+ messages in thread
From: Lv Zheng @ 2017-08-11  5:57 UTC (permalink / raw)
  To: Rafael J . Wysocki, Len Brown, Robert Moore, Lv Zheng,
	David E . Box
  Cc: Lv Zheng, linux-kernel, linux-acpi, devel

After being enabled for the first time, the GPEs may have STS bits already
set. Setting EN bits is not sufficient to trigger the GPEs again, so this
patch polls GPEs after enabling them for the first time.
This is a simpler version on top of the "GPE clear" fix generated according
to Mika's report and Rafael's original Linux based fix. Based on Linux
commit originated from Rafael J. Wysocki, fixed by Lv Zheng, tested by Mika
Westerberg.

Original-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Tested-by: Mika Westerberg <mika.westerberg@linux.intel.com>
---
 drivers/acpi/acpica/evxfgpe.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/drivers/acpi/acpica/evxfgpe.c b/drivers/acpi/acpica/evxfgpe.c
index 57718a3..d8be21d 100644
--- a/drivers/acpi/acpica/evxfgpe.c
+++ b/drivers/acpi/acpica/evxfgpe.c
@@ -97,6 +97,14 @@ acpi_status acpi_update_all_gpes(void)
 unlock_and_exit:
 	(void)acpi_ut_release_mutex(ACPI_MTX_EVENTS);
 
+	/*
+	 * Poll GPEs to handle already triggered events.
+	 * It is not sufficient to trigger edge-triggered GPE with specific
+	 * GPE chips, software need to poll once after enabling.
+	 */
+	if (acpi_gbl_all_gpes_initialized) {
+		acpi_ev_gpe_detect(acpi_gbl_gpe_xrupt_list_head);
+	}
 	return_ACPI_STATUS(status);
 }
 
@@ -120,6 +128,7 @@ acpi_status acpi_enable_gpe(acpi_handle gpe_device, u32 gpe_number)
 	acpi_status status = AE_BAD_PARAMETER;
 	struct acpi_gpe_event_info *gpe_event_info;
 	acpi_cpu_flags flags;
+	u8 poll_gpes = FALSE;
 
 	ACPI_FUNCTION_TRACE(acpi_enable_gpe);
 
@@ -135,12 +144,25 @@ acpi_status acpi_enable_gpe(acpi_handle gpe_device, u32 gpe_number)
 		if (ACPI_GPE_DISPATCH_TYPE(gpe_event_info->flags) !=
 		    ACPI_GPE_DISPATCH_NONE) {
 			status = acpi_ev_add_gpe_reference(gpe_event_info);
+			if (ACPI_SUCCESS(status) &&
+			    gpe_event_info->runtime_count == 1) {
+				poll_gpes = TRUE;
+			}
 		} else {
 			status = AE_NO_HANDLER;
 		}
 	}
 
 	acpi_os_release_lock(acpi_gbl_gpe_lock, flags);
+
+	/*
+	 * Poll GPEs to handle already triggered events.
+	 * It is not sufficient to trigger edge-triggered GPE with specific
+	 * GPE chips, software need to poll once after enabling.
+	 */
+	if (poll_gpes && acpi_gbl_all_gpes_initialized) {
+		acpi_ev_gpe_detect(acpi_gbl_gpe_xrupt_list_head);
+	}
 	return_ACPI_STATUS(status);
 }
 ACPI_EXPORT_SYMBOL(acpi_enable_gpe)
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-08-11  5:57 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-08-11  5:57 [PATCH 0/2] ACPICA: Events: Fix GPE enabling issues related to edge-triggered GPEs Lv Zheng
2017-08-11  5:57 ` [PATCH 1/2] ACPICA: Events: Stop unconditionally clearing ACPI IRQs during suspend/resume Lv Zheng
2017-08-11  5:57 ` [PATCH 2/2] ACPICA: Events: Dispatch GPEs after enabling for the first time Lv Zheng

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox