Skip to content

WIP: Userspace LL ztest#10576

Draft
lgirdwood wants to merge 181 commits intothesofproject:mainfrom
lgirdwood:qemudc233c-pipe
Draft

WIP: Userspace LL ztest#10576
lgirdwood wants to merge 181 commits intothesofproject:mainfrom
lgirdwood:qemudc233c-pipe

Conversation

@lgirdwood
Copy link
Copy Markdown
Member

Very basic/simple ztest to start with user LL. For developers only, lots still todo. Includes qemu support for dc233c atm.

(.venv) lrg@moth:~/work/sof/build-qemu_xtensa_mmu$ west build -t run
-- west build: running target run
[0/27] cmake -P /home/lrg/work/sof/sof/scripts/cmake/version.cmake
-- SOF version.cmake starting at 2026-02-24T20:54:21Z UTC
-- /home/lrg/work/sof/sof/ is at git commit with parent(s):
commit 31248867b7d03507a44c4383bbfeb91993ad0254 7bee513d082b5e058f2accb3bde00c2c7907b439 (HEAD -> qemudc233c-pipe, lrg/qemudc233c, qemudc233c)
Author: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Date:   Tue Feb 24 15:38:55 2026 +0000

    boot tests: add support for running boot tests on qemu simulator
    
    Call directly here as more qemu target wont simulate IPC which is used
    as entry for testing on HW.
    
    Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
-- GIT_TAG / GIT_LOG_HASH : v2.14-pre-rc-427-g31248867b7d0-dirty / 31248867b
-- Source content hash: 412cbc68. Notes:
  - by design, source hash is broken by Kconfig changes. See #3890.
  - Source hash is also broken by _asymmetric_ autocrlf=input, see
    #5917 and reverted #5920.
-- Unchanged /home/lrg/work/sof/build-qemu_xtensa_mmu/zephyr/include/generated/sof_versions.h
[1/2] To exit from QEMU enter: 'CTRL+a, x'[QEMU] CPU: dc233c
[    0.017126] <inf> init: FW ABI 0x301d001 DBG ABI 0x5003000 tags SOF:v2.14-pre-rc-427-g31248867b7d0-dirty zephyr:v4.3.0-5654-gf6a32b27dc17 src hash 0x412cbc68 (ref hash 0x412cbc68)
[    0.022360] <inf> ipc: SOF_BOOT_TEST_STANDALONE, disabling IPC.
*** Booting Zephyr OS build v4.3.0-5654-gf6a32b27dc17 ***
[    0.022566] <inf> main: SOF on qemu_xtensa
[    0.022584] <inf> main: SOF initialized
Running TESTSUITE sof_boot
===================================================================
START - test_sys_sem
[    0.028553] <inf> sof_boot_test: SOF thread UserSpace! (qemu_xtensa/dc233c/mmu) sem 0x1aa000: 0
 PASS - test_sys_sem in 0.007 seconds
===================================================================
START - user_space
[    0.129540] <inf> sof_boot_test: SOF thread UserSpace! (qemu_xtensa/dc233c/mmu)
[    0.140062] <inf> sof_boot_test: SOF thread UserSpace! (qemu_xtensa/dc233c/mmu)
 PASS - user_space in 0.012 seconds
===================================================================
TESTSUITE sof_boot succeeded
Running TESTSUITE userspace_ipc4_pipeline
===================================================================
START - test_pipeline_create_destroy_handlers
[    0.241230] <inf> sof_boot_test: Starting IPC4 pipeline test (handlers)
[    0.241251] <inf> pipe: pipeline new pipe_id 2 priority 0
[    0.241376] <inf> sof_boot_test: IPC4 pipeline test (handlers) complete
 PASS - test_pipeline_create_destroy_handlers in 0.001 seconds
===================================================================
START - test_pipeline_create_destroy_helpers
[    0.341912] <inf> sof_boot_test: Starting IPC4 pipeline test (helpers)
[    0.341931] <inf> pipe: pipeline new pipe_id 1 priority 0
[    0.342072] <inf> sof_boot_test: IPC4 pipeline test (helpers) complete
 PASS - test_pipeline_create_destroy_helpers in 0.001 seconds
