powerpc/64: Add #defines for paca->soft_enabled flags

Two #defines IRQS_ENABLED and IRQS_DISABLED are added to be used when
updating paca->soft_enabled. Replace the hardcoded values used when
updating paca->soft_enabled with IRQ_(EN|DIS)ABLED #define. No logic
change.

Reviewed-by: Nicholas Piggin <npiggin@gmail.com>
Signed-off-by: Madhavan Srinivasan <maddy@linux.vnet.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
This commit is contained in:
Madhavan Srinivasan 2017-12-20 09:25:42 +05:30 committed by Michael Ellerman
parent a8a4b03ab9
commit c2e480ba82
15 changed files with 50 additions and 35 deletions

View File

@ -499,7 +499,7 @@ END_FTR_SECTION_NESTED(ftr,ftr,943)
#define __SOFTEN_TEST(h, vec) \ #define __SOFTEN_TEST(h, vec) \
lbz r10,PACASOFTIRQEN(r13); \ lbz r10,PACASOFTIRQEN(r13); \
cmpwi r10,0; \ cmpwi r10,IRQS_DISABLED; \
li r10,SOFTEN_VALUE_##vec; \ li r10,SOFTEN_VALUE_##vec; \
beq masked_##h##interrupt beq masked_##h##interrupt

View File

@ -28,6 +28,12 @@
#define PACA_IRQ_EE_EDGE 0x10 /* BookE only */ #define PACA_IRQ_EE_EDGE 0x10 /* BookE only */
#define PACA_IRQ_HMI 0x20 #define PACA_IRQ_HMI 0x20
/*
* flags for paca->soft_enabled
*/
#define IRQS_ENABLED 1
#define IRQS_DISABLED 0
#endif /* CONFIG_PPC64 */ #endif /* CONFIG_PPC64 */
#ifndef __ASSEMBLY__ #ifndef __ASSEMBLY__
@ -60,9 +66,10 @@ static inline unsigned long arch_local_irq_disable(void)
unsigned long flags, zero; unsigned long flags, zero;
asm volatile( asm volatile(
"li %1,0; lbz %0,%2(13); stb %1,%2(13)" "li %1,%3; lbz %0,%2(13); stb %1,%2(13)"
: "=r" (flags), "=&r" (zero) : "=r" (flags), "=&r" (zero)
: "i" (offsetof(struct paca_struct, soft_enabled)) : "i" (offsetof(struct paca_struct, soft_enabled)),\
"i" (IRQS_DISABLED)
: "memory"); : "memory");
return flags; return flags;
@ -72,7 +79,7 @@ extern void arch_local_irq_restore(unsigned long);
static inline void arch_local_irq_enable(void) static inline void arch_local_irq_enable(void)
{ {
arch_local_irq_restore(1); arch_local_irq_restore(IRQS_ENABLED);
} }
static inline unsigned long arch_local_irq_save(void) static inline unsigned long arch_local_irq_save(void)
@ -82,7 +89,7 @@ static inline unsigned long arch_local_irq_save(void)
static inline bool arch_irqs_disabled_flags(unsigned long flags) static inline bool arch_irqs_disabled_flags(unsigned long flags)
{ {
return flags == 0; return flags == IRQS_DISABLED;
} }
static inline bool arch_irqs_disabled(void) static inline bool arch_irqs_disabled(void)
@ -102,9 +109,9 @@ static inline bool arch_irqs_disabled(void)
u8 _was_enabled; \ u8 _was_enabled; \
__hard_irq_disable(); \ __hard_irq_disable(); \
_was_enabled = local_paca->soft_enabled; \ _was_enabled = local_paca->soft_enabled; \
local_paca->soft_enabled = 0; \ local_paca->soft_enabled = IRQS_DISABLED;\
local_paca->irq_happened |= PACA_IRQ_HARD_DIS; \ local_paca->irq_happened |= PACA_IRQ_HARD_DIS; \
if (_was_enabled) \ if (_was_enabled == IRQS_ENABLED) \
trace_hardirqs_off(); \ trace_hardirqs_off(); \
} while(0) } while(0)
@ -127,7 +134,7 @@ static inline void may_hard_irq_enable(void)
static inline bool arch_irq_disabled_regs(struct pt_regs *regs) static inline bool arch_irq_disabled_regs(struct pt_regs *regs)
{ {
return !regs->softe; return (regs->softe == IRQS_DISABLED);
} }
extern bool prep_irq_for_idle(void); extern bool prep_irq_for_idle(void);

