Skip to content

Conversation

@jsarha
Copy link
Contributor

@jsarha jsarha commented Aug 26, 2025

Modules ASRC, Aria, Copier, crossover, multiband_drc, and DRC were aready once reviewed as part of #10164 .

@jsarha jsarha force-pushed the module_api_rest_of_the_modules branch 3 times, most recently from 5a81bd2 to 69b18c4 Compare August 27, 2025 14:40
@jsarha jsarha force-pushed the module_api_rest_of_the_modules branch 3 times, most recently from 6067aa8 to 32e83e3 Compare September 3, 2025 16:08
Comment on lines 193 to 194
else
ptr = rballoc(SOF_MEM_FLAG_USER, size);
ptr = rmalloc(SOF_MEM_FLAG_USER, size);
Copy link
Member

Choose a reason for hiding this comment

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

Should we also rmalloc_aligned() above for rballoc_aligned()

Copy link
Contributor Author

@jsarha jsarha Sep 4, 2025

Choose a reason for hiding this comment

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

That is a good question. Pretty much the same as should we use virtual heap in the modules at all? There were some rballoc_aligned() calls in the modules, but I do not recall any rmalloc_aligned() calls.

And there is a reason for that. There is no rmalloc_aligned() at the moment. I can of cource easily create one in zephyr/lib/alloc.c and follow the pattern that call is alway forwarded to zephyr system heap. Should I take that route?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I created rmalloc_align() and took that into use.

@jsarha jsarha force-pushed the module_api_rest_of_the_modules branch 2 times, most recently from 6d16a80 to 8f5ea1c Compare September 4, 2025 18:33
@jsarha jsarha marked this pull request as ready for review September 5, 2025 08:37
Copilot AI review requested due to automatic review settings September 5, 2025 08:37
@jsarha
Copy link
Contributor Author

jsarha commented Sep 5, 2025

Please let me know if you want me to split this into multiple PRs.

This comment was marked as outdated.

@jsarha jsarha force-pushed the module_api_rest_of_the_modules branch from 8f5ea1c to 2337ac2 Compare September 5, 2025 08:46
Jyri Sarha added 25 commits October 21, 2025 12:13
Convert auditory, dct, fft, and matrix math tests to use module heap
API functions instead of the old version using rmalloc() and friends
directly.

Signed-off-by: Jyri Sarha <jyri.sarha@linux.intel.com>
Both unit tests and modules should now use the module API heap
allocation functions, so we can now remove the directly heap using
versions.

Signed-off-by: Jyri Sarha <jyri.sarha@linux.intel.com>
Allocate all memory, blob handlers, and fast_get() buffers through
module API mod_alloc() and friends and remove all redundant rfree(),
comp_data_blob_handler_free(), and fast_put() calls from module unload
functions and init error branches.

Signed-off-by: Jyri Sarha <jyri.sarha@linux.intel.com>
Allocate all memory, blob handlers, and fast_get() buffers through
module API mod_alloc() and friends and remove all redundant rfree(),
comp_data_blob_handler_free(), and fast_put() calls from module unload
functions and init error branches.

Signed-off-by: Jyri Sarha <jyri.sarha@linux.intel.com>
Allocate all memory, blob handlers, and fast_get() buffers through
module API mod_alloc() and friends and remove all redundant rfree(),
comp_data_blob_handler_free(), and fast_put() calls from module unload
functions and init error branches.

Signed-off-by: Jyri Sarha <jyri.sarha@linux.intel.com>
Allocate all memory, blob handlers, and fast_get() buffers through
module API mod_alloc() and friends and remove all redundant rfree(),
comp_data_blob_handler_free(), and fast_put() calls from module unload
functions and init error branches. The rballoc() calls are converted
to mod_balloc(), except module pdata is allocated with mod_alloc() as
its obviously not an audio buffer.

Signed-off-by: Jyri Sarha <jyri.sarha@linux.intel.com>
Allocate all memory, blob handlers, and fast_get() buffers through
module API mod_alloc() and friends and remove all redundant rfree(),
comp_data_blob_handler_free(), and fast_put() calls from module unload
functions and init error branches.

However, the rtnr_stub's heap access, rtk_alloc() and rtk_free() still
use heap directly like before.

Signed-off-by: Jyri Sarha <jyri.sarha@linux.intel.com>
Allocate all memory, blob handlers, and fast_get() buffers through
module API mod_alloc() and friends and remove all redundant rfree(),
comp_data_blob_handler_free(), and fast_put() calls from module unload
functions and init error branches.

