From 7934a1cb90873981c9009e122b3876abb85b01b6 Mon Sep 17 00:00:00 2001 From: Laurentiu Mihalcea Date: Fri, 28 Apr 2023 13:40:51 +0300 Subject: [PATCH 1/2] zephyr: wrapper: Conditionally call platform_boot_complete() Due to the fact that on i.MX93 the host will initialize the SOF_IPC_FW_READY sequence there's no need to call platform_boot_complete() at the end of start_complete(). This will be handled in the IPC3 handler. This commit makes sure that aforementioned scenario won't happen for i.MX93 while keeping the flow constant for the other platforms. Signed-off-by: Laurentiu Mihalcea --- zephyr/wrapper.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/zephyr/wrapper.c b/zephyr/wrapper.c index c508b7c1ff61..8c7c466422d2 100644 --- a/zephyr/wrapper.c +++ b/zephyr/wrapper.c @@ -198,6 +198,20 @@ int task_main_start(struct sof *sof) return 0; } +static int boot_complete(void) +{ +#ifdef CONFIG_IMX93_A55 + /* in the case of i.MX93, SOF_IPC_FW_READY + * sequence will be initiated by the host + * so we shouldn't do anything here. + */ + return 0; +#else + /* let host know DSP boot is complete */ + return platform_boot_complete(0); +#endif /* CONFIG_IMX93_A55 */ +} + int start_complete(void) { #if defined(CONFIG_IMX) @@ -215,9 +229,7 @@ int start_complete(void) 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 */ - return platform_boot_complete(0); + return boot_complete(); } /* From a34b2e8a6a866e63a7a283d95d14fcec29979a55 Mon Sep 17 00:00:00 2001 From: Laurentiu Mihalcea Date: Fri, 28 Apr 2023 13:45:29 +0300 Subject: [PATCH 2/2] ipc: ipc3: Add support for SOF_IPC_FW_READY sequence initiated by host In the case of i.MX93 Linux will send an IPC_FW_READY message to SOF and will expect to receive the following information in the hostbox: 1) reply structure 2) sof_ipc_fw_ready structure 3) sof_ipc_fw_ready structure This flow is required because the FW (due to Jailhouse's design) will be up before the platform driver from Linux so the SOF_IPC_FW_READY sequence can't be initiated by SOF. Signed-off-by: Laurentiu Mihalcea --- src/ipc/ipc3/handler.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/ipc/ipc3/handler.c b/src/ipc/ipc3/handler.c index 7d42b58d8ca2..6b869c95aecc 100644 --- a/src/ipc/ipc3/handler.c +++ b/src/ipc/ipc3/handler.c @@ -1603,6 +1603,35 @@ void ipc_boot_complete_msg(struct ipc_cmd_hdr *header, uint32_t data) header->dat[1] = data; } +static int ipc_fw_ready(void) +{ +#ifdef CONFIG_IMX93_A55 + /* VERY IMPORTANT: + * * due to how the FW is started, i.MX93 has the + * following flow (please note that the host driver + * is blacklisted and inserted later on): + * + * 1) Linux kernel boots and user space becomes + * available. + * 2) FW is started (through Jailhouse) => SOF is running + * 4) Host driver module is inserted. + * 5) Host platform driver sends SOF_IPC_FW_READY and + * expects SOF to send the SOF_IPC_FW_READY + * message, the window regions and the reply + * header in the following order: + * 1) reply structure + * 2) sof_ipc_fw_ready structure + * 3) windows structure + * (all of the above information is written + * contiguously in the hostbox) + */ + return platform_boot_complete(0); +#else + /* any other platform should not receive SOF_IPC_FW_READY from host */ + return -EINVAL; +#endif /* CONFIG_IMX93_A55 */ +} + /* * Global IPC Operations. */ @@ -1663,6 +1692,9 @@ void ipc_cmd(struct ipc_cmd_hdr *_hdr) case SOF_IPC_GLB_DEBUG: ret = ipc_glb_debug_message(hdr->cmd); break; + case SOF_IPC_FW_READY: + ret = ipc_fw_ready(); + break; #if CONFIG_DEBUG case SOF_IPC_GLB_TEST: ret = ipc_glb_test_message(hdr->cmd);