From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:51353) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R1c3K-0006Vi-IM for qemu-devel@nongnu.org; Thu, 08 Sep 2011 06:41:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1R1c3J-00015L-Ic for qemu-devel@nongnu.org; Thu, 08 Sep 2011 06:41:50 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50947) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R1c3J-00012I-AA for qemu-devel@nongnu.org; Thu, 08 Sep 2011 06:41:49 -0400 Date: Thu, 8 Sep 2011 13:42:42 +0300 From: "Michael S. Tsirkin" Message-ID: <20110908104242.GC25263@redhat.com> References: <4E6045E0.2090701@cn.fujitsu.com> <4E6335E4.6040705@redhat.com> <4E658E2F.6050302@cn.fujitsu.com> <4E65CF9E.20004@redhat.com> <4E66F56D.9070709@cn.fujitsu.com> <20110907115223.GD9337@redhat.com> <4E685D85.6030806@cn.fujitsu.com> <4E686E0C.7090906@cn.fujitsu.com> <4E688E32.7060207@redhat.com> <4E6891B4.5010800@cn.fujitsu.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4E6891B4.5010800@cn.fujitsu.com> Subject: Re: [Qemu-devel] [PATCH] pci: add standard bridge device List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Wen Congyang Cc: Kevin Wolf , Isaku Yamahata , qemu-devel@nongnu.org, Gerd Hoffmann , Avi Kivity On Thu, Sep 08, 2011 at 05:58:12PM +0800, Wen Congyang wrote: > At 09/08/2011 05:43 PM, Gerd Hoffmann Write: > > Hi, > > > >> I modify the code like this, and the PCI_INTERRUPT_LINE register is > >> set, and I can bind > >> it to uio_pci_generic: > > > >> --- a/src/pciinit.c > >> +++ b/src/pciinit.c > >> @@ -575,6 +575,8 @@ static int pci_bios_init_root_regions(u32 start, > >> u32 end) > > > >> pci_bios_init_bus_bases(&busses[0]); > >> - pci_bios_map_device_in_bus(0 /* host bus */); > >> + for (bus = 0; bus<= MaxPCIBus; bus++) { > >> + pci_bios_map_device_in_bus(bus /* host bus */); > > > > No. pci_bios_map_device_in_bus goes down recursively when it finds a > > bridge, so it should cover all devices already. > > Yes, pci_bios_map_device() goes down recursively. The value seems to be wrong though, I think. It seems to simply use the interrupt pin as array index. Instead, each bridge should interrupts as follows: /* Mapping mandated by PCI-to-PCI Bridge architecture specification, * revision 1.2 */ /* Table 9-1: Interrupt Binding for Devices Behind a Bridge */ static int pci_bridge_dev_map_irq_fn(PCIDevice *dev, int irq_num) { return (irq_num + PCI_SLOT(dev->devfn)) % PCI_NUM_PINS; } until we get to the host bridge. > > > >> - pci_bios_init_device_in_bus(0 /* host bus */); > >> + pci_bios_init_device_in_bus(bus /* host bus */); > >> + } > > > > That is correct. Can be done easier though by just not limiting device > > initialization to a specific bus like in the attached patch. Does that > > one work for you? > > I test it, and it works for me. > > Thanks > Wen Congyang > > > > > cheers, > > Gerd