linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] fbdev: pxa3xx: use ktime_get_ts64 for time stamps
@ 2017-11-07 14:13 Arnd Bergmann
  2017-11-07 14:13 ` [PATCH 2/2] fbdev: radeon: stop use ktime_get() for HZ calibration Arnd Bergmann
  2017-11-08 16:27 ` [PATCH 1/2] fbdev: pxa3xx: use ktime_get_ts64 for time stamps Arnd Bergmann
  0 siblings, 2 replies; 4+ messages in thread
From: Arnd Bergmann @ 2017-11-07 14:13 UTC (permalink / raw)
  To: Bartlomiej Zolnierkiewicz
  Cc: Arnd Bergmann, Himanshu Jha, Gustavo A. R. Silva, dri-devel,
	linux-fbdev, linux-kernel

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().

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 drivers/video/fbdev/pxa3xx-gcu.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/drivers/video/fbdev/pxa3xx-gcu.c b/drivers/video/fbdev/pxa3xx-gcu.c
index 3366076f9e0f..ddca4425adc8 100644
--- a/drivers/video/fbdev/pxa3xx-gcu.c
+++ b/drivers/video/fbdev/pxa3xx-gcu.c
@@ -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)(tv.tv_sec),				\
+			tv.tv_usec / NSEC_PER_MSEC,			\
+			(tv.tv_usec % 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);
-- 
2.9.0

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] fbdev: radeon: stop use ktime_get() for HZ calibration
  2017-11-07 14:13 [PATCH 1/2] fbdev: pxa3xx: use ktime_get_ts64 for time stamps Arnd Bergmann
@ 2017-11-07 14:13 ` Arnd Bergmann
  2018-01-04 12:45   ` Bartlomiej Zolnierkiewicz
  2017-11-08 16:27 ` [PATCH 1/2] fbdev: pxa3xx: use ktime_get_ts64 for time stamps Arnd Bergmann
  1 sibling, 1 reply; 4+ messages in thread
From: Arnd Bergmann @ 2017-11-07 14:13 UTC (permalink / raw)
  To: Benjamin Herrenschmidt, Bartlomiej Zolnierkiewicz
  Cc: Arnd Bergmann, Colin Ian King, linux-fbdev, dri-devel, linux-kernel

do_gettimeofday() is deprecated and a bit clumsy. This changes
radeon_probe_pll_params() over to using ktime_get() with monotonic
times. There is no need to check for negative values any more
since the monotonic clocksource cannot go backwards, but I'm
adding a check for zero-division in case of a bad clocksource.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 drivers/video/fbdev/aty/radeon_base.c | 18 +++++++-----------
 1 file changed, 7 insertions(+), 11 deletions(-)

diff --git a/drivers/video/fbdev/aty/radeon_base.c b/drivers/video/fbdev/aty/radeon_base.c
index 8ad1643e7d1c..8b7048fbf6dc 100644
--- a/drivers/video/fbdev/aty/radeon_base.c
+++ b/drivers/video/fbdev/aty/radeon_base.c
@@ -583,8 +583,8 @@ static int radeon_probe_pll_params(struct radeonfb_info *rinfo)
 	int hTotal, vTotal, num, denom, m, n;
 	unsigned long long hz, vclk;
 	long xtal;
-	struct timeval start_tv, stop_tv;
-	long total_secs, total_usecs;
+	ktime_t start_time, stop_time;
+	u64 total_usecs;
 	int i;
 
 	/* Ugh, we cut interrupts, bad bad bad, but we want some precision
@@ -600,7 +600,7 @@ static int radeon_probe_pll_params(struct radeonfb_info *rinfo)
 		if (((INREG(CRTC_VLINE_CRNT_VLINE) >> 16) & 0x3ff) == 0)
 			break;
 
-	do_gettimeofday(&start_tv);
+	start_time = ktime_get();
 
 	for(i=0; i<1000000; i++)
 		if (((INREG(CRTC_VLINE_CRNT_VLINE) >> 16) & 0x3ff) != 0)
@@ -610,18 +610,14 @@ static int radeon_probe_pll_params(struct radeonfb_info *rinfo)
 		if (((INREG(CRTC_VLINE_CRNT_VLINE) >> 16) & 0x3ff) == 0)
 			break;
 	
-	do_gettimeofday(&stop_tv);
+	stop_time = ktime_get();
 	
 	local_irq_enable();
 
-	total_secs = stop_tv.tv_sec - start_tv.tv_sec;
-	if (total_secs > 10)
+	total_usecs = ktime_us_delta(stop_time, start_time);
+	if (total_usecs >= 10 * USEC_PER_SEC || total_usecs == 0)
 		return -1;
-	total_usecs = stop_tv.tv_usec - start_tv.tv_usec;
-	total_usecs += total_secs * 1000000;
-	if (total_usecs < 0)
-		total_usecs = -total_usecs;
-	hz = 1000000/total_usecs;
+	hz = USEC_PER_SEC/(u32)total_usecs;
  
 	hTotal = ((INREG(CRTC_H_TOTAL_DISP) & 0x1ff) + 1) * 8;
 	vTotal = ((INREG(CRTC_V_TOTAL_DISP) & 0x3ff) + 1);
-- 
2.9.0

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] fbdev: pxa3xx: use ktime_get_ts64 for time stamps
  2017-11-07 14:13 [PATCH 1/2] fbdev: pxa3xx: use ktime_get_ts64 for time stamps Arnd Bergmann
  2017-11-07 14:13 ` [PATCH 2/2] fbdev: radeon: stop use ktime_get() for HZ calibration Arnd Bergmann
