Skip to content

Commit 2772f0e

Browse files
committed
parisc: Improve interrupt handling in arch_spin_lock_flags()
Rewrite arch_spin_lock() and arch_spin_lock_flags() to not re-enable and disable the PSW_SM_I interrupt flag too often. Signed-off-by: Helge Deller <[email protected]>
1 parent 997ba65 commit 2772f0e

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

arch/parisc/include/asm/spinlock.h

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,34 @@
1010
static inline int arch_spin_is_locked(arch_spinlock_t *x)
1111
{
1212
volatile unsigned int *a = __ldcw_align(x);
13+
smp_mb();
1314
return *a == 0;
1415
}
1516

16-
#define arch_spin_lock(lock) arch_spin_lock_flags(lock, 0)
17+
static inline void arch_spin_lock(arch_spinlock_t *x)
18+
{
19+
volatile unsigned int *a;
20+
21+
a = __ldcw_align(x);
22+
while (__ldcw(a) == 0)
23+
while (*a == 0)
24+
cpu_relax();
25+
}
1726

1827
static inline void arch_spin_lock_flags(arch_spinlock_t *x,
1928
unsigned long flags)
2029
{
2130
volatile unsigned int *a;
31+
unsigned long flags_dis;
2232

2333
a = __ldcw_align(x);
24-
while (__ldcw(a) == 0)
34+
while (__ldcw(a) == 0) {
35+
local_save_flags(flags_dis);
36+
local_irq_restore(flags);
2537
while (*a == 0)
26-
if (flags & PSW_SM_I) {
27-
local_irq_enable();
28-
cpu_relax();
29-
local_irq_disable();
30-
} else
31-
cpu_relax();
38+
cpu_relax();
39+
local_irq_restore(flags_dis);
40+
}
3241
}
3342
#define arch_spin_lock_flags arch_spin_lock_flags
3443

0 commit comments

Comments
 (0)