11 #include <linux/slab.h>
12 #include <linux/export.h>
16 #include <linux/bitmap.h>
25 #if defined(CONFIG_SMP)
26 static void __init init_irq_default_affinity(
void)
28 alloc_cpumask_var(&irq_default_affinity,
GFP_NOWAIT);
29 cpumask_setall(irq_default_affinity);
32 static void __init init_irq_default_affinity(
void)
40 if (!zalloc_cpumask_var_node(&desc->
irq_data.affinity, gfp, node))
43 #ifdef CONFIG_GENERIC_PENDING_IRQ
44 if (!zalloc_cpumask_var_node(&desc->pending_mask, gfp, node)) {
45 free_cpumask_var(desc->
irq_data.affinity);
52 static void desc_smp_init(
struct irq_desc *desc,
int node)
55 cpumask_copy(desc->
irq_data.affinity, irq_default_affinity);
56 #ifdef CONFIG_GENERIC_PENDING_IRQ
57 cpumask_clear(desc->pending_mask);
61 static inline int desc_node(
struct irq_desc *desc)
68 alloc_masks(
struct irq_desc *desc,
gfp_t gfp,
int node) {
return 0; }
69 static inline void desc_smp_init(
struct irq_desc *desc,
int node) { }
70 static inline int desc_node(
struct irq_desc *desc) {
return 0; }
73 static void desc_set_defaults(
unsigned int irq,
struct irq_desc *desc,
int node,
93 desc_smp_init(desc, node);
102 #ifdef CONFIG_SPARSE_IRQ
106 static void irq_insert_desc(
unsigned int irq,
struct irq_desc *desc)
117 static void delete_irq_desc(
unsigned int irq)
123 static void free_masks(
struct irq_desc *desc)
125 #ifdef CONFIG_GENERIC_PENDING_IRQ
126 free_cpumask_var(desc->pending_mask);
128 free_cpumask_var(desc->
irq_data.affinity);
131 static inline void free_masks(
struct irq_desc *desc) { }
139 desc = kzalloc_node(
sizeof(*desc), gfp, node);
147 if (alloc_masks(desc, gfp, node))
153 desc_set_defaults(irq, desc, node, owner);
164 static void free_desc(
unsigned int irq)
171 delete_irq_desc(irq);
179 static int alloc_descs(
unsigned int start,
unsigned int cnt,
int node,
185 for (i = 0; i <
cnt; i++) {
186 desc = alloc_desc(start + i, node, owner);
190 irq_insert_desc(start + i, desc);
196 for (i--; i >= 0; i--)
197 free_desc(start + i);
205 static int irq_expand_nr_irqs(
unsigned int nr)
218 init_irq_default_affinity();
230 if (initcnt > nr_irqs)
233 for (i = 0; i < initcnt; i++) {
234 desc = alloc_desc(i, node,
NULL);
236 irq_insert_desc(i, desc);
256 init_irq_default_affinity();
263 for (i = 0; i <
count; i++) {
268 desc_set_defaults(i, &desc[i], node,
NULL);
278 static void free_desc(
unsigned int irq)
283 static inline int alloc_descs(
unsigned int start,
unsigned int cnt,
int node,
288 for (i = 0; i <
cnt; i++) {
296 static int irq_expand_nr_irqs(
unsigned int nr)
314 generic_handle_irq_desc(irq, desc);
330 if (from >= nr_irqs || (from + cnt) > nr_irqs)
333 for (i = 0; i <
cnt; i++)
372 if (irq >=0 && start != irq)
375 if (start + cnt > nr_irqs) {
376 ret = irq_expand_nr_irqs(start + cnt);
383 return alloc_descs(start, cnt, node, owner);
403 if (!cnt || (from + cnt) > nr_irqs)
436 !irq_settings_is_per_cpu_devid(desc))
439 if (!(check & _IRQ_DESC_PERCPU) &&
440 irq_settings_is_per_cpu_devid(desc))
455 chip_bus_sync_unlock(desc);
473 irq_set_percpu_devid_flags(irq);
487 desc_set_defaults(irq, desc, desc_node(desc),
NULL);