diff options
Diffstat (limited to 'arch/powerpc/kernel/time.c')
-rw-r--r-- | arch/powerpc/kernel/time.c | 33 |
1 files changed, 11 insertions, 22 deletions
diff --git a/arch/powerpc/kernel/time.c b/arch/powerpc/kernel/time.c index 18e59e43d2b3..7a3c3f791ade 100644 --- a/arch/powerpc/kernel/time.c +++ b/arch/powerpc/kernel/time.c | |||
@@ -125,15 +125,8 @@ static long timezone_offset; | |||
125 | unsigned long ppc_proc_freq; | 125 | unsigned long ppc_proc_freq; |
126 | unsigned long ppc_tb_freq; | 126 | unsigned long ppc_tb_freq; |
127 | 127 | ||
128 | u64 tb_last_jiffy __cacheline_aligned_in_smp; | 128 | static u64 tb_last_jiffy __cacheline_aligned_in_smp; |
129 | unsigned long tb_last_stamp; | 129 | static DEFINE_PER_CPU(u64, last_jiffy); |
130 | |||
131 | /* | ||
132 | * Note that on ppc32 this only stores the bottom 32 bits of | ||
133 | * the timebase value, but that's enough to tell when a jiffy | ||
134 | * has passed. | ||
135 | */ | ||
136 | DEFINE_PER_CPU(unsigned long, last_jiffy); | ||
137 | 130 | ||
138 | #ifdef CONFIG_VIRT_CPU_ACCOUNTING | 131 | #ifdef CONFIG_VIRT_CPU_ACCOUNTING |
139 | /* | 132 | /* |
@@ -458,7 +451,7 @@ void do_gettimeofday(struct timeval *tv) | |||
458 | do { | 451 | do { |
459 | seq = read_seqbegin_irqsave(&xtime_lock, flags); | 452 | seq = read_seqbegin_irqsave(&xtime_lock, flags); |
460 | sec = xtime.tv_sec; | 453 | sec = xtime.tv_sec; |
461 | nsec = xtime.tv_nsec + tb_ticks_since(tb_last_stamp); | 454 | nsec = xtime.tv_nsec + tb_ticks_since(tb_last_jiffy); |
462 | } while (read_seqretry_irqrestore(&xtime_lock, seq, flags)); | 455 | } while (read_seqretry_irqrestore(&xtime_lock, seq, flags)); |
463 | usec = nsec / 1000; | 456 | usec = nsec / 1000; |
464 | while (usec >= 1000000) { | 457 | while (usec >= 1000000) { |
@@ -700,7 +693,6 @@ void timer_interrupt(struct pt_regs * regs) | |||
700 | tb_next_jiffy = tb_last_jiffy + tb_ticks_per_jiffy; | 693 | tb_next_jiffy = tb_last_jiffy + tb_ticks_per_jiffy; |
701 | if (per_cpu(last_jiffy, cpu) >= tb_next_jiffy) { | 694 | if (per_cpu(last_jiffy, cpu) >= tb_next_jiffy) { |
702 | tb_last_jiffy = tb_next_jiffy; | 695 | tb_last_jiffy = tb_next_jiffy; |
703 | tb_last_stamp = per_cpu(last_jiffy, cpu); | ||
704 | do_timer(regs); | 696 | do_timer(regs); |
705 | timer_recalc_offset(tb_last_jiffy); | 697 | timer_recalc_offset(tb_last_jiffy); |
706 | timer_check_rtc(); | 698 | timer_check_rtc(); |
@@ -749,7 +741,7 @@ void __init smp_space_timers(unsigned int max_cpus) | |||
749 | int i; | 741 | int i; |
750 | unsigned long half = tb_ticks_per_jiffy / 2; | 742 | unsigned long half = tb_ticks_per_jiffy / 2; |
751 | unsigned long offset = tb_ticks_per_jiffy / max_cpus; | 743 | unsigned long offset = tb_ticks_per_jiffy / max_cpus; |
752 | unsigned long previous_tb = per_cpu(last_jiffy, boot_cpuid); | 744 | u64 previous_tb = per_cpu(last_jiffy, boot_cpuid); |
753 | 745 | ||
754 | /* make sure tb > per_cpu(last_jiffy, cpu) for all cpus always */ | 746 | /* make sure tb > per_cpu(last_jiffy, cpu) for all cpus always */ |
755 | previous_tb -= tb_ticks_per_jiffy; | 747 | previous_tb -= tb_ticks_per_jiffy; |
@@ -830,7 +822,7 @@ int do_settimeofday(struct timespec *tv) | |||
830 | * and therefore the (jiffies - wall_jiffies) computation | 822 | * and therefore the (jiffies - wall_jiffies) computation |
831 | * has been removed. | 823 | * has been removed. |
832 | */ | 824 | */ |
833 | tb_delta = tb_ticks_since(tb_last_stamp); | 825 | tb_delta = tb_ticks_since(tb_last_jiffy); |
834 | tb_delta = mulhdu(tb_delta, do_gtod.varp->tb_to_xs); /* in xsec */ | 826 | tb_delta = mulhdu(tb_delta, do_gtod.varp->tb_to_xs); /* in xsec */ |
835 | new_nsec -= SCALE_XSEC(tb_delta, 1000000000); | 827 | new_nsec -= SCALE_XSEC(tb_delta, 1000000000); |
836 | 828 | ||
@@ -868,19 +860,17 @@ EXPORT_SYMBOL(do_settimeofday); | |||
868 | static int __init get_freq(char *name, int cells, unsigned long *val) | 860 | static int __init get_freq(char *name, int cells, unsigned long *val) |
869 | { | 861 | { |
870 | struct device_node *cpu; | 862 | struct device_node *cpu; |
871 | unsigned int *fp; | 863 | const unsigned int *fp; |
872 | int found = 0; | 864 | int found = 0; |
873 | 865 | ||
874 | /* The cpu node should have timebase and clock frequency properties */ | 866 | /* The cpu node should have timebase and clock frequency properties */ |
875 | cpu = of_find_node_by_type(NULL, "cpu"); | 867 | cpu = of_find_node_by_type(NULL, "cpu"); |
876 | 868 | ||
877 | if (cpu) { | 869 | if (cpu) { |
878 | fp = (unsigned int *)get_property(cpu, name, NULL); | 870 | fp = get_property(cpu, name, NULL); |
879 | if (fp) { | 871 | if (fp) { |
880 | found = 1; | 872 | found = 1; |
881 | *val = 0; | 873 | *val = of_read_ulong(fp, cells); |
882 | while (cells--) | ||
883 | *val = (*val << 32) | *fp++; | ||
884 | } | 874 | } |
885 | 875 | ||
886 | of_node_put(cpu); | 876 | of_node_put(cpu); |
@@ -950,8 +940,7 @@ void __init time_init(void) | |||
950 | if (__USE_RTC()) { | 940 | if (__USE_RTC()) { |
951 | /* 601 processor: dec counts down by 128 every 128ns */ | 941 | /* 601 processor: dec counts down by 128 every 128ns */ |
952 | ppc_tb_freq = 1000000000; | 942 | ppc_tb_freq = 1000000000; |
953 | tb_last_stamp = get_rtcl(); | 943 | tb_last_jiffy = get_rtcl(); |
954 | tb_last_jiffy = tb_last_stamp; | ||
955 | } else { | 944 | } else { |
956 | /* Normal PowerPC with timebase register */ | 945 | /* Normal PowerPC with timebase register */ |
957 | ppc_md.calibrate_decr(); | 946 | ppc_md.calibrate_decr(); |
@@ -959,7 +948,7 @@ void __init time_init(void) | |||
959 | ppc_tb_freq / 1000000, ppc_tb_freq % 1000000); | 948 | ppc_tb_freq / 1000000, ppc_tb_freq % 1000000); |
960 | printk(KERN_DEBUG "time_init: processor frequency = %lu.%.6lu MHz\n", | 949 | printk(KERN_DEBUG "time_init: processor frequency = %lu.%.6lu MHz\n", |
961 | ppc_proc_freq / 1000000, ppc_proc_freq % 1000000); | 950 | ppc_proc_freq / 1000000, ppc_proc_freq % 1000000); |
962 | tb_last_stamp = tb_last_jiffy = get_tb(); | 951 | tb_last_jiffy = get_tb(); |
963 | } | 952 | } |
964 | 953 | ||
965 | tb_ticks_per_jiffy = ppc_tb_freq / HZ; | 954 | tb_ticks_per_jiffy = ppc_tb_freq / HZ; |
@@ -1036,7 +1025,7 @@ void __init time_init(void) | |||
1036 | do_gtod.varp = &do_gtod.vars[0]; | 1025 | do_gtod.varp = &do_gtod.vars[0]; |
1037 | do_gtod.var_idx = 0; | 1026 | do_gtod.var_idx = 0; |
1038 | do_gtod.varp->tb_orig_stamp = tb_last_jiffy; | 1027 | do_gtod.varp->tb_orig_stamp = tb_last_jiffy; |
1039 | __get_cpu_var(last_jiffy) = tb_last_stamp; | 1028 | __get_cpu_var(last_jiffy) = tb_last_jiffy; |
1040 | do_gtod.varp->stamp_xsec = (u64) xtime.tv_sec * XSEC_PER_SEC; | 1029 | do_gtod.varp->stamp_xsec = (u64) xtime.tv_sec * XSEC_PER_SEC; |
1041 | do_gtod.tb_ticks_per_sec = tb_ticks_per_sec; | 1030 | do_gtod.tb_ticks_per_sec = tb_ticks_per_sec; |
1042 | do_gtod.varp->tb_to_xs = tb_to_xs; | 1031 | do_gtod.varp->tb_to_xs = tb_to_xs; |