From owner-svn-src-head@FreeBSD.ORG Sun Jun 28 20:52:12 2009 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 2A5B21065674; Sun, 28 Jun 2009 20:52:12 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 19CD28FC13; Sun, 28 Jun 2009 20:52:12 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n5SKqBHw021582; Sun, 28 Jun 2009 20:52:11 GMT (envelope-from ed@svn.freebsd.org) Received: (from ed@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n5SKqBT7021580; Sun, 28 Jun 2009 20:52:11 GMT (envelope-from ed@svn.freebsd.org) Message-Id: <200906282052.n5SKqBT7021580@svn.freebsd.org> From: Ed Schouten Date: Sun, 28 Jun 2009 20:52:11 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r195146 - head/sys/dev/usb/serial X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 28 Jun 2009 20:52:12 -0000 Author: ed Date: Sun Jun 28 20:52:11 2009 New Revision: 195146 URL: http://svn.freebsd.org/changeset/base/195146 Log: Don't pick up Giant inside ucom(4). Giant was only used here to lock down a bit mask of allocated unit numbers. Change the code to use its own mutex. Reviewed by: hselasky Approved by: re (kib) Modified: head/sys/dev/usb/serial/usb_serial.c Modified: head/sys/dev/usb/serial/usb_serial.c ============================================================================== --- head/sys/dev/usb/serial/usb_serial.c Sun Jun 28 17:24:27 2009 (r195145) +++ head/sys/dev/usb/serial/usb_serial.c Sun Jun 28 20:52:11 2009 (r195146) @@ -151,6 +151,8 @@ MODULE_VERSION(ucom, 1); #define UCOM_SUB_UNIT_MAX 0x100 /* exclusive */ static uint8_t ucom_bitmap[(UCOM_UNIT_MAX + 7) / 8]; +static struct mtx ucom_bitmap_mtx; +MTX_SYSINIT(ucom_bitmap_mtx, &ucom_bitmap_mtx, "ucom bitmap", MTX_DEF); static uint8_t ucom_units_alloc(uint32_t sub_units, uint32_t *p_root_unit) @@ -161,7 +163,7 @@ ucom_units_alloc(uint32_t sub_units, uin uint32_t max = UCOM_UNIT_MAX - (UCOM_UNIT_MAX % sub_units); uint8_t error = 1; - mtx_lock(&Giant); + mtx_lock(&ucom_bitmap_mtx); for (n = 0; n < max; n += sub_units) { @@ -192,7 +194,7 @@ ucom_units_alloc(uint32_t sub_units, uin skip: ; } - mtx_unlock(&Giant); + mtx_unlock(&ucom_bitmap_mtx); /* * Always set the variable pointed to by "p_root_unit" so that @@ -208,14 +210,14 @@ ucom_units_free(uint32_t root_unit, uint { uint32_t x; - mtx_lock(&Giant); + mtx_lock(&ucom_bitmap_mtx); while (sub_units--) { x = root_unit + sub_units; ucom_bitmap[x / 8] &= ~(1 << (x % 8)); } - mtx_unlock(&Giant); + mtx_unlock(&ucom_bitmap_mtx); } /*