linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 2/2] cpuidle: riscv-sbi: Fix code to allow a genpd governor to be used
@ 2022-05-14 15:20 Ulf Hansson
  2022-05-14 16:47 ` Anup Patel
  0 siblings, 1 reply; 2+ messages in thread
From: Ulf Hansson @ 2022-05-14 15:20 UTC (permalink / raw)
  To: Rafael J . Wysocki, Anup Patel, linux-pm
  Cc: Sudeep Holla, Lorenzo Pieralisi, Maulik Shah, Daniel Lezcano,
	Paul Walmsley, Palmer Dabbelt, Albert Ou, Atish Patra,
	Ulf Hansson, linux-arm-kernel, linux-riscv, linux-kernel

The intent is to use a genpd governor when there are some states that needs
to be managed. Although, the current code ends up to never assign a
governor, let's fix this.

Fixes: 6abf32f1d9c50 ("cpuidle: Add RISC-V SBI CPU idle driver")
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
---
 drivers/cpuidle/cpuidle-riscv-sbi.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/cpuidle/cpuidle-riscv-sbi.c b/drivers/cpuidle/cpuidle-riscv-sbi.c
index b459eda2cd37..478970fa3b0c 100644
--- a/drivers/cpuidle/cpuidle-riscv-sbi.c
+++ b/drivers/cpuidle/cpuidle-riscv-sbi.c
@@ -413,7 +413,7 @@ static int sbi_pd_init(struct device_node *np)
 	struct generic_pm_domain *pd;
 	struct sbi_pd_provider *pd_provider;
 	struct dev_power_governor *pd_gov;
-	int ret = -ENOMEM, state_count = 0;
+	int ret = -ENOMEM;
 
 	pd = dt_idle_pd_alloc(np, sbi_dt_parse_state_node);
 	if (!pd)
@@ -432,7 +432,7 @@ static int sbi_pd_init(struct device_node *np)
 		pd->flags |= GENPD_FLAG_ALWAYS_ON;
 
 	/* Use governor for CPU PM domains if it has some states to manage. */
-	pd_gov = state_count > 0 ? &pm_domain_cpu_gov : NULL;
+	pd_gov = pd->states ? &pm_domain_cpu_gov : NULL;
 
 	ret = pm_genpd_init(pd, pd_gov, false);
 	if (ret)
-- 
2.25.1


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

* Re: [PATCH 2/2] cpuidle: riscv-sbi: Fix code to allow a genpd governor to be used
  2022-05-14 15:20 [PATCH 2/2] cpuidle: riscv-sbi: Fix code to allow a genpd governor to be used Ulf Hansson
@ 2022-05-14 16:47 ` Anup Patel
  0 siblings, 0 replies; 2+ messages in thread
From: Anup Patel @ 2022-05-14 16:47 UTC (permalink / raw)
  To: Ulf Hansson
  Cc: Rafael J . Wysocki, open list:THERMAL, Sudeep Holla,
	Lorenzo Pieralisi, Maulik Shah, Daniel Lezcano, Paul Walmsley,
	Palmer Dabbelt, Albert Ou, Atish Patra, linux-arm-kernel,
	linux-riscv, linux-kernel@vger.kernel.org List

On Sat, May 14, 2022 at 8:50 PM Ulf Hansson <ulf.hansson@linaro.org> wrote:
>
> The intent is to use a genpd governor when there are some states that needs
> to be managed. Although, the current code ends up to never assign a
> governor, let's fix this.
>
> Fixes: 6abf32f1d9c50 ("cpuidle: Add RISC-V SBI CPU idle driver")
> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>

Looks good to me. I have tested this on QEMU RISC-V as well.

Reviewed-by: Anup Patel <anup@brainfault.org>
Tested-by: Anup Patel <anup@brainfault.org>

Thanks,
Anup

> ---
>  drivers/cpuidle/cpuidle-riscv-sbi.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/cpuidle/cpuidle-riscv-sbi.c b/drivers/cpuidle/cpuidle-riscv-sbi.c
> index b459eda2cd37..478970fa3b0c 100644
> --- a/drivers/cpuidle/cpuidle-riscv-sbi.c
> +++ b/drivers/cpuidle/cpuidle-riscv-sbi.c
> @@ -413,7 +413,7 @@ static int sbi_pd_init(struct device_node *np)
>         struct generic_pm_domain *pd;
>         struct sbi_pd_provider *pd_provider;
>         struct dev_power_governor *pd_gov;
> -       int ret = -ENOMEM, state_count = 0;
> +       int ret = -ENOMEM;
>
>         pd = dt_idle_pd_alloc(np, sbi_dt_parse_state_node);
>         if (!pd)
> @@ -432,7 +432,7 @@ static int sbi_pd_init(struct device_node *np)
>                 pd->flags |= GENPD_FLAG_ALWAYS_ON;
>
>         /* Use governor for CPU PM domains if it has some states to manage. */
> -       pd_gov = state_count > 0 ? &pm_domain_cpu_gov : NULL;
> +       pd_gov = pd->states ? &pm_domain_cpu_gov : NULL;
>
>         ret = pm_genpd_init(pd, pd_gov, false);
>         if (ret)
> --
> 2.25.1
>

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

end of thread, other threads:[~2022-05-14 16:47 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-14 15:20 [PATCH 2/2] cpuidle: riscv-sbi: Fix code to allow a genpd governor to be used Ulf Hansson
2022-05-14 16:47 ` Anup Patel

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