ptl: mmu: Enable module data processing in userspace#10305
ptl: mmu: Enable module data processing in userspace#10305abonislawski merged 6 commits intothesofproject:mainfrom
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR implements userspace module data processing support in the PTL MMU component. It introduces helper functions for memory domain management, extends module adapter initialization, and provides userspace proxy functionality to enable audio data processing in userspace modules.
- Add memory domain helper functions for adding/removing memory regions with proper alignment
- Extend module adapter initialization with userspace context parameter
- Implement userspace proxy module with complete interface forwarding for secure module execution
Reviewed Changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| zephyr/lib/userspace_helper.c | Implements user_add_memory and user_remove_memory functions for memory domain management |
| zephyr/include/rtos/userspace_helper.h | Adds function declarations for memory domain helper functions |
| uuid-registry.txt | Registers UUID for userspace_proxy module |
| src/library_manager/lib_manager.c | Integrates userspace proxy creation and module registration with userspace support |
| src/include/sof/audio/module_adapter/module/generic.h | Updates module_adapter_new_ext signature to include userspace context |
| src/include/sof/audio/module_adapter/library/userspace_proxy.h | Defines userspace proxy interface and context structure |
| src/audio/module_adapter/module_adapter.c | Updates module adapter to use userspace-aware memory allocation |
| src/audio/module_adapter/module/modules.c | Adds APP_TASK_DATA annotation to processing module interface |
| src/audio/module_adapter/library/userspace_proxy.c | Implements complete userspace proxy module with interface forwarding |
| src/audio/module_adapter/CMakeLists.txt | Adds conditional compilation for userspace proxy |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
zephyr/lib/userspace_helper.c
Outdated
| int ret; | ||
|
|
||
| /* Define parameters for user_partition */ | ||
| k_mem_region_align(&addr_aligned, &size_aligned, (uintptr_t)addr, size, HOST_PAGE_SIZE); |
There was a problem hiding this comment.
Redundant cast to uintptr_t - the parameter addr is already of type uintptr_t.
| k_mem_region_align(&addr_aligned, &size_aligned, (uintptr_t)addr, size, HOST_PAGE_SIZE); | |
| k_mem_region_align(&addr_aligned, &size_aligned, addr, size, HOST_PAGE_SIZE); |
There was a problem hiding this comment.
ditto - lets keep this in pages so that clients are forced to consider what's in userspace and whats not.
|
@softwarecki also a general request: could you please put your implementation under |
lgirdwood
left a comment
There was a problem hiding this comment.
@softwarecki we are going to have several options around userspace and will need to split the CONFIG_USERSPACE into more meaningful configs e.g. we could have
- CONFIG_USERSPACE code needed by all userspace.
- CONFIG_USERSPACE_DP_PROXY code needed by this PR
- CONFIG_USERSPACE_APP code needed by running infra and LL in userspace.
This way it should mean easier partitioning of the code.
One other thing is we will need more abstraction around memory alloc and free so that the modules allocate from the right place depending on the CONFIG.
zephyr/lib/userspace_helper.c
Outdated
| int ret; | ||
|
|
||
| /* Define parameters for user_partition */ | ||
| k_mem_region_align(&addr_aligned, &size_aligned, (uintptr_t)addr, size, HOST_PAGE_SIZE); |
There was a problem hiding this comment.
ditto - lets keep this in pages so that clients are forced to consider what's in userspace and whats not.
tmleman
left a comment
There was a problem hiding this comment.
Just minor comments and questions.
tmleman
left a comment
There was a problem hiding this comment.
You'll get my approval once you fix the issues reported by checkpatch and clarify that one small issue below.
fc52897 to
326d4a1
Compare
326d4a1 to
7708f61
Compare
|
Rebased due conflicts. |
Rename the parameter `bytes` to `size` in the documentation of the `mod_alloc_ext` function in `generic.h` to match the actual parameter name in the function definition. Signed-off-by: Adrian Warecki <adrian.warecki@intel.com>
7708f61 to
d883318
Compare
Introduce a configuration option to control heap sharing between userspace module instances. When enabled, instances of the same module type share a private heap allocated for the module driver. When disabled, each instance maintains its own independent heap. Rename DRV_HEAP_SIZE to more meaningful name USER_MOD_HEAP_SIZE. This allows fine-grained control over memory isolation and resource sharing in userspace modules. Signed-off-by: Adrian Warecki <adrian.warecki@intel.com>
…truct Replace multiple arguments passed to system_agent_start and native_system_agent_start with a single pointer to system_agent_params. This improves readability and simplifies function signature. Signed-off-by: Adrian Warecki <adrian.warecki@intel.com>
Introduce initial support for userspace proxy logic. This includes configuring the module's memory domain to ensure proper access rights and creating intermediary functions that forward calls to the module's interface. Signed-off-by: Jaroslaw Stelter <Jaroslaw.Stelter@intel.com> Signed-off-by: Adrian Warecki <adrian.warecki@intel.com>
Extend the module_adapter_new_ext function with an additional user_ctx parameter. This enables the caller to explicitly set the userspace context field within the processing module structure during module adapter initialization. Signed-off-by: Adrian Warecki <adrian.warecki@intel.com>
Introduce support for loading userspace modules. Allow the DP thread to process audio data in userspace. Signed-off-by: Jaroslaw Stelter <Jaroslaw.Stelter@intel.com> Signed-off-by: Adrian Warecki <adrian.warecki@intel.com>
d883318 to
a9a4403
Compare
user_add_memoryanduser_remove_memorythat allows to add/remove memory regions from the memory domain. The purpose of these functions is to round addresses appropriately for the memory domain.module_adapter_new_extfunction with an additionaluser_ctxparameter. This enables the caller to explicitly set the userspace context field within the processing module structure during module adapter initialization.