2 * linux/kernel/irq/handle.c
4 * Copyright (C) 1992, 1998-2006 Linus Torvalds, Ingo Molnar
5 * Copyright (C) 2005-2006, Thomas Gleixner, Russell King
7 * This file contains the core interrupt handling code.
9 * Detailed information is available in Documentation/DocBook/genericirq
13 #include <linux/irq.h>
14 #include <linux/module.h>
15 #include <linux/random.h>
16 #include <linux/interrupt.h>
17 #include <linux/kernel_stat.h>
19 #include "internals.h"
21 static void init_copy_kstat_irqs(struct irq_desc
*old_desc
,
22 struct irq_desc
*desc
,
27 init_kstat_irqs(desc
, cpu
, nr
);
29 if (desc
->kstat_irqs
!= old_desc
->kstat_irqs
) {
30 /* Compute how many bytes we need per irq and allocate them */
31 bytes
= nr
* sizeof(unsigned int);
33 memcpy(desc
->kstat_irqs
, old_desc
->kstat_irqs
, bytes
);
37 static void free_kstat_irqs(struct irq_desc
*old_desc
, struct irq_desc
*desc
)
39 if (old_desc
->kstat_irqs
== desc
->kstat_irqs
)
42 kfree(old_desc
->kstat_irqs
);
43 old_desc
->kstat_irqs
= NULL
;
46 static void init_copy_one_irq_desc(int irq
, struct irq_desc
*old_desc
,
47 struct irq_desc
*desc
, int cpu
)
49 memcpy(desc
, old_desc
, sizeof(struct irq_desc
));
51 lockdep_set_class(&desc
->lock
, &irq_desc_lock_class
);
52 init_copy_kstat_irqs(old_desc
, desc
, cpu
, nr_cpu_ids
);
53 arch_init_copy_chip_data(old_desc
, desc
, cpu
);
56 static void free_one_irq_desc(struct irq_desc
*old_desc
, struct irq_desc
*desc
)
58 free_kstat_irqs(old_desc
, desc
);
59 arch_free_chip_data(old_desc
, desc
);
62 static struct irq_desc
*__real_move_irq_desc(struct irq_desc
*old_desc
,
65 struct irq_desc
*desc
;
72 spin_lock_irqsave(&sparse_irq_lock
, flags
);
74 /* We have to check it to avoid races with another CPU */
75 desc
= irq_desc_ptrs
[irq
];
77 if (desc
&& old_desc
!= desc
)
80 node
= cpu_to_node(cpu
);
81 desc
= kzalloc_node(sizeof(*desc
), GFP_ATOMIC
, node
);
82 printk(KERN_DEBUG
" move irq_desc for %d to cpu %d node %d\n",
85 printk(KERN_ERR
"can not get new irq_desc for moving\n");
86 /* still use old one */
90 init_copy_one_irq_desc(irq
, old_desc
, desc
, cpu
);
92 irq_desc_ptrs
[irq
] = desc
;
94 /* free the old one */
95 free_one_irq_desc(old_desc
, desc
);
99 spin_unlock_irqrestore(&sparse_irq_lock
, flags
);
104 struct irq_desc
*move_irq_desc(struct irq_desc
*desc
, int cpu
)
109 /* those all static, do move them */
110 if (desc
->irq
< NR_IRQS_LEGACY
)
115 "try to move irq_desc from cpu %d to %d\n", old_cpu
, cpu
);
116 if (old_cpu
!= cpu
) {
117 node
= cpu_to_node(cpu
);
118 old_node
= cpu_to_node(old_cpu
);
119 if (old_node
!= node
)
120 desc
= __real_move_irq_desc(desc
, cpu
);
This page took 0.042409 seconds and 5 git commands to generate.