Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 212223
b: refs/heads/master
c: a05a900
h: refs/heads/master
i:
  212221: 9e7fcd6
  212219: 1d4691c
  212215: 7f8a725
  212207: 91ce171
  212191: b54649a
  212159: 126bc38
  212095: 2f8535c
  211967: 16b8970
v: v3
  • Loading branch information
Thomas Gleixner committed Oct 12, 2010
1 parent b91676d commit c6deadd
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 20 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: c2f31c37b7303150ffcce53f6c6ed4ac62952b34
refs/heads/master: a05a900a51c7622ebd8ddb41f14f8bf9db599d8d
33 changes: 14 additions & 19 deletions trunk/kernel/irq/irqdesc.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ static void desc_set_defaults(unsigned int irq, struct irq_desc *desc, int node)
int nr_irqs = NR_IRQS;
EXPORT_SYMBOL_GPL(nr_irqs);

static DEFINE_RAW_SPINLOCK(sparse_irq_lock);
static DEFINE_MUTEX(sparse_irq_lock);
static DECLARE_BITMAP(allocated_irqs, NR_IRQS);

#ifdef CONFIG_SPARSE_IRQ
Expand Down Expand Up @@ -159,13 +159,12 @@ static struct irq_desc *alloc_desc(int irq, int node)
static void free_desc(unsigned int irq)
{
struct irq_desc *desc = irq_to_desc(irq);
unsigned long flags;

unregister_irq_proc(irq, desc);

raw_spin_lock_irqsave(&sparse_irq_lock, flags);
mutex_lock(&sparse_irq_lock);
delete_irq_desc(irq);
raw_spin_unlock_irqrestore(&sparse_irq_lock, flags);
mutex_unlock(&sparse_irq_lock);

free_masks(desc);
kfree(desc->kstat_irqs);
Expand All @@ -175,26 +174,25 @@ static void free_desc(unsigned int irq)
static int alloc_descs(unsigned int start, unsigned int cnt, int node)
{
struct irq_desc *desc;
unsigned long flags;
int i;

for (i = 0; i < cnt; i++) {
desc = alloc_desc(start + i, node);
if (!desc)
goto err;
raw_spin_lock_irqsave(&sparse_irq_lock, flags);
mutex_lock(&sparse_irq_lock);
irq_insert_desc(start + i, desc);
raw_spin_unlock_irqrestore(&sparse_irq_lock, flags);
mutex_unlock(&sparse_irq_lock);
}
return start;

err:
for (i--; i >= 0; i--)
free_desc(start + i);

raw_spin_lock_irqsave(&sparse_irq_lock, flags);
mutex_lock(&sparse_irq_lock);
bitmap_clear(allocated_irqs, start, cnt);
raw_spin_unlock_irqrestore(&sparse_irq_lock, flags);
mutex_unlock(&sparse_irq_lock);
return -ENOMEM;
}

Expand Down Expand Up @@ -291,7 +289,6 @@ static inline int alloc_descs(unsigned int start, unsigned int cnt, int node)
*/
void irq_free_descs(unsigned int from, unsigned int cnt)
{
unsigned long flags;
int i;

if (from >= nr_irqs || (from + cnt) > nr_irqs)
Expand All @@ -300,9 +297,9 @@ void irq_free_descs(unsigned int from, unsigned int cnt)
for (i = 0; i < cnt; i++)
free_desc(from + i);

raw_spin_lock_irqsave(&sparse_irq_lock, flags);
mutex_lock(&sparse_irq_lock);
bitmap_clear(allocated_irqs, from, cnt);
raw_spin_unlock_irqrestore(&sparse_irq_lock, flags);
mutex_unlock(&sparse_irq_lock);
}

/**
Expand All @@ -317,13 +314,12 @@ void irq_free_descs(unsigned int from, unsigned int cnt)
int __ref
irq_alloc_descs(int irq, unsigned int from, unsigned int cnt, int node)
{
unsigned long flags;
int start, ret;

if (!cnt)
return -EINVAL;

raw_spin_lock_irqsave(&sparse_irq_lock, flags);
mutex_lock(&sparse_irq_lock);

start = bitmap_find_next_zero_area(allocated_irqs, nr_irqs, from, cnt, 0);
ret = -EEXIST;
Expand All @@ -335,11 +331,11 @@ irq_alloc_descs(int irq, unsigned int from, unsigned int cnt, int node)
goto err;

bitmap_set(allocated_irqs, start, cnt);
raw_spin_unlock_irqrestore(&sparse_irq_lock, flags);
mutex_unlock(&sparse_irq_lock);
return alloc_descs(start, cnt, node);

err:
raw_spin_unlock_irqrestore(&sparse_irq_lock, flags);
mutex_unlock(&sparse_irq_lock);
return ret;
}

Expand All @@ -352,20 +348,19 @@ irq_alloc_descs(int irq, unsigned int from, unsigned int cnt, int node)
*/
int irq_reserve_irqs(unsigned int from, unsigned int cnt)
{
unsigned long flags;
unsigned int start;
int ret = 0;

if (!cnt || (from + cnt) > nr_irqs)
return -EINVAL;

raw_spin_lock_irqsave(&sparse_irq_lock, flags);
mutex_lock(&sparse_irq_lock);
start = bitmap_find_next_zero_area(allocated_irqs, nr_irqs, from, cnt, 0);
if (start == from)
bitmap_set(allocated_irqs, start, cnt);
else
ret = -EEXIST;
raw_spin_unlock_irqrestore(&sparse_irq_lock, flags);
mutex_unlock(&sparse_irq_lock);
return ret;
}

Expand Down

0 comments on commit c6deadd

Please sign in to comment.