@@ -1342,18 +1342,27 @@ static void genpd_complete(struct device *dev)
static void genpd_syscore_switch(struct device *dev, bool suspend)
{
struct generic_pm_domain *genpd;
+ bool use_lock;
genpd = dev_to_genpd_safe(dev);
if (!genpd)
return;
+ use_lock = genpd_is_irq_safe(genpd);
+
+ if (use_lock)
+ genpd_lock(genpd);
+
if (suspend) {
genpd->suspended_count++;
- genpd_sync_power_off(genpd, false, 0);
+ genpd_sync_power_off(genpd, use_lock, 0);
} else {
- genpd_sync_power_on(genpd, false, 0);
+ genpd_sync_power_on(genpd, use_lock, 0);
genpd->suspended_count--;
}
+
+ if (use_lock)
+ genpd_unlock(genpd);
}
void pm_genpd_syscore_poweroff(struct device *dev)
The genpd lock is currently not being used, while suspending/resuming syscore devices through genpd. This because we need to avoid using a mutex when running in the syscore phase. However, the locking can be useful under special circumstances (as shown in subsequent changes) and for a genpd having the flag GENPD_FLAG_IRQ_SAFE set. Therefore, let's make use of the lock when it's possible. Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org> --- drivers/base/power/domain.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) -- 2.25.1