From owner-p4-projects@FreeBSD.ORG Sun Apr 11 08:34:03 2004 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 7CD3E16A4D0; Sun, 11 Apr 2004 08:34:03 -0700 (PDT) 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 3FACB16A4CE for ; Sun, 11 Apr 2004 08:34:03 -0700 (PDT) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 286E843D55 for ; Sun, 11 Apr 2004 08:34:03 -0700 (PDT) (envelope-from scottl@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.12.10/8.12.10) with ESMTP id i3BFY3Ge007070 for ; Sun, 11 Apr 2004 08:34:03 -0700 (PDT) (envelope-from scottl@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.12.10/8.12.10/Submit) id i3BFY2rF007067 for perforce@freebsd.org; Sun, 11 Apr 2004 08:34:02 -0700 (PDT) (envelope-from scottl@freebsd.org) Date: Sun, 11 Apr 2004 08:34:02 -0700 (PDT) Message-Id: <200404111534.i3BFY2rF007067@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 50842 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: Sun, 11 Apr 2004 15:34:03 -0000 http://perforce.freebsd.org/chv.cgi?CH=50842 Change 50842 by scottl@scottl-junior-camlock on 2004/04/11 08:33:51 Instead of calling xpt_schedule() in each stage of probedone(), call probeschedule1() to queue a WORK_XPT_SCHED workitem. This will result in probestart() being called from the desired context, and removes the need to do an xpt action workitem from there. It's unclear whether probeschedule() and probeschedule1() should be combined, or whether the whole workitem framework should be moved into xpt_schedule. Affected files ... .. //depot/projects/scottl-camlock/src/sys/cam/cam_probe.c#5 edit Differences ... ==== //depot/projects/scottl-camlock/src/sys/cam/cam_probe.c#5 (text+ko) ==== @@ -82,12 +82,14 @@ typedef enum { WORK_EXECUTE_CCB = 0x1, + WORK_XPT_SCHED = 0x2, } cam_workflags; struct cam_workitem { TAILQ_ENTRY(cam_workitem) work_links; cam_workflags command; - void *data; + void *data1; + uintptr_t data2; void (*cbfcnp)(void *); }; @@ -133,6 +135,19 @@ } static void +probeschedule1(struct cam_periph *periph, uint32_t priority) +{ + probe_softc *softc; + + softc = (probe_softc *)periph->softc; + softc->work->command = WORK_XPT_SCHED; + softc->work->data1 = periph; + softc->work->data2 = (uintptr_t)priority; + softc->work->cbfcnp = NULL; + probe_queue_work(softc->work); +} + +static void probe_work(void *dummy) { struct cam_workitem *work; @@ -150,7 +165,13 @@ switch (work->command) { case WORK_EXECUTE_CCB: mtx_lock(&Giant); - xpt_action((union ccb *)work->data); + xpt_action((union ccb *)work->data1); + mtx_unlock(&Giant); + break; + case WORK_XPT_SCHED: + mtx_lock(&Giant); + xpt_schedule((struct cam_periph *)work->data1, + (uint32_t)(work->data2)); mtx_unlock(&Giant); break; default: @@ -158,7 +179,7 @@ } if (work->cbfcnp != NULL) - work->cbfcnp(work->data); + work->cbfcnp(work->data1); mtx_lock(&probe_workmtx); } @@ -418,10 +439,7 @@ } } - softc->work->command = WORK_EXECUTE_CCB; - softc->work->data = start_ccb; - softc->work->cbfcnp = NULL; - probe_queue_work(softc->work); + xpt_action(start_ccb); } static void @@ -476,7 +494,7 @@ } softc->action = PROBE_INQUIRY; xpt_release_ccb(done_ccb); - xpt_schedule(periph, priority); + probeschedule1(periph, priority); return; } case PROBE_INQUIRY: @@ -511,7 +529,7 @@ && alen > (SHORT_INQUIRY_LENGTH - 4)) { softc->action = PROBE_FULL_INQUIRY; xpt_release_ccb(done_ccb); - xpt_schedule(periph, priority); + probeschedule1(periph, priority); return; } @@ -528,7 +546,7 @@ path->device->flags &= ~CAM_DEV_UNCONFIGURED; xpt_release_ccb(done_ccb); - xpt_schedule(periph, priority); + probeschedule1(periph, priority); return; } default: @@ -589,7 +607,7 @@ xpt_release_ccb(done_ccb); free(mode_hdr, M_TEMP); softc->action = PROBE_SERIAL_NUM; - xpt_schedule(periph, priority); + probeschedule1(periph, priority); return; } case PROBE_SERIAL_NUM: @@ -695,7 +713,7 @@ * perform any necessary transfer negotiation. */ softc->action = PROBE_TUR_FOR_NEGOTIATION; - xpt_schedule(periph, priority); + probeschedule1(periph, priority); return; } xpt_release_ccb(done_ccb);