time.c (7615856ebfee52b080c22d263ca4debbd0df0ac1) | time.c (0e469db8f70c2645acdc90981c0480a3e19d5e68) |
---|---|
1/* 2 * Common time routines among all ppc machines. 3 * 4 * Written by Cort Dougan (cort@cs.nmt.edu) to merge 5 * Paul Mackerras' version and mine for PReP and Pmac. 6 * MPC8xx/MBX changes by Dan Malek (dmalek@jlc.net). 7 * Converted for 64-bit by Mike Corrigan (mikejc@us.ibm.com) 8 * --- 835 unchanged lines hidden (view full) --- 844 return (cycle_t)get_rtc(); 845} 846 847static cycle_t timebase_read(struct clocksource *cs) 848{ 849 return (cycle_t)get_tb(); 850} 851 | 1/* 2 * Common time routines among all ppc machines. 3 * 4 * Written by Cort Dougan (cort@cs.nmt.edu) to merge 5 * Paul Mackerras' version and mine for PReP and Pmac. 6 * MPC8xx/MBX changes by Dan Malek (dmalek@jlc.net). 7 * Converted for 64-bit by Mike Corrigan (mikejc@us.ibm.com) 8 * --- 835 unchanged lines hidden (view full) --- 844 return (cycle_t)get_rtc(); 845} 846 847static cycle_t timebase_read(struct clocksource *cs) 848{ 849 return (cycle_t)get_tb(); 850} 851 |
852void update_vsyscall(struct timespec *wall_time, struct timespec *wtm, 853 struct clocksource *clock, u32 mult) | 852static inline void update_gtod(u64 new_tb_stamp, u64 new_stamp_xsec, 853 u64 new_tb_to_xs, struct timespec *now, 854 u32 frac_sec) |
854{ | 855{ |
855 u64 new_tb_to_xs, new_stamp_xsec; 856 857 if (clock != &clocksource_timebase) 858 return; 859 860 /* Make userspace gettimeofday spin until we're done. */ 861 ++vdso_data->tb_update_count; 862 smp_mb(); 863 864 /* XXX this assumes clock->shift == 22 */ 865 /* 4611686018 ~= 2^(20+64-22) / 1e9 */ 866 new_tb_to_xs = (u64) mult * 4611686018ULL; 867 new_stamp_xsec = (u64) wall_time->tv_nsec * XSEC_PER_SEC; 868 do_div(new_stamp_xsec, 1000000000); 869 new_stamp_xsec += (u64) wall_time->tv_sec * XSEC_PER_SEC; 870 | |
871 /* 872 * tb_update_count is used to allow the userspace gettimeofday code 873 * to assure itself that it sees a consistent view of the tb_to_xs and 874 * stamp_xsec variables. It reads the tb_update_count, then reads 875 * tb_to_xs and stamp_xsec and then reads tb_update_count again. If 876 * the two values of tb_update_count match and are even then the 877 * tb_to_xs and stamp_xsec values are consistent. If not, then it 878 * loops back and reads them again until this criteria is met. 879 * We expect the caller to have done the first increment of 880 * vdso_data->tb_update_count already. 881 */ | 856 /* 857 * tb_update_count is used to allow the userspace gettimeofday code 858 * to assure itself that it sees a consistent view of the tb_to_xs and 859 * stamp_xsec variables. It reads the tb_update_count, then reads 860 * tb_to_xs and stamp_xsec and then reads tb_update_count again. If 861 * the two values of tb_update_count match and are even then the 862 * tb_to_xs and stamp_xsec values are consistent. If not, then it 863 * loops back and reads them again until this criteria is met. 864 * We expect the caller to have done the first increment of 865 * vdso_data->tb_update_count already. 866 */ |
882 vdso_data->tb_orig_stamp = clock->cycle_last; | 867 vdso_data->tb_orig_stamp = new_tb_stamp; |
883 vdso_data->stamp_xsec = new_stamp_xsec; 884 vdso_data->tb_to_xs = new_tb_to_xs; | 868 vdso_data->stamp_xsec = new_stamp_xsec; 869 vdso_data->tb_to_xs = new_tb_to_xs; |
885 vdso_data->wtom_clock_sec = wtm->tv_sec; 886 vdso_data->wtom_clock_nsec = wtm->tv_nsec; 887 vdso_data->stamp_xtime = *wall_time; | 870 vdso_data->wtom_clock_sec = wall_to_monotonic.tv_sec; 871 vdso_data->wtom_clock_nsec = wall_to_monotonic.tv_nsec; 872 vdso_data->stamp_xtime = *now; 873 vdso_data->stamp_sec_fraction = frac_sec; |
888 smp_wmb(); 889 ++(vdso_data->tb_update_count); 890} 891 | 874 smp_wmb(); 875 ++(vdso_data->tb_update_count); 876} 877 |
878void update_vsyscall(struct timespec *wall_time, struct clocksource *clock, 879 u32 mult) 880{ 881 u64 t2x, stamp_xsec; 882 u32 frac_sec; 883 884 if (clock != &clocksource_timebase) 885 return; 886 887 /* Make userspace gettimeofday spin until we're done. */ 888 ++vdso_data->tb_update_count; 889 smp_mb(); 890 891 /* XXX this assumes clock->shift == 22 */ 892 /* 4611686018 ~= 2^(20+64-22) / 1e9 */ 893 t2x = (u64) mult * 4611686018ULL; 894 stamp_xsec = (u64) wall_time->tv_nsec * XSEC_PER_SEC; 895 do_div(stamp_xsec, 1000000000); 896 stamp_xsec += (u64) wall_time->tv_sec * XSEC_PER_SEC; 897 898 BUG_ON(wall_time->tv_nsec >= NSEC_PER_SEC); 899 /* this is tv_nsec / 1e9 as a 0.32 fraction */ 900 frac_sec = ((u64) wall_time->tv_nsec * 18446744073ULL) >> 32; 901 update_gtod(clock->cycle_last, stamp_xsec, t2x, wall_time, frac_sec); 902} 903 |
|
892void update_vsyscall_tz(void) 893{ 894 /* Make userspace gettimeofday spin until we're done. */ 895 ++vdso_data->tb_update_count; 896 smp_mb(); 897 vdso_data->tz_minuteswest = sys_tz.tz_minuteswest; 898 vdso_data->tz_dsttime = sys_tz.tz_dsttime; 899 smp_mb(); --- 188 unchanged lines hidden (view full) --- 1088 if (timezone_offset) { 1089 sys_tz.tz_minuteswest = -timezone_offset / 60; 1090 sys_tz.tz_dsttime = 0; 1091 } 1092 1093 vdso_data->tb_orig_stamp = tb_last_jiffy; 1094 vdso_data->tb_update_count = 0; 1095 vdso_data->tb_ticks_per_sec = tb_ticks_per_sec; | 904void update_vsyscall_tz(void) 905{ 906 /* Make userspace gettimeofday spin until we're done. */ 907 ++vdso_data->tb_update_count; 908 smp_mb(); 909 vdso_data->tz_minuteswest = sys_tz.tz_minuteswest; 910 vdso_data->tz_dsttime = sys_tz.tz_dsttime; 911 smp_mb(); --- 188 unchanged lines hidden (view full) --- 1100 if (timezone_offset) { 1101 sys_tz.tz_minuteswest = -timezone_offset / 60; 1102 sys_tz.tz_dsttime = 0; 1103 } 1104 1105 vdso_data->tb_orig_stamp = tb_last_jiffy; 1106 vdso_data->tb_update_count = 0; 1107 vdso_data->tb_ticks_per_sec = tb_ticks_per_sec; |
1096 vdso_data->stamp_xsec = (u64) get_seconds() * XSEC_PER_SEC; | 1108 vdso_data->stamp_xsec = (u64) xtime.tv_sec * XSEC_PER_SEC; |
1097 vdso_data->tb_to_xs = tb_to_xs; 1098 1099 write_sequnlock_irqrestore(&xtime_lock, flags); 1100 1101 /* Start the decrementer on CPUs that have manual control 1102 * such as BookE 1103 */ 1104 start_cpu_decrementer(); --- 178 unchanged lines hidden --- | 1109 vdso_data->tb_to_xs = tb_to_xs; 1110 1111 write_sequnlock_irqrestore(&xtime_lock, flags); 1112 1113 /* Start the decrementer on CPUs that have manual control 1114 * such as BookE 1115 */ 1116 start_cpu_decrementer(); --- 178 unchanged lines hidden --- |