From owner-svn-src-projects@FreeBSD.ORG Mon Apr 15 17:20:01 2013 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 39871D15; Mon, 15 Apr 2013 17:20:01 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 2BC78F8B; Mon, 15 Apr 2013 17:20:01 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r3FHK1lD001318; Mon, 15 Apr 2013 17:20:01 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r3FHJvPJ001244; Mon, 15 Apr 2013 17:19:57 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <201304151719.r3FHJvPJ001244@svn.freebsd.org> From: Alexander Motin Date: Mon, 15 Apr 2013 17:19:57 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r249512 - in projects/camlock/sys/cam: . ata ctl scsi X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 15 Apr 2013 17:20:01 -0000 Author: mav Date: Mon Apr 15 17:19:57 2013 New Revision: 249512 URL: http://svnweb.freebsd.org/changeset/base/249512 Log: Make cam_periph_getccb() to simply allocate CCBs and consume device openings neither checking their availability nor bothering with periph scheduling. Consumers of this KPI are normally waiting on the CCB completion and so number of CCBs there can't be infinite. Finite number of CCBs can now be correctly handled by the modified CCB queue code. This allows to remove duplicated code needed to schedule allocation of these immediate CCBs from many periph drivers, simplifying them and their locking. Modified: projects/camlock/sys/cam/ata/ata_da.c projects/camlock/sys/cam/cam_periph.c projects/camlock/sys/cam/cam_periph.h projects/camlock/sys/cam/cam_xpt.c projects/camlock/sys/cam/ctl/scsi_ctl.c projects/camlock/sys/cam/scsi/scsi_cd.c projects/camlock/sys/cam/scsi/scsi_ch.c projects/camlock/sys/cam/scsi/scsi_da.c projects/camlock/sys/cam/scsi/scsi_enc.c projects/camlock/sys/cam/scsi/scsi_enc_internal.h projects/camlock/sys/cam/scsi/scsi_enc_safte.c projects/camlock/sys/cam/scsi/scsi_enc_ses.c projects/camlock/sys/cam/scsi/scsi_pass.c projects/camlock/sys/cam/scsi/scsi_pt.c projects/camlock/sys/cam/scsi/scsi_sa.c projects/camlock/sys/cam/scsi/scsi_sg.c projects/camlock/sys/cam/scsi/scsi_targ_bh.c Modified: projects/camlock/sys/cam/ata/ata_da.c ============================================================================== --- projects/camlock/sys/cam/ata/ata_da.c Mon Apr 15 17:19:28 2013 (r249511) +++ projects/camlock/sys/cam/ata/ata_da.c Mon Apr 15 17:19:57 2013 (r249512) @@ -98,7 +98,6 @@ typedef enum { ADA_CCB_RAHEAD = 0x01, ADA_CCB_WCACHE = 0x02, ADA_CCB_BUFFER_IO = 0x03, - ADA_CCB_WAITING = 0x04, ADA_CCB_DUMP = 0x05, ADA_CCB_TRIM = 0x06, ADA_CCB_TYPE_MASK = 0x0F, @@ -611,23 +610,15 @@ static void adaschedule(struct cam_periph *periph) { struct ada_softc *softc = (struct ada_softc *)periph->softc; - uint32_t prio; if (softc->state != ADA_STATE_NORMAL) return; - /* Check if cam_periph_getccb() was called. */ - prio = periph->immediate_priority; - /* Check if we have more work to do. */ if (bioq_first(&softc->bio_queue) || (!softc->trim_running && bioq_first(&softc->trim_queue))) { - prio = CAM_PRIORITY_NORMAL; + xpt_schedule(periph, CAM_PRIORITY_NORMAL); } - - /* Schedule CCB if any of above is true. */ - if (prio != CAM_PRIORITY_NONE) - xpt_schedule(periph, prio); } /* @@ -1321,19 +1312,6 @@ adastart(struct cam_periph *periph, unio struct bio *bp; u_int8_t tag_code; - /* Execute immediate CCB if waiting. */ - if (periph->immediate_priority <= periph->pinfo.priority) { - CAM_DEBUG(periph->path, CAM_DEBUG_SUBTRACE, - ("queuing for immediate ccb\n")); - start_ccb->ccb_h.ccb_state = ADA_CCB_WAITING; - SLIST_INSERT_HEAD(&periph->ccb_list, &start_ccb->ccb_h, - periph_links.sle); - periph->immediate_priority = CAM_PRIORITY_NONE; - wakeup(&periph->ccb_list); - /* Have more work to do, so ensure we stay scheduled */ - adaschedule(periph); - break; - } /* Run TRIM if not running yet. */ if (!softc->trim_running && (bp = bioq_first(&softc->trim_queue)) != 0) { @@ -1775,12 +1753,6 @@ out: cam_periph_release_locked(periph); return; } - case ADA_CCB_WAITING: - { - /* Caller will release the CCB */ - wakeup(&done_ccb->ccb_h.cbfcnp); - return; - } case ADA_CCB_DUMP: /* No-op. We're polling */ return; Modified: projects/camlock/sys/cam/cam_periph.c ============================================================================== --- projects/camlock/sys/cam/cam_periph.c Mon Apr 15 17:19:28 2013 (r249511) +++ projects/camlock/sys/cam/cam_periph.c Mon Apr 15 17:19:57 2013 (r249512) @@ -202,7 +202,6 @@ cam_periph_alloc(periph_ctor_t *periph_c periph->periph_oninval = periph_oninvalidate; periph->type = type; periph->periph_name = name; - periph->immediate_priority = CAM_PRIORITY_NONE; periph->refcount = 0; periph->sim = sim; mtx_init(&periph->periph_mtx, "CAM periph lock", NULL, MTX_DEF); @@ -948,31 +947,6 @@ cam_periph_unmapmem(union ccb *ccb, stru PRELE(curproc); } -union ccb * -cam_periph_getccb(struct cam_periph *periph, u_int32_t priority) -{ - struct ccb_hdr *ccb_h; - - mtx_assert(periph->sim->mtx, MA_OWNED); - CAM_DEBUG(periph->path, CAM_DEBUG_TRACE, ("entering cdgetccb\n")); - - while (SLIST_FIRST(&periph->ccb_list) == NULL) { - if (periph->immediate_priority > priority) - periph->immediate_priority = priority; - xpt_schedule(periph, priority); - if ((SLIST_FIRST(&periph->ccb_list) != NULL) - && (SLIST_FIRST(&periph->ccb_list)->pinfo.priority == priority)) - break; - mtx_assert(periph->sim->mtx, MA_OWNED); - mtx_sleep(&periph->ccb_list, periph->sim->mtx, PRIBIO, "cgticb", - 0); - } - - ccb_h = SLIST_FIRST(&periph->ccb_list); - SLIST_REMOVE_HEAD(&periph->ccb_list, periph_links.sle); - return ((union ccb *)ccb_h); -} - void cam_periph_ccbwait(union ccb *ccb) { @@ -1046,6 +1020,14 @@ cam_periph_ioctl(struct cam_periph *peri return(error); } +static void +cam_periph_done(struct cam_periph *periph, union ccb *done_ccb) +{ + + /* Caller will release the CCB */ + wakeup(&done_ccb->ccb_h.cbfcnp); +} + int cam_periph_runccb(union ccb *ccb, int (*error_routine)(union ccb *ccb, @@ -1069,6 +1051,7 @@ cam_periph_runccb(union ccb *ccb, ccb->ccb_h.func_code == XPT_ATA_IO)) devstat_start_transaction(ds, NULL); + ccb->ccb_h.cbfcnp = cam_periph_done; xpt_action(ccb); do { Modified: projects/camlock/sys/cam/cam_periph.h ============================================================================== --- projects/camlock/sys/cam/cam_periph.h Mon Apr 15 17:19:28 2013 (r249511) +++ projects/camlock/sys/cam/cam_periph.h Mon Apr 15 17:19:57 2013 (r249512) @@ -121,7 +121,6 @@ struct cam_periph { #define CAM_PERIPH_NEW_DEV_FOUND 0x10 #define CAM_PERIPH_RECOVERY_INPROG 0x20 #define CAM_PERIPH_FREE 0x80 - u_int32_t immediate_priority; u_int32_t refcount; SLIST_HEAD(, ccb_hdr) ccb_list; /* For "immediate" requests */ SLIST_ENTRY(cam_periph) periph_links; Modified: projects/camlock/sys/cam/cam_xpt.c ============================================================================== --- projects/camlock/sys/cam/cam_xpt.c Mon Apr 15 17:19:28 2013 (r249511) +++ projects/camlock/sys/cam/cam_xpt.c Mon Apr 15 17:19:57 2013 (r249512) @@ -342,13 +342,6 @@ xpt_periph_init() make_dev(&xpt_cdevsw, 0, UID_ROOT, GID_OPERATOR, 0600, "xpt0"); } -static void -xptdone(struct cam_periph *periph, union ccb *done_ccb) -{ - /* Caller will release the CCB */ - wakeup(&done_ccb->ccb_h.cbfcnp); -} - static int xptopen(struct cdev *dev, int flags, int fmt, struct thread *td) { @@ -468,7 +461,6 @@ xptioctl(struct cdev *dev, u_long cmd, c xpt_setup_ccb(&ccb->ccb_h, ccb->ccb_h.path, inccb->ccb_h.pinfo.priority); xpt_merge_ccb(ccb, inccb); - ccb->ccb_h.cbfcnp = xptdone; cam_periph_runccb(ccb, NULL, 0, 0, NULL); bcopy(ccb, inccb, sizeof(union ccb)); xpt_free_path(ccb->ccb_h.path); @@ -503,7 +495,6 @@ xptioctl(struct cdev *dev, u_long cmd, c xpt_setup_ccb(&ccb.ccb_h, ccb.ccb_h.path, inccb->ccb_h.pinfo.priority); xpt_merge_ccb(&ccb, inccb); - ccb.ccb_h.cbfcnp = xptdone; xpt_action(&ccb); bcopy(&ccb, inccb, sizeof(union ccb)); xpt_free_path(ccb.ccb_h.path); @@ -4332,6 +4323,23 @@ xpt_get_ccb(struct cam_ed *device) return (new_ccb); } +union ccb * +cam_periph_getccb(struct cam_periph *periph, u_int32_t priority) +{ + union ccb *ccb; + struct cam_devq *devq; + + cam_periph_unlock(periph); + ccb = malloc(sizeof(*ccb), M_CAMCCB, M_WAITOK); + cam_periph_lock(periph); + devq = periph->sim->devq; + mtx_lock(&devq->send_mtx); + cam_ccbq_take_opening(&periph->path->device->ccbq); + xpt_setup_ccb(&ccb->ccb_h, periph->path, priority); + mtx_unlock(&devq->send_mtx); + return (ccb); +} + static void xpt_release_bus(struct cam_eb *bus) { Modified: projects/camlock/sys/cam/ctl/scsi_ctl.c ============================================================================== --- projects/camlock/sys/cam/ctl/scsi_ctl.c Mon Apr 15 17:19:28 2013 (r249511) +++ projects/camlock/sys/cam/ctl/scsi_ctl.c Mon Apr 15 17:19:57 2013 (r249512) @@ -73,8 +73,7 @@ __FBSDID("$FreeBSD$"); #include typedef enum { - CTLFE_CCB_DEFAULT = 0x00, - CTLFE_CCB_WAITING = 0x01 + CTLFE_CCB_DEFAULT = 0x00 } ctlfe_ccb_types; struct ctlfe_softc { @@ -705,14 +704,7 @@ ctlfestart(struct cam_periph *periph, un start_ccb->ccb_h.ccb_type = CTLFE_CCB_DEFAULT; ccb_h = TAILQ_FIRST(&softc->work_queue); - if (periph->immediate_priority <= periph->pinfo.priority) { - panic("shouldn't get to the CCB waiting case!"); - start_ccb->ccb_h.ccb_type = CTLFE_CCB_WAITING; - SLIST_INSERT_HEAD(&periph->ccb_list, &start_ccb->ccb_h, - periph_links.sle); - periph->immediate_priority = CAM_PRIORITY_NONE; - wakeup(&periph->ccb_list); - } else if (ccb_h == NULL) { + if (ccb_h == NULL) { softc->ccbs_freed++; xpt_release_ccb(start_ccb); } else { @@ -1157,12 +1149,6 @@ ctlfedone(struct cam_periph *periph, uni softc = (struct ctlfe_lun_softc *)periph->softc; bus_softc = softc->parent_softc; - if (done_ccb->ccb_h.ccb_type == CTLFE_CCB_WAITING) { - panic("shouldn't get to the CCB waiting case!"); - wakeup(&done_ccb->ccb_h.cbfcnp); - return; - } - /* * If the peripheral is invalid, ATIOs and immediate notify CCBs * need to be freed. Most of the ATIOs and INOTs that come back Modified: projects/camlock/sys/cam/scsi/scsi_cd.c ============================================================================== --- projects/camlock/sys/cam/scsi/scsi_cd.c Mon Apr 15 17:19:28 2013 (r249511) +++ projects/camlock/sys/cam/scsi/scsi_cd.c Mon Apr 15 17:19:57 2013 (r249512) @@ -110,7 +110,6 @@ typedef enum { typedef enum { CD_CCB_PROBE = 0x01, CD_CCB_BUFFER_IO = 0x02, - CD_CCB_WAITING = 0x03, CD_CCB_TUR = 0x04, CD_CCB_TYPE_MASK = 0x0F, CD_CCB_RETRY_UA = 0x10 @@ -1530,14 +1529,7 @@ cdstart(struct cam_periph *periph, union case CD_STATE_NORMAL: { bp = bioq_first(&softc->bio_queue); - if (periph->immediate_priority <= periph->pinfo.priority) { - start_ccb->ccb_h.ccb_state = CD_CCB_WAITING; - - SLIST_INSERT_HEAD(&periph->ccb_list, &start_ccb->ccb_h, - periph_links.sle); - periph->immediate_priority = CAM_PRIORITY_NONE; - wakeup(&periph->ccb_list); - } else if (bp == NULL) { + if (bp == NULL) { if (softc->tur) { softc->tur = 0; csio = &start_ccb->csio; @@ -1601,11 +1593,9 @@ cdstart(struct cam_periph *periph, union xpt_action(start_ccb); } - if (bp != NULL || softc->tur || - periph->immediate_priority != CAM_PRIORITY_NONE) { + if (bp != NULL || softc->tur) { /* Have more work to do, so ensure we stay scheduled */ - xpt_schedule(periph, min(CAM_PRIORITY_NORMAL, - periph->immediate_priority)); + xpt_schedule(periph, CAM_PRIORITY_NORMAL); } break; } @@ -1888,15 +1878,6 @@ cddone(struct cam_periph *periph, union cam_periph_unhold(periph); return; } - case CD_CCB_WAITING: - { - /* Caller will release the CCB */ - CAM_DEBUG(periph->path, CAM_DEBUG_TRACE, - ("trying to wakeup ccbwait\n")); - - wakeup(&done_ccb->ccb_h.cbfcnp); - return; - } case CD_CCB_TUR: { if ((done_ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP) { Modified: projects/camlock/sys/cam/scsi/scsi_ch.c ============================================================================== --- projects/camlock/sys/cam/scsi/scsi_ch.c Mon Apr 15 17:19:28 2013 (r249511) +++ projects/camlock/sys/cam/scsi/scsi_ch.c Mon Apr 15 17:19:57 2013 (r249512) @@ -116,8 +116,7 @@ typedef enum { } ch_state; typedef enum { - CH_CCB_PROBE, - CH_CCB_WAITING + CH_CCB_PROBE } ch_ccb_types; typedef enum { @@ -535,14 +534,7 @@ chstart(struct cam_periph *periph, union switch (softc->state) { case CH_STATE_NORMAL: { - if (periph->immediate_priority <= periph->pinfo.priority){ - start_ccb->ccb_h.ccb_state = CH_CCB_WAITING; - - SLIST_INSERT_HEAD(&periph->ccb_list, &start_ccb->ccb_h, - periph_links.sle); - periph->immediate_priority = CAM_PRIORITY_NONE; - wakeup(&periph->ccb_list); - } + xpt_release_ccb(start_ccb); break; } case CH_STATE_PROBE: @@ -719,12 +711,6 @@ chdone(struct cam_periph *periph, union cam_periph_unhold(periph); return; } - case CH_CCB_WAITING: - { - /* Caller will release the CCB */ - wakeup(&done_ccb->ccb_h.cbfcnp); - return; - } default: break; } Modified: projects/camlock/sys/cam/scsi/scsi_da.c ============================================================================== --- projects/camlock/sys/cam/scsi/scsi_da.c Mon Apr 15 17:19:28 2013 (r249511) +++ projects/camlock/sys/cam/scsi/scsi_da.c Mon Apr 15 17:19:57 2013 (r249512) @@ -99,7 +99,6 @@ typedef enum { DA_CCB_PROBE = 0x01, DA_CCB_PROBE2 = 0x02, DA_CCB_BUFFER_IO = 0x03, - DA_CCB_WAITING = 0x04, DA_CCB_DUMP = 0x05, DA_CCB_DELETE = 0x06, DA_CCB_TUR = 0x07, @@ -1079,24 +1078,16 @@ static void daschedule(struct cam_periph *periph) { struct da_softc *softc = (struct da_softc *)periph->softc; - uint32_t prio; if (softc->state != DA_STATE_NORMAL) return; - /* Check if cam_periph_getccb() was called. */ - prio = periph->immediate_priority; - /* Check if we have more work to do. */ if (bioq_first(&softc->bio_queue) || (!softc->delete_running && bioq_first(&softc->delete_queue)) || softc->tur) { - prio = CAM_PRIORITY_NORMAL; + xpt_schedule(periph, CAM_PRIORITY_NORMAL); } - - /* Schedule CCB if any of above is true. */ - if (prio != CAM_PRIORITY_NONE) - xpt_schedule(periph, prio); } /* @@ -1829,20 +1820,6 @@ dastart(struct cam_periph *periph, union struct bio *bp, *bp1; uint8_t tag_code; - /* Execute immediate CCB if waiting. */ - if (periph->immediate_priority <= periph->pinfo.priority) { - CAM_DEBUG(periph->path, CAM_DEBUG_SUBTRACE, - ("queuing for immediate ccb\n")); - start_ccb->ccb_h.ccb_state = DA_CCB_WAITING; - SLIST_INSERT_HEAD(&periph->ccb_list, &start_ccb->ccb_h, - periph_links.sle); - periph->immediate_priority = CAM_PRIORITY_NONE; - wakeup(&periph->ccb_list); - /* May have more work to do, so ensure we stay scheduled */ - daschedule(periph); - break; - } - /* Run BIO_DELETE if not running yet. */ if (!softc->delete_running && (bp = bioq_first(&softc->delete_queue)) != NULL) { @@ -2532,12 +2509,6 @@ dadone(struct cam_periph *periph, union cam_periph_release_locked(periph); return; } - case DA_CCB_WAITING: - { - /* Caller will release the CCB */ - wakeup(&done_ccb->ccb_h.cbfcnp); - return; - } case DA_CCB_DUMP: /* No-op. We're polling */ return; Modified: projects/camlock/sys/cam/scsi/scsi_enc.c ============================================================================== --- projects/camlock/sys/cam/scsi/scsi_enc.c Mon Apr 15 17:19:28 2013 (r249511) +++ projects/camlock/sys/cam/scsi/scsi_enc.c Mon Apr 15 17:19:57 2013 (r249512) @@ -67,7 +67,6 @@ static periph_init_t enc_init; static periph_ctor_t enc_ctor; static periph_oninv_t enc_oninvalidate; static periph_dtor_t enc_dtor; -static periph_start_t enc_start; static void enc_async(void *, uint32_t, struct cam_path *, void *); static enctyp enc_type(struct ccb_getdev *); @@ -246,7 +245,7 @@ enc_async(void *callback_arg, uint32_t c } status = cam_periph_alloc(enc_ctor, enc_oninvalidate, - enc_dtor, enc_start, "ses", CAM_PERIPH_BIO, + enc_dtor, NULL, "ses", CAM_PERIPH_BIO, cgd->ccb_h.path, enc_async, AC_FOUND_DEVICE, cgd); if (status != CAM_REQ_CMP && status != CAM_REQ_INPROG) { @@ -336,29 +335,6 @@ enc_close(struct cdev *dev, int flag, in return (0); } -static void -enc_start(struct cam_periph *p, union ccb *sccb) -{ - struct enc_softc *enc; - - enc = p->softc; - ENC_DLOG(enc, "%s enter imm=%d prio=%d\n", - __func__, p->immediate_priority, p->pinfo.priority); - if (p->immediate_priority <= p->pinfo.priority) { - SLIST_INSERT_HEAD(&p->ccb_list, &sccb->ccb_h, periph_links.sle); - p->immediate_priority = CAM_PRIORITY_NONE; - wakeup(&p->ccb_list); - } else - xpt_release_ccb(sccb); - ENC_DLOG(enc, "%s exit\n", __func__); -} - -void -enc_done(struct cam_periph *periph, union ccb *dccb) -{ - wakeup(&dccb->ccb_h.cbfcnp); -} - int enc_error(union ccb *ccb, uint32_t cflags, uint32_t sflags) { @@ -617,7 +593,7 @@ enc_runcmd(struct enc_softc *enc, char * if (enc->enc_type == ENC_SEMB_SES || enc->enc_type == ENC_SEMB_SAFT) { tdlen = min(dlen, 1020); tdlen = (tdlen + 3) & ~3; - cam_fill_ataio(&ccb->ataio, 0, enc_done, ddf, 0, dptr, tdlen, + cam_fill_ataio(&ccb->ataio, 0, NULL, ddf, 0, dptr, tdlen, 30 * 1000); if (cdb[0] == RECEIVE_DIAGNOSTIC) ata_28bit_cmd(&ccb->ataio, @@ -635,7 +611,7 @@ enc_runcmd(struct enc_softc *enc, char * 0x80, tdlen / 4); } else { tdlen = dlen; - cam_fill_csio(&ccb->csio, 0, enc_done, ddf, MSG_SIMPLE_Q_TAG, + cam_fill_csio(&ccb->csio, 0, NULL, ddf, MSG_SIMPLE_Q_TAG, dptr, dlen, sizeof (struct scsi_sense_data), cdbl, 60 * 1000); bcopy(cdb, ccb->csio.cdb_io.cdb_bytes, cdbl); Modified: projects/camlock/sys/cam/scsi/scsi_enc_internal.h ============================================================================== --- projects/camlock/sys/cam/scsi/scsi_enc_internal.h Mon Apr 15 17:19:28 2013 (r249511) +++ projects/camlock/sys/cam/scsi/scsi_enc_internal.h Mon Apr 15 17:19:57 2013 (r249512) @@ -192,7 +192,6 @@ struct ses_mgmt_mode_page { /* Enclosure core interface for sub-drivers */ int enc_runcmd(struct enc_softc *, char *, int, char *, int *); void enc_log(struct enc_softc *, const char *, ...); -void enc_done(struct cam_periph *, union ccb *); int enc_error(union ccb *, uint32_t, uint32_t); void enc_update_request(enc_softc_t *, uint32_t); Modified: projects/camlock/sys/cam/scsi/scsi_enc_safte.c ============================================================================== --- projects/camlock/sys/cam/scsi/scsi_enc_safte.c Mon Apr 15 17:19:28 2013 (r249511) +++ projects/camlock/sys/cam/scsi/scsi_enc_safte.c Mon Apr 15 17:19:57 2013 (r249512) @@ -243,12 +243,12 @@ safte_fill_read_buf_io(enc_softc_t *enc, if (enc->enc_type == ENC_SEMB_SAFT) { semb_read_buffer(&ccb->ataio, /*retries*/5, - enc_done, MSG_SIMPLE_Q_TAG, + NULL, MSG_SIMPLE_Q_TAG, state->page_code, buf, state->buf_size, state->timeout); } else { scsi_read_buffer(&ccb->csio, /*retries*/5, - enc_done, MSG_SIMPLE_Q_TAG, 1, + NULL, MSG_SIMPLE_Q_TAG, 1, state->page_code, 0, buf, state->buf_size, SSD_FULL_SIZE, state->timeout); } @@ -942,11 +942,11 @@ safte_fill_control_request(enc_softc_t * if (enc->enc_type == ENC_SEMB_SAFT) { semb_write_buffer(&ccb->ataio, /*retries*/5, - enc_done, MSG_SIMPLE_Q_TAG, + NULL, MSG_SIMPLE_Q_TAG, buf, xfer_len, state->timeout); } else { scsi_write_buffer(&ccb->csio, /*retries*/5, - enc_done, MSG_SIMPLE_Q_TAG, 1, + NULL, MSG_SIMPLE_Q_TAG, 1, 0, 0, buf, xfer_len, SSD_FULL_SIZE, state->timeout); } Modified: projects/camlock/sys/cam/scsi/scsi_enc_ses.c ============================================================================== --- projects/camlock/sys/cam/scsi/scsi_enc_ses.c Mon Apr 15 17:19:28 2013 (r249511) +++ projects/camlock/sys/cam/scsi/scsi_enc_ses.c Mon Apr 15 17:19:57 2013 (r249512) @@ -1185,7 +1185,7 @@ ses_set_timed_completion(enc_softc_t *en if (mode_buf == NULL) goto out; - scsi_mode_sense(&ccb->csio, /*retries*/4, enc_done, MSG_SIMPLE_Q_TAG, + scsi_mode_sense(&ccb->csio, /*retries*/4, NULL, MSG_SIMPLE_Q_TAG, /*dbd*/FALSE, SMS_PAGE_CTRL_CURRENT, SES_MGMT_MODE_PAGE_CODE, mode_buf, mode_buf_len, SSD_FULL_SIZE, /*timeout*/60 * 1000); @@ -1213,7 +1213,7 @@ ses_set_timed_completion(enc_softc_t *en /* SES2r20: a completion time of zero means as long as possible */ bzero(&mgmt->max_comp_time, sizeof(mgmt->max_comp_time)); - scsi_mode_select(&ccb->csio, 5, enc_done, MSG_SIMPLE_Q_TAG, + scsi_mode_select(&ccb->csio, 5, NULL, MSG_SIMPLE_Q_TAG, /*page_fmt*/FALSE, /*save_pages*/TRUE, mode_buf, mode_buf_len, SSD_FULL_SIZE, /*timeout*/60 * 1000); @@ -2017,12 +2017,12 @@ ses_fill_rcv_diag_io(enc_softc_t *enc, s if (enc->enc_type == ENC_SEMB_SES) { semb_receive_diagnostic_results(&ccb->ataio, /*retries*/5, - enc_done, MSG_SIMPLE_Q_TAG, /*pcv*/1, + NULL, MSG_SIMPLE_Q_TAG, /*pcv*/1, state->page_code, buf, state->buf_size, state->timeout); } else { scsi_receive_diagnostic_results(&ccb->csio, /*retries*/5, - enc_done, MSG_SIMPLE_Q_TAG, /*pcv*/1, + NULL, MSG_SIMPLE_Q_TAG, /*pcv*/1, state->page_code, buf, state->buf_size, SSD_FULL_SIZE, state->timeout); } @@ -2140,12 +2140,12 @@ ses_fill_control_request(enc_softc_t *en /* Fill out the ccb */ if (enc->enc_type == ENC_SEMB_SES) { - semb_send_diagnostic(&ccb->ataio, /*retries*/5, enc_done, + semb_send_diagnostic(&ccb->ataio, /*retries*/5, NULL, MSG_SIMPLE_Q_TAG, buf, ses_page_length(&ses_cache->status_page->hdr), state->timeout); } else { - scsi_send_diagnostic(&ccb->csio, /*retries*/5, enc_done, + scsi_send_diagnostic(&ccb->csio, /*retries*/5, NULL, MSG_SIMPLE_Q_TAG, /*unit_offline*/0, /*device_offline*/0, /*self_test*/0, /*page_format*/1, /*self_test_code*/0, Modified: projects/camlock/sys/cam/scsi/scsi_pass.c ============================================================================== --- projects/camlock/sys/cam/scsi/scsi_pass.c Mon Apr 15 17:19:28 2013 (r249511) +++ projects/camlock/sys/cam/scsi/scsi_pass.c Mon Apr 15 17:19:57 2013 (r249512) @@ -64,8 +64,7 @@ typedef enum { } pass_state; typedef enum { - PASS_CCB_BUFFER_IO, - PASS_CCB_WAITING + PASS_CCB_BUFFER_IO } pass_ccb_types; #define ccb_type ppriv_field0 @@ -92,12 +91,9 @@ static periph_init_t passinit; static periph_ctor_t passregister; static periph_oninv_t passoninvalidate; static periph_dtor_t passcleanup; -static periph_start_t passstart; static void pass_add_physpath(void *context, int pending); static void passasync(void *callback_arg, u_int32_t code, struct cam_path *path, void *arg); -static void passdone(struct cam_periph *periph, - union ccb *done_ccb); static int passerror(union ccb *ccb, u_int32_t cam_flags, u_int32_t sense_flags); static int passsendccb(struct cam_periph *periph, union ccb *ccb, @@ -300,7 +296,7 @@ passasync(void *callback_arg, u_int32_t * process. */ status = cam_periph_alloc(passregister, passoninvalidate, - passcleanup, passstart, "pass", + passcleanup, NULL, "pass", CAM_PERIPH_BIO, cgd->ccb_h.path, passasync, AC_FOUND_DEVICE, cgd); @@ -537,41 +533,6 @@ passclose(struct cdev *dev, int flag, in return (0); } -static void -passstart(struct cam_periph *periph, union ccb *start_ccb) -{ - struct pass_softc *softc; - - softc = (struct pass_softc *)periph->softc; - - switch (softc->state) { - case PASS_STATE_NORMAL: - start_ccb->ccb_h.ccb_type = PASS_CCB_WAITING; - SLIST_INSERT_HEAD(&periph->ccb_list, &start_ccb->ccb_h, - periph_links.sle); - periph->immediate_priority = CAM_PRIORITY_NONE; - wakeup(&periph->ccb_list); - break; - } -} - -static void -passdone(struct cam_periph *periph, union ccb *done_ccb) -{ - struct pass_softc *softc; - struct ccb_scsiio *csio; - - softc = (struct pass_softc *)periph->softc; - csio = &done_ccb->csio; - switch (csio->ccb_h.ccb_type) { - case PASS_CCB_WAITING: - /* Caller will release the CCB */ - wakeup(&done_ccb->ccb_h.cbfcnp); - return; - } - xpt_release_ccb(done_ccb); -} - static int passioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flag, struct thread *td) { @@ -681,12 +642,6 @@ passsendccb(struct cam_periph *periph, u xpt_merge_ccb(ccb, inccb); /* - * There's no way for the user to have a completion - * function, so we put our own completion function in here. - */ - ccb->ccb_h.cbfcnp = passdone; - - /* * We only attempt to map the user memory into kernel space * if they haven't passed in a physical memory pointer, * and if there is actually an I/O operation to perform. Modified: projects/camlock/sys/cam/scsi/scsi_pt.c ============================================================================== --- projects/camlock/sys/cam/scsi/scsi_pt.c Mon Apr 15 17:19:28 2013 (r249511) +++ projects/camlock/sys/cam/scsi/scsi_pt.c Mon Apr 15 17:19:57 2013 (r249512) @@ -66,7 +66,6 @@ typedef enum { typedef enum { PT_CCB_BUFFER_IO = 0x01, - PT_CCB_WAITING = 0x02, PT_CCB_RETRY_UA = 0x04, PT_CCB_BUFFER_IO_UA = PT_CCB_BUFFER_IO|PT_CCB_RETRY_UA } pt_ccb_state; @@ -426,15 +425,7 @@ ptstart(struct cam_periph *periph, union * See if there is a buf with work for us to do.. */ bp = bioq_first(&softc->bio_queue); - if (periph->immediate_priority <= periph->pinfo.priority) { - CAM_DEBUG(periph->path, CAM_DEBUG_SUBTRACE, - ("queuing for immediate ccb\n")); - start_ccb->ccb_h.ccb_state = PT_CCB_WAITING; - SLIST_INSERT_HEAD(&periph->ccb_list, &start_ccb->ccb_h, - periph_links.sle); - periph->immediate_priority = CAM_PRIORITY_NONE; - wakeup(&periph->ccb_list); - } else if (bp == NULL) { + if (bp == NULL) { xpt_release_ccb(start_ccb); } else { bioq_remove(&softc->bio_queue, bp); @@ -557,10 +548,6 @@ ptdone(struct cam_periph *periph, union biofinish(bp, softc->device_stats, 0); break; } - case PT_CCB_WAITING: - /* Caller will release the CCB */ - wakeup(&done_ccb->ccb_h.cbfcnp); - return; } xpt_release_ccb(done_ccb); } Modified: projects/camlock/sys/cam/scsi/scsi_sa.c ============================================================================== --- projects/camlock/sys/cam/scsi/scsi_sa.c Mon Apr 15 17:19:28 2013 (r249511) +++ projects/camlock/sys/cam/scsi/scsi_sa.c Mon Apr 15 17:19:57 2013 (r249512) @@ -112,7 +112,6 @@ typedef enum { #define ccb_bp ppriv_ptr1 #define SA_CCB_BUFFER_IO 0x0 -#define SA_CCB_WAITING 0x1 #define SA_CCB_TYPEMASK 0x1 #define SA_POSITION_UPDATED 0x2 @@ -1570,15 +1569,7 @@ sastart(struct cam_periph *periph, union * See if there is a buf with work for us to do.. */ bp = bioq_first(&softc->bio_queue); - if (periph->immediate_priority <= periph->pinfo.priority) { - CAM_DEBUG_PRINT(CAM_DEBUG_SUBTRACE, - ("queuing for immediate ccb\n")); - Set_CCB_Type(start_ccb, SA_CCB_WAITING); - SLIST_INSERT_HEAD(&periph->ccb_list, &start_ccb->ccb_h, - periph_links.sle); - periph->immediate_priority = CAM_PRIORITY_NONE; - wakeup(&periph->ccb_list); - } else if (bp == NULL) { + if (bp == NULL) { xpt_release_ccb(start_ccb); } else if ((softc->flags & SA_FLAG_ERR_PENDING) != 0) { struct bio *done_bp; @@ -1797,12 +1788,6 @@ sadone(struct cam_periph *periph, union biofinish(bp, softc->device_stats, 0); break; } - case SA_CCB_WAITING: - { - /* Caller will release the CCB */ - wakeup(&done_ccb->ccb_h.cbfcnp); - return; - } } xpt_release_ccb(done_ccb); } @@ -2389,7 +2374,8 @@ saerror(union ccb *ccb, u_int32_t cflgs, /* * If a read/write command, we handle it here. */ - if (CCB_Type(csio) != SA_CCB_WAITING) { + if (csio->cdb_io.cdb_bytes[0] == SA_READ || + csio->cdb_io.cdb_bytes[0] == SA_WRITE) { break; } /* Modified: projects/camlock/sys/cam/scsi/scsi_sg.c ============================================================================== --- projects/camlock/sys/cam/scsi/scsi_sg.c Mon Apr 15 17:19:28 2013 (r249511) +++ projects/camlock/sys/cam/scsi/scsi_sg.c Mon Apr 15 17:19:57 2013 (r249512) @@ -76,8 +76,7 @@ typedef enum { } sg_rdwr_state; typedef enum { - SG_CCB_RDWR_IO, - SG_CCB_WAITING + SG_CCB_RDWR_IO } sg_ccb_types; #define ccb_type ppriv_field0 @@ -119,7 +118,6 @@ static periph_init_t sginit; static periph_ctor_t sgregister; static periph_oninv_t sgoninvalidate; static periph_dtor_t sgcleanup; -static periph_start_t sgstart; static void sgasync(void *callback_arg, uint32_t code, struct cam_path *path, void *arg); static void sgdone(struct cam_periph *periph, union ccb *done_ccb); @@ -282,7 +280,7 @@ sgasync(void *callback_arg, uint32_t cod * start the probe process. */ status = cam_periph_alloc(sgregister, sgoninvalidate, - sgcleanup, sgstart, "sg", + sgcleanup, NULL, "sg", CAM_PERIPH_BIO, cgd->ccb_h.path, sgasync, AC_FOUND_DEVICE, cgd); if ((status != CAM_REQ_CMP) && (status != CAM_REQ_INPROG)) { @@ -388,24 +386,6 @@ sgregister(struct cam_periph *periph, vo } static void -sgstart(struct cam_periph *periph, union ccb *start_ccb) -{ - struct sg_softc *softc; - - softc = (struct sg_softc *)periph->softc; - - switch (softc->state) { - case SG_STATE_NORMAL: - start_ccb->ccb_h.ccb_type = SG_CCB_WAITING; - SLIST_INSERT_HEAD(&periph->ccb_list, &start_ccb->ccb_h, - periph_links.sle); - periph->immediate_priority = CAM_PRIORITY_NONE; - wakeup(&periph->ccb_list); - break; - } -} - -static void sgdone(struct cam_periph *periph, union ccb *done_ccb) { struct sg_softc *softc; @@ -414,10 +394,6 @@ sgdone(struct cam_periph *periph, union softc = (struct sg_softc *)periph->softc; csio = &done_ccb->csio; switch (csio->ccb_h.ccb_type) { - case SG_CCB_WAITING: - /* Caller will release the CCB */ - wakeup(&done_ccb->ccb_h.cbfcnp); - return; case SG_CCB_RDWR_IO: { struct sg_rdwr *rdwr; Modified: projects/camlock/sys/cam/scsi/scsi_targ_bh.c ============================================================================== --- projects/camlock/sys/cam/scsi/scsi_targ_bh.c Mon Apr 15 17:19:28 2013 (r249511) +++ projects/camlock/sys/cam/scsi/scsi_targ_bh.c Mon Apr 15 17:19:57 2013 (r249512) @@ -65,8 +65,7 @@ typedef enum { } targbh_flags; typedef enum { - TARGBH_CCB_WORKQ, - TARGBH_CCB_WAITING + TARGBH_CCB_WORKQ } targbh_ccb_types; #define MAX_ACCEPT 8 @@ -453,13 +452,7 @@ targbhstart(struct cam_periph *periph, u softc = (struct targbh_softc *)periph->softc; ccbh = TAILQ_FIRST(&softc->work_queue); - if (periph->immediate_priority <= periph->pinfo.priority) { - start_ccb->ccb_h.ccb_type = TARGBH_CCB_WAITING; - SLIST_INSERT_HEAD(&periph->ccb_list, &start_ccb->ccb_h, - periph_links.sle); - periph->immediate_priority = CAM_PRIORITY_NONE; - wakeup(&periph->ccb_list); - } else if (ccbh == NULL) { + if (ccbh == NULL) { xpt_release_ccb(start_ccb); } else { TAILQ_REMOVE(&softc->work_queue, ccbh, periph_links.tqe); @@ -538,12 +531,6 @@ targbhdone(struct cam_periph *periph, un softc = (struct targbh_softc *)periph->softc; - if (done_ccb->ccb_h.ccb_type == TARGBH_CCB_WAITING) { - /* Caller will release the CCB */ - wakeup(&done_ccb->ccb_h.cbfcnp); - return; - } - switch (done_ccb->ccb_h.func_code) { case XPT_ACCEPT_TARGET_IO: {