Lines Matching +full:host +full:- +full:command

1 // SPDX-License-Identifier: GPL-2.0-or-later
3 /* NCR (or Symbios) 53c700 and 53c700-66 Driver
6 **-----------------------------------------------------------------------------
9 **-----------------------------------------------------------------------------
20 * The 700-66 can at least do synchronous SCSI up to 10MHz.
22 * The 700 chip has no host bus interface logic of its own. However,
27 * minimal wrapper for the purpose---see the NCR_D700 driver for
45 * bad bug having to do with 10 byte command processing and REQUEST
46 * SENSE (the command would loop forever getting a transfer length
54 * Bogendoerfer). Added missing SCp->request_bufflen initialisation
73 * Added support for the 53c710 chip (in 53c700 emulation mode only---no
135 * a non dereferenceable pointer to point to a structure in dma-able
149 MODULE_DESCRIPTION("53c700 and 53c700-66 Driver");
159 STATIC void NCR_700_chip_setup(struct Scsi_Host *host);
160 STATIC void NCR_700_chip_reset(struct Scsi_Host *host);
174 "before command phase",
175 "after command phase",
229 * NOTE: According to SCSI-2, the true transfer period (in ns) is
237 __u8 min_xferp = (hostdata->chip710 in NCR_700_offset_period_to_sxfer()
239 __u8 max_offset = (hostdata->chip710 in NCR_700_offset_period_to_sxfer()
245 if(period < hostdata->min_period) { in NCR_700_offset_period_to_sxfer()
247 period = hostdata->min_period; in NCR_700_offset_period_to_sxfer()
249 XFERP = (period*4 * hostdata->sync_clock)/1000 - 4; in NCR_700_offset_period_to_sxfer()
265 (struct NCR_700_Host_Parameters *)SDp->host->hostdata[0]; in NCR_700_get_SXFER()
268 spi_offset(SDp->sdev_target), in NCR_700_get_SXFER()
269 spi_period(SDp->sdev_target)); in NCR_700_get_SXFER()
274 return h->pScript + ((uintptr_t)p - (uintptr_t)h->script); in virt_to_dma()
280 if (h->noncoherent) in dma_sync_to_dev()
281 dma_sync_single_for_device(h->dev, virt_to_dma(h, addr), in dma_sync_to_dev()
288 if (h->noncoherent) in dma_sync_from_dev()
289 dma_sync_single_for_device(h->dev, virt_to_dma(h, addr), size, in dma_sync_from_dev()
300 struct Scsi_Host *host; in NCR_700_detect() local
304 if (tpnt->sdev_groups == NULL) in NCR_700_detect()
305 tpnt->sdev_groups = NCR_700_dev_groups; in NCR_700_detect()
309 hostdata->noncoherent = 1; in NCR_700_detect()
319 hostdata->msgin = memory + MSGIN_OFFSET; in NCR_700_detect()
320 hostdata->msgout = memory + MSGOUT_OFFSET; in NCR_700_detect()
321 hostdata->status = memory + STATUS_OFFSET; in NCR_700_detect()
322 hostdata->slots = (struct NCR_700_command_slot *)(memory + SLOTS_OFFSET); in NCR_700_detect()
323 hostdata->dev = dev; in NCR_700_detect()
327 /* Fill in the missing routines from the host template */ in NCR_700_detect()
328 tpnt->queuecommand = NCR_700_queuecommand; in NCR_700_detect()
329 tpnt->eh_abort_handler = NCR_700_abort; in NCR_700_detect()
330 tpnt->eh_host_reset_handler = NCR_700_host_reset; in NCR_700_detect()
331 tpnt->can_queue = NCR_700_COMMAND_SLOTS_PER_HOST; in NCR_700_detect()
332 tpnt->sg_tablesize = NCR_700_SG_SEGMENTS; in NCR_700_detect()
333 tpnt->cmd_per_lun = NCR_700_CMD_PER_LUN; in NCR_700_detect()
334 tpnt->sdev_configure = NCR_700_sdev_configure; in NCR_700_detect()
335 tpnt->sdev_destroy = NCR_700_sdev_destroy; in NCR_700_detect()
336 tpnt->sdev_init = NCR_700_sdev_init; in NCR_700_detect()
337 tpnt->change_queue_depth = NCR_700_change_queue_depth; in NCR_700_detect()
339 if(tpnt->name == NULL) in NCR_700_detect()
340 tpnt->name = "53c700"; in NCR_700_detect()
341 if(tpnt->proc_name == NULL) in NCR_700_detect()
342 tpnt->proc_name = "53c700"; in NCR_700_detect()
344 host = scsi_host_alloc(tpnt, 4); in NCR_700_detect()
345 if (!host) in NCR_700_detect()
347 memset(hostdata->slots, 0, sizeof(struct NCR_700_command_slot) in NCR_700_detect()
350 dma_addr_t offset = (dma_addr_t)((unsigned long)&hostdata->slots[j].SG[0] in NCR_700_detect()
351 - (unsigned long)&hostdata->slots[0].SG[0]); in NCR_700_detect()
352 hostdata->slots[j].pSG = (struct NCR_700_SG_List *)((unsigned long)(pSlots + offset)); in NCR_700_detect()
354 hostdata->free_list = &hostdata->slots[j]; in NCR_700_detect()
356 hostdata->slots[j-1].ITL_forw = &hostdata->slots[j]; in NCR_700_detect()
357 hostdata->slots[j].state = NCR_700_SLOT_FREE; in NCR_700_detect()
374 hostdata->script = script; in NCR_700_detect()
375 hostdata->pScript = pScript; in NCR_700_detect()
376 dma_sync_single_for_device(hostdata->dev, pScript, sizeof(SCRIPT), DMA_TO_DEVICE); in NCR_700_detect()
377 hostdata->state = NCR_700_HOST_FREE; in NCR_700_detect()
378 hostdata->cmd = NULL; in NCR_700_detect()
379 host->max_id = 8; in NCR_700_detect()
380 host->max_lun = NCR_700_MAX_LUNS; in NCR_700_detect()
382 host->transportt = NCR_700_transport_template; in NCR_700_detect()
383 host->unique_id = (unsigned long)hostdata->base; in NCR_700_detect()
384 hostdata->eh_complete = NULL; in NCR_700_detect()
385 host->hostdata[0] = (unsigned long)hostdata; in NCR_700_detect()
387 NCR_700_writeb(0xff, host, CTEST9_REG); in NCR_700_detect()
388 if (hostdata->chip710) in NCR_700_detect()
389 hostdata->rev = (NCR_700_readb(host, CTEST8_REG)>>4) & 0x0f; in NCR_700_detect()
391 hostdata->rev = (NCR_700_readb(host, CTEST7_REG)>>4) & 0x0f; in NCR_700_detect()
392 hostdata->fast = (NCR_700_readb(host, CTEST9_REG) == 0); in NCR_700_detect()
397 printk(KERN_NOTICE "scsi%d: %s rev %d %s\n", host->host_no, in NCR_700_detect()
398 hostdata->chip710 ? "53c710" : in NCR_700_detect()
399 (hostdata->fast ? "53c700-66" : "53c700"), in NCR_700_detect()
400 hostdata->rev, hostdata->differential ? in NCR_700_detect()
403 NCR_700_chip_reset(host); in NCR_700_detect()
405 if (scsi_add_host(host, dev)) { in NCR_700_detect()
407 scsi_host_put(host); in NCR_700_detect()
411 spi_signalling(host) = hostdata->differential ? SPI_SIGNAL_HVD : in NCR_700_detect()
414 return host; in NCR_700_detect()
418 NCR_700_release(struct Scsi_Host *host) in NCR_700_release() argument
421 (struct NCR_700_Host_Parameters *)host->hostdata[0]; in NCR_700_release()
423 if (hostdata->noncoherent) in NCR_700_release()
424 dma_free_noncoherent(hostdata->dev, TOTAL_MEM_SIZE, in NCR_700_release()
425 hostdata->script, hostdata->pScript, in NCR_700_release()
428 dma_free_coherent(hostdata->dev, TOTAL_MEM_SIZE, in NCR_700_release()
429 hostdata->script, hostdata->pScript); in NCR_700_release()
442 * Function : static int data_residual (Scsi_Host *host)
450 * Inputs : host - SCSI host */
452 NCR_700_data_residual (struct Scsi_Host *host) { in NCR_700_data_residual() argument
454 (struct NCR_700_Host_Parameters *)host->hostdata[0]; in NCR_700_data_residual()
458 if(hostdata->chip710) { in NCR_700_data_residual()
459 count = ((NCR_700_readb(host, DFIFO_REG) & 0x7f) - in NCR_700_data_residual()
460 (NCR_700_readl(host, DBC_REG) & 0x7f)) & 0x7f; in NCR_700_data_residual()
462 count = ((NCR_700_readb(host, DFIFO_REG) & 0x3f) - in NCR_700_data_residual()
463 (NCR_700_readl(host, DBC_REG) & 0x3f)) & 0x3f; in NCR_700_data_residual()
466 if(hostdata->fast) in NCR_700_data_residual()
467 synchronous = NCR_700_readb(host, SXFER_REG) & 0x0f; in NCR_700_data_residual()
470 ddir = NCR_700_readb(host, CTEST0_REG) & 0x01; in NCR_700_data_residual()
475 count += (NCR_700_readb(host, SSTAT2_REG) & 0xf0) >> 4; in NCR_700_data_residual()
477 if (NCR_700_readb(host, SSTAT1_REG) & SIDL_REG_FULL) in NCR_700_data_residual()
481 __u8 sstat = NCR_700_readb(host, SSTAT1_REG); in NCR_700_data_residual()
525 struct NCR_700_command_slot *slot = hostdata->free_list; in find_empty_slot()
529 if(hostdata->command_slot_count != NCR_700_COMMAND_SLOTS_PER_HOST) in find_empty_slot()
530 …printk(KERN_ERR "SLOTS FULL, but count is %d, should be %d\n", hostdata->command_slot_count, NCR_7… in find_empty_slot()
534 if(slot->state != NCR_700_SLOT_FREE) in find_empty_slot()
539 hostdata->free_list = slot->ITL_forw; in find_empty_slot()
540 slot->ITL_forw = NULL; in find_empty_slot()
545 * finish routine. If we cannot queue the command when it in find_empty_slot()
547 slot->state = NCR_700_SLOT_BUSY; in find_empty_slot()
548 slot->flags = 0; in find_empty_slot()
549 hostdata->command_slot_count++; in find_empty_slot()
558 if((slot->state & NCR_700_SLOT_MASK) != NCR_700_SLOT_MAGIC) { in free_slot()
561 if(slot->state == NCR_700_SLOT_FREE) { in free_slot()
565 slot->resume_offset = 0; in free_slot()
566 slot->cmnd = NULL; in free_slot()
567 slot->state = NCR_700_SLOT_FREE; in free_slot()
568 slot->ITL_forw = hostdata->free_list; in free_slot()
569 hostdata->free_list = slot; in free_slot()
570 hostdata->command_slot_count--; in free_slot()
574 /* This routine really does very little. The command is indexed on
583 (struct NCR_700_command_slot *)SCp->host_scribble; in save_for_reselection()
585 slot->resume_offset = dsp; in save_for_reselection()
587 hostdata->state = NCR_700_HOST_FREE; in save_for_reselection()
588 hostdata->cmd = NULL; in save_for_reselection()
595 if(SCp->sc_data_direction != DMA_NONE && in NCR_700_unmap()
596 SCp->sc_data_direction != DMA_BIDIRECTIONAL) in NCR_700_unmap()
604 hostdata->state = NCR_700_HOST_FREE; in NCR_700_scsi_done()
605 hostdata->cmd = NULL; in NCR_700_scsi_done()
609 (struct NCR_700_command_slot *)SCp->host_scribble; in NCR_700_scsi_done()
611 dma_unmap_single(hostdata->dev, slot->pCmd, in NCR_700_scsi_done()
613 if (slot->flags == NCR_700_FLAG_AUTOSENSE) { in NCR_700_scsi_done()
614 char *cmnd = NCR_700_get_sense_cmnd(SCp->device); in NCR_700_scsi_done()
616 dma_unmap_single(hostdata->dev, slot->dma_handle, in NCR_700_scsi_done()
623 SCp->cmd_len = cmnd[8]; in NCR_700_scsi_done()
629 if(NCR_700_get_depth(SCp->device) == 0 || in NCR_700_scsi_done()
630 NCR_700_get_depth(SCp->device) > SCp->device->queue_depth) in NCR_700_scsi_done()
632 NCR_700_get_depth(SCp->device)); in NCR_700_scsi_done()
634 NCR_700_set_depth(SCp->device, NCR_700_get_depth(SCp->device) - 1); in NCR_700_scsi_done()
636 SCp->host_scribble = NULL; in NCR_700_scsi_done()
637 SCp->result = result; in NCR_700_scsi_done()
646 NCR_700_internal_bus_reset(struct Scsi_Host *host) in NCR_700_internal_bus_reset() argument
649 NCR_700_writeb(ASSERT_RST, host, SCNTL1_REG); in NCR_700_internal_bus_reset()
651 NCR_700_writeb(0, host, SCNTL1_REG); in NCR_700_internal_bus_reset()
656 NCR_700_chip_setup(struct Scsi_Host *host) in NCR_700_chip_setup() argument
659 (struct NCR_700_Host_Parameters *)host->hostdata[0]; in NCR_700_chip_setup()
661 __u8 min_xferp = (hostdata->chip710 ? NCR_710_MIN_XFERP : NCR_700_MIN_XFERP); in NCR_700_chip_setup()
663 if(hostdata->chip710) { in NCR_700_chip_setup()
667 switch (hostdata->burst_length) { in NCR_700_chip_setup()
684 hostdata->dcntl_extra |= COMPAT_700_MODE; in NCR_700_chip_setup()
686 NCR_700_writeb(hostdata->dcntl_extra, host, DCNTL_REG); in NCR_700_chip_setup()
687 NCR_700_writeb(burst_length | hostdata->dmode_extra, in NCR_700_chip_setup()
688 host, DMODE_710_REG); in NCR_700_chip_setup()
689 NCR_700_writeb(burst_disable | hostdata->ctest7_extra | in NCR_700_chip_setup()
690 (hostdata->differential ? DIFF : 0), in NCR_700_chip_setup()
691 host, CTEST7_REG); in NCR_700_chip_setup()
692 NCR_700_writeb(BTB_TIMER_DISABLE, host, CTEST0_REG); in NCR_700_chip_setup()
694 | AUTO_ATN, host, SCNTL0_REG); in NCR_700_chip_setup()
696 NCR_700_writeb(BURST_LENGTH_8 | hostdata->dmode_extra, in NCR_700_chip_setup()
697 host, DMODE_700_REG); in NCR_700_chip_setup()
698 NCR_700_writeb(hostdata->differential ? in NCR_700_chip_setup()
699 DIFF : 0, host, CTEST7_REG); in NCR_700_chip_setup()
700 if(hostdata->fast) { in NCR_700_chip_setup()
701 /* this is for 700-66, does nothing on 700 */ in NCR_700_chip_setup()
703 | GENERATE_RECEIVE_PARITY, host, in NCR_700_chip_setup()
707 | PARITY | AUTO_ATN, host, SCNTL0_REG); in NCR_700_chip_setup()
711 NCR_700_writeb(1 << host->this_id, host, SCID_REG); in NCR_700_chip_setup()
712 NCR_700_writeb(0, host, SBCL_REG); in NCR_700_chip_setup()
713 NCR_700_writeb(ASYNC_OPERATION, host, SXFER_REG); in NCR_700_chip_setup()
716 | RST_INT | PAR_ERR_INT | SELECT_INT, host, SIEN_REG); in NCR_700_chip_setup()
718 NCR_700_writeb(ABORT_INT | INT_INST_INT | ILGL_INST_INT, host, DIEN_REG); in NCR_700_chip_setup()
719 NCR_700_writeb(ENABLE_SELECT, host, SCNTL1_REG); in NCR_700_chip_setup()
720 if(hostdata->clock > 75) { in NCR_700_chip_setup()
721 …lock speed %dMHz is too high: 75Mhz is the maximum this chip can be driven at\n", hostdata->clock); in NCR_700_chip_setup()
725 NCR_700_writeb(SYNC_DIV_2_0, host, SBCL_REG); in NCR_700_chip_setup()
726 NCR_700_writeb(ASYNC_DIV_3_0 | hostdata->dcntl_extra, host, DCNTL_REG); in NCR_700_chip_setup()
727 hostdata->sync_clock = hostdata->clock/2; in NCR_700_chip_setup()
728 } else if(hostdata->clock > 50 && hostdata->clock <= 75) { in NCR_700_chip_setup()
731 NCR_700_writeb(SYNC_DIV_1_5, host, SBCL_REG); in NCR_700_chip_setup()
732 NCR_700_writeb(ASYNC_DIV_3_0 | hostdata->dcntl_extra, host, DCNTL_REG); in NCR_700_chip_setup()
733 hostdata->sync_clock = hostdata->clock*2; in NCR_700_chip_setup()
734 hostdata->sync_clock /= 3; in NCR_700_chip_setup()
736 } else if(hostdata->clock > 37 && hostdata->clock <= 50) { in NCR_700_chip_setup()
739 NCR_700_writeb(SYNC_DIV_1_0, host, SBCL_REG); in NCR_700_chip_setup()
740 NCR_700_writeb(ASYNC_DIV_2_0 | hostdata->dcntl_extra, host, DCNTL_REG); in NCR_700_chip_setup()
741 hostdata->sync_clock = hostdata->clock; in NCR_700_chip_setup()
742 } else if(hostdata->clock > 25 && hostdata->clock <=37) { in NCR_700_chip_setup()
745 NCR_700_writeb(SYNC_DIV_1_0, host, SBCL_REG); in NCR_700_chip_setup()
746 NCR_700_writeb(ASYNC_DIV_1_5 | hostdata->dcntl_extra, host, DCNTL_REG); in NCR_700_chip_setup()
747 hostdata->sync_clock = hostdata->clock; in NCR_700_chip_setup()
750 NCR_700_writeb(SYNC_DIV_1_0, host, SBCL_REG); in NCR_700_chip_setup()
751 NCR_700_writeb(ASYNC_DIV_1_0 | hostdata->dcntl_extra, host, DCNTL_REG); in NCR_700_chip_setup()
753 hostdata->sync_clock = hostdata->clock; in NCR_700_chip_setup()
759 min_period = 1000*(4+min_xferp)/(4*hostdata->sync_clock); in NCR_700_chip_setup()
760 hostdata->min_period = NCR_700_MIN_PERIOD; in NCR_700_chip_setup()
762 hostdata->min_period = min_period; in NCR_700_chip_setup()
766 NCR_700_chip_reset(struct Scsi_Host *host) in NCR_700_chip_reset() argument
769 (struct NCR_700_Host_Parameters *)host->hostdata[0]; in NCR_700_chip_reset()
770 if(hostdata->chip710) { in NCR_700_chip_reset()
771 NCR_700_writeb(SOFTWARE_RESET_710, host, ISTAT_REG); in NCR_700_chip_reset()
774 NCR_700_writeb(0, host, ISTAT_REG); in NCR_700_chip_reset()
776 NCR_700_writeb(SOFTWARE_RESET, host, DCNTL_REG); in NCR_700_chip_reset()
779 NCR_700_writeb(0, host, DCNTL_REG); in NCR_700_chip_reset()
784 NCR_700_chip_setup(host); in NCR_700_chip_reset()
794 process_extended_message(struct Scsi_Host *host, in process_extended_message() argument
802 pun = SCp->device->id; in process_extended_message()
803 lun = SCp->device->lun; in process_extended_message()
806 switch(hostdata->msgin[2]) { in process_extended_message()
808 if(SCp != NULL && NCR_700_is_flag_set(SCp->device, NCR_700_DEV_BEGIN_SYNC_NEGOTIATION)) { in process_extended_message()
809 struct scsi_target *starget = SCp->device->sdev_target; in process_extended_message()
810 __u8 period = hostdata->msgin[3]; in process_extended_message()
811 __u8 offset = hostdata->msgin[4]; in process_extended_message()
821 if(NCR_700_is_flag_set(SCp->device, NCR_700_DEV_PRINT_SYNC_NEGOTIATION)) { in process_extended_message()
823 NCR_700_clear_flag(SCp->device, NCR_700_DEV_PRINT_SYNC_NEGOTIATION); in process_extended_message()
826 NCR_700_set_flag(SCp->device, NCR_700_DEV_NEGOTIATED_SYNC); in process_extended_message()
827 NCR_700_clear_flag(SCp->device, NCR_700_DEV_BEGIN_SYNC_NEGOTIATION); in process_extended_message()
829 NCR_700_writeb(NCR_700_get_SXFER(SCp->device), in process_extended_message()
830 host, SXFER_REG); in process_extended_message()
834 shost_printk(KERN_WARNING, host, in process_extended_message()
836 hostdata->msgout[0] = A_REJECT_MSG; in process_extended_message()
837 dma_sync_to_dev(hostdata, hostdata->msgout, 1); in process_extended_message()
838 script_patch_16(hostdata, hostdata->script, in process_extended_message()
842 resume_offset = hostdata->pScript + Ent_SendMessageWithATN; in process_extended_message()
848 host->host_no, pun, lun); in process_extended_message()
849 hostdata->msgout[0] = A_REJECT_MSG; in process_extended_message()
850 dma_sync_to_dev(hostdata, hostdata->msgout, 1); in process_extended_message()
851 script_patch_16(hostdata, hostdata->script, MessageCount, 1); in process_extended_message()
852 resume_offset = hostdata->pScript + Ent_SendMessageWithATN; in process_extended_message()
858 host->host_no, pun, lun, in process_extended_message()
860 spi_print_msg(hostdata->msgin); in process_extended_message()
863 hostdata->msgout[0] = A_REJECT_MSG; in process_extended_message()
864 dma_sync_to_dev(hostdata, hostdata->msgout, 1); in process_extended_message()
865 script_patch_16(hostdata, hostdata->script, MessageCount, 1); in process_extended_message()
868 resume_offset = hostdata->pScript + Ent_SendMessageWithATN; in process_extended_message()
870 NCR_700_writel(temp, host, TEMP_REG); in process_extended_message()
875 process_message(struct Scsi_Host *host, struct NCR_700_Host_Parameters *hostdata, in process_message() argument
883 pun = SCp->device->id; in process_message()
884 lun = SCp->device->lun; in process_message()
888 printk("scsi%d (%d:%d): message %s: ", host->host_no, pun, lun, in process_message()
890 spi_print_msg(hostdata->msgin); in process_message()
894 switch(hostdata->msgin[0]) { in process_message()
897 resume_offset = process_extended_message(host, hostdata, SCp, in process_message()
902 if(SCp != NULL && NCR_700_is_flag_set(SCp->device, NCR_700_DEV_BEGIN_SYNC_NEGOTIATION)) { in process_message()
904 spi_period(SCp->device->sdev_target) = in process_message()
905 spi_offset(SCp->device->sdev_target) = 0; in process_message()
906 NCR_700_set_flag(SCp->device, NCR_700_DEV_NEGOTIATED_SYNC); in process_message()
907 NCR_700_clear_flag(SCp->device, NCR_700_DEV_BEGIN_SYNC_NEGOTIATION); in process_message()
908 …} else if(SCp != NULL && NCR_700_get_tag_neg_state(SCp->device) == NCR_700_DURING_TAG_NEGOTIATION)… in process_message()
913 NCR_700_set_tag_neg_state(SCp->device, NCR_700_FINISHED_TAG_NEGOTIATION); in process_message()
914 hostdata->tag_negotiated &= ~(1<<scmd_id(SCp)); in process_message()
916 SCp->device->tagged_supported = 0; in process_message()
917 SCp->device->simple_tags = 0; in process_message()
918 scsi_change_queue_depth(SCp->device, host->cmd_per_lun); in process_message()
920 shost_printk(KERN_WARNING, host, in process_message()
929 printk(KERN_ERR "scsi%d (%d:%d) Parity Error!\n", host->host_no, in process_message()
931 NCR_700_internal_bus_reset(host); in process_message()
934 printk(KERN_INFO "scsi%d (%d:%d) SIMPLE TAG %d %s\n", host->host_no, in process_message()
935 pun, lun, hostdata->msgin[1], in process_message()
941 host->host_no, pun, lun, in process_message()
944 spi_print_msg(hostdata->msgin); in process_message()
947 hostdata->msgout[0] = A_REJECT_MSG; in process_message()
948 dma_sync_to_dev(hostdata, hostdata->msgout, 1); in process_message()
949 script_patch_16(hostdata, hostdata->script, MessageCount, 1); in process_message()
952 resume_offset = hostdata->pScript + Ent_SendMessageWithATN; in process_message()
956 NCR_700_writel(temp, host, TEMP_REG); in process_message()
958 dma_sync_from_dev(hostdata, hostdata->msgin, MSG_ARRAY_SIZE); in process_message()
964 struct Scsi_Host *host, in process_script_interrupt() argument
971 pun = SCp->device->id; in process_script_interrupt()
972 lun = SCp->device->lun; in process_script_interrupt()
976 DEBUG((" COMMAND COMPLETE, status=%02x\n", in process_script_interrupt()
977 hostdata->status[0])); in process_script_interrupt()
979 if (NCR_700_get_tag_neg_state(SCp->device) == NCR_700_DURING_TAG_NEGOTIATION) in process_script_interrupt()
980 NCR_700_set_tag_neg_state(SCp->device, in process_script_interrupt()
984 if (hostdata->status[0] == SAM_STAT_CHECK_CONDITION || in process_script_interrupt()
985 hostdata->status[0] == SAM_STAT_COMMAND_TERMINATED) { in process_script_interrupt()
987 (struct NCR_700_command_slot *)SCp->host_scribble; in process_script_interrupt()
988 if(slot->flags == NCR_700_FLAG_AUTOSENSE) { in process_script_interrupt()
993 NCR_700_scsi_done(hostdata, SCp, hostdata->status[0]); in process_script_interrupt()
996 NCR_700_get_sense_cmnd(SCp->device); in process_script_interrupt()
1000 SCp, hostdata->status[0]); in process_script_interrupt()
1002 /* we can destroy the command here in process_script_interrupt()
1005 * will re-copy the command from the in process_script_interrupt()
1007 * data associated with the command in process_script_interrupt()
1010 dma_unmap_single(hostdata->dev, slot->pCmd, in process_script_interrupt()
1021 * REQUEST_SENSE command is six bytes, in process_script_interrupt()
1025 * of the command */ in process_script_interrupt()
1027 cmnd[7] = hostdata->status[0]; in process_script_interrupt()
1028 cmnd[8] = SCp->cmd_len; in process_script_interrupt()
1029 SCp->cmd_len = 6; /* command length for in process_script_interrupt()
1031 slot->pCmd = dma_map_single(hostdata->dev, cmnd, MAX_COMMAND_SIZE, DMA_TO_DEVICE); in process_script_interrupt()
1032 …slot->dma_handle = dma_map_single(hostdata->dev, SCp->sense_buffer, SCSI_SENSE_BUFFERSIZE, DMA_FRO… in process_script_interrupt()
1033 slot->SG[0].ins = bS_to_host(SCRIPT_MOVE_DATA_IN | SCSI_SENSE_BUFFERSIZE); in process_script_interrupt()
1034 slot->SG[0].pAddr = bS_to_host(slot->dma_handle); in process_script_interrupt()
1035 slot->SG[1].ins = bS_to_host(SCRIPT_RETURN); in process_script_interrupt()
1036 slot->SG[1].pAddr = 0; in process_script_interrupt()
1037 slot->resume_offset = hostdata->pScript; in process_script_interrupt()
1038 dma_sync_to_dev(hostdata, slot->SG, sizeof(slot->SG[0])*2); in process_script_interrupt()
1039 dma_sync_from_dev(hostdata, SCp->sense_buffer, SCSI_SENSE_BUFFERSIZE); in process_script_interrupt()
1041 /* queue the command for reissue */ in process_script_interrupt()
1042 slot->state = NCR_700_SLOT_QUEUED; in process_script_interrupt()
1043 slot->flags = NCR_700_FLAG_AUTOSENSE; in process_script_interrupt()
1044 hostdata->state = NCR_700_HOST_FREE; in process_script_interrupt()
1045 hostdata->cmd = NULL; in process_script_interrupt()
1051 //if(status_byte(hostdata->status[0]) == GOOD && in process_script_interrupt()
1052 // SCp->cmnd[0] == INQUIRY && SCp->use_sg == 0) { in process_script_interrupt()
1054 // * on this command */ in process_script_interrupt()
1055 // dma_sync_single_for_cpu(hostdata->dev, in process_script_interrupt()
1056 // slot->dma_handle, in process_script_interrupt()
1057 // SCp->request_bufflen, in process_script_interrupt()
1059 // if(((char *)SCp->request_buffer)[7] & 0x02) { in process_script_interrupt()
1061 // "Enabling Tag Command Queuing\n"); in process_script_interrupt()
1062 // hostdata->tag_negotiated |= (1<<scmd_id(SCp)); in process_script_interrupt()
1063 // NCR_700_set_flag(SCp->device, NCR_700_DEV_BEGIN_TAG_QUEUEING); in process_script_interrupt()
1065 // NCR_700_clear_flag(SCp->device, NCR_700_DEV_BEGIN_TAG_QUEUEING); in process_script_interrupt()
1066 // hostdata->tag_negotiated &= ~(1<<scmd_id(SCp)); in process_script_interrupt()
1069 NCR_700_scsi_done(hostdata, SCp, hostdata->status[0]); in process_script_interrupt()
1076 sbcl_to_string(NCR_700_readb(host, SBCL_REG))); in process_script_interrupt()
1078 SCp->cmd_len); in process_script_interrupt()
1081 NCR_700_internal_bus_reset(host); in process_script_interrupt()
1086 host->host_no, pun, lun, NCR_700_fatal_messages[i]); in process_script_interrupt()
1089 hostdata->msgin[0], hostdata->msgin[1]); in process_script_interrupt()
1091 NCR_700_internal_bus_reset(host); in process_script_interrupt()
1097 host->host_no, pun, lun, in process_script_interrupt()
1105 __u8 reselection_id = hostdata->reselection_id; in process_script_interrupt()
1108 lun = hostdata->msgin[0] & 0x1f; in process_script_interrupt()
1110 hostdata->reselection_id = 0xff; in process_script_interrupt()
1112 host->host_no, reselection_id, lun)); in process_script_interrupt()
1114 SDp = __scsi_device_lookup(host, 0, reselection_id, lun); in process_script_interrupt()
1117 host->host_no, reselection_id, lun); in process_script_interrupt()
1120 if(hostdata->msgin[1] == A_SIMPLE_TAG_MSG) { in process_script_interrupt()
1123 SCp = scsi_host_find_tag(SDp->host, hostdata->msgin[2]); in process_script_interrupt()
1126 host->host_no, reselection_id, lun, hostdata->msgin[2]); in process_script_interrupt()
1130 slot = (struct NCR_700_command_slot *)SCp->host_scribble; in process_script_interrupt()
1133 hostdata->msgin[2], slot, slot->tag); in process_script_interrupt()
1135 struct NCR_700_Device_Parameters *p = SDp->hostdata; in process_script_interrupt()
1136 struct scsi_cmnd *SCp = p->current_cmnd; in process_script_interrupt()
1143 slot = (struct NCR_700_command_slot *)SCp->host_scribble; in process_script_interrupt()
1147 printk(KERN_ERR "scsi%d: (%d:%d) RESELECTED but no saved command (MSG = %02x %02x %02x)!!\n", in process_script_interrupt()
1148 host->host_no, reselection_id, lun, in process_script_interrupt()
1149 hostdata->msgin[0], hostdata->msgin[1], in process_script_interrupt()
1150 hostdata->msgin[2]); in process_script_interrupt()
1152 if(hostdata->state != NCR_700_HOST_BUSY) in process_script_interrupt()
1153 printk(KERN_ERR "scsi%d: FATAL, host not busy during valid reselection!\n", in process_script_interrupt()
1154 host->host_no); in process_script_interrupt()
1155 resume_offset = slot->resume_offset; in process_script_interrupt()
1156 hostdata->cmd = slot->cmnd; in process_script_interrupt()
1158 /* re-patch for this command */ in process_script_interrupt()
1159 script_patch_32_abs(hostdata, hostdata->script, in process_script_interrupt()
1160 CommandAddress, slot->pCmd); in process_script_interrupt()
1161 script_patch_16(hostdata, hostdata->script, in process_script_interrupt()
1162 CommandCount, slot->cmnd->cmd_len); in process_script_interrupt()
1163 script_patch_32_abs(hostdata, hostdata->script, in process_script_interrupt()
1165 to32bit(&slot->pSG[0].ins)); in process_script_interrupt()
1172 NCR_700_writeb(NCR_700_get_SXFER(hostdata->cmd->device), in process_script_interrupt()
1173 host, SXFER_REG); in process_script_interrupt()
1174 dma_sync_from_dev(hostdata, hostdata->msgin, in process_script_interrupt()
1176 dma_sync_to_dev(hostdata, hostdata->msgout, in process_script_interrupt()
1178 /* I'm just being paranoid here, the command should in process_script_interrupt()
1180 dma_sync_to_dev(hostdata, slot->cmnd->cmnd, in process_script_interrupt()
1181 slot->cmnd->cmd_len); in process_script_interrupt()
1195 __u8 reselection_id = NCR_700_readb(host, SFBR_REG); in process_script_interrupt()
1199 reselection_id &= ~(1<<host->this_id); in process_script_interrupt()
1204host->host_no, reselection_id, lun, dsp, dsp - hostdata->pScript, hostdata->state, hostdata->comma… in process_script_interrupt()
1208 __u32 SG = (__u32)bS_to_cpu(hostdata->script[A_SGScriptStartAddress_used[0]]); in process_script_interrupt()
1212 if(SG >= to32bit(&hostdata->slots[i].pSG[0]) in process_script_interrupt()
1213 && SG <= to32bit(&hostdata->slots[i].pSG[NCR_700_SG_SEGMENTS])) in process_script_interrupt()
1216 …eing %08x in slot %p, cmd %p, slot->resume_offset=%08x\n", SG, &hostdata->slots[i], hostdata->slot… in process_script_interrupt()
1217 SCp = hostdata->slots[i].cmnd; in process_script_interrupt()
1221 slot = (struct NCR_700_command_slot *)SCp->host_scribble; in process_script_interrupt()
1222 /* change slot from busy to queued to redo command */ in process_script_interrupt()
1223 slot->state = NCR_700_SLOT_QUEUED; in process_script_interrupt()
1225 hostdata->cmd = NULL; in process_script_interrupt()
1228 if(hostdata->reselection_id == 0xff) { in process_script_interrupt()
1229 printk(KERN_ERR "scsi%d: Invalid reselection during selection!!\n", host->host_no); in process_script_interrupt()
1233 host->host_no); in process_script_interrupt()
1234 reselection_id = hostdata->reselection_id; in process_script_interrupt()
1241 hostdata->reselection_id = reselection_id; in process_script_interrupt()
1243 hostdata->msgin[1] = 0; in process_script_interrupt()
1244 dma_sync_to_dev(hostdata, hostdata->msgin, MSG_ARRAY_SIZE); in process_script_interrupt()
1245 if(hostdata->tag_negotiated & (1<<reselection_id)) { in process_script_interrupt()
1246 resume_offset = hostdata->pScript + Ent_GetReselectionWithTag; in process_script_interrupt()
1248 resume_offset = hostdata->pScript + Ent_GetReselectionData; in process_script_interrupt()
1252 * a return here will re-run the queued command slot in process_script_interrupt()
1256 resume_offset = process_message(host, hostdata, SCp, in process_script_interrupt()
1261 host->host_no, pun, lun, NCR_700_condition[i], in process_script_interrupt()
1262 NCR_700_phase[j], dsp - hostdata->pScript); in process_script_interrupt()
1268 …08x\n", i, sg->length, ((struct NCR_700_command_slot *)SCp->host_scribble)->SG[i].ins, ((struct NC… in process_script_interrupt()
1271 NCR_700_internal_bus_reset(host); in process_script_interrupt()
1274 host->host_no, pun, lun, dsps & 0xfff, dsp, dsp - hostdata->pScript); in process_script_interrupt()
1278 host->host_no, pun, lun, dsps, dsp - hostdata->pScript); in process_script_interrupt()
1279 NCR_700_internal_bus_reset(host); in process_script_interrupt()
1292 process_selection(struct Scsi_Host *host, __u32 dsp) in process_selection() argument
1298 (struct NCR_700_Host_Parameters *)host->hostdata[0]; in process_selection()
1299 struct scsi_cmnd *SCp = hostdata->cmd; in process_selection()
1303 id = NCR_700_readb(host, hostdata->chip710 ? in process_selection()
1307 id &= ~(1<<host->this_id); in process_selection()
1312 sbcl = NCR_700_readb(host, SBCL_REG); in process_selection()
1318 hostdata->reselection_id = id = bitmap_to_number(id); in process_selection()
1320 host->host_no, id)); in process_selection()
1322 if(hostdata->state == NCR_700_HOST_BUSY && SCp != NULL) { in process_selection()
1324 (struct NCR_700_command_slot *)SCp->host_scribble; in process_selection()
1325 …G: RESELECTION OF BUSY HOST, saving cmd %p, slot %p, addr %x [%04x], resume %x!\n", id, hostdata->… in process_selection()
1327 switch(dsp - hostdata->pScript) { in process_selection()
1330 save_for_reselection(hostdata, SCp, Ent_Disconnect2 + hostdata->pScript); in process_selection()
1334 save_for_reselection(hostdata, SCp, Ent_Disconnect4 + hostdata->pScript); in process_selection()
1338 save_for_reselection(hostdata, SCp, Ent_Disconnect6 + hostdata->pScript); in process_selection()
1342 save_for_reselection(hostdata, SCp, Ent_Disconnect8 + hostdata->pScript); in process_selection()
1346 process_script_interrupt(A_GOOD_STATUS_AFTER_STATUS, dsp, SCp, host, hostdata); in process_selection()
1350 slot->state = NCR_700_SLOT_QUEUED; in process_selection()
1354 hostdata->state = NCR_700_HOST_BUSY; in process_selection()
1355 hostdata->cmd = NULL; in process_selection()
1357 hostdata->msgin[1] = 0; in process_selection()
1358 dma_sync_to_dev(hostdata, hostdata->msgin, MSG_ARRAY_SIZE); in process_selection()
1362 resume_offset = hostdata->pScript + Ent_SelectedAsTarget; in process_selection()
1363 } else if(hostdata->tag_negotiated & (1<<id)) { in process_selection()
1364 resume_offset = hostdata->pScript + Ent_GetReselectionWithTag; in process_selection()
1366 resume_offset = hostdata->pScript + Ent_GetReselectionData; in process_selection()
1372 NCR_700_clear_fifo(struct Scsi_Host *host) { in NCR_700_clear_fifo() argument
1374 = (struct NCR_700_Host_Parameters *)host->hostdata[0]; in NCR_700_clear_fifo()
1375 if(hostdata->chip710) { in NCR_700_clear_fifo()
1376 NCR_700_writeb(CLR_FIFO_710, host, CTEST8_REG); in NCR_700_clear_fifo()
1378 NCR_700_writeb(CLR_FIFO, host, DFIFO_REG); in NCR_700_clear_fifo()
1383 NCR_700_flush_fifo(struct Scsi_Host *host) { in NCR_700_flush_fifo() argument
1385 = (struct NCR_700_Host_Parameters *)host->hostdata[0]; in NCR_700_flush_fifo()
1386 if(hostdata->chip710) { in NCR_700_flush_fifo()
1387 NCR_700_writeb(FLUSH_DMA_FIFO_710, host, CTEST8_REG); in NCR_700_flush_fifo()
1389 NCR_700_writeb(0, host, CTEST8_REG); in NCR_700_flush_fifo()
1391 NCR_700_writeb(FLUSH_DMA_FIFO, host, DFIFO_REG); in NCR_700_flush_fifo()
1393 NCR_700_writeb(0, host, DFIFO_REG); in NCR_700_flush_fifo()
1404 (struct NCR_700_command_slot *)SCp->host_scribble; in NCR_700_start_command()
1406 (struct NCR_700_Host_Parameters *)SCp->device->host->hostdata[0]; in NCR_700_start_command()
1408 u8 lun = SCp->device->lun; in NCR_700_start_command()
1410 if(hostdata->state != NCR_700_HOST_FREE) { in NCR_700_start_command()
1412 * the running command finishes on another CPU while we don't in NCR_700_start_command()
1414 slot->state = NCR_700_SLOT_QUEUED; in NCR_700_start_command()
1416 DEBUG(("scsi%d: host busy, queueing command %p, slot %p\n", in NCR_700_start_command()
1417 SCp->device->host->host_no, slot->cmnd, slot)); in NCR_700_start_command()
1420 hostdata->state = NCR_700_HOST_BUSY; in NCR_700_start_command()
1421 hostdata->cmd = SCp; in NCR_700_start_command()
1422 slot->state = NCR_700_SLOT_BUSY; in NCR_700_start_command()
1423 /* keep interrupts disabled until we have the command correctly in NCR_700_start_command()
1426 hostdata->msgout[0] = NCR_700_identify((SCp->cmnd[0] != REQUEST_SENSE && in NCR_700_start_command()
1427 slot->flags != NCR_700_FLAG_AUTOSENSE), in NCR_700_start_command()
1432 if(SCp->cmnd[0] == INQUIRY || SCp->cmnd[0] == REQUEST_SENSE || in NCR_700_start_command()
1433 slot->flags == NCR_700_FLAG_AUTOSENSE) { in NCR_700_start_command()
1434 NCR_700_clear_flag(SCp->device, NCR_700_DEV_NEGOTIATED_SYNC); in NCR_700_start_command()
1441 if((hostdata->tag_negotiated & (1<<scmd_id(SCp))) in NCR_700_start_command()
1442 && (slot->tag != SCSI_NO_TAG && SCp->cmnd[0] != REQUEST_SENSE && in NCR_700_start_command()
1443 slot->flags != NCR_700_FLAG_AUTOSENSE)) { in NCR_700_start_command()
1444 count += spi_populate_tag_msg(&hostdata->msgout[count], SCp); in NCR_700_start_command()
1447 if(hostdata->fast && in NCR_700_start_command()
1448 NCR_700_is_flag_clear(SCp->device, NCR_700_DEV_NEGOTIATED_SYNC)) { in NCR_700_start_command()
1449 count += spi_populate_sync_msg(&hostdata->msgout[count], in NCR_700_start_command()
1450 spi_period(SCp->device->sdev_target), in NCR_700_start_command()
1451 spi_offset(SCp->device->sdev_target)); in NCR_700_start_command()
1452 NCR_700_set_flag(SCp->device, NCR_700_DEV_BEGIN_SYNC_NEGOTIATION); in NCR_700_start_command()
1455 script_patch_16(hostdata, hostdata->script, MessageCount, count); in NCR_700_start_command()
1457 script_patch_ID(hostdata, hostdata->script, Device_ID, 1<<scmd_id(SCp)); in NCR_700_start_command()
1459 script_patch_32_abs(hostdata, hostdata->script, CommandAddress, in NCR_700_start_command()
1460 slot->pCmd); in NCR_700_start_command()
1461 script_patch_16(hostdata, hostdata->script, CommandCount, SCp->cmd_len); in NCR_700_start_command()
1464 script_patch_32_abs(hostdata, hostdata->script, in NCR_700_start_command()
1465 SGScriptStartAddress, to32bit(&slot->pSG[0].ins)); in NCR_700_start_command()
1466 NCR_700_clear_fifo(SCp->device->host); in NCR_700_start_command()
1468 if(slot->resume_offset == 0) in NCR_700_start_command()
1469 slot->resume_offset = hostdata->pScript; in NCR_700_start_command()
1471 dma_sync_to_dev(hostdata, hostdata->msgout, count); in NCR_700_start_command()
1472 dma_sync_from_dev(hostdata, hostdata->msgin, MSG_ARRAY_SIZE); in NCR_700_start_command()
1473 dma_sync_to_dev(hostdata, SCp->cmnd, SCp->cmd_len); in NCR_700_start_command()
1474 dma_sync_from_dev(hostdata, hostdata->status, 1); in NCR_700_start_command()
1477 NCR_700_writeb(NCR_700_get_SXFER(SCp->device), in NCR_700_start_command()
1478 SCp->device->host, SXFER_REG); in NCR_700_start_command()
1479 NCR_700_writel(slot->temp, SCp->device->host, TEMP_REG); in NCR_700_start_command()
1480 NCR_700_writel(slot->resume_offset, SCp->device->host, DSP_REG); in NCR_700_start_command()
1488 struct Scsi_Host *host = (struct Scsi_Host *)dev_id; in NCR_700_intr() local
1490 (struct NCR_700_Host_Parameters *)host->hostdata[0]; in NCR_700_intr()
1497 /* Use the host lock to serialise access to the 53c700 in NCR_700_intr()
1500 * need to ensure that for this driver, the host lock and the in NCR_700_intr()
1502 spin_lock_irqsave(host->host_lock, flags); in NCR_700_intr()
1503 if((istat = NCR_700_readb(host, ISTAT_REG)) in NCR_700_intr()
1508 struct scsi_cmnd *SCp = hostdata->cmd; in NCR_700_intr()
1515 sstat0 = NCR_700_readb(host, SSTAT0_REG); in NCR_700_intr()
1521 dstat = NCR_700_readb(host, DSTAT_REG); in NCR_700_intr()
1524 dsps = NCR_700_readl(host, DSPS_REG); in NCR_700_intr()
1525 dsp = NCR_700_readl(host, DSP_REG); in NCR_700_intr()
1528 host->host_no, istat, sstat0, dstat, in NCR_700_intr()
1529 (dsp - (__u32)(hostdata->pScript))/4, in NCR_700_intr()
1533 pun = SCp->device->id; in NCR_700_intr()
1534 lun = SCp->device->lun; in NCR_700_intr()
1541 hostdata->state = NCR_700_HOST_BUSY; in NCR_700_intr()
1543 printk(KERN_ERR "scsi%d: Bus Reset detected, executing command %p, slot %p, dsp %08x[%04x]\n", in NCR_700_intr()
1544host->host_no, SCp, SCp == NULL ? NULL : SCp->host_scribble, dsp, dsp - hostdata->pScript); in NCR_700_intr()
1546 scsi_report_bus_reset(host, 0); in NCR_700_intr()
1549 __shost_for_each_device(SDp, host) in NCR_700_intr()
1556 &hostdata->slots[i]; in NCR_700_intr()
1558 if(slot->state == NCR_700_SLOT_FREE) in NCR_700_intr()
1561 SCp = slot->cmnd; in NCR_700_intr()
1562 printk(KERN_ERR " failing command because of reset, slot %p, cmnd %p\n", in NCR_700_intr()
1565 SCp->host_scribble = NULL; in NCR_700_intr()
1566 NCR_700_set_depth(SCp->device, 0); in NCR_700_intr()
1568 * rely on mid-layer guarantees that in NCR_700_intr()
1570 * command again otherwise we'll in NCR_700_intr()
1572 * hostdata->state_lock */ in NCR_700_intr()
1573 SCp->result = DID_RESET << 16; in NCR_700_intr()
1577 NCR_700_chip_setup(host); in NCR_700_intr()
1579 hostdata->state = NCR_700_HOST_FREE; in NCR_700_intr()
1580 hostdata->cmd = NULL; in NCR_700_intr()
1582 if(hostdata->eh_complete != NULL) in NCR_700_intr()
1583 complete(hostdata->eh_complete); in NCR_700_intr()
1587 host->host_no, pun, lun)); in NCR_700_intr()
1591 (struct NCR_700_command_slot *)SCp->host_scribble; in NCR_700_intr()
1593 if(dsp == Ent_SendMessage + 8 + hostdata->pScript) { in NCR_700_intr()
1597 __u32 temp = NCR_700_readl(host, TEMP_REG); in NCR_700_intr()
1598 …nt count = (hostdata->script[Ent_SendMessage/4] & 0xffffff) - ((NCR_700_readl(host, DBC_REG) & 0xf… in NCR_700_intr()
1599 … %p[%04x], phase %s\n", host->host_no, pun, lun, count, (void *)temp, temp - hostdata->pScript, sb… in NCR_700_intr()
1601 resume_offset = hostdata->pScript + Ent_SendMessagePhaseMismatch; in NCR_700_intr()
1602 } else if (slot && dsp >= to32bit(&slot->pSG[0].ins) && in NCR_700_intr()
1603 dsp <= to32bit(&slot->pSG[NCR_700_SG_SEGMENTS].ins)) { in NCR_700_intr()
1604 int data_transfer = NCR_700_readl(host, DBC_REG) & 0xffffff; in NCR_700_intr()
1605 int SGcount = (dsp - to32bit(&slot->pSG[0].ins))/sizeof(struct NCR_700_SG_List); in NCR_700_intr()
1606 int residual = NCR_700_data_residual(host); in NCR_700_intr()
1609 __u32 naddr = NCR_700_readl(host, DNAD_REG); in NCR_700_intr()
1611 printk("scsi%d: (%d:%d) Expected phase mismatch in slot->SG[%d], transferred 0x%x\n", in NCR_700_intr()
1612 host->host_no, pun, lun, in NCR_700_intr()
1616 … printk("scsi%d: (%d:%d) Expected phase mismatch in slot->SG[%d], transferred 0x%x, residual %d\n", in NCR_700_intr()
1617 host->host_no, pun, lun, in NCR_700_intr()
1627 SGcount--; in NCR_700_intr()
1629 count = (bS_to_cpu(slot->SG[SGcount].ins) & 0x00ffffff); in NCR_700_intr()
1630 DEBUG(("DATA TRANSFER MISMATCH, count = %d, transferred %d\n", count, count-data_transfer)); in NCR_700_intr()
1631 slot->SG[SGcount].ins &= bS_to_host(0xff000000); in NCR_700_intr()
1632 slot->SG[SGcount].ins |= bS_to_host(data_transfer); in NCR_700_intr()
1633 pAddr = bS_to_cpu(slot->SG[SGcount].pAddr); in NCR_700_intr()
1634 pAddr += (count - data_transfer); in NCR_700_intr()
1637 …transfer mismatch pAddr=%lx, naddr=%lx, data_transfer=%d, residual=%d\n", host->host_no, pun, lun,… in NCR_700_intr()
1640 slot->SG[SGcount].pAddr = bS_to_host(pAddr); in NCR_700_intr()
1644 slot->SG[i].ins = bS_to_host(SCRIPT_NOP); in NCR_700_intr()
1645 slot->SG[i].pAddr = 0; in NCR_700_intr()
1647 dma_sync_to_dev(hostdata, slot->SG, sizeof(slot->SG)); in NCR_700_intr()
1649 * the command phase */ in NCR_700_intr()
1650 resume_offset = hostdata->pScript + Ent_MsgInDuringData; in NCR_700_intr()
1652 NCR_700_flush_fifo(host); in NCR_700_intr()
1654 __u8 sbcl = NCR_700_readb(host, SBCL_REG); in NCR_700_intr()
1656 host->host_no, pun, lun, dsp - hostdata->pScript, sbcl_to_string(sbcl)); in NCR_700_intr()
1657 NCR_700_internal_bus_reset(host); in NCR_700_intr()
1662 host->host_no, pun, lun); in NCR_700_intr()
1666 host->host_no, pun, lun); in NCR_700_intr()
1670 host->host_no, pun, lun)); in NCR_700_intr()
1671 resume_offset = process_script_interrupt(dsps, dsp, SCp, host, hostdata); in NCR_700_intr()
1675 host->host_no, pun, lun, in NCR_700_intr()
1676 dsp, dsp - hostdata->pScript); in NCR_700_intr()
1680 host->host_no, pun, lun, dstat); in NCR_700_intr()
1692 * interrupts to complete a command that in NCR_700_intr()
1696 * command. If we guess the reselected in NCR_700_intr()
1697 * command here and prepare it, we only need in NCR_700_intr()
1700 * overhead is much greater than the command in NCR_700_intr()
1703 * only have one outstanding command on a in NCR_700_intr()
1706 resume_offset = process_selection(host, dsp); in NCR_700_intr()
1713 if(hostdata->state != NCR_700_HOST_BUSY) { in NCR_700_intr()
1714 printk(KERN_ERR "scsi%d: Driver error: resume at 0x%08x [0x%04x] with non busy host!\n", in NCR_700_intr()
1715 host->host_no, resume_offset, resume_offset - hostdata->pScript); in NCR_700_intr()
1716 hostdata->state = NCR_700_HOST_BUSY; in NCR_700_intr()
1720 NCR_700_clear_fifo(host); in NCR_700_intr()
1721 NCR_700_writel(resume_offset, host, DSP_REG); in NCR_700_intr()
1723 /* There is probably a technical no-no about this: If we're a in NCR_700_intr()
1726 * check our queued commands here---of course, there shouldn't in NCR_700_intr()
1728 if(hostdata->state == NCR_700_HOST_FREE) { in NCR_700_intr()
1734 int j = (i + hostdata->saved_slot_position) in NCR_700_intr()
1737 if(hostdata->slots[j].state != NCR_700_SLOT_QUEUED) in NCR_700_intr()
1739 if(NCR_700_start_command(hostdata->slots[j].cmnd)) { in NCR_700_intr()
1740 DEBUG(("scsi%d: Issuing saved command slot %p, cmd %p\t\n", in NCR_700_intr()
1741 host->host_no, &hostdata->slots[j], in NCR_700_intr()
1742 hostdata->slots[j].cmnd)); in NCR_700_intr()
1743 hostdata->saved_slot_position = j + 1; in NCR_700_intr()
1750 spin_unlock_irqrestore(host->host_lock, flags); in NCR_700_intr()
1757 (struct NCR_700_Host_Parameters *)SCp->device->host->hostdata[0]; in NCR_700_queuecommand_lck()
1761 if(hostdata->command_slot_count >= NCR_700_COMMAND_SLOTS_PER_HOST) { in NCR_700_queuecommand_lck()
1764 …printk(KERN_WARNING "scsi%d: Command depth has gone over queue depth\n", SCp->device->host->host_n… in NCR_700_queuecommand_lck()
1770 * - The tag negotiated bitmap is clear in NCR_700_queuecommand_lck()
1771 * - The blk layer sent and untagged command in NCR_700_queuecommand_lck()
1773 if(NCR_700_get_depth(SCp->device) != 0 in NCR_700_queuecommand_lck()
1774 && (!(hostdata->tag_negotiated & (1<<scmd_id(SCp))) in NCR_700_queuecommand_lck()
1775 || !(SCp->flags & SCMD_TAGGED))) { in NCR_700_queuecommand_lck()
1777 NCR_700_get_depth(SCp->device)); in NCR_700_queuecommand_lck()
1780 if(NCR_700_get_depth(SCp->device) >= SCp->device->queue_depth) { in NCR_700_queuecommand_lck()
1782 NCR_700_get_depth(SCp->device)); in NCR_700_queuecommand_lck()
1785 NCR_700_set_depth(SCp->device, NCR_700_get_depth(SCp->device) + 1); in NCR_700_queuecommand_lck()
1787 /* begin the command here */ in NCR_700_queuecommand_lck()
1792 slot->cmnd = SCp; in NCR_700_queuecommand_lck()
1794 SCp->host_scribble = (unsigned char *)slot; in NCR_700_queuecommand_lck()
1797 printk("53c700: scsi%d, command ", SCp->device->host->host_no); in NCR_700_queuecommand_lck()
1800 if ((SCp->flags & SCMD_TAGGED) in NCR_700_queuecommand_lck()
1801 && (hostdata->tag_negotiated &(1<<scmd_id(SCp))) == 0 in NCR_700_queuecommand_lck()
1802 && NCR_700_get_tag_neg_state(SCp->device) == NCR_700_START_TAG_NEGOTIATION) { in NCR_700_queuecommand_lck()
1803 scmd_printk(KERN_ERR, SCp, "Enabling Tag Command Queuing\n"); in NCR_700_queuecommand_lck()
1804 hostdata->tag_negotiated |= (1<<scmd_id(SCp)); in NCR_700_queuecommand_lck()
1805 NCR_700_set_tag_neg_state(SCp->device, NCR_700_DURING_TAG_NEGOTIATION); in NCR_700_queuecommand_lck()
1808 /* here we may have to process an untagged command. The gate in NCR_700_queuecommand_lck()
1814 if (!(SCp->flags & SCMD_TAGGED) in NCR_700_queuecommand_lck()
1815 && (hostdata->tag_negotiated &(1<<scmd_id(SCp)))) { in NCR_700_queuecommand_lck()
1816 scmd_printk(KERN_INFO, SCp, "Disabling Tag Command Queuing\n"); in NCR_700_queuecommand_lck()
1817 hostdata->tag_negotiated &= ~(1<<scmd_id(SCp)); in NCR_700_queuecommand_lck()
1820 if ((hostdata->tag_negotiated & (1<<scmd_id(SCp))) && in NCR_700_queuecommand_lck()
1821 SCp->device->simple_tags) { in NCR_700_queuecommand_lck()
1822 slot->tag = scsi_cmd_to_rq(SCp)->tag; in NCR_700_queuecommand_lck()
1824 slot->tag, slot); in NCR_700_queuecommand_lck()
1826 struct NCR_700_Device_Parameters *p = SCp->device->hostdata; in NCR_700_queuecommand_lck()
1828 slot->tag = SCSI_NO_TAG; in NCR_700_queuecommand_lck()
1829 /* save current command for reselection */ in NCR_700_queuecommand_lck()
1830 p->current_cmnd = SCp; in NCR_700_queuecommand_lck()
1832 /* sanity check: some of the commands generated by the mid-layer in NCR_700_queuecommand_lck()
1835 SCp->sc_data_direction != DMA_NONE) { in NCR_700_queuecommand_lck()
1837 printk("53c700: Command"); in NCR_700_queuecommand_lck()
1839 printk("Has wrong data direction %d\n", SCp->sc_data_direction); in NCR_700_queuecommand_lck()
1841 SCp->sc_data_direction = DMA_NONE; in NCR_700_queuecommand_lck()
1844 switch (SCp->cmnd[0]) { in NCR_700_queuecommand_lck()
1847 SCp->cmnd[6] = 0; in NCR_700_queuecommand_lck()
1850 /* OK, get it from the command */ in NCR_700_queuecommand_lck()
1851 switch(SCp->sc_data_direction) { in NCR_700_queuecommand_lck()
1854 printk(KERN_ERR "53c700: Unknown command for data direction "); in NCR_700_queuecommand_lck()
1886 slot->SG[i].ins = bS_to_host(move_ins | count); in NCR_700_queuecommand_lck()
1888 i, count, slot->SG[i].ins, (unsigned long)vPtr)); in NCR_700_queuecommand_lck()
1889 slot->SG[i].pAddr = bS_to_host(vPtr); in NCR_700_queuecommand_lck()
1891 slot->SG[i].ins = bS_to_host(SCRIPT_RETURN); in NCR_700_queuecommand_lck()
1892 slot->SG[i].pAddr = 0; in NCR_700_queuecommand_lck()
1893 dma_sync_to_dev(hostdata, slot->SG, sizeof(slot->SG)); in NCR_700_queuecommand_lck()
1895 (&slot->pSG[i].ins), in NCR_700_queuecommand_lck()
1896 slot->SG[i].ins)); in NCR_700_queuecommand_lck()
1898 slot->resume_offset = 0; in NCR_700_queuecommand_lck()
1899 slot->pCmd = dma_map_single(hostdata->dev, SCp->cmnd, in NCR_700_queuecommand_lck()
1912 scmd_printk(KERN_INFO, SCp, "abort command\n"); in DEF_SCSI_QCMD()
1914 slot = (struct NCR_700_command_slot *)SCp->host_scribble; in DEF_SCSI_QCMD()
1917 /* no outstanding command to abort */ in DEF_SCSI_QCMD()
1919 if(SCp->cmnd[0] == TEST_UNIT_READY) { in DEF_SCSI_QCMD()
1926 * this would leave us with an outstanding command in DEF_SCSI_QCMD()
1930 NCR_700_internal_bus_reset(SCp->device->host); in DEF_SCSI_QCMD()
1942 (struct NCR_700_Host_Parameters *)SCp->device->host->hostdata[0]; in NCR_700_host_reset()
1945 "New error handler wants HOST reset, cmd %p\n\t", SCp); in NCR_700_host_reset()
1951 spin_lock_irq(SCp->device->host->host_lock); in NCR_700_host_reset()
1952 while (hostdata->eh_complete != NULL) { in NCR_700_host_reset()
1953 spin_unlock_irq(SCp->device->host->host_lock); in NCR_700_host_reset()
1955 spin_lock_irq(SCp->device->host->host_lock); in NCR_700_host_reset()
1958 hostdata->eh_complete = &complete; in NCR_700_host_reset()
1959 NCR_700_internal_bus_reset(SCp->device->host); in NCR_700_host_reset()
1960 NCR_700_chip_reset(SCp->device->host); in NCR_700_host_reset()
1962 spin_unlock_irq(SCp->device->host->host_lock); in NCR_700_host_reset()
1964 spin_lock_irq(SCp->device->host->host_lock); in NCR_700_host_reset()
1966 hostdata->eh_complete = NULL; in NCR_700_host_reset()
1968 if(hostdata->fast) in NCR_700_host_reset()
1969 spi_schedule_dv_device(SCp->device); in NCR_700_host_reset()
1971 spin_unlock_irq(SCp->device->host->host_lock); in NCR_700_host_reset()
1978 struct Scsi_Host *SHp = dev_to_shost(STp->dev.parent); in NCR_700_set_period()
1980 (struct NCR_700_Host_Parameters *)SHp->hostdata[0]; in NCR_700_set_period()
1982 if(!hostdata->fast) in NCR_700_set_period()
1985 if(period < hostdata->min_period) in NCR_700_set_period()
1986 period = hostdata->min_period; in NCR_700_set_period()
1997 struct Scsi_Host *SHp = dev_to_shost(STp->dev.parent); in NCR_700_set_offset()
1999 (struct NCR_700_Host_Parameters *)SHp->hostdata[0]; in NCR_700_set_offset()
2000 int max_offset = hostdata->chip710 in NCR_700_set_offset()
2003 if(!hostdata->fast) in NCR_700_set_offset()
2010 if(spi_offset(STp) == 0 && (spi_period(STp) < hostdata->min_period || in NCR_700_set_offset()
2012 spi_period(STp) = hostdata->min_period; in NCR_700_set_offset()
2023 SDp->hostdata = kzalloc(sizeof(struct NCR_700_Device_Parameters), in NCR_700_sdev_init()
2026 if (!SDp->hostdata) in NCR_700_sdev_init()
2027 return -ENOMEM; in NCR_700_sdev_init()
2036 (struct NCR_700_Host_Parameters *)SDp->host->hostdata[0]; in NCR_700_sdev_configure()
2039 if(SDp->tagged_supported) { in NCR_700_sdev_configure()
2044 if(hostdata->fast) { in NCR_700_sdev_configure()
2046 if (!spi_initial_dv(SDp->sdev_target)) in NCR_700_sdev_configure()
2049 spi_offset(SDp->sdev_target) = 0; in NCR_700_sdev_configure()
2050 spi_period(SDp->sdev_target) = 0; in NCR_700_sdev_configure()
2058 kfree(SDp->hostdata); in NCR_700_sdev_destroy()
2059 SDp->hostdata = NULL; in NCR_700_sdev_destroy()
2108 return -ENODEV; in NCR_700_init()