From 41a737b206eb3f006edccdb940827a81f9cb5f86 Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Sat, 5 Dec 2026 15:05:57 +0000 Subject: [PATCH] kernel: use k_panic() instead of sof_panic() Kernel code uses the native Zephyr API, while user code keeps the SOF and POSIX ones. On Zephyr, sof_panic() is defined as k_panic() and drops its panic code. Call k_panic() directly in the remaining kernel code: the IPC core, the system agent and the i.MX IPC driver. The host provides k_panic() through rtos/panic.h. No functional change on Zephyr. On the host, these panics report SOF_IPC_PANIC_ASSERT instead of the IPC or idle panic code; the host panic handler aborts without using the code. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Liam Girdwood --- src/kernel/drivers/imx/ipc.c | 4 ++-- src/kernel/ipc/ipc-common-kernel.c | 10 +++++----- src/kernel/lib/agent.c | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/kernel/drivers/imx/ipc.c b/src/kernel/drivers/imx/ipc.c index 6cf36224ac6c..084a301cdf47 100644 --- a/src/kernel/drivers/imx/ipc.c +++ b/src/kernel/drivers/imx/ipc.c @@ -203,7 +203,7 @@ int platform_ipc_init(struct ipc *ipc) iipc->dh_buffer.page_table = rzalloc(SOF_MEM_FLAG_USER, PLATFORM_PAGE_TABLE_SIZE); if (!iipc->dh_buffer.page_table) - sof_panic(SOF_IPC_PANIC_IPC); + k_panic(); bzero(iipc->dh_buffer.page_table, PLATFORM_PAGE_TABLE_SIZE); #if CONFIG_ZEPHYR_NATIVE_DRIVERS iipc->dh_buffer.dmac = sof_dma_get(SOF_DMA_DIR_HMEM_TO_LMEM, 0, SOF_DMA_DEV_HOST, @@ -214,7 +214,7 @@ int platform_ipc_init(struct ipc *ipc) #endif if (!iipc->dh_buffer.dmac) { tr_err(&ipc_tr, "Unable to find DMA for host page table"); - sof_panic(SOF_IPC_PANIC_IPC); + k_panic(); } #endif diff --git a/src/kernel/ipc/ipc-common-kernel.c b/src/kernel/ipc/ipc-common-kernel.c index 3263c63c1255..7da927ec9746 100644 --- a/src/kernel/ipc/ipc-common-kernel.c +++ b/src/kernel/ipc/ipc-common-kernel.c @@ -734,7 +734,7 @@ __cold static void ipc_user_init(void) if (!ipc_user) { LOG_ERR("user IPC pdata alloc failed"); - sof_panic(SOF_IPC_PANIC_IPC); + k_panic(); } /* the allocation is not zeroed, start with clean state (e.g. ppl_phase) */ @@ -800,14 +800,14 @@ __cold static void ipc_user_init(void) ret = ipc_user_init_thread(ipc_user, PLATFORM_PRIMARY_CORE_ID); if (ret < 0) { LOG_ERR("user IPC thread initialization failed"); - sof_panic(SOF_IPC_PANIC_IPC); + k_panic(); } ret = user_access_to_mailbox(zephyr_ll_mem_domain(), ipc_user_kthread[PLATFORM_PRIMARY_CORE_ID]); if (ret < 0) { LOG_ERR("ipc user: mailbox access grant failed: %d", ret); - sof_panic(SOF_IPC_PANIC_IPC); + k_panic(); } /* Store references in ipc struct so kernel handler can forward commands */ @@ -867,7 +867,7 @@ __cold int ipc_init(struct sof *sof) sizeof(*ipc->ll_alloc), 0); if (!ipc->ll_alloc) { tr_err(&ipc_tr, "Unable to allocate IPC ll_alloc"); - sof_panic(SOF_IPC_PANIC_IPC); + k_panic(); } ipc->ll_alloc->heap = heap; ipc->ll_alloc->vreg = NULL; @@ -892,7 +892,7 @@ __cold int ipc_init(struct sof *sof) #endif if (!ipc->comp_data) { tr_err(&ipc_tr, "Unable to allocate IPC component data"); - sof_panic(SOF_IPC_PANIC_IPC); + k_panic(); } memset(ipc->comp_data, 0, SOF_IPC_MSG_MAX_SIZE); #ifdef CONFIG_SOF_USERSPACE_LL diff --git a/src/kernel/lib/agent.c b/src/kernel/lib/agent.c index 384e76d93c02..1dc4ad3e787f 100644 --- a/src/kernel/lib/agent.c +++ b/src/kernel/lib/agent.c @@ -76,7 +76,7 @@ static enum task_state validate(void *data) #if CONFIG_AGENT_PANIC_ON_DELAY /* panic timeout */ if (sa->panic_on_delay && delta > sa->panic_timeout) - sof_panic(SOF_IPC_PANIC_IDLE); + k_panic(); #endif /* warning timeout */