Skip to content

audio: src: skip processing without one source and one sink - #11547

Open
singalsu wants to merge 1 commit into
thesofproject:mainfrom
singalsu:src_fix_for_no_sink_or_source
Open

singalsu wants to merge 1 commit into
thesofproject:mainfrom
singalsu:src_fix_for_no_sink_or_source

Conversation

@singalsu

Copy link
Copy Markdown
Collaborator

The SRC process and is_ready_to_process functions use sources[0] and sinks[0] without checking the number of sources and sinks. The sink of the SRC can be unbound while the pipeline of the SRC keeps running, e.g. when the SRC output goes to a module in another pipeline that is stopped while another PCM keeps the SRC pipeline running. The module adapter then sets num_of_sinks to zero but keeps the stale pointer in mod->sinks[0], and the SRC writes to the freed buffer. This was seen as a DSP panic (StoreProhibited) in src_polyphase_stage_cir() when the 16 kHz ECNS PCM was stopped while the 48 kHz ECNS PCM was running on a shared echo reference pipeline.

Do not use sources[0] or sinks[0] unless there is exactly one source and one sink. With a source but no sink, drop the available input instead, so that a shared upstream module, e.g. a copier with several sinks, is not stalled by the full input buffer of the SRC. src_is_ready_to_process() reports data to drop as ready for the DP case.

The SRC process and is_ready_to_process functions use sources[0] and
sinks[0] without checking the number of sources and sinks. The sink of
the SRC can be unbound while the pipeline of the SRC keeps running,
e.g. when the SRC output goes to a module in another pipeline that is
stopped while another PCM keeps the SRC pipeline running. The module
adapter then sets num_of_sinks to zero but keeps the stale pointer in
mod->sinks[0], and the SRC writes to the freed buffer. This was seen as
a DSP panic (StoreProhibited) in src_polyphase_stage_cir() when the
16 kHz ECNS PCM was stopped while the 48 kHz ECNS PCM was running on a
shared echo reference pipeline.

Do not use sources[0] or sinks[0] unless there is exactly one source and
one sink. With a source but no sink, drop the available input instead,
so that a shared upstream module, e.g. a copier with several sinks, is
not stalled by the full input buffer of the SRC. src_is_ready_to_process()
reports data to drop as ready for the DP case.

Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
@singalsu
singalsu marked this pull request as ready for review November 26, 2026 18:04
Copilot AI balanced review requested due to automatic review settings November 26, 2026 18:04

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.

🟢 Approval recommended

No active review issues are reported for the SRC changes intended to prevent stale-buffer access when a source or sink is unbound.

No open issues 🎉

What changed in this PR

This PR protects the sample rate converter (SRC) from accessing stale buffers when a source or sink is unbound while its pipeline remains running.

Changes:

  • Guard processing and readiness checks so normal processing requires exactly one source and one sink.
  • Drop available input when the sink is absent to avoid blocking shared upstream modules, and report that input as ready for DP processing.
File Description
src/​audio/​src/​src_common.c Adds source/sink count guards and a documented helper to discard input when no sink is connected.

Review effort: Balanced

@intel-sofci

Copy link
Copy Markdown

PR 11547: test results

Run date: 2026-11-26 18:29 UTC

Tested commit: 358b36b7dd4152554fce5b09d0447ad6073c8868

mtl pass rate lnl pass rate ptl pass rate wcl pass rate nvl pass rate

Comment on lines +656 to +665
* \brief Drop the input of an SRC that has no sink.
*
* The sink of the SRC can be unbound while the pipeline of the SRC keeps
* running, e.g. when the SRC output goes to another pipeline that is stopped.
* The input is dropped so that a shared upstream module, e.g. a copier with
* several sinks, is not stalled by the full input buffer of the SRC.
*
* \param[in] source Input of the SRC
* \return 0 or a negative error code
*/

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think this needs to be fixed at the level up in the pipeline or module layer as teh same situation could happen to any DP module when connected to LL pipelines. Can you ask agent to investigate and plan at the higher level so all DP modules are protected here.

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.

4 participants