Commit 59560645 authored by Philippe Gerum's avatar Philippe Gerum

cobalt/sched, clock: provide ipipe_enter_idle_hook()

Since kernel 4.9, the pipeline code may ask us whether it would be
fine to enter the idle state on the current CPU, by mean of a probing
hook called ipipe_enter_idle_hook().

Provide this hook, considering that absence of outstanding timers
means idleness to us.
parent 945c7dbf
......@@ -42,6 +42,7 @@
#define XNINTCK 0x40000000 /* In master tick handler context */
/* Sched local flags */
#define XNIDLE 0x00010000 /* Idle (no outstanding timer) */
#define XNHTICK 0x00008000 /* Host tick pending */
#define XNINIRQ 0x00004000 /* In IRQ handling context */
#define XNHDEFER 0x00002000 /* Host tick deferred */
......
......@@ -143,8 +143,10 @@ void xnclock_core_local_shot(struct xnsched *sched)
*/
tmd = xnclock_this_timerdata(&nkclock);
h = xntimerq_head(&tmd->q);
if (h == NULL)
if (h == NULL) {
sched->lflags |= XNIDLE;
return;
}
/*
* Here we try to defer the host tick heading the timer queue,
......@@ -166,7 +168,7 @@ void xnclock_core_local_shot(struct xnsched *sched)
* or a timer with an earlier timeout date is scheduled,
* whichever comes first.
*/
sched->lflags &= ~XNHDEFER;
sched->lflags &= ~(XNHDEFER|XNIDLE);
timer = container_of(h, struct xntimer, aplink);
if (unlikely(timer == &sched->htimer)) {
if (xnsched_resched_p(sched) ||
......
......@@ -822,6 +822,12 @@ int ipipe_trap_hook(struct ipipe_trap_data *data)
return KEVENT_PROPAGATE;
}
bool ipipe_enter_idle_hook(void) /* hw IRQs off */
{
struct xnsched *sched = xnsched_current();
return !!(sched->lflags & XNIDLE);
}
#ifdef CONFIG_SMP
static int handle_setaffinity_event(struct ipipe_cpu_migration_data *d)
......
......@@ -175,7 +175,7 @@ void xnsched_init(struct xnsched *sched, int cpu)
}
sched->status = 0;
sched->lflags = 0;
sched->lflags = XNIDLE;
sched->inesting = 0;
sched->curr = &sched->rootcb;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment