Skip to content

Commit e7d90cf

Browse files
Ulf Hanssonrafaeljw
authored andcommitted
PM: domains: Prevent power off for parent unless child is in deepest state
A PM domain managed by genpd may support multiple idlestates (power-off states). During genpd_power_off() a genpd governor may be asked to select one of the idlestates based upon the dev PM QoS constraints, for example. However, there is a problem with the behaviour around this in genpd. More precisely, a parent-domain is allowed to be powered off, no matter of what idlestate that has been selected for the child-domain. For the stm32mp1 platform from STMicro, this behaviour doesn't play well. Instead, the parent-domain must not be powered off, unless the deepest idlestate has been selected for the child-domain. As the current behaviour in genpd is quite questionable anyway, let's simply change it into what is needed by the stm32mp1 platform. If it surprisingly turns out that other platforms may need a different behaviour from genpd, then we will have to revisit this to find a way to make it configurable. Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org> Reviewed-by: Dmitry Osipenko <digetx@gmail.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent 7e57714 commit e7d90cf

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

drivers/base/power/domain.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -636,6 +636,18 @@ static int genpd_power_off(struct generic_pm_domain *genpd, bool one_dev_on,
636636
atomic_read(&genpd->sd_count) > 0)
637637
return -EBUSY;
638638

639+
/*
640+
* The children must be in their deepest (powered-off) states to allow
641+
* the parent to be powered off. Note that, there's no need for
642+
* additional locking, as powering on a child, requires the parent's
643+
* lock to be acquired first.
644+
*/
645+
list_for_each_entry(link, &genpd->parent_links, parent_node) {
646+
struct generic_pm_domain *child = link->child;
647+
if (child->state_idx < child->state_count - 1)
648+
return -EBUSY;
649+
}
650+
639651
list_for_each_entry(pdd, &genpd->dev_list, list_node) {
640652
enum pm_qos_flags_status stat;
641653

@@ -1073,6 +1085,13 @@ static void genpd_sync_power_off(struct generic_pm_domain *genpd, bool use_lock,
10731085
|| atomic_read(&genpd->sd_count) > 0)
10741086
return;
10751087

1088+
/* Check that the children are in their deepest (powered-off) state. */
1089+
list_for_each_entry(link, &genpd->parent_links, parent_node) {
1090+
struct generic_pm_domain *child = link->child;
1091+
if (child->state_idx < child->state_count - 1)
1092+
return;
1093+
}
1094+
10761095
/* Choose the deepest state when suspending */
10771096
genpd->state_idx = genpd->state_count - 1;
10781097
if (_genpd_power_off(genpd, false))

0 commit comments

Comments
 (0)