View File

@ -49,8 +49,8 @@
#define RECONCILE_IRQ_STATE(__rA, __rB) \ #define RECONCILE_IRQ_STATE(__rA, __rB) \
lbz __rA,PACASOFTIRQEN(r13); \ lbz __rA,PACASOFTIRQEN(r13); \
lbz __rB,PACAIRQHAPPENED(r13); \ lbz __rB,PACAIRQHAPPENED(r13); \
cmpwi cr0,__rA,0; \ cmpwi cr0,__rA,IRQS_DISABLED;\
li __rA,0; \ li __rA,IRQS_DISABLED; \
ori __rB,__rB,PACA_IRQ_HARD_DIS; \ ori __rB,__rB,PACA_IRQ_HARD_DIS; \
stb __rB,PACAIRQHAPPENED(r13); \ stb __rB,PACAIRQHAPPENED(r13); \
beq 44f; \ beq 44f; \
@ -64,7 +64,7 @@
#define RECONCILE_IRQ_STATE(__rA, __rB) \ #define RECONCILE_IRQ_STATE(__rA, __rB) \
lbz __rA,PACAIRQHAPPENED(r13); \ lbz __rA,PACAIRQHAPPENED(r13); \
li __rB,0; \ li __rB,IRQS_DISABLED; \
ori __rA,__rA,PACA_IRQ_HARD_DIS; \ ori __rA,__rA,PACA_IRQ_HARD_DIS; \
stb __rB,PACASOFTIRQEN(r13); \ stb __rB,PACASOFTIRQEN(r13); \
stb __rA,PACAIRQHAPPENED(r13) stb __rA,PACAIRQHAPPENED(r13)

View File

@ -873,7 +873,7 @@ static inline void kvmppc_fix_ee_before_entry(void)
/* Only need to enable IRQs by hard enabling them after this */ /* Only need to enable IRQs by hard enabling them after this */
local_paca->irq_happened = 0; local_paca->irq_happened = 0;
local_paca->soft_enabled = 1; local_paca->soft_enabled = IRQS_ENABLED;
#endif #endif
} }

View File

@ -130,7 +130,7 @@ END_FW_FTR_SECTION_IFSET(FW_FEATURE_SPLPAR)
*/ */
#if defined(CONFIG_TRACE_IRQFLAGS) && defined(CONFIG_BUG) #if defined(CONFIG_TRACE_IRQFLAGS) && defined(CONFIG_BUG)
lbz r10,PACASOFTIRQEN(r13) lbz r10,PACASOFTIRQEN(r13)
xori r10,r10,1 xori r10,r10,IRQS_ENABLED
1: tdnei r10,0 1: tdnei r10,0
EMIT_BUG_ENTRY 1b,__FILE__,__LINE__,BUGFLAG_WARNING EMIT_BUG_ENTRY 1b,__FILE__,__LINE__,BUGFLAG_WARNING
#endif #endif
@ -147,7 +147,7 @@ system_call: /* label this so stack traces look sane */
/* We do need to set SOFTE in the stack frame or the return /* We do need to set SOFTE in the stack frame or the return
* from interrupt will be painful * from interrupt will be painful
*/ */
li r10,1 li r10,IRQS_ENABLED
std r10,SOFTE(r1) std r10,SOFTE(r1)
CURRENT_THREAD_INFO(r11, r1) CURRENT_THREAD_INFO(r11, r1)
@ -743,7 +743,7 @@ resume_kernel:
lwz r8,TI_PREEMPT(r9) lwz r8,TI_PREEMPT(r9)
cmpwi cr1,r8,0 cmpwi cr1,r8,0
ld r0,SOFTE(r1) ld r0,SOFTE(r1)
cmpdi r0,0 cmpdi r0,IRQS_DISABLED
crandc eq,cr1*4+eq,eq crandc eq,cr1*4+eq,eq
bne restore bne restore
@ -783,11 +783,11 @@ restore:
*/ */
ld r5,SOFTE(r1) ld r5,SOFTE(r1)
lbz r6,PACASOFTIRQEN(r13) lbz r6,PACASOFTIRQEN(r13)
cmpwi cr0,r5,0 cmpwi cr0,r5,IRQS_DISABLED
beq .Lrestore_irq_off beq .Lrestore_irq_off
/* We are enabling, were we already enabled ? Yes, just return */ /* We are enabling, were we already enabled ? Yes, just return */
cmpwi cr0,r6,1 cmpwi cr0,r6,IRQS_ENABLED
beq cr0,.Ldo_restore beq cr0,.Ldo_restore
/* /*
@ -806,7 +806,7 @@ restore:
*/ */
.Lrestore_no_replay: .Lrestore_no_replay:
TRACE_ENABLE_INTS TRACE_ENABLE_INTS
li r0,1 li r0,IRQS_ENABLED
stb r0,PACASOFTIRQEN(r13); stb r0,PACASOFTIRQEN(r13);
/* /*
@ -915,7 +915,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_HAS_PPR)
#if defined(CONFIG_TRACE_IRQFLAGS) && defined(CONFIG_BUG) #if defined(CONFIG_TRACE_IRQFLAGS) && defined(CONFIG_BUG)
/* The interrupt should not have soft enabled. */ /* The interrupt should not have soft enabled. */
lbz r7,PACASOFTIRQEN(r13) lbz r7,PACASOFTIRQEN(r13)
1: tdnei r7,0 1: tdnei r7,IRQS_DISABLED
EMIT_BUG_ENTRY 1b,__FILE__,__LINE__,BUGFLAG_WARNING EMIT_BUG_ENTRY 1b,__FILE__,__LINE__,BUGFLAG_WARNING
#endif #endif
b .Ldo_restore b .Ldo_restore
@ -1036,7 +1036,7 @@ _GLOBAL(enter_rtas)
* check it with the asm equivalent of WARN_ON * check it with the asm equivalent of WARN_ON
*/ */
lbz r0,PACASOFTIRQEN(r13) lbz r0,PACASOFTIRQEN(r13)
1: tdnei r0,0 1: tdnei r0,IRQS_DISABLED
EMIT_BUG_ENTRY 1b,__FILE__,__LINE__,BUGFLAG_WARNING EMIT_BUG_ENTRY 1b,__FILE__,__LINE__,BUGFLAG_WARNING
#endif #endif

