diff options
Diffstat (limited to 'include/linux/irq.h')
| -rw-r--r-- | include/linux/irq.h | 86 |
1 files changed, 83 insertions, 3 deletions
diff --git a/include/linux/irq.h b/include/linux/irq.h index 6db939a575bd..873e4ac11b81 100644 --- a/include/linux/irq.h +++ b/include/linux/irq.h | |||
| @@ -180,11 +180,11 @@ struct irq_desc { | |||
| 180 | unsigned int irqs_unhandled; | 180 | unsigned int irqs_unhandled; |
| 181 | spinlock_t lock; | 181 | spinlock_t lock; |
| 182 | #ifdef CONFIG_SMP | 182 | #ifdef CONFIG_SMP |
| 183 | cpumask_t affinity; | 183 | cpumask_var_t affinity; |
| 184 | unsigned int cpu; | 184 | unsigned int cpu; |
| 185 | #endif | ||
| 186 | #ifdef CONFIG_GENERIC_PENDING_IRQ | 185 | #ifdef CONFIG_GENERIC_PENDING_IRQ |
| 187 | cpumask_t pending_mask; | 186 | cpumask_var_t pending_mask; |
| 187 | #endif | ||
| 188 | #endif | 188 | #endif |
| 189 | #ifdef CONFIG_PROC_FS | 189 | #ifdef CONFIG_PROC_FS |
| 190 | struct proc_dir_entry *dir; | 190 | struct proc_dir_entry *dir; |
| @@ -414,4 +414,84 @@ extern int set_irq_msi(unsigned int irq, struct msi_desc *entry); | |||
| 414 | 414 | ||
| 415 | #endif /* !CONFIG_S390 */ | 415 | #endif /* !CONFIG_S390 */ |
| 416 | 416 | ||
| 417 | #ifdef CONFIG_SMP | ||
| 418 | /** | ||
| 419 | * init_alloc_desc_masks - allocate cpumasks for irq_desc | ||
| 420 | * @desc: pointer to irq_desc struct | ||
| 421 | * @cpu: cpu which will be handling the cpumasks | ||
| 422 | * @boot: true if need bootmem | ||
| 423 | * | ||
| 424 | * Allocates affinity and pending_mask cpumask if required. | ||
| 425 | * Returns true if successful (or not required). | ||
| 426 | * Side effect: affinity has all bits set, pending_mask has all bits clear. | ||
| 427 | */ | ||
| 428 | static inline bool init_alloc_desc_masks(struct irq_desc *desc, int cpu, | ||
| 429 | bool boot) | ||
| 430 | { | ||
| 431 | int node; | ||
| 432 | |||
| 433 | if (boot) { | ||
| 434 | alloc_bootmem_cpumask_var(&desc->affinity); | ||
| 435 | cpumask_setall(desc->affinity); | ||
| 436 | |||
| 437 | #ifdef CONFIG_GENERIC_PENDING_IRQ | ||
| 438 | alloc_bootmem_cpumask_var(&desc->pending_mask); | ||
| 439 | cpumask_clear(desc->pending_mask); | ||
| 440 | #endif | ||
| 441 | return true; | ||
| 442 | } | ||
| 443 | |||
| 444 | node = cpu_to_node(cpu); | ||
| 445 | |||
| 446 | if (!alloc_cpumask_var_node(&desc->affinity, GFP_ATOMIC, node)) | ||
| 447 | return false; | ||
| 448 | cpumask_setall(desc->affinity); | ||
| 449 | |||
| 450 | #ifdef CONFIG_GENERIC_PENDING_IRQ | ||
| 451 | if (!alloc_cpumask_var_node(&desc->pending_mask, GFP_ATOMIC, node)) { | ||
| 452 | free_cpumask_var(desc->affinity); | ||
| 453 | return false; | ||
| 454 | } | ||
| 455 | cpumask_clear(desc->pending_mask); | ||
| 456 | #endif | ||
| 457 | return true; | ||
| 458 | } | ||
| 459 | |||
| 460 | /** | ||
| 461 | * init_copy_desc_masks - copy cpumasks for irq_desc | ||
| 462 | * @old_desc: pointer to old irq_desc struct | ||
| 463 | * @new_desc: pointer to new irq_desc struct | ||
| 464 | * | ||
| 465 | * Insures affinity and pending_masks are copied to new irq_desc. | ||
| 466 | * If !CONFIG_CPUMASKS_OFFSTACK the cpumasks are embedded in the | ||
| 467 | * irq_desc struct so the copy is redundant. | ||
| 468 | */ | ||
| 469 | |||
| 470 | static inline void init_copy_desc_masks(struct irq_desc *old_desc, | ||
| 471 | struct irq_desc *new_desc) | ||
| 472 | { | ||
| 473 | #ifdef CONFIG_CPUMASKS_OFFSTACK | ||
| 474 | cpumask_copy(new_desc->affinity, old_desc->affinity); | ||
| 475 | |||
| 476 | #ifdef CONFIG_GENERIC_PENDING_IRQ | ||
| 477 | cpumask_copy(new_desc->pending_mask, old_desc->pending_mask); | ||
| 478 | #endif | ||
| 479 | #endif | ||
| 480 | } | ||
| 481 | |||
| 482 | #else /* !CONFIG_SMP */ | ||
| 483 | |||
| 484 | static inline bool init_alloc_desc_masks(struct irq_desc *desc, int cpu, | ||
| 485 | bool boot) | ||
| 486 | { | ||
| 487 | return true; | ||
| 488 | } | ||
| 489 | |||
| 490 | static inline void init_copy_desc_masks(struct irq_desc *old_desc, | ||
| 491 | struct irq_desc *new_desc) | ||
| 492 | { | ||
| 493 | } | ||
| 494 | |||
| 495 | #endif /* CONFIG_SMP */ | ||
| 496 | |||
| 417 | #endif /* _LINUX_IRQ_H */ | 497 | #endif /* _LINUX_IRQ_H */ |
