1/* 2 * include/asm-s390/hardirq.h 3 * 4 * S390 version 5 * Copyright (C) 1999 IBM Deutschland Entwicklung GmbH, IBM Corporation 6 * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com), 7 * Denis Joseph Barrow (djbarrow@de.ibm.com,barrow_dj@yahoo.com) 8 * 9 * Derived from "include/asm-i386/hardirq.h" 10 */ 11 12#ifndef __ASM_HARDIRQ_H 13#define __ASM_HARDIRQ_H 14 15#include <linux/config.h> 16#include <linux/threads.h> 17#include <asm/lowcore.h> 18#include <linux/sched.h> 19 20/* entry.S is sensitive to the offsets of these fields */ 21typedef struct { 22 unsigned int __softirq_pending; 23 unsigned int __local_irq_count; 24 unsigned int __local_bh_count; 25 unsigned int __syscall_count; 26 struct task_struct * __ksoftirqd_task; /* waitqueue is too large */ 27} ____cacheline_aligned irq_cpustat_t; 28 29#include <linux/irq_cpustat.h> /* Standard mappings for irq_cpustat_t above */ 30 31/* 32 * Are we in an interrupt context? Either doing bottom half 33 * or hardware interrupt processing? 34 */ 35#define in_interrupt() ({ int __cpu = smp_processor_id(); \ 36 (local_irq_count(__cpu) + local_bh_count(__cpu) != 0); }) 37 38#define in_irq() (local_irq_count(smp_processor_id()) != 0) 39 40#ifndef CONFIG_SMP 41 42#define hardirq_trylock(cpu) (local_irq_count(cpu) == 0) 43#define hardirq_endlock(cpu) do { } while (0) 44 45#define hardirq_enter(cpu) (local_irq_count(cpu)++) 46#define hardirq_exit(cpu) (local_irq_count(cpu)--) 47 48#define synchronize_irq() do { } while (0) 49 50#else 51 52#include <asm/atomic.h> 53#include <asm/smp.h> 54 55extern atomic_t global_irq_holder; 56extern atomic_t global_irq_lock; 57extern atomic_t global_irq_count; 58 59static inline void release_irqlock(int cpu) 60{ 61 /* if we didn't own the irq lock, just ignore.. */ 62 if (atomic_read(&global_irq_holder) == cpu) { 63 atomic_set(&global_irq_holder,NO_PROC_ID); 64 atomic_set(&global_irq_lock,0); 65 } 66} 67 68static inline void hardirq_enter(int cpu) 69{ 70 ++local_irq_count(cpu); 71 atomic_inc(&global_irq_count); 72} 73 74static inline void hardirq_exit(int cpu) 75{ 76 atomic_dec(&global_irq_count); 77 --local_irq_count(cpu); 78} 79 80static inline int hardirq_trylock(int cpu) 81{ 82 return !atomic_read(&global_irq_count) && 83 !atomic_read(&global_irq_lock); 84} 85 86#define hardirq_endlock(cpu) do { } while (0) 87 88extern void synchronize_irq(void); 89 90#endif /* CONFIG_SMP */ 91 92#endif /* __ASM_HARDIRQ_H */ 93