Commit a2fda0da authored by Alessandro Rubini's avatar Alessandro Rubini

bugfix: wr_clocksource needs a spinlock

Signed-off-by: Alessandro Rubini's avatarAlessandro Rubini <rubini@gnudd.com>
parent 0b279361
...@@ -46,9 +46,12 @@ static inline void wrcs_do_stats(void) ...@@ -46,9 +46,12 @@ static inline void wrcs_do_stats(void)
ncalls++; ncalls++;
} }
DEFINE_SPINLOCK(wrcs_lock);
static cycle_t wrcs_read(struct clocksource *cs) static cycle_t wrcs_read(struct clocksource *cs)
{ {
static uint32_t offset, last, this; static uint32_t offset, last, this;
unsigned long flags;
wrcs_do_stats(); wrcs_do_stats();
...@@ -59,10 +62,12 @@ static cycle_t wrcs_read(struct clocksource *cs) ...@@ -59,10 +62,12 @@ static cycle_t wrcs_read(struct clocksource *cs)
* We reset at 0x3b9aca0, so without this we should use mask = 0x1f * We reset at 0x3b9aca0, so without this we should use mask = 0x1f
* and mac_idle = 32 ticks = 512ns. Unaffordable. * and mac_idle = 32 ticks = 512ns. Unaffordable.
*/ */
spin_lock_irqsave(&wrcs_lock, flags);
this = readl(&wrcs_ppsg->CNTR_NSEC); this = readl(&wrcs_ppsg->CNTR_NSEC);
if (this < last) if (this < last)
offset += WRCS_FREQUENCY; offset += WRCS_FREQUENCY;
last = this; last = this;
spin_unlock_irqrestore(&wrcs_lock, flags);
return offset + this; return offset + this;
} }
......
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