From 1045847fde41c615291e41ff6353de7c4609b732 Mon Sep 17 00:00:00 2001 From: Kai Vehmanen Date: Tue, 26 May 2026 19:29:29 +0300 Subject: [PATCH] dai: turn dai_get_device() into a syscall Make dai_get_device() a syscall, so it can be called from user-space threads. Signed-off-by: Kai Vehmanen --- src/include/sof/lib/dai-zephyr.h | 4 +++- src/lib/dai.c | 2 +- zephyr/CMakeLists.txt | 2 ++ zephyr/syscall/dai.c | 19 +++++++++++++++++++ 4 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 zephyr/syscall/dai.c diff --git a/src/include/sof/lib/dai-zephyr.h b/src/include/sof/lib/dai-zephyr.h index 3e40c6e682af..a0c42bff351e 100644 --- a/src/include/sof/lib/dai-zephyr.h +++ b/src/include/sof/lib/dai-zephyr.h @@ -309,7 +309,7 @@ void dai_release_llp_slot(struct dai_data *dd); /** * \brief Retrieve a pointer to the Zephyr device structure for a DAI of a given type and index. */ -const struct device *dai_get_device(enum sof_ipc_dai_type type, uint32_t index); +__syscall const struct device *dai_get_device(enum sof_ipc_dai_type type, uint32_t index); /** * \brief Retrieve the list of all DAI devices. @@ -319,4 +319,6 @@ const struct device *dai_get_device(enum sof_ipc_dai_type type, uint32_t index); const struct device **dai_get_device_list(size_t *count); /** @}*/ +#include + #endif /* __SOF_LIB_DAI_ZEPHYR_H__ */ diff --git a/src/lib/dai.c b/src/lib/dai.c index 7a8e44087a65..d51266aa345e 100644 --- a/src/lib/dai.c +++ b/src/lib/dai.c @@ -243,7 +243,7 @@ static int sof_dai_type_to_zephyr(uint32_t type) } } -const struct device *dai_get_device(enum sof_ipc_dai_type type, uint32_t index) +const struct device *z_impl_dai_get_device(enum sof_ipc_dai_type type, uint32_t index) { struct dai_config cfg; int z_type; diff --git a/zephyr/CMakeLists.txt b/zephyr/CMakeLists.txt index 9bdaa6453ad4..a3c4b643bcda 100644 --- a/zephyr/CMakeLists.txt +++ b/zephyr/CMakeLists.txt @@ -622,6 +622,8 @@ zephyr_syscall_header(${SOF_SRC_PATH}/include/sof/audio/module_adapter/module/ge zephyr_syscall_header(${SOF_SRC_PATH}/include/sof/lib/fast-get.h) zephyr_syscall_header(include/rtos/alloc.h) zephyr_library_sources_ifdef(CONFIG_SOF_USERSPACE_INTERFACE_ALLOC syscall/alloc.c) +zephyr_syscall_header(${SOF_SRC_PATH}/include/sof/lib/dai-zephyr.h) +zephyr_library_sources_ifdef(CONFIG_USERSPACE syscall/dai.c) zephyr_library_link_libraries(SOF) target_link_libraries(SOF INTERFACE zephyr_interface) diff --git a/zephyr/syscall/dai.c b/zephyr/syscall/dai.c new file mode 100644 index 000000000000..2e09187e146b --- /dev/null +++ b/zephyr/syscall/dai.c @@ -0,0 +1,19 @@ +// SPDX-License-Identifier: BSD-3-Clause +// +// Copyright(c) 2026 Intel Corporation. + +#include +#include +#include + +static inline const struct device *z_vrfy_dai_get_device(enum sof_ipc_dai_type type, + uint32_t index) +{ + const struct device *dev = z_impl_dai_get_device(type, index); + + if (dev && !k_object_is_valid(dev, K_OBJ_DRIVER_DAI)) + return NULL; + + return dev; +} +#include