All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] fbdev: radeon: Remove 'struct timeval' usage
@ 2015-05-25  4:19 ` Tina Ruchandani
  0 siblings, 0 replies; 12+ messages in thread
From: Tina Ruchandani @ 2015-05-25  4:07 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: y2038, Benjamin Herrenschmidt, Jean-Christophe Plagniol-Villard,
	Tomi Valkeinen, linux-fbdev, linux-kernel

'struct timeval' uses a 32-bit representation for the
seconds field which will overflow in the year 2038 and beyond.
This patch replaces the usage of 'struct timeval' with
ktime_t which uses a 64-bit time representation and does not
suffer from the y2038 problem. This patch is part of a larger
effort to remove all instances of 'struct timeval', 'struct
timespec', time_t and other 32-bit timekeeping variables
from the kernel.
The patch also replaces the use of real time (do_gettimeofday)
with monotonic time (ktime_get).

Signed-off-by: Tina Ruchandani <ruchandani.tina@gmail.com>
---
 drivers/video/fbdev/aty/radeon_base.c | 29 ++++++++++++++---------------
 1 file changed, 14 insertions(+), 15 deletions(-)

diff --git a/drivers/video/fbdev/aty/radeon_base.c b/drivers/video/fbdev/aty/radeon_base.c
index 01237c8..9747e9e 100644
--- a/drivers/video/fbdev/aty/radeon_base.c
+++ b/drivers/video/fbdev/aty/radeon_base.c
@@ -64,6 +64,7 @@
 #include <linux/slab.h>
 #include <linux/delay.h>
 #include <linux/time.h>
+#include <linux/ktime.h>
 #include <linux/fb.h>
 #include <linux/ioport.h>
 #include <linux/init.h>
@@ -461,8 +462,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, stop;
+	s64 delta;
 	int i;
 
 	/* Ugh, we cut interrupts, bad bad bad, but we want some precision
@@ -478,7 +479,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 = ktime_get();
 
 	for(i=0; i<1000000; i++)
 		if (((INREG(CRTC_VLINE_CRNT_VLINE) >> 16) & 0x3ff) != 0)
@@ -487,20 +488,18 @@ static int radeon_probe_pll_params(struct radeonfb_info *rinfo)
 	for(i=0; i<1000000; i++)
 		if (((INREG(CRTC_VLINE_CRNT_VLINE) >> 16) & 0x3ff) == 0)
 			break;
-	
-	do_gettimeofday(&stop_tv);
-	
+
+	stop = ktime_get();
+
 	local_irq_enable();
 
-	total_secs = stop_tv.tv_sec - start_tv.tv_sec;
-	if (total_secs > 10)
+	delta = ktime_us_delta(stop, start);
+
+	/* Return -1 if more than 10 seconds have elapsed */
+	if (delta > (10*1000000))
 		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 = 1000000/delta;
+
 	hTotal = ((INREG(CRTC_H_TOTAL_DISP) & 0x1ff) + 1) * 8;
 	vTotal = ((INREG(CRTC_V_TOTAL_DISP) & 0x3ff) + 1);
 	vclk = (long long)hTotal * (long long)vTotal * hz;
@@ -548,7 +547,7 @@ static int radeon_probe_pll_params(struct radeonfb_info *rinfo)
 		denom *= 3;
 		break;
 	case 6:
-		denom *= 6;   
+		denom *= 6;
 		break;
 	case 7:
 		denom *= 12;
-- 
2.2.0.rc0.207.ga3a616c


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

* [PATCH] fbdev: radeon: Remove 'struct timeval' usage
@ 2015-05-25  4:19 ` Tina Ruchandani
  0 siblings, 0 replies; 12+ messages in thread
From: Tina Ruchandani @ 2015-05-25  4:19 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: y2038, Benjamin Herrenschmidt, Jean-Christophe Plagniol-Villard,
	Tomi Valkeinen, linux-fbdev, linux-kernel

'struct timeval' uses a 32-bit representation for the
seconds field which will overflow in the year 2038 and beyond.
This patch replaces the usage of 'struct timeval' with
ktime_t which uses a 64-bit time representation and does not
suffer from the y2038 problem. This patch is part of a larger
effort to remove all instances of 'struct timeval', 'struct
timespec', time_t and other 32-bit timekeeping variables
from the kernel.
The patch also replaces the use of real time (do_gettimeofday)
with monotonic time (ktime_get).

