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 | |
| 4 | void set_pending_irq(unsigned int irq, cpumask_t mask) |
| 5 | { |
| 6 | irq_desc_t *desc = irq_desc + irq; |
| 7 | unsigned long flags; |
| 8 | |
| 9 | spin_lock_irqsave(&desc->lock, flags); |
| 10 | desc->move_irq = 1; |
| 11 | pending_irq_cpumask[irq] = mask; |
| 12 | spin_unlock_irqrestore(&desc->lock, flags); |
| 13 | } |
| 14 | |
| 15 | void move_native_irq(int irq) |
| 16 | { |
| 17 | cpumask_t tmp; |
| 18 | irq_desc_t *desc = irq_descp(irq); |
| 19 | |
Bryan Holty | 501f249 | 2006-03-25 03:07:37 -0800 | [diff] [blame] | 20 | if (likely(!desc->move_irq)) |
Andrew Morton | c777ac5 | 2006-03-25 03:07:36 -0800 | [diff] [blame] | 21 | return; |
| 22 | |
Bryan Holty | 501f249 | 2006-03-25 03:07:37 -0800 | [diff] [blame] | 23 | /* |
| 24 | * Paranoia: cpu-local interrupts shouldn't be calling in here anyway. |
| 25 | */ |
| 26 | if (CHECK_IRQ_PER_CPU(desc->status)) { |
| 27 | WARN_ON(1); |
| 28 | return; |
| 29 | } |
| 30 | |
Andrew Morton | c777ac5 | 2006-03-25 03:07:36 -0800 | [diff] [blame] | 31 | desc->move_irq = 0; |
| 32 | |
Daniel Walker | 89d0cf0 | 2006-06-23 02:05:29 -0700 | [diff] [blame^] | 33 | if (unlikely(cpus_empty(pending_irq_cpumask[irq]))) |
Andrew Morton | c777ac5 | 2006-03-25 03:07:36 -0800 | [diff] [blame] | 34 | return; |
| 35 | |
| 36 | if (!desc->handler->set_affinity) |
| 37 | return; |
| 38 | |
Bryan Holty | 501f249 | 2006-03-25 03:07:37 -0800 | [diff] [blame] | 39 | assert_spin_locked(&desc->lock); |
| 40 | |
Andrew Morton | c777ac5 | 2006-03-25 03:07:36 -0800 | [diff] [blame] | 41 | cpus_and(tmp, pending_irq_cpumask[irq], cpu_online_map); |
| 42 | |
| 43 | /* |
| 44 | * If there was a valid mask to work with, please |
| 45 | * do the disable, re-program, enable sequence. |
| 46 | * This is *not* particularly important for level triggered |
| 47 | * but in a edge trigger case, we might be setting rte |
| 48 | * when an active trigger is comming in. This could |
| 49 | * cause some ioapics to mal-function. |
| 50 | * Being paranoid i guess! |
| 51 | */ |
Daniel Walker | 89d0cf0 | 2006-06-23 02:05:29 -0700 | [diff] [blame^] | 52 | if (likely(!cpus_empty(tmp))) { |
Bryan Holty | 501f249 | 2006-03-25 03:07:37 -0800 | [diff] [blame] | 53 | if (likely(!(desc->status & IRQ_DISABLED))) |
| 54 | desc->handler->disable(irq); |
| 55 | |
Andrew Morton | c777ac5 | 2006-03-25 03:07:36 -0800 | [diff] [blame] | 56 | desc->handler->set_affinity(irq,tmp); |
Bryan Holty | 501f249 | 2006-03-25 03:07:37 -0800 | [diff] [blame] | 57 | |
| 58 | if (likely(!(desc->status & IRQ_DISABLED))) |
| 59 | desc->handler->enable(irq); |
Andrew Morton | c777ac5 | 2006-03-25 03:07:36 -0800 | [diff] [blame] | 60 | } |
| 61 | cpus_clear(pending_irq_cpumask[irq]); |
| 62 | } |