fbdev: radeon: Remove 'struct timeval' usage
Subsystems (2)
PATCH 1/1 fbdev: radeon: Remove 'struct timeval' usage
'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).
--- drivers/video/fbdev/aty/radeon_base.c | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-)
drivers/video/fbdev/aty/radeon_base.c +14 -15
@@ -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 ;
Signature · 1 line
2.2.0.rc0.207.ga3a616c
Quoted 79 lines · Tina Ruchandani
'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_twhich 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_tand 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 <[email protected]>--- drivers/video/fbdev/aty/radeon_base.c | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-)drivers/video/fbdev/aty/radeon_base.c +13
-14@@ -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;
drivers/video/fbdev/aty/radeon_base.c static int radeon_probe_pll_params(struct radeonfb_info *rinfo) · line 553
Quoted 8 lines
drivers/video/fbdev/aty/radeon_base.c +1
-1@@ -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
Quoted 63 lines · Tomi Valkeinen
Quoted 60 lines · Tina Ruchandani
'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_twhich 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_tand 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 <[email protected]>--- drivers/video/fbdev/aty/radeon_base.c | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-)drivers/video/fbdev/aty/radeon_base.c +7
-6@@ -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 ();
Quoted 14 lines
Quoted 4 lines
drivers/video/fbdev/aty/radeon_base.c +2
-2- total_secs = stop_tv.tv_sec - start_tv.tv_sec; -if (total_secs >10 ) + delta =ktime_us_delta (stop, start); +drivers/video/fbdev/aty/radeon_base.c static int radeon_probe_pll_params(struct radeonfb_info *rinfo) · line 501
Quoted 10 lines
drivers/video/fbdev/aty/radeon_base.c +3
-6+/* 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.
Hi Tina,
Quoted 11 lines · Tina Ruchandani
'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_twhich 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_tand other 32-bit timekeeping variables from the kernel.
The patch also replaces the use of real time (do_gettimeofday) with monotonic time (ktime_get).
Quoted 1 line
Signed-off-by Tina Ruchandani <[email protected]>
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