]> git.proxmox.com Git - mirror_qemu.git/commitdiff
pci: insert assert that auto-assigned-address function is single function device.
authorIsaku Yamahata <yamahata@valinux.co.jp>
Wed, 23 Jun 2010 07:15:26 +0000 (16:15 +0900)
committerBlue Swirl <blauwirbel@gmail.com>
Sun, 11 Jul 2010 17:00:53 +0000 (20:00 +0300)
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 <yamahata@valinux.co.jp>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
hw/pci.c
hw/pci.h

index a7ff5668a717434108daba628a559a6d9b3327bc..11d9b70eca4dbda794fd8fe7662a1ad507ce76c4 100644 (file)
--- a/hw/pci.c
+++ b/hw/pci.c
@@ -227,6 +227,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;
 
     /* host bridge */
@@ -608,7 +609,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;
         }
index 3a15bd40102d856ba6d70fde8eb6e5f641f7dd97..68d5c4ee253fbf5ac74e1291d6b7f55e02231764 100644 (file)
--- 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"