sst-linux/drivers/base
Rafael J. Wysocki 72520ca5f9 PM: sleep: Fix handling devices with direct_complete set on errors
[ Upstream commit 03f1444016b71feffa1dfb8a51f15ba592f94b13 ]

When dpm_suspend() fails, some devices with power.direct_complete set
may not have been handled by device_suspend() yet, so runtime PM has
not been disabled for them yet even though power.direct_complete is set.

Since device_resume() expects that runtime PM has been disabled for all
devices with power.direct_complete set, it will attempt to reenable
runtime PM for the devices that have not been processed by device_suspend()
which does not make sense.  Had those devices had runtime PM disabled
before device_suspend() had run, device_resume() would have inadvertently
enable runtime PM for them, but this is not expected to happen because
it would require ->prepare() callbacks to return positive values for
devices with runtime PM disabled, which would be invalid.

In practice, this issue is most likely benign because pm_runtime_enable()
will not allow the "disable depth" counter to underflow, but it causes a
warning message to be printed for each affected device.

To allow device_resume() to distinguish the "direct complete" devices
that have been processed by device_suspend() from those which have not
been handled by it, make device_suspend() set power.is_suspended for
"direct complete" devices.

Next, move the power.is_suspended check in device_resume() before the
power.direct_complete check in it to make it skip the "direct complete"
devices that have not been handled by device_suspend().

This change is based on a preliminary patch from Saravana Kannan.

Fixes: aae4518b31 ("PM / sleep: Mechanism to avoid resuming runtime-suspended devices unnecessarily")
Link: https://lore.kernel.org/linux-pm/20241114220921.2529905-2-saravanak@google.com/
Reported-by: Saravana Kannan <saravanak@google.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Reviewed-by: Saravana Kannan <saravanak@google.com>
Link: https://patch.msgid.link/12627587.O9o76ZdvQC@rjwysocki.net
Signed-off-by: Sasha Levin <sashal@kernel.org>
2025-04-10 14:33:31 +02:00
..
firmware_loader firmware_loader: Block path traversal 2024-10-17 15:21:20 +02:00
power PM: sleep: Fix handling devices with direct_complete set on errors 2025-04-10 14:33:31 +02:00
regmap regmap-irq: Add missing kfree() 2025-02-21 13:50:05 +01:00
test
arch_numa.c arm64: irq: set the correct node for VMAP stack 2024-02-05 20:12:46 +00:00
arch_topology.c
attribute_container.c
auxiliary.c
base.h
bus.c driver core: bus: Fix double free in driver API bus_register() 2024-12-14 19:54:00 +01:00
cacheinfo.c
class.c
component.c
container.c
core.c drivers: core: fix device leak in __fw_devlink_relax_cycles() 2025-03-13 12:53:22 +01:00
cpu.c x86/rfds: Mitigate Register File Data Sampling (RFDS) 2024-03-15 10:48:21 -04:00
dd.c
devcoredump.c
devres.c devres: Initialize an uninitialized struct member 2024-09-12 11:10:23 +02:00
devtmpfs.c
driver.c
firmware.c
hypervisor.c
init.c
isa.c
Kconfig
Makefile
map.c
memory.c
module.c Revert "driver core: Fix uevent_show() vs driver detach race" 2024-11-08 16:26:44 +01:00
node.c base/node.c: initialize the accessor list before registering 2024-01-25 15:27:46 -08:00
physical_location.c
physical_location.h
pinctrl.c
platform-msi.c
platform.c
property.c device property: Constify device child node APIs 2024-12-14 19:54:28 +01:00
soc.c
swnode.c software node: Let args be NULL in software_node_get_reference_args 2024-01-25 15:27:46 -08:00
syscore.c
topology.c topology: Keep the cpumask unchanged when printing cpumap 2025-01-17 13:34:44 +01:00
trace.c
trace.h
transport_class.c