diff mbox series

[1/2] cpuidle: dt: Return the correct numbers of parsed idle states

Message ID 20221021151013.148457-1-ulf.hansson@linaro.org (mailing list archive)
State New, archived
Headers show
Series [1/2] cpuidle: dt: Return the correct numbers of parsed idle states | expand

Commit Message

Ulf Hansson Oct. 21, 2022, 3:10 p.m. UTC
While we correctly skips to initialize an idle state from a disabled idle
state node in DT, the returned value from dt_init_idle_driver() don't get
adjusted accordingly. Instead the number of found idle state nodes are
returned, while the callers are expecting the number of successfully
initialized idle states from DT.

This leads to cpuidle drivers unnecessarily continues to initialize their
idle state specific data. Moreover, in the case when all idle states have
been disabled in DT, we would end up registering a cpuidle driver, rather
than relying on the default arch specific idle call.

Fixes: 9f14da345599 ("drivers: cpuidle: implement DT based idle states infrastructure")
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
---
 drivers/cpuidle/dt_idle_states.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Sudeep Holla Oct. 25, 2022, 11:43 a.m. UTC | #1
On Fri, Oct 21, 2022 at 05:10:12PM +0200, Ulf Hansson wrote:
> While we correctly skips to initialize an idle state from a disabled idle
> state node in DT, the returned value from dt_init_idle_driver() don't get
> adjusted accordingly. Instead the number of found idle state nodes are
> returned, while the callers are expecting the number of successfully
> initialized idle states from DT.
> 
> This leads to cpuidle drivers unnecessarily continues to initialize their
> idle state specific data. Moreover, in the case when all idle states have
> been disabled in DT, we would end up registering a cpuidle driver, rather
> than relying on the default arch specific idle call.
>

Makes sense.

Reviewed-by: Sudeep Holla <sudeep.holla@arm.com>
Rafael J. Wysocki Oct. 28, 2022, 6:10 p.m. UTC | #2
On Tue, Oct 25, 2022 at 1:43 PM Sudeep Holla <sudeep.holla@arm.com> wrote:
>
> On Fri, Oct 21, 2022 at 05:10:12PM +0200, Ulf Hansson wrote:
> > While we correctly skips to initialize an idle state from a disabled idle
> > state node in DT, the returned value from dt_init_idle_driver() don't get
> > adjusted accordingly. Instead the number of found idle state nodes are
> > returned, while the callers are expecting the number of successfully
> > initialized idle states from DT.
> >
> > This leads to cpuidle drivers unnecessarily continues to initialize their
> > idle state specific data. Moreover, in the case when all idle states have
> > been disabled in DT, we would end up registering a cpuidle driver, rather
> > than relying on the default arch specific idle call.
> >
>
> Makes sense.
>
> Reviewed-by: Sudeep Holla <sudeep.holla@arm.com>

Applied along with the [2/2] as 6.2 material, thanks!
diff mbox series

Patch

diff --git a/drivers/cpuidle/dt_idle_states.c b/drivers/cpuidle/dt_idle_states.c
index 252f2a9686a6..448bc796b0b4 100644
--- a/drivers/cpuidle/dt_idle_states.c
+++ b/drivers/cpuidle/dt_idle_states.c
@@ -223,6 +223,6 @@  int dt_init_idle_driver(struct cpuidle_driver *drv,
 	 * also be 0 on platforms with missing DT idle states or legacy DT
 	 * configuration predating the DT idle states bindings.
 	 */
-	return i;
+	return state_idx - start_idx;
 }
 EXPORT_SYMBOL_GPL(dt_init_idle_driver);