Skip to content

Commit c9ffda6

Browse files
committed
dp: clear memory domain when freeing
Recently a new function has been added to Zephyr to safely remove memory domains. Use it when releasing domains in SOF DP. Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
1 parent 2aec30f commit c9ffda6

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

src/schedule/zephyr_dp_schedule_application.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,7 @@ static void scheduler_dp_domain_free(struct task_dp_pdata *pdata)
387387

388388
/* All partitions removed, the domain can be freed now */
389389
pmod->mdom = NULL;
390+
k_mem_domain_deinit(mdom);
390391
objpool_free(&dp_mdom_head, mdom);
391392
}
392393

@@ -506,6 +507,7 @@ int scheduler_dp_task_init(struct task **task, const struct sof_uuid_entry *uid,
506507
unsigned int pidx;
507508
size_t size;
508509
uintptr_t start;
510+
bool on_pool = false;
509511
struct k_mem_domain *mdom = objpool_alloc(&dp_mdom_head, sizeof(*mdom),
510512
SOF_MEM_FLAG_COHERENT);
511513

@@ -515,12 +517,14 @@ int scheduler_dp_task_init(struct task **task, const struct sof_uuid_entry *uid,
515517
goto e_thread;
516518
}
517519

520+
on_pool = true;
521+
518522
mod->mdom = mdom;
519523

520524
if (!mdom->arch.ptables) {
521525
ret = k_mem_domain_init(mdom, 0, NULL);
522526
if (ret < 0)
523-
goto e_dom;
527+
goto e_thread;
524528
}
525529

526530
/* Module heap partition */
@@ -577,7 +581,10 @@ int scheduler_dp_task_init(struct task **task, const struct sof_uuid_entry *uid,
577581

578582
e_dom:
579583
scheduler_dp_domain_free(pdata);
584+
on_pool = false;
580585
e_thread:
586+
if (on_pool)
587+
objpool_free(&dp_mdom_head, mdom);
581588
k_thread_abort(pdata->thread_id);
582589
e_kobj:
583590
/* k_object_free looks for a pointer in the list, any invalid value can be passed */

0 commit comments

Comments
 (0)