Signed-off-by: Tina Ruchandani <ruchandani.tina@gmail.com>
---
 drivers/video/fbdev/aty/radeon_base.c | 29 ++++++++++++++---------------
 1 file changed, 14 insertions(+), 15 deletions(-)

diff --git a/drivers/video/fbdev/aty/radeon_base.c b/drivers/video/fbdev/aty/radeon_base.c
index 01237c8..9747e9e 100644
--- a/drivers/video/fbdev/aty/radeon_base.c
+++ b/drivers/video/fbdev/aty/radeon_base.c
@@ -64,6 +64,7 @@
 #include <linux/slab.h>
 #include <linux/delay.h>
 #include <linux/time.h>
+#include <linux/ktime.h>
 #include <linux/fb.h>
 #include <linux/ioport.h>
 #include <linux/init.h>
@@ -461,8 +462,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, stop;
+	s64 delta;
 	int i;
 
 	/* Ugh, we cut interrupts, bad bad bad, but we want some precision
@@ -478,7 +479,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 = ktime_get();
 
 	for(i=0; i<1000000; i++)
 		if (((INREG(CRTC_VLINE_CRNT_VLINE) >> 16) & 0x3ff) != 0)
@@ -487,20 +488,18 @@ static int radeon_probe_pll_params(struct radeonfb_info *rinfo)
 	for(i=0; i<1000000; i++)
 		if (((INREG(CRTC_VLINE_CRNT_VLINE) >> 16) & 0x3ff) = 0)
 			break;
-	
-	do_gettimeofday(&stop_tv);
-	
+
+	stop = ktime_get();
+
 	local_irq_enable();
 
-	total_secs = stop_tv.tv_sec - start_tv.tv_sec;
-	if (total_secs > 10)
+	delta = ktime_us_delta(stop, start);
+
+	/* Return -1 if more than 10 seconds have elapsed */
+	if (delta > (10*1000000))
 		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 = 1000000/delta;
+
 	hTotal = ((INREG(CRTC_H_TOTAL_DISP) & 0x1ff) + 1) * 8;
 	vTotal = ((INREG(CRTC_V_TOTAL_DISP) & 0x3ff) + 1);
 	vclk = (long long)hTotal * (long long)vTotal * hz;
@@ -548,7 +547,7 @@ static int radeon_probe_pll_params(struct radeonfb_info *rinfo)
 		denom *= 3;
 		break;
 	case 6:
-		denom *= 6;   
+		denom *= 6;
 		break;
 	case 7:
 		denom *= 12;
-- 
2.2.0.rc0.207.ga3a616c


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

* Re: [PATCH] fbdev: radeon: Remove 'struct timeval' usage
  2015-05-25  4:19 ` Tina Ruchandani
@ 2015-06-03 11:59   ` Tomi Valkeinen
  -1 siblings, 0 replies; 12+ messages in thread
From: Tomi Valkeinen @ 2015-06-03 11:59 UTC (permalink / raw)
  To: Tina Ruchandani, Arnd Bergmann
  Cc: y2038, Benjamin Herrenschmidt, Jean-Christophe Plagniol-Villard,
	linux-fbdev, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 3189 bytes --]



