From owner-p4-projects@FreeBSD.ORG Sun Apr 18 23:43:18 2004 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 37C2716A4FB; Sun, 18 Apr 2004 23:43:17 -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 DF9FC16A4D3 for ; Sun, 18 Apr 2004 23:43:16 -0700 (PDT) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id D6B7F43D31 for ; Sun, 18 Apr 2004 23:43:16 -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 i3J6hGGe013361 for ; Sun, 18 Apr 2004 23:43:16 -0700 (PDT) (envelope-from scottl@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.12.10/8.12.10/Submit) id i3J6hGMB013358 for perforce@freebsd.org; Sun, 18 Apr 2004 23:43:16 -0700 (PDT) (envelope-from scottl@freebsd.org) Date: Sun, 18 Apr 2004 23:43:16 -0700 (PDT) Message-Id: <200404190643.i3J6hGMB013358@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 51332 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: Mon, 19 Apr 2004 06:43:18 -0000 http://perforce.freebsd.org/chv.cgi?CH=51332 Change 51332 by scottl@scottl-junior-camlock on 2004/04/18 23:42:58 Add probescheduleprobe() to decouple the invocation of probeschedule(). Clean up a bunch of other little things that were bothing me. With the change, the probe driver is pretty much fully decoupled and ready for lockdown. Affected files ... .. //depot/projects/scottl-camlock/src/sys/cam/cam_probe.c#7 edit Differences ... ==== //depot/projects/scottl-camlock/src/sys/cam/cam_probe.c#7 (text+ko) ==== @@ -81,16 +81,18 @@ PERIPHDRIVER_DECLARE(probe, probe_driver); typedef enum { - WORK_EXECUTE_CCB = 0x1, - WORK_XPT_SCHED = 0x2, + WORK_EXECUTE_CCB, + WORK_XPT_SCHED, + WORK_PROBE_SCHED } cam_workflags; struct cam_workitem { TAILQ_ENTRY(cam_workitem) work_link; cam_workflags command; void *data1; - uintptr_t data2; + void *data2; void (*cbfcnp)(void *); + void *cbdata; }; typedef enum { @@ -135,14 +137,27 @@ } static void -probeschedule1(struct cam_periph *periph, uint32_t priority) +probereschedule(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->data2 = (void *)(uintptr_t)priority; + softc->work->cbfcnp = NULL; + probe_queue_work(softc->work); +} + +static void +probeschedprobe(struct cam_periph *periph) +{ + probe_softc *softc; + + softc = (probe_softc *)periph->softc; + softc->work->command = WORK_PROBE_SCHED; + softc->work->data1 = periph; softc->work->cbfcnp = NULL; probe_queue_work(softc->work); } @@ -171,7 +186,12 @@ case WORK_XPT_SCHED: mtx_lock(&Giant); xpt_schedule((struct cam_periph *)work->data1, - (uint32_t)(work->data2)); + (uint32_t)(uintptr_t)(work->data2)); + mtx_unlock(&Giant); + break; + case WORK_PROBE_SCHED: + mtx_lock(&Giant); + probeschedule((struct cam_periph *)work->data1); mtx_unlock(&Giant); break; default: @@ -179,7 +199,7 @@ } if (work->cbfcnp != NULL) - work->cbfcnp(work->data1); + work->cbfcnp(work->cbdata); mtx_lock(&probe_workmtx); } @@ -247,7 +267,7 @@ */ cam_periph_freeze_after_event(periph, &periph->path->bus->last_reset, scsi_delay); - probeschedule(periph); + probeschedprobe(periph); return(CAM_REQ_CMP); } @@ -494,7 +514,7 @@ } softc->action = PROBE_INQUIRY; xpt_release_ccb(done_ccb); - probeschedule1(periph, priority); + probereschedule(periph, priority); return; } case PROBE_INQUIRY: @@ -529,7 +549,7 @@ && alen > (SHORT_INQUIRY_LENGTH - 4)) { softc->action = PROBE_FULL_INQUIRY; xpt_release_ccb(done_ccb); - probeschedule1(periph, priority); + probereschedule(periph, priority); return; } @@ -546,7 +566,7 @@ path->device->flags &= ~CAM_DEV_UNCONFIGURED; xpt_release_ccb(done_ccb); - probeschedule1(periph, priority); + probereschedule(periph, priority); return; } default: @@ -607,7 +627,7 @@ xpt_release_ccb(done_ccb); free(mode_hdr, M_TEMP); softc->action = PROBE_SERIAL_NUM; - probeschedule1(periph, priority); + probereschedule(periph, priority); return; } case PROBE_SERIAL_NUM: @@ -713,7 +733,7 @@ * perform any necessary transfer negotiation. */ softc->action = PROBE_TUR_FOR_NEGOTIATION; - probeschedule1(periph, priority); + probereschedule(periph, priority); return; } xpt_release_ccb(done_ccb); @@ -746,7 +766,7 @@ cam_periph_invalidate(periph); cam_periph_release(periph); } else { - probeschedule(periph); + probeschedprobe(periph); } }