diff options
Diffstat (limited to 'lib/psci/psci_on.c')
-rw-r--r-- | lib/psci/psci_on.c | 51 |
1 files changed, 34 insertions, 17 deletions
diff --git a/lib/psci/psci_on.c b/lib/psci/psci_on.c index 53b044ec..f38900cf 100644 --- a/lib/psci/psci_on.c +++ b/lib/psci/psci_on.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2017, ARM Limited and Contributors. All rights reserved. + * Copyright (c) 2013-2018, ARM Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ @@ -15,6 +15,19 @@ #include <stddef.h> #include "psci_private.h" +/* + * Helper functions for the CPU level spinlocks + */ +static inline void psci_spin_lock_cpu(int idx) +{ + spin_lock(&psci_cpu_pd_nodes[idx].cpu_lock); +} + +static inline void psci_spin_unlock_cpu(int idx) +{ + spin_unlock(&psci_cpu_pd_nodes[idx].cpu_lock); +} + /******************************************************************************* * This function checks whether a cpu which has been requested to be turned on * is OFF to begin with. @@ -42,22 +55,22 @@ static int cpu_on_validate_state(aff_info_state_t aff_state) * platform handler as it can return error. ******************************************************************************/ int psci_cpu_on_start(u_register_t target_cpu, - entry_point_info_t *ep) + const entry_point_info_t *ep) { int rc; - unsigned int target_idx = plat_core_pos_by_mpidr(target_cpu); aff_info_state_t target_aff_state; + int target_idx = plat_core_pos_by_mpidr(target_cpu); /* Calling function must supply valid input arguments */ - assert((int) target_idx >= 0); + assert(target_idx >= 0); assert(ep != NULL); /* * This function must only be called on platforms where the * CPU_ON platform hooks have been implemented. */ - assert(psci_plat_pm_ops->pwr_domain_on && - psci_plat_pm_ops->pwr_domain_on_finish); + assert((psci_plat_pm_ops->pwr_domain_on != NULL) && + (psci_plat_pm_ops->pwr_domain_on_finish != NULL)); /* Protect against multiple CPUs trying to turn ON the same target CPU */ psci_spin_lock_cpu(target_idx); @@ -78,7 +91,8 @@ int psci_cpu_on_start(u_register_t target_cpu, * target CPUs shutdown was not seen by the current CPU's cluster. And * so the cache may contain stale data for the target CPU. */ - flush_cpu_data_by_index(target_idx, psci_svc_cpu_data.aff_info_state); + flush_cpu_data_by_index((unsigned int)target_idx, + psci_svc_cpu_data.aff_info_state); rc = cpu_on_validate_state(psci_get_aff_info_state_by_idx(target_idx)); if (rc != PSCI_E_SUCCESS) goto exit; @@ -88,7 +102,7 @@ int psci_cpu_on_start(u_register_t target_cpu, * to let it do any bookeeping. If the handler encounters an error, it's * expected to assert within */ - if (psci_spd_pm && psci_spd_pm->svc_on) + if ((psci_spd_pm != NULL) && (psci_spd_pm->svc_on != NULL)) psci_spd_pm->svc_on(target_cpu); /* @@ -97,7 +111,8 @@ int psci_cpu_on_start(u_register_t target_cpu, * turned OFF. */ psci_set_aff_info_state_by_idx(target_idx, AFF_STATE_ON_PENDING); - flush_cpu_data_by_index(target_idx, psci_svc_cpu_data.aff_info_state); + flush_cpu_data_by_index((unsigned int)target_idx, + psci_svc_cpu_data.aff_info_state); /* * The cache line invalidation by the target CPU after setting the @@ -109,9 +124,11 @@ int psci_cpu_on_start(u_register_t target_cpu, if (target_aff_state != AFF_STATE_ON_PENDING) { assert(target_aff_state == AFF_STATE_OFF); psci_set_aff_info_state_by_idx(target_idx, AFF_STATE_ON_PENDING); - flush_cpu_data_by_index(target_idx, psci_svc_cpu_data.aff_info_state); + flush_cpu_data_by_index((unsigned int)target_idx, + psci_svc_cpu_data.aff_info_state); - assert(psci_get_aff_info_state_by_idx(target_idx) == AFF_STATE_ON_PENDING); + assert(psci_get_aff_info_state_by_idx(target_idx) == + AFF_STATE_ON_PENDING); } /* @@ -123,15 +140,16 @@ int psci_cpu_on_start(u_register_t target_cpu, * steps to power on. */ rc = psci_plat_pm_ops->pwr_domain_on(target_cpu); - assert(rc == PSCI_E_SUCCESS || rc == PSCI_E_INTERN_FAIL); + assert((rc == PSCI_E_SUCCESS) || (rc == PSCI_E_INTERN_FAIL)); if (rc == PSCI_E_SUCCESS) /* Store the re-entry information for the non-secure world. */ - cm_init_context_by_index(target_idx, ep); + cm_init_context_by_index((unsigned int)target_idx, ep); else { /* Restore the state on error. */ psci_set_aff_info_state_by_idx(target_idx, AFF_STATE_OFF); - flush_cpu_data_by_index(target_idx, psci_svc_cpu_data.aff_info_state); + flush_cpu_data_by_index((unsigned int)target_idx, + psci_svc_cpu_data.aff_info_state); } exit: @@ -144,8 +162,7 @@ exit: * are called by the common finisher routine in psci_common.c. The `state_info` * is the psci_power_state from which this CPU has woken up from. ******************************************************************************/ -void psci_cpu_on_finish(unsigned int cpu_idx, - psci_power_state_t *state_info) +void psci_cpu_on_finish(int cpu_idx, const psci_power_state_t *state_info) { /* * Plat. management: Perform the platform specific actions @@ -186,7 +203,7 @@ void psci_cpu_on_finish(unsigned int cpu_idx, * Dispatcher to let it do any bookeeping. If the handler encounters an * error, it's expected to assert within */ - if (psci_spd_pm && psci_spd_pm->svc_on_finish) + if ((psci_spd_pm != NULL) && (psci_spd_pm->svc_on_finish != NULL)) psci_spd_pm->svc_on_finish(0); PUBLISH_EVENT(psci_cpu_on_finish); |