linux-stable/drivers/base/power
Tony Lindgren 182f1f72af PM: runtime: Fix unpaired parent child_count for force_resume
commit c745253e2a upstream.

As pm_runtime_need_not_resume() relies also on usage_count, it can return
a different value in pm_runtime_force_suspend() compared to when called in
pm_runtime_force_resume(). Different return values can happen if anything
calls PM runtime functions in between, and causes the parent child_count
to increase on every resume.

So far I've seen the issue only for omapdrm that does complicated things
with PM runtime calls during system suspend for legacy reasons:

omap_atomic_commit_tail() for omapdrm.0
 dispc_runtime_get()
  wakes up 58000000.dss as it's the dispc parent
   dispc_runtime_resume()
    rpm_resume() increases parent child_count
 dispc_runtime_put() won't idle, PM runtime suspend blocked
pm_runtime_force_suspend() for 58000000.dss, !pm_runtime_need_not_resume()
 __update_runtime_status()
system suspended
pm_runtime_force_resume() for 58000000.dss, pm_runtime_need_not_resume()
 pm_runtime_enable() only called because of pm_runtime_need_not_resume()
omap_atomic_commit_tail() for omapdrm.0
 dispc_runtime_get()
  wakes up 58000000.dss as it's the dispc parent
   dispc_runtime_resume()
    rpm_resume() increases parent child_count
 dispc_runtime_put() won't idle, PM runtime suspend blocked
...
rpm_suspend for 58000000.dss but parent child_count is now unbalanced

Let's fix the issue by adding a flag for needs_force_resume and use it in
pm_runtime_force_resume() instead of pm_runtime_need_not_resume().

Additionally omapdrm system suspend could be simplified later on to avoid
lots of unnecessary PM runtime calls and the complexity it adds. The
driver can just use internal functions that are shared between the PM
runtime and system suspend related functions.

Fixes: 4918e1f87c ("PM / runtime: Rework pm_runtime_force_suspend/resume()")
Signed-off-by: Tony Lindgren <tony@atomide.com>
Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org>
Tested-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Cc: 4.16+ <stable@vger.kernel.org> # 4.16+
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-05-19 10:12:51 +02:00
..
clock_ops.c PM / clk: Remove error message on out-of-memory condition 2019-05-28 19:40:21 +02:00
common.c PM / Domains: Introduce dev_pm_domain_start() 2019-11-13 11:41:50 +01:00
domain.c PM: domains: Fix build error for genpd notifiers 2020-10-20 19:40:54 +02:00
domain_governor.c PM: domains: Fix up terminology with parent/child 2020-07-09 14:24:00 +02:00
generic_ops.c drivers: base: power: add proper SPDX identifiers on files that did not have them. 2019-04-04 20:03:40 +02:00
main.c PM: sleep: remove unreachable break 2020-10-22 18:43:31 +02:00
Makefile PM / QoS: Initial kunit test 2019-11-29 12:04:49 +01:00
power.h drivers/base/power: add dpm_sysfs_change_owner() 2020-02-26 20:07:25 -08:00
qos-test.c kunit: allow kunit tests to be loaded as a module 2020-01-09 16:42:29 -07:00
qos.c PM / QoS: Restore DEV_PM_QOS_MIN/MAX_FREQUENCY 2019-11-29 12:04:50 +01:00
runtime.c PM: runtime: Fix unpaired parent child_count for force_resume 2021-05-19 10:12:51 +02:00
sysfs.c drivers core: Miscellaneous changes for sysfs_emit 2020-10-02 13:12:07 +02:00
trace.c PM: sleep: core: mark 2 functions as __init to save some memory 2020-06-23 17:35:33 +02:00
wakeirq.c PM / wakeirq: remove unnecessary parentheses 2019-11-13 11:31:08 +01:00
wakeup.c PM: sleep: wakeup: Skip wakeup_source_sysfs_remove() if device is not there 2020-03-25 11:15:55 +01:00
wakeup_stats.c drivers core: Miscellaneous changes for sysfs_emit 2020-10-02 13:12:07 +02:00