From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=48928 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1ORN07-0004kN-Ae for qemu-devel@nongnu.org; Wed, 23 Jun 2010 06:16:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1ORN06-0001IF-1G for qemu-devel@nongnu.org; Wed, 23 Jun 2010 06:16:11 -0400 Received: from mx1.redhat.com ([209.132.183.28]:4740) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1ORN05-0001I2-R3 for qemu-devel@nongnu.org; Wed, 23 Jun 2010 06:16:10 -0400 Date: Wed, 23 Jun 2010 13:11:00 +0300 From: "Michael S. Tsirkin" Message-ID: <20100623101100.GB9835@redhat.com> References: <504880ade711145a5094f754994e7d5344f437ad.1277277076.git.yamahata@valinux.co.jp> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <504880ade711145a5094f754994e7d5344f437ad.1277277076.git.yamahata@valinux.co.jp> Subject: [Qemu-devel] Re: [PATCH v5 2/9] pci: insert assert that auto-assigned-address function is single function device. List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Isaku Yamahata Cc: blauwirbel@gmail.com, yu.liu@freescale.com, qemu-devel@nongnu.org, aurelien@aurel32.net, paul@codesourcery.com On Wed, Jun 23, 2010 at 04:15:26PM +0900, Isaku Yamahata wrote: > Auto-assigned-address pci function (passing devfn = -1) is always > single function. > This patch adds assert() to guarantee that auto-assigned-address function > is always single function device at function = 0. > > Signed-off-by: Isaku Yamahata So this means we must pass PCI_DEVFN(x, 0) to pci_register_bus? > --- > changes v2 -> v3 > split out into PCI_DEVFN() patch and assert patch. > --- > hw/pci.c | 3 ++- > hw/pci.h | 1 + > 2 files changed, 3 insertions(+), 1 deletions(-) > > diff --git a/hw/pci.c b/hw/pci.c > index ef17eb4..1ba209f 100644 > --- a/hw/pci.c > +++ b/hw/pci.c > @@ -224,6 +224,7 @@ void pci_bus_new_inplace(PCIBus *bus, DeviceState *parent, > const char *name, int devfn_min) > { > qbus_create_inplace(&bus->qbus, &pci_bus_info, parent, name); > + assert(PCI_FUNC(devfn_min) == 0); > bus->devfn_min = devfn_min; > QLIST_INIT(&bus->child); > vmstate_register(-1, &vmstate_pcibus, bus); > @@ -601,7 +602,7 @@ static PCIDevice *do_pci_register_device(PCIDevice *pci_dev, PCIBus *bus, > { > if (devfn < 0) { > for(devfn = bus->devfn_min ; devfn < ARRAY_SIZE(bus->devices); > - devfn += 8) { > + devfn += PCI_FUNC_MAX) { > if (!bus->devices[devfn]) > goto found; > } > diff --git a/hw/pci.h b/hw/pci.h > index 6a2bc6a..077387d 100644 > --- a/hw/pci.h > +++ b/hw/pci.h > @@ -14,6 +14,7 @@ > #define PCI_DEVFN(slot, func) ((((slot) & 0x1f) << 3) | ((func) & 0x07)) > #define PCI_SLOT(devfn) (((devfn) >> 3) & 0x1f) > #define PCI_FUNC(devfn) ((devfn) & 0x07) > +#define PCI_FUNC_MAX 8 > > /* Class, Vendor and Device IDs from Linux's pci_ids.h */ > #include "pci_ids.h" > -- > 1.6.6.1