diff options
author | Mischa Jonker <mjonker@synopsys.com> | 2013-08-30 05:56:25 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-10-18 10:45:45 -0400 |
commit | 8036c31c84117707d4132cd199d997d7ed41427c (patch) | |
tree | 33c8a035061278ccabc7196be5ccffbebd4811cd /arch/arc | |
parent | 98f745546bd27e54fe0bed1e9c900301428de9d5 (diff) |
ARC: Fix __udelay calculation
commit 7efd0da2d17360e1cef91507dbe619db0ee2c691 upstream.
Cast usecs to u64, to ensure that the (usecs * 4295 * HZ)
multiplication is 64 bit.
Initially, the (usecs * 4295 * HZ) part was done as a 32 bit
multiplication, with the result casted to 64 bit. This led to some bits
falling off, causing a "DMA initialization error" in the stmmac Ethernet
driver, due to a premature timeout.
Signed-off-by: Mischa Jonker <mjonker@synopsys.com>
Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'arch/arc')
-rw-r--r-- | arch/arc/include/asm/delay.h | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/arch/arc/include/asm/delay.h b/arch/arc/include/asm/delay.h index 442ce5d0f709..43de30256981 100644 --- a/arch/arc/include/asm/delay.h +++ b/arch/arc/include/asm/delay.h | |||
@@ -53,11 +53,10 @@ static inline void __udelay(unsigned long usecs) | |||
53 | { | 53 | { |
54 | unsigned long loops; | 54 | unsigned long loops; |
55 | 55 | ||
56 | /* (long long) cast ensures 64 bit MPY - real or emulated | 56 | /* (u64) cast ensures 64 bit MPY - real or emulated |
57 | * HZ * 4295 is pre-evaluated by gcc - hence only 2 mpy ops | 57 | * HZ * 4295 is pre-evaluated by gcc - hence only 2 mpy ops |
58 | */ | 58 | */ |
59 | loops = ((long long)(usecs * 4295 * HZ) * | 59 | loops = ((u64) usecs * 4295 * HZ * loops_per_jiffy) >> 32; |
60 | (long long)(loops_per_jiffy)) >> 32; | ||
61 | 60 | ||
62 | __delay(loops); | 61 | __delay(loops); |
63 | } | 62 | } |