drivers/acpi: Clear status of an event before enabling it
Subsystems (2)
PATCH 1/1 drivers/acpi: Clear status of an event before enabling it
Commit 18996f2db918 ("ACPICA: Events: Stop unconditionally clearing ACPI IRQs during suspend/resume") was added to stop clearing of event status bits unconditionally on suspend and resume paths. This was done because of an issue
reported (https://bugzilla.kernel.org/show_bug.cgi?id=196249) where lid status stays closed even on resume (which happens because event status bits are cleared unconditionally on resume). Though this change fixed the issue on suspend path, it introduced regressions on several resume paths.
First regression was reported and fixed on S5 path by the following
change: commit fa85015c0d95 ("ACPICA: Clear status of all events when entering S5"). Next regression was reported and fixed on all legacy sleep paths by the commit f317c7dc12b7 ("ACPICA: Clear status of all events when entering sleep states"). However, regression still exists on S0ix sleep path since it does not follow the legacy sleep path.
In case of S0ix, events are enabled as part of device suspend path. If status bits for the events are set when they are enabled, it could result in premature wake from S0ix. This change ensures that status is cleared for any event that is being enabled so that any stale events are cleared out.
--- drivers/acpi/acpica/evgpe.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/acpi/acpica/evgpe.c +5 -1
@@ -81,8 +81,12 @@ acpi_status acpi_ev_enable_gpe(struct acpi_gpe_event_info *gpe_event_info)ACPI_FUNCTION_TRACE (ev_enable_gpe); -/* Enable the requested 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 );return_ACPI_STATUS (status); }
Signature · 1 line
2.21.0.225.g810b269d1ac-goog
Adding authors of the original commit whom I failed to copy in the original patch.
Quoted 50 lines · Furquan Shaikh
Commit
18996f2db918("ACPICA: Events: Stop unconditionally clearing ACPI IRQs during suspend/resume") was added to stop clearing of event status bits unconditionally on suspend and resume paths. This was done because of an issue
reported (https://bugzilla.kernel.org/show_bug.cgi?id=196249) where lid status stays closed even on resume (which happens because event status bits are cleared unconditionally on resume). Though this change fixed the issue on suspend path, it introduced regressions on several resume paths.First regression was reported and fixed on S5 path by the following
change: commitfa85015c0d95("ACPICA: Clear status of all events when entering S5"). Next regression was reported and fixed on all legacy sleep paths by the commitf317c7dc12b7("ACPICA: Clear status of all events when entering sleep states"). However, regression still exists on S0ix sleep path since it does not follow the legacy sleep path.In case of S0ix, events are enabled as part of device suspend path. If status bits for the events are set when they are enabled, it could result in premature wake from S0ix. This change ensures that status is cleared for any event that is being enabled so that any stale events are cleared out.
Signed-off-by Furquan Shaikh <[email protected]>--- drivers/acpi/acpica/evgpe.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)drivers/acpi/acpica/evgpe.c +5
-2@@ -81,8 +81,12 @@ acpi_status acpi_ev_enable_gpe(struct acpi_gpe_event_info *gpe_event_info)ACPI_FUNCTION_TRACE (ev_enable_gpe); -/* Enable the requested 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 );return_ACPI_STATUS (status); } --2.21.0.225.g810b269d1ac-goog
Rafael J. Wysocki
maintainerQuoted 11 lines · Furquan Shaikh
Commit
18996f2db918("ACPICA: Events: Stop unconditionally clearing ACPI IRQs during suspend/resume") was added to stop clearing of event status bits unconditionally on suspend and resume paths. This was done because of an issue
reported (https://bugzilla.kernel.org/show_bug.cgi?id=196249) where lid status stays closed even on resume (which happens because event status bits are cleared unconditionally on resume). Though this change fixed the issue on suspend path, it introduced regressions on several resume paths.
Quoted 6 lines
First regression was reported and fixed on S5 path by the following
change: commitfa85015c0d95("ACPICA: Clear status of all events when entering S5"). Next regression was reported and fixed on all legacy sleep paths by the commitf317c7dc12b7("ACPICA: Clear status of all events when entering sleep states"). However, regression still exists on S0ix sleep path since it does not follow the legacy sleep path.
What exactly is failing?
Quoted 16 lines
In case of S0ix, events are enabled as part of device suspend path. If status bits for the events are set when they are enabled, it could result in premature wake from S0ix. This change ensures that status is cleared for any event that is being enabled so that any stale events are cleared out.
Signed-off-by Furquan Shaikh <furquan(a)google.com>--- drivers/acpi/acpica/evgpe.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)drivers/acpi/acpica/evgpe.c +0
-0
drivers/acpi/acpica/evgpe.c acpi_status acpi_ev_enable_gpe(struct acpi_gpe_event_info *gpe_event_info) · line 87
Quoted 8 lines
drivers/acpi/acpica/evgpe.c +4
-1@@ -81,8 +81,12 @@ acpi_status acpi_ev_enable_gpe(struct acpi_gpe_event_info *gpe_event_info)ACPI_FUNCTION_TRACE (ev_enable_gpe); -/* Enable the requested GPE */ +/* Clear the GPE (of stale events) */ + status =acpi_hw_clear_gpe (gpe_event_info); +if (ACPI_FAILURE (status)) +return_ACPI_STATUS (status);
Well, this may cause events to be missed.
Quoted 8 lines
drivers/acpi/acpica/evgpe.c +1
-1+/* Enable the requested GPE */ status =acpi_hw_low_set_gpe (gpe_event_info,ACPI_GPE_ENABLE );return_ACPI_STATUS (status); } --2.21.0.225.g810b269d1ac-goog
Quoted 13 lines · Rafael J. Wysocki
Quoted 11 lines · Furquan Shaikh
Commit
18996f2db918("ACPICA: Events: Stop unconditionally clearing ACPI IRQs during suspend/resume") was added to stop clearing of event status bits unconditionally on suspend and resume paths. This was done because of an issue
reported (https://bugzilla.kernel.org/show_bug.cgi?id=196249) where lid status stays closed even on resume (which happens because event status bits are cleared unconditionally on resume). Though this change fixed the issue on suspend path, it introduced regressions on several resume paths.
Quoted 8 lines
Quoted 6 lines
First regression was reported and fixed on S5 path by the following
change: commitfa85015c0d95("ACPICA: Clear status of all events when entering S5"). Next regression was reported and fixed on all legacy sleep paths by the commitf317c7dc12b7("ACPICA: Clear status of all events when entering sleep states"). However, regression still exists on S0ix sleep path since it does not follow the legacy sleep path.What exactly is failing?
Here is the failure scenario:
1. Consider the case of trackpad which acts as a wake source.
2. Since the pad is configured for SCI, GPE_STS gets set for that pad during normal interrupts as well (i.e. during probe at boot or when using the trackpad)
3. Now, when the platform decides to enter S0ix, it enables the wake on trackpad by enabling appropriate GPE_EN bit.
4. So, at this point, we are in a situation where GPE_EN as well as GPE_STS are set.
5. Now, if the platform enters S0ix, having GPE_STS set will result in unwanted wakes because of stale events.
This is similar to what was fixed on the legacy sleep path:
https://lkml.org/lkml/2018/8/12/42. However, as S0ix does not follow the legacy sleep path, clearing of GPE status does not happen. Thus, it is causing failures to go into S0ix on our platforms because of the stale wake events as described above.
Quoted 20 lines
Quoted 20 lines
In case of S0ix, events are enabled as part of device suspend path. If status bits for the events are set when they are enabled, it could result in premature wake from S0ix. This change ensures that status is cleared for any event that is being enabled so that any stale events are cleared out.
Signed-off-by Furquan Shaikh <[email protected]>--- drivers/acpi/acpica/evgpe.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)drivers/acpi/acpica/evgpe.c +0
-0@@ -81,8 +81,12 @@ acpi_status acpi_ev_enable_gpe(struct acpi_gpe_event_info *gpe_event_info)ACPI_FUNCTION_TRACE (ev_enable_gpe);
Quoted 7 lines
drivers/acpi/acpica/evgpe.c acpi_status acpi_ev_enable_gpe(struct acpi_gpe_event_info *gpe_event_info) · line 87
Quoted 5 lines
drivers/acpi/acpica/evgpe.c +4
-1-/* Enable the requested GPE */ +/* Clear the GPE (of stale events) */ + status =acpi_hw_clear_gpe (gpe_event_info); +if (ACPI_FAILURE (status)) +return_ACPI_STATUS (status);Well, this may cause events to be missed.
Won't those be stale events? i.e. any event that has occurred before GPE is enabled should be ignored.
Quoted 9 lines
Quoted 9 lines
drivers/acpi/acpica/evgpe.c +1
-1+/* Enable the requested GPE */ status =acpi_hw_low_set_gpe (gpe_event_info,ACPI_GPE_ENABLE );return_ACPI_STATUS (status); } --2.21.0.225.g810b269d1ac-goog
Rafael J. Wysocki
maintainerQuoted 22 lines · Furquan Shaikh
Quoted 20 lines · Rafael J. Wysocki
Quoted 17 lines · Furquan Shaikh
Commit
18996f2db918("ACPICA: Events: Stop unconditionally clearing ACPI IRQs during suspend/resume") was added to stop clearing of event status bits unconditionally on suspend and resume paths. This was done because of an issue
reported (https://bugzilla.kernel.org/show_bug.cgi?id=196249) where lid status stays closed even on resume (which happens because event status bits are cleared unconditionally on resume). Though this change fixed the issue on suspend path, it introduced regressions on several resume paths.First regression was reported and fixed on S5 path by the following
change: commitfa85015c0d95("ACPICA: Clear status of all events when entering S5"). Next regression was reported and fixed on all legacy sleep paths by the commitf317c7dc12b7("ACPICA: Clear status of all events when entering sleep states"). However, regression still exists on S0ix sleep path since it does not follow the legacy sleep path.
Quoted 8 lines
Quoted 1 line
What exactly is failing?
Here is the failure scenario:
1. Consider the case of trackpad which acts as a wake source.
2. Since the pad is configured for SCI,GPE_STSgets set for that pad during normal interrupts as well (i.e. during probe at boot or when using the trackpad)
I don't quite understand this.
Is the same GPE used for signaling trackpad events in the system working state and for wakeup?
Quoted 41 lines
3. Now, when the platform decides to enter S0ix, it enables the wake on trackpad by enabling appropriate
GPE_ENbit.
4. So, at this point, we are in a situation whereGPE_ENas well asGPE_STSare set.
5. Now, if the platform enters S0ix, havingGPE_STSset will result in unwanted wakes because of stale events.This is similar to what was fixed on the legacy sleep path:
https://lkml.org/lkml/2018/8/12/42. However, as S0ix does not follow the legacy sleep path, clearing of GPE status does not happen. Thus, it is causing failures to go into S0ix on our platforms because of the stale wake events as described above.Quoted 20 lines
Quoted 20 lines
In case of S0ix, events are enabled as part of device suspend path. If status bits for the events are set when they are enabled, it could result in premature wake from S0ix. This change ensures that status is cleared for any event that is being enabled so that any stale events are cleared out.
Signed-off-by Furquan Shaikh <furquan(a)google.com>--- drivers/acpi/acpica/evgpe.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)drivers/acpi/acpica/evgpe.c +0
-0@@ -81,8 +81,12 @@ acpi_status acpi_ev_enable_gpe(struct acpi_gpe_event_info *gpe_event_info)ACPI_FUNCTION_TRACE (ev_enable_gpe);Quoted 7 lines
drivers/acpi/acpica/evgpe.c acpi_status acpi_ev_enable_gpe(struct acpi_gpe_event_info *gpe_event_info) · line 87
Quoted 5 lines
drivers/acpi/acpica/evgpe.c +4
-1-/* Enable the requested GPE */ +/* Clear the GPE (of stale events) */ + status =acpi_hw_clear_gpe (gpe_event_info); +if (ACPI_FAILURE (status)) +return_ACPI_STATUS (status);Well, this may cause events to be missed.
Quoted 1 line
Won't those be stale events?
They need not be stale, the device may have already detected some activity before the GPE is enabled.
Quoted 1 line
i.e. any event that has occurred before GPE is enabled should be ignored.
But this is a good point.
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
drivers/acpi/acpica/evgpe.c +1
-1+/* Enable the requested GPE */ status =acpi_hw_low_set_gpe (gpe_event_info,ACPI_GPE_ENABLE );return_ACPI_STATUS (status); } --
Quoted 33 lines · Rafael J. Wysocki
Quoted 22 lines · Furquan Shaikh
Quoted 20 lines · Rafael J. Wysocki
Quoted 17 lines · Furquan Shaikh
Commit
18996f2db918("ACPICA: Events: Stop unconditionally clearing ACPI IRQs during suspend/resume") was added to stop clearing of event status bits unconditionally on suspend and resume paths. This was done because of an issue
reported (https://bugzilla.kernel.org/show_bug.cgi?id=196249) where lid status stays closed even on resume (which happens because event status bits are cleared unconditionally on resume). Though this change fixed the issue on suspend path, it introduced regressions on several resume paths.First regression was reported and fixed on S5 path by the following
change: commitfa85015c0d95("ACPICA: Clear status of all events when entering S5"). Next regression was reported and fixed on all legacy sleep paths by the commitf317c7dc12b7("ACPICA: Clear status of all events when entering sleep states"). However, regression still exists on S0ix sleep path since it does not follow the legacy sleep path.Quoted 8 lines
Quoted 1 line
What exactly is failing?
Here is the failure scenario:
1. Consider the case of trackpad which acts as a wake source.
2. Since the pad is configured for SCI,GPE_STSgets set for that pad during normal interrupts as well (i.e. during probe at boot or when using the trackpad)
Quoted 4 lines
I don't quite understand this.
Is the same GPE used for signaling trackpad events in the system working state and for wakeup?
Yes. The same pad is being configured for interrupts (i.e. routed to APIC) during S0 as well as configured for GPE (i.e. routed for SCI) to cause wakes when in S0ix/S3. This pad is externally connected to trackpad interrupt line.
Quoted 59 lines
Quoted 42 lines
3. Now, when the platform decides to enter S0ix, it enables the wake on trackpad by enabling appropriate
GPE_ENbit.
4. So, at this point, we are in a situation whereGPE_ENas well asGPE_STSare set.
5. Now, if the platform enters S0ix, havingGPE_STSset will result in unwanted wakes because of stale events.This is similar to what was fixed on the legacy sleep path:
https://lkml.org/lkml/2018/8/12/42. However, as S0ix does not follow the legacy sleep path, clearing of GPE status does not happen. Thus, it is causing failures to go into S0ix on our platforms because of the stale wake events as described above.Quoted 20 lines
Quoted 20 lines
In case of S0ix, events are enabled as part of device suspend path. If status bits for the events are set when they are enabled, it could result in premature wake from S0ix. This change ensures that status is cleared for any event that is being enabled so that any stale events are cleared out.
Signed-off-by Furquan Shaikh <[email protected]>--- drivers/acpi/acpica/evgpe.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)drivers/acpi/acpica/evgpe.c +0
-0@@ -81,8 +81,12 @@ acpi_status acpi_ev_enable_gpe(struct acpi_gpe_event_info *gpe_event_info)ACPI_FUNCTION_TRACE (ev_enable_gpe);Quoted 7 lines
drivers/acpi/acpica/evgpe.c acpi_status acpi_ev_enable_gpe(struct acpi_gpe_event_info *gpe_event_info) · line 87
Quoted 5 lines
drivers/acpi/acpica/evgpe.c +4
-1-/* Enable the requested GPE */ +/* Clear the GPE (of stale events) */ + status =acpi_hw_clear_gpe (gpe_event_info); +if (ACPI_FAILURE (status)) +return_ACPI_STATUS (status);Well, this may cause events to be missed.
Quoted 1 line
Won't those be stale events?
They need not be stale, the device may have already detected some activity before the GPE is enabled.
Quoted 1 line
i.e. any event that has occurred before GPE is enabled should be ignored.
But this is a good point.
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
drivers/acpi/acpica/evgpe.c +1
-1+/* Enable the requested GPE */ status =acpi_hw_low_set_gpe (gpe_event_info,ACPI_GPE_ENABLE );return_ACPI_STATUS (status); } --
Rafael J. Wysocki
maintainerQuoted 37 lines · Furquan Shaikh
Quoted 35 lines · Rafael J. Wysocki
Quoted 22 lines · Furquan Shaikh
Quoted 20 lines · Rafael J. Wysocki
Quoted 17 lines · Furquan Shaikh
Commit
18996f2db918("ACPICA: Events: Stop unconditionally clearing ACPI IRQs during suspend/resume") was added to stop clearing of event status bits unconditionally on suspend and resume paths. This was done because of an issue
reported (https://bugzilla.kernel.org/show_bug.cgi?id=196249) where lid status stays closed even on resume (which happens because event status bits are cleared unconditionally on resume). Though this change fixed the issue on suspend path, it introduced regressions on several resume paths.First regression was reported and fixed on S5 path by the following
change: commitfa85015c0d95("ACPICA: Clear status of all events when entering S5"). Next regression was reported and fixed on all legacy sleep paths by the commitf317c7dc12b7("ACPICA: Clear status of all events when entering sleep states"). However, regression still exists on S0ix sleep path since it does not follow the legacy sleep path.Quoted 8 lines
Quoted 1 line
What exactly is failing?
Here is the failure scenario:
1. Consider the case of trackpad which acts as a wake source.
2. Since the pad is configured for SCI,GPE_STSgets set for that pad during normal interrupts as well (i.e. during probe at boot or when using the trackpad)I don't quite understand this.
Quoted 7 lines
Quoted 2 lines
Is the same GPE used for signaling trackpad events in the system working state and for wakeup?
Yes. The same pad is being configured for interrupts (i.e. routed to APIC) during S0 as well as configured for GPE (i.e. routed for SCI) to cause wakes when in S0ix/S3. This pad is externally connected to trackpad interrupt line.
And the way the system is wired up causes the GPE status to be set when it is enabled, I suppose?
So effectively, you need to disable the active-state IRQ, then clear the GPE status and enable it for wakeup.
OK, I'll queue up the patch (and talk to the upstream ACPICA people about taking it in there).
Thanks!
Quoted 42 lines · Rafael J. Wysocki
Quoted 40 lines · Furquan Shaikh
Quoted 37 lines · Rafael J. Wysocki
Quoted 22 lines · Furquan Shaikh
Quoted 20 lines · Rafael J. Wysocki
Quoted 17 lines · Furquan Shaikh
Commit
18996f2db918("ACPICA: Events: Stop unconditionally clearing ACPI IRQs during suspend/resume") was added to stop clearing of event status bits unconditionally on suspend and resume paths. This was done because of an issue
reported (https://bugzilla.kernel.org/show_bug.cgi?id=196249) where lid status stays closed even on resume (which happens because event status bits are cleared unconditionally on resume). Though this change fixed the issue on suspend path, it introduced regressions on several resume paths.First regression was reported and fixed on S5 path by the following
change: commitfa85015c0d95("ACPICA: Clear status of all events when entering S5"). Next regression was reported and fixed on all legacy sleep paths by the commitf317c7dc12b7("ACPICA: Clear status of all events when entering sleep states"). However, regression still exists on S0ix sleep path since it does not follow the legacy sleep path.Quoted 8 lines
Quoted 1 line
What exactly is failing?
Here is the failure scenario:
1. Consider the case of trackpad which acts as a wake source.
2. Since the pad is configured for SCI,GPE_STSgets set for that pad during normal interrupts as well (i.e. during probe at boot or when using the trackpad)I don't quite understand this.
Is the same GPE used for signaling trackpad events in the system working state and for wakeup?
Quoted 7 lines
Quoted 4 lines
Yes. The same pad is being configured for interrupts (i.e. routed to APIC) during S0 as well as configured for GPE (i.e. routed for SCI) to cause wakes when in S0ix/S3. This pad is externally connected to trackpad interrupt line.
And the way the system is wired up causes the GPE status to be set when it is enabled, I suppose?
That is correct.
Quoted 6 lines
So effectively, you need to disable the active-state IRQ, then clear the GPE status and enable it for wakeup.
OK, I'll queue up the patch (and talk to the upstream ACPICA people about taking it in there).
Thank you!
Quoted 2 lines
Thanks!