DEBUG((KERN_ERR "scsi%d (%d:%d) has non zero depth %d\n", SCp->device->host->host_no, SCp->device->id, SCp->device->lun, NCR_700_get_depth(SCp->device))); 
CDEBUG(KERN_ERR, SCp, "has non zero depth %d\n", NCR_700_get_depth(SCp->device)); 
NCR_700_queuecommand(struct scsi_cmnd *SCp, void (*done)(struct scsi_cmnd *)){	struct NCR_700_Host_Parameters *hostdata = 		(struct NCR_700_Host_Parameters *)SCp->device->host->hostdata[0];	__u32 move_ins;	enum dma_data_direction direction;	struct NCR_700_command_slot *slot;	if(hostdata->command_slot_count >= NCR_700_COMMAND_SLOTS_PER_HOST) {		/* We're over our allocation, this should never happen		 * since we report the max allocation to the mid layer */		printk(KERN_WARNING "scsi%d: Command depth has gone over queue depth\n", SCp->device->host->host_no);		return 1;	}	/* check for untagged commands.  We cannot have any outstanding	 * commands if we accept them.  Commands could be untagged because:	 *	 * - The tag negotiated bitmap is clear	 * - The blk layer sent and untagged command	 */	if(NCR_700_get_depth(SCp->device) != 0	   && (!(hostdata->tag_negotiated & (1<<SCp->device->id))	       || !blk_rq_tagged(SCp->request))) {		DEBUG((KERN_ERR "scsi%d (%d:%d) has non zero depth %d\n",		       SCp->device->host->host_no, SCp->device->id, SCp->device->lun,		       NCR_700_get_depth(SCp->device)));		return SCSI_MLQUEUE_DEVICE_BUSY;	}	if(NCR_700_get_depth(SCp->device) >= SCp->device->queue_depth) {		DEBUG((KERN_ERR "scsi%d (%d:%d) has max tag depth %d\n",		       SCp->device->host->host_no, SCp->device->id, SCp->device->lun,		       NCR_700_get_depth(SCp->device)));		return SCSI_MLQUEUE_DEVICE_BUSY;	}	NCR_700_set_depth(SCp->device, NCR_700_get_depth(SCp->device) + 1);	/* begin the command here */	/* no need to check for NULL, test for command_slot_count above	 * ensures a slot is free */	slot = find_empty_slot(hostdata);	slot->cmnd = SCp;	SCp->scsi_done = done;	SCp->host_scribble = (unsigned char *)slot;	SCp->SCp.ptr = NULL;	SCp->SCp.buffer = NULL;#ifdef NCR_700_DEBUG	printk("53c700: scsi%d, command ", SCp->device->host->host_no);	scsi_print_command(SCp);#endif	if(blk_rq_tagged(SCp->request)	   && (hostdata->tag_negotiated &(1<<SCp->device->id)) == 0	   && NCR_700_get_tag_neg_state(SCp->device) == NCR_700_START_TAG_NEGOTIATION) {		printk(KERN_ERR "scsi%d: (%d:%d) Enabling Tag Command Queuing\n", SCp->device->host->host_no, SCp->device->id, SCp->device->lun);		hostdata->tag_negotiated |= (1<<SCp->device->id);		NCR_700_set_tag_neg_state(SCp->device, NCR_700_DURING_TAG_NEGOTIATION);	}	/* here we may have to process an untagged command.  The gate	 * above ensures that this will be the only one outstanding,	 * so clear the tag negotiated bit.	 *	 * FIXME: This will royally screw up on multiple LUN devices	 * */	if(!blk_rq_tagged(SCp->request)	   && (hostdata->tag_negotiated &(1<<SCp->device->id))) {		printk(KERN_INFO "scsi%d: (%d:%d) Disabling Tag Command Queuing\n", SCp->device->host->host_no, SCp->device->id, SCp->device->lun);		hostdata->tag_negotiated &= ~(1<<SCp->device->id);	}	if((hostdata->tag_negotiated &(1<<SCp->device->id))	   && scsi_get_tag_type(SCp->device)) {		slot->tag = SCp->request->tag;		DEBUG(("53c700 %d:%d:%d, sending out tag %d, slot %p\n",		       SCp->device->host->host_no, SCp->device->id, SCp->device->lun, slot->tag,		       slot));	} else {		slot->tag = SCSI_NO_TAG;		/* must populate current_cmnd for scsi_find_tag to work */		SCp->device->current_cmnd = SCp;	}	/* sanity check: some of the commands generated by the mid-layer	 * have an eccentric idea of their sc_data_direction */	if(!SCp->use_sg && !SCp->request_bufflen 	   && SCp->sc_data_direction != DMA_NONE) {#ifdef NCR_700_DEBUG		printk("53c700: Command");		scsi_print_command(SCp);		printk("Has wrong data direction %d\n", SCp->sc_data_direction);#endif		SCp->sc_data_direction = DMA_NONE;	}	switch (SCp->cmnd[0]) {	case REQUEST_SENSE:		/* clear the internal sense magic */		SCp->cmnd[6] = 0;		/* fall through */	default:		/* OK, get it from the command */		switch(SCp->sc_data_direction) {		case DMA_BIDIRECTIONAL:		default:			printk(KERN_ERR "53c700: Unknown command for data direction ");			scsi_print_command(SCp);						move_ins = 0;			break;		case DMA_NONE:			move_ins = 0;			break;		case DMA_FROM_DEVICE:			move_ins = SCRIPT_MOVE_DATA_IN;			break;		case DMA_TO_DEVICE:			move_ins = SCRIPT_MOVE_DATA_OUT;			break;		}	}	/* now build the scatter gather list */	direction = SCp->sc_data_direction;	if(move_ins != 0) {		int i;		int sg_count;		dma_addr_t vPtr = 0;		__u32 count = 0;		if(SCp->use_sg) {			sg_count = dma_map_sg(hostdata->dev, SCp->buffer,					      SCp->use_sg, direction);		} else {			vPtr = dma_map_single(hostdata->dev,					      SCp->request_buffer, 					      SCp->request_bufflen,					      direction);			count = SCp->request_bufflen;			slot->dma_handle = vPtr;			sg_count = 1;		}					for(i = 0; i < sg_count; i++) {			if(SCp->use_sg) {				struct scatterlist *sg = SCp->buffer;				vPtr = sg_dma_address(&sg[i]);				count = sg_dma_len(&sg[i]);			}			slot->SG[i].ins = bS_to_host(move_ins | count);			DEBUG((" scatter block %d: move %d[%08x] from 0x%lx\n",			       i, count, slot->SG[i].ins, (unsigned long)vPtr));			slot->SG[i].pAddr = bS_to_host(vPtr);		}		slot->SG[i].ins = bS_to_host(SCRIPT_RETURN);		slot->SG[i].pAddr = 0;		dma_cache_sync(slot->SG, sizeof(slot->SG), DMA_TO_DEVICE);		DEBUG((" SETTING %08lx to %x\n",		       (&slot->pSG[i].ins), 		       slot->SG[i].ins));	}	slot->resume_offset = 0;	slot->pCmd = dma_map_single(hostdata->dev, SCp->cmnd,				    sizeof(SCp->cmnd), DMA_TO_DEVICE);	NCR_700_start_command(SCp);	return 0;}
4520	/local/tlutelli/issta_data/temp/c/2005_temp/2005/4520/017560fca496f72ed9dd734ffde63ce39dfe0411/53c700.c/buggy/drivers/scsi/53c700.c