===================================================================
TESTSUITE userspace_ipc4_pipeline succeeded
Running TESTSUITE userspace_ll
===================================================================
START - ll_task_test
 SKIP - ll_task_test in 0.001 seconds
===================================================================
TESTSUITE userspace_ll succeeded
Running TESTSUITE userspace_mailbox
===================================================================
START - mailbox_test
 SKIP - mailbox_test in 0.001 seconds
===================================================================
TESTSUITE userspace_mailbox succeeded

------ TESTSUITE SUMMARY START ------

SUITE PASS - 100.00% [sof_boot]: pass = 2, fail = 0, skip = 0, total = 2 duration = 0.019 seconds
 - PASS - [sof_boot.test_sys_sem] duration = 0.007 seconds
 - PASS - [sof_boot.user_space] duration = 0.012 seconds

SUITE PASS - 100.00% [userspace_ipc4_pipeline]: pass = 2, fail = 0, skip = 0, total = 2 duration = 0.002 seconds
 - PASS - [userspace_ipc4_pipeline.test_pipeline_create_destroy_handlers] duration = 0.001 seconds
 - PASS - [userspace_ipc4_pipeline.test_pipeline_create_destroy_helpers] duration = 0.001 seconds

SUITE SKIP -   0.00% [userspace_ll]: pass = 0, fail = 0, skip = 1, total = 1 duration = 0.001 seconds
 - SKIP - [userspace_ll.ll_task_test] duration = 0.001 seconds

SUITE SKIP -   0.00% [userspace_mailbox]: pass = 0, fail = 0, skip = 1, total = 1 duration = 0.001 seconds
 - SKIP - [userspace_mailbox.mailbox_test] duration = 0.001 seconds

------ TESTSUITE SUMMARY END ------

===================================================================
PROJECT EXECUTION SUCCESSFUL
QEMU: Terminated

@lgirdwood lgirdwood force-pushed the qemudc233c-pipe branch 3 times, most recently from d7d6b73 to 77fa25d Compare March 12, 2026 21:00
@lgirdwood
Copy link
Copy Markdown
Member Author

@kv2019i @jsarha @lyakh fyi - still WIP but can run pipelines on qemu, will be splitting up to upstream.

kv2019i added 25 commits April 22, 2026 17:00
If CONFIG_SOF_BOOT_TEST_STANDALONE is set, ipc_init() is terminated
early. This ensures SOF will not start to generate or respond
to IPC messages that could potentially interfere with standalone
test cases (some of which send and receive IPCs).

The current implementation leaves the component list uninitialized
and this can cause trouble to standalone tests that want to utilzie
common IPC code to build messages.

Fix this problem by executing more of ipc_init() also in the standalone
mode.

Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Add a method to add access to a component object to a particular
thread. This is required as component object state includes kernel
objects and to use these from user-space, access needs to be granted.

Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
In userspace LL builds, use a mutex to protect component
connections. This code shoudl work for kernel builds, but at least
now add new code under a ifdef to avoid the cost of additional
mutex object.

Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
- replace dynamically-allocated k_mutex *list_mutex with embedded sys_mutex
- remove k_object_alloc in comp_init, k_object_release in comp_free
- remove comp_grant_access_to_thread() function and caller
- update PPL_LOCK/PPL_UNLOCK and ipc-helper lock sites

Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Add sof_sys_user_heap_get() to get heap object to use for SOF audio
application heap allocations. When SOF is built with
CONFIG_SOF_USERSPACE_LL, this will return a heap that can be
used for user-space code.

Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Add APP_SYSUSER_BSS() and APP_SYSUSER_DATA() macros to put global
objects to a memory partition that is available to the user context
used to run main SOF application. If SOF is run in kernel space,
these are no-ops, but if CONFIG_SOF_USERSPACE_LL is set, a dedicated
memory partition is used.

Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Add a built option to make sof_heap_allo/free available as
system calls to user-space.

