2005-04-16 15:20:36 -07:00
/ * rwsem. S : R W s e m a p h o r e a s s e m b l e r .
*
* Written b y D a v i d S . M i l l e r ( d a v e m @redhat.com), 2001.
* Derived f r o m a s m - i 3 8 6 / r w s e m . h
* /
# include < a s m / r w s e m - c o n s t . h >
2008-01-28 21:06:23 -08:00
.section .sched .text , " ax"
2005-04-16 15:20:36 -07:00
.globl __down_read
__down_read :
1 : lduw [ % o 0 ] , % g 1
add % g 1 , 1 , % g 7
cas [ % o 0 ] , % g 1 , % g 7
cmp % g 1 , % g 7
bne,p n % i c c , 1 b
add % g 7 , 1 , % g 7
cmp % g 7 , 0
[SPARC64]: Avoid membar instructions in delay slots.
In particular, avoid membar instructions in the delay
slot of a jmpl instruction.
UltraSPARC-I, II, IIi, and IIe have a bug, documented in
the UltraSPARC-IIi User's Manual, Appendix K, Erratum 51
The long and short of it is that if the IMU unit misses
on a branch or jmpl, and there is a store buffer synchronizing
membar in the delay slot, the chip can stop fetching instructions.
If interrupts are enabled or some other trap is enabled, the
chip will unwedge itself, but performance will suffer.
We already had a workaround for this bug in a few spots, but
it's better to have the entire tree sanitized for this rule.
Signed-off-by: David S. Miller <davem@davemloft.net>
2005-06-27 15:42:04 -07:00
membar #S t o r e L o a d | # S t o r e S t o r e
2005-04-16 15:20:36 -07:00
bl,p n % i c c , 3 f
[SPARC64]: Avoid membar instructions in delay slots.
In particular, avoid membar instructions in the delay
slot of a jmpl instruction.
UltraSPARC-I, II, IIi, and IIe have a bug, documented in
the UltraSPARC-IIi User's Manual, Appendix K, Erratum 51
The long and short of it is that if the IMU unit misses
on a branch or jmpl, and there is a store buffer synchronizing
membar in the delay slot, the chip can stop fetching instructions.
If interrupts are enabled or some other trap is enabled, the
chip will unwedge itself, but performance will suffer.
We already had a workaround for this bug in a few spots, but
it's better to have the entire tree sanitized for this rule.
Signed-off-by: David S. Miller <davem@davemloft.net>
2005-06-27 15:42:04 -07:00
nop
2005-04-16 15:20:36 -07:00
2 :
retl
nop
3 :
save % s p , - 1 9 2 , % s p
call r w s e m _ d o w n _ r e a d _ f a i l e d
mov % i 0 , % o 0
ret
restore
.size _ _ down_ r e a d , . - _ _ d o w n _ r e a d
.globl __down_read_trylock
__down_read_trylock :
1 : lduw [ % o 0 ] , % g 1
add % g 1 , 1 , % g 7
cmp % g 7 , 0
bl,p n % i c c , 2 f
mov 0 , % o 1
cas [ % o 0 ] , % g 1 , % g 7
cmp % g 1 , % g 7
bne,p n % i c c , 1 b
mov 1 , % o 1
membar #S t o r e L o a d | # S t o r e S t o r e
2 : retl
mov % o 1 , % o 0
.size _ _ down_ r e a d _ t r y l o c k , . - _ _ d o w n _ r e a d _ t r y l o c k
.globl __down_write
__down_write :
sethi % h i ( R W S E M _ A C T I V E _ W R I T E _ B I A S ) , % g 1
or % g 1 , % l o ( R W S E M _ A C T I V E _ W R I T E _ B I A S ) , % g 1
1 :
lduw [ % o 0 ] , % g 3
add % g 3 , % g 1 , % g 7
cas [ % o 0 ] , % g 3 , % g 7
cmp % g 3 , % g 7
bne,p n % i c c , 1 b
cmp % g 7 , 0
[SPARC64]: Avoid membar instructions in delay slots.
In particular, avoid membar instructions in the delay
slot of a jmpl instruction.
UltraSPARC-I, II, IIi, and IIe have a bug, documented in
the UltraSPARC-IIi User's Manual, Appendix K, Erratum 51
The long and short of it is that if the IMU unit misses
on a branch or jmpl, and there is a store buffer synchronizing
membar in the delay slot, the chip can stop fetching instructions.
If interrupts are enabled or some other trap is enabled, the
chip will unwedge itself, but performance will suffer.
We already had a workaround for this bug in a few spots, but
it's better to have the entire tree sanitized for this rule.
Signed-off-by: David S. Miller <davem@davemloft.net>
2005-06-27 15:42:04 -07:00
membar #S t o r e L o a d | # S t o r e S t o r e
2005-04-16 15:20:36 -07:00
bne,p n % i c c , 3 f
[SPARC64]: Avoid membar instructions in delay slots.
In particular, avoid membar instructions in the delay
slot of a jmpl instruction.
UltraSPARC-I, II, IIi, and IIe have a bug, documented in
the UltraSPARC-IIi User's Manual, Appendix K, Erratum 51
The long and short of it is that if the IMU unit misses
on a branch or jmpl, and there is a store buffer synchronizing
membar in the delay slot, the chip can stop fetching instructions.
If interrupts are enabled or some other trap is enabled, the
chip will unwedge itself, but performance will suffer.
We already had a workaround for this bug in a few spots, but
it's better to have the entire tree sanitized for this rule.
Signed-off-by: David S. Miller <davem@davemloft.net>
2005-06-27 15:42:04 -07:00
nop
2005-04-16 15:20:36 -07:00
2 : retl
nop
3 :
save % s p , - 1 9 2 , % s p
call r w s e m _ d o w n _ w r i t e _ f a i l e d
mov % i 0 , % o 0
ret
restore
.size _ _ down_ w r i t e , . - _ _ d o w n _ w r i t e
.globl __down_write_trylock
__down_write_trylock :
sethi % h i ( R W S E M _ A C T I V E _ W R I T E _ B I A S ) , % g 1
or % g 1 , % l o ( R W S E M _ A C T I V E _ W R I T E _ B I A S ) , % g 1
1 :
lduw [ % o 0 ] , % g 3
cmp % g 3 , 0
bne,p n % i c c , 2 f
mov 0 , % o 1
add % g 3 , % g 1 , % g 7
cas [ % o 0 ] , % g 3 , % g 7
cmp % g 3 , % g 7
bne,p n % i c c , 1 b
mov 1 , % o 1
membar #S t o r e L o a d | # S t o r e S t o r e
2 : retl
mov % o 1 , % o 0
.size _ _ down_ w r i t e _ t r y l o c k , . - _ _ d o w n _ w r i t e _ t r y l o c k
.globl __up_read
__up_read :
1 :
lduw [ % o 0 ] , % g 1
sub % g 1 , 1 , % g 7
cas [ % o 0 ] , % g 1 , % g 7
cmp % g 1 , % g 7
bne,p n % i c c , 1 b
cmp % g 7 , 0
[SPARC64]: Avoid membar instructions in delay slots.
In particular, avoid membar instructions in the delay
slot of a jmpl instruction.
UltraSPARC-I, II, IIi, and IIe have a bug, documented in
the UltraSPARC-IIi User's Manual, Appendix K, Erratum 51
The long and short of it is that if the IMU unit misses
on a branch or jmpl, and there is a store buffer synchronizing
membar in the delay slot, the chip can stop fetching instructions.
If interrupts are enabled or some other trap is enabled, the
chip will unwedge itself, but performance will suffer.
We already had a workaround for this bug in a few spots, but
it's better to have the entire tree sanitized for this rule.
Signed-off-by: David S. Miller <davem@davemloft.net>
2005-06-27 15:42:04 -07:00
membar #S t o r e L o a d | # S t o r e S t o r e
2005-04-16 15:20:36 -07:00
bl,p n % i c c , 3 f
[SPARC64]: Avoid membar instructions in delay slots.
In particular, avoid membar instructions in the delay
slot of a jmpl instruction.
UltraSPARC-I, II, IIi, and IIe have a bug, documented in
the UltraSPARC-IIi User's Manual, Appendix K, Erratum 51
The long and short of it is that if the IMU unit misses
on a branch or jmpl, and there is a store buffer synchronizing
membar in the delay slot, the chip can stop fetching instructions.
If interrupts are enabled or some other trap is enabled, the
chip will unwedge itself, but performance will suffer.
We already had a workaround for this bug in a few spots, but
it's better to have the entire tree sanitized for this rule.
Signed-off-by: David S. Miller <davem@davemloft.net>
2005-06-27 15:42:04 -07:00
nop
2005-04-16 15:20:36 -07:00
2 : retl
nop
3 : sethi % h i ( R W S E M _ A C T I V E _ M A S K ) , % g 1
sub % g 7 , 1 , % g 7
or % g 1 , % l o ( R W S E M _ A C T I V E _ M A S K ) , % g 1
andcc % g 7 , % g 1 , % g 0
bne,p n % i c c , 2 b
nop
save % s p , - 1 9 2 , % s p
call r w s e m _ w a k e
mov % i 0 , % o 0
ret
restore
.size _ _ up_ r e a d , . - _ _ u p _ r e a d
.globl __up_write
__up_write :
sethi % h i ( R W S E M _ A C T I V E _ W R I T E _ B I A S ) , % g 1
or % g 1 , % l o ( R W S E M _ A C T I V E _ W R I T E _ B I A S ) , % g 1
1 :
lduw [ % o 0 ] , % g 3
sub % g 3 , % g 1 , % g 7
cas [ % o 0 ] , % g 3 , % g 7
cmp % g 3 , % g 7
bne,p n % i c c , 1 b
sub % g 7 , % g 1 , % g 7
cmp % g 7 , 0
[SPARC64]: Avoid membar instructions in delay slots.
In particular, avoid membar instructions in the delay
slot of a jmpl instruction.
UltraSPARC-I, II, IIi, and IIe have a bug, documented in
the UltraSPARC-IIi User's Manual, Appendix K, Erratum 51
The long and short of it is that if the IMU unit misses
on a branch or jmpl, and there is a store buffer synchronizing
membar in the delay slot, the chip can stop fetching instructions.
If interrupts are enabled or some other trap is enabled, the
chip will unwedge itself, but performance will suffer.
We already had a workaround for this bug in a few spots, but
it's better to have the entire tree sanitized for this rule.
Signed-off-by: David S. Miller <davem@davemloft.net>
2005-06-27 15:42:04 -07:00
membar #S t o r e L o a d | # S t o r e S t o r e
2005-04-16 15:20:36 -07:00
bl,p n % i c c , 3 f
[SPARC64]: Avoid membar instructions in delay slots.
In particular, avoid membar instructions in the delay
slot of a jmpl instruction.
UltraSPARC-I, II, IIi, and IIe have a bug, documented in
the UltraSPARC-IIi User's Manual, Appendix K, Erratum 51
The long and short of it is that if the IMU unit misses
on a branch or jmpl, and there is a store buffer synchronizing
membar in the delay slot, the chip can stop fetching instructions.
If interrupts are enabled or some other trap is enabled, the
chip will unwedge itself, but performance will suffer.
We already had a workaround for this bug in a few spots, but
it's better to have the entire tree sanitized for this rule.
Signed-off-by: David S. Miller <davem@davemloft.net>
2005-06-27 15:42:04 -07:00
nop
2005-04-16 15:20:36 -07:00
2 :
retl
nop
3 :
save % s p , - 1 9 2 , % s p
call r w s e m _ w a k e
mov % i 0 , % o 0
ret
restore
.size _ _ up_ w r i t e , . - _ _ u p _ w r i t e
.globl __downgrade_write
__downgrade_write :
sethi % h i ( R W S E M _ W A I T I N G _ B I A S ) , % g 1
or % g 1 , % l o ( R W S E M _ W A I T I N G _ B I A S ) , % g 1
1 :
lduw [ % o 0 ] , % g 3
sub % g 3 , % g 1 , % g 7
cas [ % o 0 ] , % g 3 , % g 7
cmp % g 3 , % g 7
bne,p n % i c c , 1 b
sub % g 7 , % g 1 , % g 7
cmp % g 7 , 0
[SPARC64]: Avoid membar instructions in delay slots.
In particular, avoid membar instructions in the delay
slot of a jmpl instruction.
UltraSPARC-I, II, IIi, and IIe have a bug, documented in
the UltraSPARC-IIi User's Manual, Appendix K, Erratum 51
The long and short of it is that if the IMU unit misses
on a branch or jmpl, and there is a store buffer synchronizing
membar in the delay slot, the chip can stop fetching instructions.
If interrupts are enabled or some other trap is enabled, the
chip will unwedge itself, but performance will suffer.
We already had a workaround for this bug in a few spots, but
it's better to have the entire tree sanitized for this rule.
Signed-off-by: David S. Miller <davem@davemloft.net>
2005-06-27 15:42:04 -07:00
membar #S t o r e L o a d | # S t o r e S t o r e
2005-04-16 15:20:36 -07:00
bl,p n % i c c , 3 f
[SPARC64]: Avoid membar instructions in delay slots.
In particular, avoid membar instructions in the delay
slot of a jmpl instruction.
UltraSPARC-I, II, IIi, and IIe have a bug, documented in
the UltraSPARC-IIi User's Manual, Appendix K, Erratum 51
The long and short of it is that if the IMU unit misses
on a branch or jmpl, and there is a store buffer synchronizing
membar in the delay slot, the chip can stop fetching instructions.
If interrupts are enabled or some other trap is enabled, the
chip will unwedge itself, but performance will suffer.
We already had a workaround for this bug in a few spots, but
it's better to have the entire tree sanitized for this rule.
Signed-off-by: David S. Miller <davem@davemloft.net>
2005-06-27 15:42:04 -07:00
nop
2005-04-16 15:20:36 -07:00
2 :
retl
nop
3 :
save % s p , - 1 9 2 , % s p
call r w s e m _ d o w n g r a d e _ w a k e
mov % i 0 , % o 0
ret
restore
.size _ _ downgrade_ w r i t e , . - _ _ d o w n g r a d e _ w r i t e