PCI Probe Question

John Rose johnrose at austin.ibm.com
Wed Jan 28 10:28:22 EST 2004


Hi-

> How about a patch against a clean kernel so I can see it better?  :)

Here's a patch against bkbits.  Jake's fix for probing multifunc devices
with no function 0 will affect code in the same neighorhood, so the
resolution of that will affect this.  Non-Greg readers, find info on
Jake's problem/fix at:
http://www.ussg.iu.edu/hypermail/linux/kernel/0401.3/0766.html

Thanks-
John

diff -Nru a/drivers/pci/probe.c b/drivers/pci/probe.c
--- a/drivers/pci/probe.c	Tue Jan 27 17:22:31 2004
+++ b/drivers/pci/probe.c	Tue Jan 27 17:22:31 2004
@@ -535,6 +535,30 @@
 	return dev;
 }

+struct pci_dev * __devinit
+pci_scan_single_device(struct pci_bus *bus, int devfn)
+{
+	struct pci_dev *dev;
+
+	dev = pci_scan_device(bus, devfn);
+	pci_scan_msi_device(dev);
+
+	if (!dev)
+		return NULL;
+
+	/* Fix up broken headers */
+	pci_fixup_device(PCI_FIXUP_HEADER, dev);
+
+	/*
+	 * Add the device to our list of discovered devices
+	 * and the bus list for fixup functions, etc.
+	 */
+	INIT_LIST_HEAD(&dev->global_list);
+	list_add_tail(&dev->bus_list, &bus->devices);
+
+	return dev;
+}
+
 /**
  * pci_scan_slot - scan a PCI slot on a bus for devices.
  * @bus: PCI bus to scan
@@ -551,34 +575,23 @@
 	for (func = 0; func < 8; func++, devfn++) {
 		struct pci_dev *dev;

-		dev = pci_scan_device(bus, devfn);
-		pci_scan_msi_device(dev);
-		if (func == 0) {
-			if (!dev)
-				break;
+		dev = pci_scan_single_device(bus, devfn);
+		if (dev) {
+			nr++;
+
+			/*
+		 	 * If this is a single function device,
+		 	 * don't scan past the first function.
+		 	 */
+			if (!dev->multifunction)
+				if (func > 0)
+					dev->multifunction = 1;
+				else
+ 					break;
 		} else {
-			if (!dev)
-				continue;
-			dev->multifunction = 1;
+			if (func == 0)
+				break;
 		}
-
-		/* Fix up broken headers */
-		pci_fixup_device(PCI_FIXUP_HEADER, dev);
-
-		/*
-		 * Add the device to our list of discovered devices
-		 * and the bus list for fixup functions, etc.
-		 */
-		INIT_LIST_HEAD(&dev->global_list);
-		list_add_tail(&dev->bus_list, &bus->devices);
-		nr++;
-
-		/*
-		 * If this is a single function device,
-		 * don't scan past the first function.
-		 */
-		if (!dev->multifunction)
-			break;
 	}
 	return nr;
 }
@@ -681,4 +694,5 @@
 EXPORT_SYMBOL(pci_do_scan_bus);
 EXPORT_SYMBOL(pci_scan_slot);
 EXPORT_SYMBOL(pci_scan_bridge);
+EXPORT_SYMBOL(pci_scan_single_device);
 #endif
diff -Nru a/include/linux/pci.h b/include/linux/pci.h
--- a/include/linux/pci.h	Tue Jan 27 17:22:31 2004
+++ b/include/linux/pci.h	Tue Jan 27 17:22:31 2004
@@ -585,6 +585,7 @@
 	return pci_scan_bus_parented(NULL, bus, ops, sysdata);
 }
 int pci_scan_slot(struct pci_bus *bus, int devfn);
+struct pci_dev * pci_scan_single_device(struct pci_bus *bus, int devfn);
 void pci_bus_add_devices(struct pci_bus *bus);
 void pci_name_device(struct pci_dev *dev);
 char *pci_class_name(u32 class);


** Sent via the linuxppc64-dev mail list. See http://lists.linuxppc.org/





More information about the Linuxppc64-dev mailing list