LL userspace ipc_msg_send() and send_resource_notif() syscalls and related changes - #10725
LL userspace ipc_msg_send() and send_resource_notif() syscalls and related changes#10725jsarha wants to merge 3 commits into
Conversation
9511db2 to
0382995
Compare
|
Hmmm, looks like something is crashintg this branch every now and then at GLB_CREATE_PIPELINE message. Not sure if its my changes or some other bug in the userspace support. I guess I need come up with new methods to debug issue. Can not proceed with getting CONFIG_HOST_DMA_IPC_POSITION_UPDATES=y to work while there is random crashes even without it. |
Make ipc_msg_send() a Zephyr system call so audio processing modules running in user-space LL threads can queue IPC messages (e.g. position updates, notifications) back to the host. The change takes effect only if CONFIG_SOF_USERSPACE_LL=y. Follows the same pattern used for ipc_msg_reply(): a dedicated header with __syscall declaration, z_impl/z_vrfy split, and syscall header registration in CMakeLists.txt. The verifier validates that the msg struct is writable (the implementation touches the list linkage) and that the data buffer, when provided, is readable up to msg->tx_size bytes. Signed-off-by: Jyri Sarha <jyri.sarha@linux.intel.com>
Add an optional heap parameter to ipc_msg_w_ext_init() and ipc_msg_init() so callers can direct allocations to a specific heap. When the heap argument is NULL the existing rzalloc() path is used; when non-NULL, sof_heap_alloc()/sof_heap_free() are used instead. This allows IPC messages to be allocated from userspace-accessible heaps. For audio module contexts, introduce mod_ipc_msg_w_ext_init() and mod_ipc_msg_init() in generic.h. These use mod_zalloc()/ mod_free() for allocations that are automatically tracked and freed with the module lifecycle. ipc_msg_w_ext_init() is moved from a static inline in msg.h to a non-inline function in ipc-common.c due to the additional sof_heap_alloc dependency. Update all existing callers: - Module context callers (cadence, google_hotword_detect, sound_dose, tdfb, mfcc) use the new mod_ipc_msg_*() variants. - host-zephyr.c uses hd->heap, pipeline-graph.c uses the heap parameter from pipeline_new(). - Remaining kernel-context callers pass NULL for the default heap. Signed-off-by: Jyri Sarha <jyri.sarha@linux.intel.com>
Move user-facing notification functions (send_copier_gateway_xrun_notif_msg, send_gateway_xrun_notif_msg, send_mixer_underrun_notif_msg, send_process_data_error_notif_msg) to a new notification-user.c file so they can run in userspace. The send_resource_notif() function, which depends on the kernel-side notification pool and IPC message infrastructure, is converted to a Zephyr syscall. The implementation is renamed to z_impl_send_resource_notif() and remains in notification.c alongside is_notif_filtered_out() and ipc4_update_notification_mask(). The send_resource_notif() is converted to a system call only if CONFIG_SOF_USERSPACE_LL=y, without it the behaviour is same as befofe. A z_vrfy_send_resource_notif() handler is added to validate the user-provided data buffer and other parameters before forwarding to the kernel implementation. Signed-off-by: Jyri Sarha <jyri.sarha@linux.intel.com>
0382995 to
8812392
Compare
|
I just rebased the the relevant commits on top of V32 of #10558 and tested that they still work, and also that they do not break the normal functions of non LL user-space build. So I think these are ready for wider review and merge. |
There was a problem hiding this comment.
Pull request overview
This PR introduces Zephyr user-space (LL) syscall support for ipc_msg_send() and IPC4 send_resource_notif(), and refactors some IPC4 notification helpers while extending IPC message allocation to optionally use specific heaps/module allocators.
Changes:
- Added Zephyr syscall wrappers + marshalling for
ipc_msg_send()and IPC4send_resource_notif(). - Refactored IPC4 notification helpers into a separate compilation unit and added syscall-side argument validation.
- Extended IPC message initialization APIs to optionally allocate from a specified
k_heapand introduced module-allocator IPC msg init helpers.
Reviewed changes
Copilot reviewed 21 out of 21 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| zephyr/CMakeLists.txt | Registers new syscall headers for ipc_msg_send and IPC4 notification syscalls. |
| src/trace/dma-trace.c | Updates ipc_msg_init() call to the new signature. |
| src/samples/audio/detect_test.c | Updates IPC msg init helpers to pass an explicit heap argument. |
| src/library_manager/lib_notification.c | Updates ipc_msg_init() call to the new signature. |
| src/ipc/ipc4/notification.c | Converts send_resource_notif() into a syscall-capable implementation + verifier. |
| src/ipc/ipc4/notification-user.c | Adds refactored, non-syscall IPC4 notification helper functions. |
| src/ipc/ipc4/CMakeLists.txt | Adds the new notification-user.c to the IPC4 build. |
| src/ipc/ipc-common.c | Adds heap-aware IPC msg allocation and syscall support for ipc_msg_send(). |
| src/include/sof/ipc/msg.h | Changes IPC msg init APIs to accept an optional heap; moves send decl to a new header. |
| src/include/sof/ipc/ipc_msg_send.h | Introduces a dedicated header for ipc_msg_send() (syscall-aware). |
| src/include/sof/audio/module_adapter/module/generic.h | Adds module-allocator IPC msg init helpers. |
| src/include/ipc4/notification.h | Declares send_resource_notif() as a syscall under CONFIG_SOF_USERSPACE_LL. |
| src/audio/tdfb/tdfb_ipc4.c | Switches IPC4 notification template allocation to module allocator helper. |
| src/audio/tdfb/tdfb_ipc3.c | Switches IPC3 IPC msg allocation to module allocator helper. |
| src/audio/sound_dose/sound_dose-ipc4.c | Switches IPC4 notification template allocation to module allocator helper. |
| src/audio/pipeline/pipeline-graph.c | Allocates pipeline IPC msg using the pipeline heap via the new API. |
| src/audio/module_adapter/module/cadence_ipc4.c | Switches IPC notification template allocation to module allocator helper. |
| src/audio/mfcc/mfcc_ipc4.c | Switches IPC4 notification template allocation to module allocator helper. |
| src/audio/host-zephyr.c | Allocates host position IPC msg using the host heap via the new API. |
| src/audio/host-legacy.c | Updates ipc_msg_init() call to the new signature. |
| src/audio/google/google_hotword_detect.c | Updates ipc_msg_init() call to the new signature. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| #else | ||
| void z_impl_ipc_msg_send(struct ipc_msg *msg, void *data, | ||
| bool high_priority); | ||
| #define ipc_msg_send z_impl_ipc_msg_send | ||
| #endif |
| struct ipc_msg *ipc_msg_w_ext_init(struct k_heap *heap, uint32_t header, | ||
| uint32_t extension, uint32_t size); | ||
|
|
| void z_vrfy_ipc_msg_send(struct ipc_msg *msg, void *data, bool high_priority) | ||
| { | ||
| K_OOPS(K_SYSCALL_MEMORY_WRITE(msg, sizeof(*msg))); | ||
|
|
||
| z_vrfy_ipc_msg_send_check_data(msg, data); | ||
|
|
||
| z_impl_ipc_msg_send(msg, data, high_priority); | ||
| } |
| static inline struct ipc_msg *mod_ipc_msg_w_ext_init(struct processing_module *mod, | ||
| uint32_t header, | ||
| uint32_t extension, | ||
| uint32_t size) | ||
| { |
FYI @kv2019i , @lyakh , @lrgirdwo
I still intent to make sure the position updates work.