diff --git a/lib/os/Kconfig b/lib/os/Kconfig index 9ce3be2a66ebf..004df87ccf390 100644 --- a/lib/os/Kconfig +++ b/lib/os/Kconfig @@ -106,6 +106,16 @@ config MPSC_CLEAR_ALLOCATED When enabled packet space is zeroed before returning from allocation. endif +if SCHED_DEADLINE + +config P4WQ_INIT_STAGE_EARLY + bool "Early initialization of P4WQ threads" + help + Initialize P4WQ threads early so that the P4WQ can be used on devices + initialization sequence. + +endif + config REBOOT bool "Reboot functionality" help diff --git a/lib/os/p4wq.c b/lib/os/p4wq.c index 22d24da140b83..3d7310c47ee68 100644 --- a/lib/os/p4wq.c +++ b/lib/os/p4wq.c @@ -213,7 +213,11 @@ void k_p4wq_enable_static_thread(struct k_p4wq *queue, struct k_thread *thread, * so they can initialize in parallel instead of serially on the main * CPU. */ +#if defined(CONFIG_P4WQ_INIT_STAGE_EARLY) +SYS_INIT(static_init, POST_KERNEL, 1); +#else SYS_INIT(static_init, APPLICATION, 99); +#endif void k_p4wq_submit(struct k_p4wq *queue, struct k_p4wq_work *item) { diff --git a/subsys/rtio/Kconfig.workq b/subsys/rtio/Kconfig.workq index af85220415692..ad8dcd8ffdf7e 100644 --- a/subsys/rtio/Kconfig.workq +++ b/subsys/rtio/Kconfig.workq @@ -4,6 +4,7 @@ config RTIO_WORKQ bool "RTIO Work-queues service to process Sync operations" select SCHED_DEADLINE + select P4WQ_INIT_STAGE_EARLY select RTIO_CONSUME_SEM help Enable RTIO Work-queues to allow processing synchronous operations