Repository navigation
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
Critical issues remain: a forwarding timeout can leave a freed component accessible to the IPC user thread or component list, and repeated configuration calls can exhaust non-reclaimable staging storage.
2 open issues
What changed in this PR
Moves DP module allocations away from the LL user heap, preparing SOF for stronger kernel/user-space isolation.
Changes:
- Uses module-owned storage for DP allocation contexts and configuration buffers.
- Delegates registration of kernel-created DP components to the IPC user thread.
- Updates cleanup and documents the revised allocation ownership.
| File | Description |
|---|---|
src/kernel/ipc/ipc4/helper-kernel.c |
Defers component registration when LL userspace is enabled. |
src/kernel/ipc/ipc4/handler-user-kernel.c |
Hands component registration to the IPC user thread. |
src/ipc/ipc4/handler-user.c |
Registers components already created by the kernel. |
src/include/sof/userspace/README.md |
Documents DP allocation ownership and registration. |
src/include/sof/ipc/common.h |
Adds the component pointer used for the handoff. |
src/audio/module_adapter/module/generic.c |
Moves configuration buffers to module-managed allocation. |
src/audio/module_adapter/module_adapter.c |
Places DP allocation contexts in their virtual regions. |
src/audio/buffers/comp_buffer.c |
Relies on virtual-region teardown to release allocation contexts. |
Review effort: Balanced
PR 11479: test resultsRun date: 2026-11-18 17:01 UTC Tested commit: 5ed38403f308fcf9b94fdcda5ff0128d12ca79bb |
|
@kv2019i I guess you will re-flow for copilot and CI, but LGTM. |
DP modules are created by kernel code, which allocated the allocation context of each DP module from the LL user heap, whose metadata user threads can write. The context was then freed by whichever of the module and its buffers dropped the last reference to the module's vregion. Allocate the context from the module's own vregion instead. It is released with the vregion, so the module and buffer free paths only put their vregion reference. The context becomes writable by the DP thread. This does not give the DP thread new means: it can already make the module point to any context through struct processing_module, which is in the same vregion. Signed-off-by: Kai Vehmanen <[email protected]>
With CONFIG_SOF_USERSPACE_LL, DP modules are created by kernel code, which then allocated the component container from the LL user heap, whose metadata user threads can write, and linked it into the user-writable component list. The container was later freed by the IPC user thread. After creating a DP component, forward the request to the IPC user thread of the core, which adds the component to the list, so the container is both allocated and freed by that thread. If the thread reports an error, the kernel frees the component. If the forward times out, the thread may still add the component later, so the kernel withdraws the component from the request and does not free it. At worst the component is leaked, but never used after it is freed. Signed-off-by: Kai Vehmanen <[email protected]>
module_set_configuration() and module_load_config() allocated the runtime parameter and configuration buffers with sof_heap_alloc() from the LL user heap. Modules such as cadence, waves, dts and ffmpeg call module_set_configuration() from their set_configuration operation, which for a DP module runs in the DP thread. DP threads may not call sof_heap_alloc(), so the system call caller check kills the thread. Allocate and free the buffers of DP modules through the module's allocation context instead, as module memory in their vregion. Other modules keep using the LL user heap. Until the pipeline is complete, a vregion only has its lifetime allocator, which does not reclaim freed memory, and the host sets the module configuration before that. So keep the staging buffer of module_set_configuration() for the next request of a DP module, and only replace it when a larger one is needed, instead of allocating a new one for each request. The buffer is freed with the module. Signed-off-by: Kai Vehmanen <[email protected]>
Document that the allocation context, pin formats and configuration buffers of DP modules are in the module vregion, and that the IPC user thread adds kernel-created DP components to the component list. Signed-off-by: Kai Vehmanen <[email protected]>
dc6f5d5 to
5ed3840
Compare
|
V2 pushed:
|
There was a problem hiding this comment.
🟡 Changes recommended
Alternating configuration sizes repeatedly allocate non-reclaimable DP vregion storage, risking exhaustion and configuration failures with -ENOMEM unless destination capacity is tracked and reused.
1 open issue
2 resolved since last review
Review effort: Balanced
| module_cfg_free(mod, dst->data); | ||
| dst->data = module_cfg_alloc(mod, size); |

DP modules are created by kernel code (ipc4_init_module_instance()) and then run in their own DP user thread. While creating them, the kernel still allocated three kinds of objects from the LL user heap, whose sys_heap metadata user threads can write:
Two problems came with this:
After this series, creating a DP module no longer allocates from the LL user heap in kernel code.
This is preparation for moving LL user heap completely to user-space, completing isolation of kernel code.