From owner-p4-projects@FreeBSD.ORG Sat Feb 19 03:59:10 2005 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id D455016A4D0; Sat, 19 Feb 2005 03:59:09 +0000 (GMT) Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id AD5A616A4CE for ; Sat, 19 Feb 2005 03:59:09 +0000 (GMT) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 6DB0643D49 for ; Sat, 19 Feb 2005 03:59:09 +0000 (GMT) (envelope-from scottl@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.1/8.13.1) with ESMTP id j1J3x9hi075487 for ; Sat, 19 Feb 2005 03:59:09 GMT (envelope-from scottl@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.1/8.13.1/Submit) id j1J3x9uA075484 for perforce@freebsd.org; Sat, 19 Feb 2005 03:59:09 GMT (envelope-from scottl@freebsd.org) Date: Sat, 19 Feb 2005 03:59:09 GMT Message-Id: <200502190359.j1J3x9uA075484@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to scottl@freebsd.org using -f From: Scott Long To: Perforce Change Reviews Subject: PERFORCE change 71286 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 19 Feb 2005 03:59:10 -0000 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 -__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 #include @@ -44,6 +44,9 @@ #include #include +#include +#include + #ifdef PC98 #include /* 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);