Skip to content

userspace_proxy: domain deinit - #11550

Open
abonislawski wants to merge 2 commits into
thesofproject:mainfrom
abonislawski:userspace_proxy_domain_deinit
Open

abonislawski wants to merge 2 commits into
thesofproject:mainfrom
abonislawski:userspace_proxy_domain_deinit

Conversation

@abonislawski

Copy link
Copy Markdown
Member

No description provided.

The Xtensa MMU code in Zephyr links the memory domains into a list
that is walked on whichever core maps or unmaps memory. The domain of a
userspace module was allocated through the cached alias, so another
core could see stale contents. Allocate it from coherent memory, as the
application variant of the DP scheduler already does.

Signed-off-by: Adrian Bonislawski <adrian.bonislawski@intel.com>
userspace_proxy_destroy() freed the memory domain of a module without
k_mem_domain_deinit(). The domain stayed on the Xtensa MMU domain list
in Zephyr, so the DSP panicked once the freed memory was reused.

Deinitialize the domain before freeing it. This fails while the domain
has member threads, so destroy the proxy in the library manager, after
module_adapter_free(), and move a surviving IPC worker thread back to
the default domain first.

Signed-off-by: Adrian Bonislawski <adrian.bonislawski@intel.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

A timed-out free callback can still be running when its work item and module mappings are released, risking a shared-worker fault and breaking IPC for other modules.

1 open issue
What changed in this PR

This PR moves userspace proxy cleanup into the library manager so module memory domains outlive their processing threads and are properly deinitialized before release.

Changes:

  • Defer proxy destruction until after module adapter teardown.
  • Move the shared IPC worker out of a domain before deinitializing it.
  • Allocate domain objects in coherent memory and document their lifetime requirements.
File Description
src/​kernel/​library_manager/​lib_manager.c Destroy the proxy after module adapter teardown.
src/​kernel/​audio/​module_adapter/​library/​userspace_proxy.c Add domain deinitialization, worker detachment, and coherent allocation.
src/​include/​sof/​audio/​module_adapter/​library/​userspace_proxy.h Document the thread-termination requirement for proxy destruction.
src/​audio/​module_adapter/​library/​README.md Explain proxy ownership, teardown ordering, and coherent domain storage.

Review effort: Balanced

Comment on lines +872 to +873
if (userspace)
userspace_proxy_destroy(drv, userspace);

@abonislawski abonislawski Nov 27, 2026 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The scenario is real, but it is not introduced here, on main that case already ends in a (different) fault, probably could be also fixed later

@intel-sofci

Copy link
Copy Markdown

PR 11550: test results

Run date: 2026-11-27 09:13 UTC

Tested commit: 91dbd73ac98a4386b6b589aad8bd3cde5dfd1cee

mtl pass rate lnl pass rate ptl pass rate wcl pass rate nvl pass rate

@abonislawski abonislawski changed the title Userspace proxy domain deinit userspace_proxy: domain deinit Nov 27, 2026
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.

3 participants