Path: blob/master/arch/arc/include/asm/irqflags-compact.h
26481 views
/* SPDX-License-Identifier: GPL-2.0-only */1/*2* Copyright (C) 2014-15 Synopsys, Inc. (www.synopsys.com)3* Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)4*/56#ifndef __ASM_IRQFLAGS_ARCOMPACT_H7#define __ASM_IRQFLAGS_ARCOMPACT_H89/* vineetg: March 2010 : local_irq_save( ) optimisation10* -Remove explicit mov of current status32 into reg, that is not needed11* -Use BIC insn instead of INVERTED + AND12* -Conditionally disable interrupts (if they are not enabled, don't disable)13*/1415#include <asm/arcregs.h>1617/* status32 Reg bits related to Interrupt Handling */18#define STATUS_E1_BIT 1 /* Int 1 enable */19#define STATUS_E2_BIT 2 /* Int 2 enable */20#define STATUS_A1_BIT 3 /* Int 1 active */21#define STATUS_A2_BIT 4 /* Int 2 active */22#define STATUS_AE_BIT 5 /* Exception active */2324#define STATUS_E1_MASK (1<<STATUS_E1_BIT)25#define STATUS_E2_MASK (1<<STATUS_E2_BIT)26#define STATUS_A1_MASK (1<<STATUS_A1_BIT)27#define STATUS_A2_MASK (1<<STATUS_A2_BIT)28#define STATUS_AE_MASK (1<<STATUS_AE_BIT)29#define STATUS_IE_MASK (STATUS_E1_MASK | STATUS_E2_MASK)3031/* Other Interrupt Handling related Aux regs */32#define AUX_IRQ_LEV 0x200 /* IRQ Priority: L1 or L2 */33#define AUX_IRQ_HINT 0x201 /* For generating Soft Interrupts */34#define AUX_IRQ_LV12 0x43 /* interrupt level register */3536#define AUX_IENABLE 0x40c37#define AUX_ITRIGGER 0x40d38#define AUX_IPULSE 0x4153940#define ISA_INIT_STATUS_BITS STATUS_IE_MASK4142#ifndef __ASSEMBLER__4344/******************************************************************45* IRQ Control Macros46*47* All of them have "memory" clobber (compiler barrier) which is needed to48* ensure that LD/ST requiring irq safety (R-M-W when LLSC is not available)49* are redone after IRQs are re-enabled (and gcc doesn't reuse stale register)50*51* Noted at the time of Abilis Timer List corruption52*53* Orig Bug + Rejected solution:54* https://lore.kernel.org/lkml/[email protected]55*56* Reasoning:57* https://lore.kernel.org/lkml/CA+55aFyFWjpSVQM6M266tKrG_ZXJzZ-nYejpmXYQXbrr42mGPQ@mail.gmail.com58*59******************************************************************/6061/*62* Save IRQ state and disable IRQs63*/64static inline long arch_local_irq_save(void)65{66unsigned long temp, flags;6768__asm__ __volatile__(69" lr %1, [status32] \n"70" bic %0, %1, %2 \n"71" and.f 0, %1, %2 \n"72" flag.nz %0 \n"73: "=r"(temp), "=r"(flags)74: "n"((STATUS_E1_MASK | STATUS_E2_MASK))75: "memory", "cc");7677return flags;78}7980/*81* restore saved IRQ state82*/83static inline void arch_local_irq_restore(unsigned long flags)84{8586__asm__ __volatile__(87" flag %0 \n"88:89: "r"(flags)90: "memory");91}9293/*94* Unconditionally Enable IRQs95*/96#ifdef CONFIG_ARC_COMPACT_IRQ_LEVELS97extern void arch_local_irq_enable(void);98#else99static inline void arch_local_irq_enable(void)100{101unsigned long temp;102103__asm__ __volatile__(104" lr %0, [status32] \n"105" or %0, %0, %1 \n"106" flag %0 \n"107: "=&r"(temp)108: "n"((STATUS_E1_MASK | STATUS_E2_MASK))109: "cc", "memory");110}111#endif112113/*114* Unconditionally Disable IRQs115*/116static inline void arch_local_irq_disable(void)117{118unsigned long temp;119120__asm__ __volatile__(121" lr %0, [status32] \n"122" and %0, %0, %1 \n"123" flag %0 \n"124: "=&r"(temp)125: "n"(~(STATUS_E1_MASK | STATUS_E2_MASK))126: "memory");127}128129/*130* save IRQ state131*/132static inline long arch_local_save_flags(void)133{134unsigned long temp;135136__asm__ __volatile__(137" lr %0, [status32] \n"138: "=&r"(temp)139:140: "memory");141142return temp;143}144145/*146* Query IRQ state147*/148static inline int arch_irqs_disabled_flags(unsigned long flags)149{150return !(flags & (STATUS_E1_MASK151#ifdef CONFIG_ARC_COMPACT_IRQ_LEVELS152| STATUS_E2_MASK153#endif154));155}156157static inline int arch_irqs_disabled(void)158{159return arch_irqs_disabled_flags(arch_local_save_flags());160}161162#else163164#ifdef CONFIG_TRACE_IRQFLAGS165166.macro TRACE_ASM_IRQ_DISABLE167bl trace_hardirqs_off168.endm169170.macro TRACE_ASM_IRQ_ENABLE171bl trace_hardirqs_on172.endm173174#else175176.macro TRACE_ASM_IRQ_DISABLE177.endm178179.macro TRACE_ASM_IRQ_ENABLE180.endm181182#endif183184.macro IRQ_DISABLE scratch185lr \scratch, [status32]186bic \scratch, \scratch, (STATUS_E1_MASK | STATUS_E2_MASK)187flag \scratch188TRACE_ASM_IRQ_DISABLE189.endm190191.macro IRQ_ENABLE scratch192TRACE_ASM_IRQ_ENABLE193lr \scratch, [status32]194or \scratch, \scratch, (STATUS_E1_MASK | STATUS_E2_MASK)195flag \scratch196.endm197198#endif /* __ASSEMBLER__ */199200#endif201202203