linux/drivers/base
Rafael J. Wysocki 8873710660 PM: runtime: Fix supplier device management during consumer probe
Because pm_runtime_get_suppliers() bumps up the rpm_active counter
of each device link to a supplier of the given device in addition
to bumping up the supplier's PM-runtime usage counter, a runtime
suspend of the consumer device may case the latter to go down to 0
when pm_runtime_put_suppliers() is running on a remote CPU.  If that
happens after pm_runtime_put_suppliers() has released power.lock for
the consumer device, and a runtime resume of that device takes place
immediately after it, before pm_runtime_put() is called for the
supplier, that pm_runtime_put() call may cause the supplier to be
suspended even though the consumer is active.

To prevent that from happening, modify pm_runtime_get_suppliers() to
call pm_runtime_get_sync() for the given device's suppliers without
touching the rpm_active counters of the involved device links
Accordingly, modify pm_runtime_put_suppliers() to call pm_runtime_put()
for the given device's suppliers without looking at the rpm_active
counters of the device links at hand.  [This is analogous to what
happened before commit 4c06c4e6cf ("driver core: Fix possible
supplier PM-usage counter imbalance").]

Since pm_runtime_get_suppliers() sets supplier_preactivated for each
device link where the supplier's PM-runtime usage counter has been
incremented and pm_runtime_put_suppliers() calls pm_runtime_put() for
the suppliers whose device links have supplier_preactivated set, the
PM-runtime usage counter is balanced for each supplier and this is
independent of the runtime suspend and resume of the consumer device.

However, in case a device link with DL_FLAG_PM_RUNTIME set is dropped
during the consumer device probe, so pm_runtime_get_suppliers() bumps
up the supplier's PM-runtime usage counter, but it cannot be dropped by
pm_runtime_put_suppliers(), make device_link_release_fn() take care of
that.

Fixes: 4c06c4e6cf ("driver core: Fix possible supplier PM-usage counter imbalance")
Reported-by: Peter Wang <peter.wang@mediatek.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Reviewed-by: Peter Wang <peter.wang@mediatek.com>
Cc: 5.1+ <stable@vger.kernel.org> # 5.1+
2022-07-01 21:04:15 +02:00
..
firmware_loader firmware_loader: enable XZ by default if compressed support is enabled 2022-06-03 15:46:03 -07:00
power PM: runtime: Fix supplier device management during consumer probe 2022-07-01 21:04:15 +02:00
regmap regmap-irq: Fix offset/index mismatch in read_sub_irq_data() 2022-06-22 11:59:52 +01:00
test
arch_numa.c
arch_topology.c
attribute_container.c
auxiliary.c
base.h driver core: Extend deferred probe timeout on driver registration 2022-05-19 19:32:33 +02:00
bus.c
cacheinfo.c
class.c
component.c
container.c
core.c PM: runtime: Fix supplier device management during consumer probe 2022-07-01 21:04:15 +02:00
cpu.c x86/speculation/mmio: Add sysfs reporting for Processor MMIO Stale Data 2022-05-21 12:16:04 +02:00
dd.c driver core: Set default deferred_probe_timeout back to 0. 2022-06-03 11:58:54 -07:00
devcoredump.c
devres.c
devtmpfs.c
driver.c driver core: Extend deferred probe timeout on driver registration 2022-05-19 19:32:33 +02:00
firmware.c
hypervisor.c
init.c init: Initialize noop_backing_dev_info early 2022-06-16 10:55:57 +02:00
isa.c
Kconfig
Makefile
map.c
memory.c mm/memory-failure: disable unpoison once hw error happens 2022-06-16 19:11:32 -07:00
module.c
node.c
physical_location.c
physical_location.h
pinctrl.c
platform-msi.c
platform.c Driver core changes for 5.19-rc1 2022-06-03 11:48:47 -07:00
property.c USB / Thunderbolt changes for 5.19-rc1 2022-06-03 11:17:49 -07:00
soc.c
swnode.c
syscore.c
topology.c
trace.c
trace.h
transport_class.c