Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 33464
b: refs/heads/master
c: 5db9fa9
h: refs/heads/master
v: v3
  • Loading branch information
Nathan Lynch authored and Paul Mackerras committed Aug 23, 2006
1 parent ad9f5d6 commit 757b729
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 9 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: aa74a30be971c632d734e487df42278b1cf85151
refs/heads/master: 5db9fa9593e2ff69f2b95f9d59229dc4faaa564d
25 changes: 17 additions & 8 deletions trunk/arch/powerpc/kernel/time.c
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ static __inline__ void timer_check_rtc(void)
/*
* This version of gettimeofday has microsecond resolution.
*/
static inline void __do_gettimeofday(struct timeval *tv, u64 tb_val)
static inline void __do_gettimeofday(struct timeval *tv)
{
unsigned long sec, usec;
u64 tb_ticks, xsec;
Expand All @@ -431,7 +431,12 @@ static inline void __do_gettimeofday(struct timeval *tv, u64 tb_val)
* without a divide (and in fact, without a multiply)
*/
temp_varp = do_gtod.varp;
tb_ticks = tb_val - temp_varp->tb_orig_stamp;

/* Sampling the time base must be done after loading
* do_gtod.varp in order to avoid racing with update_gtod.
*/
data_barrier(temp_varp);
tb_ticks = get_tb() - temp_varp->tb_orig_stamp;
temp_tb_to_xs = temp_varp->tb_to_xs;
temp_stamp_xsec = temp_varp->stamp_xsec;
xsec = temp_stamp_xsec + mulhdu(tb_ticks, temp_tb_to_xs);
Expand Down Expand Up @@ -464,7 +469,7 @@ void do_gettimeofday(struct timeval *tv)
tv->tv_usec = usec;
return;
}
__do_gettimeofday(tv, get_tb());
__do_gettimeofday(tv);
}

EXPORT_SYMBOL(do_gettimeofday);
Expand Down Expand Up @@ -650,6 +655,7 @@ void timer_interrupt(struct pt_regs * regs)
int next_dec;
int cpu = smp_processor_id();
unsigned long ticks;
u64 tb_next_jiffy;

#ifdef CONFIG_PPC32
if (atomic_read(&ppc_n_lost_interrupts) != 0)
Expand Down Expand Up @@ -691,11 +697,14 @@ void timer_interrupt(struct pt_regs * regs)
continue;

write_seqlock(&xtime_lock);
tb_last_jiffy += tb_ticks_per_jiffy;
tb_last_stamp = per_cpu(last_jiffy, cpu);
do_timer(regs);
timer_recalc_offset(tb_last_jiffy);
timer_check_rtc();
tb_next_jiffy = tb_last_jiffy + tb_ticks_per_jiffy;
if (per_cpu(last_jiffy, cpu) >= tb_next_jiffy) {
tb_last_jiffy = tb_next_jiffy;
tb_last_stamp = per_cpu(last_jiffy, cpu);
do_timer(regs);
timer_recalc_offset(tb_last_jiffy);
timer_check_rtc();
}
write_sequnlock(&xtime_lock);
}

Expand Down
9 changes: 9 additions & 0 deletions trunk/include/asm-powerpc/system.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,15 @@
#define smp_read_barrier_depends() do { } while(0)
#endif /* CONFIG_SMP */

/*
* This is a barrier which prevents following instructions from being
* started until the value of the argument x is known. For example, if
* x is a variable loaded from memory, this prevents following
* instructions from being executed until the load has been performed.
*/
#define data_barrier(x) \
asm volatile("twi 0,%0,0; isync" : : "r" (x) : "memory");

struct task_struct;
struct pt_regs;

Expand Down

0 comments on commit 757b729

Please sign in to comment.