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.

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

if (!task)
return NULL;

memset(task, 0, sizeof(*task));
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.

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.

Copilot uses AI. Check for mistakes.
return NULL;
}

memset(p, 0, sizeof(*p));
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.

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.

Copilot uses AI. Check for mistakes.
task = rzalloc(SOF_MEM_FLAG_USER,
sizeof(*task));
task = sof_heap_alloc(p->heap, SOF_MEM_FLAG_USER,
sizeof(*task), 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__(*task) / alignof(struct pipeline_task) or the project’s default alignment constant) to prevent misalignment if a heap implementation changes.

Suggested change
sizeof(*task), 0);
sizeof(*task), __alignof__(*task));

Copilot uses AI. Check for mistakes.

/* 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.
return p;
free:
rfree(p);
sof_heap_free(heap, p);
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.

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).

Suggested change
sof_heap_free(heap, p);
sof_heap_free(p->heap, p);

Copilot uses AI. Check for mistakes.
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.

1 participant