diff options
author | Paul Mundt <lethal@linux-sh.org> | 2009-05-21 21:40:09 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-05-23 08:55:24 -0400 |
commit | 948cd52906baf1f92aeea2f9b5c515db1b2e592a (patch) | |
tree | a03482aebb7f8ed0b1706db8d6cd105f79ea53cc /kernel/irq/handle.c | |
parent | 4c6f18fc81565967da20f2d4a3922cdba33f8e2b (diff) |
sparseirq: Allow early irq_desc allocation
Presently non-legacy IRQs have their irq_desc allocated with
kzalloc_node(). This assumes that all callers of irq_to_desc_node_alloc()
will be sufficiently late in the boot process that kmalloc is available.
While porting sparseirq support to sh this blew up immediately, as at the
time that we register the CPU's interrupt vector map only bootmem is
available. Check slab_is_available() to work out which path to use.
[ Impact: fix SH early boot crash with sparseirq enabled ]
Signed-off-by: Paul Mundt <lethal@linux-sh.org>
Acked-by: Yinghai Lu <yinghai@kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Mel Gorman <mel@csn.ul.ie>
LKML-Reference: <20090522014008.GA2806@linux-sh.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'kernel/irq/handle.c')
-rw-r--r-- | kernel/irq/handle.c | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/kernel/irq/handle.c b/kernel/irq/handle.c index a3c671e0f165..18041a254d32 100644 --- a/kernel/irq/handle.c +++ b/kernel/irq/handle.c | |||
@@ -11,6 +11,7 @@ | |||
11 | */ | 11 | */ |
12 | 12 | ||
13 | #include <linux/irq.h> | 13 | #include <linux/irq.h> |
14 | #include <linux/slab.h> | ||
14 | #include <linux/module.h> | 15 | #include <linux/module.h> |
15 | #include <linux/random.h> | 16 | #include <linux/random.h> |
16 | #include <linux/interrupt.h> | 17 | #include <linux/interrupt.h> |
@@ -81,11 +82,16 @@ static struct irq_desc irq_desc_init = { | |||
81 | .lock = __SPIN_LOCK_UNLOCKED(irq_desc_init.lock), | 82 | .lock = __SPIN_LOCK_UNLOCKED(irq_desc_init.lock), |
82 | }; | 83 | }; |
83 | 84 | ||
84 | void init_kstat_irqs(struct irq_desc *desc, int node, int nr) | 85 | void __ref init_kstat_irqs(struct irq_desc *desc, int node, int nr) |
85 | { | 86 | { |
86 | void *ptr; | 87 | void *ptr; |
87 | 88 | ||
88 | ptr = kzalloc_node(nr * sizeof(*desc->kstat_irqs), GFP_ATOMIC, node); | 89 | if (slab_is_available()) |
90 | ptr = kzalloc_node(nr * sizeof(*desc->kstat_irqs), | ||
91 | GFP_ATOMIC, node); | ||
92 | else | ||
93 | ptr = alloc_bootmem_node(NODE_DATA(node), | ||
94 | nr * sizeof(*desc->kstat_irqs)); | ||
89 | 95 | ||
90 | /* | 96 | /* |
91 | * don't overwite if can not get new one | 97 | * don't overwite if can not get new one |
@@ -186,7 +192,7 @@ struct irq_desc *irq_to_desc(unsigned int irq) | |||
186 | return NULL; | 192 | return NULL; |
187 | } | 193 | } |
188 | 194 | ||
189 | struct irq_desc *irq_to_desc_alloc_node(unsigned int irq, int node) | 195 | struct irq_desc * __ref irq_to_desc_alloc_node(unsigned int irq, int node) |
190 | { | 196 | { |
191 | struct irq_desc *desc; | 197 | struct irq_desc *desc; |
192 | unsigned long flags; | 198 | unsigned long flags; |
@@ -208,7 +214,11 @@ struct irq_desc *irq_to_desc_alloc_node(unsigned int irq, int node) | |||
208 | if (desc) | 214 | if (desc) |
209 | goto out_unlock; | 215 | goto out_unlock; |
210 | 216 | ||
211 | desc = kzalloc_node(sizeof(*desc), GFP_ATOMIC, node); | 217 | if (slab_is_available()) |
218 | desc = kzalloc_node(sizeof(*desc), GFP_ATOMIC, node); | ||
219 | else | ||
220 | desc = alloc_bootmem_node(NODE_DATA(node), sizeof(*desc)); | ||
221 | |||
212 | printk(KERN_DEBUG " alloc irq_desc for %d on node %d\n", irq, node); | 222 | printk(KERN_DEBUG " alloc irq_desc for %d on node %d\n", irq, node); |
213 | if (!desc) { | 223 | if (!desc) { |
214 | printk(KERN_ERR "can not alloc irq_desc\n"); | 224 | printk(KERN_ERR "can not alloc irq_desc\n"); |