]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
PM: sleep: Update power.completion for all devices on errors
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>
Mon, 14 Jul 2025 17:45:31 +0000 (19:45 +0200)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Tue, 15 Jul 2025 12:55:11 +0000 (14:55 +0200)
commitebd6884167eac94bae9f92793fcd84069d9e4415
treee169dea607f3c4dfd40c708b4bce5827e3d31dec
parent228b9deded0011482149cdb474e3ad15aeeb4a97
PM: sleep: Update power.completion for all devices on errors

After commit aa7a9275ab81 ("PM: sleep: Suspend async parents after
suspending children"), the following scenario is possible:

 1. Device A is async and it depends on device B that is sync.
 2. Async suspend is scheduled for A before the processing of B is
    started.
 3. A is waiting for B.
 4. In the meantime, an unrelated device fails to suspend and returns
    an error.
 5. The processing of B doesn't start at all and its power.completion is
    not updated.
 6. A is still waiting for B when async_synchronize_full() is called.
 7. Deadlock ensues.

To prevent this from happening, update power.completion for all devices
on errors in all suspend phases, but do not do it directly for devices
that are already being processed or are waiting for the processing to
start because in those cases it may be necessary to wait for the
processing to actually complete before updating power.completion for
the device.

Fixes: aa7a9275ab81 ("PM: sleep: Suspend async parents after suspending children")
Fixes: 443046d1ad66 ("PM: sleep: Make suspend of devices more asynchronous")
Closes: https://lore.kernel.org/linux-pm/e13740a0-88f3-4a6f-920f-15805071a7d6@linaro.org/
Reported-and-tested-by: Tudor Ambarus <tudor.ambarus@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org>
Link: https://patch.msgid.link/6191258.lOV4Wx5bFT@rjwysocki.net
drivers/base/power/main.c