Skip to content

audio: pipeline: fix control init order and unrouted component prepare in static pipeline - #11315

Draft
lgirdwood wants to merge 2 commits into
thesofproject:mainfrom
lgirdwood:topic/static-pipeline-fixes
Draft

lgirdwood wants to merge 2 commits into
thesofproject:mainfrom
lgirdwood:topic/static-pipeline-fixes

Conversation

@lgirdwood

@lgirdwood lgirdwood commented Oct 15, 2026 •

Copy link
Copy Markdown
Member

Description

This PR fixes two initialization and prepare issues in the declarative static pipeline loader subsystem (static_pipeline_loader.c), which operates strictly under IPC4 (CONFIG_IPC_MAJOR_4=y):

  1. Premature kcontrol initialization order in sof_static_topology_init():

    • Stage 7 (sof_static_topology_init_controls()) dispatches default control values via sof_static_kcontrol_set(), which verifies if (!s_active_topo) return -ENODEV;.
    • s_active_topo was assigned only after Stage 7 succeeded, causing all initial kcontrol configurations at boot to fail with -ENODEV (-19).
    • Fix: Publish s_active_topo = topo; prior to Stage 7, and reset it to NULL in err_unwind if topology construction fails.
  2. Unrouted component prepare failure:

    • In Stage 6 (sof_static_topology_prepare_comps()), comp_prepare() is called on all components in COMP_STATE_READY. For optional or unrouted components declared in a static topology that have no connected buffers (bsource_list and bsink_list both empty), comp_prepare() fails with -ENOTCONN (-107).
    • Fix: Skip components without any buffer connections in the stage 6 prepare loop.

Changes

  • src/audio/pipeline/static_pipeline_loader.c:
    • Set s_active_topo = topo; before calling sof_static_topology_init_controls(), and clear to NULL on error unwind.
    • Skip prepare on components where list_is_empty(&dev->bsource_list) && list_is_empty(&dev->bsink_list).

All static pipeline logic remains strictly IPC4-based with zero IPC3 dependencies.

@lgirdwood
lgirdwood force-pushed the topic/static-pipeline-fixes branch from 9084313 to a0838bc Compare October 15, 2026 18:25
@lgirdwood lgirdwood changed the title audio: pipeline: fix IPC3 support and control init in static pipeline audio: pipeline: fix control init order and unrouted component prepare in static pipeline Oct 15, 2026
/* Only prepare components currently in READY state */
/* Only prepare components currently in READY state that are connected to buffers */
if (dev->state == COMP_STATE_READY) {
if (list_is_empty(&dev->bsource_list) && list_is_empty(&dev->bsink_list))

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Could we check this for the sink/source buffer APIs instead of relying on comp_buffer?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

will do, I want everything using the new API too

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Updated and rebased on main:

  • Replaced the dev->bsource_list / dev->bsink_list check in sof_static_topology_prepare_comps() with sof_static_comp_has_sink_source(), which checks mod->num_of_sources > 0 || mod->num_of_sinks > 0 for module adapter components and source_get_comp_state() / sink_get_state() on sof_audio_buffer handles for endpoint components.
  • Added comp_bind() / comp_unbind() in sof_static_topology_init_routes() and sof_static_topology_unwind() so sof_sink and sof_source interfaces are bound to IPC4 processing_module instances before prepare().
  • Converted init_buffer_params(), sof_static_topology_unwind(), and sof_static_pipeline_set_sample_rate() to use the sof_sink, sof_source, and sof_audio_buffer APIs (sink_set_params(), source_set_params(), audio_buffer_reset(), audio_buffer_free(), source_get_frm_fmt(), source_get_channels()).

In sof_static_topology_init(), Stage 7 calls sof_static_topology_init_controls()
which dispatches to sof_static_kcontrol_set() to set initial default control
values. However, sof_static_kcontrol_set() checks for an active topology via:

    if (!s_active_topo)
        return -ENODEV;

Because s_active_topo was previously assigned only after Stage 7 succeeded,
all initial kcontrol configurations failed with -ENODEV (-19).

Publish s_active_topo prior to running Stage 7 so control lookups succeed,
and ensure s_active_topo is reset to NULL in err_unwind if initialization fails.

Signed-off-by: Liam Girdwood <[email protected]>
… prepare

Update the static pipeline loader to use the SOF sink/source and
audio_buffer APIs instead of legacy comp_buffer / audio_stream accesses,
and skip unrouted components during Stage 6 prepare:

1. In init_buffer_params(), configure stream parameters, frame/valid
   formats, alignment constants, min_free_space / min_available, and
   buffer reset via sink_set_params(), source_set_params(), and
   audio_buffer_reset().
2. In sof_static_topology_init_routes() (Stage 4), bind buffer sof_sink
   and sof_source interfaces to producer and consumer components via
   comp_bind() so IPC4 processing_module instances populate their
   mod->sources[] and mod->sinks[] tables before module_prepare().
   Correspondingly call comp_unbind(), pipeline_disconnect(), and
   audio_buffer_free() in sof_static_topology_unwind().
3. In sof_static_topology_prepare_comps() (Stage 6), check whether
   components have bound sinks/sources via sof_static_comp_has_sink_source()
   (checking mod->num_of_sources / mod->num_of_sinks for module adapter
   components and source_get_comp_state() / sink_get_state() for endpoint
   components) instead of inspecting dev->bsource_list and dev->bsink_list.
4. In sof_static_pipeline_set_sample_rate(), query buffer format and
   channels via source_get_frm_fmt() and source_get_channels(), update
   IPC4 module base_cfg rate/IBS/OBS, and refresh sink/source thresholds.

Signed-off-by: Liam Girdwood <[email protected]>
@lgirdwood
lgirdwood force-pushed the topic/static-pipeline-fixes branch from a0838bc to 6cd4592 Compare November 1, 2026 20:37
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