* bzero the sense data before having
* Zero the sense data before having
ahc_done(ahc, scb)	struct ahc_softc *ahc;	struct scb *scb;{	struct scsi_xfer *xs = scb->io_ctx;	struct scsi_link *sc_link = xs->sc_link;	int requeue = 0;	int target;	int lun;	SC_DEBUG(xs->sc_link, SDEV_DB2, ("ahc_done\n"));		LIST_REMOVE(scb, pending_links);	if ((scb->flags & SCB_UNTAGGEDQ) != 0) {		struct scb_tailq *untagged_q;		int target_offset;		target_offset = SCB_GET_TARGET_OFFSET(ahc, scb);		untagged_q = &ahc->untagged_queues[target_offset];		TAILQ_REMOVE(untagged_q, scb, links.tqe);		scb->flags &= ~SCB_UNTAGGEDQ;		ahc_run_untagged_queue(ahc, untagged_q);	}		timeout_del(&xs->stimeout);#ifdef AHC_DEBUG	if ((ahc_debug & AHC_SHOWCMDS)) {		ahc_print_path(ahc, scb);		printf("ahc_done: opcode 0x%x tag %x flags %x status %d error %d\n", 		       xs->cmdstore.opcode, scb->hscb->tag, 		       scb->flags, xs->status, xs->error);	}#endif		target = sc_link->target;	lun = sc_link->lun;	if (xs->datalen) {		int op;			if ((xs->flags & SCSI_DATA_IN) != 0)			op = BUS_DMASYNC_POSTREAD;		else			op = BUS_DMASYNC_POSTWRITE;		ahc->buffer_dmat = ahc->parent_dmat;		bus_dmamap_sync(ahc->buffer_dmat, scb->dmamap,		    0, scb->dmamap->dm_mapsize, op);				bus_dmamap_unload(ahc->buffer_dmat, scb->dmamap);	}	/*	 * Unbusy this target/channel/lun.	 * XXX if we are holding two commands per lun, 	 *     send the next command.	 */	if (!(scb->hscb->control & TAG_ENB)){		ahc_pause_unbusy_tcl(ahc, XS_TCL(xs));	}	/*	 * If the recovery SCB completes, we have to be	 * out of our timeout.	 */	if ((scb->flags & SCB_RECOVERY_SCB) != 0) {		struct	scb *list_scb;		/*		 * We were able to complete the command successfully,		 * so reinstate the timeouts for all other pending		 * commands.		 */		LIST_FOREACH(list_scb, &ahc->pending_scbs, pending_links) {			struct scsi_xfer *txs = list_scb->io_ctx;			if (!(txs->flags & SCSI_POLL))				timeout_add(&list_scb->io_ctx->stimeout,				    (list_scb->io_ctx->timeout * hz)/1000);		}		if (xs->error != XS_NOERROR)			ahc_set_transaction_status(scb, CAM_CMD_TIMEOUT);		ahc_print_path(ahc, scb);		printf("no longer in timeout, status = %x\n", xs->status);	}	if (xs->error != XS_NOERROR) {		/* Don't clobber any existing error state */	} else if ((scb->flags & SCB_SENSE) != 0) {		/*		 * We performed autosense retrieval.		 *		 * bzero the sense data before having		 * the drive fill it.  The SCSI spec mandates		 * that any untransfered data should be		 * assumed to be zero.  Complete the 'bounce'		 * of sense information through buffers accessible		 * via bus-space by copying it into the clients		 * csio.		 */		memset(&xs->sense, 0, sizeof(struct scsi_sense_data));		memcpy(&xs->sense, ahc_get_sense_buf(ahc, scb),		       ahc_le32toh((scb->sg_list->len & AHC_SG_LEN_MASK)));		xs->error = XS_SENSE;	}		if (scb->platform_data->flags & SCB_FREEZE_QUEUE) {		/* keep negs from happening */		if (ahc->platform_data->devqueue_blocked[target] > 0) {			ahc->platform_data->devqueue_blocked[target]--;		}		scb->platform_data->flags &= ~SCB_FREEZE_QUEUE;	}		requeue = scb->platform_data->flags & SCB_REQUEUE;	ahc_free_scb(ahc, scb);	if (requeue) {		/*		 * Re-insert at the front of the private queue to		 * preserve order.		 */		int s;		ahc_lock(ahc, &s);		ahc_list_insert_head(ahc, xs);		ahc_unlock(ahc, &s);	} else {		xs->flags |= ITSDONE;                ahc_check_tags(ahc, xs);		scsi_done(xs);	}	/*	 * If there are entries in the software queue, try to	 * run the first one.  We should be more or less guaranteed	 * to succeed, since we just freed an SCB.	 *	 * NOTE: ahc_action() relies on our calling it with	 * the first entry in the queue.	 */	if ((xs = ahc->platform_data->sc_xxxq.lh_first) != NULL)		(void) ahc_action(xs);}