2005-04-16 15:20:36 -07:00
/ *
* linux/ a r c h / a r m / l i b / d e l a y . S
*
* Copyright ( C ) 1 9 9 5 , 1 9 9 6 R u s s e l l K i n g
*
* This p r o g r a m i s f r e e s o f t w a r e ; you can redistribute it and/or modify
* it u n d e r t h e t e r m s o f t h e G N U G e n e r a l P u b l i c L i c e n s e v e r s i o n 2 a s
* published b y t h e F r e e S o f t w a r e F o u n d a t i o n .
* /
# include < l i n u x / l i n k a g e . h >
# include < a s m / a s s e m b l e r . h >
2012-07-06 15:47:17 +01:00
# include < a s m / d e l a y . h >
2015-02-25 22:50:39 +01:00
2005-04-16 15:20:36 -07:00
.text
2005-11-11 21:51:49 +00:00
.LC0 : .word loops_per_jiffy
2012-07-06 15:47:17 +01:00
.LC1 : .word UDELAY_MULT
2005-04-16 15:20:36 -07:00
/ *
2016-10-07 05:38:35 +01:00
* loops = r0 * H Z * l o o p s _ p e r _ j i f f y / 1 0 0 0 0 0 0
*
2006-03-20 17:10:09 +00:00
* r0 < = 2 0 0 0
* HZ < = 1 0 0 0
2005-04-16 15:20:36 -07:00
* /
2006-03-20 17:10:09 +00:00
2012-07-06 15:47:17 +01:00
ENTRY( _ _ l o o p _ u d e l a y )
2006-03-20 17:10:09 +00:00
ldr r2 , . L C 1
2016-10-07 05:38:35 +01:00
mul r0 , r2 , r0 @ r0 = delay_us * UDELAY_MULT
ENTRY( _ _ l o o p _ c o n s t _ u d e l a y ) @ 0 <= r0 <= 0xfffffaf0
2005-11-11 21:51:49 +00:00
ldr r2 , . L C 0
2015-02-25 22:50:39 +01:00
ldr r2 , [ r2 ]
2016-10-07 05:38:35 +01:00
umull r1 , r0 , r2 , r0 @ r0-r1 = r0 * loops_per_jiffy
adds r1 , r1 , #0xffffffff @ rounding up ...
adcs r0 , r0 , r0 @ and right shift by 31
2014-06-30 16:29:12 +01:00
reteq l r
2005-04-16 15:20:36 -07:00
ARM: 7907/1: lib: delay-loop: Add align directive to fix BogoMIPS calculation
Currently mx53 (CortexA8) running at 1GHz reports:
Calibrating delay loop... 663.55 BogoMIPS (lpj=3317760)
Tom Evans verified that alignments of 0x0 and 0x8 run the two instructions of __loop_delay in one clock cycle (1 clock/loop), while alignments of 0x4 and 0xc take 3 clocks to run the loop twice. (1.5 clock/loop)
The original object code looks like this:
00000010 <__loop_const_udelay>:
10: e3e01000 mvn r1, #0
14: e51f201c ldr r2, [pc, #-28] ; 0 <__loop_udelay-0x8>
18: e5922000 ldr r2, [r2]
1c: e0800921 add r0, r0, r1, lsr #18
20: e1a00720 lsr r0, r0, #14
24: e0822b21 add r2, r2, r1, lsr #22
28: e1a02522 lsr r2, r2, #10
2c: e0000092 mul r0, r2, r0
30: e0800d21 add r0, r0, r1, lsr #26
34: e1b00320 lsrs r0, r0, #6
38: 01a0f00e moveq pc, lr
0000003c <__loop_delay>:
3c: e2500001 subs r0, r0, #1
40: 8afffffe bhi 3c <__loop_delay>
44: e1a0f00e mov pc, lr
After adding the 'align 3' directive to __loop_delay (align to 8 bytes):
00000010 <__loop_const_udelay>:
10: e3e01000 mvn r1, #0
14: e51f201c ldr r2, [pc, #-28] ; 0 <__loop_udelay-0x8>
18: e5922000 ldr r2, [r2]
1c: e0800921 add r0, r0, r1, lsr #18
20: e1a00720 lsr r0, r0, #14
24: e0822b21 add r2, r2, r1, lsr #22
28: e1a02522 lsr r2, r2, #10
2c: e0000092 mul r0, r2, r0
30: e0800d21 add r0, r0, r1, lsr #26
34: e1b00320 lsrs r0, r0, #6
38: 01a0f00e moveq pc, lr
3c: e320f000 nop {0}
00000040 <__loop_delay>:
40: e2500001 subs r0, r0, #1
44: 8afffffe bhi 40 <__loop_delay>
48: e1a0f00e mov pc, lr
4c: e320f000 nop {0}
, which now reports:
Calibrating delay loop... 996.14 BogoMIPS (lpj=4980736)
Some more test results:
On mx31 (ARM1136) running at 532 MHz, before the patch:
Calibrating delay loop... 351.43 BogoMIPS (lpj=1757184)
On mx31 (ARM1136) running at 532 MHz after the patch:
Calibrating delay loop... 528.79 BogoMIPS (lpj=2643968)
Also tested on mx6 (CortexA9) and on mx27 (ARM926), which shows the same
BogoMIPS value before and after this patch.
Reported-by: Tom Evans <tom_usenet@optusnet.com.au>
Suggested-by: Tom Evans <tom_usenet@optusnet.com.au>
Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
2013-11-30 15:24:42 +01:00
.align 3
2005-04-16 15:20:36 -07:00
@ Delay routine
2012-07-06 15:47:17 +01:00
ENTRY( _ _ l o o p _ d e l a y )
2005-04-16 15:20:36 -07:00
subs r0 , r0 , #1
# if 0
2014-06-30 16:29:12 +01:00
retls l r
2005-04-16 15:20:36 -07:00
subs r0 , r0 , #1
2014-06-30 16:29:12 +01:00
retls l r
2005-04-16 15:20:36 -07:00
subs r0 , r0 , #1
2014-06-30 16:29:12 +01:00
retls l r
2005-04-16 15:20:36 -07:00
subs r0 , r0 , #1
2014-06-30 16:29:12 +01:00
retls l r
2005-04-16 15:20:36 -07:00
subs r0 , r0 , #1
2014-06-30 16:29:12 +01:00
retls l r
2005-04-16 15:20:36 -07:00
subs r0 , r0 , #1
2014-06-30 16:29:12 +01:00
retls l r
2005-04-16 15:20:36 -07:00
subs r0 , r0 , #1
2014-06-30 16:29:12 +01:00
retls l r
2005-04-16 15:20:36 -07:00
subs r0 , r0 , #1
# endif
2012-07-06 15:47:17 +01:00
bhi _ _ l o o p _ d e l a y
2014-06-30 16:29:12 +01:00
ret l r
2012-07-06 15:47:17 +01:00
ENDPROC( _ _ l o o p _ u d e l a y )
ENDPROC( _ _ l o o p _ c o n s t _ u d e l a y )
ENDPROC( _ _ l o o p _ d e l a y )