diff options
author | Rafael J. Wysocki <rjw@sisk.pl> | 2011-08-08 17:43:22 -0400 |
---|---|---|
committer | Rafael J. Wysocki <rjw@sisk.pl> | 2011-08-25 09:33:44 -0400 |
commit | 9e08cf429697090d0fac57d493dc7b6de17a5eee (patch) | |
tree | 70b18a96a5510bdec9bd35307bbf9d3b3e57981d /drivers/base | |
parent | 3c07cbc488bfd1ad1abf64d09cc692339b5f8a83 (diff) |
PM / Domains: Make pm_genpd_poweron() always survive parent removal
If pm_genpd_remove_subdomain() is called to remove a PM domain's
subdomain and pm_genpd_poweron() is called for that subdomain at
the same time, and the pm_genpd_poweron() called by it recursively
for the parent returns an error, the first pm_genpd_poweron()'s
error code path will attempt to decrement the subdomain counter of
a PM domain that it's not a subdomain of any more.
Rearrange the code in pm_genpd_poweron() to prevent this from
happening.
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Diffstat (limited to 'drivers/base')
-rw-r--r-- | drivers/base/power/domain.c | 33 |
1 files changed, 20 insertions, 13 deletions
diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index ef25b6f99f99..dc423a99c67c 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c | |||
@@ -89,12 +89,14 @@ static void genpd_set_active(struct generic_pm_domain *genpd) | |||
89 | */ | 89 | */ |
90 | int pm_genpd_poweron(struct generic_pm_domain *genpd) | 90 | int pm_genpd_poweron(struct generic_pm_domain *genpd) |
91 | { | 91 | { |
92 | struct generic_pm_domain *parent = genpd->parent; | 92 | struct generic_pm_domain *parent; |
93 | int ret = 0; | 93 | int ret = 0; |
94 | 94 | ||
95 | start: | ||
96 | mutex_lock(&genpd->lock); | 95 | mutex_lock(&genpd->lock); |
97 | 96 | ||
97 | parent = genpd->parent; | ||
98 | |||
99 | start: | ||
98 | if (genpd->status == GPD_STATE_ACTIVE | 100 | if (genpd->status == GPD_STATE_ACTIVE |
99 | || (genpd->prepared_count > 0 && genpd->suspend_power_off)) | 101 | || (genpd->prepared_count > 0 && genpd->suspend_power_off)) |
100 | goto out; | 102 | goto out; |
@@ -110,29 +112,34 @@ int pm_genpd_poweron(struct generic_pm_domain *genpd) | |||
110 | mutex_unlock(&genpd->lock); | 112 | mutex_unlock(&genpd->lock); |
111 | 113 | ||
112 | ret = pm_genpd_poweron(parent); | 114 | ret = pm_genpd_poweron(parent); |
113 | if (ret) { | 115 | |
114 | genpd_sd_counter_dec(parent); | 116 | mutex_lock(&genpd->lock); |
115 | return ret; | 117 | |
116 | } | 118 | if (ret) |
119 | goto err; | ||
117 | 120 | ||
118 | parent = NULL; | 121 | parent = NULL; |
119 | goto start; | 122 | goto start; |
120 | } | 123 | } |
121 | 124 | ||
122 | if (genpd->power_on) | 125 | if (genpd->power_on) { |
123 | ret = genpd->power_on(genpd); | 126 | ret = genpd->power_on(genpd); |
124 | 127 | if (ret) | |
125 | if (ret) { | 128 | goto err; |
126 | if (genpd->parent) | ||
127 | genpd_sd_counter_dec(genpd->parent); | ||
128 | } else { | ||
129 | genpd_set_active(genpd); | ||
130 | } | 129 | } |
131 | 130 | ||
131 | genpd_set_active(genpd); | ||
132 | |||
132 | out: | 133 | out: |
133 | mutex_unlock(&genpd->lock); | 134 | mutex_unlock(&genpd->lock); |
134 | 135 | ||
135 | return ret; | 136 | return ret; |
137 | |||
138 | err: | ||
139 | if (genpd->parent) | ||
140 | genpd_sd_counter_dec(genpd->parent); | ||
141 | |||
142 | goto out; | ||
136 | } | 143 | } |
137 | 144 | ||
138 | #endif /* CONFIG_PM */ | 145 | #endif /* CONFIG_PM */ |