Skip to content

Commit 7efd0da

Browse files
mischajonkervineetgarc
authored andcommitted
ARC: Fix __udelay calculation
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>
1 parent 8508d56 commit 7efd0da

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

‎arch/arc/include/asm/delay.h‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,10 @@ static inline void __udelay(unsigned long usecs)
5353
{
5454
unsigned long loops;
5555

56-
/* (long long) cast ensures 64 bit MPY - real or emulated
56+
/* (u64) cast ensures 64 bit MPY - real or emulated
5757
* HZ * 4295 is pre-evaluated by gcc - hence only 2 mpy ops
5858
*/
59-
loops = ((long long)(usecs * 4295 * HZ) *
60-
(long long)(loops_per_jiffy)) >> 32;
59+
loops = ((u64) usecs * 4295 * HZ * loops_per_jiffy) >> 32;
6160

6261
__delay(loops);
6362
}

0 commit comments

Comments
 (0)