Skip to content

Commit dd4fea4

Browse files
author
Jyri Sarha
committed
audio: module_adapter: use sof_ctx_alloc/free in generic.c
Replace the open-coded vregion vs heap allocation and free patterns in z_impl_mod_alloc_ext() and free_contents() with the new sof_ctx_alloc() and sof_ctx_free() wrappers. Signed-off-by: Jyri Sarha <jyri.sarha@linux.intel.com>
1 parent d357b22 commit dd4fea4

1 file changed

Lines changed: 3 additions & 14 deletions

File tree

src/audio/module_adapter/module/generic.c

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include <sof/audio/data_blob.h>
1919
#include <sof/lib/fast-get.h>
2020
#include <sof/lib/vregion.h>
21+
#include <sof/ctx_alloc.h>
2122
#include <sof/schedule/dp_schedule.h>
2223
#if CONFIG_IPC_MAJOR_4
2324
#include <ipc4/header.h>
@@ -252,16 +253,7 @@ void *z_impl_mod_alloc_ext(struct processing_module *mod, uint32_t flags, size_t
252253
}
253254

254255
/* Allocate memory for module */
255-
void *ptr;
256-
257-
if (!res->alloc->vreg)
258-
ptr = sof_heap_alloc(res->alloc->heap, flags, size, alignment);
259-
else if (flags & SOF_MEM_FLAG_COHERENT)
260-
ptr = vregion_alloc_coherent_align(res->alloc->vreg, VREGION_MEM_TYPE_INTERIM,
261-
size, alignment);
262-
else
263-
ptr = vregion_alloc_align(res->alloc->vreg, VREGION_MEM_TYPE_INTERIM,
264-
size, alignment);
256+
void *ptr = sof_ctx_alloc(res->alloc, flags, size, alignment);
265257

266258
if (!ptr) {
267259
comp_err(mod->dev, "Failed to alloc %zu bytes %zu alignment for comp %#x.",
@@ -362,10 +354,7 @@ static int free_contents(struct processing_module *mod, struct module_resource *
362354

363355
switch (container->type) {
364356
case MOD_RES_HEAP:
365-
if (res->alloc->vreg)
366-
vregion_free(res->alloc->vreg, container->ptr);
367-
else
368-
sof_heap_free(res->alloc->heap, container->ptr);
357+
sof_ctx_free(res->alloc, container->ptr);
369358
res->heap_usage -= container->size;
370359
return 0;
371360
#if CONFIG_COMP_BLOB

0 commit comments

Comments
 (0)