Skip to content

ipc4: pipeline: split trigger and copy processing - #11094

Open
serhiy-katsyuba-intel wants to merge 4 commits into
thesofproject:mainfrom
serhiy-katsyuba-intel:separate_triggers_v2
Open

ipc4: pipeline: split trigger and copy processing#11094
serhiy-katsyuba-intel wants to merge 4 commits into
thesofproject:mainfrom
serhiy-katsyuba-intel:separate_triggers_v2

Conversation

@serhiy-katsyuba-intel

Copy link
Copy Markdown
Contributor

Split IPC4 LL pipeline processing into two tasks:

  • A one-shot trigger task that normally returns TASK_COMPLETED, causing the LL scheduler to remove it from its task list. It is not strictly one-shot, as it can be rescheduled to support delayed triggers.
  • A copy task, with almost no changes to the existing implementation.

When a pipeline starts, both tasks are added to the LL scheduler. Trigger tasks are appended with the highest priority, -1, regardless of their pipeline priority. They are therefore added in IPC order and run before any LL copy tasks. Copy tasks are added as before, respecting their pipeline priorities.

Once a trigger task has completed, it returns TASK_COMPLETED and is removed from the LL scheduler's task list. The copy task is prevented from copying while its trigger task remains on the LL scheduler's list to support delayed triggering.

When stopping a pipeline, only the trigger task needs to be added because the copy task is already scheduled. Once the trigger task changes the pipeline state to paused, both tasks return TASK_COMPLETED and are removed from the scheduler's task list.

Separating trigger and copy processing preserves the pipeline trigger order specified by a multi-pipeline-set-state IPC, regardless of pipeline priorities, while allowing copy tasks to run according to pipeline priorities.

This makes the blocking wait introduced by commit c5d638a ("ipc4: handler: maintain IPC set_pipeline_state order") unnecessary.

Change LL task priorities and scheduler initialization interfaces from
uint16_t to int16_t. Lower numeric values continue to represent higher
priorities, so existing task ordering remains unchanged.

Pipelines can use priority 0. The signed range allows the IPC4 trigger
tasks introduced by the following commit to use priority -1 and run
before all pipeline copy tasks.

Signed-off-by: Serhiy Katsyuba <serhiy.katsyuba@intel.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR updates SOF’s IPC4 low-latency pipeline scheduling to split trigger handling and copy processing into separate LL tasks, ensuring host-specified trigger order is preserved independently of pipeline priority, and removes the IPC-side blocking wait that was previously used to maintain ordering.

Changes:

  • Introduces a dedicated IPC4 “trigger task” (priority -1) alongside the existing copy task to preserve IPC trigger order while still allowing copy tasks to run by pipeline priority.
  • Switches LL task priority to a signed type (int16_t) across schedulers and related APIs to support negative (higher-than-0) priorities.
  • Removes the IPC4 handler blocking wait for delayed triggers, relying on the new scheduling model instead.

Reviewed changes

Copilot reviewed 17 out of 17 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
zephyr/test/userspace/test_ll_task.c Extends userspace LL task test to validate negative priority preservation.
zephyr/include/rtos/task.h Changes task priority to int16_t and documents “lower runs first”.
posix/include/rtos/task.h Mirrors the int16_t task priority change for POSIX builds.
src/include/sof/schedule/schedule.h Updates schedule_task_init() signature to accept signed priority.
src/include/sof/schedule/ll_schedule.h Updates LL task init APIs to accept signed priority (and supports IPC4 usage).
src/schedule/schedule.c Propagates signed priority through scheduler task initialization.
src/schedule/ll_schedule_xtos.c Updates LL init signature to signed priority for XtOS LL scheduler.
src/schedule/zephyr_ll.c Updates Zephyr LL init signature and clarifies priority ordering semantics.
src/platform/library/schedule/schedule.c Updates library scheduler init signature to signed priority.
src/platform/library/schedule/ll_schedule.c Updates library LL init signature (but currently still drops passed type/priority).
src/platform/library/include/platform/lib/ll_schedule.h Updates library LL header signature to signed priority.
test/cmocka/src/common_mocks.c Updates weak mock signatures for scheduler init functions to signed priority.
src/include/sof/audio/pipeline.h Adds IPC4 trigger-task pointer to pipeline struct and exposes a task-free helper.
src/audio/pipeline/pipeline-schedule.c Implements IPC4 trigger/copy split, delayed-trigger ownership gating, and task free helper.
src/audio/pipeline/pipeline-graph.c Switches pipeline teardown to the new pipeline_comp_ll_task_free() helper.
src/ipc/ipc4/handler-user.c Removes blocking wait previously used to preserve IPC trigger ordering.
uuid-registry.txt Adds UUID entry for the new IPC4 pipeline trigger task.
Suppressed comments (2)

src/platform/library/schedule/ll_schedule.c:112

  • schedule_task_init_ll() ignores both the provided task type and priority, always initializing as SOF_SCHEDULE_LL_TIMER with priority 0. With the new signed priority support (e.g., -1 for trigger tasks), this makes library/standalone builds behave differently and can break ordering guarantees/tests.
			  int16_t priority, enum task_state (*run)(void *data),
			  void *data, uint16_t core, uint32_t flags)
{
	return schedule_task_init(task, uid, SOF_SCHEDULE_LL_TIMER, 0, run,
				  data, core, flags);

src/audio/pipeline/pipeline-schedule.c:572

  • pipeline_comp_ll_task_free() frees p->pipe_task but does not clear the pointer. This can leave a dangling task pointer if the pipeline object continues to exist after freeing tasks (the new helper is not limited to pipeline_free()).
	if (p->pipe_task) {
#if !CONFIG_LIBRARY || UNIT_TEST
		schedule_task_free(p->pipe_task);
#endif
		sof_heap_free(p->heap, p->pipe_task);

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/audio/pipeline/pipeline-schedule.c
Split IPC4 LL pipeline processing into two tasks:

* A one-shot trigger task that normally returns TASK_COMPLETED, causing
  the LL scheduler to remove it from its task list. It is not strictly
  one-shot, as it can be rescheduled to support delayed triggers.
* A copy task, with almost no changes to the existing implementation.

When a pipeline starts, both tasks are added to the LL scheduler.
Trigger tasks are appended with the highest priority, -1, regardless of
their pipeline priority. They are therefore added in IPC order and run
before any LL copy tasks. Copy tasks are added as before, respecting
their pipeline priorities.

Once a trigger task has completed, it returns TASK_COMPLETED and is
removed from the LL scheduler's task list. The copy task is prevented
from copying while its trigger task remains on the LL scheduler's list
to support delayed triggering.

When stopping a pipeline, only the trigger task needs to be added
because the copy task is already scheduled. Once the trigger task
changes the pipeline state to paused, both tasks return TASK_COMPLETED
and are removed from the scheduler's task list.

Separating trigger and copy processing preserves the pipeline trigger
order specified by a multi-pipeline-set-state IPC, regardless
of pipeline priorities, while allowing copy tasks to run according to
pipeline priorities.

This makes the blocking wait introduced by commit c5d638a
("ipc4: handler: maintain IPC set_pipeline_state order") unnecessary.

Signed-off-by: Serhiy Katsyuba <serhiy.katsyuba@intel.com>
This reverts commit 05bffd7.

Signed-off-by: Serhiy Katsyuba <serhiy.katsyuba@intel.com>
Validate the requested core ID before dispatching pipeline creation.
This prevents an out-of-bounds access found by IPC4 fuzzing.

Signed-off-by: Serhiy Katsyuba <serhiy.katsyuba@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.

2 participants