diff mbox series

[v2,2/2] cpuidle: riscv-sbi: Add cpuidle_disabled() check

Message ID 20240814054434.3563453-3-nick.hu@sifive.com (mailing list archive)
State New
Headers show
Series cpuidle: riscv-sbi: Allow cpuidle pd used by other devices | expand

Checks

Context Check Description
conchuod/vmtest-for-next-PR success PR summary
conchuod/patch-2-test-1 success .github/scripts/patches/tests/build_rv32_defconfig.sh
conchuod/patch-2-test-2 success .github/scripts/patches/tests/build_rv64_clang_allmodconfig.sh
conchuod/patch-2-test-3 success .github/scripts/patches/tests/build_rv64_gcc_allmodconfig.sh
conchuod/patch-2-test-4 success .github/scripts/patches/tests/build_rv64_nommu_k210_defconfig.sh
conchuod/patch-2-test-5 success .github/scripts/patches/tests/build_rv64_nommu_virt_defconfig.sh
conchuod/patch-2-test-6 success .github/scripts/patches/tests/checkpatch.sh
conchuod/patch-2-test-7 success .github/scripts/patches/tests/dtb_warn_rv64.sh
conchuod/patch-2-test-8 success .github/scripts/patches/tests/header_inline.sh
conchuod/patch-2-test-9 success .github/scripts/patches/tests/kdoc.sh
conchuod/patch-2-test-10 success .github/scripts/patches/tests/module_param.sh
conchuod/patch-2-test-11 success .github/scripts/patches/tests/verify_fixes.sh
conchuod/patch-2-test-12 success .github/scripts/patches/tests/verify_signedoff.sh

Commit Message

Nick Hu Aug. 14, 2024, 5:44 a.m. UTC
The consumer devices that inside the cpu/cluster power domain may register
the genpd notifier where their power domains point to the pd nodes under
'/cpus/power-domains'. If the cpuidle.off==1, the genpd notifier will fail
due to sbi_cpuidle_pd_allow_domain_state is not set. We also need the
sbi_cpuidle_cpuhp_up/down to invoke the callbacks. Therefore adding a
cpuidle_disabled() check before cpuidle_register() to address the issue.

Signed-off-by: Nick Hu <nick.hu@sifive.com>
---
 drivers/cpuidle/cpuidle-riscv-sbi.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

Comments

Anup Patel Aug. 23, 2024, 7:09 a.m. UTC | #1
On Wed, Aug 14, 2024 at 11:14 AM Nick Hu <nick.hu@sifive.com> wrote:
>
> The consumer devices that inside the cpu/cluster power domain may register
> the genpd notifier where their power domains point to the pd nodes under
> '/cpus/power-domains'. If the cpuidle.off==1, the genpd notifier will fail
> due to sbi_cpuidle_pd_allow_domain_state is not set. We also need the
> sbi_cpuidle_cpuhp_up/down to invoke the callbacks. Therefore adding a
> cpuidle_disabled() check before cpuidle_register() to address the issue.
>
> Signed-off-by: Nick Hu <nick.hu@sifive.com>

LGTM.

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

Regards,
Anup

> ---
>  drivers/cpuidle/cpuidle-riscv-sbi.c | 9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/cpuidle/cpuidle-riscv-sbi.c b/drivers/cpuidle/cpuidle-riscv-sbi.c
> index 98e7751dbfe8..3c8a509288f3 100644
> --- a/drivers/cpuidle/cpuidle-riscv-sbi.c
> +++ b/drivers/cpuidle/cpuidle-riscv-sbi.c
> @@ -25,6 +25,7 @@
>  #include <asm/smp.h>
>  #include <asm/suspend.h>
>
> +#include "cpuidle.h"
>  #include "dt_idle_states.h"
>  #include "dt_idle_genpd.h"
>
> @@ -336,6 +337,9 @@ static int sbi_cpuidle_init_cpu(struct device *dev, int cpu)
>                 return ret;
>         }
>
> +       if (cpuidle_disabled())
> +               return 0;
> +
>         ret = cpuidle_register(drv, NULL);
>         if (ret)
>                 goto deinit;
> @@ -548,7 +552,10 @@ static int sbi_cpuidle_probe(struct platform_device *pdev)
>         /* Setup CPU hotplut notifiers */
>         sbi_idle_init_cpuhp();
>
> -       pr_info("idle driver registered for all CPUs\n");
> +       if (cpuidle_disabled())
> +               pr_info("cpuidle is disabled\n");
> +       else
> +               pr_info("idle driver registered for all CPUs\n");
>
>         return 0;
>
> --
> 2.34.1
>
diff mbox series

Patch

diff --git a/drivers/cpuidle/cpuidle-riscv-sbi.c b/drivers/cpuidle/cpuidle-riscv-sbi.c
index 98e7751dbfe8..3c8a509288f3 100644
--- a/drivers/cpuidle/cpuidle-riscv-sbi.c
+++ b/drivers/cpuidle/cpuidle-riscv-sbi.c
@@ -25,6 +25,7 @@ 
 #include <asm/smp.h>
 #include <asm/suspend.h>
 
+#include "cpuidle.h"
 #include "dt_idle_states.h"
 #include "dt_idle_genpd.h"
 
@@ -336,6 +337,9 @@  static int sbi_cpuidle_init_cpu(struct device *dev, int cpu)
 		return ret;
 	}
 
+	if (cpuidle_disabled())
+		return 0;
+
 	ret = cpuidle_register(drv, NULL);
 	if (ret)
 		goto deinit;
@@ -548,7 +552,10 @@  static int sbi_cpuidle_probe(struct platform_device *pdev)
 	/* Setup CPU hotplut notifiers */
 	sbi_idle_init_cpuhp();
 
-	pr_info("idle driver registered for all CPUs\n");
+	if (cpuidle_disabled())
+		pr_info("cpuidle is disabled\n");
+	else
+		pr_info("idle driver registered for all CPUs\n");
 
 	return 0;