* [PATCH 0/8] Add y2038 safe replacements for read_boot_clock(), read_persistent_clock() and update_persistent_clock()
@ 2015-03-11 3:15 Xunlei Pang
[not found] ` <1426043715-22043-1-git-send-email-xlpang-KN7UnAbNpbg@public.gmane.org>
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Xunlei Pang @ 2015-03-11 3:15 UTC (permalink / raw)
To: linux-kernel-u79uwXL29TY76Z2rM5mHXA
Cc: rtc-linux-/JYPxA39Uh5TLH3MbocFFw, Thomas Gleixner,
Alessandro Zummo, John Stultz, Arnd Bergmann,
linux-omap-u79uwXL29TY76Z2rM5mHXA, Tony Lindgren,
linux-tegra-u79uwXL29TY76Z2rM5mHXA, Stephen Warren,
linux390-tA70FqPdS9bQT0dZR+AlfA, Martin Schwidefsky, Ralf Baechle,
Arnd Bergmann, Xunlei Pang
From: Xunlei Pang <pang.xunlei-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
read_boot_clock(), read_persistent_clock() and update_persistent_clock()
all use timespec which may have "y2038 problem", thus we are planning on
converting all of them to use timespec64.
The approach we're using is:
1) First of all, add the "__weak" implementaion of xxx_clock64() which uses
xxx_clock() and timespec64.
Let's take read_persistent_clock() as an example. We can create its
y2038-safe version below:
void __weak read_persistent_clock64(struct timespec64 *ts64)
{
struct timespec ts;
read_persistent_clock(&ts);
*ts64 = timespec_to_timespec64(ts);
}
Then, replace all the call sites of xxx_clock() with xxx_clock64() except
the one used by xxx_clock64().
2) Convert every architecture specific xxx_clock() to xxx_clock64() one by one.
At this point, we can convert the three functions at a time if needed, because
most time they're correlated.
3) Remove xxx_clock() after all its architecture specific implementations have been
converted to use corresponding y2038 safe xxx_clock64().
This patchset firstly finished the step1 for all the three functions, then focused
on read_boot_clock() which is simple to go on with step2 and step3 as a whole show.
As for read_persistent_clock() and update_persistent_clock() which are more complex,
requiring many efforts to convert every architecture specific implementation gradually.
The approach used here is Suggested-by: "Arnd Bergmann <arnd-r2nGTMty4D4@public.gmane.org>"
Xunlei Pang (8):
time: Add y2038 safe read_boot_clock64()
time: Add y2038 safe read_persistent_clock64()
time: Add y2038 safe update_persistent_clock64()
ARM: OMAP: 32k counter: Provide y2038-safe
omap_read_persistent_clock() replacement
ARM: tegra: clock: Provide y2038-safe tegra_read_persistent_clock()
replacement
ARM: time: Provide read_boot_clock64() and read_persistent_clock64()
s390: time: Provide read_boot_clock64() and read_persistent_clock64()
time: Remove read_boot_clock()
arch/arm/include/asm/mach/time.h | 3 +--
arch/arm/kernel/time.c | 6 +++---
arch/arm/plat-omap/counter_32k.c | 18 ++++++------------
arch/mips/lasat/sysctl.c | 4 ++--
arch/s390/include/asm/timex.h | 4 ++--
arch/s390/kernel/debug.c | 4 ++--
arch/s390/kernel/time.c | 6 +++---
drivers/clocksource/tegra20_timer.c | 15 +++++++--------
drivers/rtc/systohc.c | 2 +-
include/linux/timekeeping.h | 4 +++-
kernel/time/ntp.c | 13 ++++++++++++-
kernel/time/timekeeping.c | 31 ++++++++++++++++---------------
12 files changed, 58 insertions(+), 52 deletions(-)
--
1.9.1
^ permalink raw reply [flat|nested] 7+ messages in thread[parent not found: <1426043715-22043-1-git-send-email-xlpang-KN7UnAbNpbg@public.gmane.org>]
* [PATCH 1/8] time: Add y2038 safe read_boot_clock64() [not found] ` <1426043715-22043-1-git-send-email-xlpang-KN7UnAbNpbg@public.gmane.org> @ 2015-03-11 3:15 ` Xunlei Pang [not found] ` <OF2C7428FA.095162DD-ON48257E0C.004641E0-48257E0C.004652BC@zte.com.cn> 2015-03-11 3:15 ` [PATCH 2/8] time: Add y2038 safe read_persistent_clock64() Xunlei Pang 1 sibling, 1 reply; 7+ messages in thread From: Xunlei Pang @ 2015-03-11 3:15 UTC (permalink / raw) To: linux-kernel-u79uwXL29TY76Z2rM5mHXA Cc: rtc-linux-/JYPxA39Uh5TLH3MbocFFw, Thomas Gleixner, Alessandro Zummo, John Stultz, Arnd Bergmann, linux-omap-u79uwXL29TY76Z2rM5mHXA, Tony Lindgren, linux-tegra-u79uwXL29TY76Z2rM5mHXA, Stephen Warren, linux390-tA70FqPdS9bQT0dZR+AlfA, Martin Schwidefsky, Ralf Baechle, Arnd Bergmann, Xunlei Pang From: Xunlei Pang <pang.xunlei-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org> As part of addressing in-kernel y2038 issues, this patch adds read_boot_clock64() and replaces all the call sites of read_boot_clock() with this function. This is a __weak implementation, which simply calls the existing y2038 unsafe read_boot_clock(). This allows architecture specific implementations to be converted independently, and eventually the y2038 unsafe read_boot_clock() can be removed after all its architecture specific implementations have been converted to read_boot_clock64(). Suggested-by: Arnd Bergmann <arnd-r2nGTMty4D4@public.gmane.org> Signed-off-by: Xunlei Pang <pang.xunlei-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org> --- include/linux/timekeeping.h | 1 + kernel/time/timekeeping.c | 11 +++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/include/linux/timekeeping.h b/include/linux/timekeeping.h index 3eaae47..d53c522 100644 --- a/include/linux/timekeeping.h +++ b/include/linux/timekeeping.h @@ -263,6 +263,7 @@ static inline bool has_persistent_clock(void) extern void read_persistent_clock(struct timespec *ts); extern void read_boot_clock(struct timespec *ts); +extern void read_boot_clock64(struct timespec64 *ts); extern int update_persistent_clock(struct timespec now); diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c index 91db941..7080c21 100644 --- a/kernel/time/timekeeping.c +++ b/kernel/time/timekeeping.c @@ -1072,6 +1072,14 @@ void __weak read_boot_clock(struct timespec *ts) ts->tv_nsec = 0; } +void __weak read_boot_clock64(struct timespec64 *ts64) +{ + struct timespec ts; + + read_boot_clock(&ts); + *ts64 = timespec_to_timespec64(ts); +} + /* * timekeeping_init - Initializes the clocksource and common timekeeping values */ @@ -1093,8 +1101,7 @@ void __init timekeeping_init(void) } else if (now.tv_sec || now.tv_nsec) persistent_clock_exist = true; - read_boot_clock(&ts); - boot = timespec_to_timespec64(ts); + read_boot_clock64(&boot); if (!timespec64_valid_strict(&boot)) { pr_warn("WARNING: Boot clock returned invalid value!\n" " Check your CMOS/BIOS settings.\n"); -- 1.9.1 ^ permalink raw reply related [flat|nested] 7+ messages in thread
[parent not found: <OF2C7428FA.095162DD-ON48257E0C.004641E0-48257E0C.004652BC@zte.com.cn>]
* Re: [PATCH 1/8] time: Add y2038 safe read_boot_clock64() [not found] ` <OF2C7428FA.095162DD-ON48257E0C.004641E0-48257E0C.004652BC@zte.com.cn> @ 2015-03-18 16:30 ` John Stultz 0 siblings, 0 replies; 7+ messages in thread From: John Stultz @ 2015-03-18 16:30 UTC (permalink / raw) To: pang.xunlei Cc: lkml, Alessandro Zummo, Arnd Bergmann, Arnd Bergmann, linux-omap@vger.kernel.org, linux-tegra@vger.kernel.org, linux390, Xunlei Pang, Ralf Baechle, rtc-linux@googlegroups.com, Martin Schwidefsky, Stephen Warren, Thomas Gleixner, Tony Lindgren On Wed, Mar 18, 2015 at 5:48 AM, <pang.xunlei@zte.com.cn> wrote: > Ping ... Thanks for the reminder. Since there's not been any objections, I'm queuing this up. thanks -john ^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 2/8] time: Add y2038 safe read_persistent_clock64() [not found] ` <1426043715-22043-1-git-send-email-xlpang-KN7UnAbNpbg@public.gmane.org> 2015-03-11 3:15 ` [PATCH 1/8] time: Add y2038 safe read_boot_clock64() Xunlei Pang @ 2015-03-11 3:15 ` Xunlei Pang 1 sibling, 0 replies; 7+ messages in thread From: Xunlei Pang @ 2015-03-11 3:15 UTC (permalink / raw) To: linux-kernel-u79uwXL29TY76Z2rM5mHXA Cc: rtc-linux-/JYPxA39Uh5TLH3MbocFFw, Thomas Gleixner, Alessandro Zummo, John Stultz, Arnd Bergmann, linux-omap-u79uwXL29TY76Z2rM5mHXA, Tony Lindgren, linux-tegra-u79uwXL29TY76Z2rM5mHXA, Stephen Warren, linux390-tA70FqPdS9bQT0dZR+AlfA, Martin Schwidefsky, Ralf Baechle, Arnd Bergmann, Xunlei Pang From: Xunlei Pang <pang.xunlei-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org> As part of addressing in-kernel y2038 issues, this patch adds read_persistent_clock64() and replaces all the call sites of read_persistent_clock() with this function. This is a __weak implementation, which simply calls the existing y2038 unsafe read_persistent_clock(). This allows architecture specific implementations to be converted independently, and eventually the y2038 unsafe read_persistent_clock() can be removed after all its architecture specific implementations have been converted to read_persistent_clock64(). Suggested-by: Arnd Bergmann <arnd-r2nGTMty4D4@public.gmane.org> Signed-off-by: Xunlei Pang <pang.xunlei-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org> --- arch/mips/lasat/sysctl.c | 4 ++-- include/linux/timekeeping.h | 1 + kernel/time/timekeeping.c | 22 ++++++++++++---------- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/arch/mips/lasat/sysctl.c b/arch/mips/lasat/sysctl.c index 3b7f65c..cf9b4633 100644 --- a/arch/mips/lasat/sysctl.c +++ b/arch/mips/lasat/sysctl.c @@ -75,11 +75,11 @@ static int rtctmp; int proc_dolasatrtc(struct ctl_table *table, int write, void *buffer, size_t *lenp, loff_t *ppos) { - struct timespec ts; + struct timespec64 ts; int r; if (!write) { - read_persistent_clock(&ts); + read_persistent_clock64(&ts); rtctmp = ts.tv_sec; /* check for time < 0 and set to 0 */ if (rtctmp < 0) diff --git a/include/linux/timekeeping.h b/include/linux/timekeeping.h index d53c522..ff56a0f 100644 --- a/include/linux/timekeeping.h +++ b/include/linux/timekeeping.h @@ -262,6 +262,7 @@ static inline bool has_persistent_clock(void) } extern void read_persistent_clock(struct timespec *ts); +extern void read_persistent_clock64(struct timespec64 *ts); extern void read_boot_clock(struct timespec *ts); extern void read_boot_clock64(struct timespec64 *ts); extern int update_persistent_clock(struct timespec now); diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c index 7080c21..0e5a696 100644 --- a/kernel/time/timekeeping.c +++ b/kernel/time/timekeeping.c @@ -1057,6 +1057,14 @@ void __weak read_persistent_clock(struct timespec *ts) ts->tv_nsec = 0; } +void __weak read_persistent_clock64(struct timespec64 *ts64) +{ + struct timespec ts; + + read_persistent_clock(&ts); + *ts64 = timespec_to_timespec64(ts); +} + /** * read_boot_clock - Return time of the system start. * @@ -1089,10 +1097,8 @@ void __init timekeeping_init(void) struct clocksource *clock; unsigned long flags; struct timespec64 now, boot, tmp; - struct timespec ts; - read_persistent_clock(&ts); - now = timespec_to_timespec64(ts); + read_persistent_clock64(&now); if (!timespec64_valid_strict(&now)) { pr_warn("WARNING: Persistent clock returned invalid value!\n" " Check your CMOS/BIOS settings.\n"); @@ -1163,7 +1169,7 @@ static void __timekeeping_inject_sleeptime(struct timekeeper *tk, * timekeeping_inject_sleeptime64 - Adds suspend interval to timeekeeping values * @delta: pointer to a timespec64 delta value * - * This hook is for architectures that cannot support read_persistent_clock + * This hook is for architectures that cannot support read_persistent_clock64 * because their RTC/persistent clock is only accessible when irqs are enabled. * * This function should only be called by rtc_resume(), and allows @@ -1210,12 +1216,10 @@ void timekeeping_resume(void) struct clocksource *clock = tk->tkr.clock; unsigned long flags; struct timespec64 ts_new, ts_delta; - struct timespec tmp; cycle_t cycle_now, cycle_delta; bool suspendtime_found = false; - read_persistent_clock(&tmp); - ts_new = timespec_to_timespec64(tmp); + read_persistent_clock64(&ts_new); clockevents_resume(); clocksource_resume(); @@ -1291,10 +1295,8 @@ int timekeeping_suspend(void) unsigned long flags; struct timespec64 delta, delta_delta; static struct timespec64 old_delta; - struct timespec tmp; - read_persistent_clock(&tmp); - timekeeping_suspend_time = timespec_to_timespec64(tmp); + read_persistent_clock64(&timekeeping_suspend_time); /* * On some systems the persistent_clock can not be detected at -- 1.9.1 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 3/8] time: Add y2038 safe update_persistent_clock64() 2015-03-11 3:15 [PATCH 0/8] Add y2038 safe replacements for read_boot_clock(), read_persistent_clock() and update_persistent_clock() Xunlei Pang [not found] ` <1426043715-22043-1-git-send-email-xlpang-KN7UnAbNpbg@public.gmane.org> @ 2015-03-11 3:15 ` Xunlei Pang 2015-03-11 3:15 ` [PATCH 4/8] ARM: OMAP: 32k counter: Provide y2038-safe omap_read_persistent_clock() replacement Xunlei Pang 2 siblings, 0 replies; 7+ messages in thread From: Xunlei Pang @ 2015-03-11 3:15 UTC (permalink / raw) To: linux-kernel Cc: rtc-linux, Thomas Gleixner, Alessandro Zummo, John Stultz, Arnd Bergmann, linux-omap, Tony Lindgren, linux-tegra, Stephen Warren, linux390, Martin Schwidefsky, Ralf Baechle, Arnd Bergmann, Xunlei Pang From: Xunlei Pang <pang.xunlei@linaro.org> As part of addressing in-kernel y2038 issues, this patch adds update_persistent_clock64() and replaces all the call sites of update_persistent_clock() with this function. This is a __weak implementation, which simply calls the existing y2038 unsafe update_persistent_clock(). This allows architecture specific implementations to be converted independently, and eventually y2038-unsafe update_persistent_clock() can be removed after all its architecture specific implementations have been converted to update_persistent_clock64(). Suggested-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Xunlei Pang <pang.xunlei@linaro.org> --- drivers/rtc/systohc.c | 2 +- include/linux/timekeeping.h | 1 + kernel/time/ntp.c | 13 ++++++++++++- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/drivers/rtc/systohc.c b/drivers/rtc/systohc.c index eb71872..ef3c07a 100644 --- a/drivers/rtc/systohc.c +++ b/drivers/rtc/systohc.c @@ -11,7 +11,7 @@ * rtc_set_ntp_time - Save NTP synchronized time to the RTC * @now: Current time of day * - * Replacement for the NTP platform function update_persistent_clock + * Replacement for the NTP platform function update_persistent_clock64 * that stores time for later retrieval by rtc_hctosys. * * Returns 0 on successful RTC update, -ENODEV if a RTC update is not diff --git a/include/linux/timekeeping.h b/include/linux/timekeeping.h index ff56a0f..a7fa96b 100644 --- a/include/linux/timekeeping.h +++ b/include/linux/timekeeping.h @@ -266,6 +266,7 @@ extern void read_persistent_clock64(struct timespec64 *ts); extern void read_boot_clock(struct timespec *ts); extern void read_boot_clock64(struct timespec64 *ts); extern int update_persistent_clock(struct timespec now); +extern int update_persistent_clock64(struct timespec64 now); #endif diff --git a/kernel/time/ntp.c b/kernel/time/ntp.c index 0f60b08..42d1bc7 100644 --- a/kernel/time/ntp.c +++ b/kernel/time/ntp.c @@ -459,6 +459,16 @@ out: return leap; } +#ifdef CONFIG_GENERIC_CMOS_UPDATE +int __weak update_persistent_clock64(struct timespec64 now64) +{ + struct timespec now; + + now = timespec64_to_timespec(now64); + return update_persistent_clock(now); +} +#endif + #if defined(CONFIG_GENERIC_CMOS_UPDATE) || defined(CONFIG_RTC_SYSTOHC) static void sync_cmos_clock(struct work_struct *work); @@ -494,8 +504,9 @@ static void sync_cmos_clock(struct work_struct *work) if (persistent_clock_is_local) adjust.tv_sec -= (sys_tz.tz_minuteswest * 60); #ifdef CONFIG_GENERIC_CMOS_UPDATE - fail = update_persistent_clock(timespec64_to_timespec(adjust)); + fail = update_persistent_clock64(adjust); #endif + #ifdef CONFIG_RTC_SYSTOHC if (fail == -ENODEV) fail = rtc_set_ntp_time(adjust); -- 1.9.1 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 4/8] ARM: OMAP: 32k counter: Provide y2038-safe omap_read_persistent_clock() replacement 2015-03-11 3:15 [PATCH 0/8] Add y2038 safe replacements for read_boot_clock(), read_persistent_clock() and update_persistent_clock() Xunlei Pang [not found] ` <1426043715-22043-1-git-send-email-xlpang-KN7UnAbNpbg@public.gmane.org> 2015-03-11 3:15 ` [PATCH 3/8] time: Add y2038 safe update_persistent_clock64() Xunlei Pang @ 2015-03-11 3:15 ` Xunlei Pang 2015-03-11 15:28 ` Tony Lindgren 2 siblings, 1 reply; 7+ messages in thread From: Xunlei Pang @ 2015-03-11 3:15 UTC (permalink / raw) To: linux-kernel Cc: rtc-linux, Thomas Gleixner, Alessandro Zummo, John Stultz, Arnd Bergmann, linux-omap, Tony Lindgren, linux-tegra, Stephen Warren, linux390, Martin Schwidefsky, Ralf Baechle, Arnd Bergmann, Xunlei Pang From: Xunlei Pang <pang.xunlei@linaro.org> As part of addressing "y2038 problem" for in-kernel uses, this patch adds the y2038-safe omap_read_persistent_clock64() using timespec64. Because we rely on some subsequent changes to convert arm multiarch support, omap_read_persistent_clock() will be removed then. Also remove the needless spinlock, because read_persistent_clock() doesn't run simultaneously. Signed-off-by: Xunlei Pang <pang.xunlei@linaro.org> --- arch/arm/plat-omap/counter_32k.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/arch/arm/plat-omap/counter_32k.c b/arch/arm/plat-omap/counter_32k.c index 61b4d70..d422e36 100644 --- a/arch/arm/plat-omap/counter_32k.c +++ b/arch/arm/plat-omap/counter_32k.c @@ -44,24 +44,20 @@ static u64 notrace omap_32k_read_sched_clock(void) } /** - * omap_read_persistent_clock - Return time from a persistent clock. + * omap_read_persistent_clock64 - Return time from a persistent clock. * * Reads the time from a source which isn't disabled during PM, the * 32k sync timer. Convert the cycles elapsed since last read into - * nsecs and adds to a monotonically increasing timespec. + * nsecs and adds to a monotonically increasing timespec64. */ -static struct timespec persistent_ts; +static struct timespec64 persistent_ts; static cycles_t cycles; static unsigned int persistent_mult, persistent_shift; -static DEFINE_SPINLOCK(read_persistent_clock_lock); -static void omap_read_persistent_clock(struct timespec *ts) +static void omap_read_persistent_clock64(struct timespec64 *ts) { unsigned long long nsecs; cycles_t last_cycles; - unsigned long flags; - - spin_lock_irqsave(&read_persistent_clock_lock, flags); last_cycles = cycles; cycles = sync32k_cnt_reg ? readl_relaxed(sync32k_cnt_reg) : 0; @@ -69,11 +65,17 @@ static void omap_read_persistent_clock(struct timespec *ts) nsecs = clocksource_cyc2ns(cycles - last_cycles, persistent_mult, persistent_shift); - timespec_add_ns(&persistent_ts, nsecs); + timespec64_add_ns(&persistent_ts, nsecs); *ts = persistent_ts; +} + +static void omap_read_persistent_clock(struct timespec *ts) +{ + struct timespec64 ts64; - spin_unlock_irqrestore(&read_persistent_clock_lock, flags); + omap_read_persistent_clock64(&ts64); + *ts = timespec64_to_timespec(ts64); } /** -- 1.9.1 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH 4/8] ARM: OMAP: 32k counter: Provide y2038-safe omap_read_persistent_clock() replacement 2015-03-11 3:15 ` [PATCH 4/8] ARM: OMAP: 32k counter: Provide y2038-safe omap_read_persistent_clock() replacement Xunlei Pang @ 2015-03-11 15:28 ` Tony Lindgren 0 siblings, 0 replies; 7+ messages in thread From: Tony Lindgren @ 2015-03-11 15:28 UTC (permalink / raw) To: Xunlei Pang Cc: linux-kernel, rtc-linux, Thomas Gleixner, Alessandro Zummo, John Stultz, Arnd Bergmann, linux-omap, linux-tegra, Stephen Warren, linux390, Martin Schwidefsky, Ralf Baechle, Arnd Bergmann, Xunlei Pang * Xunlei Pang <xlpang@126.com> [150310 20:18]: > From: Xunlei Pang <pang.xunlei@linaro.org> > > As part of addressing "y2038 problem" for in-kernel uses, this > patch adds the y2038-safe omap_read_persistent_clock64() using > timespec64. > > Because we rely on some subsequent changes to convert arm multiarch > support, omap_read_persistent_clock() will be removed then. > > Also remove the needless spinlock, because read_persistent_clock() > doesn't run simultaneously. > > Signed-off-by: Xunlei Pang <pang.xunlei@linaro.org> Looks OK to me: Acked-by: Tony Lindgren <tony@atomide.com> > --- > arch/arm/plat-omap/counter_32k.c | 22 ++++++++++++---------- > 1 file changed, 12 insertions(+), 10 deletions(-) > > diff --git a/arch/arm/plat-omap/counter_32k.c b/arch/arm/plat-omap/counter_32k.c > index 61b4d70..d422e36 100644 > --- a/arch/arm/plat-omap/counter_32k.c > +++ b/arch/arm/plat-omap/counter_32k.c > @@ -44,24 +44,20 @@ static u64 notrace omap_32k_read_sched_clock(void) > } > > /** > - * omap_read_persistent_clock - Return time from a persistent clock. > + * omap_read_persistent_clock64 - Return time from a persistent clock. > * > * Reads the time from a source which isn't disabled during PM, the > * 32k sync timer. Convert the cycles elapsed since last read into > - * nsecs and adds to a monotonically increasing timespec. > + * nsecs and adds to a monotonically increasing timespec64. > */ > -static struct timespec persistent_ts; > +static struct timespec64 persistent_ts; > static cycles_t cycles; > static unsigned int persistent_mult, persistent_shift; > -static DEFINE_SPINLOCK(read_persistent_clock_lock); > > -static void omap_read_persistent_clock(struct timespec *ts) > +static void omap_read_persistent_clock64(struct timespec64 *ts) > { > unsigned long long nsecs; > cycles_t last_cycles; > - unsigned long flags; > - > - spin_lock_irqsave(&read_persistent_clock_lock, flags); > > last_cycles = cycles; > cycles = sync32k_cnt_reg ? readl_relaxed(sync32k_cnt_reg) : 0; > @@ -69,11 +65,17 @@ static void omap_read_persistent_clock(struct timespec *ts) > nsecs = clocksource_cyc2ns(cycles - last_cycles, > persistent_mult, persistent_shift); > > - timespec_add_ns(&persistent_ts, nsecs); > + timespec64_add_ns(&persistent_ts, nsecs); > > *ts = persistent_ts; > +} > + > +static void omap_read_persistent_clock(struct timespec *ts) > +{ > + struct timespec64 ts64; > > - spin_unlock_irqrestore(&read_persistent_clock_lock, flags); > + omap_read_persistent_clock64(&ts64); > + *ts = timespec64_to_timespec(ts64); > } > > /** > -- > 1.9.1 > > ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2015-03-18 16:30 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-03-11 3:15 [PATCH 0/8] Add y2038 safe replacements for read_boot_clock(), read_persistent_clock() and update_persistent_clock() Xunlei Pang
[not found] ` <1426043715-22043-1-git-send-email-xlpang-KN7UnAbNpbg@public.gmane.org>
2015-03-11 3:15 ` [PATCH 1/8] time: Add y2038 safe read_boot_clock64() Xunlei Pang
[not found] ` <OF2C7428FA.095162DD-ON48257E0C.004641E0-48257E0C.004652BC@zte.com.cn>
2015-03-18 16:30 ` John Stultz
2015-03-11 3:15 ` [PATCH 2/8] time: Add y2038 safe read_persistent_clock64() Xunlei Pang
2015-03-11 3:15 ` [PATCH 3/8] time: Add y2038 safe update_persistent_clock64() Xunlei Pang
2015-03-11 3:15 ` [PATCH 4/8] ARM: OMAP: 32k counter: Provide y2038-safe omap_read_persistent_clock() replacement Xunlei Pang
2015-03-11 15:28 ` Tony Lindgren
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).