Rafael J. Wysocki 4c06c4e6cf driver core: Fix possible supplier PM-usage counter imbalance
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: e2f3cd831a28 ("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>
2019-02-13 09:09:57 +01:00
..
2019-02-11 09:09:02 +01:00
2018-12-31 17:32:35 -08:00
2018-12-29 08:20:44 -07:00
2019-01-25 13:03:34 -10:00
2019-02-10 10:39:37 -08:00
2018-12-10 10:17:45 +01:00
2019-01-09 19:20:31 -05:00
2019-01-26 11:14:25 +01:00
2019-02-11 09:09:02 +01:00
2019-02-06 17:24:37 -05:00
2019-01-05 11:30:37 -08:00
2018-12-28 16:52:18 -08:00
2019-02-01 15:53:54 +01:00
2019-02-11 09:09:02 +01:00
2019-01-05 11:23:17 -08:00
2019-01-25 12:57:09 -10:00
2018-12-29 13:03:29 -08:00
2018-12-24 12:06:56 +01:00
2019-01-01 13:24:31 -08:00
2019-02-08 15:37:17 -08:00
2019-01-30 11:14:04 +01:00
2018-12-31 13:06:30 -08:00
2019-02-08 10:49:55 -08:00
2018-12-28 20:54:57 -08:00
2019-01-28 22:53:09 -08:00
2019-01-25 12:58:40 -10:00
2018-12-29 13:40:29 -08:00