fbdev: radeon: use ktime_get() for HZ calibration

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>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
This commit is contained in:
Arnd Bergmann 2018-01-04 16:53:49 +01:00 коммит произвёл Bartlomiej Zolnierkiewicz
Родитель defddeff61
Коммит 63a4be9393
1 изменённых файлов: 7 добавлений и 11 удалений

Просмотреть файл

@ -583,8 +583,8 @@ static int radeon_probe_pll_params(struct radeonfb_info *rinfo)
int hTotal, vTotal, num, denom, m, n; int hTotal, vTotal, num, denom, m, n;
unsigned long long hz, vclk; unsigned long long hz, vclk;
long xtal; long xtal;
struct timeval start_tv, stop_tv; ktime_t start_time, stop_time;
long total_secs, total_usecs; u64 total_usecs;
int i; int i;
/* Ugh, we cut interrupts, bad bad bad, but we want some precision /* 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) if (((INREG(CRTC_VLINE_CRNT_VLINE) >> 16) & 0x3ff) == 0)
break; break;
do_gettimeofday(&start_tv); start_time = ktime_get();
for(i=0; i<1000000; i++) for(i=0; i<1000000; i++)
if (((INREG(CRTC_VLINE_CRNT_VLINE) >> 16) & 0x3ff) != 0) 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) if (((INREG(CRTC_VLINE_CRNT_VLINE) >> 16) & 0x3ff) == 0)
break; break;
do_gettimeofday(&stop_tv); stop_time = ktime_get();
local_irq_enable(); local_irq_enable();
total_secs = stop_tv.tv_sec - start_tv.tv_sec; total_usecs = ktime_us_delta(stop_time, start_time);
if (total_secs > 10) if (total_usecs >= 10 * USEC_PER_SEC || total_usecs == 0)
return -1; return -1;
total_usecs = stop_tv.tv_usec - start_tv.tv_usec; hz = USEC_PER_SEC/(u32)total_usecs;
total_usecs += total_secs * 1000000;
if (total_usecs < 0)
total_usecs = -total_usecs;
hz = 1000000/total_usecs;
hTotal = ((INREG(CRTC_H_TOTAL_DISP) & 0x1ff) + 1) * 8; hTotal = ((INREG(CRTC_H_TOTAL_DISP) & 0x1ff) + 1) * 8;
vTotal = ((INREG(CRTC_V_TOTAL_DISP) & 0x3ff) + 1); vTotal = ((INREG(CRTC_V_TOTAL_DISP) & 0x3ff) + 1);