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);
 }
 
 /*
_______________________________________________
[email protected] mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "[email protected]"

Reply via email to