Skip to content

Commit 4c33deb

Browse files
author
Jyri Sarha
committed
audio: module_adapter: add vregion_type to mod_alloc_ctx
Add a vregion_type field to struct mod_alloc_ctx to track the current vregion allocation mode for each module. Initialize it to VREGION_MEM_TYPE_LIFETIME during module_adapter_mem_alloc() so that all allocations during module creation and init use the lifetime partition. Switch it to VREGION_MEM_TYPE_INTERIM at the start of module_adapter_prepare() so that runtime allocations use the interim partition. Signed-off-by: Jyri Sarha <jyri.sarha@linux.intel.com>
1 parent 4779c33 commit 4c33deb

2 files changed

Lines changed: 6 additions & 0 deletions

File tree

src/audio/module_adapter/module_adapter.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,8 @@ struct processing_module *module_adapter_mem_alloc(const struct comp_driver *drv
149149
memset(mod, 0, sizeof(*mod));
150150
alloc->heap = mod_heap;
151151
alloc->vreg = mod_vreg;
152+
/* Set vreg type to lifetime mode first, will become interim in module_adapter_prepare() */
153+
alloc->vregion_type = VREGION_MEM_TYPE_LIFETIME;
152154
mod->priv.resources.alloc = alloc;
153155
mod_resource_init(mod);
154156

@@ -422,6 +424,9 @@ int module_adapter_prepare(struct comp_dev *dev)
422424
int i = 0;
423425

424426
comp_dbg(dev, "start");
427+
428+
/* Prepare has been called, from now on all vreg allocs should be INTERIM. */
429+
mod->priv.resources.alloc->vregion_type = VREGION_MEM_TYPE_INTERIM;
425430
#if CONFIG_IPC_MAJOR_4
426431
/* allocate stream_params and retrieve the params from the basecfg if needed */
427432
if (!mod->stream_params) {

src/include/sof/audio/component.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -584,6 +584,7 @@ struct vregion;
584584
struct mod_alloc_ctx {
585585
struct k_heap *heap;
586586
struct vregion *vreg;
587+
int vregion_type; /* enum vregion_mem_type */
587588
};
588589

589590
/**

0 commit comments

Comments
 (0)