diff options
| -rw-r--r-- | arch/x86/kernel/io_apic.c | 26 | ||||
| -rw-r--r-- | include/linux/irq.h | 11 | ||||
| -rw-r--r-- | kernel/irq/internals.h | 2 | ||||
| -rw-r--r-- | kernel/irq/manage.c | 68 | ||||
| -rw-r--r-- | kernel/irq/migration.c | 11 | ||||
| -rw-r--r-- | kernel/irq/proc.c | 2 |
6 files changed, 80 insertions, 40 deletions
diff --git a/arch/x86/kernel/io_apic.c b/arch/x86/kernel/io_apic.c index 1fec0f9b150..9043251210f 100644 --- a/arch/x86/kernel/io_apic.c +++ b/arch/x86/kernel/io_apic.c | |||
| @@ -3755,7 +3755,9 @@ int acpi_get_override_irq(int bus_irq, int *trigger, int *polarity) | |||
| 3755 | void __init setup_ioapic_dest(void) | 3755 | void __init setup_ioapic_dest(void) |
| 3756 | { | 3756 | { |
| 3757 | int pin, ioapic, irq, irq_entry; | 3757 | int pin, ioapic, irq, irq_entry; |
| 3758 | struct irq_desc *desc; | ||
| 3758 | struct irq_cfg *cfg; | 3759 | struct irq_cfg *cfg; |
| 3760 | cpumask_t mask; | ||
| 3759 | 3761 | ||
| 3760 | if (skip_ioapic_setup == 1) | 3762 | if (skip_ioapic_setup == 1) |
| 3761 | return; | 3763 | return; |
| @@ -3772,16 +3774,30 @@ void __init setup_ioapic_dest(void) | |||
| 3772 | * cpu is online. | 3774 | * cpu is online. |
| 3773 | */ | 3775 | */ |
| 3774 | cfg = irq_cfg(irq); | 3776 | cfg = irq_cfg(irq); |
| 3775 | if (!cfg->vector) | 3777 | if (!cfg->vector) { |
| 3776 | setup_IO_APIC_irq(ioapic, pin, irq, | 3778 | setup_IO_APIC_irq(ioapic, pin, irq, |
| 3777 | irq_trigger(irq_entry), | 3779 | irq_trigger(irq_entry), |
| 3778 | irq_polarity(irq_entry)); | 3780 | irq_polarity(irq_entry)); |
| 3781 | continue; | ||
| 3782 | |||
| 3783 | } | ||
| 3784 | |||
| 3785 | /* | ||
| 3786 | * Honour affinities which have been set in early boot | ||
| 3787 | */ | ||
| 3788 | desc = irq_to_desc(irq); | ||
| 3789 | if (desc->status & | ||
| 3790 | (IRQ_NO_BALANCING | IRQ_AFFINITY_SET)) | ||
| 3791 | mask = desc->affinity; | ||
| 3792 | else | ||
| 3793 | mask = TARGET_CPUS; | ||
| 3794 | |||
| 3779 | #ifdef CONFIG_INTR_REMAP | 3795 | #ifdef CONFIG_INTR_REMAP |
| 3780 | else if (intr_remapping_enabled) | 3796 | if (intr_remapping_enabled) |
| 3781 | set_ir_ioapic_affinity_irq(irq, TARGET_CPUS); | 3797 | set_ir_ioapic_affinity_irq(irq, mask); |
| 3782 | #endif | ||
| 3783 | else | 3798 | else |
| 3784 | set_ioapic_affinity_irq(irq, TARGET_CPUS); | 3799 | #endif |
| 3800 | set_ioapic_affinity_irq(irq, mask); | ||
| 3785 | } | 3801 | } |
| 3786 | 3802 | ||
| 3787 | } | 3803 | } |
diff --git a/include/linux/irq.h b/include/linux/irq.h index d058c57be02..3dddfa703eb 100644 --- a/include/linux/irq.h +++ b/include/linux/irq.h | |||
| @@ -63,7 +63,8 @@ typedef void (*irq_flow_handler_t)(unsigned int irq, | |||
| 63 | #define IRQ_MOVE_PENDING 0x00200000 /* need to re-target IRQ destination */ | 63 | #define IRQ_MOVE_PENDING 0x00200000 /* need to re-target IRQ destination */ |
| 64 | #define IRQ_NO_BALANCING 0x00400000 /* IRQ is excluded from balancing */ | 64 | #define IRQ_NO_BALANCING 0x00400000 /* IRQ is excluded from balancing */ |
| 65 | #define IRQ_SPURIOUS_DISABLED 0x00800000 /* IRQ was disabled by the spurious trap */ | 65 | #define IRQ_SPURIOUS_DISABLED 0x00800000 /* IRQ was disabled by the spurious trap */ |
| 66 | #define IRQ_MOVE_PCNTXT 0x01000000 /* IRQ migration from process context */ | 66 | #define IRQ_MOVE_PCNTXT 0x01000000 /* IRQ migration from process context */ |
| 67 | #define IRQ_AFFINITY_SET 0x02000000 /* IRQ affinity was set from userspace*/ | ||
| 67 | 68 | ||
| 68 | #ifdef CONFIG_IRQ_PER_CPU | 69 | #ifdef CONFIG_IRQ_PER_CPU |
| 69 | # define CHECK_IRQ_PER_CPU(var) ((var) & IRQ_PER_CPU) | 70 | # define CHECK_IRQ_PER_CPU(var) ((var) & IRQ_PER_CPU) |
| @@ -130,7 +131,7 @@ struct irq_chip { | |||
| 130 | 131 | ||
| 131 | /** | 132 | /** |
| 132 | * struct irq_desc - interrupt descriptor | 133 | * struct irq_desc - interrupt descriptor |
| 133 | * | 134 | * @irq: interrupt number for this descriptor |
| 134 | * @handle_irq: highlevel irq-events handler [if NULL, __do_IRQ()] | 135 | * @handle_irq: highlevel irq-events handler [if NULL, __do_IRQ()] |
| 135 | * @chip: low level interrupt hardware access | 136 | * @chip: low level interrupt hardware access |
| 136 | * @msi_desc: MSI descriptor | 137 | * @msi_desc: MSI descriptor |
| @@ -149,7 +150,6 @@ struct irq_chip { | |||
| 149 | * @cpu: cpu index useful for balancing | 150 | * @cpu: cpu index useful for balancing |
| 150 | * @pending_mask: pending rebalanced interrupts | 151 | * @pending_mask: pending rebalanced interrupts |
| 151 | * @dir: /proc/irq/ procfs entry | 152 | * @dir: /proc/irq/ procfs entry |
| 152 | * @affinity_entry: /proc/irq/smp_affinity procfs entry on SMP | ||
| 153 | * @name: flow handler name for /proc/interrupts output | 153 | * @name: flow handler name for /proc/interrupts output |
| 154 | */ | 154 | */ |
| 155 | struct irq_desc { | 155 | struct irq_desc { |
| @@ -210,7 +210,6 @@ extern int setup_irq(unsigned int irq, struct irqaction *new); | |||
| 210 | 210 | ||
| 211 | #ifdef CONFIG_GENERIC_PENDING_IRQ | 211 | #ifdef CONFIG_GENERIC_PENDING_IRQ |
| 212 | 212 | ||
| 213 | void set_pending_irq(unsigned int irq, cpumask_t mask); | ||
| 214 | void move_native_irq(int irq); | 213 | void move_native_irq(int irq); |
| 215 | void move_masked_irq(int irq); | 214 | void move_masked_irq(int irq); |
| 216 | 215 | ||
| @@ -228,10 +227,6 @@ static inline void move_masked_irq(int irq) | |||
| 228 | { | 227 | { |
| 229 | } | 228 | } |
| 230 | 229 | ||
| 231 | static inline void set_pending_irq(unsigned int irq, cpumask_t mask) | ||
| 232 | { | ||
| 233 | } | ||
| 234 | |||
| 235 | #endif /* CONFIG_GENERIC_PENDING_IRQ */ | 230 | #endif /* CONFIG_GENERIC_PENDING_IRQ */ |
| 236 | 231 | ||
| 237 | #else /* CONFIG_SMP */ | 232 | #else /* CONFIG_SMP */ |
diff --git a/kernel/irq/internals.h b/kernel/irq/internals.h index c9767e64198..64c1c7253da 100644 --- a/kernel/irq/internals.h +++ b/kernel/irq/internals.h | |||
| @@ -25,6 +25,8 @@ static inline void unregister_handler_proc(unsigned int irq, | |||
| 25 | struct irqaction *action) { } | 25 | struct irqaction *action) { } |
| 26 | #endif | 26 | #endif |
| 27 | 27 | ||
| 28 | extern int irq_select_affinity_usr(unsigned int irq); | ||
| 29 | |||
| 28 | /* | 30 | /* |
| 29 | * Debugging printout: | 31 | * Debugging printout: |
| 30 | */ | 32 | */ |
diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c index c498a1b8c62..801addda3c4 100644 --- a/kernel/irq/manage.c +++ b/kernel/irq/manage.c | |||
| @@ -82,24 +82,27 @@ int irq_can_set_affinity(unsigned int irq) | |||
| 82 | int irq_set_affinity(unsigned int irq, cpumask_t cpumask) | 82 | int irq_set_affinity(unsigned int irq, cpumask_t cpumask) |
| 83 | { | 83 | { |
| 84 | struct irq_desc *desc = irq_to_desc(irq); | 84 | struct irq_desc *desc = irq_to_desc(irq); |
| 85 | unsigned long flags; | ||
| 85 | 86 | ||
| 86 | if (!desc->chip->set_affinity) | 87 | if (!desc->chip->set_affinity) |
| 87 | return -EINVAL; | 88 | return -EINVAL; |
| 88 | 89 | ||
| 90 | spin_lock_irqsave(&desc->lock, flags); | ||
| 91 | |||
| 89 | #ifdef CONFIG_GENERIC_PENDING_IRQ | 92 | #ifdef CONFIG_GENERIC_PENDING_IRQ |
| 90 | if (desc->status & IRQ_MOVE_PCNTXT || desc->status & IRQ_DISABLED) { | 93 | if (desc->status & IRQ_MOVE_PCNTXT || desc->status & IRQ_DISABLED) { |
| 91 | unsigned long flags; | ||
| 92 | |||
| 93 | spin_lock_irqsave(&desc->lock, flags); | ||
| 94 | desc->affinity = cpumask; | 94 | desc->affinity = cpumask; |
| 95 | desc->chip->set_affinity(irq, cpumask); | 95 | desc->chip->set_affinity(irq, cpumask); |
| 96 | spin_unlock_irqrestore(&desc->lock, flags); | 96 | } else { |
| 97 | } else | 97 | desc->status |= IRQ_MOVE_PENDING; |
| 98 | set_pending_irq(irq, cpumask); | 98 | desc->pending_mask = cpumask; |
| 99 | } | ||
| 99 | #else | 100 | #else |
| 100 | desc->affinity = cpumask; | 101 | desc->affinity = cpumask; |
| 101 | desc->chip->set_affinity(irq, cpumask); | 102 | desc->chip->set_affinity(irq, cpumask); |
| 102 | #endif | 103 | #endif |
| 104 | desc->status |= IRQ_AFFINITY_SET; | ||
| 105 | spin_unlock_irqrestore(&desc->lock, flags); | ||
| 103 | return 0; | 106 | return 0; |
| 104 | } | 107 | } |
| 105 | 108 | ||
| @@ -107,24 +110,59 @@ int irq_set_affinity(unsigned int irq, cpumask_t cpumask) | |||
| 107 | /* | 110 | /* |
| 108 | * Generic version of the affinity autoselector. | 111 | * Generic version of the affinity autoselector. |
| 109 | */ | 112 | */ |
| 110 | int irq_select_affinity(unsigned int irq) | 113 | int do_irq_select_affinity(unsigned int irq, struct irq_desc *desc) |
| 111 | { | 114 | { |
| 112 | cpumask_t mask; | 115 | cpumask_t mask; |
| 113 | struct irq_desc *desc; | ||
| 114 | 116 | ||
| 115 | if (!irq_can_set_affinity(irq)) | 117 | if (!irq_can_set_affinity(irq)) |
| 116 | return 0; | 118 | return 0; |
| 117 | 119 | ||
| 118 | cpus_and(mask, cpu_online_map, irq_default_affinity); | 120 | cpus_and(mask, cpu_online_map, irq_default_affinity); |
| 119 | 121 | ||
| 120 | desc = irq_to_desc(irq); | 122 | /* |
| 123 | * Preserve an userspace affinity setup, but make sure that | ||
| 124 | * one of the targets is online. | ||
| 125 | */ | ||
| 126 | if (desc->status & (IRQ_AFFINITY_SET | IRQ_NO_BALANCING)) { | ||
| 127 | if (cpus_intersects(desc->affinity, cpu_online_map)) | ||
| 128 | mask = desc->affinity; | ||
| 129 | else | ||
| 130 | desc->status &= ~IRQ_AFFINITY_SET; | ||
| 131 | } | ||
| 132 | |||
| 121 | desc->affinity = mask; | 133 | desc->affinity = mask; |
| 122 | desc->chip->set_affinity(irq, mask); | 134 | desc->chip->set_affinity(irq, mask); |
| 123 | 135 | ||
| 124 | return 0; | 136 | return 0; |
| 125 | } | 137 | } |
| 138 | #else | ||
| 139 | static inline int do_irq_select_affinity(unsigned int irq, struct irq_desc *d) | ||
| 140 | { | ||
| 141 | return irq_select_affinity(irq); | ||
| 142 | } | ||
| 126 | #endif | 143 | #endif |
| 127 | 144 | ||
| 145 | /* | ||
| 146 | * Called when affinity is set via /proc/irq | ||
| 147 | */ | ||
| 148 | int irq_select_affinity_usr(unsigned int irq) | ||
| 149 | { | ||
| 150 | struct irq_desc *desc = irq_to_desc(irq); | ||
| 151 | unsigned long flags; | ||
| 152 | int ret; | ||
| 153 | |||
| 154 | spin_lock_irqsave(&desc->lock, flags); | ||
| 155 | ret = do_irq_select_affinity(irq, desc); | ||
| 156 | spin_unlock_irqrestore(&desc->lock, flags); | ||
| 157 | |||
| 158 | return ret; | ||
| 159 | } | ||
| 160 | |||
| 161 | #else | ||
| 162 | static inline int do_irq_select_affinity(int irq, struct irq_desc *desc) | ||
| 163 | { | ||
| 164 | return 0; | ||
| 165 | } | ||
| 128 | #endif | 166 | #endif |
| 129 | 167 | ||
| 130 | /** | 168 | /** |
| @@ -327,7 +365,7 @@ int __irq_set_trigger(struct irq_desc *desc, unsigned int irq, | |||
| 327 | * IRQF_TRIGGER_* but the PIC does not support multiple | 365 | * IRQF_TRIGGER_* but the PIC does not support multiple |
| 328 | * flow-types? | 366 | * flow-types? |
| 329 | */ | 367 | */ |
| 330 | pr_warning("No set_type function for IRQ %d (%s)\n", irq, | 368 | pr_debug("No set_type function for IRQ %d (%s)\n", irq, |
| 331 | chip ? (chip->name ? : "unknown") : "unknown"); | 369 | chip ? (chip->name ? : "unknown") : "unknown"); |
| 332 | return 0; | 370 | return 0; |
| 333 | } | 371 | } |
| @@ -445,8 +483,12 @@ __setup_irq(unsigned int irq, struct irq_desc * desc, struct irqaction *new) | |||
| 445 | /* Undo nested disables: */ | 483 | /* Undo nested disables: */ |
| 446 | desc->depth = 1; | 484 | desc->depth = 1; |
| 447 | 485 | ||
| 486 | /* Exclude IRQ from balancing if requested */ | ||
| 487 | if (new->flags & IRQF_NOBALANCING) | ||
| 488 | desc->status |= IRQ_NO_BALANCING; | ||
| 489 | |||
| 448 | /* Set default affinity mask once everything is setup */ | 490 | /* Set default affinity mask once everything is setup */ |
| 449 | irq_select_affinity(irq); | 491 | do_irq_select_affinity(irq, desc); |
| 450 | 492 | ||
| 451 | } else if ((new->flags & IRQF_TRIGGER_MASK) | 493 | } else if ((new->flags & IRQF_TRIGGER_MASK) |
| 452 | && (new->flags & IRQF_TRIGGER_MASK) | 494 | && (new->flags & IRQF_TRIGGER_MASK) |
| @@ -459,10 +501,6 @@ __setup_irq(unsigned int irq, struct irq_desc * desc, struct irqaction *new) | |||
| 459 | 501 | ||
| 460 | *p = new; | 502 | *p = new; |
| 461 | 503 | ||
| 462 | /* Exclude IRQ from balancing */ | ||
| 463 | if (new->flags & IRQF_NOBALANCING) | ||
| 464 | desc->status |= IRQ_NO_BALANCING; | ||
| 465 | |||
| 466 | /* Reset broken irq detection when installing new handler */ | 504 | /* Reset broken irq detection when installing new handler */ |
| 467 | desc->irq_count = 0; | 505 | desc->irq_count = 0; |
| 468 | desc->irqs_unhandled = 0; | 506 | desc->irqs_unhandled = 0; |
diff --git a/kernel/irq/migration.c b/kernel/irq/migration.c index 90b920d3f52..9db681d9581 100644 --- a/kernel/irq/migration.c +++ b/kernel/irq/migration.c | |||
| @@ -1,17 +1,6 @@ | |||
| 1 | 1 | ||
| 2 | #include <linux/irq.h> | 2 | #include <linux/irq.h> |
| 3 | 3 | ||
| 4 | void set_pending_irq(unsigned int irq, cpumask_t mask) | ||
| 5 | { | ||
| 6 | struct irq_desc *desc = irq_to_desc(irq); | ||
| 7 | unsigned long flags; | ||
| 8 | |||
| 9 | spin_lock_irqsave(&desc->lock, flags); | ||
| 10 | desc->status |= IRQ_MOVE_PENDING; | ||
| 11 | desc->pending_mask = mask; | ||
| 12 | spin_unlock_irqrestore(&desc->lock, flags); | ||
| 13 | } | ||
| 14 | |||
| 15 | void move_masked_irq(int irq) | 4 | void move_masked_irq(int irq) |
| 16 | { | 5 | { |
| 17 | struct irq_desc *desc = irq_to_desc(irq); | 6 | struct irq_desc *desc = irq_to_desc(irq); |
diff --git a/kernel/irq/proc.c b/kernel/irq/proc.c index 4d161c70ba5..d257e7d6a8a 100644 --- a/kernel/irq/proc.c +++ b/kernel/irq/proc.c | |||
| @@ -62,7 +62,7 @@ static ssize_t irq_affinity_proc_write(struct file *file, | |||
| 62 | if (!cpus_intersects(new_value, cpu_online_map)) | 62 | if (!cpus_intersects(new_value, cpu_online_map)) |
| 63 | /* Special case for empty set - allow the architecture | 63 | /* Special case for empty set - allow the architecture |
| 64 | code to set default SMP affinity. */ | 64 | code to set default SMP affinity. */ |
| 65 | return irq_select_affinity(irq) ? -EINVAL : count; | 65 | return irq_select_affinity_usr(irq) ? -EINVAL : count; |
| 66 | 66 | ||
| 67 | irq_set_affinity(irq, new_value); | 67 | irq_set_affinity(irq, new_value); |
| 68 | 68 | ||
