Received: by 2002:ac0:aa62:0:0:0:0:0 with SMTP id w31-v6csp2047185ima; Mon, 22 Oct 2018 03:22:13 -0700 (PDT) X-Google-Smtp-Source: AJdET5ewXsms9Iwdecbq+G1L3g2JRGIY2DZKM9ospttCRagjJPxpflmM9gJbXqY9s04SIC/Sisp7 X-Received: by 2002:a17:902:b944:: with SMTP id h4-v6mr7563196pls.46.1540203733110; Mon, 22 Oct 2018 03:22:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540203733; cv=none; d=google.com; s=arc-20160816; b=ceWRjsEyFcDXo0j3hxwXIHrhVvX2Mz/9b1WRrlCc/crQ63Q//PdHCYGM2nL1atVThM tEbyRDQ73rqjgn4qa1GYrcUlYFq99xPp+IGorL55bSKfAxC8/wddh8gTa6vOIA3Z6aSV QMDiJIPIgOr5MstT/vXSt6MApKeLocIUG1bOnCel1A58ozpkVdTkHinWyb1ROUPwN/o5 Atrg6zWMKeOpBQPaZeXlFa7ZUi7/y61IxAZ7r8TwzkaAEDWC8wd+r6IkIh2UKBvny8WJ pxGrJBpKXOll4MehvE78u3z47emvVNLhbH/ueGggWKtpwQotnmB/N9fkV3F2bQ2Xgvc3 flOQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=mOH5psQJlgL5eJW/wJNZWaEY8Kn7IughL8J9kOpL26E=; b=nnbmxD3hPLY9rHZUdT8tkSar7oV+M6nEsO+pOn0yzK4hEmZr/HYpwlgLS98+rU4GKG wTeyayMhcyDSyeuqxLQL1MFKBt0G8RUKomOUGFp1AHkVYWib/FsjiDqa1Kb9h1K2ogLU BfGCUUcS5nrXipDVQhCDNPMNSJ6GZlaG4yILKH5Mm7VK+7u48TEDv1kF4h5FJxzjW8UO 3x9eV72e9Kw8XYjvBHub31xDyq/IeC6FqtW09Qu41Y6shqFUpC7li+iqdQMN+/9iGz29 0+zP1uf1eoQLTOx1M7CoUFT1u/IS1TR/YzJTRF/h3mx1EfSPw4sMTaX32XHvcxags1M2 cKPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=kEoyFlRr; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f25-v6si34090622pgb.170.2018.10.22.03.21.58; Mon, 22 Oct 2018 03:22:13 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=kEoyFlRr; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729063AbeJVSij (ORCPT + 99 others); Mon, 22 Oct 2018 14:38:39 -0400 Received: from mail.kernel.org ([198.145.29.99]:49446 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729012AbeJVSih (ORCPT ); Mon, 22 Oct 2018 14:38:37 -0400 Received: from sasha-vm.mshome.net (unknown [167.98.65.38]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 892552088F; Mon, 22 Oct 2018 10:20:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1540203641; bh=O8PfIDnG1p3AuR1XVjj1sfwEUFsntlViQaA+LbPTRTA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kEoyFlRrfpNMTyAM1ayVkTDEAump+9l0/JOLv17zeuIh3UbFD19rPbe8HhhDfhOyz u+VfQrhmt/rgHGyeVh5mmg0lUcEZCSQ3opJA/FiEscXKfdSLsT4HhHuXYPhKFQhmf6 2Pf7GBs6HqTK6BxEPWf8jDw29EwJKuScc5b+KIL8= From: Sasha Levin To: stable@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Daniel Drake , Dmitry Torokhov , Sasha Levin Subject: [PATCH AUTOSEL 4.14 03/15] Input: i8042 - enable keyboard wakeups by default when s2idle is used Date: Mon, 22 Oct 2018 06:20:14 -0400 Message-Id: <20181022102026.40869-3-sashal@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181022102026.40869-1-sashal@kernel.org> References: <20181022102026.40869-1-sashal@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Daniel Drake [ 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 Signed-off-by: Daniel Drake Signed-off-by: Dmitry Torokhov Signed-off-by: Sasha Levin --- 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 8544357d92d0..950b56d255ac 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 c0bc2c89697a..405e80219fe4 100644 --- a/kernel/power/suspend.c +++ b/kernel/power/suspend.c @@ -62,6 +62,12 @@ static DECLARE_WAIT_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