On 25/05/15 07:07, Tina Ruchandani wrote:
> 'struct timeval' uses a 32-bit representation for the
> seconds field which will overflow in the year 2038 and beyond.
> This patch replaces the usage of 'struct timeval' with
> ktime_t which uses a 64-bit time representation and does not
> suffer from the y2038 problem. This patch is part of a larger
> effort to remove all instances of 'struct timeval', 'struct
> timespec', time_t and other 32-bit timekeeping variables
> from the kernel.
> The patch also replaces the use of real time (do_gettimeofday)
> with monotonic time (ktime_get).
> 
> Signed-off-by: Tina Ruchandani <ruchandani.tina@gmail.com>
> ---
>  drivers/video/fbdev/aty/radeon_base.c | 29 ++++++++++++++---------------
>  1 file changed, 14 insertions(+), 15 deletions(-)
> 
> diff --git a/drivers/video/fbdev/aty/radeon_base.c b/drivers/video/fbdev/aty/radeon_base.c
> index 01237c8..9747e9e 100644
> --- a/drivers/video/fbdev/aty/radeon_base.c
> +++ b/drivers/video/fbdev/aty/radeon_base.c
> @@ -64,6 +64,7 @@
>  #include <linux/slab.h>
>  #include <linux/delay.h>
>  #include <linux/time.h>
> +#include <linux/ktime.h>
>  #include <linux/fb.h>
>  #include <linux/ioport.h>
>  #include <linux/init.h>
> @@ -461,8 +462,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, stop;
> +	s64 delta;
>  	int i;
>  
>  	/* Ugh, we cut interrupts, bad bad bad, but we want some precision
> @@ -478,7 +479,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 = ktime_get();
>  
>  	for(i=0; i<1000000; i++)
>  		if (((INREG(CRTC_VLINE_CRNT_VLINE) >> 16) & 0x3ff) != 0)
> @@ -487,20 +488,18 @@ static int radeon_probe_pll_params(struct radeonfb_info *rinfo)
>  	for(i=0; i<1000000; i++)
>  		if (((INREG(CRTC_VLINE_CRNT_VLINE) >> 16) & 0x3ff) == 0)
>  			break;
> -	
> -	do_gettimeofday(&stop_tv);
> -	
> +
> +	stop = ktime_get();
> +
>  	local_irq_enable();
>  
> -	total_secs = stop_tv.tv_sec - start_tv.tv_sec;
> -	if (total_secs > 10)
> +	delta = ktime_us_delta(stop, start);
> +
> +	/* Return -1 if more than 10 seconds have elapsed */
> +	if (delta > (10*1000000))
>  		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 = 1000000/delta;
> +
>  	hTotal = ((INREG(CRTC_H_TOTAL_DISP) & 0x1ff) + 1) * 8;
>  	vTotal = ((INREG(CRTC_V_TOTAL_DISP) & 0x3ff) + 1);
>  	vclk = (long long)hTotal * (long long)vTotal * hz;
> @@ -548,7 +547,7 @@ static int radeon_probe_pll_params(struct radeonfb_info *rinfo)
>  		denom *= 3;
>  		break;
>  	case 6:
> -		denom *= 6;   
> +		denom *= 6;
>  		break;
>  	case 7:
>  		denom *= 12;

The above change was extra. I removed it, and queued this for 4.2.

 Tomi


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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

* Re: [PATCH] fbdev: radeon: Remove 'struct timeval' usage
@ 2015-06-03 11:59   ` Tomi Valkeinen
  0 siblings, 0 replies; 12+ messages in thread
From: Tomi Valkeinen @ 2015-06-03 11:59 UTC (permalink / raw)
  To: Tina Ruchandani, Arnd Bergmann
  Cc: y2038, Benjamin Herrenschmidt, Jean-Christophe Plagniol-Villard,
	linux-fbdev, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 3189 bytes --]



On 25/05/15 07:07, Tina Ruchandani wrote:
> 'struct timeval' uses a 32-bit representation for the
> seconds field which will overflow in the year 2038 and beyond.
> This patch replaces the usage of 'struct timeval' with
> ktime_t which uses a 64-bit time representation and does not
> suffer from the y2038 problem. This patch is part of a larger
> effort to remove all instances of 'struct timeval', 'struct
> timespec', time_t and other 32-bit timekeeping variables
> from the kernel.
> The patch also replaces the use of real time (do_gettimeofday)
> with monotonic time (ktime_get).
> 
> Signed-off-by: Tina Ruchandani <ruchandani.tina@gmail.com>
> ---
>  drivers/video/fbdev/aty/radeon_base.c | 29 ++++++++++++++---------------
>  1 file changed, 14 insertions(+), 15 deletions(-)
> 
> diff --git a/drivers/video/fbdev/aty/radeon_base.c b/drivers/video/fbdev/aty/radeon_base.c
> index 01237c8..9747e9e 100644
> --- a/drivers/video/fbdev/aty/radeon_base.c
> +++ b/drivers/video/fbdev/aty/radeon_base.c
> @@ -64,6 +64,7 @@
>  #include <linux/slab.h>
>  #include <linux/delay.h>
>  #include <linux/time.h>
> +#include <linux/ktime.h>
>  #include <linux/fb.h>
>  #include <linux/ioport.h>
>  #include <linux/init.h>
> @@ -461,8 +462,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, stop;
> +	s64 delta;
>  	int i;
>  
>  	/* Ugh, we cut interrupts, bad bad bad, but we want some precision
> @@ -478,7 +479,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 = ktime_get();
>  
>  	for(i=0; i<1000000; i++)
>  		if (((INREG(CRTC_VLINE_CRNT_VLINE) >> 16) & 0x3ff) != 0)
> @@ -487,20 +488,18 @@ static int radeon_probe_pll_params(struct radeonfb_info *rinfo)
>  	for(i=0; i<1000000; i++)
>  		if (((INREG(CRTC_VLINE_CRNT_VLINE) >> 16) & 0x3ff) == 0)
>  			break;
> -	
> -	do_gettimeofday(&stop_tv);
> -	
> +
> +	stop = ktime_get();
> +
>  	local_irq_enable();
>  
> -	total_secs = stop_tv.tv_sec - start_tv.tv_sec;
> -	if (total_secs > 10)
> +	delta = ktime_us_delta(stop, start);
> +
> +	/* Return -1 if more than 10 seconds have elapsed */
> +	if (delta > (10*1000000))
>  		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 = 1000000/delta;
> +
>  	hTotal = ((INREG(CRTC_H_TOTAL_DISP) & 0x1ff) + 1) * 8;
>  	vTotal = ((INREG(CRTC_V_TOTAL_DISP) & 0x3ff) + 1);
>  	vclk = (long long)hTotal * (long long)vTotal * hz;
> @@ -548,7 +547,7 @@ static int radeon_probe_pll_params(struct radeonfb_info *rinfo)
>  		denom *= 3;
>  		break;
>  	case 6:
> -		denom *= 6;   
> +		denom *= 6;
>  		break;
>  	case 7:
>  		denom *= 12;

The above change was extra. I removed it, and queued this for 4.2.

 Tomi


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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

* Re: [PATCH] fbdev: radeon: Remove 'struct timeval' usage
  2015-06-03 11:59   ` Tomi Valkeinen
