Commit 754d5c2bf65847f7ff4e0047a830154abe666112

Authored by Jonas Bonn
1 parent 1742527511

openrisc: Set shortest clock event to 100 ticks

It takes a couple of instructions to actually configure a clock event
so setting an alarm just 1 clock cycle in the future isn't going to work;
doing so results in setting an alarm in the "past" in which case the event
won't fire until the timer overflows and rolls back around to the "current
time".

Not quite sure how many clock cycles it actually takes to get through to
actually writing the register, but 100 seems to work reliably.

Use generic helper to set up the clock event while we're at it.

Reported-by: Jan Schulte <jan.schulte@aacmicrotec.com>
Signed-off-by: Jonas Bonn <jonas@southpole.se>

Showing 1 changed file with 5 additions and 8 deletions Side-by-side Diff

arch/openrisc/kernel/time.c
... ... @@ -125,16 +125,13 @@
125 125  
126 126 static __init void openrisc_clockevent_init(void)
127 127 {
128   - clockevents_calc_mult_shift(&clockevent_openrisc_timer,
129   - cpuinfo.clock_frequency, 4);
  128 + clockevent_openrisc_timer.cpumask = cpumask_of(0);
130 129  
131 130 /* We only have 28 bits */
132   - clockevent_openrisc_timer.max_delta_ns =
133   - clockevent_delta2ns((u32) 0x0fffffff, &clockevent_openrisc_timer);
134   - clockevent_openrisc_timer.min_delta_ns =
135   - clockevent_delta2ns(1, &clockevent_openrisc_timer);
136   - clockevent_openrisc_timer.cpumask = cpumask_of(0);
137   - clockevents_register_device(&clockevent_openrisc_timer);
  131 + clockevents_config_and_register(&clockevent_openrisc_timer,
  132 + cpuinfo.clock_frequency,
  133 + 100, 0x0fffffff);
  134 +
138 135 }
139 136  
140 137 /**