From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:52864) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QWVZd-0006oO-HY for qemu-devel@nongnu.org; Tue, 14 Jun 2011 11:30:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QWVZa-0005Sh-Ma for qemu-devel@nongnu.org; Tue, 14 Jun 2011 11:30:37 -0400 Received: from goliath.siemens.de ([192.35.17.28]:34131) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QWVZZ-0005Rh-6c for qemu-devel@nongnu.org; Tue, 14 Jun 2011 11:30:34 -0400 Message-ID: <4DF77E8E.40806@siemens.com> Date: Tue, 14 Jun 2011 17:30:22 +0200 From: Jan Kiszka MIME-Version: 1.0 References: <21A10B78-49E2-453B-8AE6-48155E2071B5@suse.de> <68B936C0-E230-4B48-A274-CB875ED92D5E@suse.de> <1308053820.17937.72.camel@zakaz.uk.xensource.com> <1D2C3E16-193F-4EEC-B7EF-AE038B4F2EE9@suse.de> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] xen: fix interrupt routing List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefano Stabellini Cc: "xen-devel@lists.xensource.com" , Alexander Graf , "qemu-devel@nongnu.org" , Ian Campbell , Isaku Yamahata On 2011-06-14 15:27, Stefano Stabellini wrote: > On Tue, 14 Jun 2011, Alexander Graf wrote: >>>>>>> static int i440fx_load_old(QEMUFile* f, void *opaque, int version_id) >>>>>>> { >>>>>>> PCII440FXState *d = opaque; >>>>>>> @@ -267,8 +263,17 @@ static PCIBus *i440fx_common_init(const char *device_name, >>>>>>> d = pci_create_simple(b, 0, device_name); >>>>>>> *pi440fx_state = DO_UPCAST(PCII440FXState, dev, d); >>>>>>> >>>>>>> - piix3 = DO_UPCAST(PIIX3State, dev, >>>>>>> - pci_create_simple_multifunction(b, -1, true, "PIIX3")); >>>>>>> + if (xen_enabled()) { >>>>>>> + piix3 = DO_UPCAST(PIIX3State, dev, >>>>>>> + pci_create_simple_multifunction(b, -1, true, "PIIX3-xen")); >>>>>>> + pci_bus_irqs(b, xen_piix3_set_irq, xen_pci_slot_get_pirq, >>>>>>> + piix3, XEN_PIIX_NUM_PIRQS); >>>>>> >>>>>> But with XEN_PIIX_NUM_PIRQS it's not a piix3 anymore, no? What's the reason behind this change? >>>>> >>>>> 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: >>>>> >>>>> /* PRTA: APIC routing table (via non-legacy IOAPIC GSIs). */ >>>>> printf("Name(PRTA, Package() {\n"); >>>>> for ( dev = 1; dev < 32; dev++ ) >>>>> for ( intx = 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"); >>>>> >>>> >>>> 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. >>> >>> 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 get converted using PCI host controller specific logic to 4 interrupt lines which then go into the IO-APIC. >> >> The IO-APIC is a chip with a limited number of pins. IIRC it was 24, could be 26 though. > > The number of redirection entries in the IOAPIC can be discovered > reading from the IOAPICVER register and it is a property of a specific > model of IOAPIC. As a matter of fact Xen's emulated IOAPIC supports more > pins than the most popular IOAPIC used with PIIX3. Do real IOAPICs exist with more than 24 pins? Otherwise there is the risk that OSes aren't well prepared for this oddity - specifically not when the chipset is specified to include a 24-pin IOAPIC. > > >> 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 interrupts. Giving each PCI device its own line, on top of that more than ever could be in real hardware, is a plain hack IMHO. > > Actually this happens quite often: if I am not mistaken all the GSIs > higher than 15 are actually the result of a direct connection between > an interrupt source and the IOAPIC. I have several on my testboxes. Except that the interrupt source is the chipset with its PCI bridge, not individual PCI devices. Jan -- Siemens AG, Corporate Technology, CT T DE IT 1 Corporate Competence Center Embedded Linux From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jan Kiszka Subject: Re: [PATCH] xen: fix interrupt routing Date: Tue, 14 Jun 2011 17:30:22 +0200 Message-ID: <4DF77E8E.40806@siemens.com> References: <21A10B78-49E2-453B-8AE6-48155E2071B5@suse.de> <68B936C0-E230-4B48-A274-CB875ED92D5E@suse.de> <1308053820.17937.72.camel@zakaz.uk.xensource.com> <1D2C3E16-193F-4EEC-B7EF-AE038B4F2EE9@suse.de> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Stefano Stabellini Cc: "xen-devel@lists.xensource.com" , Alexander Graf , "qemu-devel@nongnu.org" , Ian Campbell , Isaku Yamahata , Anthony Liguori List-Id: xen-devel@lists.xenproject.org On 2011-06-14 15:27, Stefano Stabellini wrote: > On Tue, 14 Jun 2011, Alexander Graf wrote: >>>>>>> static int i440fx_load_old(QEMUFile* f, void *opaque, int version_id) >>>>>>> { >>>>>>> PCII440FXState *d = opaque; >>>>>>> @@ -267,8 +263,17 @@ static PCIBus *i440fx_common_init(const char *device_name, >>>>>>> d = pci_create_simple(b, 0, device_name); >>>>>>> *pi440fx_state = DO_UPCAST(PCII440FXState, dev, d); >>>>>>> >>>>>>> - piix3 = DO_UPCAST(PIIX3State, dev, >>>>>>> - pci_create_simple_multifunction(b, -1, true, "PIIX3")); >>>>>>> + if (xen_enabled()) { >>>>>>> + piix3 = DO_UPCAST(PIIX3State, dev, >>>>>>> + pci_create_simple_multifunction(b, -1, true, "PIIX3-xen")); >>>>>>> + pci_bus_irqs(b, xen_piix3_set_irq, xen_pci_slot_get_pirq, >>>>>>> + piix3, XEN_PIIX_NUM_PIRQS); >>>>>> >>>>>> But with XEN_PIIX_NUM_PIRQS it's not a piix3 anymore, no? What's the reason behind this change? >>>>> >>>>> 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: >>>>> >>>>> /* PRTA: APIC routing table (via non-legacy IOAPIC GSIs). */ >>>>> printf("Name(PRTA, Package() {\n"); >>>>> for ( dev = 1; dev < 32; dev++ ) >>>>> for ( intx = 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"); >>>>> >>>> >>>> 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. >>> >>> 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 get converted using PCI host controller specific logic to 4 interrupt lines which then go into the IO-APIC. >> >> The IO-APIC is a chip with a limited number of pins. IIRC it was 24, could be 26 though. > > The number of redirection entries in the IOAPIC can be discovered > reading from the IOAPICVER register and it is a property of a specific > model of IOAPIC. As a matter of fact Xen's emulated IOAPIC supports more > pins than the most popular IOAPIC used with PIIX3. Do real IOAPICs exist with more than 24 pins? Otherwise there is the risk that OSes aren't well prepared for this oddity - specifically not when the chipset is specified to include a 24-pin IOAPIC. > > >> 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 interrupts. Giving each PCI device its own line, on top of that more than ever could be in real hardware, is a plain hack IMHO. > > Actually this happens quite often: if I am not mistaken all the GSIs > higher than 15 are actually the result of a direct connection between > an interrupt source and the IOAPIC. I have several on my testboxes. Except that the interrupt source is the chipset with its PCI bridge, not individual PCI devices. Jan -- Siemens AG, Corporate Technology, CT T DE IT 1 Corporate Competence Center Embedded Linux