diff mbox series

[v2,1/2] firmware: psci: Extend psci_set_osi_mode() to allow reset to PC mode

Message ID 20200901121226.217568-2-ulf.hansson@linaro.org
State Superseded
Headers show
Series cpuidle: psci: Always create the PM domains | expand

Commit Message

Ulf Hansson Sept. 1, 2020, 12:12 p.m. UTC
The current user (cpuidle-psci) of psci_set_osi_mode() only needs to enable
the PSCI OSI mode. Although, as subsequent changes shows, there is a need
to be able to reset back into the PSCI PC mode.

Therefore, let's extend psci_set_osi_mode() to take a bool as in-parameter,
to let the user indicate whether to enable OSI or to switch back to PC
mode.

Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>

---
 drivers/cpuidle/cpuidle-psci-domain.c |  2 +-
 drivers/firmware/psci/psci.c          | 12 +++++++-----
 include/linux/psci.h                  |  2 +-
 3 files changed, 9 insertions(+), 7 deletions(-)

-- 
2.25.1

Comments

Sudeep Holla Sept. 1, 2020, 1:30 p.m. UTC | #1
On Tue, Sep 01, 2020 at 02:12:25PM +0200, Ulf Hansson wrote:
> The current user (cpuidle-psci) of psci_set_osi_mode() only needs to enable

> the PSCI OSI mode. Although, as subsequent changes shows, there is a need

> to be able to reset back into the PSCI PC mode.

>

> Therefore, let's extend psci_set_osi_mode() to take a bool as in-parameter,

> to let the user indicate whether to enable OSI or to switch back to PC

> mode.

>


Reviewed-by: Sudeep Holla <sudeep.holla@arm.com>


--
Regards,
Sudeep
diff mbox series

Patch

diff --git a/drivers/cpuidle/cpuidle-psci-domain.c b/drivers/cpuidle/cpuidle-psci-domain.c
index b6e9649ab0da..b6ab0415f450 100644
--- a/drivers/cpuidle/cpuidle-psci-domain.c
+++ b/drivers/cpuidle/cpuidle-psci-domain.c
@@ -278,7 +278,7 @@  static int psci_cpuidle_domain_probe(struct platform_device *pdev)
 		goto remove_pd;
 
 	/* Try to enable OSI mode. */
-	ret = psci_set_osi_mode();
+	ret = psci_set_osi_mode(true);
 	if (ret) {
 		pr_warn("failed to enable OSI mode: %d\n", ret);
 		psci_pd_remove_topology(np);
diff --git a/drivers/firmware/psci/psci.c b/drivers/firmware/psci/psci.c
index 92013ecc2d9e..00af99b6f97c 100644
--- a/drivers/firmware/psci/psci.c
+++ b/drivers/firmware/psci/psci.c
@@ -151,12 +151,15 @@  static u32 psci_get_version(void)
 	return invoke_psci_fn(PSCI_0_2_FN_PSCI_VERSION, 0, 0, 0);
 }
 
-int psci_set_osi_mode(void)
+int psci_set_osi_mode(bool enable)
 {
+	unsigned long suspend_mode;
 	int err;
 
-	err = invoke_psci_fn(PSCI_1_0_FN_SET_SUSPEND_MODE,
-			     PSCI_1_0_SUSPEND_MODE_OSI, 0, 0);
+	suspend_mode = enable ? PSCI_1_0_SUSPEND_MODE_OSI :
+			PSCI_1_0_SUSPEND_MODE_PC;
+
+	err = invoke_psci_fn(PSCI_1_0_FN_SET_SUSPEND_MODE, suspend_mode, 0, 0);
 	return psci_to_linux_errno(err);
 }
 
@@ -546,8 +549,7 @@  static int __init psci_1_0_init(struct device_node *np)
 		pr_info("OSI mode supported.\n");
 
 		/* Default to PC mode. */
-		invoke_psci_fn(PSCI_1_0_FN_SET_SUSPEND_MODE,
-			       PSCI_1_0_SUSPEND_MODE_PC, 0, 0);
+		psci_set_osi_mode(false);
 	}
 
 	return 0;
diff --git a/include/linux/psci.h b/include/linux/psci.h
index 14ad9b9ebcd6..2a1bfb890e58 100644
--- a/include/linux/psci.h
+++ b/include/linux/psci.h
@@ -18,7 +18,7 @@  bool psci_tos_resident_on(int cpu);
 
 int psci_cpu_suspend_enter(u32 state);
 bool psci_power_state_is_valid(u32 state);
-int psci_set_osi_mode(void);
+int psci_set_osi_mode(bool enable);
 bool psci_has_osi_support(void);
 
 struct psci_operations {