[Sound-open-firmware] [PATCH] scheduler: enforce locking for edf_schedule list operations
make sure our task list is protected by lock for readers and writers.
Signed-off-by: Liam Girdwood liam.r.girdwood@linux.intel.com --- src/lib/schedule.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/src/lib/schedule.c b/src/lib/schedule.c index 993f94a..ab0602b 100644 --- a/src/lib/schedule.c +++ b/src/lib/schedule.c @@ -102,10 +102,15 @@ static inline struct task *edf_get_next(uint64_t current, uint64_t delta; uint64_t deadline; int reschedule = 0; + uint32_t flags;
+ spin_lock_irq(&sch->lock, flags); + /* any tasks in the scheduler ? */ - if (list_is_empty(&sch->list)) + if (list_is_empty(&sch->list)) { + spin_unlock_irq(&sch->lock, flags); return NULL; + }
/* check every queued or running task in list */ list_for_item_safe(clist, tlist, &sch->list) { @@ -142,6 +147,7 @@ static inline struct task *edf_get_next(uint64_t current, } }
+ spin_unlock_irq(&sch->lock, flags); return next_task; }
@@ -164,20 +170,15 @@ static struct task *schedule_edf(void) struct task *task; struct task *next_plus1_task = NULL; uint64_t current; - uint32_t flags;
tracev_pipe("edf");
- /* get next component scheduled */ - spin_lock_irq(&sch->lock, flags); - /* get the current time */ current = platform_timer_get(platform_timer);
/* get next task to be scheduled */ task = edf_get_next(current, NULL);
- spin_unlock_irq(&sch->lock, flags); interrupt_clear(PLATFORM_SCHEDULE_IRQ);
/* any tasks ? */
Make sure error trace uses 64 bit timestamps too.
Signed-off-by: Liam Girdwood liam.r.girdwood@linux.intel.com --- src/lib/trace.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/src/lib/trace.c b/src/lib/trace.c index b0b32d6..ebe2d31 100644 --- a/src/lib/trace.c +++ b/src/lib/trace.c @@ -48,7 +48,7 @@ static struct trace trace; void _trace_error(uint32_t event) { unsigned long flags; - volatile uint32_t *t; + volatile uint64_t *t;
if (!trace.enable) return; @@ -60,14 +60,14 @@ void _trace_error(uint32_t event) spin_lock_irq(&trace.lock, flags);
/* write timestamp and event to trace buffer */ - t =(volatile uint32_t*)(MAILBOX_TRACE_BASE + trace.pos); + t =(volatile uint64_t*)(MAILBOX_TRACE_BASE + trace.pos); t[0] = platform_timer_get(platform_timer); t[1] = event;
/* writeback trace data */ - dcache_writeback_region((void*)t, sizeof(uint32_t) * 2); + dcache_writeback_region((void*)t, sizeof(uint64_t) * 2);
- trace.pos += (sizeof(uint32_t) << 1); + trace.pos += (sizeof(uint64_t) << 1);
if (trace.pos >= MAILBOX_TRACE_SIZE) trace.pos = 0; @@ -79,7 +79,7 @@ void _trace_event(uint32_t event) { unsigned long flags; volatile uint64_t dt[2]; - volatile uint32_t et = (event & 0xff000000); + uint32_t et = (event & 0xff000000);
if (!trace.enable) return;
participants (1)
-
Liam Girdwood