audio: component: add comp_free_device() and use it as pair of comp_a…#10551
Open
kv2019i wants to merge 1 commit intothesofproject:mainfrom
Open
audio: component: add comp_free_device() and use it as pair of comp_a…#10551kv2019i wants to merge 1 commit intothesofproject:mainfrom
kv2019i wants to merge 1 commit intothesofproject:mainfrom
Conversation
…lloc() In commit c49283a ("ptl: mmu: Introduce module driver heap for non-privileged modules"), implementation of comp_alloc() was modified to use module heap alloc functions instead of rzalloc(). The calling functions kept using direct rfree() to free the component device. In commit e8e5ff0 ("module-adapter: fix wrong memory freeing"), some of the callers were modified to use user heap functions for freeing the component device. To make this code safer, introduce comp_free_device() that frees the memory using the method used in comp_alloc() and use comp_free_device() in all places where comp_alloc() is used. The naming is a bit awkward as comp_free() is already taken to invoke the "free" method of the component interface. Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Collaborator
Author
|
@softwarecki and @lyakh please check. |
There was a problem hiding this comment.
Pull request overview
This PR introduces a new comp_free_device() function to properly pair with comp_alloc() for component device memory management. The change addresses inconsistent memory freeing patterns where comp_alloc() uses module heap allocation but some callers were using direct rfree() or user heap functions to free the memory.
Changes:
- Added
comp_free_device()function incomponent.hthat uses the same heap mechanism ascomp_alloc() - Replaced all direct
rfree(dev)calls withcomp_free_device(dev)across multiple audio component files
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/include/sof/audio/component.h | Adds new comp_free_device() function definition |
| src/samples/audio/smart_amp_test_ipc3.c | Updates smart amp component to use comp_free_device() |
| src/samples/audio/detect_test.c | Updates keyword detect component to use comp_free_device() |
| src/audio/tone/tone-ipc3.c | Updates tone generator component to use comp_free_device() |
| src/audio/selector/selector.c | Updates selector component to use comp_free_device() |
| src/audio/kpb.c | Updates key phrase buffer component to use comp_free_device() |
| src/audio/host-zephyr.c | Updates Zephyr host component to use comp_free_device() |
| src/audio/host-legacy.c | Updates legacy host component to use comp_free_device() |
| src/audio/google/google_hotword_detect.c | Updates Google hotword detector to use comp_free_device() |
| src/audio/dai-zephyr.c | Updates Zephyr DAI component to use comp_free_device() |
| src/audio/dai-legacy.c | Updates legacy DAI component to use comp_free_device() |
| src/audio/chain_dma.c | Updates chain DMA component to use comp_free_device() |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
softwarecki
approved these changes
Feb 16, 2026
Collaborator
softwarecki
left a comment
There was a problem hiding this comment.
Good change! The name is indeed a bit awkward but I don't have a better idea.
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.
…lloc()
In commit c49283a ("ptl: mmu: Introduce module driver heap for non-privileged modules"), implementation of comp_alloc() was modified to use module heap alloc functions instead of rzalloc(). The calling functions kept using direct rfree() to free the component device.
In commit e8e5ff0 ("module-adapter: fix wrong memory freeing"), some of the callers were modified to use user heap functions for freeing the component device.
To make this code safer, introduce comp_free_device() that frees the memory using the method used in comp_alloc() and use comp_free_device() in all places where comp_alloc() is used. The naming is a bit awkward as comp_free() is already taken to invoke the "free" method of the component interface.