WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [linux-2.6.18-xen] PCI: reserve bus range for SR-IOV dev

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [linux-2.6.18-xen] PCI: reserve bus range for SR-IOV device
From: "Xen patchbot-linux-2.6.18-xen" <patchbot-linux-2.6.18-xen@xxxxxxxxxxxxxxxxxxx>
Date: Wed, 18 Mar 2009 07:25:25 -0700
Delivery-date: Wed, 18 Mar 2009 07:26:54 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1237376372 0
# Node ID 7544e16acfe9f2c70551f3bfeda1460db37cee22
# Parent  589a78a593f361fcadd57fd4ec0c8a1905a3b312
PCI: reserve bus range for SR-IOV device

Reserve the bus number range used by the Virtual Function when
pcibios_assign_all_busses() returns true.

Signed-off-by: Yu Zhao <yu.zhao@xxxxxxxxx>
---
 drivers/pci/iov.c   |   36 ++++++++++++++++++++++++++++++++++++
 drivers/pci/pci.h   |    5 +++++
 drivers/pci/probe.c |    3 +++
 3 files changed, 44 insertions(+)

diff -r 589a78a593f3 -r 7544e16acfe9 drivers/pci/iov.c
--- a/drivers/pci/iov.c Wed Mar 18 11:39:18 2009 +0000
+++ b/drivers/pci/iov.c Wed Mar 18 11:39:32 2009 +0000
@@ -13,6 +13,18 @@
 #include <linux/delay.h>
 #include "pci.h"
 
+
+static inline u8 virtfn_bus(struct pci_dev *dev, int id)
+{
+       return dev->bus->number + ((dev->devfn + dev->sriov->offset +
+                                   dev->sriov->stride * id) >> 8);
+}
+
+static inline u8 virtfn_devfn(struct pci_dev *dev, int id)
+{
+       return (dev->devfn + dev->sriov->offset +
+               dev->sriov->stride * id) & 0xff;
+}
 
 static int sriov_init(struct pci_dev *dev, int pos)
 {
@@ -202,3 +214,27 @@ void pci_restore_iov_state(struct pci_de
        if (dev->is_physfn)
                sriov_restore_state(dev);
 }
+
+/**
+ * pci_iov_bus_range - find bus range used by Virtual Function
+ * @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;
+       struct pci_dev *dev;
+
+       list_for_each_entry(dev, &bus->devices, bus_list) {
+               if (!dev->is_physfn)
+                       continue;
+               busnr = virtfn_bus(dev, dev->sriov->total - 1);
+               if (busnr > max)
+                       max = busnr;
+       }
+
+       return max ? max - bus->number : 0;
+}
diff -r 589a78a593f3 -r 7544e16acfe9 drivers/pci/pci.h
--- a/drivers/pci/pci.h Wed Mar 18 11:39:18 2009 +0000
+++ b/drivers/pci/pci.h Wed Mar 18 11:39:32 2009 +0000
@@ -155,6 +155,7 @@ extern int pci_iov_resource_bar(struct p
 extern int pci_iov_resource_bar(struct pci_dev *dev, int resno,
                                enum pci_bar_type *type);
 extern void pci_restore_iov_state(struct pci_dev *dev);
+extern int pci_iov_bus_range(struct pci_bus *bus);
 #else
 static inline int pci_iov_init(struct pci_dev *dev)
 {
@@ -172,4 +173,8 @@ static inline void pci_restore_iov_state
 static inline void pci_restore_iov_state(struct pci_dev *dev)
 {
 }
+static inline int pci_iov_bus_range(struct pci_bus *bus)
+{
+       return 0;
+}
 #endif /* CONFIG_PCI_IOV */
diff -r 589a78a593f3 -r 7544e16acfe9 drivers/pci/probe.c
--- a/drivers/pci/probe.c       Wed Mar 18 11:39:18 2009 +0000
+++ b/drivers/pci/probe.c       Wed Mar 18 11:39:32 2009 +0000
@@ -976,6 +976,9 @@ unsigned int __devinit pci_scan_child_bu
        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-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [linux-2.6.18-xen] PCI: reserve bus range for SR-IOV device, Xen patchbot-linux-2.6.18-xen <=