From 57305fa91b1fbe99aec03514fff4e824b342665a Mon Sep 17 00:00:00 2001 From: zhujiale <945386260@qq.com> Date: Thu, 12 Sep 2024 13:12:35 +0800 Subject: [PATCH] SMP --- components/smp/smp.c | 3 +-- examples/utest/testcases/smp/smp.c | 5 +++-- include/rtdef.h | 6 ++++-- libcpu/aarch64/common/setup.c | 4 ++-- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/components/smp/smp.c b/components/smp/smp.c index 134d17e3d0c..273b7ce22d1 100644 --- a/components/smp/smp.c +++ b/components/smp/smp.c @@ -107,7 +107,7 @@ void rt_smp_call_func_cond(int cpu_mask, smp_call_func_back func, void *data,rt_ tmp_id++; tmp_mask = tmp_mask >> 1; } - rt_hw_ipi_send(RT_IPI_FUNC, cpu_mask); + rt_hw_ipi_send(RT_FUNC_IPI, cpu_mask); } if(need_wait) @@ -143,4 +143,3 @@ void smp_init(void) rt_spin_lock_init(&global_work[i].lock); } } - diff --git a/examples/utest/testcases/smp/smp.c b/examples/utest/testcases/smp/smp.c index 1af161b72fc..d5ca161a8a1 100644 --- a/examples/utest/testcases/smp/smp.c +++ b/examples/utest/testcases/smp/smp.c @@ -26,10 +26,9 @@ void test1() cpu_mask = rand() % 0xf; if (cpu_mask == 0) pass--; - rt_call_each_cpu(test_call, &cpu_mask, SMP_CALL_NO_WAIT); + rt_call_any_cpu(cpu_mask,test_call, &cpu_mask, SMP_CALL_WAIT_ALL); if (i % 20 == 0) rt_kprintf("#"); - rt_thread_mdelay(1); } rt_kprintf("\n"); uassert_true(pass_count == pass); @@ -57,6 +56,8 @@ void test2(void) static rt_err_t utest_tc_init(void) { + pass_count = 0; + pass = 1000; rt_spin_lock_init(&lock); return RT_EOK; } diff --git a/include/rtdef.h b/include/rtdef.h index 7b6fee9a125..3fba367c07c 100644 --- a/include/rtdef.h +++ b/include/rtdef.h @@ -725,10 +725,12 @@ typedef struct rt_cpu_usage_stats *rt_cpu_usage_stats_t; #define RT_STOP_IPI 1 #endif /* RT_STOP_IPI */ -#ifndef RT_IPI_FUNC -#define RT_IPI_FUNC 2 +#ifndef RT_FUNC_IPI +#define RT_FUNC_IPI 2 #endif +#define RT_MAX_IPI 3 + #define _SCHEDULER_CONTEXT(fileds) fileds /** diff --git a/libcpu/aarch64/common/setup.c b/libcpu/aarch64/common/setup.c index 9d6c16b6394..bbc349a3699 100644 --- a/libcpu/aarch64/common/setup.c +++ b/libcpu/aarch64/common/setup.c @@ -306,10 +306,10 @@ void rt_hw_common_setup(void) /* Install the IPI handle */ rt_hw_ipi_handler_install(RT_SCHEDULE_IPI, rt_scheduler_ipi_handler); rt_hw_ipi_handler_install(RT_STOP_IPI, rt_scheduler_ipi_handler); - rt_hw_ipi_handler_install(RT_IPI_FUNC, rt_smp_call_ipi_handler); + rt_hw_ipi_handler_install(RT_FUNC_IPI, rt_smp_call_ipi_handler); rt_hw_interrupt_umask(RT_SCHEDULE_IPI); rt_hw_interrupt_umask(RT_STOP_IPI); - rt_hw_interrupt_umask(RT_IPI_FUNC); + rt_hw_interrupt_umask(RT_FUNC_IPI); #endif }