Skip to content

Commit 8892eb0

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 45cb707 commit 8892eb0

1 file changed

Lines changed: 14 additions & 4 deletions

File tree

src/schedule/schedule.c

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,20 +90,23 @@ int schedule_task_init(struct task *task,
9090
static void scheduler_register(struct schedule_data *scheduler)
9191
{
9292
struct schedulers **sch = arch_schedulers_get();
93+
struct k_heap *heap = NULL;
9394

9495
#ifdef CONFIG_SOF_USERSPACE_LL
95-
if (scheduler_is_user(scheduler->type))
96+
if (scheduler_is_user(scheduler->type)) {
9697
sch = arch_user_schedulers_get();
98+
heap = sof_sys_user_heap_get();
99+
}
97100
#endif
98101

99102
if (!*sch) {
100103
/* init schedulers list */
101-
*sch = rzalloc(SOF_MEM_FLAG_KERNEL,
102-
sizeof(**sch));
104+
*sch = sof_heap_alloc(heap, 0, sizeof(**sch), 0);
103105
if (!*sch) {
104106
tr_err(&sch_tr, "allocation failed");
105107
return;
106108
}
109+
memset(*sch, 0, sizeof(**sch));
107110
list_init(&(*sch)->list);
108111
}
109112

@@ -113,16 +116,23 @@ static void scheduler_register(struct schedule_data *scheduler)
113116
void scheduler_init(int type, const struct scheduler_ops *ops, void *data)
114117
{
115118
struct schedule_data *sch;
119+
struct k_heap *heap = NULL;
120+
121+
#ifdef CONFIG_SOF_USERSPACE_LL
122+
if (scheduler_is_user(type))
123+
heap = sof_sys_user_heap_get();
124+
#endif
116125

117126
if (!ops || !ops->schedule_task || !ops->schedule_task_cancel ||
118127
!ops->schedule_task_free)
119128
return;
120129

121-
sch = rzalloc(SOF_MEM_FLAG_KERNEL, sizeof(*sch));
130+
sch = sof_heap_alloc(heap, SOF_MEM_FLAG_KERNEL, sizeof(*sch), 0);
122131
if (!sch) {
123132
tr_err(&sch_tr, "allocation failed");
124133
sof_panic(SOF_IPC_PANIC_IPC);
125134
}
135+
memset(sch, 0, sizeof(*sch));
126136
list_init(&sch->list);
127137
sch->type = type;
128138
sch->ops = ops;

0 commit comments

Comments
 (0)