@ 2015-06-05  4:40     ` Dave Airlie
  -1 siblings, 0 replies; 12+ messages in thread
From: Dave Airlie @ 2015-06-05  4:40 UTC (permalink / raw)
  To: Tomi Valkeinen
  Cc: Tina Ruchandani, Arnd Bergmann, y2038, Benjamin Herrenschmidt,
	Jean-Christophe Plagniol-Villard, Linux Fbdev development list,
	LKML

On 3 June 2015 at 21:59, Tomi Valkeinen <tomi.valkeinen@ti.com> wrote:
>
>
> On 25/05/15 07:07, Tina Ruchandani wrote:
>> 'struct timeval' uses a 32-bit representation for the
>> seconds field which will overflow in the year 2038 and beyond.
>> This patch replaces the usage of 'struct timeval' with
>> ktime_t which uses a 64-bit time representation and does not
>> suffer from the y2038 problem. This patch is part of a larger
>> effort to remove all instances of 'struct timeval', 'struct
>> timespec', time_t and other 32-bit timekeeping variables
>> from the kernel.
>> The patch also replaces the use of real time (do_gettimeofday)
>> with monotonic time (ktime_get).
>>
>> Signed-off-by: Tina Ruchandani <ruchandani.tina@gmail.com>
>> ---
>>  drivers/video/fbdev/aty/radeon_base.c | 29 ++++++++++++++---------------
>>  1 file changed, 14 insertions(+), 15 deletions(-)
>>
>> diff --git a/drivers/video/fbdev/aty/radeon_base.c b/drivers/video/fbdev/aty/radeon_base.c
>> index 01237c8..9747e9e 100644
>> --- a/drivers/video/fbdev/aty/radeon_base.c
>> +++ b/drivers/video/fbdev/aty/radeon_base.c
>> @@ -64,6 +64,7 @@
>>  #include <linux/slab.h>
>>  #include <linux/delay.h>
>>  #include <linux/time.h>
>> +#include <linux/ktime.h>
>>  #include <linux/fb.h>
>>  #include <linux/ioport.h>
>>  #include <linux/init.h>
>> @@ -461,8 +462,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, stop;
>> +     s64 delta;
>>       int i;
>>
>>       /* Ugh, we cut interrupts, bad bad bad, but we want some precision
>> @@ -478,7 +479,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 = ktime_get();
>>
>>       for(i=0; i<1000000; i++)
>>               if (((INREG(CRTC_VLINE_CRNT_VLINE) >> 16) & 0x3ff) != 0)
>> @@ -487,20 +488,18 @@ static int radeon_probe_pll_params(struct radeonfb_info *rinfo)
>>       for(i=0; i<1000000; i++)
>>               if (((INREG(CRTC_VLINE_CRNT_VLINE) >> 16) & 0x3ff) == 0)
>>                       break;
>> -
>> -     do_gettimeofday(&stop_tv);
>> -
>> +
>> +     stop = ktime_get();
>> +
>>       local_irq_enable();
>>
>> -     total_secs = stop_tv.tv_sec - start_tv.tv_sec;
>> -     if (total_secs > 10)
>> +     delta = ktime_us_delta(stop, start);
>> +
>> +     /* Return -1 if more than 10 seconds have elapsed */
>> +     if (delta > (10*1000000))
>>               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 = 1000000/delta;

This needs to be on of the do_div family.

Dave.

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

* Re: [PATCH] fbdev: radeon: Remove 'struct timeval' usage
@ 2015-06-05  4:40     ` Dave Airlie
  0 siblings, 0 replies; 12+ messages in thread
