Commit 3d1a9372 authored by Philippe Gerum's avatar Philippe Gerum Committed by Jan Kiszka

cobalt/tick: dovetail: protect call to xntimer_start()

The ugly big lock must be held when calling xntimer_start(), including
when the in-band timer subsystem wants us to emulate the next host
tick.
Signed-off-by: Philippe Gerum's avatarPhilippe Gerum <rpm@xenomai.org>
parent d04b180c
......@@ -73,10 +73,10 @@ static int proxy_set_next_ktime(ktime_t expires,
if (delta < 0)
delta = 0;
flags = hard_local_irq_save(); /* Prevent CPU migration. */
xnlock_get_irqsave(&nklock, flags);
sched = xnsched_current();
ret = xntimer_start(&sched->htimer, delta, XN_INFINITE, XN_RELATIVE);
hard_local_irq_restore(flags);
xnlock_put_irqrestore(&nklock, flags);
return ret ? -ETIME : 0;
}
......
......@@ -121,6 +121,8 @@ int xntimer_start(struct xntimer *timer,
unsigned long gravity;
int ret = 0;
atomic_only();
trace_cobalt_timer_start(timer, value, interval, mode);
if ((timer->status & XNTIMER_DEQUEUED) == 0)
......@@ -207,6 +209,8 @@ void __xntimer_stop(struct xntimer *timer)
struct xnsched *sched;
int heading = 1;
atomic_only();
trace_cobalt_timer_stop(timer);
if ((timer->status & XNTIMER_DEQUEUED) == 0) {
......@@ -242,6 +246,8 @@ EXPORT_SYMBOL_GPL(__xntimer_stop);
*/
xnticks_t xntimer_get_date(struct xntimer *timer)
{
atomic_only();
if (!xntimer_running_p(timer))
return XN_INFINITE;
......@@ -272,6 +278,8 @@ xnticks_t __xntimer_get_timeout(struct xntimer *timer)
struct xnclock *clock;
xnticks_t expiry, now;
atomic_only();
clock = xntimer_clock(timer);
now = xnclock_read_raw(clock);
expiry = xntimer_expiry(timer);
......@@ -434,6 +442,8 @@ void __xntimer_switch_tracking(struct xntimer *timer,
void xntimer_set_clock(struct xntimer *timer,
struct xnclock *newclock)
{
atomic_only();
if (timer->clock != newclock) {
xntimer_stop(timer);
timer->clock = newclock;
......@@ -608,6 +618,8 @@ unsigned long long xntimer_get_overruns(struct xntimer *timer,
xnsticks_t delta;
xntimerq_t *q;
atomic_only();
delta = now - xntimer_pexpect(timer);
if (unlikely(delta >= (xnsticks_t) period)) {
period = timer->interval_ns;
......
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