linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: stable@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Daniel Drake <drake@endlessm.com>,
	Dmitry Torokhov <dmitry.torokhov@gmail.com>,
	Sasha Levin <sashal@kernel.org>
Subject: [PATCH AUTOSEL 4.18 04/27] Input: i8042 - enable keyboard wakeups by default when s2idle is used
Date: Mon, 22 Oct 2018 06:19:01 -0400	[thread overview]
Message-ID: <20181022101924.40531-4-sashal@kernel.org> (raw)
In-Reply-To: <20181022101924.40531-1-sashal@kernel.org>

From: Daniel Drake <drake@endlessm.com>

[ Upstream commit 684bec1092b6991ff2a7751e8a763898576eb5c2 ]

Previously, on typical consumer laptops, pressing a key on the keyboard
when the system is in suspend would cause it to wake up (default or
unconditional behaviour). This happens because the EC generates a SCI
interrupt in this scenario.

That is no longer true on modern laptops based on Intel WhiskeyLake,
including Acer Swift SF314-55G, Asus UX333FA, Asus UX433FN and Asus
UX533FD. We confirmed with Asus EC engineers that the "Modern Standby"
design has been modified so that the EC no longer generates a SCI
in this case; the keyboard controller itself should be used for wakeup.

In order to retain the standard behaviour of being able to use the
keyboard to wake up the system, enable serio wakeups by default on
platforms that are using s2idle.

Link: https://lkml.kernel.org/r/CAB4CAwfQ0mPMqCLp95TVjw4J0r5zKPWkSvvkK4cpZUGE--w8bQ@mail.gmail.com
Reviewed-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Daniel Drake <drake@endlessm.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/input/serio/i8042.c | 29 ++++++++++++++++++++---------
 include/linux/suspend.h     |  2 ++
 kernel/power/suspend.c      |  6 ++++++
 3 files changed, 28 insertions(+), 9 deletions(-)

diff --git a/drivers/input/serio/i8042.c b/drivers/input/serio/i8042.c
index 824f4c1c1f31..6462f1798fbb 100644
--- a/drivers/input/serio/i8042.c
+++ b/drivers/input/serio/i8042.c
@@ -1392,15 +1392,26 @@ static void __init i8042_register_ports(void)
 	for (i = 0; i < I8042_NUM_PORTS; i++) {
 		struct serio *serio = i8042_ports[i].serio;
 
-		if (serio) {
-			printk(KERN_INFO "serio: %s at %#lx,%#lx irq %d\n",
-				serio->name,
-				(unsigned long) I8042_DATA_REG,
-				(unsigned long) I8042_COMMAND_REG,
-				i8042_ports[i].irq);
-			serio_register_port(serio);
-			device_set_wakeup_capable(&serio->dev, true);
-		}
+		if (!serio)
+			continue;
+
+		printk(KERN_INFO "serio: %s at %#lx,%#lx irq %d\n",
+			serio->name,
+			(unsigned long) I8042_DATA_REG,
+			(unsigned long) I8042_COMMAND_REG,
+			i8042_ports[i].irq);
+		serio_register_port(serio);
+		device_set_wakeup_capable(&serio->dev, true);
+
+		/*
+		 * On platforms using suspend-to-idle, allow the keyboard to
+		 * wake up the system from sleep by enabling keyboard wakeups
+		 * by default.  This is consistent with keyboard wakeup
+		 * behavior on many platforms using suspend-to-RAM (ACPI S3)
+		 * by default.
+		 */
+		if (pm_suspend_via_s2idle() && i == I8042_KBD_PORT_NO)
+			device_set_wakeup_enable(&serio->dev, true);
 	}
 }
 
diff --git a/include/linux/suspend.h b/include/linux/suspend.h
index 440b62f7502e..206b735f383f 100644
--- a/include/linux/suspend.h
+++ b/include/linux/suspend.h
@@ -251,6 +251,7 @@ static inline bool idle_should_enter_s2idle(void)
 	return unlikely(s2idle_state == S2IDLE_STATE_ENTER);
 }
 
+extern bool pm_suspend_via_s2idle(void);
 extern void __init pm_states_init(void);
 extern void s2idle_set_ops(const struct platform_s2idle_ops *ops);
 extern void s2idle_wake(void);
@@ -282,6 +283,7 @@ static inline void pm_set_suspend_via_firmware(void) {}
 static inline void pm_set_resume_via_firmware(void) {}
 static inline bool pm_suspend_via_firmware(void) { return false; }
 static inline bool pm_resume_via_firmware(void) { return false; }
+static inline bool pm_suspend_via_s2idle(void) { return false; }
 
 static inline void suspend_set_ops(const struct platform_suspend_ops *ops) {}
 static inline int pm_suspend(suspend_state_t state) { return -ENOSYS; }
diff --git a/kernel/power/suspend.c b/kernel/power/suspend.c
index 87331565e505..3eeafaff190a 100644
--- a/kernel/power/suspend.c
+++ b/kernel/power/suspend.c
@@ -63,6 +63,12 @@ static DECLARE_SWAIT_QUEUE_HEAD(s2idle_wait_head);
 enum s2idle_states __read_mostly s2idle_state;
 static DEFINE_RAW_SPINLOCK(s2idle_lock);
 
