mirror of
https://github.com/adulau/aha.git
synced 2025-01-04 07:03:38 +00:00
x86: sparse_irq needs spin_lock in allocations
Suresh Siddha noticed that we should have a spinlock around it. Signed-off-by: Yinghai Lu <yhlu.kernel@gmail.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
This commit is contained in:
parent
7ddfb650c7
commit
e89eb43863
2 changed files with 24 additions and 2 deletions
|
@ -146,6 +146,12 @@ static void init_one_irq_cfg(struct irq_cfg *cfg)
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct irq_cfg *irq_cfgx;
|
static struct irq_cfg *irq_cfgx;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Protect the irq_cfgx_free freelist:
|
||||||
|
*/
|
||||||
|
static DEFINE_SPINLOCK(irq_cfg_lock);
|
||||||
|
|
||||||
#ifdef CONFIG_HAVE_SPARSE_IRQ
|
#ifdef CONFIG_HAVE_SPARSE_IRQ
|
||||||
static struct irq_cfg *irq_cfgx_free;
|
static struct irq_cfg *irq_cfgx_free;
|
||||||
#endif
|
#endif
|
||||||
|
@ -213,8 +219,9 @@ static struct irq_cfg *irq_cfg(unsigned int irq)
|
||||||
static struct irq_cfg *irq_cfg_alloc(unsigned int irq)
|
static struct irq_cfg *irq_cfg_alloc(unsigned int irq)
|
||||||
{
|
{
|
||||||
struct irq_cfg *cfg, *cfg_pri;
|
struct irq_cfg *cfg, *cfg_pri;
|
||||||
int i;
|
unsigned long flags;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
int i;
|
||||||
|
|
||||||
cfg_pri = cfg = irq_cfgx;
|
cfg_pri = cfg = irq_cfgx;
|
||||||
while (cfg) {
|
while (cfg) {
|
||||||
|
@ -226,6 +233,7 @@ static struct irq_cfg *irq_cfg_alloc(unsigned int irq)
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
spin_lock_irqsave(&irq_cfg_lock, flags);
|
||||||
if (!irq_cfgx_free) {
|
if (!irq_cfgx_free) {
|
||||||
unsigned long phys;
|
unsigned long phys;
|
||||||
unsigned long total_bytes;
|
unsigned long total_bytes;
|
||||||
|
@ -263,6 +271,9 @@ static struct irq_cfg *irq_cfg_alloc(unsigned int irq)
|
||||||
else
|
else
|
||||||
irq_cfgx = cfg;
|
irq_cfgx = cfg;
|
||||||
cfg->irq = irq;
|
cfg->irq = irq;
|
||||||
|
|
||||||
|
spin_unlock_irqrestore(&irq_cfg_lock, flags);
|
||||||
|
|
||||||
printk(KERN_DEBUG "found new irq_cfg for irq %d\n", cfg->irq);
|
printk(KERN_DEBUG "found new irq_cfg for irq %d\n", cfg->irq);
|
||||||
#ifdef CONFIG_HAVE_SPARSE_IRQ_DEBUG
|
#ifdef CONFIG_HAVE_SPARSE_IRQ_DEBUG
|
||||||
{
|
{
|
||||||
|
|
|
@ -107,6 +107,11 @@ static void init_kstat_irqs(struct irq_desc *desc, int nr_desc, int nr)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Protect the sparse_irqs_free freelist:
|
||||||
|
*/
|
||||||
|
static DEFINE_SPINLOCK(sparse_irq_lock);
|
||||||
|
|
||||||
#ifdef CONFIG_HAVE_SPARSE_IRQ
|
#ifdef CONFIG_HAVE_SPARSE_IRQ
|
||||||
static struct irq_desc *sparse_irqs_free;
|
static struct irq_desc *sparse_irqs_free;
|
||||||
struct irq_desc *sparse_irqs;
|
struct irq_desc *sparse_irqs;
|
||||||
|
@ -166,11 +171,13 @@ struct irq_desc *irq_to_desc(unsigned int irq)
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct irq_desc *irq_to_desc_alloc(unsigned int irq)
|
struct irq_desc *irq_to_desc_alloc(unsigned int irq)
|
||||||
{
|
{
|
||||||
struct irq_desc *desc, *desc_pri;
|
struct irq_desc *desc, *desc_pri;
|
||||||
int i;
|
unsigned long flags;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
int i;
|
||||||
|
|
||||||
desc_pri = desc = sparse_irqs;
|
desc_pri = desc = sparse_irqs;
|
||||||
while (desc) {
|
while (desc) {
|
||||||
|
@ -182,6 +189,7 @@ struct irq_desc *irq_to_desc_alloc(unsigned int irq)
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
spin_lock_irqsave(&sparse_irq_lock, flags);
|
||||||
/*
|
/*
|
||||||
* we run out of pre-allocate ones, allocate more
|
* we run out of pre-allocate ones, allocate more
|
||||||
*/
|
*/
|
||||||
|
@ -223,6 +231,9 @@ struct irq_desc *irq_to_desc_alloc(unsigned int irq)
|
||||||
else
|
else
|
||||||
sparse_irqs = desc;
|
sparse_irqs = desc;
|
||||||
desc->irq = irq;
|
desc->irq = irq;
|
||||||
|
|
||||||
|
spin_unlock_irqrestore(&sparse_irq_lock, flags);
|
||||||
|
|
||||||
printk(KERN_DEBUG "found new irq_desc for irq %d\n", desc->irq);
|
printk(KERN_DEBUG "found new irq_desc for irq %d\n", desc->irq);
|
||||||
#ifdef CONFIG_HAVE_SPARSE_IRQ_DEBUG
|
#ifdef CONFIG_HAVE_SPARSE_IRQ_DEBUG
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue