diff options
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 4709a7c870d7..412370ab9a34 100644 --- a/kernel/irq/handle.c +++ b/kernel/irq/handle.c | |||
| @@ -18,6 +18,7 @@ | |||
| 18 | #include <linux/rculist.h> | 18 | #include <linux/rculist.h> |
| 19 | #include <linux/hash.h> | 19 | #include <linux/hash.h> |
| 20 | #include <trace/irq.h> | 20 | #include <trace/irq.h> |
| 21 | #include <linux/bootmem.h> | ||
| 21 | 22 | ||
| 22 | #include "internals.h" | 23 | #include "internals.h" |
| 23 | 24 | ||
| @@ -70,6 +71,7 @@ int nr_irqs = NR_IRQS; | |||
| 70 | EXPORT_SYMBOL_GPL(nr_irqs); | 71 | EXPORT_SYMBOL_GPL(nr_irqs); |
| 71 | 72 | ||
| 72 | #ifdef CONFIG_SPARSE_IRQ | 73 | #ifdef CONFIG_SPARSE_IRQ |
| 74 | |||
| 73 | static struct irq_desc irq_desc_init = { | 75 | static struct irq_desc irq_desc_init = { |
| 74 | .irq = -1, | 76 | .irq = -1, |
| 75 | .status = IRQ_DISABLED, | 77 | .status = IRQ_DISABLED, |
| @@ -77,9 +79,6 @@ static struct irq_desc irq_desc_init = { | |||
| 77 | .handle_irq = handle_bad_irq, | 79 | .handle_irq = handle_bad_irq, |
| 78 | .depth = 1, | 80 | .depth = 1, |
| 79 | .lock = __SPIN_LOCK_UNLOCKED(irq_desc_init.lock), | 81 | .lock = __SPIN_LOCK_UNLOCKED(irq_desc_init.lock), |
| 80 | #ifdef CONFIG_SMP | ||
| 81 | .affinity = CPU_MASK_ALL | ||
| 82 | #endif | ||
| 83 | }; | 82 | }; |
| 84 | 83 | ||
| 85 | void init_kstat_irqs(struct irq_desc *desc, int cpu, int nr) | 84 | void init_kstat_irqs(struct irq_desc *desc, int cpu, int nr) |
| @@ -114,6 +113,10 @@ static void init_one_irq_desc(int irq, struct irq_desc *desc, int cpu) | |||
| 114 | printk(KERN_ERR "can not alloc kstat_irqs\n"); | 113 | printk(KERN_ERR "can not alloc kstat_irqs\n"); |
| 115 | BUG_ON(1); | 114 | BUG_ON(1); |
| 116 | } | 115 | } |
| 116 | if (!init_alloc_desc_masks(desc, cpu, false)) { | ||
| 117 | printk(KERN_ERR "can not alloc irq_desc cpumasks\n"); | ||
| 118 | BUG_ON(1); | ||
| 119 | } | ||
| 117 | arch_init_chip_data(desc, cpu); | 120 | arch_init_chip_data(desc, cpu); |
| 118 | } | 121 | } |
| 119 | 122 | ||
| @@ -122,7 +125,7 @@ static void init_one_irq_desc(int irq, struct irq_desc *desc, int cpu) | |||
| 122 | */ | 125 | */ |
| 123 | DEFINE_SPINLOCK(sparse_irq_lock); | 126 | DEFINE_SPINLOCK(sparse_irq_lock); |
| 124 | 127 | ||
| 125 | struct irq_desc *irq_desc_ptrs[NR_IRQS] __read_mostly; | 128 | struct irq_desc **irq_desc_ptrs __read_mostly; |
| 126 | 129 | ||
| 127 | static struct irq_desc irq_desc_legacy[NR_IRQS_LEGACY] __cacheline_aligned_in_smp = { | 130 | static struct irq_desc irq_desc_legacy[NR_IRQS_LEGACY] __cacheline_aligned_in_smp = { |
| 128 | [0 ... NR_IRQS_LEGACY-1] = { | 131 | [0 ... NR_IRQS_LEGACY-1] = { |
| @@ -132,14 +135,10 @@ static struct irq_desc irq_desc_legacy[NR_IRQS_LEGACY] __cacheline_aligned_in_sm | |||
| 132 | .handle_irq = handle_bad_irq, | 135 | .handle_irq = handle_bad_irq, |
| 133 | .depth = 1, | 136 | .depth = 1, |
| 134 | .lock = __SPIN_LOCK_UNLOCKED(irq_desc_init.lock), | 137 | .lock = __SPIN_LOCK_UNLOCKED(irq_desc_init.lock), |
| 135 | #ifdef CONFIG_SMP | ||
| 136 | .affinity = CPU_MASK_ALL | ||
| 137 | #endif | ||
| 138 | } | 138 | } |
| 139 | }; | 139 | }; |
| 140 | 140 | ||
| 141 | /* FIXME: use bootmem alloc ...*/ | 141 | static unsigned int *kstat_irqs_legacy; |
| 142 | static unsigned int kstat_irqs_legacy[NR_IRQS_LEGACY][NR_CPUS]; | ||
| 143 | 142 | ||
| 144 | int __init early_irq_init(void) | 143 | int __init early_irq_init(void) |
| 145 | { | 144 | { |
| @@ -149,18 +148,30 @@ int __init early_irq_init(void) | |||
| 149 | 148 | ||
| 150 | init_irq_default_affinity(); | 149 | init_irq_default_affinity(); |
| 151 | 150 | ||
| 151 | /* initialize nr_irqs based on nr_cpu_ids */ | ||
| 152 | arch_probe_nr_irqs(); | ||
| 153 | printk(KERN_INFO "NR_IRQS:%d nr_irqs:%d\n", NR_IRQS, nr_irqs); | ||
| 154 | |||
| 152 | desc = irq_desc_legacy; | 155 | desc = irq_desc_legacy; |
| 153 | legacy_count = ARRAY_SIZE(irq_desc_legacy); | 156 | legacy_count = ARRAY_SIZE(irq_desc_legacy); |
| 154 | 157 | ||
| 158 | /* allocate irq_desc_ptrs array based on nr_irqs */ | ||
| 159 | irq_desc_ptrs = alloc_bootmem(nr_irqs * sizeof(void *)); | ||
| 160 | |||
| 161 | /* allocate based on nr_cpu_ids */ | ||
| 162 | /* FIXME: invert kstat_irgs, and it'd be a per_cpu_alloc'd thing */ | ||
| 163 | kstat_irqs_legacy = alloc_bootmem(NR_IRQS_LEGACY * nr_cpu_ids * | ||
| 164 | sizeof(int)); | ||
| 165 | |||
| 155 | for (i = 0; i < legacy_count; i++) { | 166 | for (i = 0; i < legacy_count; i++) { |
| 156 | desc[i].irq = i; | 167 | desc[i].irq = i; |
| 157 | desc[i].kstat_irqs = kstat_irqs_legacy[i]; | 168 | desc[i].kstat_irqs = kstat_irqs_legacy + i * nr_cpu_ids; |
| 158 | lockdep_set_class(&desc[i].lock, &irq_desc_lock_class); | 169 | lockdep_set_class(&desc[i].lock, &irq_desc_lock_class); |
| 159 | 170 | init_alloc_desc_masks(&desc[i], 0, true); | |
| 160 | irq_desc_ptrs[i] = desc + i; | 171 | irq_desc_ptrs[i] = desc + i; |
| 161 | } | 172 | } |
| 162 | 173 | ||
| 163 | for (i = legacy_count; i < NR_IRQS; i++) | 174 | for (i = legacy_count; i < nr_irqs; i++) |
| 164 | irq_desc_ptrs[i] = NULL; | 175 | irq_desc_ptrs[i] = NULL; |
| 165 | 176 | ||
| 166 | return arch_early_irq_init(); | 177 | return arch_early_irq_init(); |
| @@ -168,7 +179,10 @@ int __init early_irq_init(void) | |||
| 168 | 179 | ||
| 169 | struct irq_desc *irq_to_desc(unsigned int irq) | 180 | struct irq_desc *irq_to_desc(unsigned int irq) |
| 170 | { | 181 | { |
| 171 | return (irq < NR_IRQS) ? irq_desc_ptrs[irq] : NULL; | 182 | if (irq_desc_ptrs && irq < nr_irqs) |
| 183 | return irq_desc_ptrs[irq]; | ||
| 184 | |||
| 185 | return NULL; | ||
| 172 | } | 186 | } |
| 173 | 187 | ||
| 174 | struct irq_desc *irq_to_desc_alloc_cpu(unsigned int irq, int cpu) | 188 | struct irq_desc *irq_to_desc_alloc_cpu(unsigned int irq, int cpu) |
| @@ -177,10 +191,9 @@ struct irq_desc *irq_to_desc_alloc_cpu(unsigned int irq, int cpu) | |||
| 177 | unsigned long flags; | 191 | unsigned long flags; |
| 178 | int node; | 192 | int node; |
| 179 | 193 | ||
| 180 | if (irq >= NR_IRQS) { | 194 | if (irq >= nr_irqs) { |
| 181 | printk(KERN_WARNING "irq >= NR_IRQS in irq_to_desc_alloc: %d %d\n", | 195 | WARN(1, "irq (%d) >= nr_irqs (%d) in irq_to_desc_alloc\n", |
| 182 | irq, NR_IRQS); | 196 | irq, nr_irqs); |
| 183 | WARN_ON(1); | ||
| 184 | return NULL; | 197 | return NULL; |
| 185 | } | 198 | } |
| 186 | 199 | ||
| @@ -222,9 +235,6 @@ struct irq_desc irq_desc[NR_IRQS] __cacheline_aligned_in_smp = { | |||
| 222 | .handle_irq = handle_bad_irq, | 235 | .handle_irq = handle_bad_irq, |
| 223 | .depth = 1, | 236 | .depth = 1, |
| 224 | .lock = __SPIN_LOCK_UNLOCKED(irq_desc->lock), | 237 | .lock = __SPIN_LOCK_UNLOCKED(irq_desc->lock), |
| 225 | #ifdef CONFIG_SMP | ||
| 226 | .affinity = CPU_MASK_ALL | ||
| 227 | #endif | ||
| 228 | } | 238 | } |
| 229 | }; | 239 | }; |
| 230 | 240 | ||
| @@ -236,12 +246,15 @@ int __init early_irq_init(void) | |||
| 236 | 246 | ||
| 237 | init_irq_default_affinity(); | 247 | init_irq_default_affinity(); |
| 238 | 248 | ||
| 249 | printk(KERN_INFO "NR_IRQS:%d\n", NR_IRQS); | ||
| 250 | |||
| 239 | desc = irq_desc; | 251 | desc = irq_desc; |
| 240 | count = ARRAY_SIZE(irq_desc); | 252 | count = ARRAY_SIZE(irq_desc); |
| 241 | 253 | ||
| 242 | for (i = 0; i < count; i++) | 254 | for (i = 0; i < count; i++) { |
| 243 | desc[i].irq = i; | 255 | desc[i].irq = i; |
| 244 | 256 | init_alloc_desc_masks(&desc[i], 0, true); | |
| 257 | } | ||
| 245 | return arch_early_irq_init(); | 258 | return arch_early_irq_init(); |
| 246 | } | 259 | } |
| 247 | 260 | ||