+bool pm_suspend_via_s2idle(void)
+{
+	return mem_sleep_current == PM_SUSPEND_TO_IDLE;
+}
+EXPORT_SYMBOL_GPL(pm_suspend_via_s2idle);
+
 void s2idle_set_ops(const struct platform_s2idle_ops *ops)
 {
 	lock_system_sleep();
-- 
2.17.1


  parent reply	other threads:[~2018-10-22 10:19 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-22 10:18 [PATCH AUTOSEL 4.18 01/27] ARM: dts: imx53-qsb: disable 1.2GHz OPP Sasha Levin
2018-10-22 10:18 ` [PATCH AUTOSEL 4.18 02/27] s390/hibernate: fix error handling when suspend cpu != resume cpu Sasha Levin
2018-10-22 10:19 ` [PATCH AUTOSEL 4.18 03/27] perf report: Don't try to map ip to invalid map Sasha Levin
2018-10-22 10:19 ` Sasha Levin [this message]
2018-10-22 16:58   ` [PATCH AUTOSEL 4.18 04/27] Input: i8042 - enable keyboard wakeups by default when s2idle is used Dmitry Torokhov
2018-10-23 15:48     ` Sasha Levin
2018-10-22 10:19 ` [PATCH AUTOSEL 4.18 05/27] Input: mousedev - add a schedule point in mousedev_write() Sasha Levin
2018-10-22 10:19 ` [PATCH AUTOSEL 4.18 06/27] perf python: Use -Wno-redundant-decls to build with PYTHON=python3 Sasha Levin
2018-10-22 10:19 ` [PATCH AUTOSEL 4.18 07/27] perf record: Use unmapped IP for inline callchain cursors Sasha Levin
2018-10-22 10:19 ` [PATCH AUTOSEL 4.18 08/27] Input: evdev - add a schedule point in evdev_write() Sasha Levin
2018-10-22 17:02   ` Dmitry Torokhov
2018-10-23 15:49     ` Sasha Levin
2018-10-22 10:19 ` [PATCH AUTOSEL 4.18 09/27] Input: uinput - add a schedule point in uinput_inject_events() Sasha Levin
2018-10-22 10:19 ` [PATCH AUTOSEL 4.18 10/27] rxrpc: Don't check RXRPC_CALL_TX_LAST after calling rxrpc_rotate_tx_window() Sasha Levin
2018-10-22 10:19 ` [PATCH AUTOSEL 4.18 11/27] rxrpc: Carry call state out of locked section in rxrpc_rotate_tx_window() Sasha Levin
2018-10-22 10:19 ` [PATCH AUTOSEL 4.18 12/27] rxrpc: Only take the rwind and mtu values from latest ACK Sasha Levin
2018-10-22 10:19 ` [PATCH AUTOSEL 4.18 13/27] rxrpc: Fix connection-level abort handling Sasha Levin
2018-10-22 10:19 ` [PATCH AUTOSEL 4.18 14/27] KVM: x86: support CONFIG_KVM_AMD=y with CONFIG_CRYPTO_DEV_CCP_DD=m Sasha Levin
2018-10-22 10:19 ` [PATCH AUTOSEL 4.18 15/27] net: ena: fix warning in rmmod caused by double iounmap Sasha Levin
2018-10-22 10:19 ` [PATCH AUTOSEL 4.18 16/27] net: ena: fix rare bug when failed restart/resume is followed by driver removal Sasha Levin
2018-10-22 10:19 ` [PATCH AUTOSEL 4.18 17/27] net: ena: fix NULL dereference due to untimely napi initialization Sasha Levin
2018-10-22 10:19 ` [PATCH AUTOSEL 4.18 18/27] libertas: call into generic suspend code before turning off power Sasha Levin
2018-10-22 10:19 ` [PATCH AUTOSEL 4.18 19/27] gpio: Assign gpio_irq_chip::parents to non-stack pointer Sasha Levin
2018-10-22 10:19 ` [PATCH AUTOSEL 4.18 20/27] IB/mlx5: Unmap DMA addr from HCA before IOMMU Sasha Levin
2018-10-22 10:19 ` [PATCH AUTOSEL 4.18 21/27] rds: RDS (tcp) hangs on sendto() to unresponding address Sasha Levin
2018-10-22 10:19 ` [PATCH AUTOSEL 4.18 22/27] selftests: rtnetlink.sh explicitly requires bash Sasha Levin
2018-10-22 10:19 ` [PATCH AUTOSEL 4.18 23/27] selftests: udpgso_bench.sh " Sasha Levin
2018-10-22 10:19 ` [PATCH AUTOSEL 4.18 24/27] vmlinux.lds.h: Fix incomplete .text.exit discards Sasha Levin
2018-10-22 10:19 ` [PATCH AUTOSEL 4.18 25/27] vmlinux.lds.h: Fix linker warnings about orphan .LPBX sections Sasha Levin
2018-10-22 10:19 ` [PATCH AUTOSEL 4.18 26/27] afs: Fix cell proc list Sasha Levin
2018-10-22 10:19 ` [PATCH AUTOSEL 4.18 27/27] fs/fat/fatent.c: add cond_resched() to fat_count_free_clusters() Sasha Levin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181022101924.40531-4-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=dmitry.torokhov@gmail.com \
    --cc=drake@endlessm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).