ARM: fix delays
authorRussell King <rmk+kernel@armlinux.org.uk>
Wed, 5 Oct 2016 22:40:43 +0000 (23:40 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 16 Oct 2016 16:03:40 +0000 (18:03 +0200)
commit47d2e117d6463a5a9ac36f1391ce31a9a34929c8
tree1097be412a60547f138fa2cb1f54395759633bfb
parent73933444b82e46faaa74055b36acee975a898ac9
ARM: fix delays

commit fb833b1fbb68461772dbf5e91bddea5e839187e9 upstream.

Commit 215e362dafed ("ARM: 8306/1: loop_udelay: remove bogomips value
limitation") tried to increase the bogomips limitation, but in doing
so messed up udelay such that it always gives about a 5% error in the
delay, even if we use a timer.

The calculation is:

loops = UDELAY_MULT * us_delay * ticks_per_jiffy >> UDELAY_SHIFT

Originally, UDELAY_MULT was ((UL(2199023) * HZ) >> 11) and UDELAY_SHIFT
30.  Assuming HZ=100, us_delay of 1000 and ticks_per_jiffy of 1660000
(eg, 166MHz timer, 1ms delay) this would calculate:

((UL(2199023) * HZ) >> 11) * 1000 * 1660000 >> 30
=> 165999

With the new values of 2047 * HZ + 483648 * HZ / 1000000 and 31, we get:

(2047 * HZ + 483648 * HZ / 1000000) * 1000 * 1660000 >> 31
=> 158269

which is incorrect.  This is due to a typo - correcting it gives:

(2147 * HZ + 483648 * HZ / 1000000) * 1000 * 1660000 >> 31
=> 165999

i.o.w, the original value.

Fixes: 215e362dafed ("ARM: 8306/1: loop_udelay: remove bogomips value limitation")
Reviewed-by: Nicolas Pitre <nico@linaro.org>
Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
arch/arm/include/asm/delay.h
This page took 0.024374 seconds and 5 git commands to generate.