Merge "feat(psci): add a helper function to ensure that non-boot PEs are offline" into integration

This commit is contained in:
Manish Pandey 2022-07-21 12:27:55 +02:00 committed by TrustedFirmware Code Review
commit 0051ff8714
3 changed files with 60 additions and 2 deletions

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2017-2018, ARM Limited and Contributors. All rights reserved.
* Copyright (c) 2017-2022, Arm Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
@ -91,6 +91,8 @@ void psci_prepare_next_non_secure_ctx(
entry_point_info_t *next_image_info);
int psci_stop_other_cores(unsigned int wait_ms,
void (*stop_func)(u_register_t mpidr));
bool psci_is_last_on_cpu_safe(void);
#endif /* __ASSEMBLER__ */
#endif /* PSCI_LIB_H */

View file

@ -1022,3 +1022,56 @@ int psci_stop_other_cores(unsigned int wait_ms,
return PSCI_E_SUCCESS;
}
/*******************************************************************************
* This function verifies that all the other cores in the system have been
* turned OFF and the current CPU is the last running CPU in the system.
* Returns true if the current CPU is the last ON CPU or false otherwise.
*
* This API has following differences with psci_is_last_on_cpu
* 1. PSCI states are locked
* 2. It caters for "forest" topology instead of just "tree"
* TODO : Revisit both API's and unify them
******************************************************************************/
bool psci_is_last_on_cpu_safe(void)
{
unsigned int this_core = plat_my_core_pos();
unsigned int parent_nodes[PLAT_MAX_PWR_LVL] = {0};
unsigned int i = 0;
/*
* Traverse the forest of PSCI nodes, nodes with no parents
* (invalid-nodes) are the root nodes.
*/
while ((psci_non_cpu_pd_nodes[i].parent_node ==
PSCI_PARENT_NODE_INVALID) &&
(i < PSCI_NUM_NON_CPU_PWR_DOMAINS)) {
psci_get_parent_pwr_domain_nodes(
psci_non_cpu_pd_nodes[i].cpu_start_idx,
PLAT_MAX_PWR_LVL, parent_nodes);
psci_acquire_pwr_domain_locks(PLAT_MAX_PWR_LVL, parent_nodes);
for (unsigned int core = 0U;
core < psci_non_cpu_pd_nodes[i].ncpus; core++) {
if (core == this_core) {
continue;
}
if (psci_get_aff_info_state_by_idx(core) !=
AFF_STATE_OFF) {
psci_release_pwr_domain_locks(PLAT_MAX_PWR_LVL,
parent_nodes);
VERBOSE("core=%u other than boot core=%u %s\n",
core, this_core, "running in the system");
return false;
}
}
psci_release_pwr_domain_locks(PLAT_MAX_PWR_LVL, parent_nodes);
i++;
}
return true;
}

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2013-2020, ARM Limited and Contributors. All rights reserved.
* Copyright (c) 2013-2022, Arm Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
@ -47,6 +47,9 @@
*/
#define PSCI_MAX_CPUS_INDEX 0xFFFFU
/* Invalid parent */
#define PSCI_PARENT_NODE_INVALID 0xFFFFFFFFU
/*
* Helper functions to get/set the fields of PSCI per-cpu data.
*/