lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Date:	Sat, 27 Sep 2008 16:28:29 +0800
From:	"Zhao, Yu" <yu.zhao@...el.com>
To:	"linux-pci@...r.kernel.org" <linux-pci@...r.kernel.org>
CC:	Jesse Barnes <jbarnes@...tuousgeek.org>,
	Randy Dunlap <randy.dunlap@...cle.com>,
	Grant Grundler <grundler@...isc-linux.org>,
	Alex Chiang <achiang@...com>, Matthew Wilcox <matthew@....cx>,
	Roland Dreier <rdreier@...co.com>, Greg KH <greg@...ah.com>,
	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
	"kvm@...r.kernel.org" <kvm@...r.kernel.org>,
	"virtualization@...ts.linux-foundation.org" 
	<virtualization@...ts.linux-foundation.org>
Subject: [PATCH 5/6 v3] PCI: reserve bus range for SR-IOV

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

Cc: Jesse Barnes <jbarnes@...tuousgeek.org>
Cc: Randy Dunlap <randy.dunlap@...cle.com>
Cc: Grant Grundler <grundler@...isc-linux.org>
Cc: Alex Chiang <achiang@...com>
Cc: Matthew Wilcox <matthew@....cx>
Cc: Roland Dreier <rdreier@...co.com>
Cc: Greg KH <greg@...ah.com>
Signed-off-by: Yu Zhao <yu.zhao@...el.com>

---
 drivers/pci/iov.c   |   24 ++++++++++++++++++++++++
 drivers/pci/pci.h   |    5 +++++
 drivers/pci/probe.c |    3 +++
 3 files changed, 32 insertions(+), 0 deletions(-)

diff --git a/drivers/pci/iov.c b/drivers/pci/iov.c
index a2b2de9..17ada58 100644
--- a/drivers/pci/iov.c
+++ b/drivers/pci/iov.c
@@ -600,6 +600,30 @@ void pci_iov_remove_sysfs(struct pci_dev *dev)
        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 --git a/drivers/pci/pci.h b/drivers/pci/pci.h
index 11b1d17..7039243 100644
--- a/drivers/pci/pci.h
+++ b/drivers/pci/pci.h
@@ -208,6 +208,7 @@ void pci_iov_remove_sysfs(struct pci_dev *dev);
 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);
+extern int pci_iov_bus_range(struct pci_bus *bus);
 #else
 static inline int pci_iov_init(struct pci_dev *dev)
 {
@@ -231,6 +232,10 @@ static inline int pci_iov_resource_bar(struct pci_dev *dev, int resno,
 {
        return 0;
 }
+extern inline int pci_iov_bus_range(struct pci_bus *bus)
+{
+       return 0;
+}
 #endif /* CONFIG_PCI_IOV */

 #endif /* DRIVERS_PCI_H */
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index f18174e..a0abcde 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -1128,6 +1128,9 @@ unsigned int __devinit pci_scan_child_bus(struct pci_bus *bus)
        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.
--
1.5.6.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