aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/time/timekeeping.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/time/timekeeping.c')
-rw-r--r--kernel/time/timekeeping.c73
1 files changed, 34 insertions, 39 deletions
diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
index 49cbceef5deb..4786df904c22 100644
--- a/kernel/time/timekeeping.c
+++ b/kernel/time/timekeeping.c
@@ -705,18 +705,19 @@ static void timekeeping_forward_now(struct timekeeper *tk)
705} 705}
706 706
707/** 707/**
708 * __getnstimeofday64 - Returns the time of day in a timespec64. 708 * ktime_get_real_ts64 - Returns the time of day in a timespec64.
709 * @ts: pointer to the timespec to be set 709 * @ts: pointer to the timespec to be set
710 * 710 *
711 * Updates the time of day in the timespec. 711 * Returns the time of day in a timespec64 (WARN if suspended).
712 * Returns 0 on success, or -ve when suspended (timespec will be undefined).
713 */ 712 */
714int __getnstimeofday64(struct timespec64 *ts) 713void ktime_get_real_ts64(struct timespec64 *ts)
715{ 714{
716 struct timekeeper *tk = &tk_core.timekeeper; 715 struct timekeeper *tk = &tk_core.timekeeper;
717 unsigned long seq; 716 unsigned long seq;
718 u64 nsecs; 717 u64 nsecs;
719 718
719 WARN_ON(timekeeping_suspended);
720
720 do { 721 do {
721 seq = read_seqcount_begin(&tk_core.seq); 722 seq = read_seqcount_begin(&tk_core.seq);
722 723
@@ -727,28 +728,8 @@ int __getnstimeofday64(struct timespec64 *ts)
727 728
728 ts->tv_nsec = 0; 729 ts->tv_nsec = 0;
729 timespec64_add_ns(ts, nsecs); 730 timespec64_add_ns(ts, nsecs);
730
731 /*
732 * Do not bail out early, in case there were callers still using
733 * the value, even in the face of the WARN_ON.
734 */
735 if (unlikely(timekeeping_suspended))
736 return -EAGAIN;
737 return 0;
738}
739EXPORT_SYMBOL(__getnstimeofday64);
740
741/**
742 * getnstimeofday64 - Returns the time of day in a timespec64.
743 * @ts: pointer to the timespec64 to be set
744 *
745 * Returns the time of day in a timespec64 (WARN if suspended).
746 */
747void getnstimeofday64(struct timespec64 *ts)
748{
749 WARN_ON(__getnstimeofday64(ts));
750} 731}
751EXPORT_SYMBOL(getnstimeofday64); 732EXPORT_SYMBOL(ktime_get_real_ts64);
752 733
753ktime_t ktime_get(void) 734ktime_t ktime_get(void)
754{ 735{
@@ -814,6 +795,25 @@ ktime_t ktime_get_with_offset(enum tk_offsets offs)
814} 795}
815EXPORT_SYMBOL_GPL(ktime_get_with_offset); 796EXPORT_SYMBOL_GPL(ktime_get_with_offset);
816 797
798ktime_t ktime_get_coarse_with_offset(enum tk_offsets offs)
799{
800 struct timekeeper *tk = &tk_core.timekeeper;
801 unsigned int seq;
802 ktime_t base, *offset = offsets[offs];
803
804 WARN_ON(timekeeping_suspended);
805
806 do {
807 seq = read_seqcount_begin(&tk_core.seq);
808 base = ktime_add(tk->tkr_mono.base, *offset);
809
810 } while (read_seqcount_retry(&tk_core.seq, seq));
811
812 return base;
813
814}
815EXPORT_SYMBOL_GPL(ktime_get_coarse_with_offset);
816
817/** 817/**
818 * ktime_mono_to_any() - convert mononotic time to any other time 818 * ktime_mono_to_any() - convert mononotic time to any other time
819 * @tmono: time to convert. 819 * @tmono: time to convert.
@@ -1410,12 +1410,12 @@ int timekeeping_notify(struct clocksource *clock)
1410} 1410}
1411 1411
1412/** 1412/**
1413 * getrawmonotonic64 - Returns the raw monotonic time in a timespec 1413 * ktime_get_raw_ts64 - Returns the raw monotonic time in a timespec
1414 * @ts: pointer to the timespec64 to be set 1414 * @ts: pointer to the timespec64 to be set
1415 * 1415 *
1416 * Returns the raw monotonic time (completely un-modified by ntp) 1416 * Returns the raw monotonic time (completely un-modified by ntp)
1417 */ 1417 */
1418void getrawmonotonic64(struct timespec64 *ts) 1418void ktime_get_raw_ts64(struct timespec64 *ts)
1419{ 1419{
1420 struct timekeeper *tk = &tk_core.timekeeper; 1420 struct timekeeper *tk = &tk_core.timekeeper;
1421 unsigned long seq; 1421 unsigned long seq;
@@ -1431,7 +1431,7 @@ void getrawmonotonic64(struct timespec64 *ts)
1431 ts->tv_nsec = 0; 1431 ts->tv_nsec = 0;
1432 timespec64_add_ns(ts, nsecs); 1432 timespec64_add_ns(ts, nsecs);
1433} 1433}
1434EXPORT_SYMBOL(getrawmonotonic64); 1434EXPORT_SYMBOL(ktime_get_raw_ts64);
1435 1435
1436 1436
1437/** 1437/**
@@ -2133,23 +2133,20 @@ unsigned long get_seconds(void)
2133} 2133}
2134EXPORT_SYMBOL(get_seconds); 2134EXPORT_SYMBOL(get_seconds);
2135 2135
2136struct timespec64 current_kernel_time64(void) 2136void ktime_get_coarse_real_ts64(struct timespec64 *ts)
2137{ 2137{
2138 struct timekeeper *tk = &tk_core.timekeeper; 2138 struct timekeeper *tk = &tk_core.timekeeper;
2139 struct timespec64 now;
2140 unsigned long seq; 2139 unsigned long seq;
2141 2140
2142 do { 2141 do {
2143 seq = read_seqcount_begin(&tk_core.seq); 2142 seq = read_seqcount_begin(&tk_core.seq);
2144 2143
2145 now = tk_xtime(tk); 2144 *ts = tk_xtime(tk);
2146 } while (read_seqcount_retry(&tk_core.seq, seq)); 2145 } while (read_seqcount_retry(&tk_core.seq, seq));
2147
2148 return now;
2149} 2146}
2150EXPORT_SYMBOL(current_kernel_time64); 2147EXPORT_SYMBOL(ktime_get_coarse_real_ts64);
2151 2148
2152struct timespec64 get_monotonic_coarse64(void) 2149void ktime_get_coarse_ts64(struct timespec64 *ts)
2153{ 2150{
2154 struct timekeeper *tk = &tk_core.timekeeper; 2151 struct timekeeper *tk = &tk_core.timekeeper;
2155 struct timespec64 now, mono; 2152 struct timespec64 now, mono;
@@ -2162,12 +2159,10 @@ struct timespec64 get_monotonic_coarse64(void)
2162 mono = tk->wall_to_monotonic; 2159 mono = tk->wall_to_monotonic;
2163 } while (read_seqcount_retry(&tk_core.seq, seq)); 2160 } while (read_seqcount_retry(&tk_core.seq, seq));
2164 2161
2165 set_normalized_timespec64(&now, now.tv_sec + mono.tv_sec, 2162 set_normalized_timespec64(ts, now.tv_sec + mono.tv_sec,
2166 now.tv_nsec + mono.tv_nsec); 2163 now.tv_nsec + mono.tv_nsec);
2167
2168 return now;
2169} 2164}
2170EXPORT_SYMBOL(get_monotonic_coarse64); 2165EXPORT_SYMBOL(ktime_get_coarse_ts64);
2171 2166
2172/* 2167/*
2173 * Must hold jiffies_lock 2168 * Must hold jiffies_lock