linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] cpuidle: dt: Return the correct numbers of parsed idle states
@ 2022-10-21 15:10 Ulf Hansson
  2022-10-21 15:10 ` [PATCH 2/2] cpuidle: dt: Clarify a comment and simplify code in dt_init_idle_driver() Ulf Hansson
  2022-10-25 11:43 ` [PATCH 1/2] cpuidle: dt: Return the correct numbers of parsed idle states Sudeep Holla
  0 siblings, 2 replies; 5+ messages in thread
From: Ulf Hansson @ 2022-10-21 15:10 UTC (permalink / raw)
  To: Rafael J . Wysocki, Daniel Lezcano, linux-pm
  Cc: Sudeep Holla, Lorenzo Pieralisi, Catalin Marinas, Ulf Hansson,
	linux-arm-kernel, linux-kernel

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(-)

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);
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/2] cpuidle: dt: Clarify a comment and simplify code in dt_init_idle_driver()
  2022-10-21 15:10 [PATCH 1/2] cpuidle: dt: Return the correct numbers of parsed idle states Ulf Hansson
@ 2022-10-21 15:10 ` Ulf Hansson
  2022-10-25 11:43   ` Sudeep Holla
  2022-10-25 11:43 ` [PATCH 1/2] cpuidle: dt: Return the correct numbers of parsed idle states Sudeep Holla
  1 sibling, 1 reply; 5+ messages in thread
From: Ulf Hansson @ 2022-10-21 15:10 UTC (permalink / raw)
  To: Rafael J . Wysocki, Daniel Lezcano, linux-pm
  Cc: Sudeep Holla, Lorenzo Pieralisi, Catalin Marinas, Ulf Hansson,
	linux-arm-kernel, linux-kernel

The drv->state_count is assigned the total number of available states, so
let's make that clear.

Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
---
 drivers/cpuidle/dt_idle_states.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/cpuidle/dt_idle_states.c b/drivers/cpuidle/dt_idle_states.c
index 448bc796b0b4..7ca3d7d9b5ea 100644
--- a/drivers/cpuidle/dt_idle_states.c
+++ b/drivers/cpuidle/dt_idle_states.c
@@ -211,12 +211,9 @@ int dt_init_idle_driver(struct cpuidle_driver *drv,
 	of_node_put(cpu_node);
 	if (err)
 		return err;
-	/*
-	 * Update the driver state count only if some valid DT idle states
-	 * were detected
-	 */
-	if (i)
-		drv->state_count = state_idx;
+
+	/* Set the number of total supported idle states. */
+	drv->state_count = state_idx;
 
 	/*
 	 * Return the number of present and valid DT idle states, which can
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/2] cpuidle: dt: Return the correct numbers of parsed idle states
  2022-10-21 15:10 [PATCH 1/2] cpuidle: dt: Return the correct numbers of parsed idle states Ulf Hansson
  2022-10-21 15:10 ` [PATCH 2/2] cpuidle: dt: Clarify a comment and simplify code in dt_init_idle_driver() Ulf Hansson
@ 2022-10-25 11:43 ` Sudeep Holla
  2022-10-28 18:10   ` Rafael J. Wysocki
  1 sibling, 1 reply; 5+ messages in thread
From: Sudeep Holla @ 2022-10-25 11:43 UTC (permalink / raw)
  To: Ulf Hansson
  Cc: Rafael J . Wysocki, Daniel Lezcano, linux-pm, Lorenzo Pieralisi,
	Catalin Marinas, linux-arm-kernel, linux-kernel

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>

-- 
Regards,
Sudeep

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/2] cpuidle: dt: Clarify a comment and simplify code in dt_init_idle_driver()
  2022-10-21 15:10 ` [PATCH 2/2] cpuidle: dt: Clarify a comment and simplify code in dt_init_idle_driver() Ulf Hansson
@ 2022-10-25 11:43   ` Sudeep Holla
  0 siblings, 0 replies; 5+ messages in thread
From: Sudeep Holla @ 2022-10-25 11:43 UTC (permalink / raw)
  To: Ulf Hansson
  Cc: Rafael J . Wysocki, Daniel Lezcano, linux-pm, Lorenzo Pieralisi,
	Catalin Marinas, linux-arm-kernel, linux-kernel

On Fri, Oct 21, 2022 at 05:10:13PM +0200, Ulf Hansson wrote:
> The drv->state_count is assigned the total number of available states, so
> let's make that clear.
> 

Reviewed-by: Sudeep Holla <sudeep.holla@arm.com>

-- 
Regards,
Sudeep

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/2] cpuidle: dt: Return the correct numbers of parsed idle states
  2022-10-25 11:43 ` [PATCH 1/2] cpuidle: dt: Return the correct numbers of parsed idle states Sudeep Holla
@ 2022-10-28 18:10   ` Rafael J. Wysocki
  0 siblings, 0 replies; 5+ messages in thread
From: Rafael J. Wysocki @ 2022-10-28 18:10 UTC (permalink / raw)
  To: Sudeep Holla, Ulf Hansson
  Cc: Daniel Lezcano, linux-pm, Lorenzo Pieralisi, Catalin Marinas,
	linux-arm-kernel, linux-kernel

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!

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-10-28 18:10 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-21 15:10 [PATCH 1/2] cpuidle: dt: Return the correct numbers of parsed idle states Ulf Hansson
2022-10-21 15:10 ` [PATCH 2/2] cpuidle: dt: Clarify a comment and simplify code in dt_init_idle_driver() Ulf Hansson
2022-10-25 11:43   ` Sudeep Holla
2022-10-25 11:43 ` [PATCH 1/2] cpuidle: dt: Return the correct numbers of parsed idle states Sudeep Holla
2022-10-28 18:10   ` Rafael J. Wysocki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).