From 6bdd91e9b171be87fc3e1aca19c93bf6ffd0505e Mon Sep 17 00:00:00 2001 From: Kumar Gala Date: Thu, 27 Oct 2022 08:37:15 -0500 Subject: [PATCH] soc: Add ability for SOC to specify runtime CPU detection Add Kconfig SOC_HAS_RUNTIME_NUM_CPUS symbol that an SoC can set to specify that it supports determining the number of CPUs at runtime. On xtensa add support for SOC_HAS_RUNTIME_NUM_CPUS and expose soc_num_cpus that the SoC code should set early in boot as the means to expose the number of cpus. Signed-off-by: Kumar Gala --- include/zephyr/arch/xtensa/arch_inlines.h | 8 ++++++++ soc/Kconfig | 6 ++++++ 2 files changed, 14 insertions(+) diff --git a/include/zephyr/arch/xtensa/arch_inlines.h b/include/zephyr/arch/xtensa/arch_inlines.h index 567ef1f0997..d5fcc55af47 100644 --- a/include/zephyr/arch/xtensa/arch_inlines.h +++ b/include/zephyr/arch/xtensa/arch_inlines.h @@ -50,9 +50,17 @@ static ALWAYS_INLINE uint32_t arch_proc_id(void) return prid; } +#ifdef CONFIG_SOC_HAS_RUNTIME_NUM_CPUS +extern unsigned int soc_num_cpus; +#endif + static ALWAYS_INLINE unsigned int arch_num_cpus(void) { +#ifdef CONFIG_SOC_HAS_RUNTIME_NUM_CPUS + return soc_num_cpus; +#else return CONFIG_MP_MAX_NUM_CPUS; +#endif } #endif /* !_ASMLANGUAGE */ diff --git a/soc/Kconfig b/soc/Kconfig index da9febef2ce..fcb02a982a4 100644 --- a/soc/Kconfig +++ b/soc/Kconfig @@ -53,3 +53,9 @@ config SOC_HAS_TIMING_FUNCTIONS help Should be selected if SoC provides custom method for retrieving timestamps and cycle count. + +config SOC_HAS_RUNTIME_NUM_CPUS + bool + help + Should be selected if SoC handles determining the number of CPUs + at runtime.