The IPC3 implementation of selector uses the component interface
directly and can not use the new module API.

Signed-off-by: Jyri Sarha <jyri.sarha@linux.intel.com>
Allocate all memory, blob handlers, and fast_get() buffers through
module API mod_alloc() and friends and remove all redundant rfree(),
comp_data_blob_handler_free(), and fast_put() calls from module unload
functions and init error branches. The one rballoc() call is converted
to mod_balloc().

Signed-off-by: Jyri Sarha <jyri.sarha@linux.intel.com>
Allocate all memory, blob handlers, and fast_get() buffers through
module API mod_alloc() and friends and remove all redundant rfree(),
comp_data_blob_handler_free(), and fast_put() calls from module unload
functions and init error branches.

Signed-off-by: Jyri Sarha <jyri.sarha@linux.intel.com>
Allocate all memory, blob handlers, and fast_get() buffers through
module API mod_alloc() and friends and remove all redundant rfree(),
comp_data_blob_handler_free(), and fast_put() calls from module unload
functions and init error branches.

Signed-off-by: Jyri Sarha <jyri.sarha@linux.intel.com>
Allocate all memory, blob handlers, and fast_get() buffers through
module API mod_alloc() and friends and remove all redundant rfree(),
comp_data_blob_handler_free(), and fast_put() calls from module unload
functions and init error branches. The two rballoc() calls are
converted to mod_balloc().

Signed-off-by: Jyri Sarha <jyri.sarha@linux.intel.com>
Allocate all memory, blob handlers, and fast_get() buffers through
module API mod_alloc() and friends and remove all redundant rfree(),
comp_data_blob_handler_free(), and fast_put() calls from module unload
functions and init error branches.

Signed-off-by: Jyri Sarha <jyri.sarha@linux.intel.com>
Add mod_psy_free_mel_filterbank() for freeing the allocated memory.

Signed-off-by: Jyri Sarha <jyri.sarha@linux.intel.com>
Fix memory leaks from auditory cmocka test.

Signed-off-by: Jyri Sarha <jyri.sarha@linux.intel.com>
Fix all memory leaks found from fft test when tests were run under
Valgrind.

Signed-off-by: Jyri Sarha <jyri.sarha@linux.intel.com>
Fix all memory leaks found from matrix test when tests were run under
Valgrind.

Signed-off-by: Jyri Sarha <jyri.sarha@linux.intel.com>
Add mod_dct_free_16() to free memory allocated by mod_dct_initialize_16().

Signed-off-by: Jyri Sarha <jyri.sarha@linux.intel.com>
Fix memory leaks found by running the tests with Valgrind.

Signed-off-by: Jyri Sarha <jyri.sarha@linux.intel.com>
Fix memory freeing error from module_adapter_test_free(). Use
free_test_source() for sources, not free_test_sink().

Signed-off-by: Jyri Sarha <jyri.sarha@linux.intel.com>
Fix all memory leaks found from volume test when tests were run under
Valgrind.

Signed-off-by: Jyri Sarha <jyri.sarha@linux.intel.com>
Fix all memory leaks found from mux_copy test when tests were run under
Valgrind.

Signed-off-by: Jyri Sarha <jyri.sarha@linux.intel.com>
Fix all memory leaks found from demux_copy test when tests were run under
Valgrind.

Signed-off-by: Jyri Sarha <jyri.sarha@linux.intel.com>
Fix all memory leaks found from all pipeline tests when tests were run
under Valgrind.

Signed-off-by: Jyri Sarha <jyri.sarha@linux.intel.com>
@jsarha jsarha force-pushed the module_api_rest_of_the_modules branch from c624018 to fce2c50 Compare October 21, 2025 09:13
The current rballoc_align() implementation has this line:
assert(IS_ALIGNED(mem, align));

Which will cause division by zero due to IS_ALIGNED() Zephyr
implementation:
define IS_ALIGNED(ptr, align) (((uintptr_t)(ptr)) % (align) == 0)

So better use sizeof(void *) as the default value.

Signed-off-by: Jyri Sarha <jyri.sarha@linux.intel.com>
@jsarha jsarha force-pushed the module_api_rest_of_the_modules branch from f042224 to c449fe3 Compare October 24, 2025 12:17
@jsarha
Copy link
Contributor Author

jsarha commented Nov 12, 2025

All these commits, or their further developed versions have been merged.

@jsarha jsarha closed this Nov 12, 2025
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