summaryrefslogtreecommitdiffstats
path: root/sys/dev/drm/drm_bufs.c
diff options
context:
space:
mode:
authorrnoland <rnoland@FreeBSD.org>2009-08-23 14:27:46 +0000
committerrnoland <rnoland@FreeBSD.org>2009-08-23 14:27:46 +0000
commitb149016ae831053f369bfced2e0b0c0627a9327c (patch)
treeed69e733b4a4d99fcdc643ff073a68c34738e147 /sys/dev/drm/drm_bufs.c
parent8b1803af930eeefcd9b18b562e0ea5a2ac730837 (diff)
downloadFreeBSD-src-b149016ae831053f369bfced2e0b0c0627a9327c.zip
FreeBSD-src-b149016ae831053f369bfced2e0b0c0627a9327c.tar.gz
Clean up the locking in drm_alloc_resource()
MFC after: 2 weeks
Diffstat (limited to 'sys/dev/drm/drm_bufs.c')
-rw-r--r--sys/dev/drm/drm_bufs.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/sys/dev/drm/drm_bufs.c b/sys/dev/drm/drm_bufs.c
index 647dee9..bd31b0a 100644
--- a/sys/dev/drm/drm_bufs.c
+++ b/sys/dev/drm/drm_bufs.c
@@ -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;
}
OpenPOWER on IntegriCloud