Skip to content

Commit dd0601e

Browse files
committed
wip: vregion: add DP module support for vregion.
Make DP modules use their own vregion for allocations. TODO: abstract usage. Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
1 parent 0368ed0 commit dd0601e

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

src/schedule/zephyr_dp_schedule.c

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,13 @@ static int scheduler_dp_task_free(void *data, struct task *task)
411411
#endif
412412

413413
/* free task stack */
414+
#if CONFIG_SOF_VREGIONS
415+
struct vregion *vregion = module_get_vregion(pdata->mod);
416+
vregion_free(vregion, (__sparse_force void *)pdata->p_stack);
417+
ret = 0;
418+
#else
414419
ret = user_stack_free((__sparse_force void *)pdata->p_stack);
420+
#endif
415421
pdata->p_stack = NULL;
416422

417423
/* all other memory has been allocated as a single malloc, will be freed later by caller */
@@ -599,6 +605,7 @@ int scheduler_dp_task_init(struct task **task,
599605
{
600606
void __sparse_cache *p_stack = NULL;
601607
struct sys_heap *const user_heap = mod->dev->drv->user_heap;
608+
struct vregion *vregion = module_get_vregion(mod);
602609

603610
/* memory allocation helper structure */
604611
struct {
@@ -611,6 +618,21 @@ int scheduler_dp_task_init(struct task **task,
611618
/* must be called on the same core the task will be binded to */
612619
assert(cpu_get_id() == core);
613620

621+
#if CONFIG_SOF_VREGIONS
622+
//TODO: add check if vregion is in correct memory domain/coherent
623+
task_memory = vregion_alloc_align(vregion, VREGION_MEM_TYPE_LIFETIME_SHARED,
624+
sizeof(*task_memory), CONFIG_DCACHE_LINE_SIZE);
625+
if (!task_memory) {
626+
tr_err(&dp_tr, "vregion task memory alloc failed");
627+
return -ENOMEM;
628+
}
629+
p_stack = vregion_alloc_align(vregion, VREGION_MEM_TYPE_LIFETIME,
630+
stack_size, CONFIG_DCACHE_LINE_SIZE);
631+
if (!p_stack) {
632+
tr_err(&dp_tr, "vregion stack alloc failed");
633+
return -ENOMEM;
634+
}
635+
#else
614636
/*
615637
* allocate memory
616638
* to avoid multiple malloc operations allocate all required memory as a single structure
@@ -632,7 +654,7 @@ int scheduler_dp_task_init(struct task **task,
632654
ret = -ENOMEM;
633655
goto err;
634656
}
635-
657+
#endif /* CONFIG_SOF_VREGION */
636658
/* internal SOF task init */
637659
ret = schedule_task_init(&task_memory->task, uid, SOF_SCHEDULE_DP, 0, ops->run,
638660
mod, core, options);

0 commit comments

Comments
 (0)