From: "Jan Beulich" Subject: [PATCH v2 1/3] x86/HPET: obtain proper lock for changing IRQ affinity Date: Wed, 17 Oct 2012 12:45:55 +0100 Message-ID: <507EB69302000078000A1F46@nat28.tlf.novell.com> References: <507DA35102000078000A1C26@nat28.tlf.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__PartBF8E9C63.1__=" Return-path: In-Reply-To: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Keir Fraser Cc: xen-devel List-Id: xen-devel@lists.xenproject.org This is a MIME message. If you are reading this text, you may want to consider changing to a mail reader or gateway that understands how to properly handle MIME multipart messages. --=__PartBF8E9C63.1__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline 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 --- v2: rename new helper function --- a/xen/arch/x86/hpet.c +++ b/xen/arch/x86/hpet.c @@ -436,6 +436,16 @@ static struct hpet_event_channel *hpet_g return ch; } =20 +static void set_channel_irq_affinity(const struct hpet_event_channel *ch) +{ + struct irq_desc *desc =3D 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 if ( ch->cpu !=3D cpu ) return; =20 - hpet_msi_set_affinity(irq_to_desc(ch->irq), cpumask_of(ch->cpu)); + set_channel_irq_affinity(ch); } =20 static void hpet_detach_channel(unsigned int cpu, @@ -472,7 +482,7 @@ static void hpet_detach_channel(unsigned } =20 ch->cpu =3D cpumask_first(ch->cpumask); - hpet_msi_set_affinity(irq_to_desc(ch->irq), cpumask_of(ch->cpu)); + set_channel_irq_affinity(ch); } =20 #include --=__PartBF8E9C63.1__= Content-Type: text/plain; name="x86-HPET-affinity-lock.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="x86-HPET-affinity-lock.patch" x86/HPET: obtain proper lock for changing IRQ affinity=0A=0AThe IRQ = descriptor lock should be held while adjusting the affinity of=0Aany IRQ; = the HPET channel lock isn't sufficient to protect namely=0Aagainst races = with moving the IRQ to a different CPU.=0A=0ASigned-off-by: Jan Beulich = =0A---=0Av2: rename new helper function=0A=0A--- = a/xen/arch/x86/hpet.c=0A+++ b/xen/arch/x86/hpet.c=0A@@ -436,6 +436,16 @@ = static struct hpet_event_channel *hpet_g=0A return ch;=0A }=0A = =0A+static void set_channel_irq_affinity(const struct hpet_event_channel = *ch)=0A+{=0A+ struct irq_desc *desc =3D irq_to_desc(ch->irq);=0A+=0A+ = ASSERT(!local_irq_is_enabled());=0A+ spin_lock(&desc->lock);=0A+ = hpet_msi_set_affinity(desc, cpumask_of(ch->cpu));=0A+ spin_unlock(&desc-= >lock);=0A+}=0A+=0A static void hpet_attach_channel(unsigned int cpu,=0A = struct hpet_event_channel *ch)=0A {=0A@@ = -450,7 +460,7 @@ static void hpet_attach_channel(unsigned=0A if ( = ch->cpu !=3D cpu )=0A return;=0A =0A- hpet_msi_set_affinity(irq_= to_desc(ch->irq), cpumask_of(ch->cpu));=0A+ set_channel_irq_affinity(ch)= ;=0A }=0A =0A static void hpet_detach_channel(unsigned int cpu,=0A@@ = -472,7 +482,7 @@ static void hpet_detach_channel(unsigned=0A }=0A =0A = ch->cpu =3D cpumask_first(ch->cpumask);=0A- hpet_msi_set_affinity(irq= _to_desc(ch->irq), cpumask_of(ch->cpu));=0A+ set_channel_irq_affinity(ch= );=0A }=0A =0A #include =0A --=__PartBF8E9C63.1__= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel --=__PartBF8E9C63.1__=--