View File

@ -210,9 +210,9 @@ END_FTR_SECTION_IFSET(CPU_FTR_EMB_HV)
ld r5,SOFTE(r1) ld r5,SOFTE(r1)
/* Interrupts had better not already be enabled... */ /* Interrupts had better not already be enabled... */
twnei r6,0 twnei r6,IRQS_DISABLED
cmpwi cr0,r5,0 cmpwi cr0,r5,IRQS_DISABLED
beq 1f beq 1f
TRACE_ENABLE_INTS TRACE_ENABLE_INTS
@ -352,7 +352,7 @@ ret_from_mc_except:
#define PROLOG_ADDITION_MASKABLE_GEN(n) \ #define PROLOG_ADDITION_MASKABLE_GEN(n) \
lbz r10,PACASOFTIRQEN(r13); /* are irqs soft-disabled ? */ \ lbz r10,PACASOFTIRQEN(r13); /* are irqs soft-disabled ? */ \
cmpwi cr0,r10,0; /* yes -> go out of line */ \ cmpwi cr0,r10,IRQS_DISABLED; /* yes -> go out of line */ \
beq masked_interrupt_book3e_##n beq masked_interrupt_book3e_##n
#define PROLOG_ADDITION_2REGS_GEN(n) \ #define PROLOG_ADDITION_2REGS_GEN(n) \

View File

