Date: Sun, 18 Apr 2004 23:43:16 -0700 (PDT) From: Scott Long <scottl@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 51332 for review Message-ID: <200404190643.i3J6hGMB013358@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
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); } }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200404190643.i3J6hGMB013358>