From 43ee8d2ead862f84a4526a472519663ef27a8d6a Mon Sep 17 00:00:00 2001 From: Matthias Hopf Date: Wed, 24 Jun 2009 18:26:23 +0200 Subject: [PATCH] Unclaim PCI slot if driver probing fails. 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 deletion(-) diff --git a/hw/xfree86/common/xf86.h b/hw/xfree86/common/xf86.h index e49f28db0..f8638403b 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 11f4cf1b1..e77ffabf9 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 586973b55..9a9ae4091 100644 --- a/hw/xfree86/common/xf86pciBus.c +++ b/hw/xfree86/common/xf86pciBus.c @@ -752,6 +752,25 @@ xf86ClaimPciSlot(struct pci_device * d, DriverPtr drvp, return -1; } +/* + * 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.