aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/irq
diff options
context:
space:
mode:
authorThomas Gleixner <tglx@linutronix.de>2010-10-08 06:47:53 -0400
committerThomas Gleixner <tglx@linutronix.de>2010-10-12 10:53:45 -0400
commita05a900a51c7622ebd8ddb41f14f8bf9db599d8d (patch)
tree3c0f7d5c6aff2af86c350c76cc44631e620d9333 /kernel/irq
parentc2f31c37b7303150ffcce53f6c6ed4ac62952b34 (diff)
genirq: Make sparse_lock a mutex
No callers from atomic regions. Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Reviewed-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'kernel/irq')
-rw-r--r--kernel/irq/irqdesc.c33
1 files changed, 14 insertions, 19 deletions
diff --git a/kernel/irq/irqdesc.c b/kernel/irq/irqdesc.c
index 4f0b9c9d5c46..0e302f90d2ee 100644
--- a/kernel/irq/irqdesc.c
+++ b/kernel/irq/irqdesc.c
@@ -90,7 +90,7 @@ static void desc_set_defaults(unsigned int irq, struct irq_desc *desc, int node)
90int nr_irqs = NR_IRQS; 90int nr_irqs = NR_IRQS;
91EXPORT_SYMBOL_GPL(nr_irqs); 91EXPORT_SYMBOL_GPL(nr_irqs);
92 92
93static DEFINE_RAW_SPINLOCK(sparse_irq_lock); 93static DEFINE_MUTEX(sparse_irq_lock);
94static DECLARE_BITMAP(allocated_irqs, NR_IRQS); 94static DECLARE_BITMAP(allocated_irqs, NR_IRQS);
95 95
96#ifdef CONFIG_SPARSE_IRQ 96#ifdef CONFIG_SPARSE_IRQ
@@ -159,13 +159,12 @@ err_desc:
159static void free_desc(unsigned int irq) 159static void free_desc(unsigned int irq)
160{ 160{
161 struct irq_desc *desc = irq_to_desc(irq); 161 struct irq_desc *desc = irq_to_desc(irq);
162 unsigned long flags;
163 162
164 unregister_irq_proc(irq, desc); 163 unregister_irq_proc(irq, desc);
165 164
166 raw_spin_lock_irqsave(&sparse_irq_lock, flags); 165 mutex_lock(&sparse_irq_lock);
167 delete_irq_desc(irq); 166 delete_irq_desc(irq);
168 raw_spin_unlock_irqrestore(&sparse_irq_lock, flags); 167 mutex_unlock(&sparse_irq_lock);
169 168
170 free_masks(desc); 169 free_masks(desc);
171 kfree(desc->kstat_irqs); 170 kfree(desc->kstat_irqs);
@@ -175,16 +174,15 @@ static void free_desc(unsigned int irq)
175static int alloc_descs(unsigned int start, unsigned int cnt, int node) 174static int alloc_descs(unsigned int start, unsigned int cnt, int node)
176{ 175{
177 struct irq_desc *desc; 176 struct irq_desc *desc;
178 unsigned long flags;
179 int i; 177 int i;
180 178
181 for (i = 0; i < cnt; i++) { 179 for (i = 0; i < cnt; i++) {
182 desc = alloc_desc(start + i, node); 180 desc = alloc_desc(start + i, node);
183 if (!desc) 181 if (!desc)
184 goto err; 182 goto err;
185 raw_spin_lock_irqsave(&sparse_irq_lock, flags); 183 mutex_lock(&sparse_irq_lock);
186 irq_insert_desc(start + i, desc); 184 irq_insert_desc(start + i, desc);
187 raw_spin_unlock_irqrestore(&sparse_irq_lock, flags); 185 mutex_unlock(&sparse_irq_lock);
188 } 186 }
189 return start; 187 return start;
190 188
@@ -192,9 +190,9 @@ err:
192 for (i--; i >= 0; i--) 190 for (i--; i >= 0; i--)
193 free_desc(start + i); 191 free_desc(start + i);
194 192
195 raw_spin_lock_irqsave(&sparse_irq_lock, flags); 193 mutex_lock(&sparse_irq_lock);
196 bitmap_clear(allocated_irqs, start, cnt); 194 bitmap_clear(allocated_irqs, start, cnt);
197 raw_spin_unlock_irqrestore(&sparse_irq_lock, flags); 195 mutex_unlock(&sparse_irq_lock);
198 return -ENOMEM; 196 return -ENOMEM;
199} 197}
200 198
@@ -291,7 +289,6 @@ static inline int alloc_descs(unsigned int start, unsigned int cnt, int node)
291 */ 289 */
292void irq_free_descs(unsigned int from, unsigned int cnt) 290void irq_free_descs(unsigned int from, unsigned int cnt)
293{ 291{
294 unsigned long flags;
295 int i; 292 int i;
296 293
297 if (from >= nr_irqs || (from + cnt) > nr_irqs) 294 if (from >= nr_irqs || (from + cnt) > nr_irqs)
@@ -300,9 +297,9 @@ void irq_free_descs(unsigned int from, unsigned int cnt)
300 for (i = 0; i < cnt; i++) 297 for (i = 0; i < cnt; i++)
301 free_desc(from + i); 298 free_desc(from + i);
302 299
303 raw_spin_lock_irqsave(&sparse_irq_lock, flags); 300 mutex_lock(&sparse_irq_lock);
304 bitmap_clear(allocated_irqs, from, cnt); 301 bitmap_clear(allocated_irqs, from, cnt);
305 raw_spin_unlock_irqrestore(&sparse_irq_lock, flags); 302 mutex_unlock(&sparse_irq_lock);
306} 303}
307 304
308/** 305/**
@@ -317,13 +314,12 @@ void irq_free_descs(unsigned int from, unsigned int cnt)
317int __ref 314int __ref
318irq_alloc_descs(int irq, unsigned int from, unsigned int cnt, int node) 315irq_alloc_descs(int irq, unsigned int from, unsigned int cnt, int node)
319{ 316{
320 unsigned long flags;
321 int start, ret; 317 int start, ret;
322 318
323 if (!cnt) 319 if (!cnt)
324 return -EINVAL; 320 return -EINVAL;
325 321
326 raw_spin_lock_irqsave(&sparse_irq_lock, flags); 322 mutex_lock(&sparse_irq_lock);
327 323
328 start = bitmap_find_next_zero_area(allocated_irqs, nr_irqs, from, cnt, 0); 324 start = bitmap_find_next_zero_area(allocated_irqs, nr_irqs, from, cnt, 0);
329 ret = -EEXIST; 325 ret = -EEXIST;
@@ -335,11 +331,11 @@ irq_alloc_descs(int irq, unsigned int from, unsigned int cnt, int node)
335 goto err; 331 goto err;
336 332
337 bitmap_set(allocated_irqs, start, cnt); 333 bitmap_set(allocated_irqs, start, cnt);
338 raw_spin_unlock_irqrestore(&sparse_irq_lock, flags); 334 mutex_unlock(&sparse_irq_lock);
339 return alloc_descs(start, cnt, node); 335 return alloc_descs(start, cnt, node);
340 336
341err: 337err:
342 raw_spin_unlock_irqrestore(&sparse_irq_lock, flags); 338 mutex_unlock(&sparse_irq_lock);
343 return ret; 339 return ret;
344} 340}
345 341
@@ -352,20 +348,19 @@ err:
352 */ 348 */
353int irq_reserve_irqs(unsigned int from, unsigned int cnt) 349int irq_reserve_irqs(unsigned int from, unsigned int cnt)
354{ 350{
355 unsigned long flags;
356 unsigned int start; 351 unsigned int start;
357 int ret = 0; 352 int ret = 0;
358 353
359 if (!cnt || (from + cnt) > nr_irqs) 354 if (!cnt || (from + cnt) > nr_irqs)
360 return -EINVAL; 355 return -EINVAL;
361 356
362 raw_spin_lock_irqsave(&sparse_irq_lock, flags); 357 mutex_lock(&sparse_irq_lock);
363 start = bitmap_find_next_zero_area(allocated_irqs, nr_irqs, from, cnt, 0); 358 start = bitmap_find_next_zero_area(allocated_irqs, nr_irqs, from, cnt, 0);
364 if (start == from) 359 if (start == from)
365 bitmap_set(allocated_irqs, start, cnt); 360 bitmap_set(allocated_irqs, start, cnt);
366 else 361 else
367 ret = -EEXIST; 362 ret = -EEXIST;
368 raw_spin_unlock_irqrestore(&sparse_irq_lock, flags); 363 mutex_unlock(&sparse_irq_lock);
369 return ret; 364 return ret;
370} 365}
371 366