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.
Unified · Split
| @@ -97,7 +97,7 @@ static inline bool psci_has_ext_power_state(void) · 96 unmodified lines | ||
| 97 | 97 | PSCI_1_0_FEATURES_CPU_SUSPEND_PF_MASK; |
| 98 | 98 | } |
| 99 | 99 | |
| 100 | −static inline bool psci_has_osi_support(void) | |
| 100 | +bool psci_has_osi_support(void) | |
| 101 | 101 | { |
| 102 | 102 | return psci_cpu_suspend_feature & PSCI_1_0_OS_INITIATED; |
| 103 | 103 | } |
| @@ -162,6 +162,15 @@ static u32 psci_get_version(void) · 58 unmodified lines | ||
| 162 | 162 | return invoke_psci_fn(PSCI_0_2_FN_PSCI_VERSION, 0, 0, 0); |
| 163 | 163 | } |
| 164 | 164 | |
| 165 | +int psci_set_osi_mode(void) | |
| 166 | +{ | |
| 167 | + int err; | |
| 168 | + | |
| 169 | + err = invoke_psci_fn(PSCI_1_0_FN_SET_SUSPEND_MODE, | |
| 170 | + PSCI_1_0_SUSPEND_MODE_OSI, 0, 0); | |
| 171 | + return psci_to_linux_errno(err); | |
| 172 | +} | |
| 173 | + | |
| 165 | 174 | static int psci_cpu_suspend(u32 state, unsigned long entry_point) |
| 166 | 175 | { |
| 167 | 176 | int err; |
| @@ -544,9 +553,14 @@ static int __init psci_1_0_init(struct device_node *np) · 376 unmodified lines | ||
| 544 | 553 | if (err) |
| 545 | 554 | return err; |
| 546 | 555 | |
| 547 | − if (psci_has_osi_support()) | |
| 556 | + if (psci_has_osi_support()) { | |
| 548 | 557 | pr_info("OSI mode supported.\n"); |
| 549 | 558 | |
| 559 | + /* Default to PC mode. */ | |
| 560 | + invoke_psci_fn(PSCI_1_0_FN_SET_SUSPEND_MODE, | |
| 561 | + PSCI_1_0_SUSPEND_MODE_PC, 0, 0); | |
| 562 | + } | |
| 563 | + | |
| 550 | 564 | return 0; |
| 551 | 565 | } |
| 552 | 566 | |
| @@ -18,6 +18,8 @@ bool psci_tos_resident_on(int cpu); · 17 unmodified lines | ||
| 18 | 18 | |
| 19 | 19 | int psci_cpu_suspend_enter(u32 state); |
| 20 | 20 | bool psci_power_state_is_valid(u32 state); |
| 21 | +int psci_set_osi_mode(void); | |
| 22 | +bool psci_has_osi_support(void); | |
| 21 | 23 | |
| 22 | 24 | enum smccc_version { |
| 23 | 25 | SMCCC_VERSION_1_0, |