From: Dave Airlie @ 2015-06-05  4:40 UTC (permalink / raw)
  To: Tomi Valkeinen
  Cc: Tina Ruchandani, Arnd Bergmann, y2038, Benjamin Herrenschmidt,
	Jean-Christophe Plagniol-Villard, Linux Fbdev development list,
	LKML

On 3 June 2015 at 21:59, Tomi Valkeinen <tomi.valkeinen@ti.com> wrote:
>
>
> On 25/05/15 07:07, Tina Ruchandani wrote:
>> 'struct timeval' uses a 32-bit representation for the
>> seconds field which will overflow in the year 2038 and beyond.
>> This patch replaces the usage of 'struct timeval' with
>> ktime_t which uses a 64-bit time representation and does not
>> suffer from the y2038 problem. This patch is part of a larger
>> effort to remove all instances of 'struct timeval', 'struct
>> timespec', time_t and other 32-bit timekeeping variables
>> from the kernel.
>> The patch also replaces the use of real time (do_gettimeofday)
>> with monotonic time (ktime_get).
>>
>> Signed-off-by: Tina Ruchandani <ruchandani.tina@gmail.com>
>> ---
>>  drivers/video/fbdev/aty/radeon_base.c | 29 ++++++++++++++---------------
>>  1 file changed, 14 insertions(+), 15 deletions(-)
>>
>> diff --git a/drivers/video/fbdev/aty/radeon_base.c b/drivers/video/fbdev/aty/radeon_base.c
>> index 01237c8..9747e9e 100644
>> --- a/drivers/video/fbdev/aty/radeon_base.c
>> +++ b/drivers/video/fbdev/aty/radeon_base.c
>> @@ -64,6 +64,7 @@
>>  #include <linux/slab.h>
>>  #include <linux/delay.h>
>>  #include <linux/time.h>
>> +#include <linux/ktime.h>
>>  #include <linux/fb.h>
>>  #include <linux/ioport.h>
>>  #include <linux/init.h>
>> @@ -461,8 +462,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, stop;
>> +     s64 delta;
>>       int i;
>>
>>       /* Ugh, we cut interrupts, bad bad bad, but we want some precision
>> @@ -478,7 +479,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 = ktime_get();
>>
>>       for(i=0; i<1000000; i++)
>>               if (((INREG(CRTC_VLINE_CRNT_VLINE) >> 16) & 0x3ff) != 0)
>> @@ -487,20 +488,18 @@ static int radeon_probe_pll_params(struct radeonfb_info *rinfo)
>>       for(i=0; i<1000000; i++)
>>               if (((INREG(CRTC_VLINE_CRNT_VLINE) >> 16) & 0x3ff) = 0)
>>                       break;
>> -
>> -     do_gettimeofday(&stop_tv);
>> -
>> +
>> +     stop = ktime_get();
>> +
>>       local_irq_enable();
>>
>> -     total_secs = stop_tv.tv_sec - start_tv.tv_sec;
>> -     if (total_secs > 10)
>> +     delta = ktime_us_delta(stop, start);
>> +
>> +     /* Return -1 if more than 10 seconds have elapsed */
>> +     if (delta > (10*1000000))
>>               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 = 1000000/delta;

