Skip to contentSkip to conversation

cpuidle: riscv-sbi: Allow cpuidle pd used by other devices

PATCH Applied Nick Hu 3 participants 7 messages Aug 14, 2024 – Oct 18, 2024

Subsystems (3)
lore
Share & tools
lore

Nick Hu

author
#0 lore raw

v2 cover cpuidle: riscv-sbi: Allow cpuidle pd used by other devices

Add this patchset so the devices that inside the cpu/cluster power domain can use the cpuidle pd to register the genpd notifier to handle the PM when cpu/cluster is going to enter a deeper sleep state.

Nick Hu (2):
cpuidle: riscv-sbi: Move sbi_cpuidle_init to arch_initcall
cpuidle: riscv-sbi: Add cpuidle_disabled() check

 drivers/cpuidle/cpuidle-riscv-sbi.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)
Signature · 1 line
2.34.1
author
#1 lore raw

PATCH v2 1/2 cpuidle: riscv-sbi: Move sbi_cpuidle_init to arch_initcall

Move the sbi_cpuidle_init to the arch_initcall to prevent the consumer devices from being deferred.

---
 drivers/cpuidle/cpuidle-riscv-sbi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/cpuidle/cpuidle-riscv-sbi.c +1 -1
index a6e123dfe394..98e7751dbfe8 100644
@@ -592,4 +592,4 @@ static int __init sbi_cpuidle_init(void)
 
 	return 0;
 }
-device_initcall(sbi_cpuidle_init);
+arch_initcall(sbi_cpuidle_init);
Signature · 1 line
2.34.1
maintainer Reviewed-by on v2 1/2
#2 lore raw

Re: [PATCH v2 1/2] cpuidle: riscv-sbi: Move sbi_cpuidle_init to arch_initcall

Quoted 7 lines · Nick Hu

Move the sbi_cpuidle_init to the arch_initcall to prevent the consumer devices from being deferred.

LGTM.

Regards,
Anup

Quoted 17 lines
---
 drivers/cpuidle/cpuidle-riscv-sbi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/cpuidle/cpuidle-riscv-sbi.c +1 -2
index a6e123dfe394..98e7751dbfe8 100644
@@ -592,4 +592,4 @@ static int __init sbi_cpuidle_init(void)
 
        return 0;
 }
-device_initcall(sbi_cpuidle_init);
+arch_initcall(sbi_cpuidle_init);
--

2.34.1

author
#3 lore raw

PATCH v2 2/2 cpuidle: riscv-sbi: Add cpuidle_disabled() check

In reply to Nick Hu

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.

---
 drivers/cpuidle/cpuidle-riscv-sbi.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/cpuidle/cpuidle-riscv-sbi.c +8 -1
index 98e7751dbfe8..3c8a509288f3 100644
@@ -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;
 
Signature · 1 line
2.34.1
maintainer Reviewed-by on v2 2/2
#4 lore raw

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

Quoted 9 lines · Nick Hu

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.

LGTM.

Regards,
Anup

Quoted 41 lines
---
 drivers/cpuidle/cpuidle-riscv-sbi.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/cpuidle/cpuidle-riscv-sbi.c +8 -2
index 98e7751dbfe8..3c8a509288f3 100644
@@ -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

author
#5 lore raw
In reply to Nick Hu

Hi Anup

Any suggestions on this one?

Quoted 9 lines · Nick Hu

Add this patchset so the devices that inside the cpu/cluster power domain can use the cpuidle pd to register the genpd notifier to handle the PM when cpu/cluster is going to enter a deeper sleep state.

Nick Hu (2):
cpuidle: riscv-sbi: Move sbi_cpuidle_init to arch_initcall
cpuidle: riscv-sbi: Add cpuidle_disabled() check

Quoted 6 lines
 drivers/cpuidle/cpuidle-riscv-sbi.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

--
2.34.1

Regards,
Nick

#6 lore raw
In reply to Nick Hu
This series was applied to riscv/linux.git (for-next) by Palmer Dabbelt <[email protected]>:

Hello:

This series was applied to riscv/linux.git (for-next) by Palmer Dabbelt <[email protected]>:

Quoted 9 lines · On Wed, 14 Aug 2024 13:44:32 +0800 you wrote:

Add this patchset so the devices that inside the cpu/cluster power domain can use the cpuidle pd to register the genpd notifier to handle the PM when cpu/cluster is going to enter a deeper sleep state.

Nick Hu (2):
cpuidle: riscv-sbi: Move sbi_cpuidle_init to arch_initcall
cpuidle: riscv-sbi: Add cpuidle_disabled() check

[...]

Here is the summary with links:
- [v2,1/2] cpuidle: riscv-sbi: Move sbi_cpuidle_init to arch_initcall

    https://git.kernel.org/riscv/c/f8a23e3b79d6
  - [v2,2/2] cpuidle: riscv-sbi: Add cpuidle_disabled() check
    https://git.kernel.org/riscv/c/27b4d6aa29ab

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html