From patchwork Tue Aug 30 23:15:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Raul E Rangel X-Patchwork-Id: 601314 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2280EC65C0D for ; Tue, 30 Aug 2022 23:16:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231524AbiH3XQR (ORCPT ); Tue, 30 Aug 2022 19:16:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37306 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231442AbiH3XQQ (ORCPT ); Tue, 30 Aug 2022 19:16:16 -0400 Received: from mail-io1-xd2e.google.com (mail-io1-xd2e.google.com [IPv6:2607:f8b0:4864:20::d2e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 823965809A for ; Tue, 30 Aug 2022 16:16:13 -0700 (PDT) Received: by mail-io1-xd2e.google.com with SMTP id p187so10590921iod.8 for ; Tue, 30 Aug 2022 16:16:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=uHcOw2fkc1mUCVLkWIQ/7iJDKjHGetIDOudBHVaaJ2Y=; b=GJ52cOXmzwgv2qJ9IsGzDAd2k3eYsUINNJc2MC+WuamRiHzEjFjjYpK7vegX/+07Cl Rej9NMfnZKk+04EBi94UYyw9SKPQXY0lOFGjPKl0+bwv5geiR1nR3HPwwekhekSSeUfh P8wdrmYLFGCt4zXKuCYu8W6TRU7KGLZWm2LSc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=uHcOw2fkc1mUCVLkWIQ/7iJDKjHGetIDOudBHVaaJ2Y=; b=a9ZMib8Y/LYCP92HrWBo37r2PSAl4zimw/afiwVCNGmhohU+Fy9UiQTXt0+oJAIJeX fTpXWFvoi8w8SsNAOyRWSNGlcbjO4F/AQ5vC+wWqHxhFDTTCRAfmbJM+MF3fHNFnIxDe I8/hc00cbaEhZE/kxLz3+XHKqvxT1q0Q3W51vUcNjyMhW1Yxbsa3zsxlodt0mjGty3XU a0ELLOIOhqb1JQmSJrukNxethR4PJJfbuILM0TREaFlURY/EvU4wjturqnThlQnX5qJg QFCbmD7CIDyR8M1RwUj9BGV16eYT52iUwAQ3ApYXJ0dgdh9dU5Ea+pXQoqbwAO9TAARD VK3w== X-Gm-Message-State: ACgBeo1ZzY5Usubu1FVWN6QTHomnzE8FXl251fx/V7epVBoVHyZvsACG Z2Lv3PKuOyjflvNm3RSJf7+pLw== X-Google-Smtp-Source: AA6agR6sZcv5V28LEmNjFke5lkNoOXfN/MPFIdlkw8agvXIDe4597M1xNLIJgNOBnjXc0kWrOliwcw== X-Received: by 2002:a05:6638:2410:b0:34a:11e6:f171 with SMTP id z16-20020a056638241000b0034a11e6f171mr13609920jat.146.1661901373664; Tue, 30 Aug 2022 16:16:13 -0700 (PDT) Received: from rrangel920.bld.corp.google.com (h24-56-189-219.arvdco.broadband.dynamic.tds.net. [24.56.189.219]) by smtp.gmail.com with ESMTPSA id z30-20020a056602081e00b0068b1858c81asm6165821iow.13.2022.08.30.16.16.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Aug 2022 16:16:12 -0700 (PDT) From: Raul E Rangel To: linux-acpi@vger.kernel.org, linux-input@vger.kernel.org Cc: hdegoede@redhat.com, mario.limonciello@amd.com, timvp@google.com, rafael@kernel.org, Raul E Rangel , Angela Czubak , Bartosz Szczepanek , Benjamin Tissoires , Dmitry Torokhov , Jiri Kosina , Yang Li , linux-kernel@vger.kernel.org Subject: [PATCH 2/8] HID: i2c-hid: Use PM subsystem to manage wake irq Date: Tue, 30 Aug 2022 17:15:35 -0600 Message-Id: <20220830171332.2.Id4b4bdfe06e2caf2d5a3c9dd4a9b1080c38b539c@changeid> X-Mailer: git-send-email 2.37.2.672.g94769d06f0-goog In-Reply-To: <20220830231541.1135813-1-rrangel@chromium.org> References: <20220830231541.1135813-1-rrangel@chromium.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org The I2C hid driver is currently manually managing the wake IRQ. This change removes the explicit enable_irq_wake/disable_irq_wake and instead relies on the PM subsystem. This is done by calling dev_pm_set_wake_irq. i2c_device_probe already calls dev_pm_set_wake_irq when using device tree, so it's only required when using ACPI. The net result is that this change should be a no-op. i2c_device_remove also already calls dev_pm_clear_wake_irq, so we don't need to do that in this driver. I tested this on an ACPI system that has a HID touchscreen and verified the IRQ was armed for wake on suspend. Signed-off-by: Raul E Rangel --- drivers/hid/i2c-hid/i2c-hid-core.c | 33 +++++++++++------------------- 1 file changed, 12 insertions(+), 21 deletions(-) diff --git a/drivers/hid/i2c-hid/i2c-hid-core.c b/drivers/hid/i2c-hid/i2c-hid-core.c index baa169fadd6632..0b7a1a8b3e9a33 100644 --- a/drivers/hid/i2c-hid/i2c-hid-core.c +++ b/drivers/hid/i2c-hid/i2c-hid-core.c @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -116,7 +117,6 @@ struct i2c_hid { wait_queue_head_t wait; /* For waiting the interrupt */ - bool irq_wake_enabled; struct mutex reset_lock; struct i2chid_ops *ops; @@ -1036,6 +1036,15 @@ int i2c_hid_core_probe(struct i2c_client *client, struct i2chid_ops *ops, if (ret < 0) goto err_powered; + /* + * Systems using device tree should set up wakeup via DTS, + * the rest will configure device as wakeup source by default. + */ + if (!client->dev.of_node) { + device_init_wakeup(&client->dev, true); + dev_pm_set_wake_irq(&client->dev, client->irq); + } + hid = hid_allocate_device(); if (IS_ERR(hid)) { ret = PTR_ERR(hid); @@ -1119,7 +1128,6 @@ static int i2c_hid_core_suspend(struct device *dev) struct i2c_hid *ihid = i2c_get_clientdata(client); struct hid_device *hid = ihid->hid; int ret; - int wake_status; ret = hid_driver_suspend(hid, PMSG_SUSPEND); if (ret < 0) @@ -1130,16 +1138,8 @@ static int i2c_hid_core_suspend(struct device *dev) disable_irq(client->irq); - if (device_may_wakeup(&client->dev)) { - wake_status = enable_irq_wake(client->irq); - if (!wake_status) - ihid->irq_wake_enabled = true; - else - hid_warn(hid, "Failed to enable irq wake: %d\n", - wake_status); - } else { + if (!device_may_wakeup(&client->dev)) i2c_hid_core_power_down(ihid); - } return 0; } @@ -1150,18 +1150,9 @@ static int i2c_hid_core_resume(struct device *dev) struct i2c_client *client = to_i2c_client(dev); struct i2c_hid *ihid = i2c_get_clientdata(client); struct hid_device *hid = ihid->hid; - int wake_status; - if (!device_may_wakeup(&client->dev)) { + if (!device_may_wakeup(&client->dev)) i2c_hid_core_power_up(ihid); - } else if (ihid->irq_wake_enabled) { - wake_status = disable_irq_wake(client->irq); - if (!wake_status) - ihid->irq_wake_enabled = false; - else - hid_warn(hid, "Failed to disable irq wake: %d\n", - wake_status); - } enable_irq(client->irq); From patchwork Tue Aug 30 23:15:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Raul E Rangel X-Patchwork-Id: 601313 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 64C3EC0502A for ; Tue, 30 Aug 2022 23:16:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231717AbiH3XQ1 (ORCPT ); Tue, 30 Aug 2022 19:16:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37468 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231404AbiH3XQS (ORCPT ); Tue, 30 Aug 2022 19:16:18 -0400 Received: from mail-io1-xd31.google.com (mail-io1-xd31.google.com [IPv6:2607:f8b0:4864:20::d31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5E6CB5A8B4 for ; Tue, 30 Aug 2022 16:16:16 -0700 (PDT) Received: by mail-io1-xd31.google.com with SMTP id p187so10590981iod.8 for ; Tue, 30 Aug 2022 16:16:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=6Cki2zIPGx1POrukQe/HlbUkh63Uf8/m2v1IMF/IUTs=; b=kZW7YJ0imUUssdJmbimewISxSqiEqn1g+K9BJsvsguQF1wnXRBDeyDZgNxj8mJMP0T eF9bl5BneyyKx+/HBQ5vra8CsSlE/2vPZ5MPryjGJpTk5GTqkkR6ZAbikV4ZKsOPq6nO JkgB34Qhk6z0IA9OvLVnZtLWpvwaSyLNF7+3s= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=6Cki2zIPGx1POrukQe/HlbUkh63Uf8/m2v1IMF/IUTs=; b=MM4Prd0h6pjCj9hMqGhJL7tojlYTslAYc3mLP4LECkI+A032JxXU7VBOnjOLw0tayP fyRWMjHyB/Pz/F7EkWcIgS8FVclSPFsWp3Q9omlG4fgRJ1FANcelQsSmdF89Ufn92iWN Ph9hqukSDj2UNatcSNO4tD0r95J3h03wwn1if4gQ+i9C3xapj2RCE4IfJ73ke0/LXY2A kKH7Z3xlGm19dz0iatsbGPj11i2cG9njAMDPXXnyTUFbOsxTpTgJGG5K7d+zQR+0rxRw 2EmN1AAAI94SzWt9kUYH30HZMw4ML/yFMYwH9QepC1orONCx1IePXKGq8Ch8Ys9nz74A 80qA== X-Gm-Message-State: ACgBeo0WNI/cgDA6Iok0ppeERAkTIyj8U0dRdKmNGVfC3sUDL9RtkkpJ q6Pt5PKoCnDZTJ4x0mxbgqCTFw== X-Google-Smtp-Source: AA6agR4PPQ3OCABkevBsd5VZPlwvnQiE50aYZTYSDtxDRq0jTTRX2BRq62coRRChds8lZXfAaYPaMQ== X-Received: by 2002:a02:ce92:0:b0:34a:5b83:a0df with SMTP id y18-20020a02ce92000000b0034a5b83a0dfmr2521090jaq.307.1661901375405; Tue, 30 Aug 2022 16:16:15 -0700 (PDT) Received: from rrangel920.bld.corp.google.com (h24-56-189-219.arvdco.broadband.dynamic.tds.net. [24.56.189.219]) by smtp.gmail.com with ESMTPSA id z30-20020a056602081e00b0068b1858c81asm6165821iow.13.2022.08.30.16.16.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Aug 2022 16:16:15 -0700 (PDT) From: Raul E Rangel To: linux-acpi@vger.kernel.org, linux-input@vger.kernel.org Cc: hdegoede@redhat.com, mario.limonciello@amd.com, timvp@google.com, rafael@kernel.org, Raul E Rangel , Mika Westerberg , Wolfram Sang , linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 4/8] i2c: acpi: Use ACPI GPIO wake capability bit to set wake_irq Date: Tue, 30 Aug 2022 17:15:37 -0600 Message-Id: <20220830171332.4.I8af4282adc72eb9f247adcd03676a43893a020a6@changeid> X-Mailer: git-send-email 2.37.2.672.g94769d06f0-goog In-Reply-To: <20220830231541.1135813-1-rrangel@chromium.org> References: <20220830231541.1135813-1-rrangel@chromium.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Device tree already has a mechanism to pass the wake_irq. It does this by looking for the wakeup-source property and setting the I2C_CLIENT_WAKE flag. This CL adds the ACPI equivalent. It uses at the ACPI GpioInt wake flag to determine if the interrupt can be used to wake the system. Previously the i2c drivers had to make assumptions and blindly enable the wake IRQ. This can cause spurious wake events. e.g., If there is a device with an Active Low interrupt and the device gets powered off while suspending, the interrupt line will go low since it's no longer powered and wake the system. For this reason we should respect the board designers wishes and honor the wake bit defined on the GpioInt. This change does not cover the ACPI Interrupt or IRQ resources. Signed-off-by: Raul E Rangel --- drivers/i2c/i2c-core-acpi.c | 8 ++++++-- drivers/i2c/i2c-core-base.c | 17 +++++++++++------ drivers/i2c/i2c-core.h | 4 ++-- 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/drivers/i2c/i2c-core-acpi.c b/drivers/i2c/i2c-core-acpi.c index c762a879c4cc6b..cfe82a6ba3ef28 100644 --- a/drivers/i2c/i2c-core-acpi.c +++ b/drivers/i2c/i2c-core-acpi.c @@ -182,12 +182,13 @@ static int i2c_acpi_add_resource(struct acpi_resource *ares, void *data) /** * i2c_acpi_get_irq - get device IRQ number from ACPI * @client: Pointer to the I2C client device + * @wake_capable: Set to 1 if the IRQ is wake capable * * Find the IRQ number used by a specific client device. * * Return: The IRQ number or an error code. */ -int i2c_acpi_get_irq(struct i2c_client *client) +int i2c_acpi_get_irq(struct i2c_client *client, int *wake_capable) { struct acpi_device *adev = ACPI_COMPANION(&client->dev); struct list_head resource_list; @@ -196,6 +197,9 @@ int i2c_acpi_get_irq(struct i2c_client *client) INIT_LIST_HEAD(&resource_list); + if (wake_capable) + *wake_capable = 0; + ret = acpi_dev_get_resources(adev, &resource_list, i2c_acpi_add_resource, &irq); if (ret < 0) @@ -204,7 +208,7 @@ int i2c_acpi_get_irq(struct i2c_client *client) acpi_dev_free_resource_list(&resource_list); if (irq == -ENOENT) - irq = acpi_dev_gpio_irq_get(adev, 0); + irq = acpi_dev_gpio_irq_get_wake(adev, 0, wake_capable); return irq; } diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c index 91007558bcb260..88f4ef76235f4e 100644 --- a/drivers/i2c/i2c-core-base.c +++ b/drivers/i2c/i2c-core-base.c @@ -468,6 +468,7 @@ static int i2c_device_probe(struct device *dev) struct i2c_client *client = i2c_verify_client(dev); struct i2c_driver *driver; int status; + int acpi_wake_capable = 0; if (!client) return 0; @@ -487,7 +488,7 @@ static int i2c_device_probe(struct device *dev) if (irq == -EINVAL || irq == -ENODATA) irq = of_irq_get(dev->of_node, 0); } else if (ACPI_COMPANION(dev)) { - irq = i2c_acpi_get_irq(client); + irq = i2c_acpi_get_irq(client, &acpi_wake_capable); } if (irq == -EPROBE_DEFER) { status = irq; @@ -513,13 +514,17 @@ static int i2c_device_probe(struct device *dev) goto put_sync_adapter; } - if (client->flags & I2C_CLIENT_WAKE) { + if (client->flags & I2C_CLIENT_WAKE || acpi_wake_capable) { int wakeirq; - wakeirq = of_irq_get_byname(dev->of_node, "wakeup"); - if (wakeirq == -EPROBE_DEFER) { - status = wakeirq; - goto put_sync_adapter; + if (acpi_wake_capable) { + wakeirq = client->irq; + } else { + wakeirq = of_irq_get_byname(dev->of_node, "wakeup"); + if (wakeirq == -EPROBE_DEFER) { + status = wakeirq; + goto put_sync_adapter; + } } device_init_wakeup(&client->dev, true); diff --git a/drivers/i2c/i2c-core.h b/drivers/i2c/i2c-core.h index 87e2c914f1c57b..8e336638a0cd2e 100644 --- a/drivers/i2c/i2c-core.h +++ b/drivers/i2c/i2c-core.h @@ -61,11 +61,11 @@ static inline int __i2c_check_suspended(struct i2c_adapter *adap) #ifdef CONFIG_ACPI void i2c_acpi_register_devices(struct i2c_adapter *adap); -int i2c_acpi_get_irq(struct i2c_client *client); +int i2c_acpi_get_irq(struct i2c_client *client, int *wake_capable); #else /* CONFIG_ACPI */ static inline void i2c_acpi_register_devices(struct i2c_adapter *adap) { } -static inline int i2c_acpi_get_irq(struct i2c_client *client) +static inline int i2c_acpi_get_irq(struct i2c_client *client, int *wake_capable) { return 0; } From patchwork Tue Aug 30 23:15:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Raul E Rangel X-Patchwork-Id: 601312 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E5D2EECAAA1 for ; Tue, 30 Aug 2022 23:16:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231666AbiH3XQs (ORCPT ); Tue, 30 Aug 2022 19:16:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37848 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231528AbiH3XQ0 (ORCPT ); Tue, 30 Aug 2022 19:16:26 -0400 Received: from mail-io1-xd34.google.com (mail-io1-xd34.google.com [IPv6:2607:f8b0:4864:20::d34]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 34EE3642C2 for ; Tue, 30 Aug 2022 16:16:18 -0700 (PDT) Received: by mail-io1-xd34.google.com with SMTP id i77so10590766ioa.7 for ; Tue, 30 Aug 2022 16:16:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=9y7lXZfKic1LpjpQXIA9tlb8KUkVBW2jlGcm93skgJQ=; b=NcJfK/oaE+ozKaG0LkF54DJtrz2QVlpP3O6ijlLw4aPafT/KGp1lHiHSpirPVul/pi 8MgftYJtdSiaGFqZ5tpZX1dfUJfdfvncN+Lgg2crIJX0tU73PGyk2jSydcAYdUF6CQg9 N1XCIrmJSzZV3tPTWDO3lezzc66SBBeCWJQ+o= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=9y7lXZfKic1LpjpQXIA9tlb8KUkVBW2jlGcm93skgJQ=; b=ALglefR1D3CWXqZfh5yPP9T62sZ2sohmD6p7YmzQXudamgxZIxhsCXkXtee0JcUqCk e8DPt2iy/bbOWSJpvb7OPNN8mtrsHCaeAfAmGwrTAlQhnC6ivvuVDucf2OhPpOu0nlz9 1LgpAs7hwSkAuy5j4frk6DNquTraC1zId1urkG0HfV9O5xEK0joKBi+ARHfLJp2+hg9F RSWAK8Gn3/9WZZchmYhNwqFbg7VbKUGSGHa3IW9+EaO2Bfu8iqKi1s3eHTL1ORNCMvT6 nRC9Yq9h9HmOpMIS93xnCH40EM042KxY1qJL50Gw/4r6LXVrYvmgnlliNH1I87IpzcZT lyQQ== X-Gm-Message-State: ACgBeo10iaRaiaPGGX5Os2mbqV8WDC7im/Iy9UaLY+M9ol4MYtFIKhZA jKGRQjXmewoK+36p+A5fyqs/lA== X-Google-Smtp-Source: AA6agR5O6/8tXAxW3fbQdsvlk23iJZe+hw4eqjCS74ugbqYtFuBc+Z/YJhAGmZm8FSUp1ousJAgNLg== X-Received: by 2002:a05:6638:1456:b0:346:856f:f3c4 with SMTP id l22-20020a056638145600b00346856ff3c4mr13545825jad.179.1661901377151; Tue, 30 Aug 2022 16:16:17 -0700 (PDT) Received: from rrangel920.bld.corp.google.com (h24-56-189-219.arvdco.broadband.dynamic.tds.net. [24.56.189.219]) by smtp.gmail.com with ESMTPSA id z30-20020a056602081e00b0068b1858c81asm6165821iow.13.2022.08.30.16.16.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Aug 2022 16:16:16 -0700 (PDT) From: Raul E Rangel To: linux-acpi@vger.kernel.org, linux-input@vger.kernel.org Cc: hdegoede@redhat.com, mario.limonciello@amd.com, timvp@google.com, rafael@kernel.org, Raul E Rangel , Dmitry Torokhov , "jingle.wu" , linux-kernel@vger.kernel.org Subject: [PATCH 6/8] Input: elan_i2c - Don't set wake_irq when using ACPI Date: Tue, 30 Aug 2022 17:15:39 -0600 Message-Id: <20220830171332.6.I7309b8f322082437b93581c6e2953886eeb998d7@changeid> X-Mailer: git-send-email 2.37.2.672.g94769d06f0-goog In-Reply-To: <20220830231541.1135813-1-rrangel@chromium.org> References: <20220830231541.1135813-1-rrangel@chromium.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org The i2c-core will now handle setting the wake_irq for ACPI systems. I didn't delete the whole block since this also covers systems that don't use ACPI or DT, but I'm honestly not sure if that's a valid config. Signed-off-by: Raul E Rangel --- drivers/input/mouse/elan_i2c_core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/input/mouse/elan_i2c_core.c b/drivers/input/mouse/elan_i2c_core.c index 7d997d2b56436b..d434c8ff8c4ca2 100644 --- a/drivers/input/mouse/elan_i2c_core.c +++ b/drivers/input/mouse/elan_i2c_core.c @@ -1333,10 +1333,10 @@ static int elan_probe(struct i2c_client *client, } /* - * Systems using device tree should set up wakeup via DTS, + * Systems using device tree should set up wakeup via DTS or ACPI, * the rest will configure device as wakeup source by default. */ - if (!dev->of_node) { + if (!dev->of_node && !has_acpi_companion(dev)) { device_init_wakeup(dev, true); dev_pm_set_wake_irq(dev, client->irq); } From patchwork Tue Aug 30 23:15:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Raul E Rangel X-Patchwork-Id: 601311 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4AD5FECAAA1 for ; Tue, 30 Aug 2022 23:17:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231846AbiH3XRS (ORCPT ); Tue, 30 Aug 2022 19:17:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38810 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231773AbiH3XQq (ORCPT ); Tue, 30 Aug 2022 19:16:46 -0400 Received: from mail-io1-xd29.google.com (mail-io1-xd29.google.com [IPv6:2607:f8b0:4864:20::d29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 417F16B8D8 for ; Tue, 30 Aug 2022 16:16:20 -0700 (PDT) Received: by mail-io1-xd29.google.com with SMTP id i77so10590811ioa.7 for ; Tue, 30 Aug 2022 16:16:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=A3xTTsKZx/5fCLbOqrazlesBJJTiVoLwUz/jQe2gDwc=; b=enSBMG0ikj2KVRid8ICGNrBLNn4mDnrczn9UDKjUzxD0GnYzzrVpmDo/yOottmAKUw XdEytm0iTECUDxcQ0+a1t9pT8bZ6J1CZu3ZbUx2DQN0kMjOfgMXHg7iAQIHXcXHVo8No x6/2xXo1E8a9bvUwMSSh9HPbQmCHsO5YiLHWw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=A3xTTsKZx/5fCLbOqrazlesBJJTiVoLwUz/jQe2gDwc=; b=FxlwiYCOEfcbLZZM/wZT0m0J2aDEYzqQq0psXynrqUUcToXwrnZ0WV9SXAoT7Uyhql KAiRJA4XmyXl2TLo8KEnRYh5hturBHkV7aA9gPu2pGbqpclH87brM4TPqh+a4atO2Ojf eNc5WeIPt+E56T/2Lg2W8B2vB5lwFQM9ZMTKwcV/xu6onzRZRZJvge7o+mBeOT+6yUD1 Z3A0B32NkemxbNvbyQU6PLWbBXW1dVtPrv6tmOv7YzuKIi9v9i0vq66OVXAD88VIKrwe 4WMe6sXGVmdixi9L2BCTN88GVNsZmVRNoJcTo4Kf5kvw4h2DfyCX58BuoTcMr/83QImL K6Eg== X-Gm-Message-State: ACgBeo3DuM/db2xqgJnsqCqlV5ZA9D+1y10xXa1/u3PhRasTxDBzVB+n 0Cwo+RNyG06f9svp3QTTAMf6jQ== X-Google-Smtp-Source: AA6agR6sWZgtFPbmAA1vaJWYl2qtrzuw360jdq0jUvuVKES+v1H37eSeKRiCfPEp7nZSSmyKKOGZYA== X-Received: by 2002:a05:6638:130c:b0:343:5bc5:7a45 with SMTP id r12-20020a056638130c00b003435bc57a45mr14017254jad.250.1661901378747; Tue, 30 Aug 2022 16:16:18 -0700 (PDT) Received: from rrangel920.bld.corp.google.com (h24-56-189-219.arvdco.broadband.dynamic.tds.net. [24.56.189.219]) by smtp.gmail.com with ESMTPSA id z30-20020a056602081e00b0068b1858c81asm6165821iow.13.2022.08.30.16.16.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Aug 2022 16:16:18 -0700 (PDT) From: Raul E Rangel To: linux-acpi@vger.kernel.org, linux-input@vger.kernel.org Cc: hdegoede@redhat.com, mario.limonciello@amd.com, timvp@google.com, rafael@kernel.org, Raul E Rangel , Len Brown , linux-kernel@vger.kernel.org Subject: [PATCH 8/8] ACPI: PM: Take wake IRQ into consideration when entering suspend-to-idle Date: Tue, 30 Aug 2022 17:15:41 -0600 Message-Id: <20220830171332.8.I7d9202463f08373feccd6e8fd87482c4f40ece5d@changeid> X-Mailer: git-send-email 2.37.2.672.g94769d06f0-goog In-Reply-To: <20220830231541.1135813-1-rrangel@chromium.org> References: <20220830231541.1135813-1-rrangel@chromium.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org This change adds support for ACPI devices that use ExclusiveAndWake or SharedAndWake in their _CRS GpioInt definition (instead of using _PRW), and also provide power resources. Previously the ACPI subsystem had no idea if the device had a wake capable interrupt armed. This resulted in the ACPI device PM system placing the device into D3Cold, and thus cutting power to the device. With this change we will now query the _S0W method to figure out the appropriate wake capable D-state. Signed-off-by: Raul E Rangel --- drivers/acpi/device_pm.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/drivers/acpi/device_pm.c b/drivers/acpi/device_pm.c index 9dce1245689ca2..6bc81f525d5160 100644 --- a/drivers/acpi/device_pm.c +++ b/drivers/acpi/device_pm.c @@ -681,8 +681,23 @@ static int acpi_dev_pm_get_state(struct device *dev, struct acpi_device *adev, d_min = ret; wakeup = device_may_wakeup(dev) && adev->wakeup.flags.valid && adev->wakeup.sleep_state >= target_state; - } else { - wakeup = adev->wakeup.flags.valid; + } else if (acpi_device_can_wakeup(adev)) { + /* ACPI GPE from specified by _PRW. */ + wakeup = true; + } else if (device_may_wakeup(dev) && dev->power.wakeirq) { + /* + * The ACPI subsystem doesn't manage the wake bit for IRQs + * defined with ExclusiveAndWake and SharedAndWake. Instead we + * expect them to be managed via the PM subsystem. Drivers + * should call dev_pm_set_wake_irq to register an IRQ as a wake + * source. + * + * If a device has a wake IRQ attached we need to check the + * _S0W method to get the correct wake D-state. Otherwise we + * end up putting the device into D3Cold which will more than + * likely disable wake functionality. + */ + wakeup = true; } /*