Correct another LOR issue with resource allocation. This leaves the

drm_get_resource_* resource allocation a little racy, but they're
    getting called at either X Server startup or driver load, so it's
    serialized anyway.
main
Eric Anholt 2005-11-08 21:36:54 +00:00
parent a10d8178e3
commit c7af46cf7d
2 changed files with 8 additions and 1 deletions

View File

@ -61,12 +61,17 @@ static int drm_alloc_resource(drm_device_t *dev, int resource)
DRM_ERROR("Resource %d too large\n", resource); DRM_ERROR("Resource %d too large\n", resource);
return 1; return 1;
} }
if (dev->pcir[resource] != NULL)
DRM_UNLOCK();
if (dev->pcir[resource] != NULL) {
DRM_LOCK();
return 0; return 0;
}
dev->pcirid[resource] = PCIR_BAR(resource); dev->pcirid[resource] = PCIR_BAR(resource);
dev->pcir[resource] = bus_alloc_resource_any(dev->device, dev->pcir[resource] = bus_alloc_resource_any(dev->device,
SYS_RES_MEMORY, &dev->pcirid[resource], RF_SHAREABLE); SYS_RES_MEMORY, &dev->pcirid[resource], RF_SHAREABLE);
DRM_LOCK();
if (dev->pcir[resource] == NULL) { if (dev->pcir[resource] == NULL) {
DRM_ERROR("Couldn't find resource 0x%x\n", resource); DRM_ERROR("Couldn't find resource 0x%x\n", resource);

View File

@ -508,7 +508,9 @@ static int drm_load(drm_device_t *dev)
TAILQ_INIT(&dev->files); TAILQ_INIT(&dev->files);
if (dev->driver.load != NULL) { if (dev->driver.load != NULL) {
DRM_LOCK();
retcode = dev->driver.load(dev, dev->id_entry->driver_private); retcode = dev->driver.load(dev, dev->id_entry->driver_private);
DRM_UNLOCK();
if (retcode != 0) if (retcode != 0)
goto error; goto error;
} }