From: Jan Beulich Date: Wed, 17 Oct 2012 12:13:20 +0000 (+0200) Subject: x86/HPET: obtain proper lock for changing IRQ affinity X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~7741 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=73562aafb6268132e05b9574923650bdf9bcbc0f;p=xen.git x86/HPET: obtain proper lock for changing IRQ affinity The IRQ descriptor lock should be held while adjusting the affinity of any IRQ; the HPET channel lock isn't sufficient to protect namely against races with moving the IRQ to a different CPU. Signed-off-by: Jan Beulich Acked-by: Keir Fraser --- diff --git a/xen/arch/x86/hpet.c b/xen/arch/x86/hpet.c index d3b0b607a0..c73c398d31 100644 --- a/xen/arch/x86/hpet.c +++ b/xen/arch/x86/hpet.c @@ -436,6 +436,16 @@ static struct hpet_event_channel *hpet_get_channel(unsigned int cpu) return ch; } +static void set_channel_irq_affinity(const struct hpet_event_channel *ch) +{ + struct irq_desc *desc = irq_to_desc(ch->irq); + + ASSERT(!local_irq_is_enabled()); + spin_lock(&desc->lock); + hpet_msi_set_affinity(desc, cpumask_of(ch->cpu)); + spin_unlock(&desc->lock); +} + static void hpet_attach_channel(unsigned int cpu, struct hpet_event_channel *ch) { @@ -450,7 +460,7 @@ static void hpet_attach_channel(unsigned int cpu, if ( ch->cpu != cpu ) return; - hpet_msi_set_affinity(irq_to_desc(ch->irq), cpumask_of(ch->cpu)); + set_channel_irq_affinity(ch); } static void hpet_detach_channel(unsigned int cpu, @@ -472,7 +482,7 @@ static void hpet_detach_channel(unsigned int cpu, } ch->cpu = cpumask_first(ch->cpumask); - hpet_msi_set_affinity(irq_to_desc(ch->irq), cpumask_of(ch->cpu)); + set_channel_irq_affinity(ch); } #include