summaryrefslogtreecommitdiff
path: root/libcpu/aarch64/common
diff options
context:
space:
mode:
authorShell <[email protected]>2024-10-31 11:57:04 +0800
committerRbb666 <[email protected]>2024-11-03 10:08:45 +0800
commit2f6d98bfcb4a280f396bda0ea412df10834689d5 (patch)
tree780252d3428adb1fc2a349ade760ff50169563c1 /libcpu/aarch64/common
parent285fee9d4cb6647148476bbdd3bf0796f9e3c6f9 (diff)
feat: smp_call: added signaling call_req
This patch introduces `rt_smp_call_request` API to handle queued requests across cores with user provided data buffer, which provides a way to request IPI through a non-blocking pattern. It also resolved several issues in the old implementation: - Multiple requests from different cores can not be queued in the work object of the target core. - Data racing on `rt_smp_work` of same core. If multiple requests came in turns, or if the call is used by the target cpu, while a new request is coming, the value will be overwrite. - Memory vulnerability. The rt_smp_event is allocated on stack, though the caller may not wait until the call is done. - API naming problem. Actually we don't provide a way to issue an IPI to ANY core in mask. What the API do is aligned to MANY pattern. - FUNC_IPI registering to PIC. Changes: - Declared and configured the new `RT_SMP_CALL_IPI` to support functional IPIs for task requests across cores. - Replaced the single `rt_smp_work` array with `call_req_cores` to manage per-core call requests safely. - Added `_call_req_take` and `_call_req_release` functions for atomic handling of request lifetimes, preventing data race conditions. - Replaced single event handling with a queue-based approach (`call_queue`) for efficient multi-request processing per core. - Introduced `rt_smp_call_ipi_handler` to process queued requests, reducing IPI contention by only sending new requests when needed. - Implemented `_smp_call_remote_request` to handle remote requests with specific flags, enabling more flexible core-to-core task signaling. - Refined `rt_smp_call_req_init` to initialize and track requests with atomic usage flags, mitigating potential memory vulnerabilities. Signed-off-by: Shell <[email protected]>
Diffstat (limited to 'libcpu/aarch64/common')
-rw-r--r--libcpu/aarch64/common/setup.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/libcpu/aarch64/common/setup.c b/libcpu/aarch64/common/setup.c
index 6c16801a10..4ea111d06a 100644
--- a/libcpu/aarch64/common/setup.c
+++ b/libcpu/aarch64/common/setup.c
@@ -302,14 +302,14 @@ void rt_hw_common_setup(void)
rt_thread_idle_sethook(rt_hw_idle_wfi);
#ifdef RT_USING_SMP
- rt_smp_init();
+ rt_smp_call_init();
/* 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_FUNC_IPI, rt_smp_call_ipi_handler);
+ rt_hw_ipi_handler_install(RT_SMP_CALL_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_FUNC_IPI);
+ rt_hw_interrupt_umask(RT_SMP_CALL_IPI);
#endif
}
@@ -391,6 +391,7 @@ rt_weak void rt_hw_secondary_cpu_bsp_start(void)
rt_hw_interrupt_umask(RT_SCHEDULE_IPI);
rt_hw_interrupt_umask(RT_STOP_IPI);
+ rt_hw_interrupt_umask(RT_SMP_CALL_IPI);
LOG_I("Call cpu %d on %s", cpu_id, "success");