Audio: Buffers: Add support for DP-to-DP component binding - #10562
Audio: Buffers: Add support for DP-to-DP component binding#10562singalsu wants to merge 2 commits into
Conversation
|
No, no, no! No |
Would be great if that can be done! I need this to have decoder and phase_vocoder in same pipeline without LL components in between throttling the playback data. The phase vocoder consumes at input the audio data at 0.5x to 2.0x speed vs. normal. There can't be LL components with speed higher than 1.0. |
@softwarecki whats your rough schedule for dp-dp ? It seems like we have a real use case now that needs it. |
46ecff9 to
cdc456a
Compare
There was a problem hiding this comment.
Pull request overview
This PR extends the IPC4 binding and buffering infrastructure to allow binding two DP-scheduled components together by introducing a dual-ring-buffer “hybrid” topology around an intermediate comp_buffer, enabling lock-free DP access on both sides while preserving LL-cycle synchronization semantics.
Changes:
- Allow DP→DP binds in
ipc_comp_connect()and create/attach a secondring_bufferfor the source side in the DP→DP case. - Update secondary-buffer attachment and syncing logic to permit and handle both
secondary_buffer_sinkandsecondary_buffer_sourcesimultaneously. - Add vregion refcount release in
ring_buffer_free()to match new vregion refcounting during ring buffer creation.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/ipc/ipc4/helper.c | Removes DP→DP bind rejection and adds dual ring-buffer creation/attachment for DP→DP connections. |
| src/audio/buffers/audio_buffer.c | Allows per-side secondary attachments and adds a dual-secondary sync path for DP→DP cascaded copying. |
| src/audio/buffers/ring_buffer.c | Releases vregion references during ring buffer free to match new vregion refcounting behavior. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
See thesofproject#10562 Previously binding two DP (Data Processing) scheduled components was rejected with IPC4_INVALID_REQUEST. This patch adds support for DP-to-DP binding by creating a dual ring buffer configuration where each DP module gets its own ring buffer on either side of the intermediate comp_buffer. Data flow for DP-to-DP: src_DP -> ring_buf_src -> comp_buffer -> ring_buf_sink -> sink_DP Changes in helper.c: - Remove the DP-to-DP bind rejection in ipc_comp_connect(). - Add src_is_dp, sink_is_dp, and dp_to_dp flags to detect the DP-to-DP case. - Create a second ring_buffer allocated from the source module's mod_alloc_ctx for the source side of the comp_buffer. - Refcount the DP vregion for each created ring_buffer via vregion_get(), with a NULL alloc guard. Changes in audio_buffer.c: - Change audio_buffer_attach_secondary_buffer() from a global rejection to per-side checks, allowing both secondary_buffer_sink and secondary_buffer_source to be set simultaneously. - Add a dual-secondary sync path in audio_buffer_sync_secondary_buffer() that cascades data through: input ring_buffer -> comp_buffer -> output ring_buffer, with rate-limiting applied on the output side. Changes in ring_buffer.c: - Release the DP vregion in ring_buffer_free() via vregion_put() and free the mod_alloc_ctx when the refcount reaches zero, matching the pattern used in comp_buffer_free(). Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
|
@softwarecki @abonislawski this is needed very soon, do you have an ETA or can we go ahead here in the short term. |
cdc456a to
70ff3f1
Compare
|
I just tested this updated patch with #11092, and it worked OK. |
70ff3f1 to
0570d14
Compare
0570d14 to
58d6216
Compare
| * to ring_buffer (as sink) | ||
| */ | ||
| err = audio_buffer_sync_secondary_buffer(&buffer->audio_buffer, UINT_MAX); | ||
| err = audio_buffer_sync_secondary_buffer(&buffer->audio_buffer, SIZE_MAX); |
There was a problem hiding this comment.
Yep, done. Also I used CONFIG_DP_TO_DP_BIND to help find the code for this.
| sof_ctx_free(alloc, (__sparse_force void *)ring_buffer->_data_buffer); | ||
| sof_ctx_free(alloc, ring_buffer); | ||
|
|
||
| /* matches vregion_get() in ipc_comp_connect() for each ring_buffer */ |
There was a problem hiding this comment.
can we state this is just for DP to DP.
…uffer() The limit parameter of audio_buffer_sync_secondary_buffer() is of type size_t. Pass SIZE_MAX instead of UINT_MAX for the unlimited input copy to match the parameter type and avoid size mismatches on 64-bit platforms. Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
Previously binding two DP (Data Processing) scheduled components was rejected with IPC4_INVALID_REQUEST. This patch adds support for DP-to-DP binding by creating a dual ring buffer configuration where each DP module gets its own ring buffer on either side of the intermediate comp_buffer. Data flow for DP-to-DP: src_DP -> ring_buf_src -> comp_buffer -> ring_buf_sink -> sink_DP Changes in Kconfig: - Add CONFIG_DP_TO_DP_BIND (default y) depending on CONFIG_ZEPHYR_DP_SCHEDULER to allow enabling/disabling DP-to-DP component binding. Changes in helper.c: - Allow DP-to-DP binding when CONFIG_DP_TO_DP_BIND is enabled; reject with IPC4_INVALID_REQUEST when disabled. - Add src_is_dp, sink_is_dp, and dp_to_dp flags to detect the DP-to-DP case. - Create a second ring_buffer allocated from the source module's mod_alloc_ctx for the source side of the comp_buffer. - Refcount the DP vregion for each created ring_buffer via vregion_get(), guarded by CONFIG_DP_TO_DP_BIND. Changes in audio_buffer.c: - When CONFIG_DP_TO_DP_BIND is enabled, change audio_buffer_attach_secondary_buffer() from a global rejection to per-side checks, allowing both secondary_buffer_sink and secondary_buffer_source to be set simultaneously. - Add a dual-secondary sync path in audio_buffer_sync_secondary_buffer() under CONFIG_DP_TO_DP_BIND that cascades data through: input ring_buffer -> comp_buffer -> output ring_buffer, with rate-limiting applied on the output side. Changes in ring_buffer.c: - For DP-to-DP binding, release the DP vregion in ring_buffer_free() via vregion_put() and free the mod_alloc_ctx when the refcount reaches zero, guarded by CONFIG_DP_TO_DP_BIND. Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
58d6216 to
7c41c51
Compare
kv2019i
left a comment
There was a problem hiding this comment.
Looks clean. A few questions inline. There are also tests failing, can you take a look at those.
| int audio_buffer_attach_secondary_buffer(struct sof_audio_buffer *buffer, bool at_input, | ||
| struct sof_audio_buffer *secondary_buffer) | ||
| { | ||
| #if CONFIG_DP_TO_DP_BIND |
There was a problem hiding this comment.
Style note, "#ifdef CONFIG_DP_TO_DP_BIND" is the usual convention. @lyakh agrees, but Linux kernel and statistics of use in SOF are on my side with this.
| * ring_buffer_free for DP-to-DP binding) | ||
| */ | ||
| if (ring_buffer->audio_buffer.alloc) | ||
| vregion_get(ring_buffer->audio_buffer.alloc->vreg); |
There was a problem hiding this comment.
This I don't fully get. Why do we need an additional vregion_get/put on the ringbuffer that we already allocated in the normal single DP case. This seems correct, but I'm puzzled why this ref is not taken in ring_buffer_create(). @lyakh any thoughts?
| MAX(obs, src_module_data->mpd.out_buff_size), | ||
| is_shared, buf_id); | ||
| if (!ring_buffer2) { | ||
| buffer_free(buffer); |
There was a problem hiding this comment.
How about the first ring_buffer we allocated (and the vregion ref), should we free those here?
Previously binding two DP (Data Processing) scheduled components was rejected with IPC4_INVALID_REQUEST. This patch adds support for DP-to-DP binding by creating a dual ring buffer configuration where each DP module gets its own ring buffer on either side of the intermediate comp_buffer.
Data flow for DP-to-DP:
src_DP -> ring_buf_src -> comp_buffer -> ring_buf_sink -> sink_DP
Changes in helper.c:
Changes in audio_buffer.c:
that cascades data through: input ring_buffer -> comp_buffer ->
output ring_buffer, with rate-limiting applied on the output side.
Changes in ring_buffer.c: