UPSTREAM: PM / Domains: Fix potential deadlock while adding/removing subdomains

We must preserve the same order of how we acquire and release the lock for
genpd, as otherwise we may encounter deadlocks.

The power on phase of a genpd starts by acquiring its lock. Then it walks
the hierarchy of its parent domains to be able to power on these first, as
per design of genpd.

From a locking perspective this means the locks of the parents becomes
acquired after the lock of the subdomain.

Let's fix pm_genpd_add|remove_subdomain() to maintain the same order of
acquiring/releasing the genpd lock as being applied in the power on/off
sequence.

BUG=chrome-os-partner:54521
TEST=Built and boot and see no deadlocks; note that from the description
this is needed to fix bugs introduced by
CL:I17952f3fbf9a519b30068553638070fe683ee2c3 though there is no Fixes
tag upstream).

Change-Id: I17952f3fbf9a519b30068553638070fe683ee2c3
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Douglas Anderson <dianders@chromium.org>
(cherry picked from commit cdb300a041f5df1dfbde1367f95109b6449d1371)
Reviewed-on: https://chromium-review.googlesource.com/357861
Commit-Ready: Caesar Wang <wxt@rock-chips.com>
Reviewed-by: Dmitry Torokhov <dtor@chromium.org>
1 file changed