Skip to content

Commit 271d7dc

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 67c3a92 commit 271d7dc

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
@@ -265,7 +265,7 @@ int ipc_process_on_core(uint32_t core, bool blocking);
265265
* \brief reply to an IPC message.
266266
* @param[in] reply pointer to the reply structure.
267267
*/
268-
void ipc_msg_reply(struct sof_ipc_reply *reply);
268+
#include <sof/ipc/ipc_reply.h>
269269

270270
/**
271271
* \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.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@
3838
#include <rtos/kernel.h>
3939
#include <sof/lib_manager.h>
4040

41+
#ifdef __ZEPHYR__
42+
#include <zephyr/kernel.h>
43+
#include <zephyr/internal/syscall_handler.h>
44+
#endif
45+
4146
#include <errno.h>
4247
#include <stdbool.h>
4348
#include <stddef.h>
@@ -1679,14 +1684,23 @@ void ipc_send_buffer_status_notify(void)
16791684
}
16801685
#endif
16811686

1682-
void ipc_msg_reply(struct sof_ipc_reply *reply)
1687+
void z_impl_ipc_msg_reply(struct sof_ipc_reply *reply)
16831688
{
16841689
struct ipc4_message_request in;
16851690

16861691
in.primary.dat = msg_data.msg_in.pri;
16871692
ipc_compound_msg_done(in.primary.r.type, reply->error);
16881693
}
16891694

1695+
#ifdef CONFIG_USERSPACE
1696+
void z_vrfy_ipc_msg_reply(struct sof_ipc_reply *reply)
1697+
{
1698+
K_OOPS(K_SYSCALL_MEMORY_READ(reply, sizeof(*reply)));
1699+
z_impl_ipc_msg_reply(reply);
1700+
}
1701+
#include <zephyr/syscalls/ipc_msg_reply_mrsh.c>
1702+
#endif
1703+
16901704
void ipc_cmd(struct ipc_cmd_hdr *_hdr)
16911705
{
16921706
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)