linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ACPI / PM: Propagate KEY_POWER wakeup events to user space
@ 2019-03-04  3:00 Chen, Hu
  2019-03-26 21:49 ` Rafael J. Wysocki
  0 siblings, 1 reply; 7+ messages in thread
From: Chen, Hu @ 2019-03-04  3:00 UTC (permalink / raw)
  Cc: hu1.chen, Rafael J. Wysocki, Len Brown, linux-acpi, linux-kernel

When the system is woken from S3 by the ACPI fixed power button, send
KEY_POWER to user space.

I run Android on x86 PC (it's a NUC). Everytime I press the power button
to wake the system, it suspends right away. After some debug, I find
that Android wants to see KEY_POWER at resume. Otherwise, its
opportunistic suspend will kick in shortly.

Signed-off-by: Chen, Hu <hu1.chen@intel.com>
---
 drivers/acpi/button.c | 4 +++-
 drivers/acpi/sleep.c  | 8 ++++++++
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/drivers/acpi/button.c b/drivers/acpi/button.c
index a19ff3977ac4..117718057938 100644
--- a/drivers/acpi/button.c
+++ b/drivers/acpi/button.c
@@ -33,6 +33,7 @@
 #include <linux/acpi.h>
 #include <linux/dmi.h>
 #include <acpi/button.h>
+#include <linux/suspend.h>
 
 #define PREFIX "ACPI: "
 
@@ -417,7 +418,8 @@ static void acpi_button_notify(struct acpi_device *device, u32 event)
 			int keycode;
 
 			acpi_pm_wakeup_event(&device->dev);
-			if (button->suspended)
+			if (button->suspended &&
+			    mem_sleep_current == PM_SUSPEND_TO_IDLE)
 				break;
 
 			keycode = test_bit(KEY_SLEEP, input->keybit) ?
diff --git a/drivers/acpi/sleep.c b/drivers/acpi/sleep.c
index 403c4ff15349..c5dcee9f5872 100644
--- a/drivers/acpi/sleep.c
+++ b/drivers/acpi/sleep.c
@@ -462,6 +462,13 @@ static int find_powerf_dev(struct device *dev, void *data)
 	return !strcmp(hid, ACPI_BUTTON_HID_POWERF);
 }
 
+static void pwr_btn_notify(struct device *dev)
+{
+	struct acpi_device *device = to_acpi_device(dev);
+
+	device->driver->ops.notify(device, ACPI_FIXED_HARDWARE_EVENT);
+}
+
 /**
  *	acpi_pm_finish - Instruct the platform to leave a sleep state.
  *
@@ -505,6 +512,7 @@ static void acpi_pm_finish(void)
 				      find_powerf_dev);
 	if (pwr_btn_dev) {
 		pm_wakeup_event(pwr_btn_dev, 0);
+		pwr_btn_notify(pwr_btn_dev);
 		put_device(pwr_btn_dev);
 	}
 }
-- 
2.20.1


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

end of thread, other threads:[~2019-03-29 12:32 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-04  3:00 [PATCH] ACPI / PM: Propagate KEY_POWER wakeup events to user space Chen, Hu
2019-03-26 21:49 ` Rafael J. Wysocki
2019-03-28 10:34   ` [PATCH v2] ACPI / PM: Propagate KEY_POWER to user space when resume Chen, Hu
2019-03-28 13:31     ` Hans de Goede
2019-03-29 10:25     ` Pavel Machek
2019-03-29 11:38       ` Hans de Goede
2019-03-29 12:32         ` Pavel Machek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).