Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 77223
b: refs/heads/master
c: 894cdde
h: refs/heads/master
i:
  77221: aa4a181
  77219: 22f3db2
  77215: cb38b2a
v: v3
  • Loading branch information
Hisashi Hifumi authored and Martin Schwidefsky committed Jan 26, 2008
1 parent c36e1e3 commit 29b6709
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 2 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: dab5209cd878c146d9f6923f061d1c2725ff210f
refs/heads/master: 894cdde26b538c77b9943bc72f0570abf6e58e37
23 changes: 23 additions & 0 deletions trunk/arch/s390/lib/spinlock.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,29 @@ void _raw_spin_lock_wait(raw_spinlock_t *lp)
}
EXPORT_SYMBOL(_raw_spin_lock_wait);

void _raw_spin_lock_wait_flags(raw_spinlock_t *lp, unsigned long flags)
{
int count = spin_retry;
unsigned int cpu = ~smp_processor_id();

local_irq_restore(flags);
while (1) {
if (count-- <= 0) {
unsigned int owner = lp->owner_cpu;
if (owner != 0)
_raw_yield_cpu(~owner);
count = spin_retry;
}
if (__raw_spin_is_locked(lp))
continue;
local_irq_disable();
if (_raw_compare_and_swap(&lp->owner_cpu, 0, cpu) == 0)
return;
local_irq_restore(flags);
}
}
EXPORT_SYMBOL(_raw_spin_lock_wait_flags);

int _raw_spin_trylock_retry(raw_spinlock_t *lp)
{
unsigned int cpu = ~smp_processor_id();
Expand Down
13 changes: 12 additions & 1 deletion trunk/include/asm-s390/spinlock.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,12 @@ _raw_compare_and_swap(volatile unsigned int *lock,
*/

#define __raw_spin_is_locked(x) ((x)->owner_cpu != 0)
#define __raw_spin_lock_flags(lock, flags) __raw_spin_lock(lock)
#define __raw_spin_unlock_wait(lock) \
do { while (__raw_spin_is_locked(lock)) \
_raw_spin_relax(lock); } while (0)

extern void _raw_spin_lock_wait(raw_spinlock_t *);
extern void _raw_spin_lock_wait_flags(raw_spinlock_t *, unsigned long flags);
extern int _raw_spin_trylock_retry(raw_spinlock_t *);
extern void _raw_spin_relax(raw_spinlock_t *lock);

Expand All @@ -72,6 +72,17 @@ static inline void __raw_spin_lock(raw_spinlock_t *lp)
_raw_spin_lock_wait(lp);
}

static inline void __raw_spin_lock_flags(raw_spinlock_t *lp,
unsigned long flags)
{
int old;

old = _raw_compare_and_swap(&lp->owner_cpu, 0, ~smp_processor_id());
if (likely(old == 0))
return;
_raw_spin_lock_wait_flags(lp, flags);
}

static inline int __raw_spin_trylock(raw_spinlock_t *lp)
{
int old;
Expand Down

0 comments on commit 29b6709

Please sign in to comment.