aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/irq/handle.c
diff options
context:
space:
mode:
authorThomas Gleixner <tglx@linutronix.de>2009-03-23 09:50:03 -0400
committerThomas Gleixner <tglx@linutronix.de>2009-03-23 16:20:20 -0400
commit80c5520811d3805adcb15c570ea5e2d489fa5d0b (patch)
treeae797a7f4af39f80e77526533d06ac23b439f0ab /kernel/irq/handle.c
parentb3e3b302cf6dc8d60b67f0e84d1fa5648889c038 (diff)
parent8c083f081d0014057901c68a0a3e0f8ca7ac8d23 (diff)
Merge branch 'cpus4096' into irq/threaded
Conflicts: arch/parisc/kernel/irq.c kernel/irq/handle.c Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'kernel/irq/handle.c')
-rw-r--r--kernel/irq/handle.c54
1 files changed, 33 insertions, 21 deletions
diff --git a/kernel/irq/handle.c b/kernel/irq/handle.c
index f6cdda68e5c6..9ebf77968871 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
@@ -69,6 +70,7 @@ int nr_irqs = NR_IRQS;
69EXPORT_SYMBOL_GPL(nr_irqs); 70EXPORT_SYMBOL_GPL(nr_irqs);
70 71
71#ifdef CONFIG_SPARSE_IRQ 72#ifdef CONFIG_SPARSE_IRQ
73
72static struct irq_desc irq_desc_init = { 74static struct irq_desc irq_desc_init = {
73 .irq = -1, 75 .irq = -1,
74 .status = IRQ_DISABLED, 76 .status = IRQ_DISABLED,
@@ -76,9 +78,6 @@ static struct irq_desc irq_desc_init = {
76 .handle_irq = handle_bad_irq, 78 .handle_irq = handle_bad_irq,
77 .depth = 1, 79 .depth = 1,
78 .lock = __SPIN_LOCK_UNLOCKED(irq_desc_init.lock), 80 .lock = __SPIN_LOCK_UNLOCKED(irq_desc_init.lock),
79#ifdef CONFIG_SMP
80 .affinity = CPU_MASK_ALL
81#endif
82}; 81};
83 82
84void init_kstat_irqs(struct irq_desc *desc, int cpu, int nr) 83void init_kstat_irqs(struct irq_desc *desc, int cpu, int nr)
@@ -115,6 +114,10 @@ static void init_one_irq_desc(int irq, struct irq_desc *desc, int cpu)
115 printk(KERN_ERR "can not alloc kstat_irqs\n"); 114 printk(KERN_ERR "can not alloc kstat_irqs\n");
116 BUG_ON(1); 115 BUG_ON(1);
117 } 116 }
117 if (!init_alloc_desc_masks(desc, cpu, false)) {
118 printk(KERN_ERR "can not alloc irq_desc cpumasks\n");
119 BUG_ON(1);
120 }
118 arch_init_chip_data(desc, cpu); 121 arch_init_chip_data(desc, cpu);
119} 122}
120 123
@@ -123,7 +126,7 @@ static void init_one_irq_desc(int irq, struct irq_desc *desc, int cpu)
123 */ 126 */
124DEFINE_SPINLOCK(sparse_irq_lock); 127DEFINE_SPINLOCK(sparse_irq_lock);
125 128
126struct irq_desc *irq_desc_ptrs[NR_IRQS] __read_mostly; 129struct irq_desc **irq_desc_ptrs __read_mostly;
127 130
128static struct irq_desc irq_desc_legacy[NR_IRQS_LEGACY] __cacheline_aligned_in_smp = { 131static struct irq_desc irq_desc_legacy[NR_IRQS_LEGACY] __cacheline_aligned_in_smp = {
129 [0 ... NR_IRQS_LEGACY-1] = { 132 [0 ... NR_IRQS_LEGACY-1] = {
@@ -133,14 +136,10 @@ static struct irq_desc irq_desc_legacy[NR_IRQS_LEGACY] __cacheline_aligned_in_sm
133 .handle_irq = handle_bad_irq, 136 .handle_irq = handle_bad_irq,
134 .depth = 1, 137 .depth = 1,
135 .lock = __SPIN_LOCK_UNLOCKED(irq_desc_init.lock), 138 .lock = __SPIN_LOCK_UNLOCKED(irq_desc_init.lock),
136#ifdef CONFIG_SMP
137 .affinity = CPU_MASK_ALL
138#endif
139 } 139 }
140}; 140};
141 141
142/* FIXME: use bootmem alloc ...*/ 142static unsigned int *kstat_irqs_legacy;
143static unsigned int kstat_irqs_legacy[NR_IRQS_LEGACY][NR_CPUS];
144 143
145int __init early_irq_init(void) 144int __init early_irq_init(void)
146{ 145{
@@ -150,18 +149,30 @@ int __init early_irq_init(void)
150 149
151 init_irq_default_affinity(); 150 init_irq_default_affinity();
152 151
152 /* initialize nr_irqs based on nr_cpu_ids */
153 arch_probe_nr_irqs();
154 printk(KERN_INFO "NR_IRQS:%d nr_irqs:%d\n", NR_IRQS, nr_irqs);
155
153 desc = irq_desc_legacy; 156 desc = irq_desc_legacy;
154 legacy_count = ARRAY_SIZE(irq_desc_legacy); 157 legacy_count = ARRAY_SIZE(irq_desc_legacy);
155 158
159 /* allocate irq_desc_ptrs array based on nr_irqs */
160 irq_desc_ptrs = alloc_bootmem(nr_irqs * sizeof(void *));
161
162 /* allocate based on nr_cpu_ids */
163 /* FIXME: invert kstat_irgs, and it'd be a per_cpu_alloc'd thing */
164 kstat_irqs_legacy = alloc_bootmem(NR_IRQS_LEGACY * nr_cpu_ids *
165 sizeof(int));
166
156 for (i = 0; i < legacy_count; i++) { 167 for (i = 0; i < legacy_count; i++) {
157 desc[i].irq = i; 168 desc[i].irq = i;
158 desc[i].kstat_irqs = kstat_irqs_legacy[i]; 169 desc[i].kstat_irqs = kstat_irqs_legacy + i * nr_cpu_ids;
159 lockdep_set_class(&desc[i].lock, &irq_desc_lock_class); 170 lockdep_set_class(&desc[i].lock, &irq_desc_lock_class);
160 171 init_alloc_desc_masks(&desc[i], 0, true);
161 irq_desc_ptrs[i] = desc + i; 172 irq_desc_ptrs[i] = desc + i;
162 } 173 }
163 174
164 for (i = legacy_count; i < NR_IRQS; i++) 175 for (i = legacy_count; i < nr_irqs; i++)
165 irq_desc_ptrs[i] = NULL; 176 irq_desc_ptrs[i] = NULL;
166 177
167 return arch_early_irq_init(); 178 return arch_early_irq_init();
@@ -169,7 +180,10 @@ int __init early_irq_init(void)
169 180
170struct irq_desc *irq_to_desc(unsigned int irq) 181struct irq_desc *irq_to_desc(unsigned int irq)
171{ 182{
172 return (irq < NR_IRQS) ? irq_desc_ptrs[irq] : NULL; 183 if (irq_desc_ptrs && irq < nr_irqs)
184 return irq_desc_ptrs[irq];
185
186 return NULL;
173} 187}
174 188
175struct irq_desc *irq_to_desc_alloc_cpu(unsigned int irq, int cpu) 189struct irq_desc *irq_to_desc_alloc_cpu(unsigned int irq, int cpu)
@@ -178,10 +192,9 @@ struct irq_desc *irq_to_desc_alloc_cpu(unsigned int irq, int cpu)
178 unsigned long flags; 192 unsigned long flags;
179 int node; 193 int node;
180 194
181 if (irq >= NR_IRQS) { 195 if (irq >= nr_irqs) {
182 printk(KERN_WARNING "irq >= NR_IRQS in irq_to_desc_alloc: %d %d\n", 196 WARN(1, "irq (%d) >= nr_irqs (%d) in irq_to_desc_alloc\n",
183 irq, NR_IRQS); 197 irq, nr_irqs);
184 WARN_ON(1);
185 return NULL; 198 return NULL;
186 } 199 }
187 200
@@ -223,9 +236,6 @@ struct irq_desc irq_desc[NR_IRQS] __cacheline_aligned_in_smp = {
223 .handle_irq = handle_bad_irq, 236 .handle_irq = handle_bad_irq,
224 .depth = 1, 237 .depth = 1,
225 .lock = __SPIN_LOCK_UNLOCKED(irq_desc->lock), 238 .lock = __SPIN_LOCK_UNLOCKED(irq_desc->lock),
226#ifdef CONFIG_SMP
227 .affinity = CPU_MASK_ALL
228#endif
229 } 239 }
230}; 240};
231 241
@@ -238,14 +248,16 @@ int __init early_irq_init(void)
238 248
239 init_irq_default_affinity(); 249 init_irq_default_affinity();
240 250
251 printk(KERN_INFO "NR_IRQS:%d\n", NR_IRQS);
252
241 desc = irq_desc; 253 desc = irq_desc;
242 count = ARRAY_SIZE(irq_desc); 254 count = ARRAY_SIZE(irq_desc);
243 255
244 for (i = 0; i < count; i++) { 256 for (i = 0; i < count; i++) {
245 desc[i].irq = i; 257 desc[i].irq = i;
258 init_alloc_desc_masks(&desc[i], 0, true);
246 desc[i].kstat_irqs = kstat_irqs_all[i]; 259 desc[i].kstat_irqs = kstat_irqs_all[i];
247 } 260 }
248
249 return arch_early_irq_init(); 261 return arch_early_irq_init();
250} 262}
251 263