From 08a23bf3cf159c0eaecd759fbf19765d69463950 Mon Sep 17 00:00:00 2001 From: hujun5 Date: Wed, 6 Nov 2024 14:12:14 +0800 Subject: [PATCH] smpcall: we directly call the function to handle local smpcall reason: some arch do not support issuing interrupts to the local CPU. This commit fixes the regression from https://github.com/apache/nuttx/pull/14663 Signed-off-by: hujun5 --- sched/sched/sched_smp.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/sched/sched/sched_smp.c b/sched/sched/sched_smp.c index 0a035d5e52609..92e2b97c42baf 100644 --- a/sched/sched/sched_smp.c +++ b/sched/sched/sched_smp.c @@ -232,14 +232,18 @@ int nxsched_smp_call(cpu_set_t cpuset, nxsched_smp_call_t func, nxsem_init(&cookie.sem, 0, 0); data.cookie = &cookie; + sched_lock(); ret = nxsched_smp_call_async(cpuset, &data); if (ret < 0) { + sched_unlock(); nxsem_destroy(&cookie.sem); return ret; } + CPU_CLR(this_cpu(), &cpuset); + sched_unlock(); cpucnt = CPU_COUNT(&cpuset); for (i = 0; i < cpucnt; i++) { @@ -314,6 +318,17 @@ int nxsched_smp_call_async(cpu_set_t cpuset, sched_lock(); } + if (CPU_ISSET(this_cpu(), &cpuset)) + { + ret = data->func(data->arg); + if (ret < 0) + { + goto out; + } + + CPU_CLR(this_cpu(), &cpuset); + } + cpucnt = CPU_COUNT(&cpuset); if (cpucnt == 0) {