diff options
author | Mark Fortescue <mark@mtfhpc.demon.co.uk> | 2007-07-21 22:17:41 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2007-07-21 22:17:41 -0400 |
commit | 196bffa5dc3181897bd32e41415ec0db8dbab5e7 (patch) | |
tree | 24675b94165ea6886827d47006cb12e9dd6b3539 /arch/sparc/kernel/entry.S | |
parent | c2e68052429fdf87702fccd272951282bef1c60a (diff) |
[SPARC32]: Fix rounding errors in ndelay/udelay implementation.
__ndelay and __udelay have not been delayung >= specified time.
The problem with __ndelay has been tacked down to the rounding of the
multiplier constant. By changing this, delays > app 18us are correctly
calculated.
The problem with __udelay has also been tracked down to rounding issues.
Changing the multiplier constant (to match that used in sparc64) corrects
for large delays and adding in a rounding constant corrects for trunctaion
errors in the claculations.
Many short delays will return without looping. This is not an error as there
is the fixed delay of doing all the maths to calculate the loop count.
Signed-off-by: Mark Fortescue <mark@mtfhpc.demon.co.uk>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'arch/sparc/kernel/entry.S')
-rw-r--r-- | arch/sparc/kernel/entry.S | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/arch/sparc/kernel/entry.S b/arch/sparc/kernel/entry.S index 831f540251f8..eac38388f5fd 100644 --- a/arch/sparc/kernel/entry.S +++ b/arch/sparc/kernel/entry.S | |||
@@ -1749,8 +1749,8 @@ fpload: | |||
1749 | __ndelay: | 1749 | __ndelay: |
1750 | save %sp, -STACKFRAME_SZ, %sp | 1750 | save %sp, -STACKFRAME_SZ, %sp |
1751 | mov %i0, %o0 | 1751 | mov %i0, %o0 |
1752 | call .umul | 1752 | call .umul ! round multiplier up so large ns ok |
1753 | mov 0x1ad, %o1 ! 2**32 / (1 000 000 000 / HZ) | 1753 | mov 0x1ae, %o1 ! 2**32 / (1 000 000 000 / HZ) |
1754 | call .umul | 1754 | call .umul |
1755 | mov %i1, %o1 ! udelay_val | 1755 | mov %i1, %o1 ! udelay_val |
1756 | ba delay_continue | 1756 | ba delay_continue |
@@ -1760,11 +1760,17 @@ __ndelay: | |||
1760 | __udelay: | 1760 | __udelay: |
1761 | save %sp, -STACKFRAME_SZ, %sp | 1761 | save %sp, -STACKFRAME_SZ, %sp |
1762 | mov %i0, %o0 | 1762 | mov %i0, %o0 |
1763 | sethi %hi(0x10c6), %o1 | 1763 | sethi %hi(0x10c7), %o1 ! round multiplier up so large us ok |
1764 | call .umul | 1764 | call .umul |
1765 | or %o1, %lo(0x10c6), %o1 ! 2**32 / 1 000 000 | 1765 | or %o1, %lo(0x10c7), %o1 ! 2**32 / 1 000 000 |
1766 | call .umul | 1766 | call .umul |
1767 | mov %i1, %o1 ! udelay_val | 1767 | mov %i1, %o1 ! udelay_val |
1768 | sethi %hi(0x028f4b62), %l0 ! Add in rounding constant * 2**32, | ||
1769 | or %g0, %lo(0x028f4b62), %l0 | ||
1770 | addcc %o0, %l0, %o0 ! 2**32 * 0.009 999 | ||
1771 | bcs,a 3f | ||
1772 | add %o1, 0x01, %o1 | ||
1773 | 3: | ||
1768 | call .umul | 1774 | call .umul |
1769 | mov HZ, %o0 ! >>32 earlier for wider range | 1775 | mov HZ, %o0 ! >>32 earlier for wider range |
1770 | 1776 | ||