Skip to content

Commit c423e88

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. Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
1 parent b1acb18 commit c423e88

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
@@ -10,6 +10,7 @@
1010
#include <sof/lib/uuid.h>
1111
#include <sof/list.h>
1212
#include <sof/schedule/schedule.h>
13+
#include <sof/schedule/ll_schedule_domain.h>
1314
#include <rtos/task.h>
1415
#include <ipc/topology.h>
1516
#include <errno.h>
@@ -47,15 +48,20 @@ int schedule_task_init(struct task *task,
4748
static void scheduler_register(struct schedule_data *scheduler)
4849
{
4950
struct schedulers **sch = arch_schedulers_get();
51+
struct k_heap *heap = NULL;
52+
#ifdef CONFIG_SOF_USERSPACE_LL
53+
heap = zephyr_ll_user_heap();
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, SOF_MEM_FLAG_KERNEL,
59+
sizeof(**sch), 0);
5560
if (!*sch) {
5661
tr_err(&sch_tr, "allocation failed");
5762
return;
5863
}
64+
memset(*sch, 0, sizeof(**sch));
5965
list_init(&(*sch)->list);
6066
}
6167

@@ -65,16 +71,21 @@ static void scheduler_register(struct schedule_data *scheduler)
6571
void scheduler_init(int type, const struct scheduler_ops *ops, void *data)
6672
{
6773
struct schedule_data *sch;
74+
struct k_heap *heap = NULL;
75+
#ifdef CONFIG_SOF_USERSPACE_LL
76+
heap = zephyr_ll_user_heap();
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, SOF_MEM_FLAG_KERNEL, 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)