migration.c 1.4 KB
Newer Older
1

2
#include <linux/irq.h>
3

4
void move_masked_irq(int irq)
5
{
6
	struct irq_desc *desc = irq_to_desc(irq);
7

8
	if (likely(!(desc->status & IRQ_MOVE_PENDING)))
9 10
		return;

11 12 13 14 15 16 17 18
	/*
	 * Paranoia: cpu-local interrupts shouldn't be calling in here anyway.
	 */
	if (CHECK_IRQ_PER_CPU(desc->status)) {
		WARN_ON(1);
		return;
	}

19
	desc->status &= ~IRQ_MOVE_PENDING;
20

21
	if (unlikely(cpumask_empty(desc->pending_mask)))
22 23
		return;

24
	if (!desc->chip->set_affinity)
25 26
		return;

27 28
	assert_spin_locked(&desc->lock);

29 30 31 32 33 34 35 36
	/*
	 * If there was a valid mask to work with, please
	 * do the disable, re-program, enable sequence.
	 * This is *not* particularly important for level triggered
	 * but in a edge trigger case, we might be setting rte
	 * when an active trigger is comming in. This could
	 * cause some ioapics to mal-function.
	 * Being paranoid i guess!
37 38 39
	 *
	 * For correct operation this depends on the caller
	 * masking the irqs.
40
	 */
41
	if (likely(cpumask_any_and(desc->pending_mask, cpu_online_mask)
42
		   < nr_cpu_ids)) {
43 44 45
		cpumask_and(desc->affinity,
			    desc->pending_mask, cpu_online_mask);
		desc->chip->set_affinity(irq, desc->affinity);
46
	}
47
	cpumask_clear(desc->pending_mask);
48
}
49 50 51

void move_native_irq(int irq)
{
52
	struct irq_desc *desc = irq_to_desc(irq);
53 54 55 56

	if (likely(!(desc->status & IRQ_MOVE_PENDING)))
		return;

57 58
	if (unlikely(desc->status & IRQ_DISABLED))
		return;
59

60
	desc->chip->mask(irq);
61
	move_masked_irq(irq);
62
	desc->chip->unmask(irq);
63 64
}