This needs to be on of the do_div family.

Dave.

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

* Re: [PATCH] fbdev: radeon: Remove 'struct timeval' usage
  2015-05-25  4:19 ` Tina Ruchandani
@ 2015-06-05  7:55 ` Tina Ruchandani
  -1 siblings, 0 replies; 12+ messages in thread
From: Tina Ruchandani @ 2015-06-05  7:55 UTC (permalink / raw)
  To: Dave Airlie
  Cc: Tomi Valkeinen, Arnd Bergmann, y2038, Benjamin Herrenschmidt,
	Jean-Christophe Plagniol-Villard, Linux Fbdev development list,
	LKML

>>> +     hz = 1000000/delta;
>
> This needs to be on of the do_div family.
>
> Dave.

Hi Dave,
I build-tested the patch for both 32-bit and 64-bit x86. If my
understanding is correct, since the divisor is 64-bit here, the
compiler will do "if (delta > 1000000) hz = 0; else hz =
1000000/(s32)delta" automatically?
In general, is this a good thumb-rule to follow - use do_div if the
dividend is 64-bit, and normal divide operator if only the divisor is
64-bit?

Tina

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

* Re: [PATCH] fbdev: radeon: Remove 'struct timeval' usage
@ 2015-06-05  7:55 ` Tina Ruchandani
  0 siblings, 0 replies; 12+ messages in thread
From: Tina Ruchandani @ 2015-06-05  7:55 UTC (permalink / raw)
  To: Dave Airlie
  Cc: Tomi Valkeinen, Arnd Bergmann, y2038, Benjamin Herrenschmidt,
	Jean-Christophe Plagniol-Villard, Linux Fbdev development list,
	LKML

>>> +     hz = 1000000/delta;
>
> This needs to be on of the do_div family.
>
> Dave.

Hi Dave,
I build-tested the patch for both 32-bit and 64-bit x86. If my
understanding is correct, since the divisor is 64-bit here, the
compiler will do "if (delta > 1000000) hz = 0; else hz 1000000/(s32)delta" automatically?
In general, is this a good thumb-rule to follow - use do_div if the
dividend is 64-bit, and normal divide operator if only the divisor is
64-bit?

Tina

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

* Re: [Y2038] [PATCH] fbdev: radeon: Remove 'struct timeval' usage
  2015-06-05  7:55 ` Tina Ruchandani
@ 2015-06-05 21:12   ` Arnd Bergmann
  -1 siblings, 0 replies; 12+ messages in thread
From: Arnd Bergmann @ 2015-06-05 21:12 UTC (permalink / raw)
  To: y2038
  Cc: Tina Ruchandani, Dave Airlie, Linux Fbdev development list,
	Benjamin Herrenschmidt, LKML, Tomi Valkeinen,
	Jean-Christophe Plagniol-Villard

On Friday 05 June 2015 00:55:05 Tina Ruchandani wrote:
> >>> +     hz = 1000000/delta;
> >
> > This needs to be on of the do_div family.
> >
> > Dave.
> 
> Hi Dave,
> I build-tested the patch for both 32-bit and 64-bit x86. If my
> understanding is correct, since the divisor is 64-bit here, the
> compiler will do "if (delta > 1000000) hz = 0; else hz =
> 1000000/(s32)delta" automatically?
> In general, is this a good thumb-rule to follow - use do_div if the
> dividend is 64-bit, and normal divide operator if only the divisor is
> 64-bit?
> 

I got a build error on 32-bit arm now. There is already a check
for an overflow of 10 seconds in there (10 million microseconds),
so it is safe to do the easiest fix is to cast that microsecond
value to a u32.

	Arnd

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

* Re: [Y2038] [PATCH] fbdev: radeon: Remove 'struct timeval' usage
@ 2015-06-05 21:12   ` Arnd Bergmann
  0 siblings, 0 replies; 12+ messages in thread
From: Arnd Bergmann @ 2015-06-05 21:12 UTC (permalink / raw)
  To: y2038
  Cc: Tina Ruchandani, Dave Airlie, Linux Fbdev development list,
	Benjamin Herrenschmidt, LKML, Tomi Valkeinen,
	Jean-Christophe Plagniol-Villard

