Module: xenomai-3 Branch: wip/dovetail Commit: c2026a16156529357940cd16d6340f18b360ae52 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=c2026a16156529357940cd16d6340f18b360ae52
Author: Philippe Gerum <r...@xenomai.org> Date: Wed Mar 2 12:08:32 2016 +0100 cobalt/timer: allow binding core timers to passive CPUs Some timers initialized by the Cobalt core may have a valid reason to live on CPUs excluded from the real-time set. A typical example would be the host timer from the scheduler slot, which relays ticks to the regular kernel. Other core timers are just better dealt with when created and left passive on those CPUs. Mark all core timers specifically, and exclude them from the LART detection code in __xntimer_init(). This fixes a spurious Cobalt debug assertion seen on SMP at boot, when the real-time CPU set is restricted to a subset of the online CPU set. --- include/cobalt/kernel/timer.h | 4 +++- kernel/cobalt/sched.c | 6 +++--- kernel/cobalt/thread.c | 2 ++ kernel/cobalt/timer.c | 9 ++++++--- 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/include/cobalt/kernel/timer.h b/include/cobalt/kernel/timer.h index 00aa411..5868fcb 100644 --- a/include/cobalt/kernel/timer.h +++ b/include/cobalt/kernel/timer.h @@ -51,11 +51,13 @@ typedef enum xntmode { #define XNTIMER_RUNNING 0x00000040 #define XNTIMER_KGRAVITY 0x00000080 #define XNTIMER_UGRAVITY 0x00000100 -#define XNTIMER_IGRAVITY 0 /* most conservative */ +#define XNTIMER_IGRAVITY 0 /* most conservative */ #define XNTIMER_GRAVITY_MASK (XNTIMER_KGRAVITY|XNTIMER_UGRAVITY) #define XNTIMER_INIT_MASK (XNTIMER_GRAVITY_MASK|XNTIMER_NOBLCK) +#define __XNTIMER_CORE 0x10000000 + /* These flags are available to the real-time interfaces */ #define XNTIMER_SPARE0 0x01000000 #define XNTIMER_SPARE1 0x02000000 diff --git a/kernel/cobalt/sched.c b/kernel/cobalt/sched.c index 3863dab..dfb8ce7 100644 --- a/kernel/cobalt/sched.c +++ b/kernel/cobalt/sched.c @@ -193,11 +193,11 @@ void xnsched_init(struct xnsched *sched, int cpu) * exit code. */ xntimer_init(&sched->htimer, &nkclock, NULL, - sched, XNTIMER_IGRAVITY); + sched, XNTIMER_IGRAVITY|__XNTIMER_CORE); xntimer_set_priority(&sched->htimer, XNTIMER_LOPRIO); xntimer_set_name(&sched->htimer, htimer_name); xntimer_init(&sched->rrbtimer, &nkclock, roundrobin_handler, - sched, XNTIMER_IGRAVITY); + sched, XNTIMER_IGRAVITY|__XNTIMER_CORE); xntimer_set_name(&sched->rrbtimer, rrbtimer_name); xntimer_set_priority(&sched->rrbtimer, XNTIMER_LOPRIO); @@ -212,7 +212,7 @@ void xnsched_init(struct xnsched *sched, int cpu) #ifdef CONFIG_XENO_OPT_WATCHDOG xntimer_init(&sched->wdtimer, &nkclock, watchdog_handler, - sched, XNTIMER_NOBLCK|XNTIMER_IGRAVITY); + sched, XNTIMER_NOBLCK|XNTIMER_IGRAVITY|__XNTIMER_CORE); xntimer_set_name(&sched->wdtimer, "[watchdog]"); xntimer_set_priority(&sched->wdtimer, XNTIMER_LOPRIO); #endif /* CONFIG_XENO_OPT_WATCHDOG */ diff --git a/kernel/cobalt/thread.c b/kernel/cobalt/thread.c index 07b0c8f..b758d50 100644 --- a/kernel/cobalt/thread.c +++ b/kernel/cobalt/thread.c @@ -202,6 +202,8 @@ int __xnthread_init(struct xnthread *thread, init_completion(&thread->exited); gravity = flags & XNUSER ? XNTIMER_UGRAVITY : XNTIMER_KGRAVITY; + if (flags & XNROOT) + gravity |= __XNTIMER_CORE; xntimer_init(&thread->rtimer, &nkclock, timeout_handler, sched, gravity); xntimer_set_name(&thread->rtimer, thread->name); diff --git a/kernel/cobalt/timer.c b/kernel/cobalt/timer.c index 3e85a53..ee16198 100644 --- a/kernel/cobalt/timer.c +++ b/kernel/cobalt/timer.c @@ -363,10 +363,13 @@ void __xntimer_init(struct xntimer *timer, * clock device on the CPU served by the specified * scheduler slot. This reveals a CPU affinity * mismatch between the clock hardware and the client - * code initializing the timer. + * code initializing the timer. This check excludes + * core timers which may have their own reason to bind + * to a passive CPU (e.g. host timer). */ - XENO_WARN_ON_SMP(COBALT, !cpumask_test_cpu(xnsched_cpu(sched), - &clock->affinity)); + XENO_WARN_ON_SMP(COBALT, !(flags & __XNTIMER_CORE) && + !cpumask_test_cpu(xnsched_cpu(sched), + &clock->affinity)); timer->sched = sched; } else { cpu = xnclock_get_default_cpu(clock, 0); _______________________________________________ Xenomai-git mailing list Xenomai-git@xenomai.org https://xenomai.org/mailman/listinfo/xenomai-git