/* Update the error counting bucket and dump if needed */ if (dev->target->cmds_since_error) { dev->target->cmds_since_error++; if (dev->target->cmds_since_error > AHD_LINUX_ERR_THRESH) dev->target->cmds_since_error = 0; }  
ahd_linux_run_command(struct ahd_softc *ahd, struct ahd_linux_device *dev,		      struct scsi_cmnd *cmd){	struct	 scb *scb;	struct	 hardware_scb *hscb;	struct	 ahd_initiator_tinfo *tinfo;	struct	 ahd_tmode_tstate *tstate;	u_int	 col_idx;	uint16_t mask;	/*	 * Get an scb to use.	 */	tinfo = ahd_fetch_transinfo(ahd, 'A', ahd->our_id,				    cmd->device->id, &tstate);	if ((dev->flags & (AHD_DEV_Q_TAGGED|AHD_DEV_Q_BASIC)) == 0	 || (tinfo->curr.ppr_options & MSG_EXT_PPR_IU_REQ) != 0) {		col_idx = AHD_NEVER_COL_IDX;	} else {		col_idx = AHD_BUILD_COL_IDX(cmd->device->id,					    cmd->device->lun);	}	if ((scb = ahd_get_scb(ahd, col_idx)) == NULL) {		ahd->flags |= AHD_RESOURCE_SHORTAGE;		return SCSI_MLQUEUE_HOST_BUSY;	}	scb->io_ctx = cmd;	scb->platform_data->dev = dev;	hscb = scb->hscb;	cmd->host_scribble = (char *)scb;	/*	 * Fill out basics of the HSCB.	 */	hscb->control = 0;	hscb->scsiid = BUILD_SCSIID(ahd, cmd);	hscb->lun = cmd->device->lun;	scb->hscb->task_management = 0;	mask = SCB_GET_TARGET_MASK(ahd, scb);	if ((ahd->user_discenable & mask) != 0)		hscb->control |= DISCENB; 	if (AHD_DV_CMD(cmd) != 0)		scb->flags |= SCB_SILENT;	if ((tinfo->curr.ppr_options & MSG_EXT_PPR_IU_REQ) != 0)		scb->flags |= SCB_PACKETIZED;	if ((tstate->auto_negotiate & mask) != 0) {		scb->flags |= SCB_AUTO_NEGOTIATE;		scb->hscb->control |= MK_MESSAGE;	}	if ((dev->flags & (AHD_DEV_Q_TAGGED|AHD_DEV_Q_BASIC)) != 0) {		int	msg_bytes;		uint8_t tag_msgs[2];		msg_bytes = scsi_populate_tag_msg(cmd, tag_msgs);		if (msg_bytes && tag_msgs[0] != MSG_SIMPLE_TASK) {			hscb->control |= tag_msgs[0];			if (tag_msgs[0] == MSG_ORDERED_TASK)				dev->commands_since_idle_or_otag = 0;		} else		if (dev->commands_since_idle_or_otag == AHD_OTAG_THRESH		 && (dev->flags & AHD_DEV_Q_TAGGED) != 0) {			hscb->control |= MSG_ORDERED_TASK;			dev->commands_since_idle_or_otag = 0;		} else {			hscb->control |= MSG_SIMPLE_TASK;		}	}	hscb->cdb_len = cmd->cmd_len;	memcpy(hscb->shared_data.idata.cdb, cmd->cmnd, hscb->cdb_len);	scb->sg_count = 0;	ahd_set_residual(scb, 0);	ahd_set_sense_residual(scb, 0);	if (cmd->use_sg != 0) {		void	*sg;		struct	 scatterlist *cur_seg;		u_int	 nseg;		int	 dir;		cur_seg = (struct scatterlist *)cmd->request_buffer;		dir = cmd->sc_data_direction;		nseg = pci_map_sg(ahd->dev_softc, cur_seg,				  cmd->use_sg, dir);		scb->platform_data->xfer_len = 0;		for (sg = scb->sg_list; nseg > 0; nseg--, cur_seg++) {			dma_addr_t addr;			bus_size_t len;			addr = sg_dma_address(cur_seg);			len = sg_dma_len(cur_seg);			scb->platform_data->xfer_len += len;			sg = ahd_sg_setup(ahd, scb, sg, addr, len,					  /*last*/nseg == 1);		}	} else if (cmd->request_bufflen != 0) {		void *sg;		dma_addr_t addr;		int dir;		sg = scb->sg_list;		dir = cmd->sc_data_direction;		addr = pci_map_single(ahd->dev_softc,				      cmd->request_buffer,				      cmd->request_bufflen, dir);		scb->platform_data->xfer_len = cmd->request_bufflen;		scb->platform_data->buf_busaddr = addr;		sg = ahd_sg_setup(ahd, scb, sg, addr,				  cmd->request_bufflen, /*last*/TRUE);	}	LIST_INSERT_HEAD(&ahd->pending_scbs, scb, pending_links);	dev->openings--;	dev->active++;	dev->commands_issued++;	/* Update the error counting bucket and dump if needed */	if (dev->target->cmds_since_error) {		dev->target->cmds_since_error++;		if (dev->target->cmds_since_error >		    AHD_LINUX_ERR_THRESH)			dev->target->cmds_since_error = 0;	}	if ((dev->flags & AHD_DEV_PERIODIC_OTAG) != 0)		dev->commands_since_idle_or_otag++;	scb->flags |= SCB_ACTIVE;	ahd_queue_scb(ahd, scb);	return 0;}
4520	/local/tlutelli/issta_data/temp/c/2005_temp/2005/4520/73a25462100772b72a5d62fd66dff01b53018618/aic79xx_osm.c/buggy/drivers/scsi/aic7xxx/aic79xx_osm.c