genirq: Prepare proc for real sparse irq support
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / kernel / irq / internals.h
blob8eb01e379ccc745de14f12855b755cf575dc21ba
1 /*
2 * IRQ subsystem internal functions and variables:
3 */
4 #include <linux/irqdesc.h>
6 extern int noirqdebug;
8 #define irq_data_to_desc(data) container_of(data, struct irq_desc, irq_data)
10 /* Set default functions for irq_chip structures: */
11 extern void irq_chip_set_defaults(struct irq_chip *chip);
13 /* Set default handler: */
14 extern void compat_irq_chip_set_default_handler(struct irq_desc *desc);
16 extern int __irq_set_trigger(struct irq_desc *desc, unsigned int irq,
17 unsigned long flags);
18 extern void __disable_irq(struct irq_desc *desc, unsigned int irq, bool susp);
19 extern void __enable_irq(struct irq_desc *desc, unsigned int irq, bool resume);
21 extern struct lock_class_key irq_desc_lock_class;
22 extern void init_kstat_irqs(struct irq_desc *desc, int node, int nr);
23 extern void clear_kstat_irqs(struct irq_desc *desc);
24 extern raw_spinlock_t sparse_irq_lock;
26 /* Resending of interrupts :*/
27 void check_irq_resend(struct irq_desc *desc, unsigned int irq);
29 #ifdef CONFIG_SPARSE_IRQ
30 void replace_irq_desc(unsigned int irq, struct irq_desc *desc);
31 #endif
33 #ifdef CONFIG_PROC_FS
34 extern void register_irq_proc(unsigned int irq, struct irq_desc *desc);
35 extern void unregister_irq_proc(unsigned int irq, struct irq_desc *desc);
36 extern void register_handler_proc(unsigned int irq, struct irqaction *action);
37 extern void unregister_handler_proc(unsigned int irq, struct irqaction *action);
38 #else
39 static inline void register_irq_proc(unsigned int irq, struct irq_desc *desc) { }
40 static inline void unregister_irq_proc(unsigned int irq, struct irq_desc *desc) { }
41 static inline void register_handler_proc(unsigned int irq,
42 struct irqaction *action) { }
43 static inline void unregister_handler_proc(unsigned int irq,
44 struct irqaction *action) { }
45 #endif
47 extern int irq_select_affinity_usr(unsigned int irq);
49 extern void irq_set_thread_affinity(struct irq_desc *desc);
51 #ifndef CONFIG_GENERIC_HARDIRQS_NO_DEPRECATED
52 static inline void irq_end(unsigned int irq, struct irq_desc *desc)
54 if (desc->irq_data.chip && desc->irq_data.chip->end)
55 desc->irq_data.chip->end(irq);
57 #else
58 static inline void irq_end(unsigned int irq, struct irq_desc *desc) { }
59 #endif
61 /* Inline functions for support of irq chips on slow busses */
62 static inline void chip_bus_lock(struct irq_desc *desc)
64 if (unlikely(desc->irq_data.chip->irq_bus_lock))
65 desc->irq_data.chip->irq_bus_lock(&desc->irq_data);
68 static inline void chip_bus_sync_unlock(struct irq_desc *desc)
70 if (unlikely(desc->irq_data.chip->irq_bus_sync_unlock))
71 desc->irq_data.chip->irq_bus_sync_unlock(&desc->irq_data);
75 * Debugging printout:
78 #include <linux/kallsyms.h>
80 #define P(f) if (desc->status & f) printk("%14s set\n", #f)
82 static inline void print_irq_desc(unsigned int irq, struct irq_desc *desc)
84 printk("irq %d, desc: %p, depth: %d, count: %d, unhandled: %d\n",
85 irq, desc, desc->depth, desc->irq_count, desc->irqs_unhandled);
86 printk("->handle_irq(): %p, ", desc->handle_irq);
87 print_symbol("%s\n", (unsigned long)desc->handle_irq);
88 printk("->irq_data.chip(): %p, ", desc->irq_data.chip);
89 print_symbol("%s\n", (unsigned long)desc->irq_data.chip);
90 printk("->action(): %p\n", desc->action);
91 if (desc->action) {
92 printk("->action->handler(): %p, ", desc->action->handler);
93 print_symbol("%s\n", (unsigned long)desc->action->handler);
96 P(IRQ_INPROGRESS);
97 P(IRQ_DISABLED);
98 P(IRQ_PENDING);
99 P(IRQ_REPLAY);
100 P(IRQ_AUTODETECT);
101 P(IRQ_WAITING);
102 P(IRQ_LEVEL);
103 P(IRQ_MASKED);
104 #ifdef CONFIG_IRQ_PER_CPU
105 P(IRQ_PER_CPU);
106 #endif
107 P(IRQ_NOPROBE);
108 P(IRQ_NOREQUEST);
109 P(IRQ_NOAUTOEN);
112 #undef P
114 /* Stuff below will be cleaned up after the sparse allocator is done */
116 #ifdef CONFIG_SMP
118 * alloc_desc_masks - allocate cpumasks for irq_desc
119 * @desc: pointer to irq_desc struct
120 * @node: node which will be handling the cpumasks
121 * @boot: true if need bootmem
123 * Allocates affinity and pending_mask cpumask if required.
124 * Returns true if successful (or not required).
126 static inline bool alloc_desc_masks(struct irq_desc *desc, int node,
127 bool boot)
129 gfp_t gfp = GFP_ATOMIC;
131 if (boot)
132 gfp = GFP_NOWAIT;
134 #ifdef CONFIG_CPUMASK_OFFSTACK
135 if (!alloc_cpumask_var_node(&desc->irq_data.affinity, gfp, node))
136 return false;
138 #ifdef CONFIG_GENERIC_PENDING_IRQ
139 if (!alloc_cpumask_var_node(&desc->pending_mask, gfp, node)) {
140 free_cpumask_var(desc->irq_data.affinity);
141 return false;
143 #endif
144 #endif
145 return true;
148 static inline void init_desc_masks(struct irq_desc *desc)
150 cpumask_setall(desc->irq_data.affinity);
151 #ifdef CONFIG_GENERIC_PENDING_IRQ
152 cpumask_clear(desc->pending_mask);
153 #endif
157 * init_copy_desc_masks - copy cpumasks for irq_desc
158 * @old_desc: pointer to old irq_desc struct
159 * @new_desc: pointer to new irq_desc struct
161 * Insures affinity and pending_masks are copied to new irq_desc.
162 * If !CONFIG_CPUMASKS_OFFSTACK the cpumasks are embedded in the
163 * irq_desc struct so the copy is redundant.
166 static inline void init_copy_desc_masks(struct irq_desc *old_desc,
167 struct irq_desc *new_desc)
169 #ifdef CONFIG_CPUMASK_OFFSTACK
170 cpumask_copy(new_desc->irq_data.affinity, old_desc->irq_data.affinity);
172 #ifdef CONFIG_GENERIC_PENDING_IRQ
173 cpumask_copy(new_desc->pending_mask, old_desc->pending_mask);
174 #endif
175 #endif
178 static inline void free_desc_masks(struct irq_desc *old_desc,
179 struct irq_desc *new_desc)
181 free_cpumask_var(old_desc->irq_data.affinity);
183 #ifdef CONFIG_GENERIC_PENDING_IRQ
184 free_cpumask_var(old_desc->pending_mask);
185 #endif
188 #else /* !CONFIG_SMP */
190 static inline bool alloc_desc_masks(struct irq_desc *desc, int node,
191 bool boot)
193 return true;
196 static inline void init_desc_masks(struct irq_desc *desc)
200 static inline void init_copy_desc_masks(struct irq_desc *old_desc,
201 struct irq_desc *new_desc)
205 static inline void free_desc_masks(struct irq_desc *old_desc,
206 struct irq_desc *new_desc)
209 #endif /* CONFIG_SMP */