-
Notifications
You must be signed in to change notification settings - Fork 349
Module API additions and conversion of some modules to use them #10164
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Module API additions and conversion of some modules to use them #10164
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces new module adapter resource management APIs and converts several audio processing modules to use them. The changes improve resource tracking and provide automated cleanup functionality for modules.
- Adds a new module resource management system with containers and tracking capabilities
- Introduces convenience APIs for memory allocation, data blob handlers, and SRAM copies
- Converts multiple audio modules (crossover, multiband DRC, DRC, copier, ASRC, aria, SRC) to use the new APIs
Reviewed Changes
Copilot reviewed 19 out of 19 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| zephyr/sof_shell.c | Updates shell command to display heap high watermark alongside current usage |
| src/include/sof/audio/module_adapter/module/generic.h | Adds new module_resources structure and declares new module allocation APIs |
| src/include/module/module/base.h | Changes module_data to use module_resources instead of module_memory |
| src/include/module/crossover/crossover_common.h | Updates crossover functions to accept processing_module parameter for resource tracking |
| src/audio/module_adapter/module_adapter.c | Simplifies heap usage tracking using new resource structure |
| src/audio/module_adapter/module/generic.c | Implements new resource management system with container pooling and automatic cleanup |
| src/audio/multiband_drc/multiband_drc.h | Updates multiband DRC reset function signature |
| src/audio/multiband_drc/multiband_drc.c | Converts multiband DRC to use new module APIs and removes manual cleanup |
| src/audio/drc/drc_algorithm.h | Updates DRC function signatures for new module API |
| src/audio/drc/drc.c | Converts DRC module to use new allocation APIs |
| src/audio/crossover/crossover.c | Converts crossover module to use new allocation APIs and removes manual cleanup |
| src/audio/copier/copier.c | Updates copier module to use new allocation APIs |
| src/audio/asrc/* | Converts ASRC module to use new allocation APIs throughout |
| src/audio/aria/aria.c | Converts aria module to use new allocation APIs |
| src/audio/src/src_common.c | Updates SRC to use new mod_fast_get/put APIs |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.
lgirdwood
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One open, btw I would split the PR as some fixes could be taken now.
4b6d75a to
b1f58e8
Compare
4ddea61 to
b5b500e
Compare
kv2019i
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some minor nits, but looks good. I'd keep this as module interface changes/additions, one or two example modules converted and not put more into the PR. This is already lot of code to go through and some of the changes really require attention. I'd expect the module conversions to be more mechanistics changes that will be easier to review as separate PRs. Unless there is some dependencies I'm missing, but seems this is an opt-in migration process here.
lgirdwood
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just minor comments.
| struct module_memory *container = container_get(mod); | ||
| struct comp_data_blob_handler *dbh; | ||
|
|
||
| #if DEBUG |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to make this cleaner I would define a macro (based on above Kconfig) and using zephyr type asserts at the top of the file (if config=n then macro is empty). This gets rid of the #if DEBUG all over the file.
|
|
||
| container->ptr = dbh; | ||
| container->size = 0; | ||
| container->free = (void (*)(void *))comp_data_blob_handler_free; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jsarha in #10164 (comment) I was also (implicitly) suggesting to fix this typecast too, because it's effectively also dropping const. Since you'll be fixing PTL CI failures, we still have a chance to fix this too, or we can make that a follow-up, shouldn't be critical
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The PTL failures - is that a problem with sof-test? Looks like kernel module unloading is failing
|
SOFCI TEST |
c66734f to
36463e2
Compare
lyakh
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no more const-dropping, thanks!
| list_item_del(&mem->mem_list); | ||
| container_put(mod, mem); | ||
| return 0; | ||
| list_for_item_safe(res_list, _res_list, &res->res_list) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need for _safe() here - you return once a match is found and the element is deleted
80af2e7 to
d48ced9
Compare
|
Whoa. What a tedious job to stitch the cmocka test together again after the previous, seamingly straight forward, change. If all the CI tests are still broken after this, I am considering going back to previous version, as @lyakh is on vacation and noone else complained about the casts I got rid off. |
Add mod_data_blob_handler_new() to module API. The function is otherwise the same as comp_data_blob_handler_new(), but it takes a module pointer as the first argument, and the blob handler is automatically freed when the module unloads. The handler allocated with mod_data_blob_handler_new() should not be freed with comp_data_blob_handler_free(), mod_data_blob_handler_free() should be used. Signed-off-by: Jyri Sarha <jyri.sarha@linux.intel.com>
d48ced9 to
22f8892
Compare
|
SOFCI TEST |
|
About the CI issues, the eq_fir and eq_iir cmocka failures are probably not related to this PR (they appear also on this test PR, tha only has the first commit of this PR and eq_fir or eq_iir modules have not yet been converted): #10196 But the pass rate on regular CI tests is so much worse with my full PR that it requires much more testing from me. Unfortunately the reasons for PTL failures are not clear at all, so I put my effort on the couple of failures seen on LNL that are not there on the above test PR. |
Ack - @singalsu can you take care of the EQ bug.
Ok, lets break the full PR down into smaller chunks to debug. |
Add module API versions of fast_get() and fast_put(). The SRAM copies reserved with mod_fast_get() are released automatically when the module unloads, and those SRAM copies should not be freed with the regular fast_put(). The sram-copy allocated with mod_fast_get() should not be freed with regular fast_put(), but mod_fast_put() should be used. Signed-off-by: Jyri Sarha <jyri.sarha@linux.intel.com>
Add safeguard to mod_alloc() and friends that checks that they are always called from the same thread (e.g. no locking needed). The checking code has to be also behind defined(__ZEPHYR__) to keep cmocka tests working. Signed-off-by: Jyri Sarha <jyri.sarha@linux.intel.com>
…ree() Use list_for_item() instead of list_for_item_safe() in mod_free(). There is no need for *_safe() version when loop is not continued after an element is removed from the list. Signed-off-by: Jyri Sarha <jyri.sarha@linux.intel.com>
Take mod_fast_get() and mod_fast_put() into use. Signed-off-by: Jyri Sarha <jyri.sarha@linux.intel.com>
22f8892 to
289efb1
Compare
|
Drop the most of module conversions (except for SRC, that was already partly converted, but needed the mod_fast_get() change) and leave the API additions. Hopefully this performes better in the CI and once the API changes are merged, push the individual module changes as separate PRs in parallel to find out which modules cause the CI problems. The module conversions and cmocka fixes on top of this PRs are here in this huge draft PR: #10195 |
|
@lgirdwood now the PTL failure pattern is the same as in this close to mainline PR: #10196 Could we merge this now, so I could start sending the module conversion separately, to se which ones are broken? |
|
Internal CI fail not related to this PR |
|
So with this PR, the only module converted is the SRC, which I have been manually testing through out the development process. In addition to SRC the only modules affected by the memory API changes the modules that used the old module_allocate_memory() and friends, e.g. dts, cadence, and waves (see 2a87a79). |
|
@lgirdwood , Here is also logs from SRC (the only fully converted module in this PR) testbench run through Valgrind. No memoryleaks or other problems deteceted. I think this PR should now be ready to merge. (The earlier edit was false alarm, these are x86 results) |
Change all comp id prints from %d to %#x for better readability. Signed-off-by: Jyri Sarha <jyri.sarha@linux.intel.com>
Yep, I think some module/buffers API related changes have been left out from EQ cmocka test code. The segfault in x86 run happens in module adapter with a null pointer. |
I pushed this out for review already now even if there is more modules to convert, to get some early feedback from my additions and changes to the module resource API.