PM: domains: Prevent power off for parent unless child is in deepest state
Subsystems (4)
PATCH v2 1/1 PM: domains: Prevent power off for parent unless child is in deepest state
A PM domain managed by genpd may support multiple idlestates. 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.
So far, we have not received any reports about errors from the current behaviour. However, there is an STMicro platform that is being worked on, which can't cope with this. Therefore, let's change genpd to prevent the parent- domain from being powered off, unless the deepest idlestate has been selected for the child-domain.
---
Changes in v2:
- Clarified the commit message
--- drivers/base/power/domain.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
drivers/base/power/domain.c +18 -0
@@ -636,6 +636,17 @@ static int genpd_power_off(struct generic_pm_domain *genpd, bool one_dev_on, atomic_read(&genpd->sd_count) > 0)return -EBUSY ; +/* +* The children must be in their deepest states to allow the parent to +* be powered off. Note that, there's no need for additional locking, as +* powering on a child, requires the parent's lock to be acquired first. +*/ +list_for_each_entry (link, &genpd->parent_links, parent_node) { +struct generic_pm_domain *child = link->child; +if (child->state_idx < child->state_count -1 ) +return -EBUSY ; + } +list_for_each_entry (pdd, &genpd->dev_list, list_node) {enum pm_qos_flags_status stat;
@@ -1073,6 +1084,13 @@ static void genpd_sync_power_off(struct generic_pm_domain *genpd, bool use_lock, || atomic_read(&genpd->sd_count) > 0)return ; +/* Check that the children are in their deepest state. */ +list_for_each_entry (link, &genpd->parent_links, parent_node) { +struct generic_pm_domain *child = link->child; +if (child->state_idx < child->state_count -1 ) +return ; + } +/* Choose the deepest state when suspending */ genpd->state_idx = genpd->state_count -1 ;if (_genpd_power_off (genpd, false))
Signature · 1 line
2.25.1
04.02.2022 13:16, Ulf Hansson пишет:
Quoted 11 lines
A PM domain managed by genpd may support multiple idlestates. 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.
So far, we have not received any reports about errors from the current behaviour. However, there is an STMicro platform that is being worked on, which can't cope with this.
Could you please provide some technical info about why STMicro platform can't cope with that?
Quoted 10 lines · Dmitry Osipenko
04.02.2022 13:16, Ulf Hansson пишет:
Quoted 8 lines
A PM domain managed by genpd may support multiple idlestates. 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.
Quoted 6 lines
Quoted 3 lines
So far, we have not received any reports about errors from the current behaviour. However, there is an STMicro platform that is being worked on, which can't cope with this.
Could you please provide some technical info about why STMicro platform can't cope with that?
There is a parent domain with one power-off state. The parent domain has a few devices attached to it, which means they need to be managed to together. The parent domain is controlling a shared power rail.
The child domain, which has multiple idle states to choose from, also has some devices attached to it. The child domain is controlling a system clock, but also relies on the shared power rail that is managed by the parent domain.
Obviously, these idle states are managed by firmware.
I hope that made it a bit more clear?
Kind regards
Uffe
16.02.2022 12:45, Ulf Hansson пишет:
Quoted 22 lines · Dmitry Osipenko
Quoted 10 lines
04.02.2022 13:16, Ulf Hansson пишет:
Quoted 8 lines
A PM domain managed by genpd may support multiple idlestates. 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.
Quoted 6 lines
Quoted 3 lines
So far, we have not received any reports about errors from the current behaviour. However, there is an STMicro platform that is being worked on, which can't cope with this.
Could you please provide some technical info about why STMicro platform can't cope with that?
There is a parent domain with one power-off state. The parent domain has a few devices attached to it, which means they need to be managed to together. The parent domain is controlling a shared power rail.
Quoted 8 lines
The child domain, which has multiple idle states to choose from, also has some devices attached to it. The child domain is controlling a system clock, but also relies on the shared power rail that is managed by the parent domain.
Obviously, these idle states are managed by firmware.
I hope that made it a bit more clear?
Yes, I see now what this patch does.
So "deepest state" in the code's comment means powered off state. Maybe the comment could clarify it better a tad.
- * The children must be in their deepest states to allow the parent to
+ * The children must be in their deepest (powered-off) states to allow the parent to