Andi Kleen | 9a0b26e | 2006-09-26 10:52:28 +0200 | [diff] [blame] | 1 | /* Slow paths of read/write spinlocks. */ |
| 2 | |
| 3 | #include <linux/linkage.h> |
| 4 | #include <asm/rwlock.h> |
Adrian Bunk | 7e02cb9 | 2007-10-17 18:04:38 +0200 | [diff] [blame] | 5 | #include <asm/alternative-asm.h> |
Andi Kleen | 9a0b26e | 2006-09-26 10:52:28 +0200 | [diff] [blame] | 6 | #include <asm/dwarf2.h> |
| 7 | |
| 8 | /* rdi: pointer to rwlock_t */ |
| 9 | ENTRY(__write_lock_failed) |
| 10 | CFI_STARTPROC |
| 11 | LOCK_PREFIX |
| 12 | addl $RW_LOCK_BIAS,(%rdi) |
| 13 | 1: rep |
| 14 | nop |
| 15 | cmpl $RW_LOCK_BIAS,(%rdi) |
| 16 | jne 1b |
| 17 | LOCK_PREFIX |
| 18 | subl $RW_LOCK_BIAS,(%rdi) |
| 19 | jnz __write_lock_failed |
| 20 | ret |
| 21 | CFI_ENDPROC |
| 22 | END(__write_lock_failed) |
| 23 | |
| 24 | /* rdi: pointer to rwlock_t */ |
| 25 | ENTRY(__read_lock_failed) |
| 26 | CFI_STARTPROC |
| 27 | LOCK_PREFIX |
| 28 | incl (%rdi) |
| 29 | 1: rep |
| 30 | nop |
| 31 | cmpl $1,(%rdi) |
| 32 | js 1b |
| 33 | LOCK_PREFIX |
| 34 | decl (%rdi) |
| 35 | js __read_lock_failed |
| 36 | ret |
| 37 | CFI_ENDPROC |
| 38 | END(__read_lock_failed) |