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

Merge branch 'timers-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip

Pull timer core updates from Thomas Gleixner:
"The time(r) departement provides:

- more infrastructure work on the year 2038 issue

- a few fixes in the Armada SoC timers

- the usual pile of fixlets and improvements"

* 'timers-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
clocksource: armada-370-xp: Use the reference clock on A375 SoC
watchdog: orion: Use the reference clock on Armada 375 SoC
clocksource: armada-370-xp: Add missing clock enable
time: Fix sign bug in NTP mult overflow warning
time: Remove timekeeping_inject_sleeptime()
rtc: Update suspend/resume timing to use 64bit time
rtc/lib: Provide y2038 safe rtc_tm_to_time()/rtc_time_to_tm() replacement
time: Fixup comments to reflect usage of timespec64
time: Expose get_monotonic_coarse64() for in-kernel uses
time: Expose getrawmonotonic64 for in-kernel uses
time: Provide y2038 safe mktime() replacement
time: Provide y2038 safe timekeeping_inject_sleeptime() replacement
time: Provide y2038 safe do_settimeofday() replacement
time: Complete NTP adjustment threshold judging conditions
time: Avoid possible NTP adjustment mult overflow.
time: Rename udelay_test.c to test_udelay.c
clocksource: sirf: Remove hard-coded clock rate

