schedule: add a core index for schedule_data

A scheduler will run on a specific scheduler only, add a core index flag
to schedule_data to denote that.

To schedule or cancel a task, looking for the scheduler with correct
core index to perform the action.

Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>
This commit is contained in:
Keyon Jie 2021-05-07 12:31:24 +08:00 committed by Liam Girdwood
parent 40c9bb2e30
commit a398e92f2e
2 changed files with 8 additions and 2 deletions

View File

@ -10,6 +10,7 @@
#define __SOF_SCHEDULE_SCHEDULE_H__
#include <sof/common.h>
#include <sof/lib/cpu.h>
#include <sof/list.h>
#include <sof/schedule/task.h>
#include <sof/trace/trace.h>
@ -122,6 +123,7 @@ struct scheduler_ops {
struct schedule_data {
struct list_item list; /**< list of schedulers */
int type; /**< SOF_SCHEDULE_ type */
uint32_t core; /**< the index of the core the scheduler run on */
const struct scheduler_ops *ops; /**< scheduler operations */
void *data; /**< pointer to private data */
};
@ -210,7 +212,8 @@ static inline int schedule_task(struct task *task, uint64_t start,
list_for_item(slist, &schedulers->list) {
sch = container_of(slist, struct schedule_data, list);
if (task->type == sch->type && sch->ops->schedule_task)
if (task->type == sch->type && sch->core == cpu_get_id() &&
sch->ops->schedule_task)
return sch->ops->schedule_task(sch->data, task, start,
period);
}
@ -249,7 +252,8 @@ static inline int schedule_task_cancel(struct task *task)
list_for_item(slist, &schedulers->list) {
sch = container_of(slist, struct schedule_data, list);
if (task->type == sch->type && sch->ops->schedule_task_cancel)
if (task->type == sch->type && sch->core == cpu_get_id() &&
sch->ops->schedule_task_cancel)
return sch->ops->schedule_task_cancel(sch->data, task);
}

View File

@ -7,6 +7,7 @@
/* Generic scheduler */
#include <sof/lib/alloc.h>
#include <sof/lib/cpu.h>
#include <sof/lib/uuid.h>
#include <sof/list.h>
#include <sof/schedule/schedule.h>
@ -66,6 +67,7 @@ void scheduler_init(int type, const struct scheduler_ops *ops, void *data)
sch->type = type;
sch->ops = ops;
sch->data = data;
sch->core = cpu_get_id();
scheduler_register(sch);
}