@ 2017-11-08 16:27 ` Arnd Bergmann
  1 sibling, 0 replies; 4+ messages in thread
From: Arnd Bergmann @ 2017-11-08 16:27 UTC (permalink / raw)
  To: Bartlomiej Zolnierkiewicz
  Cc: Arnd Bergmann, Himanshu Jha, Gustavo A. R. Silva, dri-devel,
	linux-fbdev, Linux Kernel Mailing List

On Tue, Nov 7, 2017 at 3:13 PM, Arnd Bergmann <arnd@arndb.de> wrote:
> 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().
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Please ignore this patch, my randconfig builder found a typo that
I had not noticed before.

         Arnd

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 2/2] fbdev: radeon: stop use ktime_get() for HZ calibration
  2017-11-07 14:13 ` [PATCH 2/2] fbdev: radeon: stop use ktime_get() for HZ calibration Arnd Bergmann
@ 2018-01-04 12:45   ` Bartlomiej Zolnierkiewicz
  0 siblings, 0 replies; 4+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2018-01-04 12:45 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Benjamin Herrenschmidt, Colin Ian King, linux-fbdev, dri-devel,
	linux-kernel

On Tuesday, November 07, 2017 03:13:06 PM Arnd Bergmann wrote:
> do_gettimeofday() is deprecated and a bit clumsy. This changes
> radeon_probe_pll_params() over to using ktime_get() with monotonic
> times. There is no need to check for negative values any more
> since the monotonic clocksource cannot go backwards, but I'm
> adding a check for zero-division in case of a bad clocksource.
> 
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Patch queued for 4.16, thanks.

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-01-04 12:45 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-07 14:13 [PATCH 1/2] fbdev: pxa3xx: use ktime_get_ts64 for time stamps Arnd Bergmann
2017-11-07 14:13 ` [PATCH 2/2] fbdev: radeon: stop use ktime_get() for HZ calibration Arnd Bergmann
2018-01-04 12:45   ` Bartlomiej Zolnierkiewicz
2017-11-08 16:27 ` [PATCH 1/2] fbdev: pxa3xx: use ktime_get_ts64 for time stamps Arnd Bergmann

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).