-
Notifications
You must be signed in to change notification settings - Fork 350
pipeline: allocate on specific heap #10539
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Add a heap parameter to pipeline allocation functions. This makes it possible to control how allocations are done with pipeline granularity and makes it possible to move pipelines to user-space. Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Add a simple test to allocate a pipeline using a user-space memory heap and verify creation is successful. Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Fix copy and paste error in documentation for pipeline_prepare(). Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Adds heap-aware pipeline allocation so pipelines (and related objects) can be placed on specific memory domains, including user-space heaps.
Changes:
- Extends
pipeline_new()to accept a heap parameter and stores it instruct pipeline - Updates IPC and unit tests to use the new
pipeline_new(NULL, ...)default-heap calling pattern - Adds a Zephyr userspace test that allocates a pipeline from the user heap and validates placement
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| zephyr/test/userspace/test_ll_task.c | Adds a userspace test that creates/frees a pipeline on the userspace heap |
| test/cmocka/src/audio/pipeline/pipeline_new.c | Updates cmocka test to the new pipeline_new() signature |
| src/ipc/ipc4/helper.c | Updates IPC4 pipeline creation to pass default heap (NULL) |
| src/ipc/ipc3/helper.c | Updates IPC3 pipeline creation to pass default heap (NULL) |
| src/include/sof/audio/pipeline.h | Adds heap parameter + pipeline->heap field and updates doc comment |
| src/audio/pipeline/pipeline-schedule.c | Allocates pipeline tasks from the pipeline heap |
| src/audio/pipeline/pipeline-graph.c | Allocates/frees pipeline objects from a selectable heap |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if (!task) | ||
| return NULL; | ||
|
|
||
| memset(task, 0, sizeof(*task)); |
Copilot
AI
Feb 11, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
memset() is newly used here, but this file doesn't appear to include the header that declares it. Add an explicit include for the project’s string/memory header (typically <string.h> or the SOF wrapper) to avoid relying on transitive includes and potential implicit-declaration build failures.
| return NULL; | ||
| } | ||
|
|
||
| memset(p, 0, sizeof(*p)); |
Copilot
AI
Feb 11, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
memset() is newly used here, but this file doesn't appear to include the header that declares it. Add an explicit include for the project’s string/memory header (typically <string.h> or the SOF wrapper) to avoid relying on transitive includes and potential implicit-declaration build failures.
| task = rzalloc(SOF_MEM_FLAG_USER, | ||
| sizeof(*task)); | ||
| task = sof_heap_alloc(p->heap, SOF_MEM_FLAG_USER, | ||
| sizeof(*task), 0); |
Copilot
AI
Feb 11, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using an explicit alignment of 0 relies on sof_heap_alloc() default behavior. Since this allocates a struct, it’s safer/clearer to pass an explicit alignment (e.g., __alignof__(*task) / alignof(struct pipeline_task) or the project’s default alignment constant) to prevent misalignment if a heap implementation changes.
| sizeof(*task), 0); | |
| sizeof(*task), __alignof__(*task)); |
|
|
||
| /* allocate new pipeline */ | ||
| p = rzalloc(SOF_MEM_FLAG_USER, sizeof(*p)); | ||
| p = sof_heap_alloc(heap, SOF_MEM_FLAG_USER, sizeof(*p), 0); |
Copilot
AI
Feb 11, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using an explicit alignment of 0 relies on sof_heap_alloc() default behavior. Since this allocates a struct, it’s safer/clearer to pass an explicit alignment (e.g., __alignof__(*p) / alignof(struct pipeline) or the project’s default alignment constant) to prevent misalignment if a heap implementation changes.
| p = sof_heap_alloc(heap, SOF_MEM_FLAG_USER, sizeof(*p), 0); | |
| p = sof_heap_alloc(heap, SOF_MEM_FLAG_USER, sizeof(*p), __alignof__(*p)); |
| return p; | ||
| free: | ||
| rfree(p); | ||
| sof_heap_free(heap, p); |
Copilot
AI
Feb 11, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On the error path, the code frees with the function parameter heap, while the rest of the lifecycle frees via p->heap. To keep heap ownership consistent (and future-proof if the implementation ever normalizes heap to a default), resolve the effective heap once, assign it to p->heap, and use that same value for all alloc/free paths (including the free: label).
| sof_heap_free(heap, p); | |
| sof_heap_free(p->heap, p); |
Add a heap parameter to pipeline allocation functions. This makes it possible to control how allocations are done with pipeline granularity and makes it possible to move pipelines to user-space.
Second patch adds a test case that uses the new interface to create pipelline in user-space memory domain.
Third patch is a trivial documentation fix to pipeline.h.