Skip to content

Commit c1e2e03

Browse files
committed
Merge tag 'for-5.16/parisc-2' of git://git.kernel.org/pub/scm/linux/kernel/git/deller/parisc-linux
Pull more parisc architecture fixes and updates from Helge Deller: "One build error fix and two optimizations: - Fix build error by moving the CPU field back into thread_info struct (Ard Biesheuvel) - Do not enable IRQs unconditionally at start of interrupt handler if they were disabled before (Sven Schnelle) - Keep interrupts enabled during cmpxchg and futex operations (Dave Anglin)" * tag 'for-5.16/parisc-2' of git://git.kernel.org/pub/scm/linux/kernel/git/deller/parisc-linux: parisc: move CPU field back into thread_info parisc: Don't disable interrupts in cmpxchg and futex operations parisc: don't enable irqs unconditionally in handle_interruption()
2 parents 7e113d0 + 2a2e820 commit c1e2e03

7 files changed

Lines changed: 17 additions & 48 deletions

File tree

arch/parisc/include/asm/futex.h

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,35 +11,34 @@
1111
sixteen four-word locks. */
1212

1313
static inline void
14-
_futex_spin_lock_irqsave(u32 __user *uaddr, unsigned long int *flags)
14+
_futex_spin_lock(u32 __user *uaddr)
1515
{
1616
extern u32 lws_lock_start[];
1717
long index = ((long)uaddr & 0x3f8) >> 1;
1818
arch_spinlock_t *s = (arch_spinlock_t *)&lws_lock_start[index];
19-
local_irq_save(*flags);
19+
preempt_disable();
2020
arch_spin_lock(s);
2121
}
2222

2323
static inline void
24-
_futex_spin_unlock_irqrestore(u32 __user *uaddr, unsigned long int *flags)
24+
_futex_spin_unlock(u32 __user *uaddr)
2525
{
2626
extern u32 lws_lock_start[];
2727
long index = ((long)uaddr & 0x3f8) >> 1;
2828
arch_spinlock_t *s = (arch_spinlock_t *)&lws_lock_start[index];
2929
arch_spin_unlock(s);
30-
local_irq_restore(*flags);
30+
preempt_enable();
3131
}
3232

3333
static inline int
3434
arch_futex_atomic_op_inuser(int op, int oparg, int *oval, u32 __user *uaddr)
3535
{
36-
unsigned long int flags;
3736
int oldval, ret;
3837
u32 tmp;
3938

40-
_futex_spin_lock_irqsave(uaddr, &flags);
41-
4239
ret = -EFAULT;
40+
41+
_futex_spin_lock(uaddr);
4342
if (unlikely(get_user(oldval, uaddr) != 0))
4443
goto out_pagefault_enable;
4544

@@ -70,7 +69,7 @@ arch_futex_atomic_op_inuser(int op, int oparg, int *oval, u32 __user *uaddr)
7069
ret = -EFAULT;
7170

7271
out_pagefault_enable:
73-
_futex_spin_unlock_irqrestore(uaddr, &flags);
72+
_futex_spin_unlock(uaddr);
7473

7574
if (!ret)
7675
*oval = oldval;
@@ -83,7 +82,6 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
8382
u32 oldval, u32 newval)
8483
{
8584
u32 val;
86-
unsigned long flags;
8785

8886
/* futex.c wants to do a cmpxchg_inatomic on kernel NULL, which is
8987
* our gateway page, and causes no end of trouble...
@@ -100,19 +98,19 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
10098
* address. This should scale to a couple of CPUs.
10199
*/
102100

103-
_futex_spin_lock_irqsave(uaddr, &flags);
101+
_futex_spin_lock(uaddr);
104102
if (unlikely(get_user(val, uaddr) != 0)) {
105-
_futex_spin_unlock_irqrestore(uaddr, &flags);
103+
_futex_spin_unlock(uaddr);
106104
return -EFAULT;
107105
}
108106

109107
if (val == oldval && unlikely(put_user(newval, uaddr) != 0)) {
110-
_futex_spin_unlock_irqrestore(uaddr, &flags);
108+
_futex_spin_unlock(uaddr);
111109
return -EFAULT;
112110
}
113111

114112
*uval = val;
115-
_futex_spin_unlock_irqrestore(uaddr, &flags);
113+
_futex_spin_unlock(uaddr);
116114

117115
return 0;
118116
}

arch/parisc/include/asm/smp.h

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -32,25 +32,10 @@ extern void smp_send_all_nop(void);
3232
extern void arch_send_call_function_single_ipi(int cpu);
3333
extern void arch_send_call_function_ipi_mask(const struct cpumask *mask);
3434

35+
#define raw_smp_processor_id() (current_thread_info()->cpu)
36+
3537
#endif /* !ASSEMBLY */
3638

37-
/*
38-
* This is particularly ugly: it appears we can't actually get the definition
39-
* of task_struct here, but we need access to the CPU this task is running on.
40-
* Instead of using task_struct we're using TASK_CPU which is extracted from
41-
* asm-offsets.h by kbuild to get the current processor ID.
42-
*
43-
* This also needs to be safeguarded when building asm-offsets.s because at
44-
* that time TASK_CPU is not defined yet. It could have been guarded by
45-
* TASK_CPU itself, but we want the build to fail if TASK_CPU is missing
46-
* when building something else than asm-offsets.s
47-
*/
48-
#ifdef GENERATING_ASM_OFFSETS
49-
#define raw_smp_processor_id() (0)
50-
#else
51-
#include <asm/asm-offsets.h>
52-
#define raw_smp_processor_id() (*(unsigned int *)((void *)current + TASK_CPU))
53-
#endif
5439
#else /* CONFIG_SMP */
5540

