Commit ba05e30f authored by Greg Ungerer's avatar Greg Ungerer Committed by Jaroslav Kysela

[PATCH] lock xtime struct in m68knommu/ColdFire timers

This patch adds appropriate locking around updates of the xtime
structure for the m68knommu ColdFire architecture timers.
parent a5c45389
...@@ -28,6 +28,9 @@ ...@@ -28,6 +28,9 @@
u64 jiffies_64 = INITIAL_JIFFIES; u64 jiffies_64 = INITIAL_JIFFIES;
extern unsigned long wall_jiffies;
static inline int set_rtc_mmss(unsigned long nowtime) static inline int set_rtc_mmss(unsigned long nowtime)
{ {
if (mach_set_clock_mmss) if (mach_set_clock_mmss)
...@@ -66,6 +69,8 @@ static void timer_interrupt(int irq, void *dummy, struct pt_regs * regs) ...@@ -66,6 +69,8 @@ static void timer_interrupt(int irq, void *dummy, struct pt_regs * regs)
if (mach_tick) if (mach_tick)
mach_tick(); mach_tick();
write_seqlock(&xtime_lock);
do_timer(regs); do_timer(regs);
if (!user_mode(regs)) if (!user_mode(regs))
...@@ -108,6 +113,8 @@ static void timer_interrupt(int irq, void *dummy, struct pt_regs * regs) ...@@ -108,6 +113,8 @@ static void timer_interrupt(int irq, void *dummy, struct pt_regs * regs)
} }
} }
#endif /* CONFIG_HEARTBEAT */ #endif /* CONFIG_HEARTBEAT */
write_sequnlock(&xtime_lock);
} }
void time_init(void) void time_init(void)
...@@ -133,18 +140,19 @@ void time_init(void) ...@@ -133,18 +140,19 @@ void time_init(void)
void do_gettimeofday(struct timeval *tv) void do_gettimeofday(struct timeval *tv)
{ {
unsigned long flags; unsigned long flags;
unsigned long seq; unsigned long lost, seq;
unsigned long usec, sec; unsigned long usec, sec;
do { do {
seq = read_seqbegin_irqsave(&xtime_lock, flags); seq = read_seqbegin_irqsave(&xtime_lock, flags);
usec = mach_gettimeoffset ? mach_gettimeoffset() : 0; usec = mach_gettimeoffset ? mach_gettimeoffset() : 0;
lost = jiffies - wall_jiffies;
if (lost)
usec += lost * (1000000 / HZ);
sec = xtime.tv_sec; sec = xtime.tv_sec;
usec += (xtime.tv_nsec / 1000); usec += (xtime.tv_nsec / 1000);
} while (read_seqretry_irqrestore(&xtime_lock, seq, flags)); } while (read_seqretry_irqrestore(&xtime_lock, seq, flags));
while (usec >= 1000000) { while (usec >= 1000000) {
usec -= 1000000; usec -= 1000000;
sec++; sec++;
......
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