From: "Jan Beulich" Subject: [PATCH] x86/IO-APIC: refine EOI-ing of migrating level interrupts Date: Tue, 15 Nov 2011 13:14:12 +0000 Message-ID: <4EC273B40200007800061145@nat28.tlf.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__Part351AB4B4.0__=" Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: "xen-devel@lists.xensource.com" 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. --=__Part351AB4B4.0__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Rather than going through all IO-APICs and calling io_apic_eoi_vector() for the vector in question, just use eoi_IO_APIC_irq(). This in turn allows to eliminate quite a bit of other code. Signed-off-by: Jan Beulich --- a/xen/arch/x86/io_apic.c +++ b/xen/arch/x86/io_apic.c @@ -69,10 +69,6 @@ int __read_mostly nr_ioapics; =20 #define ioapic_has_eoi_reg(apic) (mp_ioapics[(apic)].mpc_apicver >=3D = 0x20) =20 -#define io_apic_eoi_vector(apic, vector) io_apic_eoi((apic), (vector), = -1) -#define io_apic_eoi_pin(apic, pin) io_apic_eoi((apic), -1, (pin)) - - /* * This is performance-critical, we want to do it O(1) * @@ -213,21 +209,18 @@ static void ioapic_write_entry( spin_unlock_irqrestore(&ioapic_lock, flags); } =20 -/* EOI an IO-APIC entry. One of vector or pin may be -1, indicating that - * it should be worked out using the other. This function expect that = the - * ioapic_lock is taken, and interrupts are disabled (or there is a good = reason - * not to), and that if both pin and vector are passed, that they refer = to the +/* EOI an IO-APIC entry. Vector may be -1, indicating that it should be + * worked out using the pin. This function expects that the ioapic_lock = is + * being held, and interrupts are disabled (or there is a good reason not + * to), and that if both pin and vector are passed, that they refer to = the * same redirection entry in the IO-APIC. */ static void __io_apic_eoi(unsigned int apic, unsigned int vector, = unsigned int pin) { - /* Ensure some useful information is passed in */ - BUG_ON( (vector =3D=3D -1 && pin =3D=3D -1) ); - =20 /* Prefer the use of the EOI register if available */ if ( ioapic_has_eoi_reg(apic) ) { /* If vector is unknown, read it from the IO-APIC */ - if ( vector =3D=3D -1 ) + if ( vector =3D=3D IRQ_VECTOR_UNASSIGNED ) vector =3D __ioapic_read_entry(apic, pin, TRUE).vector; =20 *(IO_APIC_BASE(apic)+16) =3D vector; @@ -239,42 +232,6 @@ static void __io_apic_eoi(unsigned int a struct IO_APIC_route_entry entry; bool_t need_to_unmask =3D 0; =20 - /* If pin is unknown, search for it */ - if ( pin =3D=3D -1 ) - { - unsigned int p; - for ( p =3D 0; p < nr_ioapic_entries[apic]; ++p ) - { - entry =3D __ioapic_read_entry(apic, p, TRUE); - if ( entry.vector =3D=3D vector ) - { - pin =3D p; - /* break; */ - - /* Here should be a break out of the loop, but at = the=20 - * Xen code doesn't actually prevent multiple IO-APIC - * entries being assigned the same vector, so EOI all - * pins which have the correct vector. - * - * Remove the following code when the above assertion - * is fulfilled. */ - __io_apic_eoi(apic, vector, p); - } - } - =20 - /* If search fails, nothing to do */ - - /* if ( pin =3D=3D -1 ) */ - - /* Because the loop wasn't broken out of (see comment above), - * all relevant pins have been EOI, so we can always return. - *=20 - * Re-instate the if statement above when the Xen logic has = been - * fixed.*/ - - return; - } - entry =3D __ioapic_read_entry(apic, pin, TRUE); =20 if ( ! entry.mask ) @@ -301,17 +258,6 @@ static void __io_apic_eoi(unsigned int a } } =20 -/* EOI an IO-APIC entry. One of vector or pin may be -1, indicating that - * it should be worked out using the other. This function disables = interrupts - * and takes the ioapic_lock */ -static void io_apic_eoi(unsigned int apic, unsigned int vector, unsigned = int pin) -{ - unsigned int flags; - spin_lock_irqsave(&ioapic_lock, flags); - __io_apic_eoi(apic, vector, pin); - spin_unlock_irqrestore(&ioapic_lock, flags); -} - /* * Saves all the IO-APIC RTE's */ @@ -1693,11 +1639,7 @@ static void end_level_ioapic_irq(struct=20 =20 /* Manually EOI the old vector if we are moving to the new */ if ( vector && i !=3D vector ) - { - int ioapic; - for (ioapic =3D 0; ioapic < nr_ioapics; ioapic++) - io_apic_eoi_vector(ioapic, i); - } + eoi_IO_APIC_irq(desc); =20 v =3D apic_read(APIC_TMR + ((i & ~0x1f) >> 1)); =20 --=__Part351AB4B4.0__= Content-Type: text/plain; name="x86-ioapic-EOI-after-migration.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="x86-ioapic-EOI-after-migration.patch" x86/IO-APIC: refine EOI-ing of migrating level interrupts=0A=0ARather than = going through all IO-APICs and calling io_apic_eoi_vector()=0Afor the = vector in question, just use eoi_IO_APIC_irq().=0A=0AThis in turn allows = to eliminate quite a bit of other code.=0A=0ASigned-off-by: Jan Beulich = =0A=0A--- a/xen/arch/x86/io_apic.c=0A+++ b/xen/arch/x86/= io_apic.c=0A@@ -69,10 +69,6 @@ int __read_mostly nr_ioapics;=0A =0A = #define ioapic_has_eoi_reg(apic) (mp_ioapics[(apic)].mpc_apicver >=3D = 0x20)=0A =0A-#define io_apic_eoi_vector(apic, vector) io_apic_eoi((apic), = (vector), -1)=0A-#define io_apic_eoi_pin(apic, pin) io_apic_eoi((apic), = -1, (pin))=0A-=0A-=0A /*=0A * This is performance-critical, we want to do = it O(1)=0A *=0A@@ -213,21 +209,18 @@ static void ioapic_write_entry(=0A = spin_unlock_irqrestore(&ioapic_lock, flags);=0A }=0A =0A-/* EOI an = IO-APIC entry. One of vector or pin may be -1, indicating that=0A- * it = should be worked out using the other. This function expect that the=0A- * = ioapic_lock is taken, and interrupts are disabled (or there is a good = reason=0A- * not to), and that if both pin and vector are passed, that = they refer to the=0A+/* EOI an IO-APIC entry. Vector may be -1, indicating= that it should be=0A+ * worked out using the pin. This function expects = that the ioapic_lock is=0A+ * being held, and interrupts are disabled (or = there is a good reason not=0A+ * to), and that if both pin and vector are = passed, that they refer to the=0A * same redirection entry in the = IO-APIC. */=0A static void __io_apic_eoi(unsigned int apic, unsigned int = vector, unsigned int pin)=0A {=0A- /* Ensure some useful information is = passed in */=0A- BUG_ON( (vector =3D=3D -1 && pin =3D=3D -1) );=0A- = =0A /* Prefer the use of the EOI register if available */=0A if ( = ioapic_has_eoi_reg(apic) )=0A {=0A /* If vector is unknown, = read it from the IO-APIC */=0A- if ( vector =3D=3D -1 )=0A+ = if ( vector =3D=3D IRQ_VECTOR_UNASSIGNED )=0A vector =3D = __ioapic_read_entry(apic, pin, TRUE).vector;=0A =0A *(IO_APIC_BASE(= apic)+16) =3D vector;=0A@@ -239,42 +232,6 @@ static void __io_apic_eoi(unsi= gned int a=0A struct IO_APIC_route_entry entry;=0A bool_t = need_to_unmask =3D 0;=0A =0A- /* If pin is unknown, search for it = */=0A- if ( pin =3D=3D -1 )=0A- {=0A- unsigned = int p;=0A- for ( p =3D 0; p < nr_ioapic_entries[apic]; ++p = )=0A- {=0A- entry =3D __ioapic_read_entry(apic, = p, TRUE);=0A- if ( entry.vector =3D=3D vector )=0A- = {=0A- pin =3D p;=0A- /* = break; */=0A-=0A- /* Here should be a break out of the = loop, but at the =0A- * Xen code doesn't actually = prevent multiple IO-APIC=0A- * entries being assigned = the same vector, so EOI all=0A- * pins which have the = correct vector.=0A- *=0A- * Remove = the following code when the above assertion=0A- * is = fulfilled. */=0A- __io_apic_eoi(apic, vector, p);=0A- = }=0A- }=0A- =0A- /* If = search fails, nothing to do */=0A-=0A- /* if ( pin =3D=3D -1 ) = */=0A-=0A- /* Because the loop wasn't broken out of (see = comment above),=0A- * all relevant pins have been EOI, so we = can always return.=0A- * =0A- * Re-instate the if = statement above when the Xen logic has been=0A- * fixed.*/=0A-= =0A- return;=0A- }=0A-=0A entry =3D __ioapic_read= _entry(apic, pin, TRUE);=0A =0A if ( ! entry.mask )=0A@@ -301,17 = +258,6 @@ static void __io_apic_eoi(unsigned int a=0A }=0A }=0A =0A-/* = EOI an IO-APIC entry. One of vector or pin may be -1, indicating that=0A- = * it should be worked out using the other. This function disables = interrupts=0A- * and takes the ioapic_lock */=0A-static void io_apic_eoi(un= signed int apic, unsigned int vector, unsigned int pin)=0A-{=0A- = unsigned int flags;=0A- spin_lock_irqsave(&ioapic_lock, flags);=0A- = __io_apic_eoi(apic, vector, pin);=0A- spin_unlock_irqrestore(&ioapic_loc= k, flags);=0A-}=0A-=0A /*=0A * Saves all the IO-APIC RTE's=0A */=0A@@ = -1693,11 +1639,7 @@ static void end_level_ioapic_irq(struct =0A =0A /* = Manually EOI the old vector if we are moving to the new */=0A if ( = vector && i !=3D vector )=0A- {=0A- int ioapic;=0A- for = (ioapic =3D 0; ioapic < nr_ioapics; ioapic++)=0A- io_apic_eoi_ve= ctor(ioapic, i);=0A- }=0A+ eoi_IO_APIC_irq(desc);=0A =0A v = =3D apic_read(APIC_TMR + ((i & ~0x1f) >> 1));=0A =0A --=__Part351AB4B4.0__= 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.xensource.com http://lists.xensource.com/xen-devel --=__Part351AB4B4.0__=--