svn commit: r196464 - head/sys/dev/drm
Robert Noland
rnoland at FreeBSD.org
Sun Aug 23 14:27:47 UTC 2009
Author: rnoland
Date: Sun Aug 23 14:27:46 2009
New Revision: 196464
URL: http://svn.freebsd.org/changeset/base/196464
Log:
Clean up the locking in drm_alloc_resource()
MFC after: 2 weeks
Modified:
head/sys/dev/drm/drm_bufs.c
Modified: head/sys/dev/drm/drm_bufs.c
==============================================================================
--- head/sys/dev/drm/drm_bufs.c Sun Aug 23 14:15:28 2009 (r196463)
+++ head/sys/dev/drm/drm_bufs.c Sun Aug 23 14:27:46 2009 (r196464)
@@ -45,27 +45,35 @@ __FBSDID("$FreeBSD$");
*/
static int drm_alloc_resource(struct drm_device *dev, int resource)
{
+ struct resource *res;
+ int rid;
+
+ DRM_SPINLOCK_ASSERT(&dev->dev_lock);
+
if (resource >= DRM_MAX_PCI_RESOURCE) {
DRM_ERROR("Resource %d too large\n", resource);
return 1;
}
- DRM_UNLOCK();
if (dev->pcir[resource] != NULL) {
- DRM_LOCK();
return 0;
}
- dev->pcirid[resource] = PCIR_BAR(resource);
- dev->pcir[resource] = bus_alloc_resource_any(dev->device,
- SYS_RES_MEMORY, &dev->pcirid[resource], RF_SHAREABLE);
+ DRM_UNLOCK();
+ rid = PCIR_BAR(resource);
+ res = bus_alloc_resource_any(dev->device, SYS_RES_MEMORY, &rid,
+ RF_SHAREABLE);
DRM_LOCK();
-
- if (dev->pcir[resource] == NULL) {
+ if (res == NULL) {
DRM_ERROR("Couldn't find resource 0x%x\n", resource);
return 1;
}
+ if (dev->pcir[resource] == NULL) {
+ dev->pcirid[resource] = rid;
+ dev->pcir[resource] = res;
+ }
+
return 0;
}
More information about the svn-src-head
mailing list