@ -765,7 +765,7 @@ _GLOBAL(pmac_secondary_start)
/* Mark interrupts soft and hard disabled (they might be enabled /* Mark interrupts soft and hard disabled (they might be enabled
* in the PACA when doing hotplug) * in the PACA when doing hotplug)
*/ */
li r0,0 li r0,IRQS_DISABLED
stb r0,PACASOFTIRQEN(r13) stb r0,PACASOFTIRQEN(r13)
li r0,PACA_IRQ_HARD_DIS li r0,PACA_IRQ_HARD_DIS
stb r0,PACAIRQHAPPENED(r13) stb r0,PACAIRQHAPPENED(r13)
@ -822,6 +822,7 @@ __secondary_start:
/* Mark interrupts soft and hard disabled (they might be enabled /* Mark interrupts soft and hard disabled (they might be enabled
* in the PACA when doing hotplug) * in the PACA when doing hotplug)
*/ */
li r7,IRQS_DISABLED
stb r7,PACASOFTIRQEN(r13) stb r7,PACASOFTIRQEN(r13)
li r0,PACA_IRQ_HARD_DIS li r0,PACA_IRQ_HARD_DIS
stb r0,PACAIRQHAPPENED(r13) stb r0,PACAIRQHAPPENED(r13)
@ -988,7 +989,7 @@ start_here_common:
/* Mark interrupts soft and hard disabled (they might be enabled /* Mark interrupts soft and hard disabled (they might be enabled
* in the PACA when doing hotplug) * in the PACA when doing hotplug)
*/ */
li r0,0 li r0,IRQS_DISABLED
stb r0,PACASOFTIRQEN(r13) stb r0,PACASOFTIRQEN(r13)
li r0,PACA_IRQ_HARD_DIS li r0,PACA_IRQ_HARD_DIS
stb r0,PACAIRQHAPPENED(r13) stb r0,PACAIRQHAPPENED(r13)

View File

@ -17,6 +17,7 @@
#include <asm/processor.h> #include <asm/processor.h>
#include <asm/thread_info.h> #include <asm/thread_info.h>
#include <asm/epapr_hcalls.h> #include <asm/epapr_hcalls.h>
#include <asm/hw_irq.h>
/* 64-bit version only for now */ /* 64-bit version only for now */
#ifdef CONFIG_PPC64 #ifdef CONFIG_PPC64
@ -46,7 +47,7 @@ _GLOBAL(\name)
bl trace_hardirqs_on bl trace_hardirqs_on
addi r1,r1,128 addi r1,r1,128
#endif #endif
li r0,1 li r0,IRQS_ENABLED
stb r0,PACASOFTIRQEN(r13) stb r0,PACASOFTIRQEN(r13)
/* Interrupts will make use return to LR, so get something we want /* Interrupts will make use return to LR, so get something we want

View File

@ -15,6 +15,7 @@
#include <asm/ppc_asm.h> #include <asm/ppc_asm.h>
#include <asm/asm-offsets.h> #include <asm/asm-offsets.h>
#include <asm/irqflags.h> #include <asm/irqflags.h>
#include <asm/hw_irq.h>
#undef DEBUG #undef DEBUG
@ -53,7 +54,7 @@ END_FTR_SECTION_IFCLR(CPU_FTR_CAN_NAP)
mfmsr r7 mfmsr r7
#endif /* CONFIG_TRACE_IRQFLAGS */ #endif /* CONFIG_TRACE_IRQFLAGS */
li r0,1 li r0,IRQS_ENABLED
stb r0,PACASOFTIRQEN(r13) /* we'll hard-enable shortly */ stb r0,PACASOFTIRQEN(r13) /* we'll hard-enable shortly */
BEGIN_FTR_SECTION BEGIN_FTR_SECTION
DSSALL DSSALL

View File

@ -67,6 +67,7 @@
#include <asm/smp.h> #include <asm/smp.h>
#include <asm/livepatch.h> #include <asm/livepatch.h>
#include <asm/asm-prototypes.h> #include <asm/asm-prototypes.h>
#include <asm/hw_irq.h>
#ifdef CONFIG_PPC64 #ifdef CONFIG_PPC64
#include <asm/paca.h> #include <asm/paca.h>
@ -231,7 +232,7 @@ notrace void arch_local_irq_restore(unsigned long en)
/* Write the new soft-enabled value */ /* Write the new soft-enabled value */
set_soft_enabled(en); set_soft_enabled(en);
if (!en) if (en == IRQS_DISABLED)
return; return;
/* /*
* From this point onward, we can take interrupts, preempt, * From this point onward, we can take interrupts, preempt,
@ -276,7 +277,7 @@ notrace void arch_local_irq_restore(unsigned long en)
} }
#endif /* CONFIG_TRACE_IRQFLAGS */ #endif /* CONFIG_TRACE_IRQFLAGS */
set_soft_enabled(0); set_soft_enabled(IRQS_DISABLED);
trace_hardirqs_off(); trace_hardirqs_off();
/* /*
@ -288,7 +289,7 @@ notrace void arch_local_irq_restore(unsigned long en)
/* We can soft-enable now */ /* We can soft-enable now */
trace_hardirqs_on(); trace_hardirqs_on();
set_soft_enabled(1); set_soft_enabled(IRQS_ENABLED);
/* /*
* And replay if we have to. This will return with interrupts * And replay if we have to. This will return with interrupts
@ -363,7 +364,7 @@ bool prep_irq_for_idle(void)
* of entering the low power state. * of entering the low power state.
*/ */
local_paca->irq_happened &= ~PACA_IRQ_HARD_DIS; local_paca->irq_happened &= ~PACA_IRQ_HARD_DIS;
local_paca->soft_enabled = 1; local_paca->soft_enabled = IRQS_ENABLED;
/* Tell the caller to enter the low power state */ /* Tell the caller to enter the low power state */
return true; return true;

