Skip to content

Conversation

@jsarha
Copy link
Contributor

@jsarha jsarha commented Oct 8, 2025

No description provided.

lrgirdwo and others added 30 commits October 8, 2025 12:49
Currently the symlink for sof-ipc4/platform/sof-basefw.ri is not
created. Fix this so that deployable builds can be copied directly
to target from staging directory.

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Add a simple page allocator that will manage and allocate continuous pages
from a virtual memory region and map them to non continuous physical pages.

Simplicity is due to fixed block size, max number of blocks and continuous
allocations only.

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Add support for Pre Allocated COntinuous Virtual Regions that support
bulk static memory allocation is a linear heap and temporary allocations
in a zephyr heap.

The intention is that we map the batch/bulk allocations from pipeline
and module construction to the linear heap for more concentrated memory
page usage that also means module objects will also be closer in cache.

We will also allocate the more temporary runtime configuration data to
the zephyr heap within the PACOVR so that they can be freed and re-allocated
on runtime changes. This again keeps the pipeline runtime data concentrated
in less pages and closer in cache.

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
PACOVR and VMH are mutually exclusive. Make sure we only build one.

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Allocate a PACOVR on pipeline construction and destroy PACOVR on pipeline
destruction.

TODO: get the static/dynamic heap sizes from topology.

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Use the PACOVR static linear heap for module initialization allocations and
the dynamic heap for runtime module allocations.

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Allocate all memory through module API mod_alloc() and friends and
remove all redundant rfree() 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 through module API mod_alloc() and friends
and remove all redundant rfree() calls from module unload
functions and init error branches.

NOTE: copier_dai.c and copier_host.c still have their shared memory
allocated through the old API. This is to be fixed once we have
decided on how the shared memory allocations should work in
user-space.

Signed-off-by: Jyri Sarha <jyri.sarha@linux.intel.com>
The code within #if CONFIG_HOST_DMA_STREAM_SYNCHRONIZATION should free
host_common resources in case of failure. The commit fixes the issue.

Signed-off-by: Jyri Sarha <jyri.sarha@linux.intel.com>
Allocate all memory through module API mod_alloc() and friends
and remove all redundant rfree() 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 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. 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. The one rballoc() call is converted
to mod_balloc().

The change does not touch the google_ctc_audio_processing.h API or its
mock implementation, that still uses rballoc() and rfree().

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 change does not touch the google_rtc_audio_processing.h API or its
mock implementation, that still uses rballoc() and rfree().

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>
Make mod_alloc() versions of all heap using functions. The new functions
are simple copy-paste versions of the original, just using mod_alloc()
and friend instead of rmalloc() friends.

The idea is to get rid off the original versions once all the modules
are converted to module API heap usage and the cmocka math tests have
been fixed to work with mod_alloc() 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>
Add mocks for mod_balloc_align() and mod_alloc_align(). These dummy
versions do not keep track of the allocated memory or provide real
control over alignment. They just forward the calls to regular
malloc() and free().

Signed-off-by: Jyri Sarha <jyri.sarha@linux.intel.com>
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>
Jyri Sarha and others added 22 commits October 8, 2025 15:19
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>
Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Set the pipeline pointer during init for all modules and remove the code
from copier init.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Factor out resource initialization so that it can be reused.
While at it get rid of md variable.

Signed-off-by: Daniel Baluta <daniel.baluta@nxp.com>
Remove any containers from the free container list so that
we don't keep pointers to containers that are no longer used
and will be freed when container chunks are released below.

Leaving those nodes in the free container list would cause
use-after-free on subsequent allocations.

While at it, make sure all resource lists are reset.

Signed-off-by: Daniel Baluta <daniel.baluta@nxp.com>
@jsarha jsarha force-pushed the module_api_module_conversions_test branch from 88d4a6c to 3c9c05f Compare October 17, 2025 12:04
Jyri Sarha added 4 commits October 22, 2025 22:33
Call mod_free_all() if module specific init fails. This fixes a resource
leak in case the module initialization fails in module specific init.

Signed-off-by: Jyri Sarha <jyri.sarha@linux.intel.com>
Rewrite misleading copy-pasted comment and remove unnecessary
container removals from res->res_list and res->cont_chunk_list. All
the containers are anyway freed when the container chunks are freed
and the list heads are reinitialized when mod_resource_init() is
called.

Signed-off-by: Jyri Sarha <jyri.sarha@linux.intel.com>
Make IS_ALIGNED() safe for testing with alignment == 0. Without this fix
the DSP will crash if alignemnet is 0.

Signed-off-by: Jyri Sarha <jyri.sarha@linux.intel.com>
@jsarha jsarha force-pushed the module_api_module_conversions_test branch from f76c164 to eded27a Compare October 22, 2025 20:54
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