From patchwork Fri Sep 14 08:32:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Drake X-Patchwork-Id: 10600405 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 6BC9115E8 for ; Fri, 14 Sep 2018 08:32:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2CC572B34B for ; Fri, 14 Sep 2018 08:32:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 20C452B32F; Fri, 14 Sep 2018 08:32:45 +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=unavailable 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 AF1062B2B8 for ; Fri, 14 Sep 2018 08:32:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728178AbeINNqG (ORCPT ); Fri, 14 Sep 2018 09:46:06 -0400 Received: from mail-pl1-f195.google.com ([209.85.214.195]:43433 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726883AbeINNqG (ORCPT ); Fri, 14 Sep 2018 09:46:06 -0400 Received: by mail-pl1-f195.google.com with SMTP id f66-v6so3873145plb.10 for ; Fri, 14 Sep 2018 01:32:42 -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=L+g1mFnAUdE+lKwzqzGeQ4uge7g2VRtJvcaJuHXfhR0=; b=RaeD05v54E5EtXXR7PIuH13YrvNTV9qQxbfA5e/V4rWW33h27gGcdUq/32p3DH2Obc qmnzj7U4Z1iV/DU8TXS8ByIFal29N1piyli1xpuYIAP3AtNbKrh27Qq1/GCLKW5ZCSBS oKieLWoavlfEpPzFYastbqVQKLjEn0dohvnkWO5ouT9/kkW+g86c0ziXe/KvP3ytvPPV +ONY8gj1wpWtXw5oEv1a/xHsuy5tRjK27ZpSLB1j+hw9pb5v/OKZkYgP1PQwuecz1Det SCckb1PJdzwRfvbZbrnQge21MGK0NssIr/YFs1+R50ejzoogq6yi1FjBEWZ+GWzvZ+gr LNzg== 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=L+g1mFnAUdE+lKwzqzGeQ4uge7g2VRtJvcaJuHXfhR0=; b=lhPjEl0Z77ni9J0giuefH4ZilepZ3YEjYsLgsOvfWW33REIgl7p2Gxm4rIqaqTsK9F 4945h4SYLzxvqtDuUzPZ2+qtpi+pEy09xKTASqdelGyXhIX0kGKwn+elGExsRTSJNWji LR2lxxGlVm0E93fpUHNdJTR6Xz8XCkDKDbilwEzzMXKd6uFYA0MEmqsPvucoQur9Wq1y q1buD6SjaZdcnn/NJAMluoNgWsvD3YPn7FXmoTXwamJyCnzQMR6ltnIz/FyQHUKEcFwr RUmfzTllp7H3+o9nsMyKT4/ulO+sk3mnwsRBh0vNeUhtm1PCYdkFEj7IipwC1+VDuc3M +cpg== X-Gm-Message-State: APzg51CDSUBSYUzi0k5jnOOQ3hiA5wJg5gCC4vEznqj54QoXNIt/RReS mCpam8RSuHWT6Xgk/PF0J2S+Dg== X-Google-Smtp-Source: ANB0VdbpGLwwxC7ahyboUbyCDlyQJUG2JBovLdmRhRw01cE9Jpu+ztVExFbhY/gsjORQcOcM+/2d9g== X-Received: by 2002:a17:902:4081:: with SMTP id c1-v6mr11022709pld.169.1536913961530; Fri, 14 Sep 2018 01:32:41 -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 83-v6sm11349938pft.40.2018.09.14.01.32.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 14 Sep 2018 01:32:40 -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 v4] i8042: enable keyboard wakeups by default when s2idle is used Date: Fri, 14 Sep 2018 16:32:35 +0800 Message-Id: <20180914083235.6332-1-drake@endlessm.com> X-Mailer: git-send-email 2.17.1 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@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 drivers/input/serio/i8042.c | 29 ++++++++++++++++++++--------- include/linux/suspend.h | 6 ++++++ 2 files changed, 26 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..82eb8e6e24de 100644 --- a/include/linux/suspend.h +++ b/include/linux/suspend.h @@ -237,6 +237,11 @@ static inline bool pm_resume_via_firmware(void) return !!(pm_suspend_global_flags & PM_SUSPEND_FLAG_FW_RESUME); } +static inline bool pm_suspend_via_s2idle(void) +{ + return mem_sleep_current == PM_SUSPEND_TO_IDLE; +} + /* Suspend-to-idle state machnine. */ enum s2idle_states { S2IDLE_STATE_NONE, /* Not suspended/suspending. */ @@ -282,6 +287,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; }