1 /* hardirq.h: PA-RISC hard IRQ support.
3 * Copyright (C) 2001 Matthew Wilcox <matthew@wil.cx>
5 * The locking is really quite interesting. There's a cpu-local
6 * count of how many interrupts are being handled, and a global
7 * lock. An interrupt can only be serviced if the global lock
8 * is free. You can't be sure no more interrupts are being
9 * serviced until you've acquired the lock and then checked
10 * all the per-cpu interrupt counts are all zero. It's a specialised
11 * br_lock, and that's exactly how Sparc does it. We don't because
12 * it's more locking for us. This way is lock-free in the interrupt path.
15 #ifndef _PARISC_HARDIRQ_H
16 #define _PARISC_HARDIRQ_H
18 #include <linux/config.h>
19 #include <linux/threads.h>
22 unsigned long __softirq_pending; /* set_bit is used on this */
23 unsigned int __local_irq_count;
24 unsigned int __local_bh_count;
25 unsigned int __syscall_count;
26 struct task_struct * __ksoftirqd_task;
27 } ____cacheline_aligned irq_cpustat_t;
29 #include <linux/irq_cpustat.h> /* Standard mappings for irq_cpustat_t above */
32 * Are we in an interrupt context? Either doing bottom half
33 * or hardware interrupt processing?
35 #define in_interrupt() ({ int __cpu = smp_processor_id(); \
36 (local_irq_count(__cpu) + local_bh_count(__cpu) != 0); })
38 #define in_irq() ({ int __cpu = smp_processor_id(); \
39 (local_irq_count(__cpu) != 0); })
43 #define hardirq_trylock(cpu) (local_irq_count(cpu) == 0)
44 #define hardirq_endlock(cpu) do { } while (0)
46 #define irq_enter(cpu, irq) (local_irq_count(cpu)++)
47 #define irq_exit(cpu, irq) (local_irq_count(cpu)--)
49 #define synchronize_irq() barrier()
53 #include <asm/system.h>
54 #include <asm/atomic.h>
55 #include <linux/spinlock.h>
58 extern int global_irq_holder;
59 extern spinlock_t global_irq_lock;
61 static inline int irqs_running (void)
65 for (i = 0; i < smp_num_cpus; i++)
66 if (local_irq_count(i))
72 static inline void release_irqlock(int cpu)
74 /* if we didn't own the irq lock, just ignore.. */
75 if (global_irq_holder == (unsigned char) cpu) {
76 global_irq_holder = NO_PROC_ID;
77 spin_unlock(&global_irq_lock);
81 static inline void irq_enter(int cpu, int irq)
83 ++local_irq_count(cpu);
85 while (spin_is_locked(&global_irq_lock))
89 static inline void irq_exit(int cpu, int irq)
91 --local_irq_count(cpu);
94 static inline int hardirq_trylock(int cpu)
96 return !local_irq_count(cpu) && !spin_is_locked (&global_irq_lock);
99 #define hardirq_endlock(cpu) do { } while (0)
101 extern void synchronize_irq(void);
103 #endif /* CONFIG_SMP */
105 #endif /* _PARISC_HARDIRQ_H */