View File

@ -57,6 +57,7 @@
#include <asm/debug.h> #include <asm/debug.h>
#ifdef CONFIG_PPC64 #ifdef CONFIG_PPC64
#include <asm/firmware.h> #include <asm/firmware.h>
#include <asm/hw_irq.h>
#endif #endif
#include <asm/code-patching.h> #include <asm/code-patching.h>
#include <asm/exec.h> #include <asm/exec.h>
@ -1674,7 +1675,7 @@ int copy_thread(unsigned long clone_flags, unsigned long usp,
childregs->gpr[14] = ppc_function_entry((void *)usp); childregs->gpr[14] = ppc_function_entry((void *)usp);
#ifdef CONFIG_PPC64 #ifdef CONFIG_PPC64
clear_tsk_thread_flag(p, TIF_32BIT); clear_tsk_thread_flag(p, TIF_32BIT);
childregs->softe = 1; childregs->softe = IRQS_ENABLED;
#endif #endif
childregs->gpr[15] = kthread_arg; childregs->gpr[15] = kthread_arg;
p->thread.regs = NULL; /* no user register state */ p->thread.regs = NULL; /* no user register state */

View File

@ -66,6 +66,7 @@
#include <asm/livepatch.h> #include <asm/livepatch.h>
#include <asm/opal.h> #include <asm/opal.h>
#include <asm/cputhreads.h> #include <asm/cputhreads.h>
#include <asm/hw_irq.h>
#include "setup.h" #include "setup.h"
@ -187,6 +188,8 @@ static void __init fixup_boot_paca(void)
get_paca()->cpu_start = 1; get_paca()->cpu_start = 1;
/* Allow percpu accesses to work until we setup percpu data */ /* Allow percpu accesses to work until we setup percpu data */
get_paca()->data_offset = 0; get_paca()->data_offset = 0;
/* Mark interrupts disabled in PACA */
get_paca()->soft_enabled = IRQS_DISABLED;
} }
static void __init configure_exceptions(void) static void __init configure_exceptions(void)

View File

@ -253,7 +253,7 @@ void accumulate_stolen_time(void)
* needs to reflect that so various debug stuff doesn't * needs to reflect that so various debug stuff doesn't
* complain * complain
*/ */
local_paca->soft_enabled = 0; local_paca->soft_enabled = IRQS_DISABLED;
sst = scan_dispatch_log(acct->starttime_user); sst = scan_dispatch_log(acct->starttime_user);
ust = scan_dispatch_log(acct->starttime); ust = scan_dispatch_log(acct->starttime);

View File

@ -752,7 +752,7 @@ void flush_dcache_icache_hugepage(struct page *page)
* So long as we atomically load page table pointers we are safe against teardown, * So long as we atomically load page table pointers we are safe against teardown,
* we can follow the address down to the the page and take a ref on it. * we can follow the address down to the the page and take a ref on it.
* This function need to be called with interrupts disabled. We use this variant * This function need to be called with interrupts disabled. We use this variant
* when we have MSR[EE] = 0 but the paca->soft_enabled = 1 * when we have MSR[EE] = 0 but the paca->soft_enabled = IRQS_ENABLED
*/ */
pte_t *__find_linux_pte(pgd_t *pgdir, unsigned long ea, pte_t *__find_linux_pte(pgd_t *pgdir, unsigned long ea,
bool *is_thp, unsigned *hpage_shift) bool *is_thp, unsigned *hpage_shift)

View File

@ -322,7 +322,7 @@ static inline void perf_read_regs(struct pt_regs *regs)
*/ */
static inline int perf_intr_is_nmi(struct pt_regs *regs) static inline int perf_intr_is_nmi(struct pt_regs *regs)
{ {
return !regs->softe; return (regs->softe == IRQS_DISABLED);
} }
/* /*