Commit 39f73e81 authored by Dave Airlie's avatar Dave Airlie
Browse files

xf86/pci: fix slot claiming counting.



Currently if we claim a slot for a PCI driver, we never let it go properly,
this prevents the fallback probe from reusing the slot, even though it
isn't claimed for that pci slot.

So if you set the modesetting driver to point at a specific kms device,
that isn't a PCI device (i.e. USB dongle), then the modesetting driver
loads, the pci probe tries to bind the config slot to the primary PCI
device, however we then check the kms device bus id to discover it
isn't valid. However we don't remove the claim on the slot. Next the
old probe function is called and there is no slots to claim.

This patch fixes that and converts the pciSlotClaimed boolean into
a counter, and changes the unclaim api to take a device pointer
to remove from the entity.
Reviewed-by: Adam Jackson's avatarAdam Jackson <ajax@redhat.com>
Signed-off-by: default avatarDave Airlie <airlied@redhat.com>
parent 07dcc3f1
......@@ -97,12 +97,12 @@ extern _X_EXPORT Bool VTSwitchEnabled; /* kbd driver */
/* PCI related */
#ifdef XSERVER_LIBPCIACCESS
#include <pciaccess.h>
extern _X_EXPORT Bool pciSlotClaimed;
extern _X_EXPORT int pciSlotClaimed;
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 void xf86UnclaimPciSlot(struct pci_device *, GDevPtr dev);
extern _X_EXPORT Bool xf86ParsePciBusString(const char *busID, int *bus,
int *device, int *func);
extern _X_EXPORT Bool xf86ComparePciBusString(const char *busID, int bus,
......
......@@ -420,6 +420,26 @@ xf86AddDevToEntity(int entityIndex, GDevPtr dev)
dev->claimed = TRUE;
}
void
xf86RemoveDevFromEntity(int entityIndex, GDevPtr dev)
{
EntityPtr pEnt;
int i, j;
if (entityIndex >= xf86NumEntities)
return;
pEnt = xf86Entities[entityIndex];
for (i = 0; i < pEnt->numInstances; i++) {
if (pEnt->devices[i] == dev) {
for (j = i; j < pEnt->numInstances - 1; j++)
pEnt->devices[j] = pEnt->devices[j + 1];
break;
}
}
pEnt->numInstances--;
dev->claimed = FALSE;
}
/*
* xf86GetEntityInfo() -- This function hands information from the
* EntityRec struct to the drivers. The EntityRec structure itself
......
......@@ -116,6 +116,7 @@ extern _X_EXPORT void xf86AccessLeave(void);
extern _X_EXPORT void xf86PostProbe(void);
extern _X_EXPORT void xf86ClearEntityListForScreen(int scrnIndex);
extern _X_EXPORT void xf86AddDevToEntity(int entityIndex, GDevPtr dev);
extern _X_EXPORT void xf86RemoveDevFromEntity(int entityIndex, GDevPtr dev);
/* xf86Config.c */
......
......@@ -52,7 +52,7 @@
#define PCI_VENDOR_GENERIC 0x00FF
/* Bus-specific globals */
Bool pciSlotClaimed = FALSE;
int pciSlotClaimed = 0;
#define PCIINFOCLASSES(c) \
( (((c) & 0x00ff0000) == (PCI_CLASS_PREHISTORIC << 16)) \
......@@ -223,7 +223,7 @@ xf86ClaimPciSlot(struct pci_device *d, DriverPtr drvp,
p->inUse = FALSE;
if (dev)
xf86AddDevToEntity(num, dev);
pciSlotClaimed = TRUE;
pciSlotClaimed++;
return num;
}
......@@ -235,7 +235,7 @@ 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)
xf86UnclaimPciSlot(struct pci_device *d, GDevPtr dev)
{
int i;
......@@ -244,6 +244,8 @@ xf86UnclaimPciSlot(struct pci_device *d)
if ((p->bus.type == BUS_PCI) && (p->bus.id.pci == d)) {
/* Probably the slot should be deallocated? */
xf86RemoveDevFromEntity(i, dev);
pciSlotClaimed--;
p->bus.type = BUS_NONE;
return;
}
......@@ -537,7 +539,7 @@ xf86PciProbeDev(DriverPtr drvp)
foundScreen = TRUE;
}
else
xf86UnclaimPciSlot(pPci);
xf86UnclaimPciSlot(pPci, devList[i]);
}
break;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment