public inbox for linux-acpi@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ACPI / PM: Use target_state to set the device power state
@ 2015-07-28 10:51 Mika Westerberg
  2015-07-28 15:59 ` Rafael J. Wysocki
  0 siblings, 1 reply; 2+ messages in thread
From: Mika Westerberg @ 2015-07-28 10:51 UTC (permalink / raw)
  To: Rafael J. Wysocki; +Cc: Len Brown, Mika Westerberg, linux-acpi, linux-kernel

Commit 20dacb71ad28 ("ACPI / PM: Rework device power management to follow
ACPI 6") changed the device power management to use D3hot if the device
in question does not have _PR3 method even if D3cold was requested by the
caller.

However, if the device has _PR3 device->power.state is also set to D3hot
instead of D3Cold after power resources have been turned off because
device->power.state will be assigned from "state" instead of
"target_state".

Next time the device is transitioned to D0, acpi_power_transition() will
find that the current power state of the device is D3hot instead of D3cold
which causes it to power down all resources required for the current
(wrong) state D3hot.

Below is a simplified ASL example of a real touch panel device which
triggers the problem:

  Scope (TPL1)
  {
      Name (_PR0, Package (1) { \_SB.PCI0.I2C1.PXTC })
      Name (_PR3, Package (1) { \_SB.PCI0.I2C1.PXTC })
      ...
  }

In both D0 and D3hot the same power resource is required. However, when
acpi_power_transition() turns off power resources required for D3hot (as
the device is transitioned to D0) it powers down PXTC which then makes the
device to lose its power.

Fix this by assigning "target_state" to the device power state instead of
"state" that is always D3hot even for devices with valid _PR3.

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
---
 drivers/acpi/device_pm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/acpi/device_pm.c b/drivers/acpi/device_pm.c
index 08dc3ec7e892..337e8118836d 100644
--- a/drivers/acpi/device_pm.c
+++ b/drivers/acpi/device_pm.c
@@ -231,7 +231,7 @@ int acpi_device_set_power(struct acpi_device *device, int state)
 		dev_warn(&device->dev, "Failed to change power state to %s\n",
 			 acpi_power_state_string(state));
 	} else {
-		device->power.state = state;
+		device->power.state = target_state;
 		ACPI_DEBUG_PRINT((ACPI_DB_INFO,
 				  "Device [%s] transitioned to %s\n",
 				  device->pnp.bus_id,
-- 
2.4.6


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] ACPI / PM: Use target_state to set the device power state
  2015-07-28 10:51 [PATCH] ACPI / PM: Use target_state to set the device power state Mika Westerberg
@ 2015-07-28 15:59 ` Rafael J. Wysocki
  0 siblings, 0 replies; 2+ messages in thread
From: Rafael J. Wysocki @ 2015-07-28 15:59 UTC (permalink / raw)
  To: Mika Westerberg; +Cc: Len Brown, linux-acpi, linux-kernel

On Tuesday, July 28, 2015 01:51:21 PM Mika Westerberg wrote:
> Commit 20dacb71ad28 ("ACPI / PM: Rework device power management to follow
> ACPI 6") changed the device power management to use D3hot if the device
> in question does not have _PR3 method even if D3cold was requested by the
> caller.
> 
> However, if the device has _PR3 device->power.state is also set to D3hot
> instead of D3Cold after power resources have been turned off because
> device->power.state will be assigned from "state" instead of
> "target_state".
> 
> Next time the device is transitioned to D0, acpi_power_transition() will
> find that the current power state of the device is D3hot instead of D3cold
> which causes it to power down all resources required for the current
> (wrong) state D3hot.
> 
> Below is a simplified ASL example of a real touch panel device which
> triggers the problem:
> 
>   Scope (TPL1)
>   {
>       Name (_PR0, Package (1) { \_SB.PCI0.I2C1.PXTC })
>       Name (_PR3, Package (1) { \_SB.PCI0.I2C1.PXTC })
>       ...
>   }
> 
> In both D0 and D3hot the same power resource is required. However, when
> acpi_power_transition() turns off power resources required for D3hot (as
> the device is transitioned to D0) it powers down PXTC which then makes the
> device to lose its power.
> 
> Fix this by assigning "target_state" to the device power state instead of
> "state" that is always D3hot even for devices with valid _PR3.
> 
> Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>

Applied, thanks!

Rafael

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-07-28 15:59 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-07-28 10:51 [PATCH] ACPI / PM: Use target_state to set the device power state Mika Westerberg
2015-07-28 15:59 ` Rafael J. Wysocki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox