Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'fortglx/4.4/time' of https://git.linaro.org/people/john.stultz/linux into timers/core

Time updates from John Stultz:

- More 2038 work from Arnd Bergmann around ntp and pps

+44 -44
+15 -15
drivers/net/ethernet/sfc/ptp.c
··· 401 401 /* For Siena platforms NIC time is s and ns */ 402 402 static void efx_ptp_ns_to_s_ns(s64 ns, u32 *nic_major, u32 *nic_minor) 403 403 { 404 - struct timespec ts = ns_to_timespec(ns); 405 - *nic_major = ts.tv_sec; 404 + struct timespec64 ts = ns_to_timespec64(ns); 405 + *nic_major = (u32)ts.tv_sec; 406 406 *nic_minor = ts.tv_nsec; 407 407 } 408 408 ··· 431 431 */ 432 432 static void efx_ptp_ns_to_s27(s64 ns, u32 *nic_major, u32 *nic_minor) 433 433 { 434 - struct timespec ts = ns_to_timespec(ns); 435 - u32 maj = ts.tv_sec; 434 + struct timespec64 ts = ns_to_timespec64(ns); 435 + u32 maj = (u32)ts.tv_sec; 436 436 u32 min = (u32)(((u64)ts.tv_nsec * NS_TO_S27_MULT + 437 437 (1ULL << (NS_TO_S27_SHIFT - 1))) >> NS_TO_S27_SHIFT); 438 438 ··· 646 646 struct pps_event_time *last_time) 647 647 { 648 648 struct pps_event_time now; 649 - struct timespec limit; 649 + struct timespec64 limit; 650 650 struct efx_ptp_data *ptp = efx->ptp_data; 651 - struct timespec start; 651 + struct timespec64 start; 652 652 int *mc_running = ptp->start.addr; 653 653 654 654 pps_get_ts(&now); 655 655 start = now.ts_real; 656 656 limit = now.ts_real; 657 - timespec_add_ns(&limit, SYNCHRONISE_PERIOD_NS); 657 + timespec64_add_ns(&limit, SYNCHRONISE_PERIOD_NS); 658 658 659 659 /* Write host time for specified period or until MC is done */ 660 - while ((timespec_compare(&now.ts_real, &limit) < 0) && 660 + while ((timespec64_compare(&now.ts_real, &limit) < 0) && 661 661 ACCESS_ONCE(*mc_running)) { 662 - struct timespec update_time; 662 + struct timespec64 update_time; 663 663 unsigned int host_time; 664 664 665 665 /* Don't update continuously to avoid saturating the PCIe bus */ 666 666 update_time = now.ts_real; 667 - timespec_add_ns(&update_time, SYNCHRONISATION_GRANULARITY_NS); 667 + timespec64_add_ns(&update_time, SYNCHRONISATION_GRANULARITY_NS); 668 668 do { 669 669 pps_get_ts(&now); 670 - } while ((timespec_compare(&now.ts_real, &update_time) < 0) && 670 + } while ((timespec64_compare(&now.ts_real, &update_time) < 0) && 671 671 ACCESS_ONCE(*mc_running)); 672 672 673 673 /* Synchronise NIC with single word of time only */ ··· 723 723 struct efx_ptp_data *ptp = efx->ptp_data; 724 724 u32 last_sec; 725 725 u32 start_sec; 726 - struct timespec delta; 726 + struct timespec64 delta; 727 727 ktime_t mc_time; 728 728 729 729 if (number_readings == 0) ··· 737 737 */ 738 738 for (i = 0; i < number_readings; i++) { 739 739 s32 window, corrected; 740 - struct timespec wait; 740 + struct timespec64 wait; 741 741 742 742 efx_ptp_read_timeset( 743 743 MCDI_ARRAY_STRUCT_PTR(synch_buf, 744 744 PTP_OUT_SYNCHRONIZE_TIMESET, i), 745 745 &ptp->timeset[i]); 746 746 747 - wait = ktime_to_timespec( 747 + wait = ktime_to_timespec64( 748 748 ptp->nic_to_kernel_time(0, ptp->timeset[i].wait, 0)); 749 749 window = ptp->timeset[i].window; 750 750 corrected = window - wait.tv_nsec; ··· 803 803 ptp->timeset[last_good].minor, 0); 804 804 805 805 /* Calculate delay from NIC top of second to last_time */ 806 - delta.tv_nsec += ktime_to_timespec(mc_time).tv_nsec; 806 + delta.tv_nsec += ktime_to_timespec64(mc_time).tv_nsec; 807 807 808 808 /* Set PPS timestamp to match NIC top of second */ 809 809 ptp->host_time_pps = *last_time;
+2 -2
drivers/pps/kapi.c
··· 179 179 /* check event type */ 180 180 BUG_ON((event & (PPS_CAPTUREASSERT | PPS_CAPTURECLEAR)) == 0); 181 181 182 - dev_dbg(pps->dev, "PPS event at %ld.%09ld\n", 183 - ts->ts_real.tv_sec, ts->ts_real.tv_nsec); 182 + dev_dbg(pps->dev, "PPS event at %lld.%09ld\n", 183 + (s64)ts->ts_real.tv_sec, ts->ts_real.tv_nsec); 184 184 185 185 timespec_to_pps_ktime(&ts_real, ts->ts_real); 186 186
+8 -8
include/linux/pps_kernel.h
··· 48 48 49 49 struct pps_event_time { 50 50 #ifdef CONFIG_NTP_PPS 51 - struct timespec ts_raw; 51 + struct timespec64 ts_raw; 52 52 #endif /* CONFIG_NTP_PPS */ 53 - struct timespec ts_real; 53 + struct timespec64 ts_real; 54 54 }; 55 55 56 56 /* The main struct */ ··· 105 105 struct pps_device *pps_lookup_dev(void const *cookie); 106 106 107 107 static inline void timespec_to_pps_ktime(struct pps_ktime *kt, 108 - struct timespec ts) 108 + struct timespec64 ts) 109 109 { 110 110 kt->sec = ts.tv_sec; 111 111 kt->nsec = ts.tv_nsec; ··· 115 115 116 116 static inline void pps_get_ts(struct pps_event_time *ts) 117 117 { 118 - getnstime_raw_and_real(&ts->ts_raw, &ts->ts_real); 118 + ktime_get_raw_and_real_ts64(&ts->ts_raw, &ts->ts_real); 119 119 } 120 120 121 121 #else /* CONFIG_NTP_PPS */ 122 122 123 123 static inline void pps_get_ts(struct pps_event_time *ts) 124 124 { 125 - getnstimeofday(&ts->ts_real); 125 + ktime_get_real_ts64(&ts->ts_real); 126 126 } 127 127 128 128 #endif /* CONFIG_NTP_PPS */ 129 129 130 130 /* Subtract known time delay from PPS event time(s) */ 131 - static inline void pps_sub_ts(struct pps_event_time *ts, struct timespec delta) 131 + static inline void pps_sub_ts(struct pps_event_time *ts, struct timespec64 delta) 132 132 { 133 - ts->ts_real = timespec_sub(ts->ts_real, delta); 133 + ts->ts_real = timespec64_sub(ts->ts_real, delta); 134 134 #ifdef CONFIG_NTP_PPS 135 - ts->ts_raw = timespec_sub(ts->ts_raw, delta); 135 + ts->ts_raw = timespec64_sub(ts->ts_raw, delta); 136 136 #endif 137 137 } 138 138
+2 -2
include/linux/timekeeping.h
··· 263 263 /* 264 264 * PPS accessor 265 265 */ 266 - extern void getnstime_raw_and_real(struct timespec *ts_raw, 267 - struct timespec *ts_real); 266 + extern void ktime_get_raw_and_real_ts64(struct timespec64 *ts_raw, 267 + struct timespec64 *ts_real); 268 268 269 269 /* 270 270 * Persistent clock related interfaces
+1 -1
include/linux/timex.h
··· 152 152 #define NTP_INTERVAL_LENGTH (NSEC_PER_SEC/NTP_INTERVAL_FREQ) 153 153 154 154 extern int do_adjtimex(struct timex *); 155 - extern void hardpps(const struct timespec *, const struct timespec *); 155 + extern void hardpps(const struct timespec64 *, const struct timespec64 *); 156 156 157 157 int read_current_timer(unsigned long *timer_val); 158 158 void ntp_notify_cmos_timer(void);
+8 -8
kernel/time/ntp.c
··· 99 99 static int pps_valid; /* signal watchdog counter */ 100 100 static long pps_tf[3]; /* phase median filter */ 101 101 static long pps_jitter; /* current jitter (ns) */ 102 - static struct timespec pps_fbase; /* beginning of the last freq interval */ 102 + static struct timespec64 pps_fbase; /* beginning of the last freq interval */ 103 103 static int pps_shift; /* current interval duration (s) (shift) */ 104 104 static int pps_intcnt; /* interval counter */ 105 105 static s64 pps_freq; /* frequency offset (scaled ns/s) */ ··· 509 509 static void sync_cmos_clock(struct work_struct *work) 510 510 { 511 511 struct timespec64 now; 512 - struct timespec next; 512 + struct timespec64 next; 513 513 int fail = 1; 514 514 515 515 /* ··· 559 559 next.tv_nsec -= NSEC_PER_SEC; 560 560 } 561 561 queue_delayed_work(system_power_efficient_wq, 562 - &sync_cmos_work, timespec_to_jiffies(&next)); 562 + &sync_cmos_work, timespec64_to_jiffies(&next)); 563 563 } 564 564 565 565 void ntp_notify_cmos_timer(void) ··· 773 773 * pps_normtime.nsec has a range of ( -NSEC_PER_SEC / 2, NSEC_PER_SEC / 2 ] 774 774 * while timespec.tv_nsec has a range of [0, NSEC_PER_SEC) */ 775 775 struct pps_normtime { 776 - __kernel_time_t sec; /* seconds */ 776 + s64 sec; /* seconds */ 777 777 long nsec; /* nanoseconds */ 778 778 }; 779 779 780 780 /* normalize the timestamp so that nsec is in the 781 781 ( -NSEC_PER_SEC / 2, NSEC_PER_SEC / 2 ] interval */ 782 - static inline struct pps_normtime pps_normalize_ts(struct timespec ts) 782 + static inline struct pps_normtime pps_normalize_ts(struct timespec64 ts) 783 783 { 784 784 struct pps_normtime norm = { 785 785 .sec = ts.tv_sec, ··· 861 861 pps_errcnt++; 862 862 pps_dec_freq_interval(); 863 863 printk_deferred(KERN_ERR 864 - "hardpps: PPSERROR: interval too long - %ld s\n", 864 + "hardpps: PPSERROR: interval too long - %lld s\n", 865 865 freq_norm.sec); 866 866 return 0; 867 867 } ··· 948 948 * This code is based on David Mills's reference nanokernel 949 949 * implementation. It was mostly rewritten but keeps the same idea. 950 950 */ 951 - void __hardpps(const struct timespec *phase_ts, const struct timespec *raw_ts) 951 + void __hardpps(const struct timespec64 *phase_ts, const struct timespec64 *raw_ts) 952 952 { 953 953 struct pps_normtime pts_norm, freq_norm; 954 954 ··· 969 969 } 970 970 971 971 /* ok, now we have a base for frequency calculation */ 972 - freq_norm = pps_normalize_ts(timespec_sub(*raw_ts, pps_fbase)); 972 + freq_norm = pps_normalize_ts(timespec64_sub(*raw_ts, pps_fbase)); 973 973 974 974 /* check that the signal is in the range 975 975 * [1s - MAXFREQ us, 1s + MAXFREQ us], otherwise reject it */
+1 -1
kernel/time/ntp_internal.h
··· 9 9 extern int second_overflow(unsigned long secs); 10 10 extern int ntp_validate_timex(struct timex *); 11 11 extern int __do_adjtimex(struct timex *, struct timespec64 *, s32 *); 12 - extern void __hardpps(const struct timespec *, const struct timespec *); 12 + extern void __hardpps(const struct timespec64 *, const struct timespec64 *); 13 13 #endif /* _LINUX_NTP_INTERNAL_H */
+7 -7
kernel/time/timekeeping.c
··· 849 849 #ifdef CONFIG_NTP_PPS 850 850 851 851 /** 852 - * getnstime_raw_and_real - get day and raw monotonic time in timespec format 852 + * ktime_get_raw_and_real_ts64 - get day and raw monotonic time in timespec format 853 853 * @ts_raw: pointer to the timespec to be set to raw monotonic time 854 854 * @ts_real: pointer to the timespec to be set to the time of day 855 855 * ··· 857 857 * same time atomically and stores the resulting timestamps in timespec 858 858 * format. 859 859 */ 860 - void getnstime_raw_and_real(struct timespec *ts_raw, struct timespec *ts_real) 860 + void ktime_get_raw_and_real_ts64(struct timespec64 *ts_raw, struct timespec64 *ts_real) 861 861 { 862 862 struct timekeeper *tk = &tk_core.timekeeper; 863 863 unsigned long seq; ··· 868 868 do { 869 869 seq = read_seqcount_begin(&tk_core.seq); 870 870 871 - *ts_raw = timespec64_to_timespec(tk->raw_time); 871 + *ts_raw = tk->raw_time; 872 872 ts_real->tv_sec = tk->xtime_sec; 873 873 ts_real->tv_nsec = 0; 874 874 ··· 877 877 878 878 } while (read_seqcount_retry(&tk_core.seq, seq)); 879 879 880 - timespec_add_ns(ts_raw, nsecs_raw); 881 - timespec_add_ns(ts_real, nsecs_real); 880 + timespec64_add_ns(ts_raw, nsecs_raw); 881 + timespec64_add_ns(ts_real, nsecs_real); 882 882 } 883 - EXPORT_SYMBOL(getnstime_raw_and_real); 883 + EXPORT_SYMBOL(ktime_get_raw_and_real_ts64); 884 884 885 885 #endif /* CONFIG_NTP_PPS */ 886 886 ··· 2025 2025 /** 2026 2026 * hardpps() - Accessor function to NTP __hardpps function 2027 2027 */ 2028 - void hardpps(const struct timespec *phase_ts, const struct timespec *raw_ts) 2028 + void hardpps(const struct timespec64 *phase_ts, const struct timespec64 *raw_ts) 2029 2029 { 2030 2030 unsigned long flags; 2031 2031