From 6214f81fed0b0abaaa6d20901350bfa53dca5ae8 Mon Sep 17 00:00:00 2001 From: Andy Ross Date: Thu, 3 Oct 2019 09:27:55 -0700 Subject: [PATCH] tests/kernel/spinlock: No need to use MP API anymore This test was written very early. Spinlocks are required for SMP implementation. They couldn't be tested in terms of it, so the test used the low level MP API instead. But of course that breaks if SMP is actually working and the CPU is already started. No need for that now. Just spawn a thread like any other, and filter the test to run only on SMP systems. Fixes #19319 Signed-off-by: Andy Ross --- tests/kernel/spinlock/prj.conf | 1 - tests/kernel/spinlock/src/main.c | 14 ++++++++++---- tests/kernel/spinlock/testcase.yaml | 2 +- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/tests/kernel/spinlock/prj.conf b/tests/kernel/spinlock/prj.conf index 26542e0a35c..9467c292689 100644 --- a/tests/kernel/spinlock/prj.conf +++ b/tests/kernel/spinlock/prj.conf @@ -1,2 +1 @@ CONFIG_ZTEST=y -CONFIG_SMP=y diff --git a/tests/kernel/spinlock/src/main.c b/tests/kernel/spinlock/src/main.c index f7f77bf615a..12a4d8ae454 100644 --- a/tests/kernel/spinlock/src/main.c +++ b/tests/kernel/spinlock/src/main.c @@ -9,9 +9,12 @@ #include #include +BUILD_ASSERT(CONFIG_MP_NUM_CPUS > 1); + #define CPU1_STACK_SIZE 1024 K_THREAD_STACK_DEFINE(cpu1_stack, CPU1_STACK_SIZE); +struct k_thread cpu1_thread; static struct k_spinlock bounce_lock; @@ -91,10 +94,11 @@ void bounce_once(int id) k_spin_unlock(&bounce_lock, key); } -void cpu1_fn(int key, void *arg) +void cpu1_fn(void *p1, void *p2, void *p3) { - ARG_UNUSED(key); - ARG_UNUSED(arg); + ARG_UNUSED(p1); + ARG_UNUSED(p2); + ARG_UNUSED(p3); while (1) { bounce_once(4321); @@ -112,7 +116,9 @@ void test_spinlock_bounce(void) { int i; - z_arch_start_cpu(1, cpu1_stack, CPU1_STACK_SIZE, cpu1_fn, 0); + k_thread_create(&cpu1_thread, cpu1_stack, CPU1_STACK_SIZE, + cpu1_fn, NULL, NULL, NULL, + 0, 0, 0); k_busy_wait(10); diff --git a/tests/kernel/spinlock/testcase.yaml b/tests/kernel/spinlock/testcase.yaml index 09c24b2220a..65b9ffbe10e 100644 --- a/tests/kernel/spinlock/testcase.yaml +++ b/tests/kernel/spinlock/testcase.yaml @@ -1,3 +1,3 @@ tests: kernel.multiprocessing: - platform_whitelist: esp32 + filter: CONFIG_SMP and CONFIG_MP_NUM_CPUS > 1