Skip to content

Commit f398430

Browse files
committed
schedule: allocate the scheduler objects with sof_heap_alloc()
Ensure the scheduler objects and lists of schedulers are allocated such that they can be used with both kernel and user-space LL scheduler implementations. The SOF_MEM_FLAG_KERNEL flag is removed. This flag has been a no-op for a while, and given scheduler list is not always in kernel anymore, it would be highly confusing to keep it. When CONFIG_SOF_USERSPACE_LL is set, the context of all schedulers is managed in the LL user-space domain. Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
1 parent 4da3a94 commit f398430

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

src/schedule/schedule.c

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,18 +84,21 @@ int schedule_task_init(struct task *task,
8484
static void scheduler_register(struct schedule_data *scheduler)
8585
{
8686
struct schedulers **sch = arch_schedulers_get();
87+
struct k_heap *heap = NULL;
8788

88-
if (IS_ENABLED(CONFIG_SOF_USERSPACE_LL) && scheduler_is_user(scheduler->type))
89+
if (IS_ENABLED(CONFIG_SOF_USERSPACE_LL) && scheduler_is_user(scheduler->type)) {
8990
sch = arch_user_schedulers_get();
91+
heap = sof_sys_user_heap_get();
92+
}
9093

9194
if (!*sch) {
9295
/* init schedulers list */
93-
*sch = rzalloc(SOF_MEM_FLAG_KERNEL,
94-
sizeof(**sch));
96+
*sch = sof_heap_alloc(heap, 0, sizeof(**sch), 0);
9597
if (!*sch) {
9698
tr_err(&sch_tr, "allocation failed");
9799
return;
98100
}
101+
memset(*sch, 0, sizeof(**sch));
99102
list_init(&(*sch)->list);
100103
}
101104

@@ -105,16 +108,21 @@ static void scheduler_register(struct schedule_data *scheduler)
105108
void scheduler_init(int type, const struct scheduler_ops *ops, void *data)
106109
{
107110
struct schedule_data *sch;
111+
struct k_heap *heap = NULL;
112+
113+
if (IS_ENABLED(CONFIG_SOF_USERSPACE_LL) && scheduler_is_user(type))
114+
heap = sof_sys_user_heap_get();
108115

109116
if (!ops || !ops->schedule_task || !ops->schedule_task_cancel ||
110117
!ops->schedule_task_free)
111118
return;
112119

113-
sch = rzalloc(SOF_MEM_FLAG_KERNEL, sizeof(*sch));
120+
sch = sof_heap_alloc(heap, SOF_MEM_FLAG_KERNEL, sizeof(*sch), 0);
114121
if (!sch) {
115122
tr_err(&sch_tr, "allocation failed");
116123
sof_panic(SOF_IPC_PANIC_IPC);
117124
}
125+
memset(sch, 0, sizeof(*sch));
118126
list_init(&sch->list);
119127
sch->type = type;
120128
sch->ops = ops;

0 commit comments

Comments
 (0)