From 45b70e150093a2f22c2f2c53d33abeeabad284d9 Mon Sep 17 00:00:00 2001 From: Guennadi Liakhovetski Date: Thu, 15 Jul 2021 09:36:45 +0200 Subject: [PATCH] smp: limit the scope of some SMP-only functions z_smp_init() is only available if CONFIG_SMP is defined, smp_timer_init() also depends on two Kconfig parameters. Also make it conditional in cavs_timer.c. Also clarify some SMP-related comments there. Signed-off-by: Guennadi Liakhovetski --- drivers/timer/cavs_timer.c | 6 ++++-- kernel/include/kernel_internal.h | 4 ++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/timer/cavs_timer.c b/drivers/timer/cavs_timer.c index cd7b217ce5b..46c80271d38 100644 --- a/drivers/timer/cavs_timer.c +++ b/drivers/timer/cavs_timer.c @@ -88,7 +88,7 @@ static void compare_isr(const void *arg) curr = count(); #ifdef CONFIG_SMP - /* If it has been too long since last_count, + /* If we are too soon since last_count, * this interrupt is likely the same interrupt * event but being processed by another CPU. * Since it has already been processed and @@ -121,6 +121,7 @@ static void compare_isr(const void *arg) sys_clock_announce(dticks); } +/* Runs on core 0 only */ int sys_clock_driver_init(const struct device *dev) { uint64_t curr = count(); @@ -181,7 +182,8 @@ uint32_t sys_clock_cycle_get_32(void) return count32(); } -#if defined(CONFIG_SMP) && CONFIG_MP_NUM_CPUS > 1 +#if defined(CONFIG_SMP) && CONFIG_MP_NUM_CPUS > 1 && !defined(CONFIG_SMP_BOOT_DELAY) +/* Runs on secondary cores */ void smp_timer_init(void) { /* This enables the Timer 0 (or 1) interrupt for CPU n. diff --git a/kernel/include/kernel_internal.h b/kernel/include/kernel_internal.h index e55c73fa6f0..684d87dc07c 100644 --- a/kernel/include/kernel_internal.h +++ b/kernel/include/kernel_internal.h @@ -136,9 +136,13 @@ z_thread_return_value_set_with_data(struct k_thread *thread, thread->base.swap_data = data; } +#ifdef CONFIG_SMP extern void z_smp_init(void); +#if CONFIG_MP_NUM_CPUS > 1 && !defined(CONFIG_SMP_BOOT_DELAY) extern void smp_timer_init(void); +#endif +#endif extern void z_early_boot_rand_get(uint8_t *buf, size_t length);