--- zzzz-none-000/linux-3.10.107/arch/arm/include/asm/irqflags.h 2017-06-27 09:49:32.000000000 +0000 +++ scorpion-7490-727/linux-3.10.107/arch/arm/include/asm/irqflags.h 2021-02-04 17:41:59.000000000 +0000 @@ -8,21 +8,67 @@ /* * CPU interrupt mask handling. */ +#ifdef CONFIG_CPU_V7M +#define IRQMASK_REG_NAME_R "primask" +#define IRQMASK_REG_NAME_W "primask" +#define IRQMASK_I_BIT 1 +#else +#define IRQMASK_REG_NAME_R "cpsr" +#define IRQMASK_REG_NAME_W "cpsr_c" +#define IRQMASK_I_BIT PSR_I_BIT +#endif + #if __LINUX_ARM_ARCH__ >= 6 -static inline unsigned long arch_local_irq_save(void) +#if IS_ENABLED(CONFIG_ENABLE_IRQ_PROFILING_HOOKS) +#include +#define _local_RET_IP_ ((unsigned long)__builtin_return_address(0)) +#endif + +/* + * Save the current interrupt enable state. + */ +#define arch_local_save_flags arch_local_save_flags +static inline unsigned long arch_local_save_flags(void) { unsigned long flags; + asm volatile( + " mrs %0, " IRQMASK_REG_NAME_R " @ local_save_flags" + : "=r" (flags) : : "memory", "cc"); + return flags; +} + +#define arch_local_irq_save arch_local_irq_save +static inline unsigned long arch_local_irq_save(void) +{ + unsigned long flags, pc_addr __maybe_unused; asm volatile( - " mrs %0, cpsr @ arch_local_irq_save\n" + " mov %1, pc\n" + " mrs %0, " IRQMASK_REG_NAME_R " @ arch_local_irq_save\n" " cpsid i" - : "=r" (flags) : : "memory", "cc"); + : "=r" (flags), "=r" (pc_addr) + : + : "memory", "cc"); +#if IS_ENABLED(CONFIG_ENABLE_IRQ_PROFILING_HOOKS) + avm_simple_profiling_irq_disabled(pc_addr, _local_RET_IP_, + flags & PSR_I_BIT, /* old-status */ + PSR_I_BIT /* new-status */); +#endif return flags; } +#define arch_local_irq_enable arch_local_irq_enable static inline void arch_local_irq_enable(void) { +#if IS_ENABLED(CONFIG_ENABLE_IRQ_PROFILING_HOOKS) + unsigned long flags = arch_local_save_flags(); + + avm_simple_profiling_irq_disabled((unsigned long)&&here, _local_RET_IP_, + flags & PSR_I_BIT, /* old-status */ + 0 /* new-status */); +here: +#endif asm volatile( " cpsie i @ arch_local_irq_enable" : @@ -30,8 +76,13 @@ : "memory", "cc"); } +#define arch_local_irq_disable arch_local_irq_disable static inline void arch_local_irq_disable(void) { +#if IS_ENABLED(CONFIG_ENABLE_IRQ_PROFILING_HOOKS) + arch_local_irq_save(); + return; +#endif asm volatile( " cpsid i @ arch_local_irq_disable" : @@ -41,11 +92,20 @@ #define local_fiq_enable() __asm__("cpsie f @ __stf" : : : "memory", "cc") #define local_fiq_disable() __asm__("cpsid f @ __clf" : : : "memory", "cc") + +#ifndef CONFIG_CPU_V7M +#define local_abt_enable() __asm__("cpsie a @ __sta" : : : "memory", "cc") +#define local_abt_disable() __asm__("cpsid a @ __cla" : : : "memory", "cc") +#else +#define local_abt_enable() do { } while (0) +#define local_abt_disable() do { } while (0) +#endif #else /* * Save the current interrupt enable state & disable IRQs */ +#define arch_local_irq_save arch_local_irq_save static inline unsigned long arch_local_irq_save(void) { unsigned long flags, temp; @@ -63,6 +123,7 @@ /* * Enable IRQs */ +#define arch_local_irq_enable arch_local_irq_enable static inline void arch_local_irq_enable(void) { unsigned long temp; @@ -78,6 +139,7 @@ /* * Disable IRQs */ +#define arch_local_irq_disable arch_local_irq_disable static inline void arch_local_irq_disable(void) { unsigned long temp; @@ -97,9 +159,9 @@ ({ \ unsigned long temp; \ __asm__ __volatile__( \ - "mrs %0, cpsr @ stf\n" \ -" bic %0, %0, #64\n" \ -" msr cpsr_c, %0" \ + " mrs %0, cpsr @ stf\n" \ + " bic %0, %0, #64\n" \ + " msr cpsr_c, %0" \ : "=r" (temp) \ : \ : "memory", "cc"); \ @@ -112,44 +174,44 @@ ({ \ unsigned long temp; \ __asm__ __volatile__( \ - "mrs %0, cpsr @ clf\n" \ -" orr %0, %0, #64\n" \ -" msr cpsr_c, %0" \ + " mrs %0, cpsr @ clf\n" \ + " orr %0, %0, #64\n" \ + " msr cpsr_c, %0" \ : "=r" (temp) \ : \ : "memory", "cc"); \ }) +#define local_abt_enable() do { } while (0) +#define local_abt_disable() do { } while (0) #endif /* - * Save the current interrupt enable state. - */ -static inline unsigned long arch_local_save_flags(void) -{ - unsigned long flags; - asm volatile( - " mrs %0, cpsr @ local_save_flags" - : "=r" (flags) : : "memory", "cc"); - return flags; -} - -/* - * restore saved IRQ & FIQ state + * restore saved IRQ state */ +#define arch_local_irq_restore arch_local_irq_restore static inline void arch_local_irq_restore(unsigned long flags) { +#if IS_ENABLED(CONFIG_ENABLE_IRQ_PROFILING_HOOKS) + avm_simple_profiling_irq_disabled((unsigned long)&&here, _local_RET_IP_, + PSR_I_BIT, /* old-status */ + (flags & PSR_I_BIT) /* new-status */); +here: +#endif asm volatile( - " msr cpsr_c, %0 @ local_irq_restore" + " msr " IRQMASK_REG_NAME_W ", %0 @ local_irq_restore" : : "r" (flags) : "memory", "cc"); } +#define arch_irqs_disabled_flags arch_irqs_disabled_flags static inline int arch_irqs_disabled_flags(unsigned long flags) { - return flags & PSR_I_BIT; + return flags & IRQMASK_I_BIT; } -#endif -#endif +#include + +#endif /* ifdef __KERNEL__ */ +#endif /* ifndef __ASM_ARM_IRQFLAGS_H */