Lines Matching +full:reset +full:- +full:assert +full:- +full:ms

1 // SPDX-License-Identifier: GPL-2.0
4 * to implement 5380 SCSI drivers under Linux with a non-trantor
13 * +1 (303) 666-5836
24 * 1+ (719) 578-3400
25 * 1+ (800) 334-5454
42 * transfer - some PC's will use the I/O bus, 68K's must use
46 * each 5380 in the system - commands that haven't been issued yet,
51 * allowing multiple commands to propagate all the way to a SCSI-II device
57 * When used in a PIO or pseudo-dma mode, the NCR5380 is a braindead
102 * NCR5380_read(register) - read from the specified register
104 * NCR5380_write(register, value) - write to the specific register
106 * NCR5380_implementation_fields - additional fields needed for this
111 * NCR5380_dma_xfer_len - determine size of DMA/PDMA transfer
112 * NCR5380_dma_send_setup - execute DMA/PDMA from memory to 5380
113 * NCR5380_dma_recv_setup - execute DMA/PDMA from 5380 to memory
114 * NCR5380_dma_residual - residual byte count
140 * initialize_SCp - init the scsi pointer field
154 cmd->SCp.buffer = scsi_sglist(cmd); in initialize_SCp()
155 cmd->SCp.ptr = sg_virt(cmd->SCp.buffer); in initialize_SCp()
156 cmd->SCp.this_residual = cmd->SCp.buffer->length; in initialize_SCp()
158 cmd->SCp.buffer = NULL; in initialize_SCp()
159 cmd->SCp.ptr = NULL; in initialize_SCp()
160 cmd->SCp.this_residual = 0; in initialize_SCp()
163 cmd->SCp.Status = 0; in initialize_SCp()
164 cmd->SCp.Message = 0; in initialize_SCp()
169 struct scatterlist *s = cmd->SCp.buffer; in advance_sg_buffer()
171 if (!cmd->SCp.this_residual && s && !sg_is_last(s)) { in advance_sg_buffer()
172 cmd->SCp.buffer = sg_next(s); in advance_sg_buffer()
173 cmd->SCp.ptr = sg_virt(cmd->SCp.buffer); in advance_sg_buffer()
174 cmd->SCp.this_residual = cmd->SCp.buffer->length; in advance_sg_buffer()
180 int resid = cmd->SCp.this_residual; in set_resid_from_SCp()
181 struct scatterlist *s = cmd->SCp.buffer; in set_resid_from_SCp()
186 resid += s->length; in set_resid_from_SCp()
192 * NCR5380_poll_politely2 - wait for two chip register values
200 * @wait: Time-out in jiffies, 0 if sleeping is not allowed
204 * (if possible). In irq contexts the time-out is arbitrarily limited.
207 * Returns 0 if either or both event(s) occurred otherwise -ETIMEDOUT.
215 unsigned long n = hostdata->poll_loops; in NCR5380_poll_politely2()
224 } while (n--); in NCR5380_poll_politely2()
227 return -ETIMEDOUT; in NCR5380_poll_politely2()
229 /* Repeatedly sleep for 1 ms until deadline */ in NCR5380_poll_politely2()
238 return -ETIMEDOUT; in NCR5380_poll_politely2()
268 {ICR_ASSERT_RST, "ASSERT RST"},
271 {ICR_ASSERT_ACK, "ASSERT ACK"},
272 {ICR_ASSERT_BSY, "ASSERT BSY"},
273 {ICR_ASSERT_SEL, "ASSERT SEL"},
274 {ICR_ASSERT_ATN, "ASSERT ATN"},
275 {ICR_ASSERT_DATA, "ASSERT DATA"},
291 * NCR5380_print - print scsi bus signals
340 * NCR5380_print_phase - show SCSI phase
365 * NCR5380_info - report driver and host information
375 return hostdata->info; in NCR5380_info()
379 * NCR5380_init - initialise an NCR5380
399 instance->max_lun = 7; in NCR5380_init()
401 hostdata->host = instance; in NCR5380_init()
402 hostdata->id_mask = 1 << instance->this_id; in NCR5380_init()
403 hostdata->id_higher_mask = 0; in NCR5380_init()
404 for (i = hostdata->id_mask; i <= 0x80; i <<= 1) in NCR5380_init()
405 if (i > hostdata->id_mask) in NCR5380_init()
406 hostdata->id_higher_mask |= i; in NCR5380_init()
408 hostdata->busy[i] = 0; in NCR5380_init()
409 hostdata->dma_len = 0; in NCR5380_init()
411 spin_lock_init(&hostdata->lock); in NCR5380_init()
412 hostdata->connected = NULL; in NCR5380_init()
413 hostdata->sensing = NULL; in NCR5380_init()
414 INIT_LIST_HEAD(&hostdata->autosense); in NCR5380_init()
415 INIT_LIST_HEAD(&hostdata->unissued); in NCR5380_init()
416 INIT_LIST_HEAD(&hostdata->disconnected); in NCR5380_init()
418 hostdata->flags = flags; in NCR5380_init()
420 INIT_WORK(&hostdata->main_task, NCR5380_main); in NCR5380_init()
421 hostdata->work_q = alloc_workqueue("ncr5380_%d", in NCR5380_init()
423 1, instance->host_no); in NCR5380_init()
424 if (!hostdata->work_q) in NCR5380_init()
425 return -ENOMEM; in NCR5380_init()
427 snprintf(hostdata->info, sizeof(hostdata->info), in NCR5380_init()
429 instance->hostt->name, instance->irq, hostdata->io_port, in NCR5380_init()
430 hostdata->base, instance->can_queue, instance->cmd_per_lun, in NCR5380_init()
431 instance->sg_tablesize, instance->this_id, in NCR5380_init()
432 hostdata->flags & FLAG_DMA_FIXUP ? "DMA_FIXUP " : "", in NCR5380_init()
433 hostdata->flags & FLAG_NO_PSEUDO_DMA ? "NO_PSEUDO_DMA " : "", in NCR5380_init()
434 hostdata->flags & FLAG_TOSHIBA_DELAY ? "TOSHIBA_DELAY " : ""); in NCR5380_init()
454 hostdata->poll_loops = NCR5380_REG_POLL_TIME * accesses_per_ms / 2; in NCR5380_init()
460 * NCR5380_maybe_reset_bus - Detect and correct bus wedge problems.
466 * do a bus reset.
468 * Note that a bus reset will cause the chip to assert IRQ.
470 * Returns 0 if successful, otherwise -ENXIO.
492 shost_printk(KERN_ERR, instance, "bus busy, attempting reset\n"); in NCR5380_maybe_reset_bus()
494 /* Wait after a reset; the SCSI standard calls for in NCR5380_maybe_reset_bus()
495 * 250ms, we wait 500ms to be on the safe side. in NCR5380_maybe_reset_bus()
496 * But some Toshiba CD-ROMs need ten times that. in NCR5380_maybe_reset_bus()
498 if (hostdata->flags & FLAG_TOSHIBA_DELAY) in NCR5380_maybe_reset_bus()
505 return -ENXIO; in NCR5380_maybe_reset_bus()
512 * NCR5380_exit - remove an NCR5380
522 cancel_work_sync(&hostdata->main_task); in NCR5380_exit()
523 destroy_workqueue(hostdata->work_q); in NCR5380_exit()
527 * complete_cmd - finish processing a command and return it to the SCSI ML
539 if (hostdata->sensing == cmd) { in complete_cmd()
542 scsi_eh_restore_cmnd(cmd, &hostdata->ses); in complete_cmd()
544 scsi_eh_restore_cmnd(cmd, &hostdata->ses); in complete_cmd()
547 hostdata->sensing = NULL; in complete_cmd()
550 cmd->scsi_done(cmd); in complete_cmd()
554 * NCR5380_queue_command - queue a command
558 * cmd is added to the per-instance issue queue, with minor
571 switch (cmd->cmnd[0]) { in NCR5380_queue_command()
575 cmd->result = (DID_ERROR << 16); in NCR5380_queue_command()
576 cmd->scsi_done(cmd); in NCR5380_queue_command()
581 cmd->result = 0; in NCR5380_queue_command()
583 spin_lock_irqsave(&hostdata->lock, flags); in NCR5380_queue_command()
586 spin_unlock_irqrestore(&hostdata->lock, flags); in NCR5380_queue_command()
598 if (cmd->cmnd[0] == REQUEST_SENSE) in NCR5380_queue_command()
599 list_add(&ncmd->list, &hostdata->unissued); in NCR5380_queue_command()
601 list_add_tail(&ncmd->list, &hostdata->unissued); in NCR5380_queue_command()
603 spin_unlock_irqrestore(&hostdata->lock, flags); in NCR5380_queue_command()
606 cmd, (cmd->cmnd[0] == REQUEST_SENSE) ? "head" : "tail"); in NCR5380_queue_command()
609 queue_work(hostdata->work_q, &hostdata->main_task); in NCR5380_queue_command()
618 if (list_empty(&hostdata->disconnected) && in maybe_release_dma_irq()
619 list_empty(&hostdata->unissued) && in maybe_release_dma_irq()
620 list_empty(&hostdata->autosense) && in maybe_release_dma_irq()
621 !hostdata->connected && in maybe_release_dma_irq()
622 !hostdata->selecting) { in maybe_release_dma_irq()
628 * dequeue_next_cmd - dequeue a command for processing
644 if (hostdata->sensing || list_empty(&hostdata->autosense)) { in dequeue_next_cmd()
645 list_for_each_entry(ncmd, &hostdata->unissued, list) { in dequeue_next_cmd()
648 cmd, scmd_id(cmd), hostdata->busy[scmd_id(cmd)], cmd->device->lun); in dequeue_next_cmd()
650 if (!(hostdata->busy[scmd_id(cmd)] & (1 << cmd->device->lun))) { in dequeue_next_cmd()
651 list_del(&ncmd->list); in dequeue_next_cmd()
659 ncmd = list_first_entry(&hostdata->autosense, in dequeue_next_cmd()
661 list_del(&ncmd->list); in dequeue_next_cmd()
665 scsi_eh_prep_cmnd(cmd, &hostdata->ses, NULL, 0, ~0); in dequeue_next_cmd()
666 hostdata->sensing = cmd; in dequeue_next_cmd()
677 if (hostdata->sensing == cmd) { in requeue_cmd()
678 scsi_eh_restore_cmnd(cmd, &hostdata->ses); in requeue_cmd()
679 list_add(&ncmd->list, &hostdata->autosense); in requeue_cmd()
680 hostdata->sensing = NULL; in requeue_cmd()
682 list_add(&ncmd->list, &hostdata->unissued); in requeue_cmd()
686 * NCR5380_main - NCR state machines
698 struct Scsi_Host *instance = hostdata->host; in NCR5380_main()
704 spin_lock_irq(&hostdata->lock); in NCR5380_main()
705 while (!hostdata->connected && !hostdata->selecting) { in NCR5380_main()
715 * On success, instance->hostdata->connected is set. in NCR5380_main()
721 * queueing, even on SCSI-II devices because the in NCR5380_main()
734 if (hostdata->connected && !hostdata->dma_len) { in NCR5380_main()
739 if (!hostdata->connected) { in NCR5380_main()
740 NCR5380_write(SELECT_ENABLE_REG, hostdata->id_mask); in NCR5380_main()
743 spin_unlock_irq(&hostdata->lock); in NCR5380_main()
750 * NCR5380_dma_complete - finish DMA transfer
766 if (hostdata->read_overruns) { in NCR5380_dma_complete()
767 p = hostdata->connected->SCp.phase; in NCR5380_dma_complete()
781 if (sun3scsi_dma_finish(hostdata->connected->sc_data_direction)) { in NCR5380_dma_complete()
782 pr_err("scsi%d: overrun in UDC counter -- not prepared to deal with this!\n", in NCR5380_dma_complete()
783 instance->host_no); in NCR5380_dma_complete()
789 pr_err("scsi%d: BASR %02x\n", instance->host_no, in NCR5380_dma_complete()
791 pr_err("scsi%d: bus stuck in data phase -- probably a single byte overrun!\n", in NCR5380_dma_complete()
792 instance->host_no); in NCR5380_dma_complete()
801 transferred = hostdata->dma_len - NCR5380_dma_residual(hostdata); in NCR5380_dma_complete()
802 hostdata->dma_len = 0; in NCR5380_dma_complete()
804 data = (unsigned char **)&hostdata->connected->SCp.ptr; in NCR5380_dma_complete()
805 count = &hostdata->connected->SCp.this_residual; in NCR5380_dma_complete()
807 *count -= transferred; in NCR5380_dma_complete()
809 if (hostdata->read_overruns) { in NCR5380_dma_complete()
813 cnt = toPIO = hostdata->read_overruns; in NCR5380_dma_complete()
818 (*count)--; in NCR5380_dma_complete()
819 cnt--; in NCR5380_dma_complete()
820 toPIO--; in NCR5380_dma_complete()
826 *count -= toPIO - cnt; in NCR5380_dma_complete()
833 * NCR5380_intr - generic NCR5380 irq handler
841 * The chip can assert IRQ in any of six different conditions. The IRQ flag
842 * is then cleared by reading the Reset Parity/Interrupt Register (RPIR).
844 * - End of DMA (cleared by ending DMA Mode)
845 * - Parity error (cleared by reading RPIR)
846 * - Loss of BSY (cleared by reading RPIR)
848 * - Bus phase mismatch (non-maskable in DMA Mode, cleared by ending DMA Mode)
849 * - Bus reset (non-maskable)
851 * - Selection/reselection
859 * Checking for bus reset by reading RST is futile because of interrupt
860 * latency, but a bus reset will reset chip logic. Checking for parity error
874 spin_lock_irqsave(&hostdata->lock, flags); in NCR5380_intr()
892 if (hostdata->connected) { in NCR5380_intr()
894 queue_work(hostdata->work_q, &hostdata->main_task); in NCR5380_intr()
899 } else if ((NCR5380_read(CURRENT_SCSI_DATA_REG) & hostdata->id_mask) && in NCR5380_intr()
907 if (!hostdata->connected) { in NCR5380_intr()
909 queue_work(hostdata->work_q, &hostdata->main_task); in NCR5380_intr()
911 if (!hostdata->connected) in NCR5380_intr()
912 NCR5380_write(SELECT_ENABLE_REG, hostdata->id_mask); in NCR5380_intr()
914 /* Probably Bus Reset */ in NCR5380_intr()
918 /* Certainly Bus Reset */ in NCR5380_intr()
920 "bus reset interrupt\n"); in NCR5380_intr()
926 dregs->csr |= CSR_DMA_ENABLE; in NCR5380_intr()
933 dregs->csr |= CSR_DMA_ENABLE; in NCR5380_intr()
937 spin_unlock_irqrestore(&hostdata->lock, flags); in NCR5380_intr()
943 * NCR5380_select - attempt arbitration and selection for a given command
955 * with registers as they should have been on entry - ie
960 * hostdata->connected will be set to cmd.
963 * If failed (no target) : cmd->scsi_done() will be called, and the
964 * cmd->result host byte set to DID_BAD_TARGET.
968 __releases(&hostdata->lock) __acquires(&hostdata->lock) in NCR5380_select()
976 bool can_disconnect = instance->irq != NO_IRQ && in NCR5380_select()
977 cmd->cmnd[0] != REQUEST_SENSE && in NCR5380_select()
982 instance->this_id); in NCR5380_select()
991 hostdata->selecting = cmd; in NCR5380_select()
1004 NCR5380_write(OUTPUT_DATA_REG, hostdata->id_mask); in NCR5380_select()
1011 spin_unlock_irq(&hostdata->lock); in NCR5380_select()
1015 spin_lock_irq(&hostdata->lock); in NCR5380_select()
1020 if (!hostdata->selecting) { in NCR5380_select()
1031 spin_unlock_irq(&hostdata->lock); in NCR5380_select()
1033 /* The SCSI-2 arbitration delay is 2.4 us */ in NCR5380_select()
1038 (NCR5380_read(CURRENT_SCSI_DATA_REG) & hostdata->id_higher_mask) || in NCR5380_select()
1042 spin_lock_irq(&hostdata->lock); in NCR5380_select()
1047 * IBM DPES-31080 Version S31Q works now in NCR5380_select()
1058 if (hostdata->flags & FLAG_TOSHIBA_DELAY) in NCR5380_select()
1063 spin_lock_irq(&hostdata->lock); in NCR5380_select()
1069 if (!hostdata->selecting) { in NCR5380_select()
1082 NCR5380_write(OUTPUT_DATA_REG, hostdata->id_mask | (1 << scmd_id(cmd))); in NCR5380_select()
1100 spin_unlock_irq(&hostdata->lock); in NCR5380_select()
1106 udelay(1); /* wingel -- wait two bus deskew delay >2*45ns */ in NCR5380_select()
1108 /* Reset BSY */ in NCR5380_select()
1113 * Something weird happens when we cease to drive BSY - looks in NCR5380_select()
1119 * unnecessary jump, making it work on my 386-33/Trantor T128, the in NCR5380_select()
1120 * tighter 'C' code breaks and requires this) solves the problem - in NCR5380_select()
1134 * The SCSI specification calls for a 250 ms timeout for the actual in NCR5380_select()
1142 spin_lock_irq(&hostdata->lock); in NCR5380_select()
1150 spin_lock_irq(&hostdata->lock); in NCR5380_select()
1154 if (!hostdata->selecting) in NCR5380_select()
1157 cmd->result = DID_BAD_TARGET << 16; in NCR5380_select()
1160 "target did not respond within 250ms\n"); in NCR5380_select()
1168 * change the DATA BUS. -wingel in NCR5380_select()
1185 spin_lock_irq(&hostdata->lock); in NCR5380_select()
1191 if (!hostdata->selecting) { in NCR5380_select()
1198 tmp[0] = IDENTIFY(can_disconnect, cmd->device->lun); in NCR5380_select()
1206 cmd->result = DID_ERROR << 16; in NCR5380_select()
1215 hostdata->connected = cmd; in NCR5380_select()
1216 hostdata->busy[cmd->device->id] |= 1 << cmd->device->lun; in NCR5380_select()
1219 dregs->csr |= CSR_INTR; in NCR5380_select()
1227 if (!hostdata->selecting) in NCR5380_select()
1229 hostdata->selecting = NULL; in NCR5380_select()
1239 * Inputs : instance - instance of driver, *phase - pointer to
1240 * what phase is expected, *count - pointer to number of
1241 * bytes to transfer, **data - pointer to data pointer,
1242 * can_sleep - 1 or 0 when sleeping is permitted or not, respectively.
1244 * Returns : -1 when different phase is entered without transferring
1351 } while (--c); in NCR5380_transfer_pio()
1370 return -1; in NCR5380_transfer_pio()
1374 * do_reset - issue a reset command
1375 * @instance: adapter to reset
1377 * Issue a reset sequence to the NCR5380 and try and get the bus
1380 * This clears the reset interrupt flag because there may be no handler for
1401 * do_abort - abort the currently established nexus by going to
1454 rc = -ENXIO; in do_abort()
1473 * Inputs : instance - instance of driver, *phase - pointer to
1474 * what phase is expected, *count - pointer to number of
1475 * bytes to transfer, **data - pointer to data pointer.
1477 * Returns : -1 when different phase is entered without transferring
1498 return -1; in NCR5380_transfer_dma()
1501 hostdata->connected->SCp.phase = p; in NCR5380_transfer_dma()
1504 if (hostdata->read_overruns) in NCR5380_transfer_dma()
1505 c -= hostdata->read_overruns; in NCR5380_transfer_dma()
1506 else if (hostdata->flags & FLAG_DMA_FIXUP) in NCR5380_transfer_dma()
1507 --c; in NCR5380_transfer_dma()
1522 if (!(hostdata->flags & FLAG_LATE_DMA_SETUP)) { in NCR5380_transfer_dma()
1551 dregs->csr |= CSR_DMA_ENABLE; in NCR5380_transfer_dma()
1556 if (hostdata->flags & FLAG_LATE_DMA_SETUP) { in NCR5380_transfer_dma()
1572 hostdata->dma_len = result; in NCR5380_transfer_dma()
1577 hostdata->dma_len = c; in NCR5380_transfer_dma()
1585 * conditions. For non-scatter-gather operations, we can wait until REQ in NCR5380_transfer_dma()
1586 * and ACK both go false, or until a phase mismatch occurs. Gather-sends in NCR5380_transfer_dma()
1592 * we bail out of the wait-loop after a modest amount of wait-time if in NCR5380_transfer_dma()
1594 * correct solution :-% in NCR5380_transfer_dma()
1601 * out of DMA mode, this already-acknowledged byte is lost. This is in NCR5380_transfer_dma()
1606 * However, in order to handle scatter-receive, we must work around the in NCR5380_transfer_dma()
1613 if (hostdata->flags & FLAG_DMA_FIXUP) { in NCR5380_transfer_dma()
1617 * intended to with the pseudo-DMA read function, wait for in NCR5380_transfer_dma()
1619 * pseudo-DMA mode. in NCR5380_transfer_dma()
1632 result = -1; in NCR5380_transfer_dma()
1637 result = -1; in NCR5380_transfer_dma()
1640 d[*count - 1] = NCR5380_read(INPUT_DATA_REG); in NCR5380_transfer_dma()
1649 result = -1; in NCR5380_transfer_dma()
1664 * instance->connected.
1669 * modified if a command disconnects, *instance->connected will
1672 * XXX Note : we need to watch for bus free or a reset condition here
1677 __releases(&hostdata->lock) __acquires(&hostdata->lock) in NCR5380_information_transfer()
1689 dregs->csr |= CSR_INTR; in NCR5380_information_transfer()
1692 while ((cmd = hostdata->connected)) { in NCR5380_information_transfer()
1713 if (cmd->sc_data_direction == DMA_TO_DEVICE) in NCR5380_information_transfer()
1715 cmd->SCp.ptr, count); in NCR5380_information_transfer()
1718 cmd->SCp.ptr, count); in NCR5380_information_transfer()
1722 dregs->csr |= CSR_INTR; in NCR5380_information_transfer()
1746 cmd->result = DID_ERROR << 16; in NCR5380_information_transfer()
1748 hostdata->connected = NULL; in NCR5380_information_transfer()
1749 hostdata->busy[scmd_id(cmd)] &= ~(1 << cmd->device->lun); in NCR5380_information_transfer()
1755 * scatter-gather list, move onto the next one. in NCR5380_information_transfer()
1761 cmd->SCp.this_residual, in NCR5380_information_transfer()
1762 sg_nents(cmd->SCp.buffer)); in NCR5380_information_transfer()
1766 * PSEUDO-DMA for systems that are strictly PIO, in NCR5380_information_transfer()
1770 * ahead of time, since the pseudo-DMA code will sit in NCR5380_information_transfer()
1775 if (!cmd->device->borken) in NCR5380_information_transfer()
1781 &len, (unsigned char **)&cmd->SCp.ptr)) { in NCR5380_information_transfer()
1785 * polled-IO. in NCR5380_information_transfer()
1789 cmd->device->borken = 1; in NCR5380_information_transfer()
1797 transfersize = min(cmd->SCp.this_residual, in NCR5380_information_transfer()
1801 (unsigned char **)&cmd->SCp.ptr, in NCR5380_information_transfer()
1803 cmd->SCp.this_residual -= transfersize - len; in NCR5380_information_transfer()
1814 cmd->SCp.Message = tmp; in NCR5380_information_transfer()
1826 cmd, scmd_id(cmd), cmd->device->lun); in NCR5380_information_transfer()
1828 hostdata->connected = NULL; in NCR5380_information_transfer()
1829 hostdata->busy[scmd_id(cmd)] &= ~(1 << cmd->device->lun); in NCR5380_information_transfer()
1831 set_status_byte(cmd, cmd->SCp.Status); in NCR5380_information_transfer()
1835 if (cmd->cmnd[0] == REQUEST_SENSE) in NCR5380_information_transfer()
1838 if (cmd->SCp.Status == SAM_STAT_CHECK_CONDITION || in NCR5380_information_transfer()
1839 cmd->SCp.Status == SAM_STAT_COMMAND_TERMINATED) { in NCR5380_information_transfer()
1842 list_add_tail(&ncmd->list, in NCR5380_information_transfer()
1843 &hostdata->autosense); in NCR5380_information_transfer()
1858 switch (hostdata->last_message) { in NCR5380_information_transfer()
1862 cmd->device->simple_tags = 0; in NCR5380_information_transfer()
1863 hostdata->busy[cmd->device->id] |= (1 << (cmd->device->lun & 0xFF)); in NCR5380_information_transfer()
1872 hostdata->connected = NULL; in NCR5380_information_transfer()
1873 list_add(&ncmd->list, &hostdata->disconnected); in NCR5380_information_transfer()
1876 cmd, scmd_id(cmd), cmd->device->lun); in NCR5380_information_transfer()
1885 dregs->csr |= CSR_DMA_ENABLE; in NCR5380_information_transfer()
1912 spin_unlock_irq(&hostdata->lock); in NCR5380_information_transfer()
1925 extended_msg[1] <= sizeof(extended_msg) - 2) { in NCR5380_information_transfer()
1928 len = extended_msg[1] - 1; in NCR5380_information_transfer()
1950 spin_lock_irq(&hostdata->lock); in NCR5380_information_transfer()
1951 if (!hostdata->connected) in NCR5380_information_transfer()
1978 hostdata->last_message = msgout; in NCR5380_information_transfer()
1981 hostdata->connected = NULL; in NCR5380_information_transfer()
1982 hostdata->busy[scmd_id(cmd)] &= ~(1 << cmd->device->lun); in NCR5380_information_transfer()
1983 cmd->result = DID_ERROR << 16; in NCR5380_information_transfer()
1990 len = cmd->cmd_len; in NCR5380_information_transfer()
1991 data = cmd->cmnd; in NCR5380_information_transfer()
1994 * PSEUDO-DMA architecture we should probably in NCR5380_information_transfer()
2003 cmd->SCp.Status = tmp; in NCR5380_information_transfer()
2010 spin_unlock_irq(&hostdata->lock); in NCR5380_information_transfer()
2012 spin_lock_irq(&hostdata->lock); in NCR5380_information_transfer()
2020 * Purpose : does reselection, initializing the instance->connected
2024 * Inputs : instance - this instance of the NCR5380.
2043 target_mask = NCR5380_read(CURRENT_SCSI_DATA_REG) & ~(hostdata->id_mask); in NCR5380_reselect()
2044 if (!target_mask || target_mask & (target_mask - 1)) { in NCR5380_reselect()
2055 * We must assert BSY ourselves, until the target drops the SEL in NCR5380_reselect()
2113 * We need to add code for SCSI-II to track which devices have in NCR5380_reselect()
2124 list_for_each_entry(ncmd, &hostdata->disconnected, list) { in NCR5380_reselect()
2128 lun == (u8)cmd->device->lun) { in NCR5380_reselect()
2129 list_del(&ncmd->list); in NCR5380_reselect()
2139 int target = ffs(target_mask) - 1; in NCR5380_reselect()
2148 hostdata->busy[target] &= ~(1 << lun); in NCR5380_reselect()
2161 if (tmp->sc_data_direction == DMA_TO_DEVICE) in NCR5380_reselect()
2163 tmp->SCp.ptr, count); in NCR5380_reselect()
2166 tmp->SCp.ptr, count); in NCR5380_reselect()
2177 hostdata->connected = tmp; in NCR5380_reselect()
2179 scmd_id(tmp), tmp->device->lun); in NCR5380_reselect()
2183 * list_find_cmd - test for presence of a command in a linked list
2200 * list_remove_cmd - remove a command from linked list
2211 list_del(&ncmd->list); in list_del_cmd()
2218 * NCR5380_abort - scsi host eh_abort_handler() method
2223 * to abort the command. Nonetheless, the low-level driver must forget about
2224 * the command because the mid-layer reclaims it and it may be re-issued.
2229 * unissued -> selecting -> [unissued -> selecting ->]... connected ->
2230 * [disconnected -> connected ->]...
2231 * [autosense -> connected ->] done
2238 * lacks sense data). The mid-layer may re-issue a command that is in error
2243 * to serialize their own execution and prevent their own re-entry.
2248 struct Scsi_Host *instance = cmd->device->host; in NCR5380_abort()
2253 spin_lock_irqsave(&hostdata->lock, flags); in NCR5380_abort()
2261 if (list_del_cmd(&hostdata->unissued, cmd)) { in NCR5380_abort()
2264 cmd->result = DID_ABORT << 16; in NCR5380_abort()
2265 cmd->scsi_done(cmd); /* No tag or busy flag to worry about */ in NCR5380_abort()
2269 if (hostdata->selecting == cmd) { in NCR5380_abort()
2272 hostdata->selecting = NULL; in NCR5380_abort()
2273 cmd->result = DID_ABORT << 16; in NCR5380_abort()
2278 if (list_del_cmd(&hostdata->disconnected, cmd)) { in NCR5380_abort()
2282 * means releasing the lock. Need a bus reset. in NCR5380_abort()
2290 if (hostdata->connected == cmd) { in NCR5380_abort()
2292 hostdata->connected = NULL; in NCR5380_abort()
2293 hostdata->dma_len = 0; in NCR5380_abort()
2305 if (list_del_cmd(&hostdata->autosense, cmd)) { in NCR5380_abort()
2315 hostdata->busy[scmd_id(cmd)] &= ~(1 << cmd->device->lun); in NCR5380_abort()
2319 queue_work(hostdata->work_q, &hostdata->main_task); in NCR5380_abort()
2320 spin_unlock_irqrestore(&hostdata->lock, flags); in NCR5380_abort()
2332 /* reset NCR registers */ in bus_reset_cleanup()
2337 /* After the reset, there are no more connected or disconnected commands in bus_reset_cleanup()
2338 * and no busy units; so clear the low-level status here to avoid in bus_reset_cleanup()
2339 * conflicts when the mid-level code tries to wake up the affected in bus_reset_cleanup()
2343 if (hostdata->selecting) { in bus_reset_cleanup()
2344 hostdata->selecting->result = DID_RESET << 16; in bus_reset_cleanup()
2345 complete_cmd(instance, hostdata->selecting); in bus_reset_cleanup()
2346 hostdata->selecting = NULL; in bus_reset_cleanup()
2349 list_for_each_entry(ncmd, &hostdata->disconnected, list) { in bus_reset_cleanup()
2355 INIT_LIST_HEAD(&hostdata->disconnected); in bus_reset_cleanup()
2357 list_for_each_entry(ncmd, &hostdata->autosense, list) { in bus_reset_cleanup()
2360 cmd->scsi_done(cmd); in bus_reset_cleanup()
2362 INIT_LIST_HEAD(&hostdata->autosense); in bus_reset_cleanup()
2364 if (hostdata->connected) { in bus_reset_cleanup()
2365 set_host_byte(hostdata->connected, DID_RESET); in bus_reset_cleanup()
2366 complete_cmd(instance, hostdata->connected); in bus_reset_cleanup()
2367 hostdata->connected = NULL; in bus_reset_cleanup()
2371 hostdata->busy[i] = 0; in bus_reset_cleanup()
2372 hostdata->dma_len = 0; in bus_reset_cleanup()
2374 queue_work(hostdata->work_q, &hostdata->main_task); in bus_reset_cleanup()
2378 * NCR5380_host_reset - reset the SCSI host
2386 struct Scsi_Host *instance = cmd->device->host; in NCR5380_host_reset()
2391 spin_lock_irqsave(&hostdata->lock, flags); in NCR5380_host_reset()
2399 list_for_each_entry(ncmd, &hostdata->unissued, list) { in NCR5380_host_reset()
2402 scmd->result = DID_RESET << 16; in NCR5380_host_reset()
2403 scmd->scsi_done(scmd); in NCR5380_host_reset()
2405 INIT_LIST_HEAD(&hostdata->unissued); in NCR5380_host_reset()
2410 spin_unlock_irqrestore(&hostdata->lock, flags); in NCR5380_host_reset()