Skip to content

Commit 08168c0

Browse files
lyakhkv2019i
authored andcommitted
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 fe7281b commit 08168c0

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

@@ -508,6 +509,7 @@ int scheduler_dp_task_init(struct task **task, const struct sof_uuid_entry *uid,
508509
unsigned int pidx;
509510
size_t size;
510511
uintptr_t start;
512+
bool on_pool = false;
511513
struct k_mem_domain *mdom = objpool_alloc(&dp_mdom_head, sizeof(*mdom),
512514
SOF_MEM_FLAG_COHERENT);
513515

@@ -517,12 +519,14 @@ int scheduler_dp_task_init(struct task **task, const struct sof_uuid_entry *uid,
517519
goto e_thread;
518520
}
519521

522+
on_pool = true;
523+
520524
mod->mdom = mdom;
521525

522526
if (!mdom->arch.ptables) {
523527
ret = k_mem_domain_init(mdom, 0, NULL);
524528
if (ret < 0)
525-
goto e_dom;
529+
goto e_thread;
526530
}
527531

528532
/* Module heap partition */
@@ -579,7 +583,10 @@ int scheduler_dp_task_init(struct task **task, const struct sof_uuid_entry *uid,
579583

580584
e_dom:
581585
scheduler_dp_domain_free(pdata);
586+
on_pool = false;
582587
e_thread:
588+
if (on_pool)
589+
objpool_free(&dp_mdom_head, mdom);
583590
k_thread_abort(pdata->thread_id);
584591
e_kobj:
585592
/* k_object_free looks for a pointer in the list, any invalid value can be passed */

0 commit comments

Comments
 (0)