bus_dmamap_unload(sc->sc_dmat, siop_cmd->dmamap_cmd); if (siop_cmd->status == CMDST_SENSE) {
bus_dmamap_unload(sc->sc_c.sc_dmat, siop_cmd->cmd_c.dmamap_cmd); if (siop_cmd->cmd_c.status == CMDST_SENSE) {
siop_scsicmd_end(siop_cmd)	struct siop_cmd *siop_cmd;{	struct scsi_xfer *xs = siop_cmd->xs;	struct siop_softc *sc = siop_cmd->siop_sc;	switch(letoh32(siop_cmd->siop_tables.status)) {	case SCSI_OK:		xs->error = (siop_cmd->status == CMDST_DONE) ?		    XS_NOERROR : XS_SENSE;		break;	case SCSI_BUSY:		xs->error = XS_BUSY;		break;	case SCSI_CHECK:		if (siop_cmd->status == CMDST_SENSE_DONE) {			/* request sense on a request sense ? */			printf("request sense failed\n");			xs->error = XS_DRIVER_STUFFUP;		} else {			siop_cmd->status = CMDST_SENSE;		}		break;	case SCSI_QUEUE_FULL:		{		struct siop_lun *siop_lun = siop_cmd->siop_target->siop_lun[		    xs->sc_link->lun];		/*		 * Device didn't queue the command. We have to retry		 * it.  We insert it into the urgent list, hoping to		 * preserve order.  But unfortunately, commands already		 * in the scheduler may be accepted before this one.		 * Also remember the condition, to avoid starting new		 * commands for this device before one is done.		 */		INCSTAT(siop_stat_intr_qfull);#ifdef SIOP_DEBUG		printf("%s:%d:%d: queue full (tag %d)\n", sc->sc_dev.dv_xname,		    xs->sc_link->target,		    xs->sc_link->lun, siop_cmd->tag);#endif		timeout_del(&xs->stimeout);		siop_lun->lun_flags |= SIOP_LUNF_FULL;		siop_cmd->status = CMDST_READY;		siop_setuptables(siop_cmd);		TAILQ_INSERT_TAIL(&sc->urgent_list, siop_cmd, next);		return;		}	case SCSI_SIOP_NOCHECK:		/*		 * don't check status, xs->error is already valid		 */		break;	case SCSI_SIOP_NOSTATUS:		/*		 * the status byte was not updated, cmd was		 * aborted		 */		xs->error = XS_SELTIMEOUT;		break;	default:		xs->error = XS_DRIVER_STUFFUP;	}	if (siop_cmd->status != CMDST_SENSE_DONE &&	    xs->flags & (SCSI_DATA_IN | SCSI_DATA_OUT)) {		bus_dmamap_sync(sc->sc_dmat, siop_cmd->dmamap_data,		    0, siop_cmd->dmamap_data->dm_mapsize,		    (xs->flags & SCSI_DATA_IN) ?		    BUS_DMASYNC_POSTREAD : BUS_DMASYNC_POSTWRITE);		bus_dmamap_unload(sc->sc_dmat, siop_cmd->dmamap_data);	}	bus_dmamap_unload(sc->sc_dmat, siop_cmd->dmamap_cmd);	if (siop_cmd->status == CMDST_SENSE) {		/* issue a request sense for this target */		int error;		siop_cmd->rs_cmd.opcode = REQUEST_SENSE;		siop_cmd->rs_cmd.byte2 = xs->sc_link->lun << 5;		siop_cmd->rs_cmd.unused[0] = siop_cmd->rs_cmd.unused[1] = 0;		siop_cmd->rs_cmd.length = sizeof(struct scsi_sense_data);		siop_cmd->rs_cmd.control = 0;		siop_cmd->flags &= ~CMDFL_TAG;		error = bus_dmamap_load(sc->sc_dmat, siop_cmd->dmamap_cmd,		    &siop_cmd->rs_cmd, sizeof(struct scsi_sense),		    NULL, BUS_DMA_NOWAIT);		if (error) {			printf("%s: unable to load cmd DMA map "			    "(for SENSE): %d\n",			    sc->sc_dev.dv_xname, error);			xs->error = XS_DRIVER_STUFFUP;			goto out;		}		error = bus_dmamap_load(sc->sc_dmat, siop_cmd->dmamap_data,		    &xs->sense, sizeof(struct scsi_sense_data),		    NULL, BUS_DMA_NOWAIT);		if (error) {			printf("%s: unable to load data DMA map "			    "(for SENSE): %d\n",			    sc->sc_dev.dv_xname, error);			xs->error = XS_DRIVER_STUFFUP;			bus_dmamap_unload(sc->sc_dmat, siop_cmd->dmamap_cmd);			goto out;		}		bus_dmamap_sync(sc->sc_dmat, siop_cmd->dmamap_data,		    0, siop_cmd->dmamap_data->dm_mapsize,		    BUS_DMASYNC_PREREAD);		bus_dmamap_sync(sc->sc_dmat, siop_cmd->dmamap_cmd,		    0, siop_cmd->dmamap_cmd->dm_mapsize,		    BUS_DMASYNC_PREWRITE);		siop_setuptables(siop_cmd);		/* arrange for the cmd to be handled now */		TAILQ_INSERT_HEAD(&sc->urgent_list, siop_cmd, next);		return;	} else if (siop_cmd->status == CMDST_SENSE_DONE) {		bus_dmamap_sync(sc->sc_dmat, siop_cmd->dmamap_data,		    0, siop_cmd->dmamap_data->dm_mapsize,		    BUS_DMASYNC_POSTREAD);		bus_dmamap_unload(sc->sc_dmat, siop_cmd->dmamap_data);	}out:	timeout_del(&siop_cmd->xs->stimeout);	siop_cmd->status = CMDST_FREE;	xs->flags |= ITSDONE;	xs->resid = 0;	scsi_done(xs);}