Skip to content

Commit f0ae63d

Browse files
committed
ipc: turn ipc_msg_reply() into a system call
Make ipc_msg_reply() a system call, so it can be called from audio thread even when audio thread is running in a user-space thread. Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
1 parent c3689fc commit f0ae63d

5 files changed

Lines changed: 46 additions & 3 deletions

File tree

src/include/sof/ipc/common.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ int ipc_process_on_core(uint32_t core, bool blocking);
310310
* \brief reply to an IPC message.
311311
* @param[in] reply pointer to the reply structure.
312312
*/
313-
void ipc_msg_reply(struct sof_ipc_reply *reply);
313+
#include <sof/ipc/ipc_reply.h>
314314

315315
/**
316316
* \brief Call platform-specific IPC completion function.

src/include/sof/ipc/ipc_reply.h

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/* SPDX-License-Identifier: BSD-3-Clause
2+
*
3+
* Copyright(c) 2026 Intel Corporation. All rights reserved.
4+
*/
5+
6+
#ifndef __SOF_IPC_IPC_REPLY_H__
7+
#define __SOF_IPC_IPC_REPLY_H__
8+
9+
#include <ipc/header.h>
10+
11+
struct sof_ipc_reply;
12+
13+
/**
14+
* \brief reply to an IPC message.
15+
* @param[in] reply pointer to the reply structure.
16+
*/
17+
#if defined(__ZEPHYR__) && defined(CONFIG_SOF_USERSPACE_LL)
18+
__syscall void ipc_msg_reply(struct sof_ipc_reply *reply);
19+
#else
20+
void z_impl_ipc_msg_reply(struct sof_ipc_reply *reply);
21+
#define ipc_msg_reply z_impl_ipc_msg_reply
22+
#endif
23+
24+
#if defined(__ZEPHYR__) && defined(CONFIG_SOF_USERSPACE_LL)
25+
#include <zephyr/syscalls/ipc_reply.h>
26+
#endif
27+
28+
#endif /* __SOF_IPC_IPC_REPLY_H__ */

src/ipc/ipc3/helper.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -710,7 +710,7 @@ int ipc_comp_new(struct ipc *ipc, ipc_comp *_comp)
710710
return 0;
711711
}
712712

713-
void ipc_msg_reply(struct sof_ipc_reply *reply)
713+
void z_impl_ipc_msg_reply(struct sof_ipc_reply *reply)
714714
{
715715
struct ipc *ipc = ipc_get();
716716
k_spinlock_key_t key;

src/ipc/ipc4/handler-kernel.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@
4040
#include <rtos/string.h>
4141
#include <sof/lib_manager.h>
4242

43+
#ifdef __ZEPHYR__
44+
#include <zephyr/kernel.h>
45+
#include <zephyr/internal/syscall_handler.h>
46+
#endif
47+
4348
#if CONFIG_SOF_BOOT_TEST
4449
/* CONFIG_SOF_BOOT_TEST depends on Zephyr */
4550
#include <zephyr/ztest.h>
@@ -524,14 +529,23 @@ void ipc_send_buffer_status_notify(void)
524529
}
525530
#endif
526531

527-
void ipc_msg_reply(struct sof_ipc_reply *reply)
532+
void z_impl_ipc_msg_reply(struct sof_ipc_reply *reply)
528533
{
529534
struct ipc4_message_request in;
530535

531536
in.primary.dat = msg_data.msg_in.pri;
532537
ipc_compound_msg_done(in.primary.r.type, reply->error);
533538
}
534539

540+
#ifdef CONFIG_USERSPACE
541+
void z_vrfy_ipc_msg_reply(struct sof_ipc_reply *reply)
542+
{
543+
K_OOPS(K_SYSCALL_MEMORY_READ(reply, sizeof(*reply)));
544+
z_impl_ipc_msg_reply(reply);
545+
}
546+
#include <zephyr/syscalls/ipc_msg_reply_mrsh.c>
547+
#endif
548+
535549
void ipc_cmd(struct ipc_cmd_hdr *_hdr)
536550
{
537551
struct ipc4_message_request *in = ipc4_get_message_request();

zephyr/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -545,6 +545,7 @@ zephyr_library_sources_ifdef(CONFIG_SHELL
545545

546546
zephyr_syscall_header(${SOF_SRC_PATH}/include/sof/audio/module_adapter/module/generic.h)
547547
zephyr_syscall_header(${SOF_SRC_PATH}/include/sof/lib/fast-get.h)
548+
zephyr_syscall_header(${SOF_SRC_PATH}/include/sof/ipc/ipc_reply.h)
548549
zephyr_syscall_header(include/rtos/alloc.h)
549550
zephyr_library_sources(syscall/alloc.c)
550551

0 commit comments

Comments
 (0)