[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH 5/9] dom0 PCI: reserve bus range for SR-IOV device



Reserve bus range for SR-IOV at device scanning stage.

Signed-off-by: Yu Zhao <yu.zhao@xxxxxxxxx>

diff -r 75504b97c0ab -r f9bb37cf38ed drivers/pci/iov.c
--- a/drivers/pci/iov.c Sat Sep 27 01:27:01 2008 -0400
+++ b/drivers/pci/iov.c Sat Sep 27 01:27:42 2008 -0400
@@ -582,6 +582,30 @@
        kfree(iov->ve);
 }

+/**
+ * pci_iov_bus_range - find bus range used by SR-IOV capability
+ * @bus: the PCI bus
+ *
+ * Returns max number of buses (exclude current one) used by Virtual
+ * Functions.
+ */
+int pci_iov_bus_range(struct pci_bus *bus)
+{
+       int max = 0;
+       u8 busnr, devfn;
+       struct pci_dev *dev;
+
+       list_for_each_entry(dev, &bus->devices, bus_list) {
+               if (!dev->iov)
+                       continue;
+               vf_rid(dev, dev->iov->totalvfs - 1, &busnr, &devfn);
+               if (busnr > max)
+                       max = busnr;
+       }
+
+       return max ? max - bus->number : 0;
+}
+
 int pci_iov_resource_align(struct pci_dev *dev, int resno)
 {
        if (resno < PCI_IOV_RESOURCES || resno > PCI_IOV_RESOURCES_END)
diff -r 75504b97c0ab -r f9bb37cf38ed drivers/pci/pci.h
--- a/drivers/pci/pci.h Sat Sep 27 01:27:01 2008 -0400
+++ b/drivers/pci/pci.h Sat Sep 27 01:27:42 2008 -0400
@@ -160,6 +160,7 @@
 extern void pci_iov_release(struct pci_dev *dev);
 void pci_iov_create_sysfs(struct pci_dev *dev);
 void pci_iov_remove_sysfs(struct pci_dev *dev);
+extern int pci_iov_bus_range(struct pci_bus *bus);
 extern int pci_iov_resource_align(struct pci_dev *dev, int resno);
 extern int pci_iov_resource_bar(struct pci_dev *dev, int resno,
                                enum pci_bar_type *type);
@@ -177,6 +178,10 @@
 static inline void pci_iov_remove_sysfs(struct pci_dev *dev)
 {
 }
+extern inline int pci_iov_bus_range(struct pci_bus *bus)
+{
+       return 0;
+}
 static inline int pci_iov_resource_align(struct pci_dev *dev, int resno)
 {
        return 0;
diff -r 75504b97c0ab -r f9bb37cf38ed drivers/pci/probe.c
--- a/drivers/pci/probe.c       Sat Sep 27 01:27:01 2008 -0400
+++ b/drivers/pci/probe.c       Sat Sep 27 01:27:42 2008 -0400
@@ -969,6 +969,9 @@
        for (devfn = 0; devfn < 0x100; devfn += 8)
                pci_scan_slot(bus, devfn);

+       /* Reserve buses for SR-IOV capability. */
+       max += pci_iov_bus_range(bus);
+
        /*
         * After performing arch-dependent fixup of the bus, look behind
         * all PCI-to-PCI bridges on this bus.

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.