Skip to content

Commit 1f2b5c4

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 remevod. 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 c351193 commit 1f2b5c4

1 file changed

Lines changed: 14 additions & 3 deletions

File tree

src/schedule/schedule.c

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,20 @@ int schedule_task_init(struct task *task,
4747
static void scheduler_register(struct schedule_data *scheduler)
4848
{
4949
struct schedulers **sch = arch_schedulers_get();
50+
struct k_heap *heap = NULL;
51+
52+
#ifdef CONFIG_SOF_USERSPACE_LL
53+
heap = sof_sys_user_heap_get();
54+
#endif
5055

5156
if (!*sch) {
5257
/* init schedulers list */
53-
*sch = rzalloc(SOF_MEM_FLAG_KERNEL,
54-
sizeof(**sch));
58+
*sch = sof_heap_alloc(heap, 0, sizeof(**sch), 0);
5559
if (!*sch) {
5660
tr_err(&sch_tr, "allocation failed");
5761
return;
5862
}
63+
memset(*sch, 0, sizeof(**sch));
5964
list_init(&(*sch)->list);
6065
}
6166

@@ -65,16 +70,22 @@ static void scheduler_register(struct schedule_data *scheduler)
6570
void scheduler_init(int type, const struct scheduler_ops *ops, void *data)
6671
{
6772
struct schedule_data *sch;
73+
struct k_heap *heap = NULL;
74+
75+
#ifdef CONFIG_SOF_USERSPACE_LL
76+
heap = sof_sys_user_heap_get();
77+
#endif
6878

6979
if (!ops || !ops->schedule_task || !ops->schedule_task_cancel ||
7080
!ops->schedule_task_free)
7181
return;
7282

73-
sch = rzalloc(SOF_MEM_FLAG_KERNEL, sizeof(*sch));
83+
sch = sof_heap_alloc(heap, 0, sizeof(*sch), 0);
7484
if (!sch) {
7585
tr_err(&sch_tr, "allocation failed");
7686
sof_panic(SOF_IPC_PANIC_IPC);
7787
}
88+
memset(sch, 0, sizeof(*sch));
7889
list_init(&sch->list);
7990
sch->type = type;
8091
sch->ops = ops;

0 commit comments

Comments
 (0)