On Friday 05 June 2015 00:55:05 Tina Ruchandani wrote:
> >>> +     hz = 1000000/delta;
> >
> > This needs to be on of the do_div family.
> >
> > Dave.
> 
> Hi Dave,
> I build-tested the patch for both 32-bit and 64-bit x86. If my
> understanding is correct, since the divisor is 64-bit here, the
> compiler will do "if (delta > 1000000) hz = 0; else hz > 1000000/(s32)delta" automatically?
> In general, is this a good thumb-rule to follow - use do_div if the
> dividend is 64-bit, and normal divide operator if only the divisor is
> 64-bit?
> 

I got a build error on 32-bit arm now. There is already a check
for an overflow of 10 seconds in there (10 million microseconds),
so it is safe to do the easiest fix is to cast that microsecond
value to a u32.

	Arnd

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

* Re: [PATCH] fbdev: radeon: Remove 'struct timeval' usage
  2015-05-25  4:19 ` Tina Ruchandani
@ 2015-08-20  7:51   ` Tomi Valkeinen
  -1 siblings, 0 replies; 12+ messages in thread
From: Tomi Valkeinen @ 2015-08-20  7:51 UTC (permalink / raw)
  To: Tina Ruchandani, Arnd Bergmann
  Cc: y2038, Benjamin Herrenschmidt, Jean-Christophe Plagniol-Villard,
	linux-fbdev, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 844 bytes --]

Hi Tina,

On 25/05/15 07:07, Tina Ruchandani wrote:
> 'struct timeval' uses a 32-bit representation for the
> seconds field which will overflow in the year 2038 and beyond.
> This patch replaces the usage of 'struct timeval' with
> ktime_t which uses a 64-bit time representation and does not
> suffer from the y2038 problem. This patch is part of a larger
> effort to remove all instances of 'struct timeval', 'struct
> timespec', time_t and other 32-bit timekeeping variables
> from the kernel.
> The patch also replaces the use of real time (do_gettimeofday)
> with monotonic time (ktime_get).
> 
> Signed-off-by: Tina Ruchandani <ruchandani.tina@gmail.com>

I had dropped this from 4.2 as there were issues reported, but forgot to
write a mail about it...

Can you send a updated patch with the issues fixed?

 Tomi


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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

* Re: [PATCH] fbdev: radeon: Remove 'struct timeval' usage
@ 2015-08-20  7:51   ` Tomi Valkeinen
  0 siblings, 0 replies; 12+ messages in thread
From: Tomi Valkeinen @ 2015-08-20  7:51 UTC (permalink / raw)
  To: Tina Ruchandani, Arnd Bergmann
  Cc: y2038, Benjamin Herrenschmidt, Jean-Christophe Plagniol-Villard,
	linux-fbdev, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 844 bytes --]

Hi Tina,

On 25/05/15 07:07, Tina Ruchandani wrote:
> 'struct timeval' uses a 32-bit representation for the
> seconds field which will overflow in the year 2038 and beyond.
> This patch replaces the usage of 'struct timeval' with
> ktime_t which uses a 64-bit time representation and does not
> suffer from the y2038 problem. This patch is part of a larger
> effort to remove all instances of 'struct timeval', 'struct
> timespec', time_t and other 32-bit timekeeping variables
> from the kernel.
> The patch also replaces the use of real time (do_gettimeofday)
> with monotonic time (ktime_get).
> 
> Signed-off-by: Tina Ruchandani <ruchandani.tina@gmail.com>

I had dropped this from 4.2 as there were issues reported, but forgot to
write a mail about it...

Can you send a updated patch with the issues fixed?

 Tomi


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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

end of thread, other threads:[~2015-08-20  7:51 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-25  4:07 [PATCH] fbdev: radeon: Remove 'struct timeval' usage Tina Ruchandani
2015-05-25  4:19 ` Tina Ruchandani
2015-06-03 11:59 ` Tomi Valkeinen
2015-06-03 11:59   ` Tomi Valkeinen
2015-06-05  4:40   ` Dave Airlie
2015-06-05  4:40     ` Dave Airlie
2015-08-20  7:51 ` Tomi Valkeinen
2015-08-20  7:51   ` Tomi Valkeinen
2015-06-05  7:55 Tina Ruchandani
2015-06-05  7:55 ` Tina Ruchandani
2015-06-05 21:12 ` [Y2038] " Arnd Bergmann
2015-06-05 21:12   ` Arnd Bergmann

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.