Add a test case for the functions that runs in a user-space thread.

Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Separate the state for LL scheduler memory into kernel and user
accessible resources. The pointer to the LL heap must be accessible
from user-space, so that user space can allocate memory and pass
the heap pointer as argument.

Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Turn the pdata->sem into a dynamic object in userspace LL builds.
Keep statically allocated semaphore for kernel LL builds.

Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Replace the dynamically-allocated k_sem (via k_object_alloc) in
zephyr_ll_pdata with an embedded sys_sem. The dynamic kernel semaphore
could not be freed from user-space threads, causing kernel object leaks
that exhausted the kernel object pool during long test runs.

sys_sem uses k_futex in user mode and lives in user memory, so no
kernel object allocation or cleanup is needed. Add POSIX no-op stubs
for sys_sem to maintain testbench build compatibility.

Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Move the user-accessible heap pointer to common partition defined
in userspace_helper.h.

Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Add a heap parameter to DMA scatter-gather allocation interface. This
makes it possible to control how allocations are done for the DMA
buffers.

Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Continue the work in commit 9567234 ("buffer: allocate on specific
heap") and add ability to specify the heap to all buffer interface
functions.

Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Add an overlay for Intel 'ptl' target that allows to build
SOF with all audio pipeline code running in Zephyr user-sapce.

Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Allow a non-null pointer at the end of the DMA transfer block list,
if and only if it points to the first entry in the block list.

The SOF DAI module sets the DMA transfers blocks like this and
this change is required to use DAI module from user-space.

Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
The platform data descriptions need to be accessible to all threads.
These are e.g. used when setting up host/DAI copiers and they need
platform DMA properties.

Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Use separate heaps depending whether host copier is run in user
or kernel space.

Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
For historical reasons, host-zephyr has somewhat complicated code to
manage the DMA channel instance information. When a DMA channel is allocated,
a pointer to the system DMA channel table is acquired and some additional
information is stored per channel. This is however redundant as the only
piece of information actually needed is the channel index.

Simplify the code by not storing the channel pointer anymore, but
rather just store the channel index and use that in all calls to the
DMA driver.

Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Make sure we use the same heap to allocate DMA SG buffers as
we use for other component resources.

Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
These interfaces are no longer used anywhere, so they can be
safely removed.

Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
lrgirdwo added 29 commits April 22, 2026 16:21
TBD if needed

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
TBD if needed.

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Add the --rebuild option to sof-qemu-run.py to optionally skip Zephyr build/recompilation steps, enabling faster iterative testing for ztest and valgrind runs.

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Remove the qemu_started variable constraint to ensure the script drops into QEMU monitor and dumps registers after 2 seconds of log inactivity, regardless of explicit Zephyr boot strings.

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Check the modification time of external QEMU log files (-D, MTRACE) instead of relying solely on stdout to prevent premature unresponsiveness timeouts.

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Remove the -D QEMU trace log from the inactivity monitor since a crashing Zephyr firmware running an infinite loop will keep QEMU pumping instructions to the -D log. Instead, strictly monitor the ace-mtrace file which stops accurately on crashes.

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Refactor the runner to open a concurrent file descriptor against the ace-mtrace file, instantly scanning it for 'halting system' messages instead of relying on delayed filesystem mtime. Timeout is extended to 5 seconds to gracefully account for the initial Zephyr banner loading gap.

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Introcude args.timeout (default 5.0) allowing users to pass greater thresholds for tests that naturally take longer to exhibit initial output gaps.

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Allow users to specify the number of CPU cores for the QEMU machine, extending -smp appropriately and seamlessly integrating with existing west build loops.

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Enable users to spawn a TCP QEMU monitor socket (defaults to localhost:1025) using -monitor tcp:localhost:PORT,server,nowait syntax.

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Map the __log_strings linker section directly into the user thread's memory domains to restore userspace accessibility to LOG_INF calls.

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Substituted the previously hardcoded mpart2 0x400be000 block with dynamic log_part linker mappings identically across the full test suite.

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
…cros

Leverage ROUND_DOWN and ROUND_UP macros from zephyr/sys/util.h to establish the dynamic memory bounds for .log_strings, dropping arbitrary bitwise operations for clearer upstream conformity.

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Substituted arbitrary 4096 integer allocations with CONFIG_MMU_PAGE_SIZE across partition bindings and memory bounds to respect underlying compilation constants dynamically.

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
…fix XTENSA linkage

Substituted missing __log_strings linker symbols strictly with the Zephyr __rodata_region_start equivalents. Intel ADSP targets typically funnel strings into generic .rodata, negating isolated log strings allocations.

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
…aults

Userspace log emissions dynamically execute against k_log_partition data allocations to evaluate filter levels. Restored access to this data by securely mapping the global structurally exported partition into the generic userspace test domains instead of hardcoding arbitrary memory intercepts.

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
…gion to fix XTENSA linkage"

This reverts commit 49342ff4a75cb5ee414f2a4bdd80d259308670eb.
…egion to fix XTENSA linkage"

This reverts commit c0a85a8c1083e5f09dbd0668dbc2ab8610c0fdd7.
Substituted missing k_mem_domain_remove_partition closures at the end of the un-synchronized userspace tests to ensure complete environmental cleanup and prevent overlapping domain memory locks.

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
… log structure targets instead of generalized rodata

Substituted wide-reaching __rodata_region mappings strictly to the constrained z_data_smem_k_log_partition allocations.

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Since log_part was refactored to manually wrap the z_data_smem_k_log_partition boundaries to avoid mapping the entire __rodata blob, the secondary &k_log_partition attachments became overlapping duplicates. Stripped the overlapping domain attachments to leave a single clean mapping.

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Commented out test_user_thread and test_user_thread_with_sem from the sof_boot test suite to isolate test execution.

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
…builds

Automated the injection of the SOF_USERSPACE_LL configuration variable natively into the mathematical ZTest compilation loop. This enables CMake to conditionally bundle the critical IPC4 userspace pipeline tests alongside the arithmetic suites.

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
This adds:
1. --load-llext implementation triggering SOF_IPC4_GLB_LOAD_LIBRARY over TCP.
2. --start-core for dynamic secondary DSP initialization logic relying on SOF_IPC4_MOD_SET_DX.

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Wrapped audio test compilation rules in zephyr_library_sources_ifdef to prevent compiler linkage errors when optional components are disabled. Injected essential core components (SRC, Copier, Mixin, Volume) to the ztest compilation hook.

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
… measurements

Since SOF_TELEMETRY can be toggled via conditions (such as isolated test builds toggling SOF_USERSPACE_LL), the SOF_TELEMETRY_PERFORMANCE_MEASUREMENTS Kconfig needs a strict 'depends on SOF_TELEMETRY' to prevent the framework from blindly compiling performance_monitor.c while telemetry.c is disabled, which reliably leads to undefined reference linker crashes for 'telemetry_get_systick_info_ptr'.

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Since enabling the IPC4 Pipeline tests introduces ~27 additional audio test threads and module workers into the build, the native kobject prebuilt hash exceeds the default thread bytes limit during post-link. Increased CONFIG_MAX_THREAD_BYTES to 4 to allow the python indexer to definitively accommodate the dynamic ztest suites.

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Since CONFIG_SOF_BOOT_TEST inherently controls whether tests are launched during firmware initialisation, replacing the rigid CONFIG_SOF_BOOT_TEST_STANDALONE condition natively allows ZTests to be cleanly bundled inside fully-featured firmware payloads without exclusively executing in isolated testing modes.

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Added the '--test-fw-standard' execution path to the QEMU automation runner. This compiles a fully-functional baseline firmware topology (avoiding the isolated STANDALONE runtime) but still transparently links the ZTest executable blocks so they can trigger via the standard IPC boot hook.

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
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