From owner-svn-src-stable-7@FreeBSD.ORG Fri Oct 30 16:07:07 2009 Return-Path: Delivered-To: svn-src-stable-7@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1F178106566C; Fri, 30 Oct 2009 16:07:07 +0000 (UTC) (envelope-from rnoland@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 0D5948FC0C; Fri, 30 Oct 2009 16:07:07 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9UG76QA050312; Fri, 30 Oct 2009 16:07:06 GMT (envelope-from rnoland@svn.freebsd.org) Received: (from rnoland@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9UG76fT050310; Fri, 30 Oct 2009 16:07:06 GMT (envelope-from rnoland@svn.freebsd.org) Message-Id: <200910301607.n9UG76fT050310@svn.freebsd.org> From: Robert Noland Date: Fri, 30 Oct 2009 16:07:06 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r198680 - in stable/7/sys: . contrib/pf dev/drm X-BeenThere: svn-src-stable-7@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 7-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 30 Oct 2009 16:07:07 -0000 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; }