Commit f173e3a7 authored by John David Anglin's avatar John David Anglin Committed by Helge Deller

parisc: Improve spinlock handling

Use READ_ONCE() to check if spinlock is locked.
The other changes are cleanups.
Signed-off-by: default avatarJohn David Anglin <dave.anglin@bell.net>
Signed-off-by: default avatarHelge Deller <deller@gmx.de>
parent b47cf497
...@@ -10,13 +10,21 @@ ...@@ -10,13 +10,21 @@
static inline int arch_spin_is_locked(arch_spinlock_t *x) static inline int arch_spin_is_locked(arch_spinlock_t *x)
{ {
volatile unsigned int *a = __ldcw_align(x); volatile unsigned int *a = __ldcw_align(x);
return *a == 0; return READ_ONCE(*a) == 0;
} }
#define arch_spin_lock(lock) arch_spin_lock_flags(lock, 0) static inline void arch_spin_lock(arch_spinlock_t *x)
{
volatile unsigned int *a;
a = __ldcw_align(x);
while (__ldcw(a) == 0)
while (*a == 0)
continue;
}
static inline void arch_spin_lock_flags(arch_spinlock_t *x, static inline void arch_spin_lock_flags(arch_spinlock_t *x,
unsigned long flags) unsigned long flags)
{ {
volatile unsigned int *a; volatile unsigned int *a;
...@@ -25,10 +33,8 @@ static inline void arch_spin_lock_flags(arch_spinlock_t *x, ...@@ -25,10 +33,8 @@ static inline void arch_spin_lock_flags(arch_spinlock_t *x,
while (*a == 0) while (*a == 0)
if (flags & PSW_SM_I) { if (flags & PSW_SM_I) {
local_irq_enable(); local_irq_enable();
cpu_relax();
local_irq_disable(); local_irq_disable();
} else }
cpu_relax();
} }
#define arch_spin_lock_flags arch_spin_lock_flags #define arch_spin_lock_flags arch_spin_lock_flags
...@@ -44,12 +50,9 @@ static inline void arch_spin_unlock(arch_spinlock_t *x) ...@@ -44,12 +50,9 @@ static inline void arch_spin_unlock(arch_spinlock_t *x)
static inline int arch_spin_trylock(arch_spinlock_t *x) static inline int arch_spin_trylock(arch_spinlock_t *x)
{ {
volatile unsigned int *a; volatile unsigned int *a;
int ret;
a = __ldcw_align(x); a = __ldcw_align(x);
ret = __ldcw(a) != 0; return __ldcw(a) != 0;
return ret;
} }
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment