kernel: Add CONFIG_ARCH_HAS_DIRECTED_IPIS

Platforms that support IPIs allow them to be broadcast via the
new arch_sched_broadcast_ipi() routine (replacing arch_sched_ipi()).
Those that also allow IPIs to be directed to specific CPUs may
use arch_sched_directed_ipi() to do so.

As the kernel has the capability to track which CPUs may need an IPI
(see CONFIG_IPI_OPTIMIZE), this commit updates the signalling of
tracked IPIs to use the directed version if supported; otherwise
they continue to use the broadcast version.

Platforms that allow directed IPIs may see a significant reduction
in the number of IPI related ISRs when CONFIG_IPI_OPTIMIZE is
enabled and the number of CPUs increases.  These platforms can be
identified by the Kconfig option CONFIG_ARCH_HAS_DIRECTED_IPIS.

Signed-off-by: Peter Mitsis <peter.mitsis@intel.com>
This commit is contained in:
Peter Mitsis 2024-03-04 10:52:24 -05:00 committed by Anas Nashif
commit 0bcdae2c62
17 changed files with 143 additions and 55 deletions

View file

@ -12,6 +12,7 @@
#include <zephyr/drivers/interrupt_controller/intc_esp32.h>
#include <soc.h>
#include <ksched.h>
#include <ipi.h>
#include <zephyr/device.h>
#include <zephyr/kernel.h>
#include <zephyr/spinlock.h>
@ -290,10 +291,12 @@ void arch_cpu_start(int cpu_num, k_thread_stack_t *stack, int sz,
smp_log("ESP32: APPCPU initialized");
}
void arch_sched_ipi(void)
void arch_sched_directed_ipi(uint32_t cpu_bitmap)
{
const int core_id = esp_core_id();
ARG_UNUSED(cpu_bitmap);
if (core_id == 0) {
DPORT_WRITE_PERI_REG(DPORT_CPU_INTR_FROM_CPU_0_REG, DPORT_CPU_INTR_FROM_CPU_0);
} else {
@ -301,6 +304,11 @@ void arch_sched_ipi(void)
}
}
void arch_sched_broadcast_ipi(void)
{
arch_sched_directed_ipi(IPI_ALL_CPUS_MASK);
}
IRAM_ATTR bool arch_cpu_active(int cpu_num)
{
return cpus_active[cpu_num];