spufs: use timespec64 for timestamps
Subsystems (3)
PATCH 1/2 spufs: use timespec64 for timestamps
The switch log prints the tv_sec portion of timespec as a 32-bit number, while overflows in 2106. It also uses the timespec type, which is safe on 64-bit architectures, but deprecated because it causes overflows in 2038 elsewhere.
This changes it to timespec64 and printing a 64-bit number for consistency.
Signed-off-by Arnd Bergmann <[email protected]>
--- arch/powerpc/platforms/cell/spufs/file.c | 6 +++--- arch/powerpc/platforms/cell/spufs/spufs.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-)
arch/powerpc/platforms/cell/spufs/file.c +3 -3
@@ -2375,8 +2375,8 @@ static int switch_log_sprint(struct spu_context *ctx, char *tbuf, int n) p = ctx->switch_log->log + ctx->switch_log->tail %SWITCH_LOG_BUFSIZE ; - return snprintf(tbuf, n, "%u.%09u %d %u %u %llu\n", - (unsigned int) p->tstamp.tv_sec, + return snprintf(tbuf, n, "%llu.%09u %d %u %u %llu\n", + (unsigned long long) p->tstamp.tv_sec, (unsigned int) p->tstamp.tv_nsec, p->spu_id, (unsigned int) p->type,
@@ -2499,7 +2499,7 @@ void spu_switch_log_notify(struct spu *spu, struct spu_context *ctx,struct switch_log_entry *p; p = ctx->switch_log->log + ctx->switch_log->head; -ktime_get_ts (&p->tstamp); +ktime_get_ts64 (&p->tstamp); p->timebase =get_tb (); p->spu_id = spu ? spu->number :-1 ; p->type = type;
arch/powerpc/platforms/cell/spufs/spufs.h +1 -1
@@ -69,7 +69,7 @@ struct switch_log {unsigned long head;unsigned long tail;struct switch_log_entry { -struct timespec tstamp; +struct timespec64 tstamp;s32 spu_id;u32 type;u32 val;
Signature · 1 line
2.9.0
PATCH 2/2 powerpc: mpic_timer: avoid struct timeval
In an effort to remove all instances of 'struct timeval' from the kernel, I'm changing the powerpc mpic_timer interface to use plain seconds instead. There is only one user of this interface, and that doesn't use the microseconds portion, so the code gets noticeably simpler in the process.
Signed-off-by Arnd Bergmann <[email protected]>
--- arch/powerpc/include/asm/mpic_timer.h | 8 ++--- arch/powerpc/sysdev/fsl_mpic_timer_wakeup.c | 16 ++++----- arch/powerpc/sysdev/mpic_timer.c | 55 ++++++----------------------- 3 files changed, 21 insertions(+), 58 deletions(-)
arch/powerpc/include/asm/mpic_timer.h +4 -4
@@ -29,17 +29,17 @@ struct mpic_timer {#ifdef CONFIG_MPIC_TIMER struct mpic_timer *mpic_request_timer (irq_handler_t fn,void *dev, -const struct timeval *time); +time64_t time);void mpic_start_timer (struct mpic_timer *handle);void mpic_stop_timer (struct mpic_timer *handle); -void mpic_get_remain_time (struct mpic_timer *handle,struct timeval *time); +void mpic_get_remain_time (struct mpic_timer *handle,time64_t *time);void mpic_free_timer (struct mpic_timer *handle);#else struct mpic_timer *mpic_request_timer (irq_handler_t fn,void *dev, -const struct timeval *time) {return NULL ; } +time64_t time) {return NULL ; }void mpic_start_timer (struct mpic_timer *handle) { }void mpic_stop_timer (struct mpic_timer *handle) { } -void mpic_get_remain_time (struct mpic_timer *handle,struct timeval *time) { } +void mpic_get_remain_time (struct mpic_timer *handle,time64_t *time) { }void mpic_free_timer (struct mpic_timer *handle) { }#endif
arch/powerpc/sysdev/fsl_mpic_timer_wakeup.c +7 -9
@@ -56,17 +56,16 @@ static ssize_t fsl_timer_wakeup_show(struct device *dev,struct device_attribute *attr, char *buf) { - struct timeval interval; -int val =0 ; + time64_t interval = 0;mutex_lock (&sysfs_lock);if (fsl_wakeup->timer) {mpic_get_remain_time (fsl_wakeup->timer, &interval); - val = interval.tv_sec +1 ; + interval++; }mutex_unlock (&sysfs_lock); -return sprintf (buf,"%d\n" , val); +return sprintf (buf,"%lld\n" , interval); } static ssize_t fsl_timer_wakeup_store(struct device *dev,
@@ -74,11 +73,10 @@ static ssize_t fsl_timer_wakeup_store(struct device *dev,const char *buf, size_t count) { -struct timeval interval; + time64_t interval;int ret; - interval.tv_usec =0 ; -if (kstrtol (buf,0 , &interval.tv_sec)) +if (kstrtoll (buf,0 , &interval))return -EINVAL ;mutex_lock (&sysfs_lock);
@@ -89,13 +87,13 @@ static ssize_t fsl_timer_wakeup_store(struct device *dev, fsl_wakeup->timer =NULL ; } -if (!interval.tv_sec) { +if (!interval) {mutex_unlock (&sysfs_lock);return count; } fsl_wakeup->timer =mpic_request_timer (fsl_mpic_timer_irq, - fsl_wakeup, &interval); + fsl_wakeup, interval);if (!fsl_wakeup->timer) {mutex_unlock (&sysfs_lock);return -EINVAL ;
arch/powerpc/sysdev/mpic_timer.c +10 -45
109 lines not on this page · raw message
Signature · 1 line
2.9.0