Skip to content

Conversation

@kv2019i
Copy link
Collaborator

@kv2019i kv2019i commented Feb 11, 2026

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.

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

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 in struct 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.


/* allocate new pipeline */
p = rzalloc(SOF_MEM_FLAG_USER, sizeof(*p));
p = sof_heap_alloc(heap, SOF_MEM_FLAG_USER, sizeof(*p), 0);
Copy link

Copilot AI Feb 11, 2026

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.

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

Copilot uses AI. Check for mistakes.

/* Free pipeline */
ret = pipeline_free(p);
zassert_equal(ret, 0, "pipeline free failed");
Copy link
Collaborator

Choose a reason for hiding this comment

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

zassert_ok(ret,...)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Why not, need to change for V2, so I'll change this as well (although not a fan of the million variants of ztest asserts).

Copy link
Collaborator

Choose a reason for hiding this comment

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

not a fan

oh, I find them cute

struct pipeline *pipeline_new(uint32_t pipeline_id, uint32_t priority, uint32_t comp_id,
struct create_pipeline_params *pparams)
struct pipeline *pipeline_new(struct k_heap *heap, uint32_t pipeline_id, uint32_t priority,
uint32_t comp_id, struct create_pipeline_params *pparams)
Copy link
Member

Choose a reason for hiding this comment

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

Fwiw, I will be changing this to pass in a vregion soon.

@kv2019i kv2019i added the DNM Do Not Merge tag label Feb 12, 2026
@kv2019i
Copy link
Collaborator Author

kv2019i commented Feb 12, 2026

Fail in cmocka, debugging ongoing.

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 <[email protected]>
Add a simple test to allocate a pipeline using a user-space memory
heap and verify creation is successful.

Signed-off-by: Kai Vehmanen <[email protected]>
Fix copy and paste error in documentation for pipeline_prepare().

Signed-off-by: Kai Vehmanen <[email protected]>
Fix copy and paste error in documentation for pipeline_schedule_copy().

Signed-off-by: Kai Vehmanen <[email protected]>
@kv2019i kv2019i force-pushed the 202602-pipe-allow-custom-heap branch from 3e60e0a to c51bfa6 Compare February 12, 2026 15:51
@kv2019i
Copy link
Collaborator Author

kv2019i commented Feb 12, 2026

V2 pushed:

  • fixed cmocka test for pipeline_free
  • use zassert_ok (@lyakh comment)
  • add one more trivial pipeline.h documentation fix at the end of the series

@kv2019i kv2019i removed the DNM Do Not Merge tag label Feb 12, 2026
@kv2019i kv2019i requested a review from lyakh February 12, 2026 15:52
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.

5 participants