Andrew Morton | c777ac5 | 2006-03-25 03:07:36 -0800 | [diff] [blame] | 1 | |
Christoph Hellwig | d824e66 | 2006-04-10 22:54:04 -0700 | [diff] [blame] | 2 | #include <linux/irq.h> |
Yinghai Lu | 57b150c | 2009-04-27 17:59:53 -0700 | [diff] [blame^] | 3 | #include <linux/interrupt.h> |
| 4 | |
| 5 | #include "internals.h" |
Andrew Morton | c777ac5 | 2006-03-25 03:07:36 -0800 | [diff] [blame] | 6 | |
Eric W. Biederman | e7b946e | 2006-10-04 02:16:29 -0700 | [diff] [blame] | 7 | void move_masked_irq(int irq) |
Andrew Morton | c777ac5 | 2006-03-25 03:07:36 -0800 | [diff] [blame] | 8 | { |
Yinghai Lu | 08678b0 | 2008-08-19 20:50:05 -0700 | [diff] [blame] | 9 | struct irq_desc *desc = irq_to_desc(irq); |
Andrew Morton | c777ac5 | 2006-03-25 03:07:36 -0800 | [diff] [blame] | 10 | |
Eric W. Biederman | a24ceab | 2006-10-04 02:16:27 -0700 | [diff] [blame] | 11 | if (likely(!(desc->status & IRQ_MOVE_PENDING))) |
Andrew Morton | c777ac5 | 2006-03-25 03:07:36 -0800 | [diff] [blame] | 12 | return; |
| 13 | |
Bryan Holty | 501f249 | 2006-03-25 03:07:37 -0800 | [diff] [blame] | 14 | /* |
| 15 | * Paranoia: cpu-local interrupts shouldn't be calling in here anyway. |
| 16 | */ |
| 17 | if (CHECK_IRQ_PER_CPU(desc->status)) { |
| 18 | WARN_ON(1); |
| 19 | return; |
| 20 | } |
| 21 | |
Eric W. Biederman | a24ceab | 2006-10-04 02:16:27 -0700 | [diff] [blame] | 22 | desc->status &= ~IRQ_MOVE_PENDING; |
Andrew Morton | c777ac5 | 2006-03-25 03:07:36 -0800 | [diff] [blame] | 23 | |
Mike Travis | 7f7ace0 | 2009-01-10 21:58:08 -0800 | [diff] [blame] | 24 | if (unlikely(cpumask_empty(desc->pending_mask))) |
Andrew Morton | c777ac5 | 2006-03-25 03:07:36 -0800 | [diff] [blame] | 25 | return; |
| 26 | |
Ingo Molnar | d1bef4e | 2006-06-29 02:24:36 -0700 | [diff] [blame] | 27 | if (!desc->chip->set_affinity) |
Andrew Morton | c777ac5 | 2006-03-25 03:07:36 -0800 | [diff] [blame] | 28 | return; |
| 29 | |
Bryan Holty | 501f249 | 2006-03-25 03:07:37 -0800 | [diff] [blame] | 30 | assert_spin_locked(&desc->lock); |
| 31 | |
Andrew Morton | c777ac5 | 2006-03-25 03:07:36 -0800 | [diff] [blame] | 32 | /* |
| 33 | * If there was a valid mask to work with, please |
| 34 | * do the disable, re-program, enable sequence. |
| 35 | * This is *not* particularly important for level triggered |
| 36 | * but in a edge trigger case, we might be setting rte |
| 37 | * when an active trigger is comming in. This could |
| 38 | * cause some ioapics to mal-function. |
| 39 | * Being paranoid i guess! |
Eric W. Biederman | e7b946e | 2006-10-04 02:16:29 -0700 | [diff] [blame] | 40 | * |
| 41 | * For correct operation this depends on the caller |
| 42 | * masking the irqs. |
Andrew Morton | c777ac5 | 2006-03-25 03:07:36 -0800 | [diff] [blame] | 43 | */ |
Mike Travis | 7f7ace0 | 2009-01-10 21:58:08 -0800 | [diff] [blame] | 44 | if (likely(cpumask_any_and(desc->pending_mask, cpu_online_mask) |
Yinghai Lu | 57b150c | 2009-04-27 17:59:53 -0700 | [diff] [blame^] | 45 | < nr_cpu_ids)) |
| 46 | if (!desc->chip->set_affinity(irq, desc->pending_mask)) { |
| 47 | cpumask_copy(desc->affinity, desc->pending_mask); |
| 48 | irq_set_thread_affinity(desc, desc->pending_mask); |
| 49 | } |
| 50 | |
Mike Travis | 7f7ace0 | 2009-01-10 21:58:08 -0800 | [diff] [blame] | 51 | cpumask_clear(desc->pending_mask); |
Andrew Morton | c777ac5 | 2006-03-25 03:07:36 -0800 | [diff] [blame] | 52 | } |
Eric W. Biederman | e7b946e | 2006-10-04 02:16:29 -0700 | [diff] [blame] | 53 | |
| 54 | void move_native_irq(int irq) |
| 55 | { |
Yinghai Lu | 08678b0 | 2008-08-19 20:50:05 -0700 | [diff] [blame] | 56 | struct irq_desc *desc = irq_to_desc(irq); |
Eric W. Biederman | e7b946e | 2006-10-04 02:16:29 -0700 | [diff] [blame] | 57 | |
| 58 | if (likely(!(desc->status & IRQ_MOVE_PENDING))) |
| 59 | return; |
| 60 | |
Eric W. Biederman | 2a786b4 | 2007-02-23 04:46:20 -0700 | [diff] [blame] | 61 | if (unlikely(desc->status & IRQ_DISABLED)) |
| 62 | return; |
Eric W. Biederman | e7b946e | 2006-10-04 02:16:29 -0700 | [diff] [blame] | 63 | |
Eric W. Biederman | 2a786b4 | 2007-02-23 04:46:20 -0700 | [diff] [blame] | 64 | desc->chip->mask(irq); |
Eric W. Biederman | e7b946e | 2006-10-04 02:16:29 -0700 | [diff] [blame] | 65 | move_masked_irq(irq); |
Eric W. Biederman | 2a786b4 | 2007-02-23 04:46:20 -0700 | [diff] [blame] | 66 | desc->chip->unmask(irq); |
Eric W. Biederman | e7b946e | 2006-10-04 02:16:29 -0700 | [diff] [blame] | 67 | } |
| 68 | |