From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:59657) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SQKXO-0008Q5-3n for qemu-devel@nongnu.org; Fri, 04 May 2012 11:35:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SQKXM-0007uB-8Y for qemu-devel@nongnu.org; Fri, 04 May 2012 11:35:17 -0400 Received: from mx1.redhat.com ([209.132.183.28]:28421) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SQKXM-0007u3-09 for qemu-devel@nongnu.org; Fri, 04 May 2012 11:35:16 -0400 Message-ID: <4FA3F72E.7080103@redhat.com> Date: Fri, 04 May 2012 17:35:10 +0200 From: Gerd Hoffmann MIME-Version: 1.0 References: <1336119687-6295-1-git-send-email-kraxel@redhat.com> <1336119687-6295-2-git-send-email-kraxel@redhat.com> <20120504131546.GA668@morn.localdomain> In-Reply-To: <20120504131546.GA668@morn.localdomain> Content-Type: multipart/mixed; boundary="------------010708050805040309010703" Subject: Re: [Qemu-devel] [SeaBIOS] [seabios patch 1/5] pci: init all devices List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Kevin O'Connor Cc: seabios@seabios.org, qemu-devel@nongnu.org This is a multi-part message in MIME format. --------------010708050805040309010703 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit On 05/04/12 15:15, Kevin O'Connor wrote: > On Fri, May 04, 2012 at 10:21:23AM +0200, Gerd Hoffmann wrote: >> seabios used to initialize root bus devices only, with this patch >> devices behind pci bridges are initialized too. This allows to boot >> from virtio devices behind pci bridges. >> >> Signed-off-by: Gerd Hoffmann >> --- >> src/pciinit.c | 3 --- >> 1 files changed, 0 insertions(+), 3 deletions(-) >> >> diff --git a/src/pciinit.c b/src/pciinit.c >> index 25b04ac..6a7a0d2 100644 >> --- a/src/pciinit.c >> +++ b/src/pciinit.c >> @@ -213,9 +213,6 @@ static void pci_bios_init_devices(void) >> { >> struct pci_device *pci; >> foreachpci(pci) { >> - if (pci_bdf_to_bus(pci->bdf) != 0) >> - // Only init devices on host bus. >> - break; > > I think this will then assign an incorrect PCI_INTERRUPT_LINE value to > non root bus devices. Attached patch should fix it if I read the specs correctly. Untested though, review appreciated. cheers, Gerd --------------010708050805040309010703 Content-Type: text/plain; name="0001-pci-handle-bridge-irq-mapping.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="0001-pci-handle-bridge-irq-mapping.patch" >>From a36868ea1b32978244624a62ce7742346cbf5e50 Mon Sep 17 00:00:00 2001 From: Gerd Hoffmann Date: Fri, 4 May 2012 17:33:36 +0200 Subject: [PATCH] pci: handle bridge irq mapping Signed-off-by: Gerd Hoffmann --- src/pciinit.c | 12 +++++++++--- 1 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/pciinit.c b/src/pciinit.c index 52c5b69..e2bdc0c 100644 --- a/src/pciinit.c +++ b/src/pciinit.c @@ -88,9 +88,15 @@ const u8 pci_irqs[4] = { }; // Return the global irq number corresponding to a host bus device irq pin. -static int pci_slot_get_irq(u16 bdf, int pin) +static int pci_slot_get_irq(struct pci_device *pci, int pin) { - int slot_addend = pci_bdf_to_dev(bdf) - 1; + int slot_addend = 0; + + while (pci->parent != NULL) { + slot_addend += pci_bdf_to_dev(pci->bdf); + pci = pci->parent; + } + slot_addend += pci_bdf_to_dev(pci->bdf) - 1; return pci_irqs[(pin - 1 + slot_addend) & 3]; } @@ -211,7 +217,7 @@ static void pci_bios_init_device(struct pci_device *pci) /* map the interrupt */ int pin = pci_config_readb(bdf, PCI_INTERRUPT_PIN); if (pin != 0) - pci_config_writeb(bdf, PCI_INTERRUPT_LINE, pci_slot_get_irq(bdf, pin)); + pci_config_writeb(bdf, PCI_INTERRUPT_LINE, pci_slot_get_irq(pci, pin)); pci_init_device(pci_device_tbl, pci, NULL); } -- 1.7.1 --------------010708050805040309010703--