Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0db01479 authored by Subbaraman Narayanamurthy's avatar Subbaraman Narayanamurthy Committed by Stephen Boyd
Browse files

arm: arch_timer: Enable timer in set_mode only



Currently, we enable the timer hardware and unmask its interrupt in
the set_next_event callback. However, during hotplug, this callback
can be called after the timer is already supposed to be disabled.

Since the timer will be completely turned back on by set_next_event,
we will soon receive an interrupt, potentially causing us to wake up
from hotplug.

Instead, continue unmasking the interrupt when set_next_event is
called, but only enable the timer hardware in the set_mode callback.
This means that, once arch_timer_disable is called, we are guaranteed
to not receive more timer interrupts until the cpu is intentionally
hotplugged back in.

Change-Id: I0e440f58a0ef6e453c7cfb0bbe2d7a657fbb041f
Signed-off-by: default avatarSubbaraman Narayanamurthy <subbaram@codeaurora.org>
parent 96390ee5
Loading
Loading
Loading
Loading
+6 −3
Original line number Diff line number Diff line
@@ -82,6 +82,11 @@ static inline void timer_set_mode(const int access, int mode)
		ctrl &= ~ARCH_TIMER_CTRL_ENABLE;
		arch_timer_reg_write(access, ARCH_TIMER_REG_CTRL, ctrl);
		break;
	case CLOCK_EVT_MODE_ONESHOT:
		ctrl = arch_timer_reg_read(access, ARCH_TIMER_REG_CTRL);
		ctrl |= ARCH_TIMER_CTRL_ENABLE;
		arch_timer_reg_write(access, ARCH_TIMER_REG_CTRL, ctrl);
		break;
	default:
		break;
	}
@@ -103,11 +108,9 @@ static inline void set_next_event(const int access, unsigned long evt)
{
	unsigned long ctrl;
	ctrl = arch_timer_reg_read(access, ARCH_TIMER_REG_CTRL);
	ctrl &= ~(ARCH_TIMER_CTRL_ENABLE | ARCH_TIMER_CTRL_IT_MASK);
	ctrl &= ~ARCH_TIMER_CTRL_IT_MASK;
	arch_timer_reg_write(access, ARCH_TIMER_REG_CTRL, ctrl);
	arch_timer_reg_write(access, ARCH_TIMER_REG_TVAL, evt);
	ctrl |= ARCH_TIMER_CTRL_ENABLE;
	arch_specific_timer->reg_write(ARCH_TIMER_REG_CTRL, ctrl);
}

static int arch_timer_set_next_event_virt(unsigned long evt,