linux-stable/include
Rafael J. Wysocki 3d6b7c14f8 driver core: Fix possible supplier PM-usage counter imbalance
[ Upstream commit 4c06c4e6cf ]

If a stateless device link to a certain supplier with
DL_FLAG_PM_RUNTIME set in the flags is added and then removed by the
consumer driver's probe callback, the supplier's PM-runtime usage
counter will be nonzero after that which effectively causes the
supplier to remain "always on" going forward.

Namely, device_link_add() called to add the link invokes
device_link_rpm_prepare() which notices that the consumer driver is
probing, so it increments the supplier's PM-runtime usage counter
with the assumption that the link will stay around until
pm_runtime_put_suppliers() is called by driver_probe_device(),
but if the link goes away before that point, the supplier's
PM-runtime usage counter will remain nonzero.

To prevent that from happening, first rework pm_runtime_get_suppliers()
and pm_runtime_put_suppliers() to use the rpm_active refounts of device
links and make the latter only drop rpm_active and the supplier's
PM-runtime usage counter for each link by one, unless rpm_active is
one already for it.  Next, modify device_link_add() to bump up the
new link's rpm_active refcount and the suppliers PM-runtime usage
counter by two, to prevent pm_runtime_put_suppliers(), if it is
called subsequently, from suspending the supplier prematurely (in
case its PM-runtime usage counter goes down to 0 in there).

Due to the way rpm_put_suppliers() works, this change does not
affect runtime suspend of the consumer ends of new device links (or,
generally, device links for which DL_FLAG_PM_RUNTIME has just been
set).

Fixes: e2f3cd831a ("driver core: Fix handling of runtime PM flags in device_link_add()")
Reported-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org>
Tested-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2020-01-27 14:50:22 +01:00
..
acpi ACPICA: ACPI 6.3: PPTT add additional fields in Processor Structure Flags 2019-10-17 13:45:33 -07:00
asm-generic asm-generic: fix -Wtype-limits compiler warnings 2019-08-25 10:47:58 +02:00
clocksource
crypto crypto: chacha20 - Fix chacha20_block() keystream alignment (again) 2019-11-20 18:47:11 +01:00
drm drm: mst: Fix query_payload ack reply struct 2019-12-31 16:34:47 +01:00
dt-bindings dt-bindings: reset: meson8b: fix duplicate reset IDs 2020-01-23 08:21:26 +01:00
keys keys: Fix dependency loop between construction record and auth key 2019-03-23 20:09:48 +01:00
kvm KVM: arm/arm64: Sync ICH_VMCR_EL2 back when about to block 2019-08-25 10:47:59 +02:00
linux driver core: Fix possible supplier PM-usage counter imbalance 2020-01-27 14:50:22 +01:00
math-emu math-emu/soft-fp.h: (_FP_ROUND_ZERO) cast 0 to void to fix warning 2019-12-13 08:51:34 +01:00
media media: vsp1: Fix YCbCr planar formats pitch calculation 2019-11-20 18:46:52 +01:00
memory
misc
net cfg80211/mac80211: make ieee80211_send_layer2_update a public function 2020-01-17 19:46:55 +01:00
pcmcia
ras
rdma IB/mlx4: Avoid implicit enumerated type conversion 2019-11-24 08:20:04 +01:00
scsi scsi: target: iscsi: Wait for all commands to finish before freeing a session 2020-01-04 19:13:06 +01:00
soc soc/tegra: pmc: Fix pad voltage configuration for Tegra186 2019-11-20 18:45:24 +01:00
sound ASoC: wm97xx: fix uninitialized regmap pointer problem 2020-01-27 14:50:01 +01:00
target scsi: target/core: Make sure that target_wait_for_sess_cmds() waits long enough 2019-01-26 09:32:38 +01:00
trace tracing: Change offset type to s32 in preempt/irq tracepoints 2020-01-14 20:07:00 +01:00
uapi Input: input_event - fix struct padding on sparc64 2020-01-14 20:07:01 +01:00
video udlfb: introduce a rendering mutex 2019-05-25 18:23:30 +02:00
xen xen/events: fix binding user event channels to cpus 2019-07-26 09:14:25 +02:00