[PATCH] Unclaim PCI slot if driver probing fails.

Matthias Hopf mhopf at suse.de
Wed Jun 24 09:26:23 PDT 2009


Otherwise no subsequent driver will be able to claim this pci slot.
Example for this: fbdev tries to claim, but framebuffer device is not
available. Later on VESA cannot claim the device.
---
 hw/xfree86/common/xf86.h       |    1 +
 hw/xfree86/common/xf86Init.c   |    3 ++-
 hw/xfree86/common/xf86pciBus.c |   19 +++++++++++++++++++
 3 files changed, 22 insertions(+), 1 deletions(-)

diff --git a/hw/xfree86/common/xf86.h b/hw/xfree86/common/xf86.h
index e49f28d..f863840 100644
--- a/hw/xfree86/common/xf86.h
+++ b/hw/xfree86/common/xf86.h
@@ -97,6 +97,7 @@ extern _X_EXPORT Bool VTSwitchEnabled;	/* kbd driver */
 extern _X_EXPORT Bool xf86CheckPciSlot( const struct pci_device * );
 extern _X_EXPORT int xf86ClaimPciSlot( struct pci_device *, DriverPtr drvp,
 		     int chipset, GDevPtr dev, Bool active);
+extern _X_EXPORT void xf86UnclaimPciSlot(struct pci_device *);
 extern _X_EXPORT Bool xf86ParsePciBusString(const char *busID, int *bus, int *device,
 			   int *func);
 extern _X_EXPORT Bool xf86ComparePciBusString(const char *busID, int bus, int device, int func);
diff --git a/hw/xfree86/common/xf86Init.c b/hw/xfree86/common/xf86Init.c
index 11f4cf1..e77ffab 100644
--- a/hw/xfree86/common/xf86Init.c
+++ b/hw/xfree86/common/xf86Init.c
@@ -495,7 +495,8 @@ probe_devices_from_device_sections(DriverPtr drvp)
 		    if ((*drvp->PciProbe)(drvp, entry, pPci,
 					  devices[j].match_data)) {
 			foundScreen = TRUE;
-		    }
+		    } else
+			xf86UnclaimPciSlot(pPci);
 		}
 
 		break;
diff --git a/hw/xfree86/common/xf86pciBus.c b/hw/xfree86/common/xf86pciBus.c
index 586973b..9a9ae40 100644
--- a/hw/xfree86/common/xf86pciBus.c
+++ b/hw/xfree86/common/xf86pciBus.c
@@ -753,6 +753,25 @@ xf86ClaimPciSlot(struct pci_device * d, DriverPtr drvp,
 }
 
 /*
+ * Unclaim PCI slot, e.g. if probing failed, so that a different driver can claim.
+ */
+void
+xf86UnclaimPciSlot(struct pci_device *d)
+{
+    int i;
+
+    for (i = 0; i < xf86NumEntities; i++) {
+	const EntityPtr p = xf86Entities[i];
+
+	if ((p->bus.type == BUS_PCI) && (p->bus.id.pci == d)) {
+	    /* Probably the slot should be deallocated? */
+	    p->bus.type = BUS_NONE;
+	    return;
+	}
+    }
+}
+
+/*
  * Parse a BUS ID string, and return the PCI bus parameters if it was
  * in the correct format for a PCI bus id.
  */
-- 
1.6.0.2


--/04w6evG8XlLl3ft--


More information about the xorg-devel mailing list