• Home
  • Raw
  • Download

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
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()
541 if (status_byte(cmd->result) != GOOD) { 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()
586 spin_lock_irqsave(&hostdata->lock, flags); in NCR5380_queue_command()
595 if (cmd->cmnd[0] == REQUEST_SENSE) in NCR5380_queue_command()
596 list_add(&ncmd->list, &hostdata->unissued); in NCR5380_queue_command()
598 list_add_tail(&ncmd->list, &hostdata->unissued); in NCR5380_queue_command()
600 spin_unlock_irqrestore(&hostdata->lock, flags); in NCR5380_queue_command()
603 cmd, (cmd->cmnd[0] == REQUEST_SENSE) ? "head" : "tail"); in NCR5380_queue_command()
606 queue_work(hostdata->work_q, &hostdata->main_task); in NCR5380_queue_command()
615 if (list_empty(&hostdata->disconnected) && in maybe_release_dma_irq()
616 list_empty(&hostdata->unissued) && in maybe_release_dma_irq()
617 list_empty(&hostdata->autosense) && in maybe_release_dma_irq()
618 !hostdata->connected && in maybe_release_dma_irq()
619 !hostdata->selecting) { in maybe_release_dma_irq()
625 * dequeue_next_cmd - dequeue a command for processing
641 if (hostdata->sensing || list_empty(&hostdata->autosense)) { in dequeue_next_cmd()
642 list_for_each_entry(ncmd, &hostdata->unissued, list) { in dequeue_next_cmd()
645 cmd, scmd_id(cmd), hostdata->busy[scmd_id(cmd)], cmd->device->lun); in dequeue_next_cmd()
647 if (!(hostdata->busy[scmd_id(cmd)] & (1 << cmd->device->lun))) { in dequeue_next_cmd()
648 list_del(&ncmd->list); in dequeue_next_cmd()
656 ncmd = list_first_entry(&hostdata->autosense, in dequeue_next_cmd()
658 list_del(&ncmd->list); in dequeue_next_cmd()
662 scsi_eh_prep_cmnd(cmd, &hostdata->ses, NULL, 0, ~0); in dequeue_next_cmd()
663 hostdata->sensing = cmd; in dequeue_next_cmd()
674 if (hostdata->sensing == cmd) { in requeue_cmd()
675 scsi_eh_restore_cmnd(cmd, &hostdata->ses); in requeue_cmd()
676 list_add(&ncmd->list, &hostdata->autosense); in requeue_cmd()
677 hostdata->sensing = NULL; in requeue_cmd()
679 list_add(&ncmd->list, &hostdata->unissued); in requeue_cmd()
683 * NCR5380_main - NCR state machines
695 struct Scsi_Host *instance = hostdata->host; in NCR5380_main()
701 spin_lock_irq(&hostdata->lock); in NCR5380_main()
702 while (!hostdata->connected && !hostdata->selecting) { in NCR5380_main()
712 * On success, instance->hostdata->connected is set. in NCR5380_main()
718 * queueing, even on SCSI-II devices because the in NCR5380_main()
732 if (hostdata->connected && !hostdata->dma_len) { in NCR5380_main()
737 if (!hostdata->connected) in NCR5380_main()
738 NCR5380_write(SELECT_ENABLE_REG, hostdata->id_mask); in NCR5380_main()
739 spin_unlock_irq(&hostdata->lock); in NCR5380_main()
746 * NCR5380_dma_complete - finish DMA transfer
762 if (hostdata->read_overruns) { in NCR5380_dma_complete()
763 p = hostdata->connected->SCp.phase; in NCR5380_dma_complete()
777 if ((sun3scsi_dma_finish(rq_data_dir(hostdata->connected->request)))) { in NCR5380_dma_complete()
778 pr_err("scsi%d: overrun in UDC counter -- not prepared to deal with this!\n", in NCR5380_dma_complete()
779 instance->host_no); in NCR5380_dma_complete()
785 pr_err("scsi%d: BASR %02x\n", instance->host_no, in NCR5380_dma_complete()
787 pr_err("scsi%d: bus stuck in data phase -- probably a single byte overrun!\n", in NCR5380_dma_complete()
788 instance->host_no); in NCR5380_dma_complete()
797 transferred = hostdata->dma_len - NCR5380_dma_residual(hostdata); in NCR5380_dma_complete()
798 hostdata->dma_len = 0; in NCR5380_dma_complete()
800 data = (unsigned char **)&hostdata->connected->SCp.ptr; in NCR5380_dma_complete()
801 count = &hostdata->connected->SCp.this_residual; in NCR5380_dma_complete()
803 *count -= transferred; in NCR5380_dma_complete()
805 if (hostdata->read_overruns) { in NCR5380_dma_complete()
809 cnt = toPIO = hostdata->read_overruns; in NCR5380_dma_complete()
814 (*count)--; in NCR5380_dma_complete()
815 cnt--; in NCR5380_dma_complete()
816 toPIO--; in NCR5380_dma_complete()
822 *count -= toPIO - cnt; in NCR5380_dma_complete()
829 * NCR5380_intr - generic NCR5380 irq handler
837 * The chip can assert IRQ in any of six different conditions. The IRQ flag
838 * is then cleared by reading the Reset Parity/Interrupt Register (RPIR).
840 * - End of DMA (cleared by ending DMA Mode)
841 * - Parity error (cleared by reading RPIR)
842 * - Loss of BSY (cleared by reading RPIR)
844 * - Bus phase mismatch (non-maskable in DMA Mode, cleared by ending DMA Mode)
845 * - Bus reset (non-maskable)
847 * - Selection/reselection
855 * Checking for bus reset by reading RST is futile because of interrupt
856 * latency, but a bus reset will reset chip logic. Checking for parity error
870 spin_lock_irqsave(&hostdata->lock, flags); in NCR5380_intr()
888 if (hostdata->connected) { in NCR5380_intr()
890 queue_work(hostdata->work_q, &hostdata->main_task); in NCR5380_intr()
895 } else if ((NCR5380_read(CURRENT_SCSI_DATA_REG) & hostdata->id_mask) && in NCR5380_intr()
903 if (!hostdata->connected) { in NCR5380_intr()
905 queue_work(hostdata->work_q, &hostdata->main_task); in NCR5380_intr()
907 if (!hostdata->connected) in NCR5380_intr()
908 NCR5380_write(SELECT_ENABLE_REG, hostdata->id_mask); in NCR5380_intr()
910 /* Probably Bus Reset */ in NCR5380_intr()
914 /* Certainly Bus Reset */ in NCR5380_intr()
916 "bus reset interrupt\n"); in NCR5380_intr()
922 dregs->csr |= CSR_DMA_ENABLE; in NCR5380_intr()
929 dregs->csr |= CSR_DMA_ENABLE; in NCR5380_intr()
933 spin_unlock_irqrestore(&hostdata->lock, flags); in NCR5380_intr()
939 * NCR5380_select - attempt arbitration and selection for a given command
951 * with registers as they should have been on entry - ie
956 * hostdata->connected will be set to cmd.
959 * If failed (no target) : cmd->scsi_done() will be called, and the
960 * cmd->result host byte set to DID_BAD_TARGET.
964 __releases(&hostdata->lock) __acquires(&hostdata->lock) in NCR5380_select()
972 bool can_disconnect = instance->irq != NO_IRQ && in NCR5380_select()
973 cmd->cmnd[0] != REQUEST_SENSE && in NCR5380_select()
978 instance->this_id); in NCR5380_select()
987 hostdata->selecting = cmd; in NCR5380_select()
1000 NCR5380_write(OUTPUT_DATA_REG, hostdata->id_mask); in NCR5380_select()
1007 spin_unlock_irq(&hostdata->lock); in NCR5380_select()
1011 spin_lock_irq(&hostdata->lock); in NCR5380_select()
1016 if (!hostdata->selecting) { in NCR5380_select()
1027 spin_unlock_irq(&hostdata->lock); in NCR5380_select()
1029 /* The SCSI-2 arbitration delay is 2.4 us */ in NCR5380_select()
1034 (NCR5380_read(CURRENT_SCSI_DATA_REG) & hostdata->id_higher_mask) || in NCR5380_select()
1038 spin_lock_irq(&hostdata->lock); in NCR5380_select()
1043 * IBM DPES-31080 Version S31Q works now in NCR5380_select()
1054 if (hostdata->flags & FLAG_TOSHIBA_DELAY) in NCR5380_select()
1059 spin_lock_irq(&hostdata->lock); in NCR5380_select()
1065 if (!hostdata->selecting) { in NCR5380_select()
1078 NCR5380_write(OUTPUT_DATA_REG, hostdata->id_mask | (1 << scmd_id(cmd))); in NCR5380_select()
1096 spin_unlock_irq(&hostdata->lock); in NCR5380_select()
1102 udelay(1); /* wingel -- wait two bus deskew delay >2*45ns */ in NCR5380_select()
1104 /* Reset BSY */ in NCR5380_select()
1109 * Something weird happens when we cease to drive BSY - looks in NCR5380_select()
1115 * unnecessary jump, making it work on my 386-33/Trantor T128, the in NCR5380_select()
1116 * tighter 'C' code breaks and requires this) solves the problem - in NCR5380_select()
1130 * The SCSI specification calls for a 250 ms timeout for the actual in NCR5380_select()
1138 spin_lock_irq(&hostdata->lock); in NCR5380_select()
1146 spin_lock_irq(&hostdata->lock); in NCR5380_select()
1150 if (!hostdata->selecting) in NCR5380_select()
1153 cmd->result = DID_BAD_TARGET << 16; in NCR5380_select()
1156 "target did not respond within 250ms\n"); in NCR5380_select()
1164 * change the DATA BUS. -wingel in NCR5380_select()
1181 spin_lock_irq(&hostdata->lock); in NCR5380_select()
1187 if (!hostdata->selecting) { in NCR5380_select()
1194 tmp[0] = IDENTIFY(can_disconnect, cmd->device->lun); in NCR5380_select()
1202 cmd->result = DID_ERROR << 16; in NCR5380_select()
1211 hostdata->connected = cmd; in NCR5380_select()
1212 hostdata->busy[cmd->device->id] |= 1 << cmd->device->lun; in NCR5380_select()
1215 dregs->csr |= CSR_INTR; in NCR5380_select()
1223 if (!hostdata->selecting) in NCR5380_select()
1225 hostdata->selecting = NULL; in NCR5380_select()
1235 * Inputs : instance - instance of driver, *phase - pointer to
1236 * what phase is expected, *count - pointer to number of
1237 * bytes to transfer, **data - pointer to data pointer.
1239 * Returns : -1 when different phase is entered without transferring
1345 } while (--c); in NCR5380_transfer_pio()
1364 return -1; in NCR5380_transfer_pio()
1368 * do_reset - issue a reset command
1369 * @instance: adapter to reset
1371 * Issue a reset sequence to the NCR5380 and try and get the bus
1374 * This clears the reset interrupt flag because there may be no handler for
1395 * do_abort - abort the currently established nexus by going to
1445 rc = -ENXIO; in do_abort()
1464 * Inputs : instance - instance of driver, *phase - pointer to
1465 * what phase is expected, *count - pointer to number of
1466 * bytes to transfer, **data - pointer to data pointer.
1468 * Returns : -1 when different phase is entered without transferring
1489 return -1; in NCR5380_transfer_dma()
1492 hostdata->connected->SCp.phase = p; in NCR5380_transfer_dma()
1495 if (hostdata->read_overruns) in NCR5380_transfer_dma()
1496 c -= hostdata->read_overruns; in NCR5380_transfer_dma()
1497 else if (hostdata->flags & FLAG_DMA_FIXUP) in NCR5380_transfer_dma()
1498 --c; in NCR5380_transfer_dma()
1513 if (!(hostdata->flags & FLAG_LATE_DMA_SETUP)) { in NCR5380_transfer_dma()
1542 dregs->csr |= CSR_DMA_ENABLE; in NCR5380_transfer_dma()
1547 if (hostdata->flags & FLAG_LATE_DMA_SETUP) { in NCR5380_transfer_dma()
1563 hostdata->dma_len = result; in NCR5380_transfer_dma()
1568 hostdata->dma_len = c; in NCR5380_transfer_dma()
1576 * conditions. For non-scatter-gather operations, we can wait until REQ in NCR5380_transfer_dma()
1577 * and ACK both go false, or until a phase mismatch occurs. Gather-sends in NCR5380_transfer_dma()
1583 * we bail out of the wait-loop after a modest amount of wait-time if in NCR5380_transfer_dma()
1585 * correct solution :-% in NCR5380_transfer_dma()
1592 * out of DMA mode, this already-acknowledged byte is lost. This is in NCR5380_transfer_dma()
1597 * However, in order to handle scatter-receive, we must work around the in NCR5380_transfer_dma()
1604 if (hostdata->flags & FLAG_DMA_FIXUP) { in NCR5380_transfer_dma()
1608 * intended to with the pseudo-DMA read function, wait for in NCR5380_transfer_dma()
1610 * pseudo-DMA mode. in NCR5380_transfer_dma()
1623 result = -1; in NCR5380_transfer_dma()
1628 result = -1; in NCR5380_transfer_dma()
1631 d[*count - 1] = NCR5380_read(INPUT_DATA_REG); in NCR5380_transfer_dma()
1640 result = -1; in NCR5380_transfer_dma()
1655 * instance->connected.
1660 * modified if a command disconnects, *instance->connected will
1663 * XXX Note : we need to watch for bus free or a reset condition here
1668 __releases(&hostdata->lock) __acquires(&hostdata->lock) in NCR5380_information_transfer()
1680 dregs->csr |= CSR_INTR; in NCR5380_information_transfer()
1683 while ((cmd = hostdata->connected)) { in NCR5380_information_transfer()
1704 if (rq_data_dir(cmd->request)) in NCR5380_information_transfer()
1706 cmd->SCp.ptr, count); in NCR5380_information_transfer()
1709 cmd->SCp.ptr, count); in NCR5380_information_transfer()
1713 dregs->csr |= CSR_INTR; in NCR5380_information_transfer()
1737 cmd->result = DID_ERROR << 16; in NCR5380_information_transfer()
1739 hostdata->connected = NULL; in NCR5380_information_transfer()
1740 hostdata->busy[scmd_id(cmd)] &= ~(1 << cmd->device->lun); in NCR5380_information_transfer()
1746 * scatter-gather list, move onto the next one. in NCR5380_information_transfer()
1752 cmd->SCp.this_residual, in NCR5380_information_transfer()
1753 sg_nents(cmd->SCp.buffer)); in NCR5380_information_transfer()
1757 * PSEUDO-DMA for systems that are strictly PIO, in NCR5380_information_transfer()
1761 * ahead of time, since the pseudo-DMA code will sit in NCR5380_information_transfer()
1766 if (!cmd->device->borken) in NCR5380_information_transfer()
1772 &len, (unsigned char **)&cmd->SCp.ptr)) { in NCR5380_information_transfer()
1776 * polled-IO. in NCR5380_information_transfer()
1780 cmd->device->borken = 1; in NCR5380_information_transfer()
1788 transfersize = min(cmd->SCp.this_residual, in NCR5380_information_transfer()
1792 (unsigned char **)&cmd->SCp.ptr); in NCR5380_information_transfer()
1793 cmd->SCp.this_residual -= transfersize - len; in NCR5380_information_transfer()
1804 cmd->SCp.Message = tmp; in NCR5380_information_transfer()
1814 cmd, scmd_id(cmd), cmd->device->lun); in NCR5380_information_transfer()
1816 hostdata->connected = NULL; in NCR5380_information_transfer()
1817 hostdata->busy[scmd_id(cmd)] &= ~(1 << cmd->device->lun); in NCR5380_information_transfer()
1819 cmd->result &= ~0xffff; in NCR5380_information_transfer()
1820 cmd->result |= cmd->SCp.Status; in NCR5380_information_transfer()
1821 cmd->result |= cmd->SCp.Message << 8; in NCR5380_information_transfer()
1825 if (cmd->cmnd[0] == REQUEST_SENSE) in NCR5380_information_transfer()
1828 if (cmd->SCp.Status == SAM_STAT_CHECK_CONDITION || in NCR5380_information_transfer()
1829 cmd->SCp.Status == SAM_STAT_COMMAND_TERMINATED) { in NCR5380_information_transfer()
1832 list_add_tail(&ncmd->list, in NCR5380_information_transfer()
1833 &hostdata->autosense); in NCR5380_information_transfer()
1849 switch (hostdata->last_message) { in NCR5380_information_transfer()
1853 cmd->device->simple_tags = 0; in NCR5380_information_transfer()
1854 hostdata->busy[cmd->device->id] |= (1 << (cmd->device->lun & 0xFF)); in NCR5380_information_transfer()
1863 hostdata->connected = NULL; in NCR5380_information_transfer()
1864 list_add(&ncmd->list, &hostdata->disconnected); in NCR5380_information_transfer()
1867 cmd, scmd_id(cmd), cmd->device->lun); in NCR5380_information_transfer()
1876 dregs->csr |= CSR_DMA_ENABLE; in NCR5380_information_transfer()
1903 spin_unlock_irq(&hostdata->lock); in NCR5380_information_transfer()
1916 extended_msg[1] <= sizeof(extended_msg) - 2) { in NCR5380_information_transfer()
1919 len = extended_msg[1] - 1; in NCR5380_information_transfer()
1941 spin_lock_irq(&hostdata->lock); in NCR5380_information_transfer()
1942 if (!hostdata->connected) in NCR5380_information_transfer()
1969 hostdata->last_message = msgout; in NCR5380_information_transfer()
1972 hostdata->connected = NULL; in NCR5380_information_transfer()
1973 hostdata->busy[scmd_id(cmd)] &= ~(1 << cmd->device->lun); in NCR5380_information_transfer()
1974 cmd->result = DID_ERROR << 16; in NCR5380_information_transfer()
1982 len = cmd->cmd_len; in NCR5380_information_transfer()
1983 data = cmd->cmnd; in NCR5380_information_transfer()
1986 * PSEUDO-DMA architecture we should probably in NCR5380_information_transfer()
1995 cmd->SCp.Status = tmp; in NCR5380_information_transfer()
2002 spin_unlock_irq(&hostdata->lock); in NCR5380_information_transfer()
2004 spin_lock_irq(&hostdata->lock); in NCR5380_information_transfer()
2012 * Purpose : does reselection, initializing the instance->connected
2016 * Inputs : instance - this instance of the NCR5380.
2035 target_mask = NCR5380_read(CURRENT_SCSI_DATA_REG) & ~(hostdata->id_mask); in NCR5380_reselect()
2036 if (!target_mask || target_mask & (target_mask - 1)) { in NCR5380_reselect()
2047 * We must assert BSY ourselves, until the target drops the SEL in NCR5380_reselect()
2105 * We need to add code for SCSI-II to track which devices have in NCR5380_reselect()
2116 list_for_each_entry(ncmd, &hostdata->disconnected, list) { in NCR5380_reselect()
2120 lun == (u8)cmd->device->lun) { in NCR5380_reselect()
2121 list_del(&ncmd->list); in NCR5380_reselect()
2131 int target = ffs(target_mask) - 1; in NCR5380_reselect()
2140 hostdata->busy[target] &= ~(1 << lun); in NCR5380_reselect()
2153 if (rq_data_dir(tmp->request)) in NCR5380_reselect()
2155 tmp->SCp.ptr, count); in NCR5380_reselect()
2158 tmp->SCp.ptr, count); in NCR5380_reselect()
2169 hostdata->connected = tmp; in NCR5380_reselect()
2171 scmd_id(tmp), tmp->device->lun); in NCR5380_reselect()
2175 * list_find_cmd - test for presence of a command in a linked list
2192 * list_remove_cmd - remove a command from linked list
2203 list_del(&ncmd->list); in list_del_cmd()
2210 * NCR5380_abort - scsi host eh_abort_handler() method
2215 * to abort the command. Nonetheless, the low-level driver must forget about
2216 * the command because the mid-layer reclaims it and it may be re-issued.
2221 * unissued -> selecting -> [unissued -> selecting ->]... connected ->
2222 * [disconnected -> connected ->]...
2223 * [autosense -> connected ->] done
2230 * lacks sense data). The mid-layer may re-issue a command that is in error
2235 * to serialize their own execution and prevent their own re-entry.
2240 struct Scsi_Host *instance = cmd->device->host; in NCR5380_abort()
2245 spin_lock_irqsave(&hostdata->lock, flags); in NCR5380_abort()
2253 if (list_del_cmd(&hostdata->unissued, cmd)) { in NCR5380_abort()
2256 cmd->result = DID_ABORT << 16; in NCR5380_abort()
2257 cmd->scsi_done(cmd); /* No tag or busy flag to worry about */ in NCR5380_abort()
2261 if (hostdata->selecting == cmd) { in NCR5380_abort()
2264 hostdata->selecting = NULL; in NCR5380_abort()
2265 cmd->result = DID_ABORT << 16; in NCR5380_abort()
2270 if (list_del_cmd(&hostdata->disconnected, cmd)) { in NCR5380_abort()
2274 * means releasing the lock. Need a bus reset. in NCR5380_abort()
2282 if (hostdata->connected == cmd) { in NCR5380_abort()
2284 hostdata->connected = NULL; in NCR5380_abort()
2285 hostdata->dma_len = 0; in NCR5380_abort()
2297 if (list_del_cmd(&hostdata->autosense, cmd)) { in NCR5380_abort()
2307 hostdata->busy[scmd_id(cmd)] &= ~(1 << cmd->device->lun); in NCR5380_abort()
2311 queue_work(hostdata->work_q, &hostdata->main_task); in NCR5380_abort()
2313 spin_unlock_irqrestore(&hostdata->lock, flags); in NCR5380_abort()
2325 /* reset NCR registers */ in bus_reset_cleanup()
2330 /* After the reset, there are no more connected or disconnected commands in bus_reset_cleanup()
2331 * and no busy units; so clear the low-level status here to avoid in bus_reset_cleanup()
2332 * conflicts when the mid-level code tries to wake up the affected in bus_reset_cleanup()
2336 if (hostdata->selecting) { in bus_reset_cleanup()
2337 hostdata->selecting->result = DID_RESET << 16; in bus_reset_cleanup()
2338 complete_cmd(instance, hostdata->selecting); in bus_reset_cleanup()
2339 hostdata->selecting = NULL; in bus_reset_cleanup()
2342 list_for_each_entry(ncmd, &hostdata->disconnected, list) { in bus_reset_cleanup()
2348 INIT_LIST_HEAD(&hostdata->disconnected); in bus_reset_cleanup()
2350 list_for_each_entry(ncmd, &hostdata->autosense, list) { in bus_reset_cleanup()
2353 cmd->scsi_done(cmd); in bus_reset_cleanup()
2355 INIT_LIST_HEAD(&hostdata->autosense); in bus_reset_cleanup()
2357 if (hostdata->connected) { in bus_reset_cleanup()
2358 set_host_byte(hostdata->connected, DID_RESET); in bus_reset_cleanup()
2359 complete_cmd(instance, hostdata->connected); in bus_reset_cleanup()
2360 hostdata->connected = NULL; in bus_reset_cleanup()
2364 hostdata->busy[i] = 0; in bus_reset_cleanup()
2365 hostdata->dma_len = 0; in bus_reset_cleanup()
2367 queue_work(hostdata->work_q, &hostdata->main_task); in bus_reset_cleanup()
2372 * NCR5380_host_reset - reset the SCSI host
2380 struct Scsi_Host *instance = cmd->device->host; in NCR5380_host_reset()
2385 spin_lock_irqsave(&hostdata->lock, flags); in NCR5380_host_reset()
2393 list_for_each_entry(ncmd, &hostdata->unissued, list) { in NCR5380_host_reset()
2396 scmd->result = DID_RESET << 16; in NCR5380_host_reset()
2397 scmd->scsi_done(scmd); in NCR5380_host_reset()
2399 INIT_LIST_HEAD(&hostdata->unissued); in NCR5380_host_reset()
2404 spin_unlock_irqrestore(&hostdata->lock, flags); in NCR5380_host_reset()