Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ARM: ensure delay timer has sufficient accuracy for delays

We have recently had an example of someone wanting to use a 90kHz timer
for the software delay loop.

udelay() needs to have at least microsecond resolution to allow drivers
access to a delay mechanism with a reasonable chance of delaying the
period they requested within at least a 50% marging of error, especially
for small delays.

Discussion about the udelay() accuracy can be found at:
https://lkml.org/lkml/2011/1/9/37

Reject timers which are unable to supply this level of resolution.

Acked-by: Nicolas Pitre <nico@linaro.org>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>

+6
+6
arch/arm/lib/delay.c
··· 83 83 NSEC_PER_SEC, 3600); 84 84 res = cyc_to_ns(1ULL, new_mult, new_shift); 85 85 86 + if (res > 1000) { 87 + pr_err("Ignoring delay timer %ps, which has insufficient resolution of %lluns\n", 88 + timer, res); 89 + return; 90 + } 91 + 86 92 if (!delay_calibrated && (!delay_res || (res < delay_res))) { 87 93 pr_info("Switching to timer-based delay loop, resolution %lluns\n", res); 88 94 delay_timer = timer;