Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 19 Feb 2005 03:59:09 GMT
From:      Scott Long <scottl@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 71286 for review
Message-ID:  <200502190359.j1J3x9uA075484@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=71286

Change 71286 by scottl@scottl-junior on 2005/02/19 03:58:52

	IFC rev 1.149 of cam_xpt.c

Affected files ...

.. //depot/projects/scottl-camlock/src/sys/cam/cam_xpt.c#12 integrate

Differences ...

==== //depot/projects/scottl-camlock/src/sys/cam/cam_xpt.c#12 (text+ko) ====

@@ -28,7 +28,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/cam/cam_xpt.c,v 1.148 2005/01/25 08:59:06 mr Exp $");
+__FBSDID("$FreeBSD: src/sys/cam/cam_xpt.c,v 1.149 2005/02/09 11:44:15 scottl Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -44,6 +44,9 @@
 #include <sys/sbuf.h>
 #include <vm/uma.h>
 
+#include <sys/lock.h>
+#include <sys/mutex.h>
+
 #ifdef PC98
 #include <pc98/pc98/pc98_machdep.h>	/* geometry translation */
 #endif
@@ -485,6 +488,7 @@
 /* Queues for our software interrupt handler */
 typedef TAILQ_HEAD(cam_isrq, ccb_hdr) cam_isrq_t;
 static cam_isrq_t cam_bioq;
+static struct mtx cam_bioq_lock;
 
 /* "Pool" of inactive ccbs managed by xpt_alloc_ccb and xpt_free_ccb */
 static SLIST_HEAD(,ccb_hdr) ccb_freeq;
@@ -1221,6 +1225,8 @@
 	SLIST_INIT(&ccb_freeq);
 	STAILQ_INIT(&highpowerq);
 
+	mtx_init(&cam_bioq_lock, "CAM BIOQ lock", NULL, MTX_DEF);
+
 	/* Create the CCB zone */
 	ccb_zone = uma_zcreate("CAM CCB Pool", sizeof(union ccb), NULL, NULL,
 				NULL, NULL, 0, 0);
@@ -4673,8 +4679,6 @@
 {
 	int s;
 
-	GIANT_REQUIRED;
-
 	s = splcam();
 
 	CAM_DEBUG(done_ccb->ccb_h.path, CAM_DEBUG_TRACE, ("xpt_done\n"));
@@ -4685,9 +4689,11 @@
 		 */
 		switch (done_ccb->ccb_h.path->periph->type) {
 		case CAM_PERIPH_BIO:
+			mtx_lock(&cam_bioq_lock);
 			TAILQ_INSERT_TAIL(&cam_bioq, &done_ccb->ccb_h,
 					  sim_links.tqe);
 			done_ccb->ccb_h.pinfo.index = CAM_DONEQ_INDEX;
+			mtx_unlock(&cam_bioq_lock);
 			swi_sched(cambio_ih, 0);
 			break;
 		default:
@@ -6127,15 +6133,26 @@
 static void
 camisr(void *V_queue)
 {
-	cam_isrq_t *queue = V_queue;
+	cam_isrq_t *oqueue = V_queue;
+	cam_isrq_t queue;
 	int	s;
 	struct	ccb_hdr *ccb_h;
 
+	/*
+	 * Transfer the ccb_bioq list to a temporary list so we can operate
+	 * on it without needing to lock/unlock on every loop.  The concat
+	 * function with re-init the real list for us.
+	 */
 	s = splcam();
-	while ((ccb_h = TAILQ_FIRST(queue)) != NULL) {
+	mtx_lock(&cam_bioq_lock);
+	TAILQ_INIT(&queue);
+	TAILQ_CONCAT(&queue, oqueue, sim_links.tqe);
+	mtx_unlock(&cam_bioq_lock);
+
+	while ((ccb_h = TAILQ_FIRST(&queue)) != NULL) {
 		int	runq;
 
-		TAILQ_REMOVE(queue, ccb_h, sim_links.tqe);
+		TAILQ_REMOVE(&queue, ccb_h, sim_links.tqe);
 		ccb_h->pinfo.index = CAM_UNQUEUED_INDEX;
 		splx(s);
 



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