Skip to contentSkip to conversation

fbdev: pxa3xx: use ktime_get_ts64 for time stamps

PATCH In review Arnd Bergmann 2 participants 2 messages Nov 27, 2017 – Jan 4, 2018 Framebuffer layer

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 fbdev: pxa3xx: use ktime_get_ts64 for time stamps

do_gettimeofday() is deprecated because it is not y2038 safe, so I'm changing the calculation for the diagnostic output over to using 'timespec64'.

We really only print time deltas here, so changing it to monotonic time makes this more robust, the correct accessor for this is ktime_get_ts64().

---
v2: fix typo

---
 drivers/video/fbdev/pxa3xx-gcu.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)
drivers/video/fbdev/pxa3xx-gcu.c +9 -7
index 55fbb432c053..0955622a1227 100644
@@ -104,7 +104,7 @@ struct pxa3xx_gcu_priv {
 	wait_queue_head_t	  wait_idle;
 	wait_queue_head_t	  wait_free;
 	spinlock_t		  spinlock;
-	struct timeval 		  base_time;
+	struct timespec64	  base_time;
 
 	struct pxa3xx_gcu_batch *free;
 	struct pxa3xx_gcu_batch *ready;
@@ -126,18 +126,20 @@ gc_writel(struct pxa3xx_gcu_priv *priv, unsigned int off, unsigned long val)
 
 #define QPRINT(priv, level, msg)					\
 	do {								\
-		struct timeval tv;					\
+		struct timespec64 ts;					\
 		struct pxa3xx_gcu_shared *shared = priv->shared;	\
 		u32 base = gc_readl(priv, REG_GCRBBR);			\
 									\
-		do_gettimeofday(&tv);					\
+		ktime_get_ts64(&ts);					\
+		ts = timespec64_sub(ts, priv->base_time);		\
 									\
-		printk(level "%ld.%03ld.%03ld - %-17s: %-21s (%s, "	\
+		printk(level "%lld.%03ld.%03ld - %-17s: %-21s (%s, "	\
 			"STATUS "					\
 			"0x%02lx, B 0x%08lx [%ld], E %5ld, H %5ld, "	\
 			"T %5ld)\n",					\
-			tv.tv_sec - priv->base_time.tv_sec,		\
-			tv.tv_usec / 1000, tv.tv_usec % 1000,		\
+			(s64)(ts.tv_sec),				\
+			ts.tv_nsec / NSEC_PER_MSEC,			\
+			(ts.tv_nsec % NSEC_PER_MSEC) / USEC_PER_MSEC,	\
 			__func__, msg,					\
 			shared->hw_running ? "running" : "   idle",	\
 			gc_readl(priv, REG_GCISCR),			\
@@ -164,7 +166,7 @@ pxa3xx_gcu_reset(struct pxa3xx_gcu_priv *priv)
 	priv->shared->buffer_phys = priv->shared_phys;
 	priv->shared->magic = PXA3XX_GCU_SHARED_MAGIC;
 
-	do_gettimeofday(&priv->base_time);
+	ktime_get_ts64(&priv->base_time);
 
 	/* set up the ring buffer pointers */
 	gc_writel(priv, REG_GCRBLR, 0);
Signature · 1 line
2.9.0
#1 lore raw
Quoted 9 lines · Arnd Bergmann

do_gettimeofday() is deprecated because it is not y2038 safe, so I'm changing the calculation for the diagnostic output over to using 'timespec64'.

We really only print time deltas here, so changing it to monotonic time makes this more robust, the correct accessor for this is ktime_get_ts64().

Patch queued for 4.16, thanks.

Best regards,
--
Bartlomiej Zolnierkiewicz
Samsung R&D Institute Poland
Samsung Electronics