]> git.baikalelectronics.ru Git - kernel.git/commit
PM / runtime: Fixup reference counting of device link suppliers at probe
authorUlf Hansson <ulf.hansson@linaro.org>
Fri, 18 May 2018 08:48:49 +0000 (10:48 +0200)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Sun, 27 May 2018 10:10:32 +0000 (12:10 +0200)
commit1955ddc3bfbf0bb540d33f269dd869aa73248282
treef986241cbcd4db9aaf11e74d2e2776616d79e06e
parent67c239c0ea95fac45599dc1ad88257683584d3fa
PM / runtime: Fixup reference counting of device link suppliers at probe

In the driver core, before it invokes really_probe() it runtime resumes the
suppliers for the device via calling pm_runtime_get_suppliers(), which also
increases the runtime PM usage count for each of the available supplier.

This makes sense, as to be able to allow the consumer device to be probed
by its driver. However, if the driver decides to add a new supplier link
during ->probe(), hence updating the list of suppliers, the following call
to pm_runtime_put_suppliers(), invoked after really_probe() in the driver
core, we get into trouble.

More precisely, pm_runtime_put() gets called also for the new supplier(s),
which is wrong as the driver core, didn't trigger pm_runtime_get_sync() to
be called for it in the first place. In other words, the new supplier may
be runtime suspended even in cases when it shouldn't.

Fix this behaviour, by runtime resume suppliers according to the same
conditions as managed by the runtime PM core, when runtime resume callbacks
are being invoked.

Additionally, don't try to runtime suspend any of the suppliers after
really_probe(), but instead rely on that to happen via the consumer device,
when it becomes runtime suspended.

Fixes: 4c7e7b6bd1f7 (PM / runtime: Use device links)
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/base/dd.c
drivers/base/power/runtime.c
include/linux/pm_runtime.h