Skip to content

Conversation

@softwarecki
Copy link
Collaborator

  • Add helper functions user_add_memory and user_remove_memory that allows to add/remove memory regions from the memory domain. The purpose of these functions is to round addresses appropriately for the memory domain.
  • 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.
  • 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.
  • Introduce support for loading userspace modules. Allow the DP thread to process audio data in userspace.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

int ret;

/* Define parameters for user_partition */
k_mem_region_align(&addr_aligned, &size_aligned, (uintptr_t)addr, size, HOST_PAGE_SIZE);
Copy link

Copilot AI Oct 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Redundant cast to uintptr_t - the parameter addr is already of type uintptr_t.

Suggested change
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);

Copilot uses AI. Check for mistakes.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto - lets keep this in pages so that clients are forced to consider what's in userspace and whats not.

@lyakh
Copy link
Collaborator

lyakh commented Oct 15, 2025

@softwarecki also a general request: could you please put your implementation under #if CONFIG_... using a new Kconfig option, e.g. the one I'm adding in 3e5f62c

Copy link
Member

@lgirdwood lgirdwood left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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

  1. CONFIG_USERSPACE code needed by all userspace.
  2. CONFIG_USERSPACE_DP_PROXY code needed by this PR
  3. 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.

int ret;

/* Define parameters for user_partition */
k_mem_region_align(&addr_aligned, &size_aligned, (uintptr_t)addr, size, HOST_PAGE_SIZE);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto - lets keep this in pages so that clients are forced to consider what's in userspace and whats not.

Copy link
Contributor

@tmleman tmleman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just minor comments and questions.

Copy link
Contributor

@tmleman tmleman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You'll get my approval once you fix the issues reported by checkpatch and clarify that one small issue below.

@softwarecki softwarecki force-pushed the userspace-enable-tiny branch from fc52897 to 326d4a1 Compare November 4, 2025 14:04
@softwarecki softwarecki requested a review from tmleman November 4, 2025 14:44
@softwarecki softwarecki force-pushed the userspace-enable-tiny branch from 326d4a1 to 7708f61 Compare November 5, 2025 14:06
@softwarecki
Copy link
Collaborator Author

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>
@softwarecki softwarecki force-pushed the userspace-enable-tiny branch from 7708f61 to d883318 Compare November 5, 2025 17:08
softwarecki and others added 3 commits November 7, 2025 18:06
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>
@softwarecki softwarecki force-pushed the userspace-enable-tiny branch from d883318 to a9a4403 Compare November 7, 2025 17:22
@abonislawski abonislawski merged commit e8353e2 into thesofproject:main Nov 12, 2025
39 of 42 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants