File 26063-x86-HPET-affinity-lock.patch of Package xen.openSUSE_12.1_Update
# HG changeset patch
# User Jan Beulich <jbeulich@suse.com>
# Date 1350476000 -7200
# Node ID 1f4be6ee4619c88c273cb457d8e7f1eee49d00dd
# Parent ec8a091efcce717584b00ce76e3cec40a6247ebc
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 <jbeulich@suse.com>
Acked-by: Keir Fraser <keir@xen.org>
--- a/xen/arch/x86/hpet.c
+++ b/xen/arch/x86/hpet.c
@@ -482,6 +482,16 @@ static struct hpet_event_channel *hpet_g
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);
+ desc->handler->set_affinity(ch->irq, cpumask_of_cpu(ch->cpu));
+ spin_unlock(&desc->lock);
+}
+
static void hpet_attach_channel(int cpu, struct hpet_event_channel *ch)
{
ASSERT(spin_is_locked(&ch->lock));
@@ -495,9 +505,7 @@ static void hpet_attach_channel(int cpu,
if ( ch->cpu != cpu )
return;
- /* set irq affinity */
- irq_desc[ch->irq].handler->
- set_affinity(ch->irq, cpumask_of_cpu(ch->cpu));
+ set_channel_irq_affinity(ch);
}
static void hpet_detach_channel(int cpu, struct hpet_event_channel *ch)
@@ -518,9 +526,7 @@ static void hpet_detach_channel(int cpu,
}
ch->cpu = first_cpu(ch->cpumask);
- /* set irq affinity */
- irq_desc[ch->irq].handler->
- set_affinity(ch->irq, cpumask_of_cpu(ch->cpu));
+ set_channel_irq_affinity(ch);
}
#include <asm/mc146818rtc.h>