+253 -100
+6 -3
Documentation/devicetree/bindings/timer/marvell,armada-370-xp-timer.txt
··· 2 2 --------------------------------------- 3 3 4 4 Required properties: 5 - - compatible: Should be either "marvell,armada-370-timer" or 6 - "marvell,armada-xp-timer" as appropriate. 5 + - compatible: Should be one of the following 6 + "marvell,armada-370-timer", 7 + "marvell,armada-375-timer", 8 + "marvell,armada-xp-timer". 7 9 - interrupts: Should contain the list of Global Timer interrupts and 8 10 then local timer interrupts 9 11 - reg: Should contain location and length for timers register. First ··· 15 13 Clocks required for compatible = "marvell,armada-370-timer": 16 14 - clocks : Must contain a single entry describing the clock input 17 15 18 - Clocks required for compatible = "marvell,armada-xp-timer": 16 + Clocks required for compatibles = "marvell,armada-xp-timer", 17 + "marvell,armada-375-timer": 19 18 - clocks : Must contain an entry for each entry in clock-names. 20 19 - clock-names : Must include the following entries: 21 20 "nbclk" (L2/coherency fabric clock),
+13
Documentation/devicetree/bindings/watchdog/marvel.txt
··· 17 17 - reg : A third entry is mandatory and should contain the 18 18 shared mask/unmask RSTOUT address. 19 19 20 + Clocks required for compatibles = "marvell,orion-wdt", 21 + "marvell,armada-370-wdt": 22 + - clocks : Must contain a single entry describing the clock input 23 + 24 + Clocks required for compatibles = "marvell,armada-xp-wdt" 25 + "marvell,armada-375-wdt" 26 + "marvell,armada-380-wdt": 27 + - clocks : Must contain an entry for each entry in clock-names. 28 + - clock-names : Must include the following entries: 29 + "nbclk" (L2/coherency fabric clock), 30 + "fixed" (Reference 25 MHz fixed-clock). 31 + 20 32 Optional properties: 21 33 22 34 - interrupts : Contains the IRQ for watchdog expiration ··· 42 30 interrupts = <3>; 43 31 timeout-sec = <10>; 44 32 status = "okay"; 33 + clocks = <&gate_clk 7>; 45 34 };
+30
drivers/clocksource/time-armada-370-xp.c
··· 318 318 319 319 /* The 25Mhz fixed clock is mandatory, and must always be available */ 320 320 BUG_ON(IS_ERR(clk)); 321 + clk_prepare_enable(clk); 321 322 timer_clk = clk_get_rate(clk); 322 323 323 324 armada_370_xp_timer_common_init(np); ··· 326 325 CLOCKSOURCE_OF_DECLARE(armada_xp, "marvell,armada-xp-timer", 327 326 armada_xp_timer_init); 328 327 328 + static void __init armada_375_timer_init(struct device_node *np) 329 + { 330 + struct clk *clk; 331 + 332 + clk = of_clk_get_by_name(np, "fixed"); 333 + if (!IS_ERR(clk)) { 334 + clk_prepare_enable(clk); 335 + timer_clk = clk_get_rate(clk); 336 + } else { 337 + 338 + /* 339 + * This fallback is required in order to retain proper 340 + * devicetree backwards compatibility. 341 + */ 342 + clk = of_clk_get(np, 0); 343 + 344 + /* Must have at least a clock */ 345 + BUG_ON(IS_ERR(clk)); 346 + clk_prepare_enable(clk); 347 + timer_clk = clk_get_rate(clk) / TIMER_DIVIDER; 348 + timer25Mhz = false; 349 + } 350 + 351 + armada_370_xp_timer_common_init(np); 352 + } 353 + CLOCKSOURCE_OF_DECLARE(armada_375, "marvell,armada-375-timer", 354 + armada_375_timer_init); 355 + 329 356 static void __init armada_370_timer_init(struct device_node *np) 330 357 { 331 358 struct clk *clk = of_clk_get(np, 0); 332 359 333 360 BUG_ON(IS_ERR(clk)); 361 + clk_prepare_enable(clk); 334 362 timer_clk = clk_get_rate(clk) / TIMER_DIVIDER; 335 363 timer25Mhz = false; 336 364
+9 -14
drivers/clocksource/timer-marco.c
··· 20 20 #include <linux/of_address.h> 21 21 #include <linux/sched_clock.h> 22 22 23 - #define MARCO_CLOCK_FREQ 1000000 24 - 25 23 #define SIRFSOC_TIMER_32COUNTER_0_CTRL 0x0000 26 24 #define SIRFSOC_TIMER_32COUNTER_1_CTRL 0x0004 27 25 #define SIRFSOC_TIMER_MATCH_0 0x0018 ··· 37 39 #define SIRFSOC_TIMER_64COUNTER_RLATCHED_HI 0x0080 38 40 39 41 #define SIRFSOC_TIMER_REG_CNT 6 42 + 43 + static unsigned long marco_timer_rate; 40 44 41 45 static const u32 sirfsoc_timer_reg_list[SIRFSOC_TIMER_REG_CNT] = { 42 46 SIRFSOC_TIMER_WATCHDOG_EN, ··· 195 195 ce->rating = 200; 196 196 ce->set_mode = sirfsoc_timer_set_mode; 197 197 ce->set_next_event = sirfsoc_timer_set_next_event; 198 - clockevents_calc_mult_shift(ce, MARCO_CLOCK_FREQ, 60); 198 + clockevents_calc_mult_shift(ce, marco_timer_rate, 60); 199 199 ce->max_delta_ns = clockevent_delta2ns(-2, ce); 200 200 ce->min_delta_ns = clockevent_delta2ns(2, ce); 201 201 ce->cpumask = cpumask_of(cpu); ··· 257 257 /* initialize the kernel jiffy timer source */ 258 258 static void __init sirfsoc_marco_timer_init(struct device_node *np) 259 259 { 260 - unsigned long rate; 261 260 u32 timer_div; 262 261 struct clk *clk; 263 262 ··· 265 266 266 267 BUG_ON(clk_prepare_enable(clk)); 267 268 268 - rate = clk_get_rate(clk); 269 + marco_timer_rate = clk_get_rate(clk); 269 270 270 - BUG_ON(rate < MARCO_CLOCK_FREQ); 271 - BUG_ON(rate % MARCO_CLOCK_FREQ); 272 - 273 - /* Initialize the timer dividers */ 274 - timer_div = rate / MARCO_CLOCK_FREQ - 1; 275 - writel_relaxed(timer_div << 16, sirfsoc_timer_base + SIRFSOC_TIMER_64COUNTER_CTRL); 276 - writel_relaxed(timer_div << 16, sirfsoc_timer_base + SIRFSOC_TIMER_32COUNTER_0_CTRL); 277 - writel_relaxed(timer_div << 16, sirfsoc_timer_base + SIRFSOC_TIMER_32COUNTER_1_CTRL); 271 + /* timer dividers: 0, not divided */ 272 + writel_relaxed(0, sirfsoc_timer_base + SIRFSOC_TIMER_64COUNTER_CTRL); 273 + writel_relaxed(0, sirfsoc_timer_base + SIRFSOC_TIMER_32COUNTER_0_CTRL); 274 + writel_relaxed(0, sirfsoc_timer_base + SIRFSOC_TIMER_32COUNTER_1_CTRL); 278 275 279 276 /* Initialize timer counters to 0 */ 280 277 writel_relaxed(0, sirfsoc_timer_base + SIRFSOC_TIMER_64COUNTER_LOAD_LO); ··· 283 288 /* Clear all interrupts */ 284 289 writel_relaxed(0xFFFF, sirfsoc_timer_base + SIRFSOC_TIMER_INTR_STATUS); 285 290 286 - BUG_ON(clocksource_register_hz(&sirfsoc_clocksource, MARCO_CLOCK_FREQ)); 291 + BUG_ON(clocksource_register_hz(&sirfsoc_clocksource, marco_timer_rate)); 287 292 288 293 sirfsoc_clockevent_init(); 289 294 }
+15 -15
drivers/rtc/class.c
··· 45 45 * system's wall clock; restore it on resume(). 46 46 */ 47 47 48 - static struct timespec old_rtc, old_system, old_delta; 48 + static struct timespec64 old_rtc, old_system, old_delta; 49 49 50 50 51 51 static int rtc_suspend(struct device *dev) 52 52 { 53 53 struct rtc_device *rtc = to_rtc_device(dev); 54 54 struct rtc_time tm; 55 - struct timespec delta, delta_delta; 55 + struct timespec64 delta, delta_delta; 56 56 int err; 57 57 58 58 if (has_persistent_clock()) ··· 68 68 return 0; 69 69 } 70 70 71 - getnstimeofday(&old_system); 72 - rtc_tm_to_time(&tm, &old_rtc.tv_sec); 71 + getnstimeofday64(&old_system); 72 + old_rtc.tv_sec = rtc_tm_to_time64(&tm); 73 73 74 74 75 75 /* ··· 78 78 * try to compensate so the difference in system time 79 79 * and rtc time stays close to constant. 80 80 */ 81 - delta = timespec_sub(old_system, old_rtc); 82 - delta_delta = timespec_sub(delta, old_delta); 81 + delta = timespec64_sub(old_system, old_rtc); 82 + delta_delta = timespec64_sub(delta, old_delta); 83 83 if (delta_delta.tv_sec < -2 || delta_delta.tv_sec >= 2) { 84 84 /* 85 85 * if delta_delta is too large, assume time correction ··· 88 88 old_delta = delta; 89 89 } else { 90 90 /* Otherwise try to adjust old_system to compensate */ 91 - old_system = timespec_sub(old_system, delta_delta); 91 + old_system = timespec64_sub(old_system, delta_delta); 92 92 } 93 93 94 94 return 0; ··· 98 98 { 99 99 struct rtc_device *rtc = to_rtc_device(dev); 100 100 struct rtc_time tm; 101 - struct timespec new_system, new_rtc; 102 - struct timespec sleep_time; 101 + struct timespec64 new_system, new_rtc; 102 + struct timespec64 sleep_time; 103 103 int err; 104 104 105 105 if (has_persistent_clock()) ··· 110 110 return 0; 111 111 112 112 /* snapshot the current rtc and system time at resume */ 113 - getnstimeofday(&new_system); 113 + getnstimeofday64(&new_system); 114 114 err = rtc_read_time(rtc, &tm); 115 115 if (err < 0) { 116 116 pr_debug("%s: fail to read rtc time\n", dev_name(&rtc->dev)); ··· 121 121 pr_debug("%s: bogus resume time\n", dev_name(&rtc->dev)); 122 122 return 0; 123 123 } 124 - rtc_tm_to_time(&tm, &new_rtc.tv_sec); 124 + new_rtc.tv_sec = rtc_tm_to_time64(&tm); 125 125 new_rtc.tv_nsec = 0; 126 126 127 127 if (new_rtc.tv_sec < old_rtc.tv_sec) { ··· 130 130 } 131 131 132 132 /* calculate the RTC time delta (sleep time)*/ 133 - sleep_time = timespec_sub(new_rtc, old_rtc); 133 + sleep_time = timespec64_sub(new_rtc, old_rtc); 134 134 135 135 /* 136 136 * Since these RTC suspend/resume handlers are not called ··· 139 139 * so subtract kernel run-time between rtc_suspend to rtc_resume 140 140 * to keep things accurate. 141 141 */ 142 - sleep_time = timespec_sub(sleep_time, 143 - timespec_sub(new_system, old_system)); 142 + sleep_time = timespec64_sub(sleep_time, 143 + timespec64_sub(new_system, old_system)); 144 144 145 145 if (sleep_time.tv_sec >= 0) 146 - timekeeping_inject_sleeptime(&sleep_time); 146 + timekeeping_inject_sleeptime64(&sleep_time); 147 147 rtc_hctosys_ret = 0; 148 148 return 0; 149 149 }
+20 -18
drivers/rtc/rtc-lib.c
··· 45 45 } 46 46 EXPORT_SYMBOL(rtc_year_days); 47 47 48 + 48 49 /* 50 + * rtc_time_to_tm64 - Converts time64_t to rtc_time. 49 51 * Convert seconds since 01-01-1970 00:00:00 to Gregorian date. 50 52 */ 51 - void rtc_time_to_tm(unsigned long time, struct rtc_time *tm) 53 + void rtc_time64_to_tm(time64_t time, struct rtc_time *tm) 52 54 { 53 55 unsigned int month, year; 56 + unsigned long secs; 54 57 int days; 55 58 56 - days = time / 86400; 57 - time -= (unsigned int) days * 86400; 59 + /* time must be positive */ 60 + days = div_s64(time, 86400); 61 + secs = time - (unsigned int) days * 86400; 58 62 59 63 /* day of the week, 1970-01-01 was a Thursday */ 60 64 tm->tm_wday = (days + 4) % 7; ··· 85 81 tm->tm_mon = month; 86 82 tm->tm_mday = days + 1; 87 83 88 - tm->tm_hour = time / 3600; 89 - time -= tm->tm_hour * 3600; 90 - tm->tm_min = time / 60; 91 - tm->tm_sec = time - tm->tm_min * 60; 84 + tm->tm_hour = secs / 3600; 85 + secs -= tm->tm_hour * 3600; 86 + tm->tm_min = secs / 60; 87 + tm->tm_sec = secs - tm->tm_min * 60; 92 88 93 89 tm->tm_isdst = 0; 94 90 } 95 - EXPORT_SYMBOL(rtc_time_to_tm); 91 + EXPORT_SYMBOL(rtc_time64_to_tm); 96 92 97 93 /* 98 94 * Does the rtc_time represent a valid date/time? ··· 113 109 EXPORT_SYMBOL(rtc_valid_tm); 114 110 115 111 /* 112 + * rtc_tm_to_time64 - Converts rtc_time to time64_t. 116 113 * Convert Gregorian date to seconds since 01-01-1970 00:00:00. 117 114 */ 118 - int rtc_tm_to_time(struct rtc_time *tm, unsigned long *time) 115 + time64_t rtc_tm_to_time64(struct rtc_time *tm) 119 116 { 120 - *time = mktime(tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, 117 + return mktime64(tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, 121 118 tm->tm_hour, tm->tm_min, tm->tm_sec); 122 - return 0; 123 119 } 124 - EXPORT_SYMBOL(rtc_tm_to_time); 120 + EXPORT_SYMBOL(rtc_tm_to_time64); 125 121 126 122 /* 127 123 * Convert rtc_time to ktime 128 124 */ 129 125 ktime_t rtc_tm_to_ktime(struct rtc_time tm) 130 126 { 131 - time_t time; 132 - rtc_tm_to_time(&tm, &time); 133 - return ktime_set(time, 0); 127 + return ktime_set(rtc_tm_to_time64(&tm), 0); 134 128 } 135 129 EXPORT_SYMBOL_GPL(rtc_tm_to_ktime); 136 130 ··· 137 135 */ 138 136 struct rtc_time rtc_ktime_to_tm(ktime_t kt) 139 137 { 140 - struct timespec ts; 138 + struct timespec64 ts; 141 139 struct rtc_time ret; 142 140 143 - ts = ktime_to_timespec(kt); 141 + ts = ktime_to_timespec64(kt); 144 142 /* Round up any ns */ 145 143 if (ts.tv_nsec) 146 144 ts.tv_sec++; 147 - rtc_time_to_tm(ts.tv_sec, &ret); 145 + rtc_time64_to_tm(ts.tv_sec, &ret); 148 146 return ret; 149 147 } 150 148 EXPORT_SYMBOL_GPL(rtc_ktime_to_tm);
+41 -1
drivers/watchdog/orion_wdt.c
··· 114 114 return 0; 115 115 } 116 116 117 + static int armada375_wdt_clock_init(struct platform_device *pdev, 118 + struct orion_watchdog *dev) 119 + { 120 + int ret; 121 + 122 + dev->clk = of_clk_get_by_name(pdev->dev.of_node, "fixed"); 123 + if (!IS_ERR(dev->clk)) { 124 + ret = clk_prepare_enable(dev->clk); 125 + if (ret) { 126 + clk_put(dev->clk); 127 + return ret; 128 + } 129 + 130 + atomic_io_modify(dev->reg + TIMER_CTRL, 131 + WDT_AXP_FIXED_ENABLE_BIT, 132 + WDT_AXP_FIXED_ENABLE_BIT); 133 + dev->clk_rate = clk_get_rate(dev->clk); 134 + 135 + return 0; 136 + } 137 + 138 + /* Mandatory fallback for proper devicetree backward compatibility */ 139 + dev->clk = clk_get(&pdev->dev, NULL); 140 + if (IS_ERR(dev->clk)) 141 + return PTR_ERR(dev->clk); 142 + 143 + ret = clk_prepare_enable(dev->clk); 144 + if (ret) { 145 + clk_put(dev->clk); 146 + return ret; 147 + } 148 + 149 + atomic_io_modify(dev->reg + TIMER_CTRL, 150 + WDT_A370_RATIO_MASK(WDT_A370_RATIO_SHIFT), 151 + WDT_A370_RATIO_MASK(WDT_A370_RATIO_SHIFT)); 152 + dev->clk_rate = clk_get_rate(dev->clk) / WDT_A370_RATIO; 153 + 154 + return 0; 155 + } 156 + 117 157 static int armadaxp_wdt_clock_init(struct platform_device *pdev, 118 158 struct orion_watchdog *dev) 119 159 { ··· 434 394 .rstout_mask_bit = BIT(10), 435 395 .wdt_enable_bit = BIT(8), 436 396 .wdt_counter_offset = 0x34, 437 - .clock_init = armada370_wdt_clock_init, 397 + .clock_init = armada375_wdt_clock_init, 438 398 .enabled = armada375_enabled, 439 399 .start = armada375_start, 440 400 .stop = armada375_stop,
+19 -2
include/linux/rtc.h
··· 19 19 extern int rtc_month_days(unsigned int month, unsigned int year); 20 20 extern int rtc_year_days(unsigned int day, unsigned int month, unsigned int year); 21 21 extern int rtc_valid_tm(struct rtc_time *tm); 22 - extern int rtc_tm_to_time(struct rtc_time *tm, unsigned long *time); 23 - extern void rtc_time_to_tm(unsigned long time, struct rtc_time *tm); 22 + extern time64_t rtc_tm_to_time64(struct rtc_time *tm); 23 + extern void rtc_time64_to_tm(time64_t time, struct rtc_time *tm); 24 24 ktime_t rtc_tm_to_ktime(struct rtc_time tm); 25 25 struct rtc_time rtc_ktime_to_tm(ktime_t kt); 26 26 27 + /** 28 + * Deprecated. Use rtc_time64_to_tm(). 29 + */ 30 + static inline void rtc_time_to_tm(unsigned long time, struct rtc_time *tm) 31 + { 32 + rtc_time64_to_tm(time, tm); 33 + } 34 + 35 + /** 36 + * Deprecated. Use rtc_tm_to_time64(). 37 + */ 38 + static inline int rtc_tm_to_time(struct rtc_time *tm, unsigned long *time) 39 + { 40 + *time = rtc_tm_to_time64(tm); 41 + 42 + return 0; 43 + } 27 44 28 45 #include <linux/device.h> 29 46 #include <linux/seq_file.h>
+14 -3
include/linux/time.h
··· 39 39 return lhs->tv_usec - rhs->tv_usec; 40 40 } 41 41 42 - extern unsigned long mktime(const unsigned int year, const unsigned int mon, 43 - const unsigned int day, const unsigned int hour, 44 - const unsigned int min, const unsigned int sec); 42 + extern time64_t mktime64(const unsigned int year, const unsigned int mon, 43 + const unsigned int day, const unsigned int hour, 44 + const unsigned int min, const unsigned int sec); 45 + 46 + /** 47 + * Deprecated. Use mktime64(). 48 + */ 49 + static inline unsigned long mktime(const unsigned int year, 50 + const unsigned int mon, const unsigned int day, 51 + const unsigned int hour, const unsigned int min, 52 + const unsigned int sec) 53 + { 54 + return mktime64(year, mon, day, hour, min, sec); 55 + } 45 56 46 57 extern void set_normalized_timespec(struct timespec *ts, time_t sec, s64 nsec); 47 58
+45 -4
include/linux/timekeeping.h
··· 10 10 * Get and set timeofday 11 11 */ 12 12 extern void do_gettimeofday(struct timeval *tv); 13 - extern int do_settimeofday(const struct timespec *tv); 13 + extern int do_settimeofday64(const struct timespec64 *ts); 14 14 extern int do_sys_settimeofday(const struct timespec *tv, 15 15 const struct timezone *tz); 16 16 ··· 25 25 /* 26 26 * timespec based interfaces 27 27 */ 28 - struct timespec get_monotonic_coarse(void); 29 - extern void getrawmonotonic(struct timespec *ts); 28 + struct timespec64 get_monotonic_coarse64(void); 29 + extern void getrawmonotonic64(struct timespec64 *ts); 30 30 extern void ktime_get_ts64(struct timespec64 *ts); 31 31 32 32 extern int __getnstimeofday64(struct timespec64 *tv); 33 33 extern void getnstimeofday64(struct timespec64 *tv); 34 34 35 35 #if BITS_PER_LONG == 64 36 + /** 37 + * Deprecated. Use do_settimeofday64(). 38 + */ 39 + static inline int do_settimeofday(const struct timespec *ts) 40 + { 41 + return do_settimeofday64(ts); 42 + } 43 + 36 44 static inline int __getnstimeofday(struct timespec *ts) 37 45 { 38 46 return __getnstimeofday64(ts); ··· 61 53 getnstimeofday64(ts); 62 54 } 63 55 56 + static inline void getrawmonotonic(struct timespec *ts) 57 + { 58 + getrawmonotonic64(ts); 59 + } 60 + 61 + static inline struct timespec get_monotonic_coarse(void) 62 + { 63 + return get_monotonic_coarse64(); 64 + } 64 65 #else 66 + /** 67 + * Deprecated. Use do_settimeofday64(). 68 + */ 69 + static inline int do_settimeofday(const struct timespec *ts) 70 + { 71 + struct timespec64 ts64; 72 + 73 + ts64 = timespec_to_timespec64(*ts); 74 + return do_settimeofday64(&ts64); 75 + } 76 + 65 77 static inline int __getnstimeofday(struct timespec *ts) 66 78 { 67 79 struct timespec64 ts64; ··· 113 85 114 86 getnstimeofday64(&ts64); 115 87 *ts = timespec64_to_timespec(ts64); 88 + } 89 + 90 + static inline void getrawmonotonic(struct timespec *ts) 91 + { 92 + struct timespec64 ts64; 93 + 94 + getrawmonotonic64(&ts64); 95 + *ts = timespec64_to_timespec(ts64); 96 + } 97 + 98 + static inline struct timespec get_monotonic_coarse(void) 99 + { 100 + return timespec64_to_timespec(get_monotonic_coarse64()); 116 101 } 117 102 #endif 118 103 ··· 223 182 /* 224 183 * RTC specific 225 184 */ 226 - extern void timekeeping_inject_sleeptime(struct timespec *delta); 185 + extern void timekeeping_inject_sleeptime64(struct timespec64 *delta); 227 186 228 187 /* 229 188 * PPS accessor
+1 -1
kernel/time/Makefile
··· 13 13 obj-$(CONFIG_TICK_ONESHOT) += tick-sched.o 14 14 obj-$(CONFIG_TIMER_STATS) += timer_stats.o 15 15 obj-$(CONFIG_DEBUG_FS) += timekeeping_debug.o 16 - obj-$(CONFIG_TEST_UDELAY) += udelay_test.o 16 + obj-$(CONFIG_TEST_UDELAY) += test_udelay.o 17 17 18 18 $(obj)/time.o: $(obj)/timeconst.h 19 19
+8 -12
kernel/time/time.c
··· 304 304 } 305 305 EXPORT_SYMBOL(timespec_trunc); 306 306 307 - /* Converts Gregorian date to seconds since 1970-01-01 00:00:00. 307 + /* 308 + * mktime64 - Converts date to seconds. 309 + * Converts Gregorian date to seconds since 1970-01-01 00:00:00. 308 310 * Assumes input in normal date format, i.e. 1980-12-31 23:59:59 309 311 * => year=1980, mon=12, day=31, hour=23, min=59, sec=59. 310 312 * ··· 316 314 * -year/100+year/400 terms, and add 10.] 317 315 * 318 316 * This algorithm was first published by Gauss (I think). 319 - * 320 - * WARNING: this function will overflow on 2106-02-07 06:28:16 on 321 - * machines where long is 32-bit! (However, as time_t is signed, we 322 - * will already get problems at other places on 2038-01-19 03:14:08) 323 317 */ 324 - unsigned long 325 - mktime(const unsigned int year0, const unsigned int mon0, 326 - const unsigned int day, const unsigned int hour, 327 - const unsigned int min, const unsigned int sec) 318 + time64_t mktime64(const unsigned int year0, const unsigned int mon0, 319 + const unsigned int day, const unsigned int hour, 320 + const unsigned int min, const unsigned int sec) 328 321 { 329 322 unsigned int mon = mon0, year = year0; 330 323 ··· 329 332 year -= 1; 330 333 } 331 334 332 - return ((((unsigned long) 335 + return ((((time64_t) 333 336 (year/4 - year/100 + year/400 + 367*mon/12 + day) + 334 337 year*365 - 719499 335 338 )*24 + hour /* now have hours */ 336 339 )*60 + min /* now have minutes */ 337 340 )*60 + sec; /* finally seconds */ 338 341 } 339 - 340 - EXPORT_SYMBOL(mktime); 342 + EXPORT_SYMBOL(mktime64); 341 343 342 344 /** 343 345 * set_normalized_timespec - set timespec sec and nsec parts and normalize
+32 -27
kernel/time/timekeeping.c
··· 519 519 520 520 /** 521 521 * getnstimeofday64 - Returns the time of day in a timespec64. 522 - * @ts: pointer to the timespec to be set 522 + * @ts: pointer to the timespec64 to be set 523 523 * 524 - * Returns the time of day in a timespec (WARN if suspended). 524 + * Returns the time of day in a timespec64 (WARN if suspended). 525 525 */ 526 526 void getnstimeofday64(struct timespec64 *ts) 527 527 { ··· 623 623 * 624 624 * The function calculates the monotonic clock from the realtime 625 625 * clock and the wall_to_monotonic offset and stores the result 626 - * in normalized timespec format in the variable pointed to by @ts. 626 + * in normalized timespec64 format in the variable pointed to by @ts. 627 627 */ 628 628 void ktime_get_ts64(struct timespec64 *ts) 629 629 { ··· 703 703 EXPORT_SYMBOL(do_gettimeofday); 704 704 705 705 /** 706 - * do_settimeofday - Sets the time of day 707 - * @tv: pointer to the timespec variable containing the new time 706 + * do_settimeofday64 - Sets the time of day. 707 + * @ts: pointer to the timespec64 variable containing the new time 708 708 * 709 709 * Sets the time of day to the new time and update NTP and notify hrtimers 710 710 */ 711 - int do_settimeofday(const struct timespec *tv) 711 + int do_settimeofday64(const struct timespec64 *ts) 712 712 { 713 713 struct timekeeper *tk = &tk_core.timekeeper; 714 - struct timespec64 ts_delta, xt, tmp; 714 + struct timespec64 ts_delta, xt; 715 715 unsigned long flags; 716 716 717 - if (!timespec_valid_strict(tv)) 717 + if (!timespec64_valid_strict(ts)) 718 718 return -EINVAL; 719 719 720 720 raw_spin_lock_irqsave(&timekeeper_lock, flags); ··· 723 723 timekeeping_forward_now(tk); 724 724 725 725 xt = tk_xtime(tk); 726 - ts_delta.tv_sec = tv->tv_sec - xt.tv_sec; 727 - ts_delta.tv_nsec = tv->tv_nsec - xt.tv_nsec; 726 + ts_delta.tv_sec = ts->tv_sec - xt.tv_sec; 727 + ts_delta.tv_nsec = ts->tv_nsec - xt.tv_nsec; 728 728 729 729 tk_set_wall_to_mono(tk, timespec64_sub(tk->wall_to_monotonic, ts_delta)); 730 730 731 - tmp = timespec_to_timespec64(*tv); 732 - tk_set_xtime(tk, &tmp); 731 + tk_set_xtime(tk, ts); 733 732 734 733 timekeeping_update(tk, TK_CLEAR_NTP | TK_MIRROR | TK_CLOCK_WAS_SET); 735 734 ··· 740 741 741 742 return 0; 742 743 } 743 - EXPORT_SYMBOL(do_settimeofday); 744 + EXPORT_SYMBOL(do_settimeofday64); 744 745 745 746 /** 746 747 * timekeeping_inject_offset - Adds or subtracts from the current time. ··· 894 895 } 895 896 896 897 /** 897 - * getrawmonotonic - Returns the raw monotonic time in a timespec 898 - * @ts: pointer to the timespec to be set 898 + * getrawmonotonic64 - Returns the raw monotonic time in a timespec 899 + * @ts: pointer to the timespec64 to be set 899 900 * 900 901 * Returns the raw monotonic time (completely un-modified by ntp) 901 902 */ 902 - void getrawmonotonic(struct timespec *ts) 903 + void getrawmonotonic64(struct timespec64 *ts) 903 904 { 904 905 struct timekeeper *tk = &tk_core.timekeeper; 905 906 struct timespec64 ts64; ··· 914 915 } while (read_seqcount_retry(&tk_core.seq, seq)); 915 916 916 917 timespec64_add_ns(&ts64, nsecs); 917 - *ts = timespec64_to_timespec(ts64); 918 + *ts = ts64; 918 919 } 919 - EXPORT_SYMBOL(getrawmonotonic); 920 + EXPORT_SYMBOL(getrawmonotonic64); 921 + 920 922 921 923 /** 922 924 * timekeeping_valid_for_hres - Check if timekeeping is suitable for hres ··· 1068 1068 } 1069 1069 1070 1070 /** 1071 - * timekeeping_inject_sleeptime - Adds suspend interval to timeekeeping values 1072 - * @delta: pointer to a timespec delta value 1071 + * timekeeping_inject_sleeptime64 - Adds suspend interval to timeekeeping values 1072 + * @delta: pointer to a timespec64 delta value 1073 1073 * 1074 1074 * This hook is for architectures that cannot support read_persistent_clock 1075 1075 * because their RTC/persistent clock is only accessible when irqs are enabled. ··· 1077 1077 * This function should only be called by rtc_resume(), and allows 1078 1078 * a suspend offset to be injected into the timekeeping values. 1079 1079 */ 1080 - void timekeeping_inject_sleeptime(struct timespec *delta) 1080 + void timekeeping_inject_sleeptime64(struct timespec64 *delta) 1081 1081 { 1082 1082 struct timekeeper *tk = &tk_core.timekeeper; 1083 - struct timespec64 tmp; 1084 1083 unsigned long flags; 1085 1084 1086 1085 /* ··· 1094 1095 1095 1096 timekeeping_forward_now(tk); 1096 1097 1097 - tmp = timespec_to_timespec64(*delta); 1098 - __timekeeping_inject_sleeptime(tk, &tmp); 1098 + __timekeeping_inject_sleeptime(tk, delta); 1099 1099 1100 1100 timekeeping_update(tk, TK_CLEAR_NTP | TK_MIRROR | TK_CLOCK_WAS_SET); 1101 1101 ··· 1330 1332 * 1331 1333 * XXX - TODO: Doc ntp_error calculation. 1332 1334 */ 1335 + if ((mult_adj > 0) && (tk->tkr.mult + mult_adj < mult_adj)) { 1336 + /* NTP adjustment caused clocksource mult overflow */ 1337 + WARN_ON_ONCE(1); 1338 + return; 1339 + } 1340 + 1333 1341 tk->tkr.mult += mult_adj; 1334 1342 tk->xtime_interval += interval; 1335 1343 tk->tkr.xtime_nsec -= offset; ··· 1401 1397 } 1402 1398 1403 1399 if (unlikely(tk->tkr.clock->maxadj && 1404 - (tk->tkr.mult > tk->tkr.clock->mult + tk->tkr.clock->maxadj))) { 1400 + (abs(tk->tkr.mult - tk->tkr.clock->mult) 1401 + > tk->tkr.clock->maxadj))) { 1405 1402 printk_once(KERN_WARNING 1406 1403 "Adjusting %s more than 11%% (%ld vs %ld)\n", 1407 1404 tk->tkr.clock->name, (long)tk->tkr.mult, ··· 1651 1646 } 1652 1647 EXPORT_SYMBOL(current_kernel_time); 1653 1648 1654 - struct timespec get_monotonic_coarse(void) 1649 + struct timespec64 get_monotonic_coarse64(void) 1655 1650 { 1656 1651 struct timekeeper *tk = &tk_core.timekeeper; 1657 1652 struct timespec64 now, mono; ··· 1667 1662 set_normalized_timespec64(&now, now.tv_sec + mono.tv_sec, 1668 1663 now.tv_nsec + mono.tv_nsec); 1669 1664 1670 - return timespec64_to_timespec(now); 1665 + return now; 1671 1666 } 1672 1667 1673 1668 /*
kernel/time/udelay_test.c kernel/time/test_udelay.c