arch/tile: fix __ndelay etc to work better
commit13371731487896a6ef158b1cd74297f40a3da4bb
authorChris Metcalf <cmetcalf@tilera.com>
Mon, 28 Feb 2011 18:21:52 +0000 (28 13:21 -0500)
committerChris Metcalf <cmetcalf@tilera.com>
Tue, 1 Mar 2011 21:20:04 +0000 (1 16:20 -0500)
treeaf09fca3fd8811340b373faaddcdb528f8a07669
parent04f7a3f12e10032ee3d44df1a509dbf5b2001fce
arch/tile: fix __ndelay etc to work better

The current implementations of __ndelay and __udelay call a hypervisor
service to delay, but the hypervisor service isn't actually implemented
very well, and the consensus is that Linux should handle figuring this
out natively and not use a hypervisor service.

By converting nanoseconds to cycles, and then spinning until the
cycle counter reaches the desired cycle, we get several benefits:
first, we are sensitive to the actual clock speed; second, we use
less power by issuing a slow SPR read once every six cycles while
we delay; and third, we properly handle the case of an interrupt by
exiting at the target time rather than after some number of cycles.

Signed-off-by: Chris Metcalf <cmetcalf@tilera.com>
arch/tile/include/asm/timex.h
arch/tile/include/hv/hypervisor.h
arch/tile/kernel/entry.S
arch/tile/kernel/time.c
arch/tile/lib/delay.c