Repository navigation
audio: copier_host: free the FPI sync group with its last member - #11585
Open
Shrusti-pk wants to merge 1 commit into
Open
Shrusti-pk wants to merge 1 commit into
Shrusti-pk wants to merge 1 commit into
Conversation
add_to_fpi_sync_group() allocates the struct fpi_sync_group that every host gateway copier joining the same group_id shares with mod_alloc_ext(), so the group belongs to the resource pool of the copier that happens to create it. mod_free_all() releases that pool when the module is freed or when its init fails, while delete_from_fpi_sync_group() keeps the group linked in group_list_head as long as another member still references it. Deleting the creating copier while a second member is alive therefore leaves a freed node in the global list. The next host copier init reads it in find_group_by_id() and list_item_append() writes to it, and when the remaining member is deleted it decrements ref_count and runs list_item_del() on the freed block before mod_free() fails to find it. A single playback copier whose init fails after joining the group, for example with a node_id v_index of IPC4_MAX_PIPELINE_REG_SLOTS or more, leaves the same dangling node because the e_conv path does not leave the group before mod_free_all() frees it. Allocate the group from the system user heap with sof_heap_alloc(), as data_blob.c does for memory that is not owned by one module, and free it there when the last member leaves. Leave the group on the copier_host_create() error path. hd->group_id was a uint8_t copy of the 32-bit IPC group id, so delete_from_fpi_sync_group() could release a different group than the one joined; store the full id. Fixes: ca85076 ("audio: copier: Use module API also for allocating non cached memory") Signed-off-by: Shrushti P K <shrusthi@labs.digiscrypt.com>
Collaborator
|
Can one of the admins verify this patch?
|
PR 11585: test resultsRun date: 2026-12-02 10:12 UTC Tested commit: 79775e921bcfe9fd2a7e56ada0bd08c07671b224 |
Member
|
test this please |
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Error paths after successful host creation leave group references unreleased, leaking resources and potentially blocking ID reuse with a different period.
1 open issue
What changed in this PR
Fixes shared FPI synchronization-group lifetime in host copiers so groups survive individual member deletion and are freed by their last member.
Changes:
- Moves group allocation outside individual module resource pools.
- Releases membership on host-creation failure.
- Preserves full 32-bit group IDs.
| File | Description |
|---|---|
src/audio/copier/host_copier.h |
Widens the stored group ID to 32 bits. |
src/audio/copier/copier_host.c |
Uses shared heap ownership and adds host-creation failure cleanup. |
Review effort: Balanced
Comment on lines
+70
to
+72
| group = sof_heap_alloc(sof_sys_user_heap_get(), | ||
| SOF_MEM_FLAG_USER | SOF_MEM_FLAG_COHERENT, | ||
| sizeof(*group), 0); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

add_to_fpi_sync_group()allocates thestruct fpi_sync_groupshared by every host copier in a group from the resource pool of whichever copier creates it, somod_free_all()frees it with that copier while the group is still linked ingroup_list_head:delete_from_fpi_sync_group()only unlinks the group whenref_countreaches 0. Init host copier A and host copier B with the sameHDA_SYNC_FPI_UPDATE_GROUPTLV, then delete A: the node is freed but stays in the list. The next host copier init reads it infind_group_by_id()and appends to it, and deleting B writesref_countandlist_item_del()through the freed block beforemod_free()fails because the block was never B's.node_id.v_index >= IPC4_MAX_PIPELINE_REG_SLOTS, or no converter for the format pair) leaves the same dangling node, since thee_convpath does not leave the group beforemod_free_all()runs.hd->group_idis auint8_tcopy of the 32-bit IPC group id, so for ids above 255 delete releases a different group than the one joined, or none.CONFIG_HOST_DMA_STREAM_SYNCHRONIZATIONis on by default on every ACE platform. ca85076 moved the group fromrzalloc()/rfree()to the module API; the group is cold-path state only, the runtime FPI sync inhost-zephyr.creads nothing from it.The group now comes from the system user heap through
sof_heap_alloc(sof_sys_user_heap_get(), ...), the same waydata_blob.callocates memory that is not owned by one module, and the last member frees it there. The create error path leaves the group, andgroup_idkeeps the full id. Checked the init/delete sequence above against a model of the module resource pool semantics: before the fix the next lookup reads the freed node, after it the list ends empty with nothing leaked. I could not run the Zephyr build here, so a CI pass on an ACE board with two synchronized streams is the real check.