From nobody Tue Apr 7 05:37:01 2026 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 D7010ECAAA1 for ; Tue, 30 Aug 2022 23:16:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231604AbiH3XQX (ORCPT ); Tue, 30 Aug 2022 19:16:23 -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 S231402AbiH3XQO (ORCPT ); Tue, 30 Aug 2022 19:16:14 -0400 Received: from mail-il1-x12b.google.com (mail-il1-x12b.google.com [IPv6:2607:f8b0:4864:20::12b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CAAF157544 for ; Tue, 30 Aug 2022 16:16:12 -0700 (PDT) Received: by mail-il1-x12b.google.com with SMTP id j6so6103281ilu.9 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=ctE68nc4Eb96UZKVD+Mc9ihIHmfI4+MkMFxZXC+ODV6Jtga/UevnpOJkGfcgwa74y9 QAEPCDe8xz0EYmN5UYbl/SzU1F5EzxujBcPvEswAmK80XbNy4dIhLF328iTOf8Fx9tcG zWGwmY+0bl9HlD3Z7A7rZw7TVTqX4DmdHs0cPnPSxzDF5sm533GHIfIPavTFlmO8j+R2 wXayEWAu5dd5Lf9VCJ8y25O/1eH+VAGEYCJmTJLo70mdzqmCpNyrHKKjJR7otGoqqXmo a24o7de0sG5B+mjpUmur4O8yxRh35YcM6RoLmYPgA9FaWQdPjePI3B86mSsD+qHM4yj0 ItbA== X-Gm-Message-State: ACgBeo3HKFqwPvZi1uTQDbO2m/M57tz2xaGgFGcwwgQA80w7GWL1ATpr FU+m+dkXMofdQdCZ1G61EQNDzQ== 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 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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: Dmitry Torokhov Acked-by: Rafael J. Wysocki 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; =20 - 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); + } =20 return 0; } @@ -1362,8 +1363,6 @@ static int __maybe_unused elan_suspend(struct device = *dev) =20 if (device_may_wakeup(dev)) { ret =3D elan_sleep(data); - /* Enable wake from IRQ */ - data->irq_wake =3D (enable_irq_wake(client->irq) =3D=3D 0); } else { ret =3D 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 =3D false; } =20 error =3D elan_set_power(data, true); --=20 2.37.2.672.g94769d06f0-goog From nobody Tue Apr 7 05:37:01 2026 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 99DF2ECAAD5 for ; Tue, 30 Aug 2022 23:16:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231720AbiH3XQ3 (ORCPT ); Tue, 30 Aug 2022 19:16:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37304 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231460AbiH3XQQ (ORCPT ); Tue, 30 Aug 2022 19:16:16 -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 824BA580A6 for ; Tue, 30 Aug 2022 16:16:14 -0700 (PDT) Received: by mail-io1-xd31.google.com with SMTP id q81so10586971iod.9 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=qDGx+MlmarGhDRSpWDCzoryEZo0c/66aV1WxX9XcK0YuLcRDo0QPYXSKrk/jRadonA S53zgg0X1urrI8AwR4eNYlkJjWeXsn3gD8Buxqd+xGfQ35tfAQb5YF5U3ZqzDHxVx+74 efFkq8doHrflNjoDBN553jF1To3JZBI/4ZHSaG26xGur4A8xfUamCTwxM4AAlkEz0QCD DUbDRPxrsV4hHwTdDOihtW+GZfi6uFbvD6/s66JrAkcJokvGpGK2khlgoF8pBTnX2Ia2 PrPYycFCRxA8f+06wOaCHW6yl9vUMO/BQ2Q1OroFaDt0iI3knj6yMbrqTocWoPJ0jLgn AYqw== X-Gm-Message-State: ACgBeo2tUB+fiSkv61kUiRQadTcgUNbni5zM8rUOZM+lnDp1LVubXOh6 gzp/qx3+FZp3h3ukJR9etNrGuQ== 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 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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-h= id-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 { =20 wait_queue_head_t wait; /* For waiting the interrupt */ =20 - bool irq_wake_enabled; struct mutex reset_lock; =20 struct i2chid_ops *ops; @@ -1036,6 +1036,15 @@ int i2c_hid_core_probe(struct i2c_client *client, st= ruct i2chid_ops *ops, if (ret < 0) goto err_powered; =20 + /* + * 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 =3D hid_allocate_device(); if (IS_ERR(hid)) { ret =3D PTR_ERR(hid); @@ -1119,7 +1128,6 @@ static int i2c_hid_core_suspend(struct device *dev) struct i2c_hid *ihid =3D i2c_get_clientdata(client); struct hid_device *hid =3D ihid->hid; int ret; - int wake_status; =20 ret =3D hid_driver_suspend(hid, PMSG_SUSPEND); if (ret < 0) @@ -1130,16 +1138,8 @@ static int i2c_hid_core_suspend(struct device *dev) =20 disable_irq(client->irq); =20 - if (device_may_wakeup(&client->dev)) { - wake_status =3D enable_irq_wake(client->irq); - if (!wake_status) - ihid->irq_wake_enabled =3D 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); - } =20 return 0; } @@ -1150,18 +1150,9 @@ static int i2c_hid_core_resume(struct device *dev) struct i2c_client *client =3D to_i2c_client(dev); struct i2c_hid *ihid =3D i2c_get_clientdata(client); struct hid_device *hid =3D ihid->hid; - int wake_status; =20 - 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 =3D disable_irq_wake(client->irq); - if (!wake_status) - ihid->irq_wake_enabled =3D false; - else - hid_warn(hid, "Failed to disable irq wake: %d\n", - wake_status); - } =20 enable_irq(client->irq); =20 --=20 2.37.2.672.g94769d06f0-goog From nobody Tue Apr 7 05:37:01 2026 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 4F3A1ECAAA1 for ; Tue, 30 Aug 2022 23:16:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231602AbiH3XQc (ORCPT ); Tue, 30 Aug 2022 19:16:32 -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 S231364AbiH3XQQ (ORCPT ); Tue, 30 Aug 2022 19:16:16 -0400 Received: from mail-il1-x133.google.com (mail-il1-x133.google.com [IPv6:2607:f8b0:4864:20::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 592D958508 for ; Tue, 30 Aug 2022 16:16:15 -0700 (PDT) Received: by mail-il1-x133.google.com with SMTP id v15so4016310iln.6 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=D4dZQLnxu48mDmk1JArhgMCjcEiQr8mPNiaRxHZCqblfHBRsv+GegHLAhZG3v/Ff12 2AbcRa27qd8fCVdehTSUWzmElAJtwbiS9biGac3hirJ0cAsb+15wTPW+66hH/MBQp99p 6/7RrOWng8QdUW4gNtsMUM8Fb+9Hg6IGw5q3d2f3W3dtzFNsJx9xDpr4yjD/1x2deStR xi/Ms+c8Ky4CDOIBX8nWVVB67YcJrl8klZpZs5q/K8vVknAfzOsl1liNDoOuNitwG683 zD49REO+PUZwPfd+baIkSviMyWGnxgS6EYtDcshZBrr655omu5x23l/TV5kts1QzW+ih pLkQ== X-Gm-Message-State: ACgBeo3lNbfvCW3si8bYbuaf4kfRHeX9D55OM2bEJEhlJkYq6rBR5/9k tUb+rXYMkXjLs/1KDE7VNbLwlA== 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 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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"); =20 - ret =3D acpi_dev_gpio_irq_get_by(ACPI_COMPANION(dev), "irq-gpios", 0); + ret =3D acpi_dev_gpio_irq_get_by(ACPI_COMPANION(dev), "irq-gpios", 0, + NULL); if (ret < 0) return ret; =20 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_resour= ce *ares, void *data) lookup->info.pin_config =3D agpio->pin_config; lookup->info.debounce =3D agpio->debounce_timeout; lookup->info.gpioint =3D gpioint; + lookup->info.wake_capable =3D agpio->wake_capable; =20 /* * Polarity and triggering are only specified for GpioInt @@ -991,6 +992,7 @@ struct gpio_desc *acpi_node_get_gpiod(struct fwnode_han= dle *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 prop= erty * 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, i= nt 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); } =20 + if (wake_capable) + *wake_capable =3D info.wake_capable; + return irq; } =20 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, i= nt 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 a= cpi_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 ac= pi_device *adev, =20 static inline int acpi_dev_gpio_irq_get(struct acpi_device *adev, int inde= x) { - 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); } =20 /* Device properties */ --=20 2.37.2.672.g94769d06f0-goog From nobody Tue Apr 7 05:37:01 2026 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 1C967ECAAA1 for ; Tue, 30 Aug 2022 23:16:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231218AbiH3XQv (ORCPT ); Tue, 30 Aug 2022 19:16:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37796 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231206AbiH3XQZ (ORCPT ); Tue, 30 Aug 2022 19:16:25 -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 5E5FD5A897 for ; Tue, 30 Aug 2022 16:16:16 -0700 (PDT) Received: by mail-io1-xd2f.google.com with SMTP id n202so10592491iod.6 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=8N3aQ3UT40wQ9bn6XVM2g1Eg3zjiobGsviMiy4DQTWT7IyX31Gs+2ht7Pj+mFmNlKs fbCxup4/Y8Daj3TacSZOxywxe31u+hPykk2/ZTeDWfjUOQ4wFlnKnphXH9gQSMNir77B Bm5Kzei7sjiPRuiWZVQRA0LxWJfDmbZXEqsmERfh+nN4YCl7cPjH+TkpryUL65jMmMcg H0RvslYr+FZvoHnIkKw9NOb46NAJdlR6l419Gdn/nJ8oSMxYH5xZ/gi74YV5VzZ3VHVT GYBKysEJzV21t3STDxKQouMC9OAOjJ/mcwuCNseQW5K20FgcNZWfJ0N+wfnNF1HtwjSg 48pQ== X-Gm-Message-State: ACgBeo17khssaa8dNXS+NWG6wiEUdFHtnIy0HvqDedn9cMSp+JdC3P6N 2KlzS7f+2bmFdw6Fhs3UIPRPKA== 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 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 =3D ACPI_COMPANION(&client->dev); struct list_head resource_list; @@ -196,6 +197,9 @@ int i2c_acpi_get_irq(struct i2c_client *client) =20 INIT_LIST_HEAD(&resource_list); =20 + if (wake_capable) + *wake_capable =3D 0; + ret =3D 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); =20 if (irq =3D=3D -ENOENT) - irq =3D acpi_dev_gpio_irq_get(adev, 0); + irq =3D acpi_dev_gpio_irq_get_wake(adev, 0, wake_capable); =20 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 =3D i2c_verify_client(dev); struct i2c_driver *driver; int status; + int acpi_wake_capable =3D 0; =20 if (!client) return 0; @@ -487,7 +488,7 @@ static int i2c_device_probe(struct device *dev) if (irq =3D=3D -EINVAL || irq =3D=3D -ENODATA) irq =3D of_irq_get(dev->of_node, 0); } else if (ACPI_COMPANION(dev)) { - irq =3D i2c_acpi_get_irq(client); + irq =3D i2c_acpi_get_irq(client, &acpi_wake_capable); } if (irq =3D=3D -EPROBE_DEFER) { status =3D irq; @@ -513,13 +514,17 @@ static int i2c_device_probe(struct device *dev) goto put_sync_adapter; } =20 - if (client->flags & I2C_CLIENT_WAKE) { + if (client->flags & I2C_CLIENT_WAKE || acpi_wake_capable) { int wakeirq; =20 - wakeirq =3D of_irq_get_byname(dev->of_node, "wakeup"); - if (wakeirq =3D=3D -EPROBE_DEFER) { - status =3D wakeirq; - goto put_sync_adapter; + if (acpi_wake_capable) { + wakeirq =3D client->irq; + } else { + wakeirq =3D of_irq_get_byname(dev->of_node, "wakeup"); + if (wakeirq =3D=3D -EPROBE_DEFER) { + status =3D wakeirq; + goto put_sync_adapter; + } } =20 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_adap= ter *adap) #ifdef CONFIG_ACPI void i2c_acpi_register_devices(struct i2c_adapter *adap); =20 -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) { } =20 -static inline int i2c_acpi_get_irq(struct i2c_client *client) +static inline int i2c_acpi_get_irq(struct i2c_client *client, int *wake_ca= pable) { return 0; } --=20 2.37.2.672.g94769d06f0-goog From nobody Tue Apr 7 05:37:01 2026 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 93A82ECAAA1 for ; Tue, 30 Aug 2022 23:17:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231670AbiH3XRG (ORCPT ); Tue, 30 Aug 2022 19:17:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37814 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231655AbiH3XQ0 (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 BF80C61D7F for ; Tue, 30 Aug 2022 16:16:17 -0700 (PDT) Received: by mail-il1-x12a.google.com with SMTP id d15so7021109ilf.0 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=NJxYHAd7qU0+4kmOHnUa84UIld+Yyrl7yjZv/D6zAIJiUXmWY46OZ24r/2esXMYk2i wAxdU/Px0HbQcxgIpqM/jcIrhfVx8+5kvdgZqzjZEaGaUd9JYIb+kTtkYXqYXKwqoMB8 pHEa/I+yTVDr9we/uOHtTdeDPwS2EWVftRvVhVVUuyTMwU7tyGY+m4dJnvhi7z/HrhqH mk8lBGVQwnqK8il/QdKVYnVRB2TdiWts7hC7mb9UKNhY9w7SQmKok+eIJMRcLat/BDaL wLg51iBvkBBk9yEfBz3z/k8GvhbkYwzV5ERbgwj0XktDIv2Xmrt/nZoVSYPo6SQTVQHX r0mg== X-Gm-Message-State: ACgBeo1AOj8Lkyn3pcEutAQdQNsaCbGTIpFUGbj/nVX7oB54E8/EqshE IpvwDbrr1HOx5Lw541TBevrPvQ== 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 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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-h= id-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 *clien= t) =20 acpi_device_fix_up_power(adev); =20 - 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); } --=20 2.37.2.672.g94769d06f0-goog From nobody Tue Apr 7 05:37:01 2026 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 9A34FECAAD4 for ; Tue, 30 Aug 2022 23:16:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230517AbiH3XQ5 (ORCPT ); Tue, 30 Aug 2022 19:16:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37816 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231654AbiH3XQ0 (ORCPT ); Tue, 30 Aug 2022 19:16:26 -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 9090361D47 for ; Tue, 30 Aug 2022 16:16:17 -0700 (PDT) Received: by mail-io1-xd2f.google.com with SMTP id b142so10578983iof.10 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=turJaIbna+fwHxPCAf7Pbv0i0VnRYABWkOWLGmAb1HOozRvlz59hJ74N6MInZiyJaI OHbkgj8l4M6Gh3zyG/o2/q1TzkKOnHzJzfApAHlMEt9koOu//oEv7TZoDNummyldOq0P ORyOh/7Z4nHfPKr05D1dz6uP97hBvm0omMUmVx3H5v4zwRY2TyJoLxMoWtKr9VlcybhG yOxB4A21DejRbYWO5Z+rDwNU+5sh5qcuDSqeWGVfwCYGpVBGHjJMCYDSVAN5fS4yxN0O 1O7QKglnFoX2QtU1MtjyD455NSYD5BEG37+cTyDg4KbTYEemAP0CutWnV9Mr7Hbgqza9 62FA== X-Gm-Message-State: ACgBeo13G3j5OvBhVKiYkfPPl2zQ6cYpMHlHf9FGSnpUajj/oR0GTAFF stJUqFGwArqFNBxqHKVE9C/baQ== 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 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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, } =20 /* - * 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); } --=20 2.37.2.672.g94769d06f0-goog From nobody Tue Apr 7 05:37:01 2026 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 1F090ECAAD5 for ; Tue, 30 Aug 2022 23:17:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231693AbiH3XRL (ORCPT ); Tue, 30 Aug 2022 19:17:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37850 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231656AbiH3XQ0 (ORCPT ); Tue, 30 Aug 2022 19:16:26 -0400 Received: from mail-io1-xd2d.google.com (mail-io1-xd2d.google.com [IPv6:2607:f8b0:4864:20::d2d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7181C65817 for ; Tue, 30 Aug 2022 16:16:18 -0700 (PDT) Received: by mail-io1-xd2d.google.com with SMTP id c4so10597271iof.3 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=AOfTKjn3zrm3GDqZzNKnYenDn/D2Q830M7s3YZ4CuUawHGGP7diak1QeY/tiv4O/hI WjPYqxh+mKq9XgZEZv00FPHWFb5B8Barave0PYbCM5yQtRf4wibld/wpzX2kwi4/Si2s UIWzhcsHvRMpG5hwzGE8EMY/BE1NfBu8Ip6miwmo7X1AGRk25LirW+sEqQD7xCMtIkyH dkysVF6YT7QUAc0lFyybP8iURh1cgMrKw5ZWqCxIkB/QMRQnhzi9MqU33rV0tBFjLZJX 93dS99mB6RBMJPe8+5kVxFiNMO4/aPVfCFZuwi2YBnmm/fC/j/4sAvBBu8PWD05/jlVy /oCw== X-Gm-Message-State: ACgBeo3CAPV6P5leLr/PjaxpGH6ftFLtMp1F0zyetuVbETT22vLbQHXz VT6g5z1O+Q1pBkhzOaN3fUriLw== 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 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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-h= id-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, s= truct i2chid_ops *ops, goto err_powered; =20 /* - * 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); } --=20 2.37.2.672.g94769d06f0-goog From nobody Tue Apr 7 05:37:01 2026 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 006A0ECAAA1 for ; Tue, 30 Aug 2022 23:17:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231308AbiH3XRY (ORCPT ); Tue, 30 Aug 2022 19:17:24 -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 S231768AbiH3XQq (ORCPT ); Tue, 30 Aug 2022 19:16:46 -0400 Received: from mail-io1-xd30.google.com (mail-io1-xd30.google.com [IPv6:2607:f8b0:4864:20::d30]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 286C66B8C6 for ; Tue, 30 Aug 2022 16:16:19 -0700 (PDT) Received: by mail-io1-xd30.google.com with SMTP id z72so10575137iof.12 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=fV8pdaH5ib3HdewnA6ddIN8KZlc5XMqio8P6LtQEhaxyfTrXtQJoWkcm2U4HXrcWPD k0kezsQ3F+Y24E4QqMeVX2u+nlgB9k3EknKgDppFGhvpHO9VjM7VLuMicZ1GMxLGOK7p RXgh/08I/0jTauNUiPApblHm1YcRd0S6b/DH5jawzzZQw9URwsJ1QR5o6Ve7i85gimBq B5nV/kvXPizOIafi3i6AF6CdEPOq5rTrtE3xL51IoGiH+fOCNO5PzmGawi0tWzx9mZED FPkBU1pxbP4dTChO76GdbTany9eiuEmPa3I8Ob9fWtHjmgImjhxXvPsHfXOoQuoP480Z eRKw== X-Gm-Message-State: ACgBeo0A6FNU+nG9D4DJCsam1HFBs8kqvEG9kIYwIsbXLUWuierdCe8D Zx6zzMY82hmGd7cDG/q3a9g9ew== 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 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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, s= truct acpi_device *adev, d_min =3D ret; wakeup =3D device_may_wakeup(dev) && adev->wakeup.flags.valid && adev->wakeup.sleep_state >=3D target_state; - } else { - wakeup =3D adev->wakeup.flags.valid; + } else if (acpi_device_can_wakeup(adev)) { + /* ACPI GPE from specified by _PRW. */ + wakeup =3D 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 =3D true; } =20 /* --=20 2.37.2.672.g94769d06f0-goog