* [PATCH 0/8] acpi: i2c: Use SharedAndWake and ExclusiveAndWake to enable wake irq
@ 2022-08-30 23:15 Raul E Rangel
2022-08-30 23:15 ` [PATCH 4/8] i2c: acpi: Use ACPI GPIO wake capability bit to set wake_irq Raul E Rangel
2022-08-31 11:52 ` [PATCH 0/8] acpi: i2c: Use SharedAndWake and ExclusiveAndWake to enable wake irq Andy Shevchenko
0 siblings, 2 replies; 13+ messages in thread
From: Raul E Rangel @ 2022-08-30 23:15 UTC (permalink / raw)
To: linux-acpi, linux-input
Cc: hdegoede, mario.limonciello, timvp, rafael, Raul E Rangel,
Alistair Francis, Andy Shevchenko, Angela Czubak,
Bartosz Golaszewski, Bartosz Szczepanek, Benjamin Tissoires,
Dmitry Torokhov, Jiri Kosina, Len Brown, Linus Walleij,
Matthias Kaehlcke, Mika Westerberg, Rob Herring, Wolfram Sang,
Yang Li, jingle.wu, linux-gpio, linux-i2c, linux-kernel
Today, i2c drivers are making the assumption that their IRQs can also
be used as wake IRQs. This isn't always the case and it can lead to
spurious wakes. This has recently started to affect AMD Chromebooks.
With the introduction of
d62bd5ce12d7 ("pinctrl: amd: Implement irq_set_wake"), the AMD GPIO
controller gained the capability to set the wake bit on each GPIO. The
ACPI specification defines two ways to inform the system if a device is
wake capable:
1) The _PRW object defines the GPE that can be used to wake the system.
2) Setting ExclusiveAndWake or SharedAndWake in the _CRS GpioInt.
Currently only the first method is supported. The i2c drivers don't have
any indication that the IRQ is wake capable, so they guess. This causes
spurious interrupts, for example:
* We have an ACPI HID device that has `_PR0` and `_PR3`. It doesn't have
`_PRW` or `ExclusiveAndWake` so that means the device can't wake the
system.
* The IRQ line is active level low for this device and is pulled up by
the power resource defined in `_PR0`/`_PR3`.
* The i2c driver will (incorrectly) arm the GPIO for wake by calling
`enable_irq_wake` as part of its suspend hook.
* ACPI will power down the device since it doesn't have a wake GPE
associated with it.
* When the device is powered down, the IRQ line will drop, and it will
trigger a wake event.
See the following debug log:
[ 42.335804] PM: Suspending system (s2idle)
[ 42.340186] amd_gpio AMD0030:00: RX: Setting wake for pin 89 to enable
[ 42.467736] power-0416 __acpi_power_off : Power resource [PR00] turned off
[ 42.467739] device_pm-0280 device_set_power : Device [H05D] transitioned to D3cold
[ 42.475210] PM: pm_system_irq_wakeup: 11 triggered pinctrl_amd
[ 42.535293] PM: Wakeup unrelated to ACPI SCI
[ 42.535294] PM: resume from suspend-to-idle
In order to fix this, we need to take into account the wake capable bit
defined on the GpioInt. This is accomplished by:
* Migrating some of the i2c drivers over to using the PM subsystem to
manage the wake IRQ. max8925-i2c, elants_i2c, and raydium_i2c_ts still
need to be migrated, I can do that depending on the feedback to this
patch series.
* Expose the wake_capable bit from the ACPI GpioInt resource to the
i2c core.
* Use the wake_capable bit in the i2c core to call
`dev_pm_set_wake_irq`. This reuses the existing device tree flow.
* Make the i2c drivers stop calling `dev_pm_set_wake_irq` since it's now
handled by the i2c core.
* Make the ACPI device PM system aware of the wake_irq. This is
necessary so the device doesn't incorrectly get powered down when a
wake_irq is enabled.
I've tested this code with various combinations of having _PRW,
ExclusiveAndWake and power resources all defined or not defined, but it
would be great if others could test this out on their hardware.
Thanks,
Raul
Raul E Rangel (8):
Input: elan_i2c - Use PM subsystem to manage wake irq
HID: i2c-hid: Use PM subsystem to manage wake irq
gpiolib: acpi: Add wake_capable parameter to acpi_dev_gpio_irq_get_by
i2c: acpi: Use ACPI GPIO wake capability bit to set wake_irq
HID: i2c-hid: acpi: Stop setting wakeup_capable
Input: elan_i2c - Don't set wake_irq when using ACPI
HID: i2c-hid: Don't set wake_irq when using ACPI
ACPI: PM: Take wake IRQ into consideration when entering
suspend-to-idle
drivers/acpi/device_pm.c | 19 +++++++++++++++--
drivers/gpio/gpio-pca953x.c | 3 ++-
drivers/gpio/gpiolib-acpi.c | 11 +++++++++-
drivers/gpio/gpiolib-acpi.h | 2 ++
drivers/hid/i2c-hid/i2c-hid-acpi.c | 5 -----
drivers/hid/i2c-hid/i2c-hid-core.c | 33 +++++++++++------------------
drivers/i2c/i2c-core-acpi.c | 8 +++++--
drivers/i2c/i2c-core-base.c | 17 +++++++++------
drivers/i2c/i2c-core.h | 4 ++--
drivers/input/mouse/elan_i2c_core.c | 14 +++++-------
include/linux/acpi.h | 14 +++++++++---
11 files changed, 78 insertions(+), 52 deletions(-)
--
2.37.2.672.g94769d06f0-goog
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH 4/8] i2c: acpi: Use ACPI GPIO wake capability bit to set wake_irq
2022-08-30 23:15 [PATCH 0/8] acpi: i2c: Use SharedAndWake and ExclusiveAndWake to enable wake irq Raul E Rangel
@ 2022-08-30 23:15 ` Raul E Rangel
2022-09-07 1:00 ` Dmitry Torokhov
2022-08-31 11:52 ` [PATCH 0/8] acpi: i2c: Use SharedAndWake and ExclusiveAndWake to enable wake irq Andy Shevchenko
1 sibling, 1 reply; 13+ messages in thread
From: Raul E Rangel @ 2022-08-30 23:15 UTC (permalink / raw)
To: linux-acpi, linux-input
Cc: hdegoede, mario.limonciello, timvp, rafael, Raul E Rangel,
Mika Westerberg, Wolfram Sang, linux-i2c, linux-kernel
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 <rrangel@chromium.org>
---
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;
}
--
2.37.2.672.g94769d06f0-goog
^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH 0/8] acpi: i2c: Use SharedAndWake and ExclusiveAndWake to enable wake irq
2022-08-30 23:15 [PATCH 0/8] acpi: i2c: Use SharedAndWake and ExclusiveAndWake to enable wake irq Raul E Rangel
2022-08-30 23:15 ` [PATCH 4/8] i2c: acpi: Use ACPI GPIO wake capability bit to set wake_irq Raul E Rangel
@ 2022-08-31 11:52 ` Andy Shevchenko
2022-08-31 14:37 ` Raul Rangel
1 sibling, 1 reply; 13+ messages in thread
From: Andy Shevchenko @ 2022-08-31 11:52 UTC (permalink / raw)
To: Raul E Rangel
Cc: linux-acpi, linux-input, hdegoede, mario.limonciello, timvp,
rafael, Alistair Francis, Angela Czubak, Bartosz Golaszewski,
Bartosz Szczepanek, Benjamin Tissoires, Dmitry Torokhov,
Jiri Kosina, Len Brown, Linus Walleij, Matthias Kaehlcke,
Mika Westerberg, Rob Herring, Wolfram Sang, Yang Li, jingle.wu,
linux-gpio, linux-i2c, linux-kernel
On Tue, Aug 30, 2022 at 05:15:33PM -0600, Raul E Rangel wrote:
> Today, i2c drivers are making the assumption that their IRQs can also
> be used as wake IRQs. This isn't always the case and it can lead to
> spurious wakes. This has recently started to affect AMD Chromebooks.
> With the introduction of
> d62bd5ce12d7 ("pinctrl: amd: Implement irq_set_wake"), the AMD GPIO
> controller gained the capability to set the wake bit on each GPIO. The
> ACPI specification defines two ways to inform the system if a device is
> wake capable:
> 1) The _PRW object defines the GPE that can be used to wake the system.
> 2) Setting ExclusiveAndWake or SharedAndWake in the _CRS GpioInt.
>
> Currently only the first method is supported. The i2c drivers don't have
> any indication that the IRQ is wake capable, so they guess. This causes
> spurious interrupts, for example:
> * We have an ACPI HID device that has `_PR0` and `_PR3`. It doesn't have
> `_PRW` or `ExclusiveAndWake` so that means the device can't wake the
> system.
> * The IRQ line is active level low for this device and is pulled up by
> the power resource defined in `_PR0`/`_PR3`.
> * The i2c driver will (incorrectly) arm the GPIO for wake by calling
> `enable_irq_wake` as part of its suspend hook.
> * ACPI will power down the device since it doesn't have a wake GPE
> associated with it.
> * When the device is powered down, the IRQ line will drop, and it will
> trigger a wake event.
>
> See the following debug log:
> [ 42.335804] PM: Suspending system (s2idle)
> [ 42.340186] amd_gpio AMD0030:00: RX: Setting wake for pin 89 to enable
> [ 42.467736] power-0416 __acpi_power_off : Power resource [PR00] turned off
> [ 42.467739] device_pm-0280 device_set_power : Device [H05D] transitioned to D3cold
> [ 42.475210] PM: pm_system_irq_wakeup: 11 triggered pinctrl_amd
> [ 42.535293] PM: Wakeup unrelated to ACPI SCI
> [ 42.535294] PM: resume from suspend-to-idle
>
> In order to fix this, we need to take into account the wake capable bit
> defined on the GpioInt. This is accomplished by:
> * Migrating some of the i2c drivers over to using the PM subsystem to
> manage the wake IRQ. max8925-i2c, elants_i2c, and raydium_i2c_ts still
> need to be migrated, I can do that depending on the feedback to this
> patch series.
> * Expose the wake_capable bit from the ACPI GpioInt resource to the
> i2c core.
> * Use the wake_capable bit in the i2c core to call
> `dev_pm_set_wake_irq`. This reuses the existing device tree flow.
> * Make the i2c drivers stop calling `dev_pm_set_wake_irq` since it's now
> handled by the i2c core.
> * Make the ACPI device PM system aware of the wake_irq. This is
> necessary so the device doesn't incorrectly get powered down when a
> wake_irq is enabled.
>
> I've tested this code with various combinations of having _PRW,
> ExclusiveAndWake and power resources all defined or not defined, but it
> would be great if others could test this out on their hardware.
I have got only cover letter and a single patch (#3). What's going on?
Note: I'm also reviewer of I²C DesignWare driver, you really have to
fix your tools / submission process and try again. No review for this
series.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 0/8] acpi: i2c: Use SharedAndWake and ExclusiveAndWake to enable wake irq
2022-08-31 11:52 ` [PATCH 0/8] acpi: i2c: Use SharedAndWake and ExclusiveAndWake to enable wake irq Andy Shevchenko
@ 2022-08-31 14:37 ` Raul Rangel
2022-08-31 15:18 ` Hans de Goede
0 siblings, 1 reply; 13+ messages in thread
From: Raul Rangel @ 2022-08-31 14:37 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Linux ACPI, linux-input, Hans de Goede, Limonciello, Mario,
Tim Van Patten, Rafael J. Wysocki, Alistair Francis,
Angela Czubak, Bartosz Golaszewski, Bartosz Szczepanek,
Benjamin Tissoires, Dmitry Torokhov, Jiri Kosina, Len Brown,
Linus Walleij, Matthias Kaehlcke, Mika Westerberg, Rob Herring,
Wolfram Sang, Yang Li, jingle.wu, open list:GPIO SUBSYSTEM,
open list:I2C SUBSYSTEM HOST DRIVERS, linux-kernel
Interesting... The patch series is here:
https://patchwork.kernel.org/project/linux-input/cover/20220830231541.1135813-1-rrangel@chromium.org/
I'll look into why you only got added to 2 of the emails.
On Wed, Aug 31, 2022 at 5:52 AM Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
>
> On Tue, Aug 30, 2022 at 05:15:33PM -0600, Raul E Rangel wrote:
> > Today, i2c drivers are making the assumption that their IRQs can also
> > be used as wake IRQs. This isn't always the case and it can lead to
> > spurious wakes. This has recently started to affect AMD Chromebooks.
> > With the introduction of
> > d62bd5ce12d7 ("pinctrl: amd: Implement irq_set_wake"), the AMD GPIO
> > controller gained the capability to set the wake bit on each GPIO. The
> > ACPI specification defines two ways to inform the system if a device is
> > wake capable:
> > 1) The _PRW object defines the GPE that can be used to wake the system.
> > 2) Setting ExclusiveAndWake or SharedAndWake in the _CRS GpioInt.
> >
> > Currently only the first method is supported. The i2c drivers don't have
> > any indication that the IRQ is wake capable, so they guess. This causes
> > spurious interrupts, for example:
> > * We have an ACPI HID device that has `_PR0` and `_PR3`. It doesn't have
> > `_PRW` or `ExclusiveAndWake` so that means the device can't wake the
> > system.
> > * The IRQ line is active level low for this device and is pulled up by
> > the power resource defined in `_PR0`/`_PR3`.
> > * The i2c driver will (incorrectly) arm the GPIO for wake by calling
> > `enable_irq_wake` as part of its suspend hook.
> > * ACPI will power down the device since it doesn't have a wake GPE
> > associated with it.
> > * When the device is powered down, the IRQ line will drop, and it will
> > trigger a wake event.
> >
> > See the following debug log:
> > [ 42.335804] PM: Suspending system (s2idle)
> > [ 42.340186] amd_gpio AMD0030:00: RX: Setting wake for pin 89 to enable
> > [ 42.467736] power-0416 __acpi_power_off : Power resource [PR00] turned off
> > [ 42.467739] device_pm-0280 device_set_power : Device [H05D] transitioned to D3cold
> > [ 42.475210] PM: pm_system_irq_wakeup: 11 triggered pinctrl_amd
> > [ 42.535293] PM: Wakeup unrelated to ACPI SCI
> > [ 42.535294] PM: resume from suspend-to-idle
> >
> > In order to fix this, we need to take into account the wake capable bit
> > defined on the GpioInt. This is accomplished by:
> > * Migrating some of the i2c drivers over to using the PM subsystem to
> > manage the wake IRQ. max8925-i2c, elants_i2c, and raydium_i2c_ts still
> > need to be migrated, I can do that depending on the feedback to this
> > patch series.
> > * Expose the wake_capable bit from the ACPI GpioInt resource to the
> > i2c core.
> > * Use the wake_capable bit in the i2c core to call
> > `dev_pm_set_wake_irq`. This reuses the existing device tree flow.
> > * Make the i2c drivers stop calling `dev_pm_set_wake_irq` since it's now
> > handled by the i2c core.
> > * Make the ACPI device PM system aware of the wake_irq. This is
> > necessary so the device doesn't incorrectly get powered down when a
> > wake_irq is enabled.
> >
> > I've tested this code with various combinations of having _PRW,
> > ExclusiveAndWake and power resources all defined or not defined, but it
> > would be great if others could test this out on their hardware.
>
> I have got only cover letter and a single patch (#3). What's going on?
>
> Note: I'm also reviewer of I涎 DesignWare driver, you really have to
> fix your tools / submission process and try again. No review for this
> series.
>
> --
> With Best Regards,
> Andy Shevchenko
>
>
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 0/8] acpi: i2c: Use SharedAndWake and ExclusiveAndWake to enable wake irq
2022-08-31 14:37 ` Raul Rangel
@ 2022-08-31 15:18 ` Hans de Goede
0 siblings, 0 replies; 13+ messages in thread
From: Hans de Goede @ 2022-08-31 15:18 UTC (permalink / raw)
To: Raul Rangel, Andy Shevchenko
Cc: Linux ACPI, linux-input, Limonciello, Mario, Tim Van Patten,
Rafael J. Wysocki, Alistair Francis, Angela Czubak,
Bartosz Golaszewski, Bartosz Szczepanek, Benjamin Tissoires,
Dmitry Torokhov, Jiri Kosina, Len Brown, Linus Walleij,
Matthias Kaehlcke, Mika Westerberg, Rob Herring, Wolfram Sang,
Yang Li, jingle.wu, open list:GPIO SUBSYSTEM,
open list:I2C SUBSYSTEM HOST DRIVERS, linux-kernel
Hi,
On 8/31/22 16:37, Raul Rangel wrote:
> Interesting... The patch series is here:
> https://patchwork.kernel.org/project/linux-input/cover/20220830231541.1135813-1-rrangel@chromium.org/
>
> I'll look into why you only got added to 2 of the emails.
FWIW I also received the full series without problems.
I'll try to reply to this soon-ish, but I have a bit of
a patch backlog to process and I'm trying to process
the backlog in FIFO order and this is one of the last
series in the backlog ...
Regards,
Hans
>
> On Wed, Aug 31, 2022 at 5:52 AM Andy Shevchenko
> <andriy.shevchenko@linux.intel.com> wrote:
>>
>> On Tue, Aug 30, 2022 at 05:15:33PM -0600, Raul E Rangel wrote:
>>> Today, i2c drivers are making the assumption that their IRQs can also
>>> be used as wake IRQs. This isn't always the case and it can lead to
>>> spurious wakes. This has recently started to affect AMD Chromebooks.
>>> With the introduction of
>>> d62bd5ce12d7 ("pinctrl: amd: Implement irq_set_wake"), the AMD GPIO
>>> controller gained the capability to set the wake bit on each GPIO. The
>>> ACPI specification defines two ways to inform the system if a device is
>>> wake capable:
>>> 1) The _PRW object defines the GPE that can be used to wake the system.
>>> 2) Setting ExclusiveAndWake or SharedAndWake in the _CRS GpioInt.
>>>
>>> Currently only the first method is supported. The i2c drivers don't have
>>> any indication that the IRQ is wake capable, so they guess. This causes
>>> spurious interrupts, for example:
>>> * We have an ACPI HID device that has `_PR0` and `_PR3`. It doesn't have
>>> `_PRW` or `ExclusiveAndWake` so that means the device can't wake the
>>> system.
>>> * The IRQ line is active level low for this device and is pulled up by
>>> the power resource defined in `_PR0`/`_PR3`.
>>> * The i2c driver will (incorrectly) arm the GPIO for wake by calling
>>> `enable_irq_wake` as part of its suspend hook.
>>> * ACPI will power down the device since it doesn't have a wake GPE
>>> associated with it.
>>> * When the device is powered down, the IRQ line will drop, and it will
>>> trigger a wake event.
>>>
>>> See the following debug log:
>>> [ 42.335804] PM: Suspending system (s2idle)
>>> [ 42.340186] amd_gpio AMD0030:00: RX: Setting wake for pin 89 to enable
>>> [ 42.467736] power-0416 __acpi_power_off : Power resource [PR00] turned off
>>> [ 42.467739] device_pm-0280 device_set_power : Device [H05D] transitioned to D3cold
>>> [ 42.475210] PM: pm_system_irq_wakeup: 11 triggered pinctrl_amd
>>> [ 42.535293] PM: Wakeup unrelated to ACPI SCI
>>> [ 42.535294] PM: resume from suspend-to-idle
>>>
>>> In order to fix this, we need to take into account the wake capable bit
>>> defined on the GpioInt. This is accomplished by:
>>> * Migrating some of the i2c drivers over to using the PM subsystem to
>>> manage the wake IRQ. max8925-i2c, elants_i2c, and raydium_i2c_ts still
>>> need to be migrated, I can do that depending on the feedback to this
>>> patch series.
>>> * Expose the wake_capable bit from the ACPI GpioInt resource to the
>>> i2c core.
>>> * Use the wake_capable bit in the i2c core to call
>>> `dev_pm_set_wake_irq`. This reuses the existing device tree flow.
>>> * Make the i2c drivers stop calling `dev_pm_set_wake_irq` since it's now
>>> handled by the i2c core.
>>> * Make the ACPI device PM system aware of the wake_irq. This is
>>> necessary so the device doesn't incorrectly get powered down when a
>>> wake_irq is enabled.
>>>
>>> I've tested this code with various combinations of having _PRW,
>>> ExclusiveAndWake and power resources all defined or not defined, but it
>>> would be great if others could test this out on their hardware.
>>
>> I have got only cover letter and a single patch (#3). What's going on?
>>
>> Note: I'm also reviewer of I涎 DesignWare driver, you really have to
>> fix your tools / submission process and try again. No review for this
>> series.
>>
>> --
>> With Best Regards,
>> Andy Shevchenko
>>
>>
>
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 4/8] i2c: acpi: Use ACPI GPIO wake capability bit to set wake_irq
2022-08-30 23:15 ` [PATCH 4/8] i2c: acpi: Use ACPI GPIO wake capability bit to set wake_irq Raul E Rangel
@ 2022-09-07 1:00 ` Dmitry Torokhov
2022-09-07 2:00 ` Raul Rangel
0 siblings, 1 reply; 13+ messages in thread
From: Dmitry Torokhov @ 2022-09-07 1:00 UTC (permalink / raw)
To: Raul E Rangel
Cc: linux-acpi, linux-input, hdegoede, mario.limonciello, timvp,
rafael, Mika Westerberg, Wolfram Sang, linux-i2c, linux-kernel
On Tue, Aug 30, 2022 at 05:15:37PM -0600, Raul E Rangel wrote:
> 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 <rrangel@chromium.org>
> ---
>
> 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);
You also need to handle "Interrupt(..., ...AndWake)" case here. I would
look into maybe defining
#define IORESOURCE_IRQ_WAKECAPABLE (1<<6)
in include/linux/ioport.h and plumbing it through from ACPI layer.
Thanks.
--
Dmitry
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 4/8] i2c: acpi: Use ACPI GPIO wake capability bit to set wake_irq
2022-09-07 1:00 ` Dmitry Torokhov
@ 2022-09-07 2:00 ` Raul Rangel
2022-09-07 2:04 ` Dmitry Torokhov
2022-09-07 8:12 ` Hans de Goede
0 siblings, 2 replies; 13+ messages in thread
From: Raul Rangel @ 2022-09-07 2:00 UTC (permalink / raw)
To: Dmitry Torokhov
Cc: Linux ACPI, linux-input, Hans de Goede, Limonciello, Mario,
Tim Van Patten, Rafael J. Wysocki, Mika Westerberg, Wolfram Sang,
open list:I2C SUBSYSTEM HOST DRIVERS, linux-kernel
On Tue, Sep 6, 2022 at 7:00 PM Dmitry Torokhov
<dmitry.torokhov@gmail.com> wrote:
>
> On Tue, Aug 30, 2022 at 05:15:37PM -0600, Raul E Rangel wrote:
> > 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 <rrangel@chromium.org>
> > ---
> >
> > 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);
>
> You also need to handle "Interrupt(..., ...AndWake)" case here. I would
> look into maybe defining
>
> #define IORESOURCE_IRQ_WAKECAPABLE (1<<6)
>
> in include/linux/ioport.h and plumbing it through from ACPI layer.
>
> Thanks.
AFAIK the Intel (Not 100% certain) and AMD IO-APIC's can't actually
wake a system from suspend/suspend-to-idle. It requires either a GPE
or GPIO controller to wake the system. This is the reason I haven't
pushed patches to handle the Interrupt/IRQ resource. Can anyone
confirm?
Thanks
>
> --
> Dmitry
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 4/8] i2c: acpi: Use ACPI GPIO wake capability bit to set wake_irq
2022-09-07 2:00 ` Raul Rangel
@ 2022-09-07 2:04 ` Dmitry Torokhov
2022-09-07 8:12 ` Hans de Goede
1 sibling, 0 replies; 13+ messages in thread
From: Dmitry Torokhov @ 2022-09-07 2:04 UTC (permalink / raw)
To: Raul Rangel
Cc: Linux ACPI, linux-input, Hans de Goede, Limonciello, Mario,
Tim Van Patten, Rafael J. Wysocki, Mika Westerberg, Wolfram Sang,
open list:I2C SUBSYSTEM HOST DRIVERS, linux-kernel
On Tue, Sep 06, 2022 at 08:00:00PM -0600, Raul Rangel wrote:
> On Tue, Sep 6, 2022 at 7:00 PM Dmitry Torokhov
> <dmitry.torokhov@gmail.com> wrote:
> >
> > On Tue, Aug 30, 2022 at 05:15:37PM -0600, Raul E Rangel wrote:
> > > 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 <rrangel@chromium.org>
> > > ---
> > >
> > > 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);
> >
>
>
> > You also need to handle "Interrupt(..., ...AndWake)" case here. I would
> > look into maybe defining
> >
> > #define IORESOURCE_IRQ_WAKECAPABLE (1<<6)
> >
> > in include/linux/ioport.h and plumbing it through from ACPI layer.
> >
> > Thanks.
>
> AFAIK the Intel (Not 100% certain) and AMD IO-APIC's can't actually
> wake a system from suspend/suspend-to-idle. It requires either a GPE
> or GPIO controller to wake the system. This is the reason I haven't
> pushed patches to handle the Interrupt/IRQ resource. Can anyone
> confirm?
I've heard there are ARM ACPI systems...
Thanks.
--
Dmitry
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 4/8] i2c: acpi: Use ACPI GPIO wake capability bit to set wake_irq
2022-09-07 2:00 ` Raul Rangel
2022-09-07 2:04 ` Dmitry Torokhov
@ 2022-09-07 8:12 ` Hans de Goede
2022-09-08 14:40 ` Raul Rangel
1 sibling, 1 reply; 13+ messages in thread
From: Hans de Goede @ 2022-09-07 8:12 UTC (permalink / raw)
To: Raul Rangel, Dmitry Torokhov
Cc: Linux ACPI, linux-input, Limonciello, Mario, Tim Van Patten,
Rafael J. Wysocki, Mika Westerberg, Wolfram Sang,
open list:I2C SUBSYSTEM HOST DRIVERS, linux-kernel
Hi,
On 9/7/22 04:00, Raul Rangel wrote:
> On Tue, Sep 6, 2022 at 7:00 PM Dmitry Torokhov
> <dmitry.torokhov@gmail.com> wrote:
>>
>> On Tue, Aug 30, 2022 at 05:15:37PM -0600, Raul E Rangel wrote:
>>> 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 <rrangel@chromium.org>
>>> ---
>>>
>>> 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);
>>
>
>
>> You also need to handle "Interrupt(..., ...AndWake)" case here. I would
>> look into maybe defining
>>
>> #define IORESOURCE_IRQ_WAKECAPABLE (1<<6)
>>
>> in include/linux/ioport.h and plumbing it through from ACPI layer.
>>
>> Thanks.
>
> AFAIK the Intel (Not 100% certain) and AMD IO-APIC's can't actually
> wake a system from suspend/suspend-to-idle.
That may be true for S3 suspend (it sounds about right) there
certainly is no way to "arm for wakeup" on the APIC, but with
s2idle all IRQs which are not explicitly disabled by the OS
still function normally so there any IRQ can be a wakeup
source (AFAIK).
And even with S3 suspend I think some IRQs can act as wakeup,
but that is configured by the BIOS then and not something which
linux can enable/disable. E.g IIRC the parent IRQ of the GPIO
controllers on x86 is an APIC IRQ ...
Regards,
Hans
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 4/8] i2c: acpi: Use ACPI GPIO wake capability bit to set wake_irq
2022-09-07 8:12 ` Hans de Goede
@ 2022-09-08 14:40 ` Raul Rangel
2022-09-08 15:23 ` Rafael J. Wysocki
0 siblings, 1 reply; 13+ messages in thread
From: Raul Rangel @ 2022-09-08 14:40 UTC (permalink / raw)
To: Hans de Goede
Cc: Dmitry Torokhov, Linux ACPI, linux-input, Limonciello, Mario,
Tim Van Patten, Rafael J. Wysocki, Mika Westerberg, Wolfram Sang,
open list:I2C SUBSYSTEM HOST DRIVERS, linux-kernel
On Wed, Sep 7, 2022 at 2:12 AM Hans de Goede <hdegoede@redhat.com> wrote:
>
> Hi,
>
> On 9/7/22 04:00, Raul Rangel wrote:
> > On Tue, Sep 6, 2022 at 7:00 PM Dmitry Torokhov
> > <dmitry.torokhov@gmail.com> wrote:
> >>
> >> On Tue, Aug 30, 2022 at 05:15:37PM -0600, Raul E Rangel wrote:
> >>> 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 <rrangel@chromium.org>
> >>> ---
> >>>
> >>> 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);
> >>
> >
> >
> >> You also need to handle "Interrupt(..., ...AndWake)" case here. I would
> >> look into maybe defining
> >>
> >> #define IORESOURCE_IRQ_WAKECAPABLE (1<<6)
> >>
> >> in include/linux/ioport.h and plumbing it through from ACPI layer.
> >>
> >> Thanks.
> >
> > AFAIK the Intel (Not 100% certain) and AMD IO-APIC's can't actually
> > wake a system from suspend/suspend-to-idle.
>
> That may be true for S3 suspend (it sounds about right) there
> certainly is no way to "arm for wakeup" on the APIC, but with
> s2idle all IRQs which are not explicitly disabled by the OS
> still function normally so there any IRQ can be a wakeup
> source (AFAIK).
>
> And even with S3 suspend I think some IRQs can act as wakeup,
> but that is configured by the BIOS then and not something which
> linux can enable/disable. E.g IIRC the parent IRQ of the GPIO
> controllers on x86 is an APIC IRQ ...
>
> Regards,
>
> Hans
>
SGTM. I wanted to make sure there was interest before I invested the
time in adding the functionality. Hopefully I can push up a new patch
set tomorrow.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 4/8] i2c: acpi: Use ACPI GPIO wake capability bit to set wake_irq
2022-09-08 14:40 ` Raul Rangel
@ 2022-09-08 15:23 ` Rafael J. Wysocki
2022-09-09 18:47 ` Raul Rangel
0 siblings, 1 reply; 13+ messages in thread
From: Rafael J. Wysocki @ 2022-09-08 15:23 UTC (permalink / raw)
To: Raul Rangel
Cc: Hans de Goede, Dmitry Torokhov, Linux ACPI, linux-input,
Limonciello, Mario, Tim Van Patten, Rafael J. Wysocki,
Mika Westerberg, Wolfram Sang,
open list:I2C SUBSYSTEM HOST DRIVERS, linux-kernel
On Thu, Sep 8, 2022 at 4:40 PM Raul Rangel <rrangel@chromium.org> wrote:
>
> On Wed, Sep 7, 2022 at 2:12 AM Hans de Goede <hdegoede@redhat.com> wrote:
> >
> > Hi,
> >
> > On 9/7/22 04:00, Raul Rangel wrote:
> > > On Tue, Sep 6, 2022 at 7:00 PM Dmitry Torokhov
> > > <dmitry.torokhov@gmail.com> wrote:
> > >>
> > >> On Tue, Aug 30, 2022 at 05:15:37PM -0600, Raul E Rangel wrote:
> > >>> 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 <rrangel@chromium.org>
> > >>> ---
> > >>>
> > >>> 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);
> > >>
> > >
> > >
> > >> You also need to handle "Interrupt(..., ...AndWake)" case here. I would
> > >> look into maybe defining
> > >>
> > >> #define IORESOURCE_IRQ_WAKECAPABLE (1<<6)
> > >>
> > >> in include/linux/ioport.h and plumbing it through from ACPI layer.
> > >>
> > >> Thanks.
> > >
> > > AFAIK the Intel (Not 100% certain) and AMD IO-APIC's can't actually
> > > wake a system from suspend/suspend-to-idle.
> >
> > That may be true for S3 suspend (it sounds about right) there
> > certainly is no way to "arm for wakeup" on the APIC, but with
> > s2idle all IRQs which are not explicitly disabled by the OS
> > still function normally so there any IRQ can be a wakeup
> > source (AFAIK).
That's true.
Moreover, even for S3 there are transitions into it and there may be
wakeup interrupts taking place during those transitions. Those may be
any IRQs too.
> > And even with S3 suspend I think some IRQs can act as wakeup,
> > but that is configured by the BIOS then and not something which
> > linux can enable/disable. E.g IIRC the parent IRQ of the GPIO
> > controllers on x86 is an APIC IRQ ...
It's more about how the system is wired up AFAICS. Basically, in
order to wake up the system from S3, the given IRQ needs to be
physically attached to an input that will trigger the platform wakeup
logic while in S3.
> >
>
> SGTM. I wanted to make sure there was interest before I invested the
> time in adding the functionality. Hopefully I can push up a new patch
> set tomorrow.
Sounds good. :-)
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 4/8] i2c: acpi: Use ACPI GPIO wake capability bit to set wake_irq
2022-09-08 15:23 ` Rafael J. Wysocki
@ 2022-09-09 18:47 ` Raul Rangel
2022-09-10 1:25 ` Dmitry Torokhov
0 siblings, 1 reply; 13+ messages in thread
From: Raul Rangel @ 2022-09-09 18:47 UTC (permalink / raw)
To: Rafael J. Wysocki
Cc: Hans de Goede, Dmitry Torokhov, Linux ACPI, linux-input,
Limonciello, Mario, Tim Van Patten, Mika Westerberg, Wolfram Sang,
open list:I2C SUBSYSTEM HOST DRIVERS, linux-kernel
It looks like `i2c_acpi_get_irq` and `platform_get_irq_optional` are
doing pretty much the same thing. Can we replace `i2c_acpi_get_irq`
and switch over to `platform_get_irq_optional`? Is it possible to get
a `platform_device` from an `i2c_client`?
On Thu, Sep 8, 2022 at 9:23 AM Rafael J. Wysocki <rafael@kernel.org> wrote:
>
> On Thu, Sep 8, 2022 at 4:40 PM Raul Rangel <rrangel@chromium.org> wrote:
> >
> > On Wed, Sep 7, 2022 at 2:12 AM Hans de Goede <hdegoede@redhat.com> wrote:
> > >
> > > Hi,
> > >
> > > On 9/7/22 04:00, Raul Rangel wrote:
> > > > On Tue, Sep 6, 2022 at 7:00 PM Dmitry Torokhov
> > > > <dmitry.torokhov@gmail.com> wrote:
> > > >>
> > > >> On Tue, Aug 30, 2022 at 05:15:37PM -0600, Raul E Rangel wrote:
> > > >>> 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 <rrangel@chromium.org>
> > > >>> ---
> > > >>>
> > > >>> 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);
> > > >>
> > > >
> > > >
> > > >> You also need to handle "Interrupt(..., ...AndWake)" case here. I would
> > > >> look into maybe defining
> > > >>
> > > >> #define IORESOURCE_IRQ_WAKECAPABLE (1<<6)
> > > >>
> > > >> in include/linux/ioport.h and plumbing it through from ACPI layer.
> > > >>
> > > >> Thanks.
> > > >
> > > > AFAIK the Intel (Not 100% certain) and AMD IO-APIC's can't actually
> > > > wake a system from suspend/suspend-to-idle.
> > >
> > > That may be true for S3 suspend (it sounds about right) there
> > > certainly is no way to "arm for wakeup" on the APIC, but with
> > > s2idle all IRQs which are not explicitly disabled by the OS
> > > still function normally so there any IRQ can be a wakeup
> > > source (AFAIK).
>
> That's true.
>
> Moreover, even for S3 there are transitions into it and there may be
> wakeup interrupts taking place during those transitions. Those may be
> any IRQs too.
>
> > > And even with S3 suspend I think some IRQs can act as wakeup,
> > > but that is configured by the BIOS then and not something which
> > > linux can enable/disable. E.g IIRC the parent IRQ of the GPIO
> > > controllers on x86 is an APIC IRQ ...
>
> It's more about how the system is wired up AFAICS. Basically, in
> order to wake up the system from S3, the given IRQ needs to be
> physically attached to an input that will trigger the platform wakeup
> logic while in S3.
>
> > >
> >
> > SGTM. I wanted to make sure there was interest before I invested the
> > time in adding the functionality. Hopefully I can push up a new patch
> > set tomorrow.
>
> Sounds good. :-)
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 4/8] i2c: acpi: Use ACPI GPIO wake capability bit to set wake_irq
2022-09-09 18:47 ` Raul Rangel
@ 2022-09-10 1:25 ` Dmitry Torokhov
0 siblings, 0 replies; 13+ messages in thread
From: Dmitry Torokhov @ 2022-09-10 1:25 UTC (permalink / raw)
To: Raul Rangel
Cc: Rafael J. Wysocki, Hans de Goede, Linux ACPI, linux-input,
Limonciello, Mario, Tim Van Patten, Mika Westerberg, Wolfram Sang,
open list:I2C SUBSYSTEM HOST DRIVERS, linux-kernel
On Fri, Sep 09, 2022 at 12:47:11PM -0600, Raul Rangel wrote:
> It looks like `i2c_acpi_get_irq` and `platform_get_irq_optional` are
> doing pretty much the same thing. Can we replace `i2c_acpi_get_irq`
> and switch over to `platform_get_irq_optional`? Is it possible to get
> a `platform_device` from an `i2c_client`?
No, they are completely different objects.
struct device
/ | \
platform_device i2c_client spi_device ...
Also, please no top-posting on kernel mailing lists.
Thanks.
--
Dmitry
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2022-09-10 1:25 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-08-30 23:15 [PATCH 0/8] acpi: i2c: Use SharedAndWake and ExclusiveAndWake to enable wake irq Raul E Rangel
2022-08-30 23:15 ` [PATCH 4/8] i2c: acpi: Use ACPI GPIO wake capability bit to set wake_irq Raul E Rangel
2022-09-07 1:00 ` Dmitry Torokhov
2022-09-07 2:00 ` Raul Rangel
2022-09-07 2:04 ` Dmitry Torokhov
2022-09-07 8:12 ` Hans de Goede
2022-09-08 14:40 ` Raul Rangel
2022-09-08 15:23 ` Rafael J. Wysocki
2022-09-09 18:47 ` Raul Rangel
2022-09-10 1:25 ` Dmitry Torokhov
2022-08-31 11:52 ` [PATCH 0/8] acpi: i2c: Use SharedAndWake and ExclusiveAndWake to enable wake irq Andy Shevchenko
2022-08-31 14:37 ` Raul Rangel
2022-08-31 15:18 ` Hans de Goede
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox