linux-stable/drivers/base
Rafael J. Wysocki cfbb3c82d8 PM: runtime: Fix supplier device management during consumer probe
commit 8873710660 upstream.

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+
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-07-12 16:42:16 +02:00
..
firmware_loader firmware_loader: use kernel credentials when reading firmware 2022-05-06 10:00:03 +02:00
power PM: runtime: Fix supplier device management during consumer probe 2022-07-12 16:42:16 +02:00
regmap regmap-irq: Fix offset/index mismatch in read_sub_irq_data() 2022-06-29 09:04:34 +02:00
test driver core: Simplify async probe test code by using ktime_ms_delta() 2021-12-29 10:57:22 +01:00
arch_numa.c mm: percpu: add generic pcpu_populate_pte() function 2022-01-20 08:52:52 +02:00
arch_topology.c arch_topology: Do not set llc_sibling if llc_id is invalid 2022-04-20 18:57:59 +02:00
attribute_container.c driver core: attribute_container: fix W=1 warnings 2021-05-14 13:37:10 +02:00
auxiliary.c Documentation/auxiliary_bus: Move the text into the code 2021-12-03 16:41:50 +01:00
base.h software nodes: Split software_node_notify() 2021-07-16 19:17:05 +02:00
bus.c driver: base: fix UAF when driver_attach failed 2022-06-14 18:44:52 +02:00
cacheinfo.c cacheinfo: clear cache_leaves(cpu) in free_cache_attributes() 2021-07-21 17:29:40 +02:00
class.c block: remove genhd.h 2022-02-02 07:49:59 -07:00
component.c component: Add common helper for compare/release functions 2022-02-25 12:16:12 +01:00
container.c
core.c PM: runtime: Fix supplier device management during consumer probe 2022-07-12 16:42:16 +02:00
cpu.c x86/speculation/mmio: Add sysfs reporting for Processor MMIO Stale Data 2022-06-16 13:32:04 +02:00
dd.c driver core: Fix wait_for_device_probe() & deferred_probe_timeout interaction 2022-06-14 18:45:00 +02:00
devcoredump.c devcoredump: remove contact information 2021-06-04 15:05:44 +02:00
devres.c devres: fix typos in comments 2022-03-18 14:30:12 +01:00
devtmpfs.c Driver core changes for 5.18-rc1 2022-03-28 12:41:28 -07:00
driver.c drivers: base: Convert to printk alias functions 2020-07-10 14:16:44 +02:00
firmware.c
hypervisor.c
init.c init: Initialize noop_backing_dev_info early 2022-06-22 14:28:03 +02:00
isa.c bus: Make remove callback return void 2021-07-21 11:53:42 +02:00
Kconfig devtmpfs: mount with noexec and nosuid 2021-12-30 13:54:42 +01:00
Makefile mm/memory_hotplug: remove CONFIG_MEMORY_HOTPLUG_SPARSE 2021-11-06 13:30:42 -07:00
map.c driver: base: Prefer unsigned int to bare use of unsigned 2021-07-21 17:30:09 +02:00
memory.c mm/memory-failure: disable unpoison once hw error happens 2022-06-29 09:04:41 +02:00
module.c
node.c drivers/base/node.c: fix compaction sysfs file leak 2022-06-09 10:30:27 +02:00
pinctrl.c
platform-msi.c platform-msi: Simplify platform device MSI code 2021-12-16 22:22:19 +01:00
platform.c platform: use dev_err_probe() in platform_get_irq_byname() 2022-02-08 12:22:07 +01:00
property.c device property: Allow error pointer to be passed to fwnode APIs 2022-06-09 10:29:58 +02:00
soc.c base: soc: Make soc_device_match() simpler and easier to read 2022-03-18 14:28:07 +01:00
swnode.c software node: fix wrong node passed to find nargs_prop 2021-12-22 18:26:18 +01:00
syscore.c syscore: Use pm_pr_dbg() for syscore_{suspend,resume}() 2020-09-08 13:32:06 +02:00
topology.c topology: Fix up build warning in topology_is_visible() 2022-04-23 12:53:11 +02:00
trace.c devres: Enable trace events 2021-06-15 17:14:36 +02:00
trace.h devres: Enable trace events 2021-06-15 17:14:36 +02:00
transport_class.c