]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
cpuidle: psci: Enable the hierarchical topology for s2ram on PREEMPT_RT
authorUlf Hansson <ulf.hansson@linaro.org>
Mon, 27 May 2024 14:25:56 +0000 (16:25 +0200)
committerUlf Hansson <ulf.hansson@linaro.org>
Mon, 5 Aug 2024 11:24:47 +0000 (13:24 +0200)
The hierarchical PM domain topology are currently disabled on a PREEMPT_RT
based configuration. As a first step to enable it to be used, let's try to
attach the CPU devices to their PM domains on PREEMPT_RT. In this way the
syscore ops becomes available, allowing the PM domain topology to be
managed during s2ram.

For the moment let's leave the support for CPU hotplug outside PREEMPT_RT,
as it's depending on using runtime PM. For s2ram, this isn't a problem as
all CPUs are managed via the syscore ops.

Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Tested-by: Raghavendra Kakarla <quic_rkakarla@quicinc.com> # qcm6490 with PREEMPT_RT set
Acked-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Link: https://lore.kernel.org/r/20240527142557.321610-7-ulf.hansson@linaro.org
drivers/cpuidle/cpuidle-psci.c

index d82a8bc1b1949b258918e0a6b4ceae4589790a66..ad6ce9fe12b445eb7720651e79629ab0a7b0335d 100644 (file)
@@ -37,6 +37,7 @@ struct psci_cpuidle_data {
 
 static DEFINE_PER_CPU_READ_MOSTLY(struct psci_cpuidle_data, psci_cpuidle_data);
 static DEFINE_PER_CPU(u32, domain_state);
+static bool psci_cpuidle_use_syscore;
 static bool psci_cpuidle_use_cpuhp;
 
 void psci_set_domain_state(u32 state)
@@ -166,6 +167,12 @@ static struct syscore_ops psci_idle_syscore_ops = {
        .resume = psci_idle_syscore_resume,
 };
 
+static void psci_idle_init_syscore(void)
+{
+       if (psci_cpuidle_use_syscore)
+               register_syscore_ops(&psci_idle_syscore_ops);
+}
+
 static void psci_idle_init_cpuhp(void)
 {
        int err;
@@ -173,8 +180,6 @@ static void psci_idle_init_cpuhp(void)
        if (!psci_cpuidle_use_cpuhp)
                return;
 
-       register_syscore_ops(&psci_idle_syscore_ops);
-
        err = cpuhp_setup_state_nocalls(CPUHP_AP_CPU_PM_STARTING,
                                        "cpuidle/psci:online",
                                        psci_idle_cpuhp_up,
@@ -222,13 +227,16 @@ static int psci_dt_cpu_init_topology(struct cpuidle_driver *drv,
        if (!psci_has_osi_support())
                return 0;
 
-       if (IS_ENABLED(CONFIG_PREEMPT_RT))
-               return 0;
-
        data->dev = dt_idle_attach_cpu(cpu, "psci");
        if (IS_ERR_OR_NULL(data->dev))
                return PTR_ERR_OR_ZERO(data->dev);
 
+       psci_cpuidle_use_syscore = true;
+
+       /* The hierarchical topology is limited to s2ram on PREEMPT_RT. */
+       if (IS_ENABLED(CONFIG_PREEMPT_RT))
+               return 0;
+
        /*
         * Using the deepest state for the CPU to trigger a potential selection
         * of a shared state for the domain, assumes the domain states are all
@@ -312,6 +320,7 @@ static void psci_cpu_deinit_idle(int cpu)
        struct psci_cpuidle_data *data = per_cpu_ptr(&psci_cpuidle_data, cpu);
 
        dt_idle_detach_cpu(data->dev);
+       psci_cpuidle_use_syscore = false;
        psci_cpuidle_use_cpuhp = false;
 }
 
@@ -408,6 +417,7 @@ static int psci_cpuidle_probe(struct platform_device *pdev)
                        goto out_fail;
        }
 
+       psci_idle_init_syscore();
        psci_idle_init_cpuhp();
        return 0;