diff mbox series

[v6,08/13] ACPI: PM: Take wake IRQ into consideration when entering suspend-to-idle

Message ID 20220929093200.v6.8.I7d9202463f08373feccd6e8fd87482c4f40ece5d@changeid (mailing list archive)
State Mainlined
Commit a6c05e1223c9f32836ee8df3d66208b869e5b5d7
Headers show
Series acpi: i2c: Use SharedAndWake and ExclusiveAndWake to enable wake irq | expand

Commit Message

Raul Rangel Sept. 29, 2022, 4:19 p.m. UTC
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 <rrangel@chromium.org>
---

Changes in v6:
- Refactored to leave else clause

Changes in v5:
- Go back to using adev->wakeup.flags.valid to keep the diff cleaner
- Fix a typo in comment

 drivers/acpi/device_pm.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

Comments

Rafael J. Wysocki Sept. 29, 2022, 7:06 p.m. UTC | #1
On Thu, Sep 29, 2022 at 6:19 PM Raul E Rangel <rrangel@chromium.org> wrote:
>
> 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 <rrangel@chromium.org>
> ---
>
> Changes in v6:
> - Refactored to leave else clause
>
> Changes in v5:
> - Go back to using adev->wakeup.flags.valid to keep the diff cleaner
> - Fix a typo in comment
>
>  drivers/acpi/device_pm.c | 15 +++++++++++++++
>  1 file changed, 15 insertions(+)
>
> diff --git a/drivers/acpi/device_pm.c b/drivers/acpi/device_pm.c
> index 9dce1245689ca25..b657998ce728e4c 100644
> --- a/drivers/acpi/device_pm.c
> +++ b/drivers/acpi/device_pm.c
> @@ -681,7 +681,22 @@ static int acpi_dev_pm_get_state(struct device *dev, struct acpi_device *adev,
>                 d_min = ret;
>                 wakeup = device_may_wakeup(dev) && adev->wakeup.flags.valid
>                         && adev->wakeup.sleep_state >= target_state;
> +       } else if (device_may_wakeup(dev) && dev->power.wakeirq) {
> +               /*
> +                * The ACPI subsystem doesn't manage the wake bit for IRQs
> +                * defined with ExclusiveAndWake and SharedAndWake. Instead we
> +                * expect them to be managed via the PM subsystem. Drivers
> +                * should call dev_pm_set_wake_irq to register an IRQ as a wake
> +                * source.
> +                *
> +                * If a device has a wake IRQ attached we need to check the
> +                * _S0W method to get the correct wake D-state. Otherwise we
> +                * end up putting the device into D3Cold which will more than
> +                * likely disable wake functionality.
> +                */
> +               wakeup = true;
>         } else {
> +               /* ACPI GPE is specified in _PRW. */
>                 wakeup = adev->wakeup.flags.valid;
>         }
>
> --

I can apply this one readily if that helps.

It doesn't depend on anything else in the series AFAICS.

It looks like patch [01/13] could also be applied right away, but
probably it is not for the ACPI tree.

I have a small comment to patch [06/13], and after that is addressed
it could be applied right away too I suppose, but the rest of the
patches need ACKs from the respective maintainers.
diff mbox series

Patch

diff --git a/drivers/acpi/device_pm.c b/drivers/acpi/device_pm.c
index 9dce1245689ca25..b657998ce728e4c 100644
--- a/drivers/acpi/device_pm.c
+++ b/drivers/acpi/device_pm.c
@@ -681,7 +681,22 @@  static int acpi_dev_pm_get_state(struct device *dev, struct acpi_device *adev,
 		d_min = ret;
 		wakeup = device_may_wakeup(dev) && adev->wakeup.flags.valid
 			&& adev->wakeup.sleep_state >= target_state;
+	} else if (device_may_wakeup(dev) && dev->power.wakeirq) {
+		/*
+		 * The ACPI subsystem doesn't manage the wake bit for IRQs
+		 * defined with ExclusiveAndWake and SharedAndWake. Instead we
+		 * expect them to be managed via the PM subsystem. Drivers
+		 * should call dev_pm_set_wake_irq to register an IRQ as a wake
+		 * source.
+		 *
+		 * If a device has a wake IRQ attached we need to check the
+		 * _S0W method to get the correct wake D-state. Otherwise we
+		 * end up putting the device into D3Cold which will more than
+		 * likely disable wake functionality.
+		 */
+		wakeup = true;
 	} else {
+		/* ACPI GPE is specified in _PRW. */
 		wakeup = adev->wakeup.flags.valid;
 	}