Skip to content

Commit

Permalink
firmware: psci: Export functions to manage the OSI mode
Browse files Browse the repository at this point in the history
To allow subsequent changes to implement support for OSI mode through the
cpuidle-psci driver, export the existing psci_has_osi_support(). Export
also a new function, psci_set_osi_mode(), that allows its caller to enable
the OS-initiated CPU-suspend mode in the PSCI FW.

To deal with backwards compatibility for a kernel started through a kexec
call, default to set the CPU-suspend mode to the Platform Coordinated mode
during boot.

Signed-off-by: Ulf Hansson <[email protected]>
Reviewed-by: Sudeep Holla <[email protected]>
  • Loading branch information
storulf committed Jan 2, 2020
1 parent a3f048b commit 49fdcd7
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
18 changes: 16 additions & 2 deletions drivers/firmware/psci/psci.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ static inline bool psci_has_ext_power_state(void)
PSCI_1_0_FEATURES_CPU_SUSPEND_PF_MASK;
}

static inline bool psci_has_osi_support(void)
bool psci_has_osi_support(void)
{
return psci_cpu_suspend_feature & PSCI_1_0_OS_INITIATED;
}
Expand Down Expand Up @@ -162,6 +162,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 err;

err = invoke_psci_fn(PSCI_1_0_FN_SET_SUSPEND_MODE,
PSCI_1_0_SUSPEND_MODE_OSI, 0, 0);
return psci_to_linux_errno(err);
}

static int psci_cpu_suspend(u32 state, unsigned long entry_point)
{
int err;
Expand Down Expand Up @@ -544,9 +553,14 @@ static int __init psci_1_0_init(struct device_node *np)
if (err)
return err;

if (psci_has_osi_support())
if (psci_has_osi_support()) {
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);
}

return 0;
}

Expand Down
2 changes: 2 additions & 0 deletions include/linux/psci.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ 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);
bool psci_has_osi_support(void);

enum smccc_version {
SMCCC_VERSION_1_0,
Expand Down

0 comments on commit 49fdcd7

Please sign in to comment.