PCI Probe Question
John Rose
johnrose at austin.ibm.com
Wed Jan 28 07:52:50 EST 2004
Hi Greg-
Thanks for responding. I think Paul answered your other questions
better than I could have :)
> How do you all handle this in your boot up code then?
Not sure I understand what you're asking, but I believe that the
hypervisor only allows access (during scan of the PHB device) to the
devfn's corresponding to the slots that your partition currently owns.
> If you convince me you really have to do this, why duplicate the
> existing pci code in your driver? How about just creating a
> pci_scan_single_device() function for the pci core that does that logic
> (and make pci_scan_slot() call it.)
Agreed. I initially wanted to minimize my changes to generic code, but
this looks better. How's this patch?
Thanks-
John
diff -Nru a/drivers/pci/hotplug/rpadlpar_core.c b/drivers/pci/hotplug/rpadlpar_core.c
--- a/drivers/pci/hotplug/rpadlpar_core.c Tue Jan 27 14:41:07 2004
+++ b/drivers/pci/hotplug/rpadlpar_core.c Tue Jan 27 14:41:07 2004
@@ -143,9 +143,9 @@
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 (!pci_scan_single_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 Tue Jan 27 14:41:07 2004
+++ b/drivers/pci/probe.c Tue Jan 27 14:41:07 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,39 +575,17 @@
for (func = 0; func < 8; func++, devfn++) {
struct pci_dev *dev;
- dev = pci_scan_device(bus, devfn);
- pci_scan_msi_device(dev);
-#if 0
- if (func == 0) {
- if (!dev)
+ 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)
break;
- } else {
- if (!dev)
- continue;
- dev->multifunction = 1;
}
-#else
- if (!dev)
- continue;
-#endif
-
- /* 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;
}
@@ -686,4 +688,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 14:41:07 2004
+++ b/include/linux/pci.h Tue Jan 27 14:41:07 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