[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20250611031023.28769-3-nick.hu@sifive.com>
Date: Wed, 11 Jun 2025 11:10:21 +0800
From: Nick Hu <nick.hu@...ive.com>
To: conor+dt@...nel.org,
krzk+dt@...nel.org,
Alexandre Ghiti <alex@...ti.fr>,
linux-kernel@...r.kernel.org,
linux-pm@...r.kernel.org,
linux-riscv@...ts.infradead.org
Cc: Nick Hu <nick.hu@...ive.com>,
Samuel Holland <samuel.holland@...ive.com>,
Anup Patel <anup@...infault.org>,
"Rafael J. Wysocki" <rafael@...nel.org>,
Daniel Lezcano <daniel.lezcano@...aro.org>,
Paul Walmsley <paul.walmsley@...ive.com>,
Palmer Dabbelt <palmer@...belt.com>,
Albert Ou <aou@...s.berkeley.edu>
Subject: [PATCH v2 2/3] cpuidle: riscv-sbi: Work with the external pmdomain driver
To work with the external pmdomain driver, exposing the
`sbi_cpuidle_pd_power_off` and `sbi_dt_parse_state_node` so the external
pmdomain driver can parse the riscv idle state data and set the domain
idle state where powering off. In addition, defer the driver without
error message when the parent domain is not ready.
Co-developed-by: Samuel Holland <samuel.holland@...ive.com>
Signed-off-by: Samuel Holland <samuel.holland@...ive.com>
Signed-off-by: Nick Hu <nick.hu@...ive.com>
---
drivers/cpuidle/cpuidle-riscv-sbi.c | 17 +++++++++++------
drivers/cpuidle/cpuidle-riscv-sbi.h | 20 ++++++++++++++++++++
2 files changed, 31 insertions(+), 6 deletions(-)
create mode 100644 drivers/cpuidle/cpuidle-riscv-sbi.h
diff --git a/drivers/cpuidle/cpuidle-riscv-sbi.c b/drivers/cpuidle/cpuidle-riscv-sbi.c
index 0fe1ece9fbdc..d53254601522 100644
--- a/drivers/cpuidle/cpuidle-riscv-sbi.c
+++ b/drivers/cpuidle/cpuidle-riscv-sbi.c
@@ -27,6 +27,7 @@
#include <asm/suspend.h>
#include "cpuidle.h"
+#include "cpuidle-riscv-sbi.h"
#include "dt_idle_states.h"
#include "dt_idle_genpd.h"
@@ -188,7 +189,7 @@ static const struct of_device_id sbi_cpuidle_state_match[] = {
{ },
};
-static int sbi_dt_parse_state_node(struct device_node *np, u32 *state)
+int sbi_dt_parse_state_node(struct device_node *np, u32 *state)
{
int err = of_property_read_u32(np, "riscv,sbi-suspend-param", state);
@@ -325,8 +326,9 @@ static int sbi_cpuidle_init_cpu(struct device *dev, int cpu)
/* Initialize idle states from DT. */
ret = sbi_cpuidle_dt_init_states(dev, drv, cpu, state_count);
if (ret) {
- pr_err("HART%ld: failed to init idle states\n",
- cpuid_to_hartid_map(cpu));
+ if (ret != -EPROBE_DEFER)
+ pr_err("HART%ld: failed to init idle states\n",
+ cpuid_to_hartid_map(cpu));
return ret;
}
@@ -356,7 +358,7 @@ static void sbi_cpuidle_domain_sync_state(struct device *dev)
#ifdef CONFIG_DT_IDLE_GENPD
-static int sbi_cpuidle_pd_power_off(struct generic_pm_domain *pd)
+int sbi_cpuidle_pd_power_off(struct generic_pm_domain *pd)
{
struct genpd_power_state *state = &pd->states[pd->state_idx];
u32 *pd_state;
@@ -533,8 +535,11 @@ static int sbi_cpuidle_probe(struct platform_device *pdev)
for_each_present_cpu(cpu) {
ret = sbi_cpuidle_init_cpu(&pdev->dev, cpu);
if (ret) {
- pr_debug("HART%ld: idle driver init failed\n",
- cpuid_to_hartid_map(cpu));
+ if (ret == -EPROBE_DEFER)
+ pr_debug("idle driver probe deferred\n");
+ else
+ pr_debug("HART%ld: idle driver init failed\n",
+ cpuid_to_hartid_map(cpu));
goto out_fail;
}
}
diff --git a/drivers/cpuidle/cpuidle-riscv-sbi.h b/drivers/cpuidle/cpuidle-riscv-sbi.h
new file mode 100644
index 000000000000..f39186b65a10
--- /dev/null
+++ b/drivers/cpuidle/cpuidle-riscv-sbi.h
@@ -0,0 +1,20 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef __CPUIDLE_RISCV_SBI
+#define __CPUIDLE_RISCV_SBI
+
+#ifdef CONFIG_DT_IDLE_GENPD
+
+int sbi_cpuidle_pd_power_off(struct generic_pm_domain *pd);
+
+#else
+
+static inline int sbi_cpuidle_pd_power_off(struct generic_pm_domain *pd)
+{
+ return 0;
+}
+
+#endif
+
+int sbi_dt_parse_state_node(struct device_node *np, u32 *state);
+
+#endif
--
2.17.1
Powered by blists - more mailing lists