From patchwork Tue Aug 30 23:15:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Raul Rangel X-Patchwork-Id: 12960072 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 33BC5ECAAD4 for ; Tue, 30 Aug 2022 23:16:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231496AbiH3XQR (ORCPT ); Tue, 30 Aug 2022 19:16:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37310 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231404AbiH3XQO (ORCPT ); Tue, 30 Aug 2022 19:16:14 -0400 Received: from mail-il1-x136.google.com (mail-il1-x136.google.com [IPv6:2607:f8b0:4864:20::136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D62655789A for ; Tue, 30 Aug 2022 16:16:12 -0700 (PDT) Received: by mail-il1-x136.google.com with SMTP id s11so3038945iln.12 for ; Tue, 30 Aug 2022 16:16:12 -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=E5Gu43PGVE7VaKsHNMloj9b2iupdeWYkctb9tALGTWA=; b=calzQ4UJJQNihFU8xJrPTf7HQOsAtNJvL7Jdv2bN4AZQ0Eq8qPzQeFq10UppBuSOgi MUzY50aXsaEIyTwZU9C7C+ZTp308XJV8y7wcAy5q/lQQKqATC2DECYQ8yszRXczw07Rn m7rYPvOXti6+GFoLl2jol+9N+r4nMw50T0uHU= 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=E5Gu43PGVE7VaKsHNMloj9b2iupdeWYkctb9tALGTWA=; b=CYUVO+Nt5hU5Y4903Q/z+u+BwnV70sGJq9igeXK4tVW56haa/0yp++rhyD8Wa6v1Do Sk+3CoyWN3UELOKR8tCa4cxtwvdwTC7wE+1VgVNDbI2sgXyO27Bb07kWqrdjrsnPoEYj L8OK1rKrn/K9JDT7/xfly2VDcPlAZyFzL22SL40a76AZHDHo66/GIEm/gZtcuJ2Xvcf5 /y4KWMCFVGnczDimHvr4HA8AaxBW2ZpH5tGeg1xC7m0bZe+O+akAO6O5fd0kc6oiGsP0 iLkt0u9cjaVe8wVP3vnX1eFhf3QxjkxsnjllTLueDVv6+dX46eojKW8DaGX9Xfyx1Tpu SqRg== X-Gm-Message-State: ACgBeo1C4FFM8uWGPz44ZoiwbRPK7lb/GSKXfXkTngp1H81Akz/1dsZd bLp6dhKJILfCkIWOHZZMDmRFVG2UhQRbaA== X-Google-Smtp-Source: AA6agR7UWrQrF7nrb54KyCGExTs/aPKg2m+FvODWT33fVdouif8eYW5zosvaGTTPJAIvXq36GoKgDg== X-Received: by 2002:a92:cd8f:0:b0:2df:ff82:2e5f with SMTP id r15-20020a92cd8f000000b002dfff822e5fmr13230289ilb.72.1661901372164; Tue, 30 Aug 2022 16:16:12 -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.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Aug 2022 16:16:11 -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 1/8] Input: elan_i2c - Use PM subsystem to manage wake irq Date: Tue, 30 Aug 2022 17:15:34 -0600 Message-Id: <20220830171332.1.Id022caf53d01112188308520915798f08a33cd3e@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-acpi@vger.kernel.org The Elan I2C touchpad 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 where the touchpad doesn't have _PRW defined. I verified I can still wake the system and that the wake source was the touchpad IRQ GPIO. Signed-off-by: Raul E Rangel Acked-by: Rafael J. Wysocki Acked-by: Dmitry Torokhov Reviewed-by: Tony Lindgren --- drivers/input/mouse/elan_i2c_core.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/drivers/input/mouse/elan_i2c_core.c b/drivers/input/mouse/elan_i2c_core.c index e1758d5ffe4218..7d997d2b56436b 100644 --- a/drivers/input/mouse/elan_i2c_core.c +++ b/drivers/input/mouse/elan_i2c_core.c @@ -33,6 +33,7 @@ #include #include #include +#include #include #include #include @@ -86,8 +87,6 @@ struct elan_tp_data { u16 fw_page_size; u32 fw_signature_address; - bool irq_wake; - u8 min_baseline; u8 max_baseline; bool baseline_ready; @@ -1337,8 +1336,10 @@ static int elan_probe(struct i2c_client *client, * Systems using device tree should set up wakeup via DTS, * the rest will configure device as wakeup source by default. */ - if (!dev->of_node) + if (!dev->of_node) { device_init_wakeup(dev, true); + dev_pm_set_wake_irq(dev, client->irq); + } return 0; } @@ -1362,8 +1363,6 @@ static int __maybe_unused elan_suspend(struct device *dev) if (device_may_wakeup(dev)) { ret = elan_sleep(data); - /* Enable wake from IRQ */ - data->irq_wake = (enable_irq_wake(client->irq) == 0); } else { ret = elan_set_power(data, false); if (ret) @@ -1394,9 +1393,6 @@ static int __maybe_unused elan_resume(struct device *dev) dev_err(dev, "error %d enabling regulator\n", error); goto err; } - } else if (data->irq_wake) { - disable_irq_wake(client->irq); - data->irq_wake = false; } error = elan_set_power(data, true); 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 Rangel X-Patchwork-Id: 12960073 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 47F4DECAAA1 for ; Tue, 30 Aug 2022 23:16:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231442AbiH3XQS (ORCPT ); Tue, 30 Aug 2022 19:16:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37308 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231481AbiH3XQQ (ORCPT ); Tue, 30 Aug 2022 19:16:16 -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 825EE580B1 for ; Tue, 30 Aug 2022 16:16:14 -0700 (PDT) Received: by mail-io1-xd29.google.com with SMTP id e195so4641989iof.1 for ; Tue, 30 Aug 2022 16:16:14 -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=Dc4C8+ELXjYRtas4anH8E++XbfaoYz86XWhqEAmLta33wuVNO6zSxg9VwoTNIKPX6K UNdW8Iphq5WOURlvRUlC31SZp9NDKBviJTGk5HrfCP4jZ91YRNer8q43a0GuJvKo3UDF BKQ/jbXckpeNDdi6QYB1glqpvZED9FaX7Q0o6FQoqiFPbmr7ez/7tLsvgtvG05x1ANno pZ7VkeGj5YtG2s2sDTWaUlKvfupe9QfO+k/WJANg4YYWgzQe4twRQuGsFbzGWpOBQCQL QcrXeAJ+9H89lD1fmMnXPwHsCmTcS36pjTWdfgnx90OB5WDjTCUnA4QF5Jr5IQI4waI/ JN0A== X-Gm-Message-State: ACgBeo3Cc1iM4HH3+cAxZKAqhX6fJciWRCkMXft8m/UNdeS9JeD3c8/N 4/ytlxdiRG6jc2SGFqWZq3ksUeB+z3DJag== 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-acpi@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:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Raul Rangel X-Patchwork-Id: 12960074 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 D421DECAAD5 for ; Tue, 30 Aug 2022 23:16:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231511AbiH3XQT (ORCPT ); Tue, 30 Aug 2022 19:16:19 -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 S231384AbiH3XQQ (ORCPT ); Tue, 30 Aug 2022 19:16:16 -0400 Received: from mail-il1-x135.google.com (mail-il1-x135.google.com [IPv6:2607:f8b0:4864:20::135]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6261558528 for ; Tue, 30 Aug 2022 16:16:15 -0700 (PDT) Received: by mail-il1-x135.google.com with SMTP id a9so4189070ilh.1 for ; Tue, 30 Aug 2022 16:16:15 -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=7ZEan4dUIr4kyidENcq5otkByPrODYTGYAeqI0A8+e8=; b=LApH22aYoOcy5NnYQugoO/J3M0CLi/hfdEKlV68a+FlU9/g3ppYT09Zb9kwyhIgWaS ZP/wtdixww0XHWj3JGOcKhrVNTbf9U6p5+OfIczWxQzjErD9UQbQCP7+Y5bVswEAuUqo GrsQUy3M1h78ragkpBl15xJRDPorgcgvNIJlI= 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=7ZEan4dUIr4kyidENcq5otkByPrODYTGYAeqI0A8+e8=; b=TyKYDFtqHW7uhO/DxBs19tgsYng0l4UjzPnLmIqNkpBAJfq0zSTWBDBP5ws13IdQgC vm4j+5E/JQLInP2BeKNFBA4NqiauA1TAIfvHImLLqVHquigYVmpg8al0rzkk148HXNxm qF1h+Ju8UPE6Y/mhPQoavoREfGtbJfeya4NiAZ76zlGtVPYo/tjK0NFWSqOqtOmIMTGP mgZ3znmdqG7hIPPriy/lx3dfaRrOY05gDaF+7Z6uD8IorQUNkkUg2xF8r7c8C/H/sPe9 SG7+7VDxlIW7usjxEhmV42JfvKCkAsSnu0iodxIKFi4GxXmm0q45se5u277dv4zeNKJO KIlw== X-Gm-Message-State: ACgBeo1Q5ValPQucJrwQ0welE/O89YMgiLW72NzCYh+T4zTzRksCsDxL 1IZ15iEt779tYFRKNvPJ2kJ42jjayP4fgw== X-Google-Smtp-Source: AA6agR5otYu8crgU35WEswV0uWH0vHlaPxNiC7sb/8ztwtwmzx04J0ktO27LDEvZ2EzTGwJlWRPoGA== X-Received: by 2002:a92:4449:0:b0:2de:95f1:8b80 with SMTP id a9-20020a924449000000b002de95f18b80mr13223148ilm.232.1661901374643; Tue, 30 Aug 2022 16:16:14 -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.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Aug 2022 16:16:14 -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 , Andy Shevchenko , Bartosz Golaszewski , Len Brown , Linus Walleij , Mika Westerberg , linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/8] gpiolib: acpi: Add wake_capable parameter to acpi_dev_gpio_irq_get_by Date: Tue, 30 Aug 2022 17:15:36 -0600 Message-Id: <20220830171332.3.I4ff95ba7e884a486d7814ee888bf864be2ebdef4@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-acpi@vger.kernel.org The ACPI spec defines the SharedAndWake and ExclusiveAndWake share type keywords. This is an indication that the GPIO IRQ can also be used as a wake source. This change exposes the wake_capable bit so drivers can correctly enable wake functionality instead of making an assumption. Signed-off-by: Raul E Rangel Reported-by: kernel test robot --- drivers/gpio/gpio-pca953x.c | 3 ++- drivers/gpio/gpiolib-acpi.c | 11 ++++++++++- drivers/gpio/gpiolib-acpi.h | 2 ++ include/linux/acpi.h | 14 +++++++++++--- 4 files changed, 25 insertions(+), 5 deletions(-) diff --git a/drivers/gpio/gpio-pca953x.c b/drivers/gpio/gpio-pca953x.c index ecd7d169470b06..df02c3eb34a294 100644 --- a/drivers/gpio/gpio-pca953x.c +++ b/drivers/gpio/gpio-pca953x.c @@ -130,7 +130,8 @@ static int pca953x_acpi_get_irq(struct device *dev) if (ret) dev_warn(dev, "can't add GPIO ACPI mapping\n"); - ret = acpi_dev_gpio_irq_get_by(ACPI_COMPANION(dev), "irq-gpios", 0); + ret = acpi_dev_gpio_irq_get_by(ACPI_COMPANION(dev), "irq-gpios", 0, + NULL); if (ret < 0) return ret; diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c index 9be1376f9a627f..5cda2fcf7f43df 100644 --- a/drivers/gpio/gpiolib-acpi.c +++ b/drivers/gpio/gpiolib-acpi.c @@ -741,6 +741,7 @@ static int acpi_populate_gpio_lookup(struct acpi_resource *ares, void *data) lookup->info.pin_config = agpio->pin_config; lookup->info.debounce = agpio->debounce_timeout; lookup->info.gpioint = gpioint; + lookup->info.wake_capable = agpio->wake_capable; /* * Polarity and triggering are only specified for GpioInt @@ -991,6 +992,7 @@ struct gpio_desc *acpi_node_get_gpiod(struct fwnode_handle *fwnode, * @adev: pointer to a ACPI device to get IRQ from * @name: optional name of GpioInt resource * @index: index of GpioInt resource (starting from %0) + * @wake_capable: Set to 1 if the IRQ is wake capable * * If the device has one or more GpioInt resources, this function can be * used to translate from the GPIO offset in the resource to the Linux IRQ @@ -1002,9 +1004,13 @@ struct gpio_desc *acpi_node_get_gpiod(struct fwnode_handle *fwnode, * The function takes optional @name parameter. If the resource has a property * name, then only those will be taken into account. * + * The GPIO is considered wake capable if GpioInt specifies SharedAndWake or + * ExclusiveAndWake. + * * Return: Linux IRQ number (> %0) on success, negative errno on failure. */ -int acpi_dev_gpio_irq_get_by(struct acpi_device *adev, const char *name, int index) +int acpi_dev_gpio_irq_get_by(struct acpi_device *adev, const char *name, + int index, int *wake_capable) { int idx, i; unsigned int irq_flags; @@ -1061,6 +1067,9 @@ int acpi_dev_gpio_irq_get_by(struct acpi_device *adev, const char *name, int ind dev_dbg(&adev->dev, "IRQ %d already in use\n", irq); } + if (wake_capable) + *wake_capable = info.wake_capable; + return irq; } diff --git a/drivers/gpio/gpiolib-acpi.h b/drivers/gpio/gpiolib-acpi.h index e476558d947136..1ac6816839dbce 100644 --- a/drivers/gpio/gpiolib-acpi.h +++ b/drivers/gpio/gpiolib-acpi.h @@ -18,6 +18,7 @@ struct acpi_device; * @pin_config: pin bias as provided by ACPI * @polarity: interrupt polarity as provided by ACPI * @triggering: triggering type as provided by ACPI + * @wake_capable: wake capability as provided by ACPI * @debounce: debounce timeout as provided by ACPI * @quirks: Linux specific quirks as provided by struct acpi_gpio_mapping */ @@ -28,6 +29,7 @@ struct acpi_gpio_info { int pin_config; int polarity; int triggering; + bool wake_capable; unsigned int debounce; unsigned int quirks; }; diff --git a/include/linux/acpi.h b/include/linux/acpi.h index 6f64b2f3dc5479..7ee946758c5bcc 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h @@ -1202,7 +1202,8 @@ bool acpi_gpio_get_irq_resource(struct acpi_resource *ares, struct acpi_resource_gpio **agpio); bool acpi_gpio_get_io_resource(struct acpi_resource *ares, struct acpi_resource_gpio **agpio); -int acpi_dev_gpio_irq_get_by(struct acpi_device *adev, const char *name, int index); +int acpi_dev_gpio_irq_get_by(struct acpi_device *adev, const char *name, + int index, int *wake_capable); #else static inline bool acpi_gpio_get_irq_resource(struct acpi_resource *ares, struct acpi_resource_gpio **agpio) @@ -1215,7 +1216,8 @@ static inline bool acpi_gpio_get_io_resource(struct acpi_resource *ares, return false; } static inline int acpi_dev_gpio_irq_get_by(struct acpi_device *adev, - const char *name, int index) + const char *name, int index, + int *wake_capable) { return -ENXIO; } @@ -1223,7 +1225,13 @@ static inline int acpi_dev_gpio_irq_get_by(struct acpi_device *adev, static inline int acpi_dev_gpio_irq_get(struct acpi_device *adev, int index) { - return acpi_dev_gpio_irq_get_by(adev, NULL, index); + return acpi_dev_gpio_irq_get_by(adev, NULL, index, NULL); +} + +static inline int acpi_dev_gpio_irq_get_wake(struct acpi_device *adev, + int index, int *wake_capable) +{ + return acpi_dev_gpio_irq_get_by(adev, NULL, index, wake_capable); } /* Device properties */ 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 Rangel X-Patchwork-Id: 12960075 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 CFFE4ECAAD4 for ; Tue, 30 Aug 2022 23:16:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230309AbiH3XQ1 (ORCPT ); Tue, 30 Aug 2022 19:16:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37444 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231586AbiH3XQR (ORCPT ); Tue, 30 Aug 2022 19:16:17 -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 5E56A5A892 for ; Tue, 30 Aug 2022 16:16:16 -0700 (PDT) Received: by mail-io1-xd2e.google.com with SMTP id e195so4642037iof.1 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=hIJKKGgRChDQpYiV5y1cz/MnQA+tAyZzc0pp1BlKRCug7fvb5pHoJuUrdrn27hK6zd 9GnK0klaqegIDIc/kxJ0Mjj20eK2rK2UsHaQlwZV11B3Fe4bnJnpVa07Hu7TQKsRvKa9 4CFNF5a5qHghK9jO04IoDaY1gsi5bbn5ASW8NUaBBtW+fSQfkHxpZu6kQ0O2yWAEcwhc L0gRnGSbFam+daFggDwfXpoRITHBriM6qN41s4m3E9ox0DzoTVPVo4aHb6bMLzTvKbRA g0NYkc1eh8Csd5sHLQnU+OUC+rP3AGDYgWwu3o2bUBLsT0sn731O5ucC+f0gSGZ3IAGG X4Hw== X-Gm-Message-State: ACgBeo0cDEhP8lkooVTHdTJHJtFVjQ9W37OcPt/ePat9LFp/Q6U62tw+ RbwIZpHg9NygXnd1gnY/PlAcOJ0mwLz0aQ== 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-acpi@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:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Raul Rangel X-Patchwork-Id: 12960076 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 D832BECAAD4 for ; Tue, 30 Aug 2022 23:16:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231793AbiH3XQr (ORCPT ); Tue, 30 Aug 2022 19:16:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37858 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231684AbiH3XQ0 (ORCPT ); Tue, 30 Aug 2022 19:16:26 -0400 Received: from mail-il1-x12a.google.com (mail-il1-x12a.google.com [IPv6:2607:f8b0:4864:20::12a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C5D6B58528 for ; Tue, 30 Aug 2022 16:16:17 -0700 (PDT) Received: by mail-il1-x12a.google.com with SMTP id l6so5279359ilk.13 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=+Zr3ySvWsAbTk84Odn6RLHHn6wzrbctElmly11wkN94=; b=iLHDN+YCP6SEeigDXR6QMVNZFzSVxBxLEqWFEgoiIaApBvqp2Talh4Hx2+dYlXR7Jg sKyZE385q5vEsw6K/Q8Fuww3vSMn1euFi9t/lIKKrqqbkqRKE7VJ+YSobkQmze6jdN59 8uNPyKYMmbP/2VRiezTaqz6binp1k6h3Wm+Ig= 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=+Zr3ySvWsAbTk84Odn6RLHHn6wzrbctElmly11wkN94=; b=7lxVMs0zgkviI97qPzLwteDrZZ36OcE/p9tv14zfPG4OObjgHS/dHe4C4L+0dLFfZg S0g2XGtvtS7im/dXXYnb4dwq21yFyMZVMRFsUfKdYN3XEi7NU5s42N+ZWYa7Yh3LiM0d bMcHKbYN7coHkdXN06Pz01EykWoNnGuIgQgAqvKv3E/qaMCPEsIm01EieFABsMMHKfD9 fc9wrjlmnflm69vGU6cYW1kFPT9Tw68SdZFwBY2rYDAeWDUKQPjETeRXngAkUPexorIB LGWmU/qSC+K27zuRa5e1rI+yZHlUC1ST8LIMR4pY87ouv3XDBZJIXF8xuy/DM0cIbKsh xqGw== X-Gm-Message-State: ACgBeo0x/eeK1j8VaTtCe1trOb3lOVs6GAcs78L9IhBRh4Fz9c/pUwPs jHr0ckYqlGizuaaXpSeWSMKWiVkM7T6kPw== X-Google-Smtp-Source: AA6agR7EnYpMbsonCArvzFQ6q8M1F4HNUWE8hMQhf14cPNEIMWVzS2p0V6Na5vd2QXE/tx8fjaV4Yg== X-Received: by 2002:a05:6e02:1a41:b0:2eb:7762:f42e with SMTP id u1-20020a056e021a4100b002eb7762f42emr1374216ilv.151.1661901376420; Tue, 30 Aug 2022 16:16:16 -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.15 (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 , Alistair Francis , Benjamin Tissoires , Jiri Kosina , Rob Herring , linux-kernel@vger.kernel.org Subject: [PATCH 5/8] HID: i2c-hid: acpi: Stop setting wakeup_capable Date: Tue, 30 Aug 2022 17:15:38 -0600 Message-Id: <20220830171332.5.I2efb7f551e0aa2dc4c53b5fd5bbea91a1cdd9b32@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-acpi@vger.kernel.org This is now handled by the i2c-core driver. Signed-off-by: Raul E Rangel --- drivers/hid/i2c-hid/i2c-hid-acpi.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/drivers/hid/i2c-hid/i2c-hid-acpi.c b/drivers/hid/i2c-hid/i2c-hid-acpi.c index b96ae15e0ad917..375c77c3db74d9 100644 --- a/drivers/hid/i2c-hid/i2c-hid-acpi.c +++ b/drivers/hid/i2c-hid/i2c-hid-acpi.c @@ -105,11 +105,6 @@ static int i2c_hid_acpi_probe(struct i2c_client *client) acpi_device_fix_up_power(adev); - if (acpi_gbl_FADT.flags & ACPI_FADT_LOW_POWER_S0) { - device_set_wakeup_capable(dev, true); - device_set_wakeup_enable(dev, false); - } - return i2c_hid_core_probe(client, &ihid_acpi->ops, hid_descriptor_address, 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 Rangel X-Patchwork-Id: 12960078 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 7D939ECAAD4 for ; Tue, 30 Aug 2022 23:17:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230183AbiH3XRG (ORCPT ); Tue, 30 Aug 2022 19:17:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38764 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231364AbiH3XQq (ORCPT ); Tue, 30 Aug 2022 19:16:46 -0400 Received: from mail-io1-xd2f.google.com (mail-io1-xd2f.google.com [IPv6:2607:f8b0:4864:20::d2f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8D064659D4 for ; Tue, 30 Aug 2022 16:16:18 -0700 (PDT) Received: by mail-io1-xd2f.google.com with SMTP id h78so10575543iof.13 for ; Tue, 30 Aug 2022 16:16:18 -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=d6X76y41EGNBn7hLEveFRAW+Gv9znMRFaH49FIndRXOEutRaNnyhwmZyvGAitYYb0h soDf9/wAjdWPGdo1WO6sZ6EoSWiHU97S7flshdx7w8dqMM0K1pJ7Q+dROcbLBsSD+4CR /miLIQVZYWppwJcjQUvUj6MTme2xYHK0es4JqVlGAgI2b4XVABFRra2uf2kcqT6AC6Zr lRMQPPJpDls4PG3e+cc1rsjbsP5kspv0QWSbSCVhmlEYKTd2lthpdzPTY67tkegU9TD3 zT18xGLsAJUdGD4EYyA/3lPvk7drK6EOqq0w3Ayr/MP7qCGTcEssiPNIrXQeZPIaY7q2 hamw== X-Gm-Message-State: ACgBeo1P8UJ336dZSFQFfl3yvt5KEbsOAIKnMiWyxDtGTGHKSEmOASHq zng+idW1+O6jVX80z5OqxkMBEarvjLzydw== 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-acpi@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:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Raul Rangel X-Patchwork-Id: 12960077 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 05F54ECAAD5 for ; Tue, 30 Aug 2022 23:16:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231684AbiH3XQs (ORCPT ); Tue, 30 Aug 2022 19:16:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37868 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231693AbiH3XQ0 (ORCPT ); Tue, 30 Aug 2022 19:16:26 -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 8CB95659C6 for ; Tue, 30 Aug 2022 16:16:18 -0700 (PDT) Received: by mail-io1-xd31.google.com with SMTP id q81so10587117iod.9 for ; Tue, 30 Aug 2022 16:16:18 -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=1cUv8OQqQzL2mBMn36W85TxKKM2bLkDxJLwZ9X/W2YQ=; b=n8CbHCFCLa3NvlMNU6GyEavHcWEz+keNd9w4QE9X/dGEtMIwWBrhzek4sWMS/9Mra5 7mog0q8D4QWNT3dJ2mn2GkEkOgxk+S9uRjAqmpEn14RFrL8Tlv2FVGhR1aRmq7TQssWN GcYrY4tRT/1uoMpxqA0BmqO9JxkI5fCH44cGA= 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=1cUv8OQqQzL2mBMn36W85TxKKM2bLkDxJLwZ9X/W2YQ=; b=g0kqk1AuEy+yHgtkiJP0paqe4Ka7pC3AidRij956nveYnhkosbi3s2B4lxuIGqdDYP rn89BZjyNBXgDS7lxUVcYZ9ROHv7eGgL9LYWyA8NkFQ03eJyjE1bk+F5G8Cxcl2EM1S9 H00t89QvuR+y6Mj9M9d/OptQ4S18eFY7hvm93VSbX+/GNviKGprO0VG6kTzqb/4R2RVj IgrYAOzYcsW/R8EG5ucURhlFTGFZGIkBNbQhF8GuJ9UO3NQ4JJprdLvQ9rmeeKt4lJf8 9QeSyGxAmim5rIeINfRxcJOiJMb/yJASLKi+qk0SvpJSJ1sU0MTeF3zm1qpwl1K4BMfE n1/Q== X-Gm-Message-State: ACgBeo2/gkf9mlMHo/zfwGQz5/11/l/AnhMsB+4Q35C9IoGHa5Lrgy3D 27vlIa4Qh3HoPv+zaiuk8NX6TujIKdhbqw== X-Google-Smtp-Source: AA6agR7PjXZLt8Hb1gIOgXE8wv+NOkD4UEFuOUmbIEpKHV8192AELOhphNFTR6UEXBQm62sSsoK5uw== X-Received: by 2002:a02:860d:0:b0:345:b478:a611 with SMTP id e13-20020a02860d000000b00345b478a611mr13376735jai.95.1661901377952; 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.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Aug 2022 16:16:17 -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 , Alistair Francis , Angela Czubak , Benjamin Tissoires , Dmitry Torokhov , Jiri Kosina , Matthias Kaehlcke , linux-kernel@vger.kernel.org Subject: [PATCH 7/8] HID: i2c-hid: Don't set wake_irq when using ACPI Date: Tue, 30 Aug 2022 17:15:40 -0600 Message-Id: <20220830171332.7.Id22d056440953134d8e8fe2c2aff79c79bc78424@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-acpi@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/hid/i2c-hid/i2c-hid-core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/hid/i2c-hid/i2c-hid-core.c b/drivers/hid/i2c-hid/i2c-hid-core.c index 0b7a1a8b3e9a33..630e8dcda1100d 100644 --- a/drivers/hid/i2c-hid/i2c-hid-core.c +++ b/drivers/hid/i2c-hid/i2c-hid-core.c @@ -1037,10 +1037,10 @@ int i2c_hid_core_probe(struct i2c_client *client, struct i2chid_ops *ops, goto err_powered; /* - * 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 (!client->dev.of_node) { + if (!client->dev.of_node && !has_acpi_companion(&client->dev)) { device_init_wakeup(&client->dev, true); dev_pm_set_wake_irq(&client->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 Rangel X-Patchwork-Id: 12960109 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 61F0BECAAD5 for ; Tue, 30 Aug 2022 23:17:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231765AbiH3XRR (ORCPT ); Tue, 30 Aug 2022 19:17:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38802 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231754AbiH3XQq (ORCPT ); Tue, 30 Aug 2022 19:16:46 -0400 Received: from mail-io1-xd2a.google.com (mail-io1-xd2a.google.com [IPv6:2607:f8b0:4864:20::d2a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 192DA6B658 for ; Tue, 30 Aug 2022 16:16:19 -0700 (PDT) Received: by mail-io1-xd2a.google.com with SMTP id q81so10587144iod.9 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=1GNXFdrLGMPQqe9CX2wbJvsY6UWmCVQS9YFOX4TT5gRviqXLrFbUzvkPbHYe4qPwMq PbAg7Ce7yhglksN7iaRzj3N+v8086sh+5wZJcvNdh5T6DHwo68l0wvHMgF3+qt1yJaue GH8XNTn6M9Ou997A9lAjprq7QD1HS7TKkt0mpMvhT3ENSFsin0bgmq1arXTKs5+eDrd6 X3v/d57pwUPULI8cqutqTzpG2/WmdYR9s9dXRkGtkVbpbz6ZEhKVCSSFPc55wM53IbU6 j1PHp7y0vKb5L0B7DHnjfyaqdrBuGXUHH57Y2tJ31rdidTrHgDujjhulq5yqdc5YjaGR Psgg== X-Gm-Message-State: ACgBeo0OzpJd5hNGV7s3CTQt3A0lzQf6KreGwpY71L2D4NYQR1et7ixE HIIm7xZFaLRlO7xtvHSPrZqtWYBvvOiZcA== 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-acpi@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; } /*