Lines Matching +full:sr +full:- +full:idle +full:- +full:ns
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
78 * idle for too long, the system will try to sleep.
101 * NCR5380_read(register) - read from the specified register
103 * NCR5380_write(register, value) - write to the specific register
105 * NCR5380_implementation_fields - additional fields needed for this
110 * NCR5380_dma_xfer_len - determine size of DMA/PDMA transfer
111 * NCR5380_dma_send_setup - execute DMA/PDMA from memory to 5380
112 * NCR5380_dma_recv_setup - execute DMA/PDMA from 5380 to memory
113 * NCR5380_dma_residual - residual byte count
139 * initialize_SCp - init the scsi pointer field
150 ncmd->buffer = scsi_sglist(cmd); in initialize_SCp()
151 ncmd->ptr = sg_virt(ncmd->buffer); in initialize_SCp()
152 ncmd->this_residual = ncmd->buffer->length; in initialize_SCp()
154 ncmd->buffer = NULL; in initialize_SCp()
155 ncmd->ptr = NULL; in initialize_SCp()
156 ncmd->this_residual = 0; in initialize_SCp()
159 ncmd->status = 0; in initialize_SCp()
160 ncmd->message = 0; in initialize_SCp()
165 struct scatterlist *s = ncmd->buffer; in advance_sg_buffer()
167 if (!ncmd->this_residual && s && !sg_is_last(s)) { in advance_sg_buffer()
168 ncmd->buffer = sg_next(s); in advance_sg_buffer()
169 ncmd->ptr = sg_virt(ncmd->buffer); in advance_sg_buffer()
170 ncmd->this_residual = ncmd->buffer->length; in advance_sg_buffer()
177 int resid = ncmd->this_residual; in set_resid_from_SCp()
178 struct scatterlist *s = ncmd->buffer; in set_resid_from_SCp()
183 resid += s->length; in set_resid_from_SCp()
189 * NCR5380_poll_politely2 - wait for two chip register values
197 * @wait: Time-out in jiffies, 0 if sleeping is not allowed
201 * (if possible). In irq contexts the time-out is arbitrarily limited.
204 * Returns 0 if either or both event(s) occurred otherwise -ETIMEDOUT.
212 unsigned long n = hostdata->poll_loops; in NCR5380_poll_politely2()
221 } while (n--); in NCR5380_poll_politely2()
224 return -ETIMEDOUT; in NCR5380_poll_politely2()
235 return -ETIMEDOUT; in NCR5380_poll_politely2()
288 * NCR5380_print - print scsi bus signals
304 printk(KERN_DEBUG "SR = 0x%02x : ", status); in NCR5380_print()
337 * NCR5380_print_phase - show SCSI phase
362 * NCR5380_info - report driver and host information
372 return hostdata->info; in NCR5380_info()
376 * NCR5380_init - initialise an NCR5380
396 instance->max_lun = 7; in NCR5380_init()
398 hostdata->host = instance; in NCR5380_init()
399 hostdata->id_mask = 1 << instance->this_id; in NCR5380_init()
400 hostdata->id_higher_mask = 0; in NCR5380_init()
401 for (i = hostdata->id_mask; i <= 0x80; i <<= 1) in NCR5380_init()
402 if (i > hostdata->id_mask) in NCR5380_init()
403 hostdata->id_higher_mask |= i; in NCR5380_init()
405 hostdata->busy[i] = 0; in NCR5380_init()
406 hostdata->dma_len = 0; in NCR5380_init()
408 spin_lock_init(&hostdata->lock); in NCR5380_init()
409 hostdata->connected = NULL; in NCR5380_init()
410 hostdata->sensing = NULL; in NCR5380_init()
411 INIT_LIST_HEAD(&hostdata->autosense); in NCR5380_init()
412 INIT_LIST_HEAD(&hostdata->unissued); in NCR5380_init()
413 INIT_LIST_HEAD(&hostdata->disconnected); in NCR5380_init()
415 hostdata->flags = flags; in NCR5380_init()
417 INIT_WORK(&hostdata->main_task, NCR5380_main); in NCR5380_init()
418 hostdata->work_q = alloc_workqueue("ncr5380_%d", in NCR5380_init()
420 0, instance->host_no); in NCR5380_init()
421 if (!hostdata->work_q) in NCR5380_init()
422 return -ENOMEM; in NCR5380_init()
424 snprintf(hostdata->info, sizeof(hostdata->info), in NCR5380_init()
426 instance->hostt->name, instance->irq, hostdata->io_port, in NCR5380_init()
427 hostdata->base, instance->can_queue, instance->cmd_per_lun, in NCR5380_init()
428 instance->sg_tablesize, instance->this_id, in NCR5380_init()
429 hostdata->flags & FLAG_DMA_FIXUP ? "DMA_FIXUP " : "", in NCR5380_init()
430 hostdata->flags & FLAG_NO_PSEUDO_DMA ? "NO_PSEUDO_DMA " : "", in NCR5380_init()
431 hostdata->flags & FLAG_TOSHIBA_DELAY ? "TOSHIBA_DELAY " : ""); in NCR5380_init()
451 hostdata->poll_loops = NCR5380_REG_POLL_TIME * accesses_per_ms / 2; in NCR5380_init()
457 * NCR5380_maybe_reset_bus - Detect and correct bus wedge problems.
467 * Returns 0 if successful, otherwise -ENXIO.
493 * But some Toshiba CD-ROMs need ten times that. in NCR5380_maybe_reset_bus()
495 if (hostdata->flags & FLAG_TOSHIBA_DELAY) in NCR5380_maybe_reset_bus()
502 return -ENXIO; in NCR5380_maybe_reset_bus()
509 * NCR5380_exit - remove an NCR5380
519 cancel_work_sync(&hostdata->main_task); in NCR5380_exit()
520 destroy_workqueue(hostdata->work_q); in NCR5380_exit()
524 * complete_cmd - finish processing a command and return it to the SCSI ML
536 if (hostdata->sensing == cmd) { in complete_cmd()
539 scsi_eh_restore_cmnd(cmd, &hostdata->ses); in complete_cmd()
541 scsi_eh_restore_cmnd(cmd, &hostdata->ses); in complete_cmd()
544 hostdata->sensing = NULL; in complete_cmd()
551 * NCR5380_queue_command - queue a command
555 * cmd is added to the per-instance issue queue, with minor
568 switch (cmd->cmnd[0]) { in NCR5380_queue_command()
572 cmd->result = (DID_ERROR << 16); in NCR5380_queue_command()
578 cmd->result = 0; in NCR5380_queue_command()
580 spin_lock_irqsave(&hostdata->lock, flags); in NCR5380_queue_command()
583 spin_unlock_irqrestore(&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()
731 if (hostdata->connected && !hostdata->dma_len) { in NCR5380_main()
736 if (!hostdata->connected) { in NCR5380_main()
737 NCR5380_write(SELECT_ENABLE_REG, hostdata->id_mask); in NCR5380_main()
740 spin_unlock_irq(&hostdata->lock); in NCR5380_main()
747 * NCR5380_dma_complete - finish DMA transfer
757 struct NCR5380_cmd *ncmd = NCR5380_to_ncmd(hostdata->connected); in NCR5380_dma_complete()
764 if (hostdata->read_overruns) { in NCR5380_dma_complete()
765 p = ncmd->phase; in NCR5380_dma_complete()
779 if (sun3scsi_dma_finish(hostdata->connected->sc_data_direction)) { in NCR5380_dma_complete()
780 pr_err("scsi%d: overrun in UDC counter -- not prepared to deal with this!\n", in NCR5380_dma_complete()
781 instance->host_no); in NCR5380_dma_complete()
787 pr_err("scsi%d: BASR %02x\n", instance->host_no, in NCR5380_dma_complete()
789 pr_err("scsi%d: bus stuck in data phase -- probably a single byte overrun!\n", in NCR5380_dma_complete()
790 instance->host_no); in NCR5380_dma_complete()
799 transferred = hostdata->dma_len - NCR5380_dma_residual(hostdata); in NCR5380_dma_complete()
800 hostdata->dma_len = 0; in NCR5380_dma_complete()
802 data = (unsigned char **)&ncmd->ptr; in NCR5380_dma_complete()
803 count = &ncmd->this_residual; in NCR5380_dma_complete()
805 *count -= transferred; in NCR5380_dma_complete()
807 if (hostdata->read_overruns) { in NCR5380_dma_complete()
811 cnt = toPIO = hostdata->read_overruns; in NCR5380_dma_complete()
816 (*count)--; in NCR5380_dma_complete()
817 cnt--; in NCR5380_dma_complete()
818 toPIO--; in NCR5380_dma_complete()
824 *count -= toPIO - cnt; in NCR5380_dma_complete()
831 * NCR5380_intr - generic NCR5380 irq handler
842 * - End of DMA (cleared by ending DMA Mode)
843 * - Parity error (cleared by reading RPIR)
844 * - Loss of BSY (cleared by reading RPIR)
846 * - Bus phase mismatch (non-maskable in DMA Mode, cleared by ending DMA Mode)
847 * - Bus reset (non-maskable)
849 * - Selection/reselection
872 spin_lock_irqsave(&hostdata->lock, flags); in NCR5380_intr()
877 unsigned char sr = NCR5380_read(STATUS_REG); in NCR5380_intr() local
879 dsprintk(NDEBUG_INTR, instance, "IRQ %d, BASR 0x%02x, SR 0x%02x, MR 0x%02x\n", in NCR5380_intr()
880 irq, basr, sr, mr); in NCR5380_intr()
890 if (hostdata->connected) { in NCR5380_intr()
892 queue_work(hostdata->work_q, &hostdata->main_task); in NCR5380_intr()
897 } else if ((NCR5380_read(CURRENT_SCSI_DATA_REG) & hostdata->id_mask) && in NCR5380_intr()
898 (sr & (SR_SEL | SR_IO | SR_BSY | SR_RST)) == (SR_SEL | SR_IO)) { in NCR5380_intr()
905 if (!hostdata->connected) { in NCR5380_intr()
907 queue_work(hostdata->work_q, &hostdata->main_task); in NCR5380_intr()
909 if (!hostdata->connected) in NCR5380_intr()
910 NCR5380_write(SELECT_ENABLE_REG, hostdata->id_mask); in NCR5380_intr()
915 if (sr & SR_RST) { in NCR5380_intr()
924 dregs->csr |= CSR_DMA_ENABLE; in NCR5380_intr()
931 dregs->csr |= CSR_DMA_ENABLE; in NCR5380_intr()
935 spin_unlock_irqrestore(&hostdata->lock, flags); in NCR5380_intr()
941 * NCR5380_select - attempt arbitration and selection for a given command
953 * with registers as they should have been on entry - ie
958 * hostdata->connected will be set to cmd.
962 * cmd->result host byte set to DID_BAD_TARGET.
966 __releases(&hostdata->lock) __acquires(&hostdata->lock) in NCR5380_select()
974 bool can_disconnect = instance->irq != NO_IRQ && in NCR5380_select()
975 cmd->cmnd[0] != REQUEST_SENSE && in NCR5380_select()
980 instance->this_id); in NCR5380_select()
989 hostdata->selecting = cmd; in NCR5380_select()
1002 NCR5380_write(OUTPUT_DATA_REG, hostdata->id_mask); in NCR5380_select()
1005 /* The chip now waits for BUS FREE phase. Then after the 800 ns in NCR5380_select()
1009 spin_unlock_irq(&hostdata->lock); in NCR5380_select()
1013 spin_lock_irq(&hostdata->lock); in NCR5380_select()
1018 if (!hostdata->selecting) { in NCR5380_select()
1029 spin_unlock_irq(&hostdata->lock); in NCR5380_select()
1031 /* The SCSI-2 arbitration delay is 2.4 us */ in NCR5380_select()
1036 (NCR5380_read(CURRENT_SCSI_DATA_REG) & hostdata->id_higher_mask) || in NCR5380_select()
1040 spin_lock_irq(&hostdata->lock); in NCR5380_select()
1045 * IBM DPES-31080 Version S31Q works now in NCR5380_select()
1056 if (hostdata->flags & FLAG_TOSHIBA_DELAY) in NCR5380_select()
1061 spin_lock_irq(&hostdata->lock); in NCR5380_select()
1067 if (!hostdata->selecting) { in NCR5380_select()
1080 NCR5380_write(OUTPUT_DATA_REG, hostdata->id_mask | (1 << scmd_id(cmd))); in NCR5380_select()
1098 spin_unlock_irq(&hostdata->lock); in NCR5380_select()
1104 udelay(1); /* wingel -- wait two bus deskew delay >2*45ns */ in NCR5380_select()
1111 * Something weird happens when we cease to drive BSY - looks in NCR5380_select()
1117 * unnecessary jump, making it work on my 386-33/Trantor T128, the in NCR5380_select()
1118 * tighter 'C' code breaks and requires this) solves the problem - in NCR5380_select()
1140 spin_lock_irq(&hostdata->lock); in NCR5380_select()
1148 spin_lock_irq(&hostdata->lock); in NCR5380_select()
1152 if (!hostdata->selecting) in NCR5380_select()
1155 cmd->result = DID_BAD_TARGET << 16; in NCR5380_select()
1166 * change the DATA BUS. -wingel in NCR5380_select()
1183 spin_lock_irq(&hostdata->lock); in NCR5380_select()
1189 if (!hostdata->selecting) { in NCR5380_select()
1196 tmp[0] = IDENTIFY(can_disconnect, cmd->device->lun); in NCR5380_select()
1204 cmd->result = DID_ERROR << 16; in NCR5380_select()
1213 hostdata->connected = cmd; in NCR5380_select()
1214 hostdata->busy[cmd->device->id] |= 1 << cmd->device->lun; in NCR5380_select()
1217 dregs->csr |= CSR_INTR; in NCR5380_select()
1225 if (!hostdata->selecting) in NCR5380_select()
1227 hostdata->selecting = NULL; in NCR5380_select()
1237 * Inputs : instance - instance of driver, *phase - pointer to
1238 * what phase is expected, *count - pointer to number of
1239 * bytes to transfer, **data - pointer to data pointer,
1240 * can_sleep - 1 or 0 when sleeping is permitted or not, respectively.
1242 * Returns : -1 when different phase is entered without transferring
1349 } while (--c); in NCR5380_transfer_pio()
1368 return -1; in NCR5380_transfer_pio()
1372 * do_reset - issue a reset command
1399 * do_abort - abort the currently established nexus by going to
1452 rc = -ENXIO; in do_abort()
1471 * Inputs : instance - instance of driver, *phase - pointer to
1472 * what phase is expected, *count - pointer to number of
1473 * bytes to transfer, **data - pointer to data pointer.
1475 * Returns : -1 when different phase is entered without transferring
1496 return -1; in NCR5380_transfer_dma()
1499 NCR5380_to_ncmd(hostdata->connected)->phase = p; in NCR5380_transfer_dma()
1502 if (hostdata->read_overruns) in NCR5380_transfer_dma()
1503 c -= hostdata->read_overruns; in NCR5380_transfer_dma()
1504 else if (hostdata->flags & FLAG_DMA_FIXUP) in NCR5380_transfer_dma()
1505 --c; in NCR5380_transfer_dma()
1520 if (!(hostdata->flags & FLAG_LATE_DMA_SETUP)) { in NCR5380_transfer_dma()
1549 dregs->csr |= CSR_DMA_ENABLE; in NCR5380_transfer_dma()
1554 if (hostdata->flags & FLAG_LATE_DMA_SETUP) { in NCR5380_transfer_dma()
1570 hostdata->dma_len = result; in NCR5380_transfer_dma()
1575 hostdata->dma_len = c; in NCR5380_transfer_dma()
1583 * conditions. For non-scatter-gather operations, we can wait until REQ in NCR5380_transfer_dma()
1584 * and ACK both go false, or until a phase mismatch occurs. Gather-sends in NCR5380_transfer_dma()
1590 * we bail out of the wait-loop after a modest amount of wait-time if in NCR5380_transfer_dma()
1592 * correct solution :-% in NCR5380_transfer_dma()
1599 * out of DMA mode, this already-acknowledged byte is lost. This is in NCR5380_transfer_dma()
1604 * However, in order to handle scatter-receive, we must work around the in NCR5380_transfer_dma()
1611 if (hostdata->flags & FLAG_DMA_FIXUP) { in NCR5380_transfer_dma()
1615 * intended to with the pseudo-DMA read function, wait for in NCR5380_transfer_dma()
1617 * pseudo-DMA mode. in NCR5380_transfer_dma()
1630 result = -1; in NCR5380_transfer_dma()
1635 result = -1; in NCR5380_transfer_dma()
1638 d[*count - 1] = NCR5380_read(INPUT_DATA_REG); in NCR5380_transfer_dma()
1647 result = -1; in NCR5380_transfer_dma()
1662 * instance->connected.
1667 * modified if a command disconnects, *instance->connected will
1675 __releases(&hostdata->lock) __acquires(&hostdata->lock) in NCR5380_information_transfer()
1687 dregs->csr |= CSR_INTR; in NCR5380_information_transfer()
1690 while ((cmd = hostdata->connected)) { in NCR5380_information_transfer()
1711 if (cmd->sc_data_direction == DMA_TO_DEVICE) in NCR5380_information_transfer()
1713 ncmd->ptr, count); in NCR5380_information_transfer()
1716 ncmd->ptr, count); in NCR5380_information_transfer()
1720 dregs->csr |= CSR_INTR; in NCR5380_information_transfer()
1744 cmd->result = DID_ERROR << 16; in NCR5380_information_transfer()
1746 hostdata->connected = NULL; in NCR5380_information_transfer()
1747 hostdata->busy[scmd_id(cmd)] &= ~(1 << cmd->device->lun); in NCR5380_information_transfer()
1753 * scatter-gather list, move onto the next one. in NCR5380_information_transfer()
1759 ncmd->this_residual, in NCR5380_information_transfer()
1760 sg_nents(ncmd->buffer)); in NCR5380_information_transfer()
1764 * PSEUDO-DMA for systems that are strictly PIO, in NCR5380_information_transfer()
1768 * ahead of time, since the pseudo-DMA code will sit in NCR5380_information_transfer()
1773 if (!cmd->device->borken) in NCR5380_information_transfer()
1779 &len, (unsigned char **)&ncmd->ptr)) { in NCR5380_information_transfer()
1783 * polled-IO. in NCR5380_information_transfer()
1787 cmd->device->borken = 1; in NCR5380_information_transfer()
1795 transfersize = min(ncmd->this_residual, in NCR5380_information_transfer()
1799 (unsigned char **)&ncmd->ptr, in NCR5380_information_transfer()
1801 ncmd->this_residual -= transfersize - len; in NCR5380_information_transfer()
1812 ncmd->message = tmp; in NCR5380_information_transfer()
1824 cmd, scmd_id(cmd), cmd->device->lun); in NCR5380_information_transfer()
1826 hostdata->connected = NULL; in NCR5380_information_transfer()
1827 hostdata->busy[scmd_id(cmd)] &= ~(1 << cmd->device->lun); in NCR5380_information_transfer()
1829 set_status_byte(cmd, ncmd->status); in NCR5380_information_transfer()
1833 if (cmd->cmnd[0] == REQUEST_SENSE) in NCR5380_information_transfer()
1836 if (ncmd->status == SAM_STAT_CHECK_CONDITION || in NCR5380_information_transfer()
1837 ncmd->status == SAM_STAT_COMMAND_TERMINATED) { in NCR5380_information_transfer()
1840 list_add_tail(&ncmd->list, in NCR5380_information_transfer()
1841 &hostdata->autosense); in NCR5380_information_transfer()
1856 switch (hostdata->last_message) { in NCR5380_information_transfer()
1860 cmd->device->simple_tags = 0; in NCR5380_information_transfer()
1861 hostdata->busy[cmd->device->id] |= (1 << (cmd->device->lun & 0xFF)); in NCR5380_information_transfer()
1870 hostdata->connected = NULL; in NCR5380_information_transfer()
1871 list_add(&ncmd->list, &hostdata->disconnected); in NCR5380_information_transfer()
1874 cmd, scmd_id(cmd), cmd->device->lun); in NCR5380_information_transfer()
1883 dregs->csr |= CSR_DMA_ENABLE; in NCR5380_information_transfer()
1910 spin_unlock_irq(&hostdata->lock); in NCR5380_information_transfer()
1923 extended_msg[1] <= sizeof(extended_msg) - 2) { in NCR5380_information_transfer()
1926 len = extended_msg[1] - 1; in NCR5380_information_transfer()
1948 spin_lock_irq(&hostdata->lock); in NCR5380_information_transfer()
1949 if (!hostdata->connected) in NCR5380_information_transfer()
1976 hostdata->last_message = msgout; in NCR5380_information_transfer()
1979 hostdata->connected = NULL; in NCR5380_information_transfer()
1980 hostdata->busy[scmd_id(cmd)] &= ~(1 << cmd->device->lun); in NCR5380_information_transfer()
1981 cmd->result = DID_ERROR << 16; in NCR5380_information_transfer()
1988 len = cmd->cmd_len; in NCR5380_information_transfer()
1989 data = cmd->cmnd; in NCR5380_information_transfer()
1992 * PSEUDO-DMA architecture we should probably in NCR5380_information_transfer()
2001 ncmd->status = tmp; in NCR5380_information_transfer()
2008 spin_unlock_irq(&hostdata->lock); in NCR5380_information_transfer()
2010 spin_lock_irq(&hostdata->lock); in NCR5380_information_transfer()
2018 * Purpose : does reselection, initializing the instance->connected
2022 * Inputs : instance - this instance of the NCR5380.
2041 target_mask = NCR5380_read(CURRENT_SCSI_DATA_REG) & ~(hostdata->id_mask); in NCR5380_reselect()
2042 if (!target_mask || target_mask & (target_mask - 1)) { in NCR5380_reselect()
2051 * (400 ns). in NCR5380_reselect()
2111 * We need to add code for SCSI-II to track which devices have in NCR5380_reselect()
2122 list_for_each_entry(ncmd, &hostdata->disconnected, list) { in NCR5380_reselect()
2126 lun == (u8)cmd->device->lun) { in NCR5380_reselect()
2127 list_del(&ncmd->list); in NCR5380_reselect()
2137 int target = ffs(target_mask) - 1; in NCR5380_reselect()
2146 hostdata->busy[target] &= ~(1 << lun); in NCR5380_reselect()
2159 if (tmp->sc_data_direction == DMA_TO_DEVICE) in NCR5380_reselect()
2161 ncmd->ptr, count); in NCR5380_reselect()
2164 ncmd->ptr, count); in NCR5380_reselect()
2175 hostdata->connected = tmp; in NCR5380_reselect()
2177 scmd_id(tmp), tmp->device->lun); in NCR5380_reselect()
2181 * list_find_cmd - test for presence of a command in a linked list
2198 * list_remove_cmd - remove a command from linked list
2209 list_del(&ncmd->list); in list_del_cmd()
2216 * NCR5380_abort - scsi host eh_abort_handler() method
2221 * to abort the command. Nonetheless, the low-level driver must forget about
2222 * the command because the mid-layer reclaims it and it may be re-issued.
2227 * unissued -> selecting -> [unissued -> selecting ->]... connected ->
2228 * [disconnected -> connected ->]...
2229 * [autosense -> connected ->] done
2236 * lacks sense data). The mid-layer may re-issue a command that is in error
2241 * to serialize their own execution and prevent their own re-entry.
2246 struct Scsi_Host *instance = cmd->device->host; in NCR5380_abort()
2251 spin_lock_irqsave(&hostdata->lock, flags); in NCR5380_abort()
2259 if (list_del_cmd(&hostdata->unissued, cmd)) { in NCR5380_abort()
2262 cmd->result = DID_ABORT << 16; in NCR5380_abort()
2267 if (hostdata->selecting == cmd) { in NCR5380_abort()
2270 hostdata->selecting = NULL; in NCR5380_abort()
2271 cmd->result = DID_ABORT << 16; in NCR5380_abort()
2276 if (list_del_cmd(&hostdata->disconnected, cmd)) { in NCR5380_abort()
2288 if (hostdata->connected == cmd) { in NCR5380_abort()
2290 hostdata->connected = NULL; in NCR5380_abort()
2291 hostdata->dma_len = 0; in NCR5380_abort()
2303 if (list_del_cmd(&hostdata->autosense, cmd)) { in NCR5380_abort()
2313 hostdata->busy[scmd_id(cmd)] &= ~(1 << cmd->device->lun); in NCR5380_abort()
2317 queue_work(hostdata->work_q, &hostdata->main_task); in NCR5380_abort()
2318 spin_unlock_irqrestore(&hostdata->lock, flags); in NCR5380_abort()
2336 * and no busy units; so clear the low-level status here to avoid in bus_reset_cleanup()
2337 * conflicts when the mid-level code tries to wake up the affected in bus_reset_cleanup()
2341 if (hostdata->selecting) { in bus_reset_cleanup()
2342 hostdata->selecting->result = DID_RESET << 16; in bus_reset_cleanup()
2343 complete_cmd(instance, hostdata->selecting); in bus_reset_cleanup()
2344 hostdata->selecting = NULL; in bus_reset_cleanup()
2347 list_for_each_entry(ncmd, &hostdata->disconnected, list) { in bus_reset_cleanup()
2353 INIT_LIST_HEAD(&hostdata->disconnected); in bus_reset_cleanup()
2355 list_for_each_entry(ncmd, &hostdata->autosense, list) { in bus_reset_cleanup()
2360 INIT_LIST_HEAD(&hostdata->autosense); in bus_reset_cleanup()
2362 if (hostdata->connected) { in bus_reset_cleanup()
2363 set_host_byte(hostdata->connected, DID_RESET); in bus_reset_cleanup()
2364 complete_cmd(instance, hostdata->connected); in bus_reset_cleanup()
2365 hostdata->connected = NULL; in bus_reset_cleanup()
2369 hostdata->busy[i] = 0; in bus_reset_cleanup()
2370 hostdata->dma_len = 0; in bus_reset_cleanup()
2372 queue_work(hostdata->work_q, &hostdata->main_task); in bus_reset_cleanup()
2376 * NCR5380_host_reset - reset the SCSI host
2384 struct Scsi_Host *instance = cmd->device->host; in NCR5380_host_reset()
2389 spin_lock_irqsave(&hostdata->lock, flags); in NCR5380_host_reset()
2397 list_for_each_entry(ncmd, &hostdata->unissued, list) { in NCR5380_host_reset()
2400 scmd->result = DID_RESET << 16; in NCR5380_host_reset()
2403 INIT_LIST_HEAD(&hostdata->unissued); in NCR5380_host_reset()
2408 spin_unlock_irqrestore(&hostdata->lock, flags); in NCR5380_host_reset()