Uh oh!
There was an error while loading. Please reload this page.
[Userspace LL] audio: pipeline: enable position reporting for user-space pipelines - #11083
[Userspace LL] audio: pipeline: enable position reporting for user-space pipelines#11083kv2019i wants to merge 1 commit into
Conversation
kv2019i
commented
Aug 11, 2026
For context, this is part of #10558 |
There was a problem hiding this comment.
Pull request overview
This PR updates SOF’s pipeline position reporting to work with Zephyr user-mode LL pipelines by moving the position lookup table into the sysuser memory partition and replacing an interrupt-disabling spinlock with a dynamically allocated mutex when CONFIG_SOF_USERSPACE_LL is enabled.
Changes:
- Move
pipeline_posn_init()earlier in boot (primary_core_init()), beforeplatform_init()triggers user-space IPC initialization. - Add a
pipeline_posn_grant_access()helper and grant the user IPC thread access to the dynamically allocated pipeline position mutex. - Update pipeline position bookkeeping to use a mutex (userspace LL) vs. spinlock (non-userspace), and bypass
sof_get()in user-space for direct access to shared state.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| zephyr/wrapper.c | Removes late pipeline_posn_init() call from task_main_start() after init is moved earlier. |
| src/ipc/ipc-common.c | Grants the user IPC thread access to the pipeline position mutex. |
| src/init/init.c | Initializes pipeline position offsets before platform_init() to ensure the mutex exists before user IPC setup. |
| src/include/sof/audio/pipeline.h | Adds a userspace-LL-only API to grant thread access to the position mutex. |
| src/audio/pipeline/pipeline-graph.c | Moves position table into sysuser partition, replaces spinlock usage with mutex under userspace LL, adds access-grant helper, and adjusts userspace lookup. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| #ifndef CONFIG_SOF_USERSPACE_LL | ||
| /* | ||
| * pipe_tr lives in the .trace_ctx section, which is not mapped into | ||
| * the sysuser partition, so it cannot be read from a user-mode thread. | ||
| * The copy is also unnecessary in that configuration: with Zephyr |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.
Suppressed comments (4)
src/audio/pipeline/pipeline-graph.c:209
CONFIG_SOF_USERSPACE_LLdoes not depend onCONFIG_ZEPHYR_LOG, which defaults to disabled, while the non-Zephyr logging path obtains its trace context fromp->tctx. Skipping this initialization for every userspace build therefore leaves a zeroed trace context and makes subsequentpipe_*()calls invalid in a supported configuration. Either require/select Zephyr logging for userspace LL or provide a user-accessible trace-context initialization path.
#ifndef CONFIG_SOF_USERSPACE_LL
/*
* pipe_tr lives in the .trace_ctx section, which is not mapped into
* the sysuser partition, so it cannot be read from a user-mode thread.
* The copy is also unnecessary in that configuration: with Zephyr
src/audio/pipeline/pipeline-graph.c:91
- The new unlock helper lacks the required Doxygen function documentation.
static inline void pipeline_posn_unlock(struct pipeline_posn *posn, pipeline_posn_key_t key)
src/audio/pipeline/pipeline-graph.c:170
- The existing userspace pipeline test invokes
pipeline_new()from a normalZTEST, so it runs in supervisor mode and cannot detect missing mutex permissions or inaccessible sysuser memory. Add a user-mode test (for exampleZTEST_USER) that creates and frees a pipeline after receiving this grant, so the central syscall-verification behavior introduced here is covered.
void pipeline_posn_grant_access(struct k_thread *thread)
{
k_thread_access_grant(thread, pipeline_posn_mutex);
src/audio/pipeline/pipeline-graph.c:84
- The new lock helper lacks the required Doxygen function documentation.
static inline pipeline_posn_key_t pipeline_posn_lock(struct pipeline_posn *posn)
Place the pipeline position lookup table in the sysuser memory partition and replace k_spinlock with a dynamically allocated k_mutex when CONFIG_SOF_USERSPACE_LL is enabled. Spinlocks disable interrupts which is a privileged operation unavailable from user-mode threads. The mutex pointer is stored in a separate APP_SYSUSER_BSS variable outside the SHARED_DATA struct so Zephyr's kernel object tracking can recognize it for syscall verification. Move pipeline_posn_init() from task_main_start() to primary_core_init() before platform_init(), so the mutex is allocated before ipc_user_init() grants thread access to it. In pipeline_posn_get(), bypass the sof_get() kernel singleton and access the shared structure directly when running in user-space. Grant the ipc_user_init thread access to the pipeline position mutex via new pipeline_posn_grant_access() helper. Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
fe687d6 to
5ae9bc2Comparekv2019i
commented
Aug 13, 2026
V2 update:
|
Place the pipeline position lookup table in the sysuser memory partition and replace k_spinlock with a dynamically allocated k_mutex when CONFIG_SOF_USERSPACE_LL is enabled. Spinlocks disable interrupts which is a privileged operation unavailable from user-mode threads.
The mutex pointer is stored in a separate APP_SYSUSER_BSS variable outside the SHARED_DATA struct so Zephyr's kernel object tracking can recognize it for syscall verification.
Move pipeline_posn_init() from task_main_start() to primary_core_init() before platform_init(), so the mutex is allocated before ipc_user_init() grants thread access to it.
In pipeline_posn_get(), bypass the sof_get() kernel singleton and access the shared structure directly when running in user-space. Grant the ipc_user_init thread access to the pipeline position mutex via new pipeline_posn_grant_access() helper.