Skip to content

Commit 2f6d98b

Browse files
polarvidRbb666
authored andcommitted
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]>
1 parent 285fee9 commit 2f6d98b

File tree

6 files changed

+355
-86
lines changed

6 files changed

+355
-86
lines changed

components/drivers/pic/pic-gic-common.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,9 @@ void gic_common_sgi_config(void *base, void *data, int irq_base)
7171
pirq = rt_pic_find_ipi(data, ipi); \
7272
pirq->mode = RT_IRQ_MODE_EDGE_RISING; \
7373

74-
DECLARE_GIC_IPI(RT_SCHEDULE_IPI, 0);
75-
DECLARE_GIC_IPI(RT_STOP_IPI, 1);
74+
DECLARE_GIC_IPI(RT_SCHEDULE_IPI, RT_SCHEDULE_IPI);
75+
DECLARE_GIC_IPI(RT_STOP_IPI, RT_STOP_IPI);
76+
DECLARE_GIC_IPI(RT_SMP_CALL_IPI, RT_SMP_CALL_IPI);
7677

7778
#undef DECLARE_GIC_IPI
7879
}

components/drivers/pic/pic.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ static int _ipi_hash[] =
3131
#ifdef RT_USING_SMP
3232
[RT_SCHEDULE_IPI] = RT_SCHEDULE_IPI,
3333
[RT_STOP_IPI] = RT_STOP_IPI,
34+
[RT_SMP_CALL_IPI] = RT_SMP_CALL_IPI,
3435
#endif
3536
};
3637

0 commit comments

Comments
 (0)