From: Alexander Graf Subject: Re: Re: [PATCH] xen: fix interrupt routing Date: Tue, 14 Jun 2011 14:30:14 +0200 Message-ID: <1D2C3E16-193F-4EEC-B7EF-AE038B4F2EE9@suse.de> References: <21A10B78-49E2-453B-8AE6-48155E2071B5@suse.de> <68B936C0-E230-4B48-A274-CB875ED92D5E@suse.de> <1308053820.17937.72.camel@zakaz.uk.xensource.com> Mime-Version: 1.0 (iPhone Mail 8G4) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Return-path: In-Reply-To: <1308053820.17937.72.camel@zakaz.uk.xensource.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Ian Campbell Cc: Isaku Yamahata , "xen-devel@lists.xensource.com" , "qemu-devel@nongnu.org" , Anthony Liguori , Stefano Stabellini List-Id: xen-devel@lists.xenproject.org Am 14.06.2011 um 14:17 schrieb Ian Campbell : > On Tue, 2011-06-14 at 10:25 +0100, Alexander Graf wrote: >> On 31.05.2011, at 13:05, Stefano Stabellini wrote: >>=20 >>> On Sat, 28 May 2011, Alexander Graf wrote: >>>>=20 >>>> On 26.05.2011, at 17:48, Stefano Stabellini wrote: >>>>=20 >>>>> xen: fix interrupt routing >>>>>=20 >>>>> - remove i440FX-xen and i440fx_write_config_xen >>>>> we don't need to intercept pci config writes to i440FX anymore; >>>>=20 >>>> Why not? In which version? Did anything below change? What about compat= code? Older hypervisor versions? >>>=20 >>> Nothing changed, I think it was a genuine mistake in the original patch >>> series: the intention was to catch the pci config writes to 0x60-0x63 to= >>> reprogram the xen pci link routes accordingly (see >>> xen_piix_pci_write_config_client). If I am not mistaken a similar thing= >>> is done by non-Xen Qemu in piix3_update_irq_levels. >>>=20 >>>=20 >>>>> - introduce PIIX3-xen and piix3_write_config_xen >>>>> we do need to intercept pci config write to the PCI-ISA bridge to upda= te >>>>> the PCI link routing; >>>>>=20 >>>>> - set the number of PIIX3-xen interrupts lines to 128; >>>>>=20 >>>>> Signed-off-by: Stefano Stabellini >>>>>=20 >>>>> diff --git a/hw/pc.h b/hw/pc.h >>>>> index 0dcbee7..6d5730b 100644 >>>>> --- a/hw/pc.h >>>>> +++ b/hw/pc.h >>>>> @@ -176,7 +176,6 @@ struct PCII440FXState; >>>>> typedef struct PCII440FXState PCII440FXState; >>>>>=20 >>>>> PCIBus *i440fx_init(PCII440FXState **pi440fx_state, int *piix_devfn, q= emu_irq *pic, ram_addr_t ram_size); >>>>> -PCIBus *i440fx_xen_init(PCII440FXState **pi440fx_state, int *piix3_de= vfn, qemu_irq *pic, ram_addr_t ram_size); >>>>> void i440fx_init_memory_mappings(PCII440FXState *d); >>>>>=20 >>>>> /* piix4.c */ >>>>> diff --git a/hw/pc_piix.c b/hw/pc_piix.c >>>>> index 9a22a8a..ba198de 100644 >>>>> --- a/hw/pc_piix.c >>>>> +++ b/hw/pc_piix.c >>>>> @@ -124,11 +124,7 @@ static void pc_init1(ram_addr_t ram_size, >>>>> isa_irq =3D qemu_allocate_irqs(isa_irq_handler, isa_irq_state, 24); >>>>>=20 >>>>> if (pci_enabled) { >>>>> - if (!xen_enabled()) { >>>>> - pci_bus =3D i440fx_init(&i440fx_state, &piix3_devfn, isa_= irq, ram_size); >>>>> - } else { >>>>> - pci_bus =3D i440fx_xen_init(&i440fx_state, &piix3_devfn, i= sa_irq, ram_size); >>>>> - } >>>>> + pci_bus =3D i440fx_init(&i440fx_state, &piix3_devfn, isa_irq,= ram_size); >>>>> } else { >>>>> pci_bus =3D NULL; >>>>> i440fx_state =3D NULL; >>>>> diff --git a/hw/piix_pci.c b/hw/piix_pci.c >>>>> index 7f1c4cc..3d73a42 100644 >>>>> --- a/hw/piix_pci.c >>>>> +++ b/hw/piix_pci.c >>>>> @@ -40,6 +40,7 @@ typedef PCIHostState I440FXState; >>>>>=20 >>>>> #define PIIX_NUM_PIC_IRQS 16 /* i8259 * 2 */ >>>>> #define PIIX_NUM_PIRQS 4ULL /* PIRQ[A-D] */ >>>>> +#define XEN_PIIX_NUM_PIRQS 128ULL >>>>> #define PIIX_PIRQC 0x60 >>>>>=20 >>>>> typedef struct PIIX3State { >>>>> @@ -78,6 +79,8 @@ struct PCII440FXState { >>>>> #define I440FX_SMRAM 0x72 >>>>>=20 >>>>> static void piix3_set_irq(void *opaque, int pirq, int level); >>>>> +static void piix3_write_config_xen(PCIDevice *dev, >>>>> + uint32_t address, uint32_t val, int le= n); >>>>>=20 >>>>> /* return the global irq number corresponding to a given device irq >>>>> pin. We could also use the bus number to have a more precise >>>>> @@ -173,13 +176,6 @@ static void i440fx_write_config(PCIDevice *dev, >>>>> } >>>>> } >>>>>=20 >>>>> -static void i440fx_write_config_xen(PCIDevice *dev, >>>>> - uint32_t address, uint32_t val, i= nt len) >>>>> -{ >>>>> - xen_piix_pci_write_config_client(address, val, len); >>>>> - i440fx_write_config(dev, address, val, len); >>>>> -} >>>>> - >>>>> static int i440fx_load_old(QEMUFile* f, void *opaque, int version_id) >>>>> { >>>>> PCII440FXState *d =3D opaque; >>>>> @@ -267,8 +263,17 @@ static PCIBus *i440fx_common_init(const char *dev= ice_name, >>>>> d =3D pci_create_simple(b, 0, device_name); >>>>> *pi440fx_state =3D DO_UPCAST(PCII440FXState, dev, d); >>>>>=20 >>>>> - piix3 =3D DO_UPCAST(PIIX3State, dev, >>>>> - pci_create_simple_multifunction(b, -1, true, "P= IIX3")); >>>>> + if (xen_enabled()) { >>>>> + piix3 =3D DO_UPCAST(PIIX3State, dev, >>>>> + pci_create_simple_multifunction(b, -1, true, "PIIX3-x= en")); >>>>> + pci_bus_irqs(b, xen_piix3_set_irq, xen_pci_slot_get_pirq, >>>>> + piix3, XEN_PIIX_NUM_PIRQS); >>>>=20 >>>> But with XEN_PIIX_NUM_PIRQS it's not a piix3 anymore, no? What's the re= ason behind this change? >>>=20 >>> It is still a piix3, but also provides non-legacy interrupt links to the= >>> IO-APIC. >>> The four pins of each PCI device on the bus not only are routed to the >>> normal four pirqs (programmed writing to 0x60-0x63, see above) but also >>> they are connected to the IO-APIC directly. >>> These additional routes can only be discovered through ACPI, so you need= >>> matching ACPI tables. We used to build the old ACPI tables like this: >>>=20 >>> /* PRTA: APIC routing table (via non-legacy IOAPIC GSIs). */ >>> printf("Name(PRTA, Package() {\n"); >>> for ( dev =3D 1; dev < 32; dev++ ) >>> for ( intx =3D 0; intx < 4; intx++ ) /* INTA-D */ >>> printf("Package(){0x%04xffff, %u, 0, %u},\n", >>> dev, intx, ((dev*4+dev/8+intx)&31)+16); >>> printf("})\n"); >>>=20 >>=20 >> Interesting concept, but completely non-standard and very much >> different from real hardware. Please at least add a comment there to >> show readers that Xen is doing a hack which is not at all related to >> how the PIIX really works. >=20 > Isn't this more a function of the "wires" on the motherboard than the > PIIX specifically? i.e. this just encodes the permutation of the wires > from the PCI slots into the IO-APIC input pins (bypassing the PIIX, > which is only used for legacy ISA IRQs i.e. by non-APIC aware OSes)? Interrupts with PCI work slightly different. PCI devices can map (themselves= or by software) to one of 4 interrupt lines: INTA, INTB, INTC, INTD. These g= et converted using PCI host controller specific logic to 4 interrupt lines w= hich then go into the IO-APIC. The IO-APIC is a chip with a limited number of pins. IIRC it was 24, could b= e 26 though. I haven't seen a single case where PCI devices have a direct link to the IO-= APIC. I also have not seen any PCI host controller that exports more than 4 i= nterrupts. Giving each PCI device its own line, on top of that more than eve= r could be in real hardware, is a plain hack IMHO. Did this really give you actual performance/latency/scalability gains? I sti= ll think for devices that matter, we should go with MSI rather than deriving= from real hw. Alex >=20