Skip to content

Commit 887947b

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 def699a commit 887947b

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
@@ -41,6 +41,11 @@
4141
#include <rtos/string.h>
4242
#include <sof/lib_manager.h>
4343

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

528-
void ipc_msg_reply(struct sof_ipc_reply *reply)
533+
void z_impl_ipc_msg_reply(struct sof_ipc_reply *reply)
529534
{
530535
struct ipc4_message_request in;
531536

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

541+
#ifdef CONFIG_USERSPACE
542+
void z_vrfy_ipc_msg_reply(struct sof_ipc_reply *reply)
543+
{
544+
K_OOPS(K_SYSCALL_MEMORY_READ(reply, sizeof(*reply)));
545+
z_impl_ipc_msg_reply(reply);
546+
}
547+
#include <zephyr/syscalls/ipc_msg_reply_mrsh.c>
548+
#endif
549+
536550
void ipc_cmd(struct ipc_cmd_hdr *_hdr)
537551
{
538552
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)