PCI Probe Question

John Rose johnrose at austin.ibm.com
Tue Jan 27 12:11:49 EST 2004


How feasible is the generic portion of the patch below?

Currently, the PCI probe code exports pci_scan_slot() for use by hotplug
(or dlpar) modules.  This turns out to be a problem, because
pci_scan_slot() scans forward for 8 devfn values, starting at the one
passed in.  We need pci_scan_device() to be available for module use.

Scanning the pci_bus corresponding to a phb reveals 3  slots within 8
devfn values.  Consider a phb with 3 slots at devfn values 58, 5a, and
5e.  A dlpar add of the first slot would call scan_slot() with 58, and
scan_slot() adds redudant pci_dev's for the 5a and 5e to the devices
list of the phb bus.

For this case, we already know the devfn value we're interested in.  The
device_node structure for the new slot has it.   If we call
pci_scan_device() directly, we avoid the redundant devices problem.

Thoughts?
John

diff -Nru a/drivers/pci/hotplug/rpadlpar_core.c b/drivers/pci/hotplug/rpadlpar_core.c
--- a/drivers/pci/hotplug/rpadlpar_core.c	Mon Jan 26 18:58:20 2004
+++ b/drivers/pci/hotplug/rpadlpar_core.c	Mon Jan 26 18:58:20 2004
@@ -138,14 +138,36 @@
 	return 0;
 }

+static int dlpar_pci_scan_device(struct pci_bus *bus, int devfn)
+{
+	struct pci_dev *dev;
+
+	dev = pci_scan_device(bus, devfn);
+
+	if (!dev)
+		return 1;
+
+	/* 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 0;
+}
+
 static struct pci_dev *dlpar_pci_add_bus(struct device_node *dn)
 {
 	struct pci_controller *hose = dn->phb;
 	struct pci_dev *dev = NULL;
-
-	/* Scan phb bus for devices, adding new ones to bus->devices */
-	if (!pci_scan_slot(hose->bus, dn->devfn)) {
-		printk(KERN_ERR "%s: found no devices on bus\n", __FUNCTION__);
+
+	/* Scan phb bus for EADS device, adding new one to bus->devices */
+	if (dlpar_pci_scan_device(hose->bus, dn->devfn)) {
+		printk(KERN_ERR "%s: found no device on bus\n", __FUNCTION__);
 		return NULL;
 	}

diff -Nru a/drivers/pci/probe.c b/drivers/pci/probe.c
--- a/drivers/pci/probe.c	Mon Jan 26 18:58:20 2004
+++ b/drivers/pci/probe.c	Mon Jan 26 18:58:20 2004
@@ -483,7 +483,7 @@
  * Read the config data for a PCI device, sanity-check it
  * and fill in the dev structure...
  */
-static struct pci_dev * __devinit
+struct pci_dev * __devinit
 pci_scan_device(struct pci_bus *bus, int devfn)
 {
 	struct pci_dev *dev;
@@ -685,4 +685,5 @@
 EXPORT_SYMBOL(pci_do_scan_bus);
 EXPORT_SYMBOL(pci_scan_slot);
 EXPORT_SYMBOL(pci_scan_bridge);
+EXPORT_SYMBOL(pci_scan_device);
 #endif
diff -Nru a/drivers/pci/quirks.c b/drivers/pci/quirks.c
--- a/drivers/pci/quirks.c	Mon Jan 26 18:58:20 2004
+++ b/drivers/pci/quirks.c	Mon Jan 26 18:58:20 2004
@@ -976,3 +976,7 @@
 	pci_do_fixups(dev, pass, pcibios_fixups);
 	pci_do_fixups(dev, pass, pci_fixups);
 }
+
+#ifdef CONFIG_HOTPLUG
+EXPORT_SYMBOL(pci_fixup_device);
+#endif
diff -Nru a/include/linux/pci.h b/include/linux/pci.h
--- a/include/linux/pci.h	Mon Jan 26 18:58:20 2004
+++ b/include/linux/pci.h	Mon Jan 26 18:58:20 2004
@@ -580,6 +580,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_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