Commit 948cd529 authored by Paul Mundt's avatar Paul Mundt Committed by Ingo Molnar

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: default avatarPaul Mundt <lethal@linux-sh.org>
Acked-by: default avatarYinghai 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: default avatarIngo Molnar <mingo@elte.hu>
parent 4c6f18fc
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
*/ */
#include <linux/irq.h> #include <linux/irq.h>
#include <linux/slab.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/random.h> #include <linux/random.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
...@@ -81,11 +82,16 @@ static struct irq_desc irq_desc_init = { ...@@ -81,11 +82,16 @@ static struct irq_desc irq_desc_init = {
.lock = __SPIN_LOCK_UNLOCKED(irq_desc_init.lock), .lock = __SPIN_LOCK_UNLOCKED(irq_desc_init.lock),
}; };
void init_kstat_irqs(struct irq_desc *desc, int node, int nr) void __ref init_kstat_irqs(struct irq_desc *desc, int node, int nr)
{ {
void *ptr; void *ptr;
ptr = kzalloc_node(nr * sizeof(*desc->kstat_irqs), GFP_ATOMIC, node); if (slab_is_available())
ptr = kzalloc_node(nr * sizeof(*desc->kstat_irqs),
GFP_ATOMIC, node);
else
ptr = alloc_bootmem_node(NODE_DATA(node),
nr * sizeof(*desc->kstat_irqs));
/* /*
* don't overwite if can not get new one * don't overwite if can not get new one
...@@ -186,7 +192,7 @@ struct irq_desc *irq_to_desc(unsigned int irq) ...@@ -186,7 +192,7 @@ struct irq_desc *irq_to_desc(unsigned int irq)
return NULL; return NULL;
} }
struct irq_desc *irq_to_desc_alloc_node(unsigned int irq, int node) struct irq_desc * __ref irq_to_desc_alloc_node(unsigned int irq, int node)
{ {
struct irq_desc *desc; struct irq_desc *desc;
unsigned long flags; unsigned long flags;
...@@ -208,7 +214,11 @@ struct irq_desc *irq_to_desc_alloc_node(unsigned int irq, int node) ...@@ -208,7 +214,11 @@ struct irq_desc *irq_to_desc_alloc_node(unsigned int irq, int node)
if (desc) if (desc)
goto out_unlock; goto out_unlock;
desc = kzalloc_node(sizeof(*desc), GFP_ATOMIC, node); if (slab_is_available())
desc = kzalloc_node(sizeof(*desc), GFP_ATOMIC, node);
else
desc = alloc_bootmem_node(NODE_DATA(node), sizeof(*desc));
printk(KERN_DEBUG " alloc irq_desc for %d on node %d\n", irq, node); printk(KERN_DEBUG " alloc irq_desc for %d on node %d\n", irq, node);
if (!desc) { if (!desc) {
printk(KERN_ERR "can not alloc irq_desc\n"); printk(KERN_ERR "can not alloc irq_desc\n");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment