Arch: Arm: SMP: Boot & Voting Refactor

Support booting from any usable core in systems with partially
fused-off CPUs. Update get_cpu_logic_id to iterate over the actual
number of enabled CPUs using DT_CHILD_NUM_STATUS_OKAY(DT_PATH(cpus))
instead of CONFIG_MP_MAX_NUM_CPUS.

Resize the voting[] array based on DT_CHILD_NUM_STATUS_OKAY to ensure
each CPU can vote correctly.

Signed-off-by: urvashi sharma <urvashis@qti.qualcomm.com>
This commit is contained in:
urvashi sharma 2025-06-10 13:34:04 -07:00 committed by Benjamin Cabé
commit 9cef24bc62
3 changed files with 7 additions and 4 deletions

View file

@ -25,7 +25,7 @@
* Get CPU logic id by looking up cpu_node_list
* returns
* xreg0: MPID
* xreg1: logic id (0 ~ CONFIG_MP_MAX_NUM_CPUS - 1)
* xreg1: logic id (0 ~ DT_CHILD_NUM_STATUS_OKAY(DT_PATH(cpus)) - 1)
* clobbers: xreg0, xreg1, xreg2, xreg3
*/
.macro get_cpu_logic_id xreg0, xreg1, xreg2, xreg3
@ -36,7 +36,7 @@
cmp \xreg2, \xreg0
beq 2f
add \xreg1, \xreg1, 1
cmp \xreg1, #CONFIG_MP_MAX_NUM_CPUS
cmp \xreg1, #DT_CHILD_NUM_STATUS_OKAY(DT_PATH(cpus))
bne 1b
b .
2:

View file

@ -8,6 +8,7 @@
#include <zephyr/linker/sections.h>
#include <zephyr/arch/cpu.h>
#include <zephyr/offsets.h>
#include <zephyr/devicetree.h>
#include "boot.h"
#include "macro_priv.inc"
@ -163,7 +164,7 @@ resetwait:
/* wait */
bne 2b
add x5, x5, #1
cmp x5, #CONFIG_MP_MAX_NUM_CPUS
cmp x5, #DT_CHILD_NUM_STATUS_OKAY(DT_PATH(cpus))
bne 2b

View file

@ -37,7 +37,7 @@
struct boot_params {
uint64_t mpid;
char *sp;
uint8_t voting[CONFIG_MP_MAX_NUM_CPUS];
uint8_t voting[DT_CHILD_NUM_STATUS_OKAY(DT_PATH(cpus))];
arch_cpustart_t fn;
void *arg;
int cpu_num;
@ -56,6 +56,8 @@ const uint64_t cpu_node_list[] = {
DT_FOREACH_CHILD_STATUS_OKAY_SEP(DT_PATH(cpus), DT_REG_ADDR, (,))
};
BUILD_ASSERT(ARRAY_SIZE(cpu_node_list) == DT_CHILD_NUM_STATUS_OKAY(DT_PATH(cpus)));
/* cpu_map saves the maping of core id and mpid */
static uint64_t cpu_map[CONFIG_MP_MAX_NUM_CPUS] = {
[0 ... (CONFIG_MP_MAX_NUM_CPUS - 1)] = INV_MPID