aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYinghai Lu <yhlu.kernel@gmail.com>2008-08-20 23:46:25 -0400
committerIngo Molnar <mingo@elte.hu>2008-10-16 10:52:59 -0400
commite89eb43863c2d9f11a3bbe766766fe646e6c50d9 (patch)
tree3d45bdf7efb5a37edb99f62cbea1d500b3003468
parent7ddfb650c7ef7a33a5ef11c0fdf5b3d837a47dba (diff)
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>
-rw-r--r--arch/x86/kernel/io_apic.c13
-rw-r--r--kernel/irq/handle.c13
2 files changed, 24 insertions, 2 deletions
diff --git a/arch/x86/kernel/io_apic.c b/arch/x86/kernel/io_apic.c
index 34c74cf5c244..7ca556690474 100644
--- a/arch/x86/kernel/io_apic.c
+++ b/arch/x86/kernel/io_apic.c
@@ -146,6 +146,12 @@ static void init_one_irq_cfg(struct irq_cfg *cfg)
146} 146}
147 147
148static struct irq_cfg *irq_cfgx; 148static struct irq_cfg *irq_cfgx;
149
150/*
151 * Protect the irq_cfgx_free freelist:
152 */
153static DEFINE_SPINLOCK(irq_cfg_lock);
154
149#ifdef CONFIG_HAVE_SPARSE_IRQ 155#ifdef CONFIG_HAVE_SPARSE_IRQ
150static struct irq_cfg *irq_cfgx_free; 156static struct irq_cfg *irq_cfgx_free;
151#endif 157#endif
@@ -213,8 +219,9 @@ static struct irq_cfg *irq_cfg(unsigned int irq)
213static struct irq_cfg *irq_cfg_alloc(unsigned int irq) 219static struct irq_cfg *irq_cfg_alloc(unsigned int irq)
214{ 220{
215 struct irq_cfg *cfg, *cfg_pri; 221 struct irq_cfg *cfg, *cfg_pri;
216 int i; 222 unsigned long flags;
217 int count = 0; 223 int count = 0;
224 int i;
218 225
219 cfg_pri = cfg = irq_cfgx; 226 cfg_pri = cfg = irq_cfgx;
220 while (cfg) { 227 while (cfg) {
@@ -226,6 +233,7 @@ static struct irq_cfg *irq_cfg_alloc(unsigned int irq)
226 count++; 233 count++;
227 } 234 }
228 235
236 spin_lock_irqsave(&irq_cfg_lock, flags);
229 if (!irq_cfgx_free) { 237 if (!irq_cfgx_free) {
230 unsigned long phys; 238 unsigned long phys;
231 unsigned long total_bytes; 239 unsigned long total_bytes;
@@ -263,6 +271,9 @@ static struct irq_cfg *irq_cfg_alloc(unsigned int irq)
263 else 271 else
264 irq_cfgx = cfg; 272 irq_cfgx = cfg;
265 cfg->irq = irq; 273 cfg->irq = irq;
274
275 spin_unlock_irqrestore(&irq_cfg_lock, flags);
276
266 printk(KERN_DEBUG "found new irq_cfg for irq %d\n", cfg->irq); 277 printk(KERN_DEBUG "found new irq_cfg for irq %d\n", cfg->irq);
267#ifdef CONFIG_HAVE_SPARSE_IRQ_DEBUG 278#ifdef CONFIG_HAVE_SPARSE_IRQ_DEBUG
268 { 279 {
diff --git a/kernel/irq/handle.c b/kernel/irq/handle.c
index 24c83a3cee4d..d638a911cbc1 100644
--- a/kernel/irq/handle.c
+++ b/kernel/irq/handle.c
@@ -107,6 +107,11 @@ static void init_kstat_irqs(struct irq_desc *desc, int nr_desc, int nr)
107 } 107 }
108} 108}
109 109
110/*
111 * Protect the sparse_irqs_free freelist:
112 */
113static DEFINE_SPINLOCK(sparse_irq_lock);
114
110#ifdef CONFIG_HAVE_SPARSE_IRQ 115#ifdef CONFIG_HAVE_SPARSE_IRQ
111static struct irq_desc *sparse_irqs_free; 116static struct irq_desc *sparse_irqs_free;
112struct irq_desc *sparse_irqs; 117struct irq_desc *sparse_irqs;
@@ -166,11 +171,13 @@ struct irq_desc *irq_to_desc(unsigned int irq)
166 } 171 }
167 return NULL; 172 return NULL;
168} 173}
174
169struct irq_desc *irq_to_desc_alloc(unsigned int irq) 175struct irq_desc *irq_to_desc_alloc(unsigned int irq)
170{ 176{
171 struct irq_desc *desc, *desc_pri; 177 struct irq_desc *desc, *desc_pri;
172 int i; 178 unsigned long flags;
173 int count = 0; 179 int count = 0;
180 int i;
174 181
175 desc_pri = desc = sparse_irqs; 182 desc_pri = desc = sparse_irqs;
176 while (desc) { 183 while (desc) {
@@ -182,6 +189,7 @@ struct irq_desc *irq_to_desc_alloc(unsigned int irq)
182 count++; 189 count++;
183 } 190 }
184 191
192 spin_lock_irqsave(&sparse_irq_lock, flags);
185 /* 193 /*
186 * we run out of pre-allocate ones, allocate more 194 * we run out of pre-allocate ones, allocate more
187 */ 195 */
@@ -223,6 +231,9 @@ struct irq_desc *irq_to_desc_alloc(unsigned int irq)
223 else 231 else
224 sparse_irqs = desc; 232 sparse_irqs = desc;
225 desc->irq = irq; 233 desc->irq = irq;
234
235 spin_unlock_irqrestore(&sparse_irq_lock, flags);
236
226 printk(KERN_DEBUG "found new irq_desc for irq %d\n", desc->irq); 237 printk(KERN_DEBUG "found new irq_desc for irq %d\n", desc->irq);
227#ifdef CONFIG_HAVE_SPARSE_IRQ_DEBUG 238#ifdef CONFIG_HAVE_SPARSE_IRQ_DEBUG
228 { 239 {