Commit 8b55e55e authored by Krzysztof Kozlowski's avatar Krzysztof Kozlowski Committed by Rafael J. Wysocki

PM / Domains: Handle safely genpd_syscore_switch() call on non-genpd device

genpd_syscore_switch() had two problems:
 1. It silently assumed that device, it is being called for, belongs
    to generic power domain and used container_of() on its power
    domain pointer.  Such assumption might not be true always.

2. It iterated over list of generic power domains without holding
   gpd_list_lock mutex thus list could have been modified at the same
   time.

Usage of genpd_lookup_dev() solves both problems as it is safe a call
for non-generic power domains and uses mutex when iterating.
Reported-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
Signed-off-by: default avatarKrzysztof Kozlowski <krzk@kernel.org>
Acked-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
parent 10da6542
......@@ -1148,8 +1148,8 @@ static void genpd_syscore_switch(struct device *dev, bool suspend)
{
struct generic_pm_domain *genpd;
genpd = dev_to_genpd(dev);
if (!pm_genpd_present(genpd))
genpd = genpd_lookup_dev(dev);
if (!genpd)
return;
if (suspend) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment