Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch 'irq-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip

* 'irq-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip:
irq: Track the owner of irq descriptor
irq: Always set IRQF_ONESHOT if no primary handler is specified
genirq: Fix wrong bit operation

+51 -19
+10 -1
include/linux/irq.h
··· 23 23 #include <linux/errno.h> 24 24 #include <linux/topology.h> 25 25 #include <linux/wait.h> 26 + #include <linux/module.h> 26 27 27 28 #include <asm/irq.h> 28 29 #include <asm/ptrace.h> ··· 548 547 return d->msi_desc; 549 548 } 550 549 551 - int irq_alloc_descs(int irq, unsigned int from, unsigned int cnt, int node); 550 + int __irq_alloc_descs(int irq, unsigned int from, unsigned int cnt, int node, 551 + struct module *owner); 552 + 553 + static inline int irq_alloc_descs(int irq, unsigned int from, unsigned int cnt, 554 + int node) 555 + { 556 + return __irq_alloc_descs(irq, from, cnt, node, THIS_MODULE); 557 + } 558 + 552 559 void irq_free_descs(unsigned int irq, unsigned int cnt); 553 560 int irq_reserve_irqs(unsigned int from, unsigned int cnt); 554 561
+1
include/linux/irqdesc.h
··· 66 66 #ifdef CONFIG_PROC_FS 67 67 struct proc_dir_entry *dir; 68 68 #endif 69 + struct module *owner; 69 70 const char *name; 70 71 } ____cacheline_internodealigned_in_smp; 71 72
+2 -2
kernel/irq/generic-chip.c
··· 246 246 gc->mask_cache = irq_reg_readl(gc->reg_base + ct->regs.mask); 247 247 248 248 for (i = gc->irq_base; msk; msk >>= 1, i++) { 249 - if (!msk & 0x01) 249 + if (!(msk & 0x01)) 250 250 continue; 251 251 252 252 if (flags & IRQ_GC_INIT_NESTED_LOCK) ··· 301 301 raw_spin_unlock(&gc_lock); 302 302 303 303 for (; msk; msk >>= 1, i++) { 304 - if (!msk & 0x01) 304 + if (!(msk & 0x01)) 305 305 continue; 306 306 307 307 /* Remove handler first. That will mask the irq line */
+24 -12
kernel/irq/irqdesc.c
··· 70 70 static inline int desc_node(struct irq_desc *desc) { return 0; } 71 71 #endif 72 72 73 - static void desc_set_defaults(unsigned int irq, struct irq_desc *desc, int node) 73 + static void desc_set_defaults(unsigned int irq, struct irq_desc *desc, int node, 74 + struct module *owner) 74 75 { 75 76 int cpu; 76 77 ··· 87 86 desc->irq_count = 0; 88 87 desc->irqs_unhandled = 0; 89 88 desc->name = NULL; 89 + desc->owner = owner; 90 90 for_each_possible_cpu(cpu) 91 91 *per_cpu_ptr(desc->kstat_irqs, cpu) = 0; 92 92 desc_smp_init(desc, node); ··· 130 128 static inline void free_masks(struct irq_desc *desc) { } 131 129 #endif 132 130 133 - static struct irq_desc *alloc_desc(int irq, int node) 131 + static struct irq_desc *alloc_desc(int irq, int node, struct module *owner) 134 132 { 135 133 struct irq_desc *desc; 136 134 gfp_t gfp = GFP_KERNEL; ··· 149 147 raw_spin_lock_init(&desc->lock); 150 148 lockdep_set_class(&desc->lock, &irq_desc_lock_class); 151 149 152 - desc_set_defaults(irq, desc, node); 150 + desc_set_defaults(irq, desc, node, owner); 153 151 154 152 return desc; 155 153 ··· 175 173 kfree(desc); 176 174 } 177 175 178 - static int alloc_descs(unsigned int start, unsigned int cnt, int node) 176 + static int alloc_descs(unsigned int start, unsigned int cnt, int node, 177 + struct module *owner) 179 178 { 180 179 struct irq_desc *desc; 181 180 int i; 182 181 183 182 for (i = 0; i < cnt; i++) { 184 - desc = alloc_desc(start + i, node); 183 + desc = alloc_desc(start + i, node, owner); 185 184 if (!desc) 186 185 goto err; 187 186 mutex_lock(&sparse_irq_lock); ··· 230 227 nr_irqs = initcnt; 231 228 232 229 for (i = 0; i < initcnt; i++) { 233 - desc = alloc_desc(i, node); 230 + desc = alloc_desc(i, node, NULL); 234 231 set_bit(i, allocated_irqs); 235 232 irq_insert_desc(i, desc); 236 233 } ··· 264 261 alloc_masks(&desc[i], GFP_KERNEL, node); 265 262 raw_spin_lock_init(&desc[i].lock); 266 263 lockdep_set_class(&desc[i].lock, &irq_desc_lock_class); 267 - desc_set_defaults(i, &desc[i], node); 264 + desc_set_defaults(i, &desc[i], node, NULL); 268 265 } 269 266 return arch_early_irq_init(); 270 267 } ··· 279 276 dynamic_irq_cleanup(irq); 280 277 } 281 278 282 - static inline int alloc_descs(unsigned int start, unsigned int cnt, int node) 279 + static inline int alloc_descs(unsigned int start, unsigned int cnt, int node, 280 + struct module *owner) 283 281 { 282 + u32 i; 283 + 284 + for (i = 0; i < cnt; i++) { 285 + struct irq_desc *desc = irq_to_desc(start + i); 286 + 287 + desc->owner = owner; 288 + } 284 289 return start; 285 290 } 286 291 ··· 348 337 * Returns the first irq number or error code 349 338 */ 350 339 int __ref 351 - irq_alloc_descs(int irq, unsigned int from, unsigned int cnt, int node) 340 + __irq_alloc_descs(int irq, unsigned int from, unsigned int cnt, int node, 341 + struct module *owner) 352 342 { 353 343 int start, ret; 354 344 ··· 378 366 379 367 bitmap_set(allocated_irqs, start, cnt); 380 368 mutex_unlock(&sparse_irq_lock); 381 - return alloc_descs(start, cnt, node); 369 + return alloc_descs(start, cnt, node, owner); 382 370 383 371 err: 384 372 mutex_unlock(&sparse_irq_lock); 385 373 return ret; 386 374 } 387 - EXPORT_SYMBOL_GPL(irq_alloc_descs); 375 + EXPORT_SYMBOL_GPL(__irq_alloc_descs); 388 376 389 377 /** 390 378 * irq_reserve_irqs - mark irqs allocated ··· 452 440 unsigned long flags; 453 441 454 442 raw_spin_lock_irqsave(&desc->lock, flags); 455 - desc_set_defaults(irq, desc, desc_node(desc)); 443 + desc_set_defaults(irq, desc, desc_node(desc), NULL); 456 444 raw_spin_unlock_irqrestore(&desc->lock, flags); 457 445 } 458 446
+14 -4
kernel/irq/manage.c
··· 883 883 884 884 if (desc->irq_data.chip == &no_irq_chip) 885 885 return -ENOSYS; 886 + if (!try_module_get(desc->owner)) 887 + return -ENODEV; 886 888 /* 887 889 * Some drivers like serial.c use request_irq() heavily, 888 890 * so we have to be careful not to interfere with a ··· 908 906 */ 909 907 nested = irq_settings_is_nested_thread(desc); 910 908 if (nested) { 911 - if (!new->thread_fn) 912 - return -EINVAL; 909 + if (!new->thread_fn) { 910 + ret = -EINVAL; 911 + goto out_mput; 912 + } 913 913 /* 914 914 * Replace the primary handler which was provided from 915 915 * the driver for non nested interrupt handling by the ··· 933 929 934 930 t = kthread_create(irq_thread, new, "irq/%d-%s", irq, 935 931 new->name); 936 - if (IS_ERR(t)) 937 - return PTR_ERR(t); 932 + if (IS_ERR(t)) { 933 + ret = PTR_ERR(t); 934 + goto out_mput; 935 + } 938 936 /* 939 937 * We keep the reference to the task struct even if 940 938 * the thread dies to avoid that the interrupt code ··· 1101 1095 kthread_stop(t); 1102 1096 put_task_struct(t); 1103 1097 } 1098 + out_mput: 1099 + module_put(desc->owner); 1104 1100 return ret; 1105 1101 } 1106 1102 ··· 1211 1203 put_task_struct(action->thread); 1212 1204 } 1213 1205 1206 + module_put(desc->owner); 1214 1207 return action; 1215 1208 } 1216 1209 ··· 1331 1322 if (!thread_fn) 1332 1323 return -EINVAL; 1333 1324 handler = irq_default_primary_handler; 1325 + irqflags |= IRQF_ONESHOT; 1334 1326 } 1335 1327 1336 1328 action = kzalloc(sizeof(struct irqaction), GFP_KERNEL);