migration.c 1.7 KB
Newer Older
1

2
#include <linux/irq.h>
3 4 5

void set_pending_irq(unsigned int irq, cpumask_t mask)
{
6
	struct irq_desc *desc = irq_desc + irq;
7 8 9
	unsigned long flags;

	spin_lock_irqsave(&desc->lock, flags);
10
	desc->status |= IRQ_MOVE_PENDING;
11
	irq_desc[irq].pending_mask = mask;
12 13 14
	spin_unlock_irqrestore(&desc->lock, flags);
}

15
void move_masked_irq(int irq)
16
{
17
	struct irq_desc *desc = irq_desc + irq;
18 19
	cpumask_t tmp;

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

23 24 25 26 27 28 29 30
	/*
	 * Paranoia: cpu-local interrupts shouldn't be calling in here anyway.
	 */
	if (CHECK_IRQ_PER_CPU(desc->status)) {
		WARN_ON(1);
		return;
	}

31
	desc->status &= ~IRQ_MOVE_PENDING;
32

33
	if (unlikely(cpus_empty(irq_desc[irq].pending_mask)))
34 35
		return;

36
	if (!desc->chip->set_affinity)
37 38
		return;

39 40
	assert_spin_locked(&desc->lock);

41
	cpus_and(tmp, irq_desc[irq].pending_mask, cpu_online_map);
42 43 44 45 46 47 48 49 50

	/*
	 * 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!
51 52 53
	 *
	 * For correct operation this depends on the caller
	 * masking the irqs.
54
	 */
55
	if (likely(!cpus_empty(tmp))) {
56
		desc->chip->set_affinity(irq,tmp);
57
	}
58
	cpus_clear(irq_desc[irq].pending_mask);
59
}
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76

void move_native_irq(int irq)
{
	struct irq_desc *desc = irq_desc + irq;

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

	if (likely(!(desc->status & IRQ_DISABLED)))
		desc->chip->disable(irq);

	move_masked_irq(irq);

	if (likely(!(desc->status & IRQ_DISABLED)))
		desc->chip->enable(irq);
}