From dfaa45c95e92cf32e7d76469539c1c5f56c09bb4 Mon Sep 17 00:00:00 2001 From: Guennadi Liakhovetski Date: Tue, 24 Jan 2023 12:25:21 +0100 Subject: [PATCH] zephyr: move primary_core_init() to POST_KERNEL Zephyr has an elaborate subsystem initialisation framework. Use it for primary_core_init() instead of calling it from main(). This prepares for a migration of module initialisation to that framework too. Signed-off-by: Guennadi Liakhovetski --- src/include/sof/schedule/task.h | 1 + src/init/init.c | 14 +++++++++++++- zephyr/wrapper.c | 17 ++++++++++------- 3 files changed, 24 insertions(+), 8 deletions(-) diff --git a/src/include/sof/schedule/task.h b/src/include/sof/schedule/task.h index 7d828d9f6..df9040fa0 100644 --- a/src/include/sof/schedule/task.h +++ b/src/include/sof/schedule/task.h @@ -122,5 +122,6 @@ void task_main_init(void); void task_main_free(void); int task_main_start(struct sof *sof); +int start_complete(void); #endif /* __SOF_SCHEDULE_TASK_H__ */ diff --git a/src/init/init.c b/src/init/init.c index 844c9c473..9c1669398 100644 --- a/src/init/init.c +++ b/src/init/init.c @@ -10,6 +10,7 @@ */ #include +#include #include #include #include @@ -315,6 +316,17 @@ int sof_main(int argc, char *argv[]) { trace_point(TRACE_BOOT_START); - return primary_core_init(argc, argv, &sof); + return start_complete(); } + +struct device; + +static int sof_init(const struct device *dev) +{ + ARG_UNUSED(dev); + + return primary_core_init(0, NULL, &sof); +} + +SYS_INIT(sof_init, POST_KERNEL, 99); #endif diff --git a/zephyr/wrapper.c b/zephyr/wrapper.c index ba03fa05a..b45016c94 100644 --- a/zephyr/wrapper.c +++ b/zephyr/wrapper.c @@ -258,8 +258,6 @@ int task_main_start(struct sof *sof) { _smex_placeholder = smex_placeholder_f(); - int ret; - /* init default audio components */ sys_comp_init(sof); @@ -269,6 +267,14 @@ int task_main_start(struct sof *sof) /* host is mandatory */ sys_comp_host_init(); + /* init pipeline position offsets */ + pipeline_posn_init(sof); + + return 0; +} + +int start_complete(void) +{ if (IS_ENABLED(CONFIG_COMP_VOLUME)) { #if CONFIG_COMP_LEGACY_INTERFACE sys_comp_volume_init(); @@ -388,8 +394,6 @@ int task_main_start(struct sof *sof) if (IS_ENABLED(CONFIG_PROBE)) sys_comp_probe_init(); #endif - /* init pipeline position offsets */ - pipeline_posn_init(sof); /* init chain dma manager*/ if (IS_ENABLED(CONFIG_COMP_CHAIN_DMA)) @@ -410,10 +414,9 @@ int task_main_start(struct sof *sof) pm_policy_state_lock_get(PM_STATE_RUNTIME_IDLE, PM_ALL_SUBSTATES); pm_policy_state_lock_get(PM_STATE_SOFT_OFF, PM_ALL_SUBSTATES); #endif - /* let host know DSP boot is complete */ - ret = platform_boot_complete(0); - return ret; + /* let host know DSP boot is complete */ + return platform_boot_complete(0); } /*