Author: mav
Date: Mon Apr  1 13:18:34 2013
New Revision: 248973
URL: http://svnweb.freebsd.org/changeset/base/248973

Log:
  Slightly tune locking to not call xpt_alloc_ccb() that is allowed to sleep
  while holding the SIM mutex.

Modified:
  head/sys/dev/tws/tws_cam.c
  head/sys/dev/tws/tws_user.c

Modified: head/sys/dev/tws/tws_cam.c
==============================================================================
--- head/sys/dev/tws/tws_cam.c  Mon Apr  1 13:17:28 2013        (r248972)
+++ head/sys/dev/tws/tws_cam.c  Mon Apr  1 13:18:34 2013        (r248973)
@@ -217,17 +217,16 @@ tws_bus_scan(struct tws_softc *sc)
     TWS_TRACE_DEBUG(sc, "entry", sc, 0);
     if (!(sc->sim))
         return(ENXIO);
-    mtx_assert(&sc->sim_lock, MA_OWNED);
-    if ((ccb = xpt_alloc_ccb()) == NULL)
-                   return(ENOMEM);
-
+    ccb = xpt_alloc_ccb();
+    mtx_lock(&sc->sim_lock);
     if (xpt_create_path(&ccb->ccb_h.path, xpt_periph, cam_sim_path(sc->sim),
                   CAM_TARGET_WILDCARD, CAM_LUN_WILDCARD) != CAM_REQ_CMP) {
+       mtx_unlock(&sc->sim_lock);
         xpt_free_ccb(ccb);
         return(EIO);
     }
     xpt_rescan(ccb);
-    
+    mtx_unlock(&sc->sim_lock);
     return(0);
 }
 

Modified: head/sys/dev/tws/tws_user.c
==============================================================================
--- head/sys/dev/tws/tws_user.c Mon Apr  1 13:17:28 2013        (r248972)
+++ head/sys/dev/tws/tws_user.c Mon Apr  1 13:18:34 2013        (r248973)
@@ -73,9 +73,7 @@ tws_ioctl(struct cdev *dev, u_long cmd, 
             break;
         case TWS_IOCTL_SCAN_BUS :
             TWS_TRACE_DEBUG(sc, "scan-bus", 0, 0);
-            mtx_lock(&sc->sim_lock);
             error = tws_bus_scan(sc);
-            mtx_unlock(&sc->sim_lock);
             break;
         default :
             TWS_TRACE_DEBUG(sc, "ioctl-aen", cmd, buf);
_______________________________________________
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to