userspace: proxy: Add support for llext modules#10643
userspace: proxy: Add support for llext modules#10643softwarecki wants to merge 5 commits intothesofproject:mainfrom
Conversation
259de26 to
761633a
Compare
There was a problem hiding this comment.
Pull request overview
This PR adds support for userspace llext modules in the userspace proxy and updates related memory-domain and fast_get behavior to accommodate shared heaps and Zephyr MMU changes.
Changes:
- Extend llext module manifests to optionally set a
user_modeflag and propagate it into rimage manifests. - Update userspace proxy memory-domain setup (including adding a partition for the module driver heap
k_heapstructure) and add llext domain integration. - Adjust
fast_get()behavior for userspace/driver-heap configurations and simplify userspace-thread detection.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| zephyr/lib/userspace_helper.c | Removes a now-unneeded macro alias related to heap caching configuration. |
| zephyr/lib/fast-get.c | Adjusts buffer sharing/caching logic and userspace-thread detection. |
| tools/rimage/src/manifest.c | Propagates user_mode into generated module manifests. |
| src/library_manager/lib_manager.c | Makes agent start conditional and ensures LLEXT uses no agent interface. |
| src/include/module/module/llext.h | Extends LLEXT manifest macro with optional user_mode argument. |
| src/audio/module_adapter/library/userspace_proxy.c | Adds llext manager integration, updates memory-domain partitioning, and handles agent-less modules. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| /* We only get there for large buffers */ | ||
| if (k_current_get()->mem_domain_info.mem_domain->num_partitions > 1) { | ||
| /* We only get there for large buffers or module driver heap is in use */ | ||
| if (k_current_get()->base.user_options & K_USER && size > FAST_GET_MAX_COPY_SIZE) { |
There was a problem hiding this comment.
The comment states this branch applies to 'large buffers or module driver heap is in use', but the condition only gates on size > FAST_GET_MAX_COPY_SIZE. If the driver-heap configuration is intended to share buffers across userspace instances independent of size, the condition should incorporate CONFIG_SOF_USERSPACE_USE_DRIVER_HEAP (or the comment should be corrected). As written, the driver-heap case is ignored by this userspace-thread path.
| if (k_current_get()->base.user_options & K_USER && size > FAST_GET_MAX_COPY_SIZE) { | |
| if ((k_current_get()->base.user_options & K_USER) && | |
| (size > FAST_GET_MAX_COPY_SIZE || | |
| IS_ENABLED(CONFIG_SOF_USERSPACE_USE_DRIVER_HEAP))) { |
There was a problem hiding this comment.
Can you address this, same problem, how do the comment and code relate?
|
let's first merge a fast-get fix, before adding new features to it. Marking this DNM until #10639 is merged |
kv2019i
left a comment
There was a problem hiding this comment.
Nothing major, a few notes inline.
| /* We only get there for large buffers */ | ||
| if (k_current_get()->mem_domain_info.mem_domain->num_partitions > 1) { | ||
| /* We only get there for large buffers or module driver heap is in use */ | ||
| if (k_current_get()->base.user_options & K_USER && size > FAST_GET_MAX_COPY_SIZE) { |
There was a problem hiding this comment.
Can you address this, same problem, how do the comment and code relate?
|
@softwarecki do I dare and click the fix conflicts button with copilot or do you want to fix ? and we can merge. |
…FEST Extend the SOF_LLEXT_MODULE_MANIFEST macro with an optional variadic parameter to specify the user_mode flag for llext modules. When the argument is omitted, user_mode defaults to 0, preserving backward compatibility with existing module manifests. Update the rimage to propagate the user_mode field from the module manifest to manifest structure in the final firmware binary image. Signed-off-by: Adrian Warecki <adrian.warecki@intel.com>
Add support for userspace llext loadable modules to the userspace proxy. Call lib_manager_start_agent unconditionally, even when the system agent is not used, as this function is responsible for creating the userspace module proxy. Signed-off-by: Adrian Warecki <adrian.warecki@intel.com>
Allow fast_get sram buffer sharing across multiple userspace module instances when CONFIG_SOF_USERSPACE_USE_DRIVER_HEAP is enabled. The module driver heap is shared by all instances of a given module, so allocated buffers can safely be reused between them. Simplify checking whether a calling thread runs in userspace by verifying if the K_USER flag is set. Signed-off-by: Adrian Warecki <adrian.warecki@intel.com>
Rename user_get_partition_attr() to user_get_partition_cache_attr(). Signed-off-by: Adrian Warecki <adrian.warecki@intel.com>
Add a memory partition for the module driver heap k_heap structure to the module's memory domain to allow it to be referenced by syscalls. When a new memory domain is created, only L2 entries mapped with OPTION_SAVE_ATTRS are copied. Memory mapped dynamically during firmware execution is not accessible in new memory domains by default. Update the code to reflect the removal of memory double mapping in Zephyr by replacing the CONFIG_XTENSA_MMU_DOUBLE_MAP with a simple CONFIG_SOF_ZEPHYR_HEAP_CACHED check. Signed-off-by: Adrian Warecki <adrian.warecki@intel.com>
761633a to
ee44813
Compare
SOF_LLEXT_MODULE_MANIFESTmacro with an optional variadic parameter to specify the user_mode flag for llext modules. When the argument is omitted, user_mode defaults to 0, preserving backward compatibility with existing module manifests.fast_getsram buffer sharing across multiple userspace module instances whenCONFIG_SOF_USERSPACE_USE_DRIVER_HEAPis enabled.if the K_USER flag is set.
k_heapstructure to the module's memory domain to allow it to be referenced by syscalls.userspace_proxy_memory_initfunction to reflect the removal of memory double mapping in Zephyr by replacing theCONFIG_XTENSA_MMU_DOUBLE_MAPwith a simpleCONFIG_SOF_ZEPHYR_HEAP_CACHEDcheck.