diff options
author | Ingo Molnar <mingo@elte.hu> | 2009-01-28 17:12:55 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-01-28 17:12:55 -0500 |
commit | 6a385db5ce7f1fd2c68ec511e44587b67dab8fca (patch) | |
tree | 9324c8ae6f7be54b9fdbd6b60f759292aa727b1f /kernel/irq/handle.c | |
parent | 18e352e4a73465349711a9324767e1b2453383e2 (diff) | |
parent | 4369f1fb7cd4cf777312f43e1cb9aa5504fc4125 (diff) |
Merge branch 'core/percpu' into x86/core
Conflicts:
kernel/irq/handle.c
Diffstat (limited to 'kernel/irq/handle.c')
-rw-r--r-- | kernel/irq/handle.c | 57 |
1 files changed, 35 insertions, 22 deletions
diff --git a/kernel/irq/handle.c b/kernel/irq/handle.c index 3aba8d12f328..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 | ||
@@ -69,6 +70,7 @@ int nr_irqs = NR_IRQS; | |||
69 | EXPORT_SYMBOL_GPL(nr_irqs); | 70 | EXPORT_SYMBOL_GPL(nr_irqs); |
70 | 71 | ||
71 | #ifdef CONFIG_SPARSE_IRQ | 72 | #ifdef CONFIG_SPARSE_IRQ |
73 | |||
72 | static struct irq_desc irq_desc_init = { | 74 | static 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 | ||
84 | 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) |
@@ -113,6 +112,10 @@ static void init_one_irq_desc(int irq, struct irq_desc *desc, int cpu) | |||
113 | printk(KERN_ERR "can not alloc kstat_irqs\n"); | 112 | printk(KERN_ERR "can not alloc kstat_irqs\n"); |
114 | BUG_ON(1); | 113 | BUG_ON(1); |
115 | } | 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 | } | ||
116 | arch_init_chip_data(desc, cpu); | 119 | arch_init_chip_data(desc, cpu); |
117 | } | 120 | } |
118 | 121 | ||
@@ -121,7 +124,7 @@ static void init_one_irq_desc(int irq, struct irq_desc *desc, int cpu) | |||
121 | */ | 124 | */ |
122 | DEFINE_SPINLOCK(sparse_irq_lock); | 125 | DEFINE_SPINLOCK(sparse_irq_lock); |
123 | 126 | ||
124 | struct irq_desc *irq_desc_ptrs[NR_IRQS] __read_mostly; | 127 | struct irq_desc **irq_desc_ptrs __read_mostly; |
125 | 128 | ||
126 | 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 = { |
127 | [0 ... NR_IRQS_LEGACY-1] = { | 130 | [0 ... NR_IRQS_LEGACY-1] = { |
@@ -131,14 +134,10 @@ static struct irq_desc irq_desc_legacy[NR_IRQS_LEGACY] __cacheline_aligned_in_sm | |||
131 | .handle_irq = handle_bad_irq, | 134 | .handle_irq = handle_bad_irq, |
132 | .depth = 1, | 135 | .depth = 1, |
133 | .lock = __SPIN_LOCK_UNLOCKED(irq_desc_init.lock), | 136 | .lock = __SPIN_LOCK_UNLOCKED(irq_desc_init.lock), |
134 | #ifdef CONFIG_SMP | ||
135 | .affinity = CPU_MASK_ALL | ||
136 | #endif | ||
137 | } | 137 | } |
138 | }; | 138 | }; |
139 | 139 | ||
140 | /* FIXME: use bootmem alloc ...*/ | 140 | static unsigned int *kstat_irqs_legacy; |
141 | static unsigned int kstat_irqs_legacy[NR_IRQS_LEGACY][NR_CPUS]; | ||
142 | 141 | ||
143 | int __init early_irq_init(void) | 142 | int __init early_irq_init(void) |
144 | { | 143 | { |
@@ -148,18 +147,30 @@ int __init early_irq_init(void) | |||
148 | 147 | ||
149 | init_irq_default_affinity(); | 148 | init_irq_default_affinity(); |
150 | 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 | |||
151 | desc = irq_desc_legacy; | 154 | desc = irq_desc_legacy; |
152 | legacy_count = ARRAY_SIZE(irq_desc_legacy); | 155 | legacy_count = ARRAY_SIZE(irq_desc_legacy); |
153 | 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 | |||
154 | for (i = 0; i < legacy_count; i++) { | 165 | for (i = 0; i < legacy_count; i++) { |
155 | desc[i].irq = i; | 166 | desc[i].irq = i; |
156 | desc[i].kstat_irqs = kstat_irqs_legacy[i]; | 167 | desc[i].kstat_irqs = kstat_irqs_legacy + i * nr_cpu_ids; |
157 | lockdep_set_class(&desc[i].lock, &irq_desc_lock_class); | 168 | lockdep_set_class(&desc[i].lock, &irq_desc_lock_class); |
158 | 169 | init_alloc_desc_masks(&desc[i], 0, true); | |
159 | irq_desc_ptrs[i] = desc + i; | 170 | irq_desc_ptrs[i] = desc + i; |
160 | } | 171 | } |
161 | 172 | ||
162 | for (i = legacy_count; i < NR_IRQS; i++) | 173 | for (i = legacy_count; i < nr_irqs; i++) |
163 | irq_desc_ptrs[i] = NULL; | 174 | irq_desc_ptrs[i] = NULL; |
164 | 175 | ||
165 | return arch_early_irq_init(); | 176 | return arch_early_irq_init(); |
@@ -167,7 +178,10 @@ int __init early_irq_init(void) | |||
167 | 178 | ||
168 | struct irq_desc *irq_to_desc(unsigned int irq) | 179 | struct irq_desc *irq_to_desc(unsigned int irq) |
169 | { | 180 | { |
170 | 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; | ||
171 | } | 185 | } |
172 | 186 | ||
173 | 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) |
@@ -176,10 +190,9 @@ struct irq_desc *irq_to_desc_alloc_cpu(unsigned int irq, int cpu) | |||
176 | unsigned long flags; | 190 | unsigned long flags; |
177 | int node; | 191 | int node; |
178 | 192 | ||
179 | if (irq >= NR_IRQS) { | 193 | if (irq >= nr_irqs) { |
180 | 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", |
181 | irq, NR_IRQS); | 195 | irq, nr_irqs); |
182 | WARN_ON(1); | ||
183 | return NULL; | 196 | return NULL; |
184 | } | 197 | } |
185 | 198 | ||
@@ -221,9 +234,6 @@ struct irq_desc irq_desc[NR_IRQS] __cacheline_aligned_in_smp = { | |||
221 | .handle_irq = handle_bad_irq, | 234 | .handle_irq = handle_bad_irq, |
222 | .depth = 1, | 235 | .depth = 1, |
223 | .lock = __SPIN_LOCK_UNLOCKED(irq_desc->lock), | 236 | .lock = __SPIN_LOCK_UNLOCKED(irq_desc->lock), |
224 | #ifdef CONFIG_SMP | ||
225 | .affinity = CPU_MASK_ALL | ||
226 | #endif | ||
227 | } | 237 | } |
228 | }; | 238 | }; |
229 | 239 | ||
@@ -235,12 +245,15 @@ int __init early_irq_init(void) | |||
235 | 245 | ||
236 | init_irq_default_affinity(); | 246 | init_irq_default_affinity(); |
237 | 247 | ||
248 | printk(KERN_INFO "NR_IRQS:%d\n", NR_IRQS); | ||
249 | |||
238 | desc = irq_desc; | 250 | desc = irq_desc; |
239 | count = ARRAY_SIZE(irq_desc); | 251 | count = ARRAY_SIZE(irq_desc); |
240 | 252 | ||
241 | for (i = 0; i < count; i++) | 253 | for (i = 0; i < count; i++) { |
242 | desc[i].irq = i; | 254 | desc[i].irq = i; |
243 | 255 | init_alloc_desc_masks(&desc[i], 0, true); | |
256 | } | ||
244 | return arch_early_irq_init(); | 257 | return arch_early_irq_init(); |
245 | } | 258 | } |
246 | 259 | ||