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