Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 30 Oct 2009 16:07:06 +0000 (UTC)
From:      Robert Noland <rnoland@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org
Subject:   svn commit: r198680 - in stable/7/sys: . contrib/pf dev/drm
Message-ID:  <200910301607.n9UG76fT050310@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: rnoland
Date: Fri Oct 30 16:07:06 2009
New Revision: 198680
URL: http://svn.freebsd.org/changeset/base/198680

Log:
  MFC r196464
  
  Clean up the locking in drm_alloc_resource()

Modified:
  stable/7/sys/   (props changed)
  stable/7/sys/contrib/pf/   (props changed)
  stable/7/sys/dev/drm/drm_bufs.c

Modified: stable/7/sys/dev/drm/drm_bufs.c
==============================================================================
--- stable/7/sys/dev/drm/drm_bufs.c	Fri Oct 30 16:06:32 2009	(r198679)
+++ stable/7/sys/dev/drm/drm_bufs.c	Fri Oct 30 16:07:06 2009	(r198680)
@@ -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;
 }
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200910301607.n9UG76fT050310>