UPSTREAM: PM / Domains: Fix potential deadlock while adding/removing subdomains
authorUlf Hansson <ulf.hansson@linaro.org>
Wed, 27 Jan 2016 08:10:37 +0000 (09:10 +0100)
committerHuang, Tao <huangtao@rock-chips.com>
Fri, 1 Jul 2016 11:38:51 +0000 (19:38 +0800)
commit1771adf9a9bc52468c8ec1f459ba251e02254730
treed63c88db69eb11bc729097fdcd998c64c69863e2
parent5655ffbda224a0f85b597a3f95faed7436136384
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.

Change-Id: I7f56875b7620eee6247efecd502a3ada4bfa4e24
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Caesar Wang <wxt@rock-chips.com>
(cherry picked from commit cdb300a041f5df1dfbde1367f95109b6449d1371)
drivers/base/power/domain.c