Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 77198
b: refs/heads/master
c: 3b4beb3
h: refs/heads/master
v: v3
  • Loading branch information
Heiko Carstens authored and Martin Schwidefsky committed Jan 26, 2008
1 parent 0332d7a commit a8879ef
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 23 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 9f4b0ba81f158df459fa2cfc98ab1475c090f29c
refs/heads/master: 3b4beb31759765efdda9f9431aebfedf828bbfe0
12 changes: 4 additions & 8 deletions trunk/arch/s390/lib/spinlock.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ static inline void _raw_yield_cpu(int cpu)
_raw_yield();
}

void _raw_spin_lock_wait(raw_spinlock_t *lp, unsigned int pc)
void _raw_spin_lock_wait(raw_spinlock_t *lp)
{
int count = spin_retry;
unsigned int cpu = ~smp_processor_id();
Expand All @@ -53,26 +53,22 @@ void _raw_spin_lock_wait(raw_spinlock_t *lp, unsigned int pc)
}
if (__raw_spin_is_locked(lp))
continue;
if (_raw_compare_and_swap(&lp->owner_cpu, 0, cpu) == 0) {
lp->owner_pc = pc;
if (_raw_compare_and_swap(&lp->owner_cpu, 0, cpu) == 0)
return;
}
}
}
EXPORT_SYMBOL(_raw_spin_lock_wait);

int _raw_spin_trylock_retry(raw_spinlock_t *lp, unsigned int pc)
int _raw_spin_trylock_retry(raw_spinlock_t *lp)
{
unsigned int cpu = ~smp_processor_id();
int count;

for (count = spin_retry; count > 0; count--) {
if (__raw_spin_is_locked(lp))
continue;
if (_raw_compare_and_swap(&lp->owner_cpu, 0, cpu) == 0) {
lp->owner_pc = pc;
if (_raw_compare_and_swap(&lp->owner_cpu, 0, cpu) == 0)
return 1;
}
}
return 0;
}
Expand Down
19 changes: 6 additions & 13 deletions trunk/include/asm-s390/spinlock.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,39 +58,32 @@ _raw_compare_and_swap(volatile unsigned int *lock,
do { while (__raw_spin_is_locked(lock)) \
_raw_spin_relax(lock); } while (0)

extern void _raw_spin_lock_wait(raw_spinlock_t *, unsigned int pc);
extern int _raw_spin_trylock_retry(raw_spinlock_t *, unsigned int pc);
extern void _raw_spin_lock_wait(raw_spinlock_t *);
extern int _raw_spin_trylock_retry(raw_spinlock_t *);
extern void _raw_spin_relax(raw_spinlock_t *lock);

static inline void __raw_spin_lock(raw_spinlock_t *lp)
{
unsigned long pc = 1 | (unsigned long) __builtin_return_address(0);
int old;

old = _raw_compare_and_swap(&lp->owner_cpu, 0, ~smp_processor_id());
if (likely(old == 0)) {
lp->owner_pc = pc;
if (likely(old == 0))
return;
}
_raw_spin_lock_wait(lp, pc);
_raw_spin_lock_wait(lp);
}

static inline int __raw_spin_trylock(raw_spinlock_t *lp)
{
unsigned long pc = 1 | (unsigned long) __builtin_return_address(0);
int old;

old = _raw_compare_and_swap(&lp->owner_cpu, 0, ~smp_processor_id());
if (likely(old == 0)) {
lp->owner_pc = pc;
if (likely(old == 0))
return 1;
}
return _raw_spin_trylock_retry(lp, pc);
return _raw_spin_trylock_retry(lp);
}

static inline void __raw_spin_unlock(raw_spinlock_t *lp)
{
lp->owner_pc = 0;
_raw_compare_and_swap(&lp->owner_cpu, lp->owner_cpu, 0);
}

Expand Down
1 change: 0 additions & 1 deletion trunk/include/asm-s390/spinlock_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

typedef struct {
volatile unsigned int owner_cpu;
volatile unsigned int owner_pc;
} __attribute__ ((aligned (4))) raw_spinlock_t;

#define __RAW_SPIN_LOCK_UNLOCKED { 0 }
Expand Down

0 comments on commit a8879ef

Please sign in to comment.