From patchwork Tue Sep 25 07:29:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Drake X-Patchwork-Id: 10613571 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3DA38913 for ; Tue, 25 Sep 2018 07:29:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2C6F72988F for ; Tue, 25 Sep 2018 07:29:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1FA0C29932; Tue, 25 Sep 2018 07:29:30 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 059882988F for ; Tue, 25 Sep 2018 07:29:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727588AbeIYNfk (ORCPT ); Tue, 25 Sep 2018 09:35:40 -0400 Received: from mail-pf1-f193.google.com ([209.85.210.193]:37413 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727589AbeIYNfj (ORCPT ); Tue, 25 Sep 2018 09:35:39 -0400 Received: by mail-pf1-f193.google.com with SMTP id x26-v6so558664pfn.4 for ; Tue, 25 Sep 2018 00:29:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=endlessm-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=+bZdjxL6jexT2+aLOHSbHv07Eo8X0y3+lYfERgLaaiA=; b=wEaIUAVffhbLcWMTLGugOaMcdW3qQKmPRoGH42lWn+/q9vH7qF9dt5ecAl3XIB4wWz PDTDjVxR3GOgWsLChOnNtUyvjaCBUF6/KOJjO86Y/dZXJYT4PK+/pFAiR60/QN+Y8D+k Opx/4ty19s7RtzbgWwmU9k9dOA/nhfja2n8fk0UueZhaQqh5lFXcosiqNbrA0Ee4kY+X zLQyZoKcFZDX9X0JvURbpjhOPqX2U5/gIvq5tFUtEFqe9+pow9x2ldGMqYzqnICDujqg jdZCbbG7WMPvjDzFRTCJDbtEJpkfYaQU9nixPF2n98k8lGCYPBsigdjvRx+MyCd1NLEO w7tw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=+bZdjxL6jexT2+aLOHSbHv07Eo8X0y3+lYfERgLaaiA=; b=AF73zgGbn25ynHXSnz+i2pBZaR7RDI9TTCirCLdc9yNFDpNOamjzNGEbumRW+eQaw6 Uhxf+kyJahFaZDnmEuTrRo4Toc+XDlO4Ov8limb+dBnX0Uqe9ezmFKKRofqlCODsjKMp SRkGp8bvrlqzSD9uVWAoRAYph9fyIFr/MunsDCpzsc8BJwj8nvVqGBP4WfMgL2Ja7Md9 AoqW9f6CpUNwX+H+1AogDNqX63oS5C7alQtijooJpNxwXRlSPJjSh23HcaTXiQr6DDLo y7SE5BIYjF511d+dqSCZ5vrcmsbNdLVWFmpSpkxTngua2MW3WfUxmfB5Vv4uB40IR1xK cB6A== X-Gm-Message-State: ABuFfojTMOGiyj9mIbuvJJNK1/FJxQvb2ukywSewPeW8ckpmnyKAoeTr 2CUlO/TPw5LzOO/COiaccOfuSafvttY= X-Google-Smtp-Source: ACcGV62rQl69xScEruqGQXqagFkAuaMvKFBaZpJiq9PlaGocEev0zvgpuRDSzksh1JcQjJCvtXa52A== X-Received: by 2002:a17:902:2f43:: with SMTP id s61-v6mr2226359plb.176.1537860566760; Tue, 25 Sep 2018 00:29:26 -0700 (PDT) Received: from limbo.local (125-227-158-176.HINET-IP.hinet.net. [125.227.158.176]) by smtp.gmail.com with ESMTPSA id l21-v6sm1850250pgo.81.2018.09.25.00.29.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 25 Sep 2018 00:29:26 -0700 (PDT) From: Daniel Drake To: dmitry.torokhov@gmail.com Cc: linux-input@vger.kernel.org, linux-pm@vger.kernel.org, linux@endlessm.com, rjw@rjwysocki.net Subject: [PATCH v5] i8042: enable keyboard wakeups by default when s2idle is used Date: Tue, 25 Sep 2018 15:29:21 +0800 Message-Id: <20180925072921.13686-1-drake@endlessm.com> X-Mailer: git-send-email 2.17.1 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- Notes: v2: tweak comment as suggested by Rafael v3: fix checkpatch line length warning v4: add and use stub function pm_suspend_via_s2idle(). Fixes !CONFIG_SUSPEND case v5: export pm_suspend_via_s2idle() as a symbol. Fixes I8042=m case 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 b8bc71569349..95a78ccbd847 100644 --- a/drivers/input/serio/i8042.c +++ b/drivers/input/serio/i8042.c @@ -1395,15 +1395,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 5a28ac9284f0..3f529ad9a9d2 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 5342f6fc022e..0bd595a0b610 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();