OSDN Git Service

PM-runtime: Take suppliers into account in __pm_runtime_set_status()
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>
Thu, 7 Feb 2019 18:38:56 +0000 (19:38 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 8 Feb 2019 10:26:14 +0000 (11:26 +0100)
commit4080ab083000a1e9656b0d1607e238e7001e0c84
treeeac34432ee6a46348a1a41bc277df934ef71aa19
parent79a4e91d1bb2a411a4ce2baa93680fa707567003
PM-runtime: Take suppliers into account in __pm_runtime_set_status()

If the target device has any suppliers, as reflected by device links
to them, __pm_runtime_set_status() does not take them into account,
which is not consistent with the other parts of the PM-runtime
framework and may lead to programming mistakes.

Modify __pm_runtime_set_status() to take suppliers into account by
activating them upfront if the new status is RPM_ACTIVE and
deactivating them on exit if the new status is RPM_SUSPENDED.

If the activation of one of the suppliers fails, the new status
will be RPM_SUSPENDED and the (remaining) suppliers will be
deactivated on exit (the child count of the device's parent
will be dropped too then).

Of course, adding device links locking to __pm_runtime_set_status()
means that it cannot be run fron interrupt context, so make it use
spin_lock_irq() and spin_unlock_irq() instead of spin_lock_irqsave()
and spin_unlock_irqrestore(), respectively.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/base/power/runtime.c