2 * arch/s390/lib/spinlock.c
3 * Out of line spinlock code.
6 * Copyright (C) 2004 IBM Deutschland Entwicklung GmbH, IBM Corporation
7 * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com)
10 #include <linux/types.h>
11 #include <linux/module.h>
12 #include <linux/spinlock.h>
13 #include <linux/init.h>
16 int spin_retry = 1000;
19 * spin_retry= parameter
21 static int __init spin_retry_setup(char *str)
23 spin_retry = simple_strtoul(str, &str, 0);
26 __setup("spin_retry=", spin_retry_setup);
32 if (MACHINE_HAS_DIAG44)
34 asm volatile("diag 0,0,0x44");
38 _raw_spin_lock_wait(raw_spinlock_t *lp, unsigned int pc)
40 int count = spin_retry;
47 if (_raw_compare_and_swap(&lp->lock, 0, pc) == 0)
51 EXPORT_SYMBOL(_raw_spin_lock_wait);
54 _raw_spin_trylock_retry(raw_spinlock_t *lp, unsigned int pc)
56 int count = spin_retry;
59 if (_raw_compare_and_swap(&lp->lock, 0, pc) == 0)
64 EXPORT_SYMBOL(_raw_spin_trylock_retry);
67 _raw_read_lock_wait(raw_rwlock_t *rw)
70 int count = spin_retry;
77 old = rw->lock & 0x7fffffffU;
78 if (_raw_compare_and_swap(&rw->lock, old, old + 1) == old)
82 EXPORT_SYMBOL(_raw_read_lock_wait);
85 _raw_read_trylock_retry(raw_rwlock_t *rw)
88 int count = spin_retry;
91 old = rw->lock & 0x7fffffffU;
92 if (_raw_compare_and_swap(&rw->lock, old, old + 1) == old)
97 EXPORT_SYMBOL(_raw_read_trylock_retry);
100 _raw_write_lock_wait(raw_rwlock_t *rw)
102 int count = spin_retry;
109 if (_raw_compare_and_swap(&rw->lock, 0, 0x80000000) == 0)
113 EXPORT_SYMBOL(_raw_write_lock_wait);
116 _raw_write_trylock_retry(raw_rwlock_t *rw)
118 int count = spin_retry;
120 while (count-- > 0) {
121 if (_raw_compare_and_swap(&rw->lock, 0, 0x80000000) == 0)
126 EXPORT_SYMBOL(_raw_write_trylock_retry);