direct-io.hg

view linux-2.6-xen-sparse/include/linux/interrupt.h @ 11509:2e6c10dc7c0b

[POWERPC][XEN] make sure put_domain() is called in case of allocate_rma() failuer

Signed-off-by: Jimi Xenidis <jimix@watson.ibm.com>
Signed-off-by: Hollis Blanchard <hollisb@us.ibm.com>
author Jimi Xenidis <jimix@watson.ibm.com>
date Tue Sep 12 10:53:46 2006 -0400 (2006-09-12)
parents 6fb0d5ad63d7
children 3adf00179a63
line source
1 /* interrupt.h */
2 #ifndef _LINUX_INTERRUPT_H
3 #define _LINUX_INTERRUPT_H
5 #include <linux/config.h>
6 #include <linux/kernel.h>
7 #include <linux/linkage.h>
8 #include <linux/bitops.h>
9 #include <linux/preempt.h>
10 #include <linux/cpumask.h>
11 #include <linux/hardirq.h>
12 #include <linux/sched.h>
13 #include <asm/atomic.h>
14 #include <asm/ptrace.h>
15 #include <asm/system.h>
17 /*
18 * For 2.4.x compatibility, 2.4.x can use
19 *
20 * typedef void irqreturn_t;
21 * #define IRQ_NONE
22 * #define IRQ_HANDLED
23 * #define IRQ_RETVAL(x)
24 *
25 * To mix old-style and new-style irq handler returns.
26 *
27 * IRQ_NONE means we didn't handle it.
28 * IRQ_HANDLED means that we did have a valid interrupt and handled it.
29 * IRQ_RETVAL(x) selects on the two depending on x being non-zero (for handled)
30 */
31 typedef int irqreturn_t;
33 #define IRQ_NONE (0)
34 #define IRQ_HANDLED (1)
35 #define IRQ_RETVAL(x) ((x) != 0)
37 struct irqaction {
38 irqreturn_t (*handler)(int, void *, struct pt_regs *);
39 unsigned long flags;
40 cpumask_t mask;
41 const char *name;
42 void *dev_id;
43 struct irqaction *next;
44 int irq;
45 struct proc_dir_entry *dir;
46 };
48 extern irqreturn_t no_action(int cpl, void *dev_id, struct pt_regs *regs);
49 extern int request_irq(unsigned int,
50 irqreturn_t (*handler)(int, void *, struct pt_regs *),
51 unsigned long, const char *, void *);
52 extern void free_irq(unsigned int, void *);
55 #ifdef CONFIG_GENERIC_HARDIRQS
56 extern void disable_irq_nosync(unsigned int irq);
57 extern void disable_irq(unsigned int irq);
58 extern void enable_irq(unsigned int irq);
59 #endif
61 #ifdef CONFIG_HAVE_IRQ_IGNORE_UNHANDLED
62 int irq_ignore_unhandled(unsigned int irq);
63 #else
64 #define irq_ignore_unhandled(irq) 0
65 #endif
67 #ifndef __ARCH_SET_SOFTIRQ_PENDING
68 #define set_softirq_pending(x) (local_softirq_pending() = (x))
69 #define or_softirq_pending(x) (local_softirq_pending() |= (x))
70 #endif
72 /*
73 * Temporary defines for UP kernels, until all code gets fixed.
74 */
75 #ifndef CONFIG_SMP
76 static inline void __deprecated cli(void)
77 {
78 local_irq_disable();
79 }
80 static inline void __deprecated sti(void)
81 {
82 local_irq_enable();
83 }
84 static inline void __deprecated save_flags(unsigned long *x)
85 {
86 local_save_flags(*x);
87 }
88 #define save_flags(x) save_flags(&x)
89 static inline void __deprecated restore_flags(unsigned long x)
90 {
91 local_irq_restore(x);
92 }
94 static inline void __deprecated save_and_cli(unsigned long *x)
95 {
96 local_irq_save(*x);
97 }
98 #define save_and_cli(x) save_and_cli(&x)
99 #endif /* CONFIG_SMP */
101 /* SoftIRQ primitives. */
102 #define local_bh_disable() \
103 do { add_preempt_count(SOFTIRQ_OFFSET); barrier(); } while (0)
104 #define __local_bh_enable() \
105 do { barrier(); sub_preempt_count(SOFTIRQ_OFFSET); } while (0)
107 extern void local_bh_enable(void);
109 /* PLEASE, avoid to allocate new softirqs, if you need not _really_ high
110 frequency threaded job scheduling. For almost all the purposes
111 tasklets are more than enough. F.e. all serial device BHs et
112 al. should be converted to tasklets, not to softirqs.
113 */
115 enum
116 {
117 HI_SOFTIRQ=0,
118 TIMER_SOFTIRQ,
119 NET_TX_SOFTIRQ,
120 NET_RX_SOFTIRQ,
121 BLOCK_SOFTIRQ,
122 TASKLET_SOFTIRQ
123 };
125 /* softirq mask and active fields moved to irq_cpustat_t in
126 * asm/hardirq.h to get better cache usage. KAO
127 */
129 struct softirq_action
130 {
131 void (*action)(struct softirq_action *);
132 void *data;
133 };
135 asmlinkage void do_softirq(void);
136 extern void open_softirq(int nr, void (*action)(struct softirq_action*), void *data);
137 extern void softirq_init(void);
138 #define __raise_softirq_irqoff(nr) do { or_softirq_pending(1UL << (nr)); } while (0)
139 extern void FASTCALL(raise_softirq_irqoff(unsigned int nr));
140 extern void FASTCALL(raise_softirq(unsigned int nr));
143 /* Tasklets --- multithreaded analogue of BHs.
145 Main feature differing them of generic softirqs: tasklet
146 is running only on one CPU simultaneously.
148 Main feature differing them of BHs: different tasklets
149 may be run simultaneously on different CPUs.
151 Properties:
152 * If tasklet_schedule() is called, then tasklet is guaranteed
153 to be executed on some cpu at least once after this.
154 * If the tasklet is already scheduled, but its excecution is still not
155 started, it will be executed only once.
156 * If this tasklet is already running on another CPU (or schedule is called
157 from tasklet itself), it is rescheduled for later.
158 * Tasklet is strictly serialized wrt itself, but not
159 wrt another tasklets. If client needs some intertask synchronization,
160 he makes it with spinlocks.
161 */
163 struct tasklet_struct
164 {
165 struct tasklet_struct *next;
166 unsigned long state;
167 atomic_t count;
168 void (*func)(unsigned long);
169 unsigned long data;
170 };
172 #define DECLARE_TASKLET(name, func, data) \
173 struct tasklet_struct name = { NULL, 0, ATOMIC_INIT(0), func, data }
175 #define DECLARE_TASKLET_DISABLED(name, func, data) \
176 struct tasklet_struct name = { NULL, 0, ATOMIC_INIT(1), func, data }
179 enum
180 {
181 TASKLET_STATE_SCHED, /* Tasklet is scheduled for execution */
182 TASKLET_STATE_RUN /* Tasklet is running (SMP only) */
183 };
185 #ifdef CONFIG_SMP
186 static inline int tasklet_trylock(struct tasklet_struct *t)
187 {
188 return !test_and_set_bit(TASKLET_STATE_RUN, &(t)->state);
189 }
191 static inline void tasklet_unlock(struct tasklet_struct *t)
192 {
193 smp_mb__before_clear_bit();
194 clear_bit(TASKLET_STATE_RUN, &(t)->state);
195 }
197 static inline void tasklet_unlock_wait(struct tasklet_struct *t)
198 {
199 while (test_bit(TASKLET_STATE_RUN, &(t)->state)) { barrier(); }
200 }
201 #else
202 #define tasklet_trylock(t) 1
203 #define tasklet_unlock_wait(t) do { } while (0)
204 #define tasklet_unlock(t) do { } while (0)
205 #endif
207 extern void FASTCALL(__tasklet_schedule(struct tasklet_struct *t));
209 static inline void tasklet_schedule(struct tasklet_struct *t)
210 {
211 if (!test_and_set_bit(TASKLET_STATE_SCHED, &t->state))
212 __tasklet_schedule(t);
213 }
215 extern void FASTCALL(__tasklet_hi_schedule(struct tasklet_struct *t));
217 static inline void tasklet_hi_schedule(struct tasklet_struct *t)
218 {
219 if (!test_and_set_bit(TASKLET_STATE_SCHED, &t->state))
220 __tasklet_hi_schedule(t);
221 }
224 static inline void tasklet_disable_nosync(struct tasklet_struct *t)
225 {
226 atomic_inc(&t->count);
227 smp_mb__after_atomic_inc();
228 }
230 static inline void tasklet_disable(struct tasklet_struct *t)
231 {
232 tasklet_disable_nosync(t);
233 tasklet_unlock_wait(t);
234 smp_mb();
235 }
237 static inline void tasklet_enable(struct tasklet_struct *t)
238 {
239 smp_mb__before_atomic_dec();
240 atomic_dec(&t->count);
241 }
243 static inline void tasklet_hi_enable(struct tasklet_struct *t)
244 {
245 smp_mb__before_atomic_dec();
246 atomic_dec(&t->count);
247 }
249 extern void tasklet_kill(struct tasklet_struct *t);
250 extern void tasklet_kill_immediate(struct tasklet_struct *t, unsigned int cpu);
251 extern void tasklet_init(struct tasklet_struct *t,
252 void (*func)(unsigned long), unsigned long data);
254 /*
255 * Autoprobing for irqs:
256 *
257 * probe_irq_on() and probe_irq_off() provide robust primitives
258 * for accurate IRQ probing during kernel initialization. They are
259 * reasonably simple to use, are not "fooled" by spurious interrupts,
260 * and, unlike other attempts at IRQ probing, they do not get hung on
261 * stuck interrupts (such as unused PS2 mouse interfaces on ASUS boards).
262 *
263 * For reasonably foolproof probing, use them as follows:
264 *
265 * 1. clear and/or mask the device's internal interrupt.
266 * 2. sti();
267 * 3. irqs = probe_irq_on(); // "take over" all unassigned idle IRQs
268 * 4. enable the device and cause it to trigger an interrupt.
269 * 5. wait for the device to interrupt, using non-intrusive polling or a delay.
270 * 6. irq = probe_irq_off(irqs); // get IRQ number, 0=none, negative=multiple
271 * 7. service the device to clear its pending interrupt.
272 * 8. loop again if paranoia is required.
273 *
274 * probe_irq_on() returns a mask of allocated irq's.
275 *
276 * probe_irq_off() takes the mask as a parameter,
277 * and returns the irq number which occurred,
278 * or zero if none occurred, or a negative irq number
279 * if more than one irq occurred.
280 */
282 #if defined(CONFIG_GENERIC_HARDIRQS) && !defined(CONFIG_GENERIC_IRQ_PROBE)
283 static inline unsigned long probe_irq_on(void)
284 {
285 return 0;
286 }
287 static inline int probe_irq_off(unsigned long val)
288 {
289 return 0;
290 }
291 static inline unsigned int probe_irq_mask(unsigned long val)
292 {
293 return 0;
294 }
295 #else
296 extern unsigned long probe_irq_on(void); /* returns 0 on failure */
297 extern int probe_irq_off(unsigned long); /* returns 0 or negative on failure */
298 extern unsigned int probe_irq_mask(unsigned long); /* returns mask of ISA interrupts */
299 #endif
301 #endif