diff options
Diffstat (limited to 'kernel/irq/handle.c')
-rw-r--r-- | kernel/irq/handle.c | 73 |
1 files changed, 51 insertions, 22 deletions
diff --git a/kernel/irq/handle.c b/kernel/irq/handle.c index c20db0be9173..f51eaee921b6 100644 --- a/kernel/irq/handle.c +++ b/kernel/irq/handle.c | |||
@@ -17,6 +17,7 @@ | |||
17 | #include <linux/kernel_stat.h> | 17 | #include <linux/kernel_stat.h> |
18 | #include <linux/rculist.h> | 18 | #include <linux/rculist.h> |
19 | #include <linux/hash.h> | 19 | #include <linux/hash.h> |
20 | #include <linux/bootmem.h> | ||
20 | 21 | ||
21 | #include "internals.h" | 22 | #include "internals.h" |
22 | 23 | ||
@@ -39,6 +40,18 @@ void handle_bad_irq(unsigned int irq, struct irq_desc *desc) | |||
39 | ack_bad_irq(irq); | 40 | ack_bad_irq(irq); |
40 | } | 41 | } |
41 | 42 | ||
43 | #if defined(CONFIG_SMP) && defined(CONFIG_GENERIC_HARDIRQS) | ||
44 | static void __init init_irq_default_affinity(void) | ||
45 | { | ||
46 | alloc_bootmem_cpumask_var(&irq_default_affinity); | ||
47 | cpumask_setall(irq_default_affinity); | ||
48 | } | ||
49 | #else | ||
50 | static void __init init_irq_default_affinity(void) | ||
51 | { | ||
52 | } | ||
53 | #endif | ||
54 | |||
42 | /* | 55 | /* |
43 | * Linux has a controller-independent interrupt architecture. | 56 | * Linux has a controller-independent interrupt architecture. |
44 | * Every controller has a 'controller-template', that is used | 57 | * Every controller has a 'controller-template', that is used |
@@ -57,6 +70,7 @@ int nr_irqs = NR_IRQS; | |||
57 | EXPORT_SYMBOL_GPL(nr_irqs); | 70 | EXPORT_SYMBOL_GPL(nr_irqs); |
58 | 71 | ||
59 | #ifdef CONFIG_SPARSE_IRQ | 72 | #ifdef CONFIG_SPARSE_IRQ |
73 | |||
60 | static struct irq_desc irq_desc_init = { | 74 | static struct irq_desc irq_desc_init = { |
61 | .irq = -1, | 75 | .irq = -1, |
62 | .status = IRQ_DISABLED, | 76 | .status = IRQ_DISABLED, |
@@ -64,9 +78,6 @@ static struct irq_desc irq_desc_init = { | |||
64 | .handle_irq = handle_bad_irq, | 78 | .handle_irq = handle_bad_irq, |
65 | .depth = 1, | 79 | .depth = 1, |
66 | .lock = __SPIN_LOCK_UNLOCKED(irq_desc_init.lock), | 80 | .lock = __SPIN_LOCK_UNLOCKED(irq_desc_init.lock), |
67 | #ifdef CONFIG_SMP | ||
68 | .affinity = CPU_MASK_ALL | ||
69 | #endif | ||
70 | }; | 81 | }; |
71 | 82 | ||
72 | void init_kstat_irqs(struct irq_desc *desc, int cpu, int nr) | 83 | void init_kstat_irqs(struct irq_desc *desc, int cpu, int nr) |
@@ -101,6 +112,10 @@ static void init_one_irq_desc(int irq, struct irq_desc *desc, int cpu) | |||
101 | printk(KERN_ERR "can not alloc kstat_irqs\n"); | 112 | printk(KERN_ERR "can not alloc kstat_irqs\n"); |
102 | BUG_ON(1); | 113 | BUG_ON(1); |
103 | } | 114 | } |
115 | if (!init_alloc_desc_masks(desc, cpu, false)) { | ||
116 | printk(KERN_ERR "can not alloc irq_desc cpumasks\n"); | ||
117 | BUG_ON(1); | ||
118 | } | ||
104 | arch_init_chip_data(desc, cpu); | 119 | arch_init_chip_data(desc, cpu); |
105 | } | 120 | } |
106 | 121 | ||
@@ -109,7 +124,7 @@ static void init_one_irq_desc(int irq, struct irq_desc *desc, int cpu) | |||
109 | */ | 124 | */ |
110 | DEFINE_SPINLOCK(sparse_irq_lock); | 125 | DEFINE_SPINLOCK(sparse_irq_lock); |
111 | 126 | ||
112 | struct irq_desc *irq_desc_ptrs[NR_IRQS] __read_mostly; | 127 | struct irq_desc **irq_desc_ptrs __read_mostly; |
113 | 128 | ||
114 | static struct irq_desc irq_desc_legacy[NR_IRQS_LEGACY] __cacheline_aligned_in_smp = { | 129 | static struct irq_desc irq_desc_legacy[NR_IRQS_LEGACY] __cacheline_aligned_in_smp = { |
115 | [0 ... NR_IRQS_LEGACY-1] = { | 130 | [0 ... NR_IRQS_LEGACY-1] = { |
@@ -119,14 +134,10 @@ static struct irq_desc irq_desc_legacy[NR_IRQS_LEGACY] __cacheline_aligned_in_sm | |||
119 | .handle_irq = handle_bad_irq, | 134 | .handle_irq = handle_bad_irq, |
120 | .depth = 1, | 135 | .depth = 1, |
121 | .lock = __SPIN_LOCK_UNLOCKED(irq_desc_init.lock), | 136 | .lock = __SPIN_LOCK_UNLOCKED(irq_desc_init.lock), |
122 | #ifdef CONFIG_SMP | ||
123 | .affinity = CPU_MASK_ALL | ||
124 | #endif | ||
125 | } | 137 | } |
126 | }; | 138 | }; |
127 | 139 | ||
128 | /* FIXME: use bootmem alloc ...*/ | 140 | static unsigned int *kstat_irqs_legacy; |
129 | static unsigned int kstat_irqs_legacy[NR_IRQS_LEGACY][NR_CPUS]; | ||
130 | 141 | ||
131 | int __init early_irq_init(void) | 142 | int __init early_irq_init(void) |
132 | { | 143 | { |
@@ -134,18 +145,32 @@ int __init early_irq_init(void) | |||
134 | int legacy_count; | 145 | int legacy_count; |
135 | int i; | 146 | int i; |
136 | 147 | ||
148 | init_irq_default_affinity(); | ||
149 | |||
150 | /* initialize nr_irqs based on nr_cpu_ids */ | ||
151 | arch_probe_nr_irqs(); | ||
152 | printk(KERN_INFO "NR_IRQS:%d nr_irqs:%d\n", NR_IRQS, nr_irqs); | ||
153 | |||
137 | desc = irq_desc_legacy; | 154 | desc = irq_desc_legacy; |
138 | legacy_count = ARRAY_SIZE(irq_desc_legacy); | 155 | legacy_count = ARRAY_SIZE(irq_desc_legacy); |
139 | 156 | ||
157 | /* allocate irq_desc_ptrs array based on nr_irqs */ | ||
158 | irq_desc_ptrs = alloc_bootmem(nr_irqs * sizeof(void *)); | ||
159 | |||
160 | /* allocate based on nr_cpu_ids */ | ||
161 | /* FIXME: invert kstat_irgs, and it'd be a per_cpu_alloc'd thing */ | ||
162 | kstat_irqs_legacy = alloc_bootmem(NR_IRQS_LEGACY * nr_cpu_ids * | ||
163 | sizeof(int)); | ||
164 | |||
140 | for (i = 0; i < legacy_count; i++) { | 165 | for (i = 0; i < legacy_count; i++) { |
141 | desc[i].irq = i; | 166 | desc[i].irq = i; |
142 | desc[i].kstat_irqs = kstat_irqs_legacy[i]; | 167 | desc[i].kstat_irqs = kstat_irqs_legacy + i * nr_cpu_ids; |
143 | lockdep_set_class(&desc[i].lock, &irq_desc_lock_class); | 168 | lockdep_set_class(&desc[i].lock, &irq_desc_lock_class); |
144 | 169 | init_alloc_desc_masks(&desc[i], 0, true); | |
145 | irq_desc_ptrs[i] = desc + i; | 170 | irq_desc_ptrs[i] = desc + i; |
146 | } | 171 | } |
147 | 172 | ||
148 | for (i = legacy_count; i < NR_IRQS; i++) | 173 | for (i = legacy_count; i < nr_irqs; i++) |
149 | irq_desc_ptrs[i] = NULL; | 174 | irq_desc_ptrs[i] = NULL; |
150 | 175 | ||
151 | return arch_early_irq_init(); | 176 | return arch_early_irq_init(); |
@@ -153,7 +178,10 @@ int __init early_irq_init(void) | |||
153 | 178 | ||
154 | struct irq_desc *irq_to_desc(unsigned int irq) | 179 | struct irq_desc *irq_to_desc(unsigned int irq) |
155 | { | 180 | { |
156 | return (irq < NR_IRQS) ? irq_desc_ptrs[irq] : NULL; | 181 | if (irq_desc_ptrs && irq < nr_irqs) |
182 | return irq_desc_ptrs[irq]; | ||
183 | |||
184 | return NULL; | ||
157 | } | 185 | } |
158 | 186 | ||
159 | struct irq_desc *irq_to_desc_alloc_cpu(unsigned int irq, int cpu) | 187 | struct irq_desc *irq_to_desc_alloc_cpu(unsigned int irq, int cpu) |
@@ -162,10 +190,9 @@ struct irq_desc *irq_to_desc_alloc_cpu(unsigned int irq, int cpu) | |||
162 | unsigned long flags; | 190 | unsigned long flags; |
163 | int node; | 191 | int node; |
164 | 192 | ||
165 | if (irq >= NR_IRQS) { | 193 | if (irq >= nr_irqs) { |
166 | printk(KERN_WARNING "irq >= NR_IRQS in irq_to_desc_alloc: %d %d\n", | 194 | WARN(1, "irq (%d) >= nr_irqs (%d) in irq_to_desc_alloc\n", |
167 | irq, NR_IRQS); | 195 | irq, nr_irqs); |
168 | WARN_ON(1); | ||
169 | return NULL; | 196 | return NULL; |
170 | } | 197 | } |
171 | 198 | ||
@@ -207,9 +234,6 @@ struct irq_desc irq_desc[NR_IRQS] __cacheline_aligned_in_smp = { | |||
207 | .handle_irq = handle_bad_irq, | 234 | .handle_irq = handle_bad_irq, |
208 | .depth = 1, | 235 | .depth = 1, |
209 | .lock = __SPIN_LOCK_UNLOCKED(irq_desc->lock), | 236 | .lock = __SPIN_LOCK_UNLOCKED(irq_desc->lock), |
210 | #ifdef CONFIG_SMP | ||
211 | .affinity = CPU_MASK_ALL | ||
212 | #endif | ||
213 | } | 237 | } |
214 | }; | 238 | }; |
215 | 239 | ||
@@ -219,12 +243,17 @@ int __init early_irq_init(void) | |||
219 | int count; | 243 | int count; |
220 | int i; | 244 | int i; |
221 | 245 | ||
246 | init_irq_default_affinity(); | ||
247 | |||
248 | printk(KERN_INFO "NR_IRQS:%d\n", NR_IRQS); | ||
249 | |||
222 | desc = irq_desc; | 250 | desc = irq_desc; |
223 | count = ARRAY_SIZE(irq_desc); | 251 | count = ARRAY_SIZE(irq_desc); |
224 | 252 | ||
225 | for (i = 0; i < count; i++) | 253 | for (i = 0; i < count; i++) { |
226 | desc[i].irq = i; | 254 | desc[i].irq = i; |
227 | 255 | init_alloc_desc_masks(&desc[i], 0, true); | |
256 | } | ||
228 | return arch_early_irq_init(); | 257 | return arch_early_irq_init(); |
229 | } | 258 | } |
230 | 259 | ||