Skip to content

Commit 1094201

Browse files
Ulf Hanssonrafaeljw
authored andcommitted
firmware: psci: Extend psci_set_osi_mode() to allow reset to PC mode
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> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent 653f68b commit 1094201

3 files changed

Lines changed: 9 additions & 7 deletions

File tree

drivers/cpuidle/cpuidle-psci-domain.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ static int psci_cpuidle_domain_probe(struct platform_device *pdev)
278278
goto remove_pd;
279279

280280
/* Try to enable OSI mode. */
281-
ret = psci_set_osi_mode();
281+
ret = psci_set_osi_mode(true);
282282
if (ret) {
283283
pr_warn("failed to enable OSI mode: %d\n", ret);
284284
psci_pd_remove_topology(np);

drivers/firmware/psci/psci.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -151,12 +151,15 @@ static u32 psci_get_version(void)
151151
return invoke_psci_fn(PSCI_0_2_FN_PSCI_VERSION, 0, 0, 0);
152152
}
153153

154-
int psci_set_osi_mode(void)
154+
int psci_set_osi_mode(bool enable)
155155
{
156+
unsigned long suspend_mode;
156157
int err;
157158

158-
err = invoke_psci_fn(PSCI_1_0_FN_SET_SUSPEND_MODE,
159-
PSCI_1_0_SUSPEND_MODE_OSI, 0, 0);
159+
suspend_mode = enable ? PSCI_1_0_SUSPEND_MODE_OSI :
160+
PSCI_1_0_SUSPEND_MODE_PC;
161+
162+
err = invoke_psci_fn(PSCI_1_0_FN_SET_SUSPEND_MODE, suspend_mode, 0, 0);
160163
return psci_to_linux_errno(err);
161164
}
162165

@@ -546,8 +549,7 @@ static int __init psci_1_0_init(struct device_node *np)
546549
pr_info("OSI mode supported.\n");
547550

548551
/* Default to PC mode. */
549-
invoke_psci_fn(PSCI_1_0_FN_SET_SUSPEND_MODE,
550-
PSCI_1_0_SUSPEND_MODE_PC, 0, 0);
552+
psci_set_osi_mode(false);
551553
}
552554

553555
return 0;

include/linux/psci.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ bool psci_tos_resident_on(int cpu);
1818

1919
int psci_cpu_suspend_enter(u32 state);
2020
bool psci_power_state_is_valid(u32 state);
21-
int psci_set_osi_mode(void);
21+
int psci_set_osi_mode(bool enable);
2222
bool psci_has_osi_support(void);
2323

2424
struct psci_operations {

0 commit comments

Comments
 (0)