5641
static inline void smp_send_all_nop(void) { return; }

arch/parisc/include/asm/thread_info.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
struct thread_info {
1010
unsigned long flags; /* thread_info flags (see TIF_*) */
1111
int preempt_count; /* 0=premptable, <0=BUG; will also serve as bh-counter */
12+
#ifdef CONFIG_SMP
13+
unsigned int cpu;
14+
#endif
1215
};
1316

1417
#define INIT_THREAD_INFO(tsk) \

arch/parisc/kernel/asm-offsets.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414
* Copyright (C) 2003 James Bottomley <jejb at parisc-linux.org>
1515
*/
1616

17-
#define GENERATING_ASM_OFFSETS /* asm/smp.h */
18-
1917
#include <linux/types.h>
2018
#include <linux/sched.h>
2119
#include <linux/thread_info.h>
@@ -39,9 +37,6 @@ int main(void)
3937
{
4038
DEFINE(TASK_TI_FLAGS, offsetof(struct task_struct, thread_info.flags));
4139
DEFINE(TASK_STACK, offsetof(struct task_struct, stack));
42-
#ifdef CONFIG_SMP
43-
DEFINE(TASK_CPU, offsetof(struct task_struct, cpu));
44-
#endif
4540
BLANK();
4641
DEFINE(TASK_REGS, offsetof(struct task_struct, thread.regs));
4742
DEFINE(TASK_PT_PSW, offsetof(struct task_struct, thread.regs.gr[ 0]));

arch/parisc/kernel/smp.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -339,8 +339,6 @@ int smp_boot_one_cpu(int cpuid, struct task_struct *idle)
339339
const struct cpuinfo_parisc *p = &per_cpu(cpu_data, cpuid);
340340
long timeout;
341341

342-
idle->cpu = cpuid;
343-
344342
/* Let _start know what logical CPU we're booting
345343
** (offset into init_tasks[],cpu_data[])
346344
*/

arch/parisc/kernel/syscall.S

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -597,13 +597,11 @@ cas_nocontend:
597597
# endif
598598
/* ENABLE_LWS_DEBUG */
599599

600-
rsm PSW_SM_I, %r0 /* Disable interrupts */
601600
/* COW breaks can cause contention on UP systems */
602601
LDCW 0(%sr2,%r20), %r28 /* Try to acquire the lock */
603602
cmpb,<>,n %r0, %r28, cas_action /* Did we get it? */
604603
cas_wouldblock:
605604
ldo 2(%r0), %r28 /* 2nd case */
606-
ssm PSW_SM_I, %r0
607605
b lws_exit /* Contended... */
608606
ldo -EAGAIN(%r0), %r21 /* Spin in userspace */
609607

@@ -639,8 +637,6 @@ cas_action:
639637
/* Clear thread register indicator */
640638
stw %r0, 4(%sr2,%r20)
641639
#endif
642-
/* Enable interrupts */
643-
ssm PSW_SM_I, %r0
644640
/* Return to userspace, set no error */
645641
b lws_exit
646642
copy %r0, %r21
@@ -652,7 +648,6 @@ cas_action:
652648
#if ENABLE_LWS_DEBUG
653649
stw %r0, 4(%sr2,%r20)
654650
#endif
655-
ssm PSW_SM_I, %r0
656651
b lws_exit
657652
ldo -EFAULT(%r0),%r21 /* set errno */
658653
nop
@@ -764,13 +759,11 @@ cas2_lock_start:
764759
shlw %r20, 4, %r20
765760
add %r20, %r28, %r20
766761

767-
rsm PSW_SM_I, %r0 /* Disable interrupts */
768762
/* COW breaks can cause contention on UP systems */
769763
LDCW 0(%sr2,%r20), %r28 /* Try to acquire the lock */
770764
cmpb,<>,n %r0, %r28, cas2_action /* Did we get it? */
771765
cas2_wouldblock:
772766
ldo 2(%r0), %r28 /* 2nd case */
773-
ssm PSW_SM_I, %r0
774767
b lws_exit /* Contended... */
775768
ldo -EAGAIN(%r0), %r21 /* Spin in userspace */
776769

@@ -850,8 +843,6 @@ cas2_action:
850843
cas2_end:
851844
/* Free lock */
852845
stw,ma %r20, 0(%sr2,%r20)
853-
/* Enable interrupts */
854-
ssm PSW_SM_I, %r0
855846
/* Return to userspace, set no error */
856847
b lws_exit
857848
copy %r0, %r21
@@ -860,7 +851,6 @@ cas2_end:
860851
/* Error occurred on load or store */
861852
/* Free lock */
862853
stw,ma %r20, 0(%sr2,%r20)
863-
ssm PSW_SM_I, %r0
864854
ldo 1(%r0),%r28
865855
b lws_exit
866856
ldo -EFAULT(%r0),%r21 /* set errno */

arch/parisc/kernel/traps.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,7 @@ void notrace handle_interruption(int code, struct pt_regs *regs)
481481

482482
if (code == 1)
483483
pdc_console_restart(); /* switch back to pdc if HPMC */
484-
else
484+
else if (!irqs_disabled_flags(regs->gr[0]))
485485
local_irq_enable();
486486

487487
/* Security check:

0 commit comments

Comments
 (0)