pmdomain: core: Scale down parent/child performance states in reverse order
authorStephan Gerhold <stephan@gerhold.net>
Wed, 3 Jan 2024 21:10:05 +0000 (22:10 +0100)
committerUlf Hansson <ulf.hansson@linaro.org>
Wed, 14 Feb 2024 09:26:11 +0000 (10:26 +0100)
commit2b391c4ca735d0633bcdca5f83939c9791405225
treef1681294a549b3e47671c732608cfe87621129a6
parentb9401b65fb203dc7a3611394ce7af812e6033843
pmdomain: core: Scale down parent/child performance states in reverse order

Power domains might have parent domains assigned that are automatically
managed by the PM domain core. In particular, parent domains are
automatically powered on/off and setting performance states on child
domains are propagated to parent domains (e.g. using an OPP table from the
device tree).

Currently the parent performance state is always adjusted before the
performance state of the child domain, which is a problem for some cases
when scaling down the performance state. More exactly, it may lead to that
the parent domain could run in a lower performance state, than what is
required by the child domain.

To fix the behaviour, let's differentiate between scaling up/down and
adjust the order of operations:

 - When scaling up, parent domains should be adjusted before the child
   domain. In case of an error, the rollback happens in reverse order.

 - When scaling down, parent domains should be adjusted after the child
   domain, in reverse order, just as if we would rollback scaling up.
   In case of an error, the rollback happens in normal order (just as
   if we would normally scale up).

Signed-off-by: Stephan Gerhold <stephan@gerhold.net>
Link: https://lore.kernel.org/r/20240103-genpd-perf-order-v2-1-eeecfc55624b@gerhold.net
Tested-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
drivers/pmdomain/core.c