Lines Matching +full:dma +full:- +full:byte +full:- +full:en

1 // SPDX-License-Identifier: GPL-2.0-only
5 * Copyright (C) 1997-2003 Russell King
20 * 30-08-1997 RMK Created
21 * 14-09-1997 RMK Started disconnect support
22 * 08-02-1998 RMK Corrected real DMA support
23 * 15-02-1998 RMK Started sync xfer support
24 * 06-04-1998 RMK Tightened conditions for printing incomplete
26 * 02-05-1998 RMK Added extra checks in fas216_reset
27 * 24-05-1998 RMK Fixed synchronous transfers with period >= 200ns
28 * 27-06-1998 RMK Changed asm/delay.h to linux/delay.h
29 * 26-08-1998 RMK Improved message support wrt MESSAGE_REJECT
30 * 02-04-2000 RMK Converted to use the new error handling, and
45 #include <asm/dma.h>
60 /* NOTE: SCSI2 Synchronous transfers *require* DMA according to
68 * > (1) Re-negotiation at every selection is not recommended, since a
79 * transfers, you must always use DMA.
112 level_mask |= -1; in fas216_log_setup()
146 unsigned int off = reg << info->scsi.io_shift; in fas216_readb()
147 return readb(info->scsi.io_base + off); in fas216_readb()
152 unsigned int off = reg << info->scsi.io_shift; in fas216_writeb()
153 writeb(val, info->scsi.io_base + off); in fas216_writeb()
180 prefix, SCp->ptr, SCp->this_residual, SCp->buffer, in print_SCp()
181 SCp->buffers_residual, suffix); in print_SCp()
195 info->magic_start, info->host, info->SCpnt, in fas216_dumpinfo()
196 info->origSCpnt); in fas216_dumpinfo()
198 info->scsi.io_shift, info->scsi.irq, in fas216_dumpinfo()
199 info->scsi.cfg[0], info->scsi.cfg[1], info->scsi.cfg[2], in fas216_dumpinfo()
200 info->scsi.cfg[3]); in fas216_dumpinfo()
202 info->scsi.type, info->scsi.phase); in fas216_dumpinfo()
203 print_SCp(&info->scsi.SCp, " SCp={ ", " }\n"); in fas216_dumpinfo()
205 info->scsi.async_stp, in fas216_dumpinfo()
206 info->scsi.disconnectable, info->scsi.aborting); in fas216_dumpinfo()
209 info->stats.queues, info->stats.removes, info->stats.fins, in fas216_dumpinfo()
210 info->stats.reads, info->stats.writes, info->stats.miscs, in fas216_dumpinfo()
211 info->stats.disconnects, info->stats.aborts, info->stats.bus_resets, in fas216_dumpinfo()
212 info->stats.host_resets); in fas216_dumpinfo()
214 info->ifcfg.clockrate, info->ifcfg.select_timeout, in fas216_dumpinfo()
215 info->ifcfg.asyncperiod, info->ifcfg.sync_max_depth); in fas216_dumpinfo()
218 i, info->busyluns[i], i, in fas216_dumpinfo()
219 info->device[i].disconnect_ok, info->device[i].stp, in fas216_dumpinfo()
220 info->device[i].sof, info->device[i].sync_state); in fas216_dumpinfo()
222 printk(" dma={ transfer_type=%X setup=%p pseudo=%p stop=%p }\n", in fas216_dumpinfo()
223 info->dma.transfer_type, info->dma.setup, in fas216_dumpinfo()
224 info->dma.pseudo, info->dma.stop); in fas216_dumpinfo()
226 info->internal_done, info->magic_end); in fas216_dumpinfo()
232 if (info->magic_start != MAGIC) { in __fas216_checkmagic()
236 if (info->magic_end != MAGIC) { in __fas216_checkmagic()
278 if (info->scsi.phase < ARRAY_SIZE(phases) && in fas216_drv_phase()
279 phases[info->scsi.phase]) in fas216_drv_phase()
280 return phases[info->scsi.phase]; in fas216_drv_phase()
286 if (info->SCpnt) in fas216_target()
287 return '0' + info->SCpnt->device->id; in fas216_target()
298 printk("scsi%d.%c: %s", info->host->host_no, target, buf); in fas216_do_log()
310 fas216_do_log(info, '0' + SCpnt->device->id, fmt, args); in fas216_log_command()
362 ph_ptr = (ph_ptr + 1) & (PH_SIZE-1); in add_debug_list()
389 i = (i + 1) & (PH_SIZE - 1); in print_debug_list()
408 * fas216_get_last_msg - retrive last message from the list
421 while ((msg = msgqueue_getmsg(&info->scsi.msgs, msgnr++)) != NULL) { in fas216_get_last_msg()
422 if (pos >= msg->fifo) in fas216_get_last_msg()
427 if (msg->msg[0] == EXTENDED_MESSAGE) in fas216_get_last_msg()
428 packed_msg = EXTENDED_MESSAGE | msg->msg[2] << 8; in fas216_get_last_msg()
430 packed_msg = msg->msg[0]; in fas216_get_last_msg()
440 * fas216_syncperiod - calculate STP register value
449 int value = (info->ifcfg.clockrate * ns) / 1000; in fas216_syncperiod()
462 * fas216_set_sync - setup FAS216 chip for specified transfer period.
468 * a transfer period >= 200ns - otherwise the chip will violate
475 fas216_writeb(info, REG_SOF, info->device[target].sof); in fas216_set_sync()
476 fas216_writeb(info, REG_STP, info->device[target].stp); in fas216_set_sync()
478 cntl3 = info->scsi.cfg[2]; in fas216_set_sync()
479 if (info->device[target].period >= (200 / 4)) in fas216_set_sync()
510 * fas216_handlesync - Handle a synchronous transfer message
518 struct fas216_device *dev = &info->device[info->SCpnt->device->id]; in fas216_handlesync()
534 if (dev->sync_state == neg_inprogress) { in fas216_handlesync()
535 dev->sync_state = neg_invalid; in fas216_handlesync()
541 switch (dev->sync_state) { in fas216_handlesync()
558 if (msg[4] > info->ifcfg.sync_max_depth) in fas216_handlesync()
559 msg[4] = info->ifcfg.sync_max_depth; in fas216_handlesync()
560 if (msg[3] < 1000 / info->ifcfg.clockrate) in fas216_handlesync()
561 msg[3] = 1000 / info->ifcfg.clockrate; in fas216_handlesync()
563 msgqueue_flush(&info->scsi.msgs); in fas216_handlesync()
564 msgqueue_addmsg(&info->scsi.msgs, 5, in fas216_handlesync()
567 info->scsi.phase = PHASE_MSGOUT_EXPECT; in fas216_handlesync()
572 dev->sync_state = neg_targcomplete; in fas216_handlesync()
584 if (msg[4] <= info->ifcfg.sync_max_depth && in fas216_handlesync()
585 msg[3] >= 1000 / info->ifcfg.clockrate) { in fas216_handlesync()
586 dev->sync_state = neg_complete; in fas216_handlesync()
598 dev->period = msg[3]; in fas216_handlesync()
599 dev->sof = msg[4]; in fas216_handlesync()
600 dev->stp = fas216_syncperiod(info, msg[3] * 4); in fas216_handlesync()
601 fas216_set_sync(info, info->SCpnt->device->id); in fas216_handlesync()
606 msgqueue_flush(&info->scsi.msgs); in fas216_handlesync()
607 msgqueue_addmsg(&info->scsi.msgs, 1, MESSAGE_REJECT); in fas216_handlesync()
608 info->scsi.phase = PHASE_MSGOUT_EXPECT; in fas216_handlesync()
612 dev->period = info->ifcfg.asyncperiod / 4; in fas216_handlesync()
613 dev->sof = 0; in fas216_handlesync()
614 dev->stp = info->scsi.async_stp; in fas216_handlesync()
615 fas216_set_sync(info, info->SCpnt->device->id); in fas216_handlesync()
624 * fas216_updateptrs - update data pointers after transfer suspended/paused
632 struct scsi_pointer *SCp = &info->scsi.SCp; in fas216_updateptrs()
638 SCp->phase -= bytes_transferred; in fas216_updateptrs()
641 if (SCp->this_residual > bytes_transferred) in fas216_updateptrs()
647 bytes_transferred -= SCp->this_residual; in fas216_updateptrs()
650 info->host->host_no, '0' + info->SCpnt->device->id); in fas216_updateptrs()
655 SCp->this_residual -= bytes_transferred; in fas216_updateptrs()
656 if (SCp->this_residual) in fas216_updateptrs()
657 SCp->ptr += bytes_transferred; in fas216_updateptrs()
659 SCp->ptr = NULL; in fas216_updateptrs()
663 * fas216_pio - transfer data off of/on to card using programmed IO
672 struct scsi_pointer *SCp = &info->scsi.SCp; in fas216_pio()
681 if (SCp->this_residual == 0) in fas216_pio()
700 * fas216_cleanuptransfer - clean up after a transfer has completed.
709 fasdmatype_t dmatype = info->dma.transfer_type; in fas216_cleanuptransfer()
711 info->dma.transfer_type = fasdma_none; in fas216_cleanuptransfer()
720 total = info->scsi.SCp.phase; in fas216_cleanuptransfer()
722 total = info->scsi.SCp.this_residual; in fas216_cleanuptransfer()
733 * If we were performing Data-Out, the transfer counter in fas216_cleanuptransfer()
734 * counts down each time a byte is transferred by the in fas216_cleanuptransfer()
738 if (info->scsi.phase == PHASE_DATAOUT) in fas216_cleanuptransfer()
741 fas216_updateptrs(info, total - residual); in fas216_cleanuptransfer()
745 * fas216_transfer - Perform a DMA/PIO transfer off of/on to card
748 * Start a DMA/PIO transfer off of/on to card
757 info->scsi.SCp.ptr, info->scsi.SCp.this_residual, in fas216_transfer()
758 info->scsi.SCp.phase); in fas216_transfer()
760 if (!info->scsi.SCp.ptr) { in fas216_transfer()
763 print_SCp(&info->scsi.SCp, "SCp: ", "\n"); in fas216_transfer()
764 print_SCp(arm_scsi_pointer(info->SCpnt), "Cmnd SCp: ", "\n"); in fas216_transfer()
770 * use DMA mode. If we are using asynchronous transfers, we may in fas216_transfer()
771 * use DMA mode or PIO mode. in fas216_transfer()
773 if (info->device[info->SCpnt->device->id].sof) in fas216_transfer()
778 if (info->scsi.phase == PHASE_DATAOUT) in fas216_transfer()
783 if (info->dma.setup) in fas216_transfer()
784 dmatype = info->dma.setup(info->host, &info->scsi.SCp, in fas216_transfer()
786 info->dma.transfer_type = dmatype; in fas216_transfer()
789 fas216_set_stc(info, info->scsi.SCp.phase); in fas216_transfer()
791 fas216_set_stc(info, info->scsi.SCp.this_residual); in fas216_transfer()
797 fas216_writeb(info, REG_STP, info->scsi.async_stp); in fas216_transfer()
805 info->dma.pseudo(info->host, &info->scsi.SCp, in fas216_transfer()
806 direction, info->SCpnt->transfersize); in fas216_transfer()
810 fas216_log(info, LOG_BUFFER, "block dma transfer"); in fas216_transfer()
815 fas216_log(info, LOG_BUFFER, "total dma transfer"); in fas216_transfer()
821 "invalid FAS216 DMA type"); in fas216_transfer()
827 * fas216_stoptransfer - Stop a DMA transfer onto / off of the card
836 if (info->dma.transfer_type == fasdma_real_all || in fas216_stoptransfer()
837 info->dma.transfer_type == fasdma_real_block) in fas216_stoptransfer()
838 info->dma.stop(info->host, &info->scsi.SCp); in fas216_stoptransfer()
842 if (info->scsi.phase == PHASE_DATAIN) { in fas216_stoptransfer()
846 * If we were performing Data-In, then the FIFO counter in fas216_stoptransfer()
847 * contains the number of bytes not transferred via DMA in fas216_stoptransfer()
848 * from the on-board FIFO. Read them manually. in fas216_stoptransfer()
851 while (fifo && info->scsi.SCp.ptr) { in fas216_stoptransfer()
852 *info->scsi.SCp.ptr = fas216_readb(info, REG_FF); in fas216_stoptransfer()
854 fifo--; in fas216_stoptransfer()
858 * After a Data-Out phase, there may be unsent in fas216_stoptransfer()
869 if (info->dma.transfer_type == fasdma_real_all || in fas216_aborttransfer()
870 info->dma.transfer_type == fasdma_real_block) in fas216_aborttransfer()
871 info->dma.stop(info->host, &info->scsi.SCp); in fas216_aborttransfer()
873 info->dma.transfer_type = fasdma_none; in fas216_aborttransfer()
880 * fas216_disconnected_intr - handle device disconnection
892 info->scsi.phase); in fas216_disconnect_intr()
894 msgqueue_flush(&info->scsi.msgs); in fas216_disconnect_intr()
896 switch (info->scsi.phase) { in fas216_disconnect_intr()
897 case PHASE_SELECTION: /* while selecting - no target */ in fas216_disconnect_intr()
902 case PHASE_MSGIN_DISCONNECT: /* message in - disconnecting */ in fas216_disconnect_intr()
903 info->scsi.disconnectable = 1; in fas216_disconnect_intr()
904 info->scsi.phase = PHASE_IDLE; in fas216_disconnect_intr()
905 info->stats.disconnects += 1; in fas216_disconnect_intr()
906 spin_lock_irqsave(&info->host_lock, flags); in fas216_disconnect_intr()
907 if (info->scsi.phase == PHASE_IDLE) in fas216_disconnect_intr()
909 spin_unlock_irqrestore(&info->host_lock, flags); in fas216_disconnect_intr()
912 case PHASE_DONE: /* at end of command - complete */ in fas216_disconnect_intr()
916 case PHASE_MSGOUT: /* message out - possible ABORT message */ in fas216_disconnect_intr()
917 if (fas216_get_last_msg(info, info->scsi.msgin_fifo) == ABORT) { in fas216_disconnect_intr()
918 info->scsi.aborting = 0; in fas216_disconnect_intr()
926 info->host->host_no, fas216_target(info), fas216_drv_phase(info)); in fas216_disconnect_intr()
935 * fas216_reselected_intr - start reconnection of a device
949 WARN_ON(info->scsi.phase == PHASE_SELECTION || in fas216_reselected_intr()
950 info->scsi.phase == PHASE_SELSTEPS); in fas216_reselected_intr()
955 info->scsi.phase, cfis); in fas216_reselected_intr()
961 info->host->host_no); in fas216_reselected_intr()
968 if (!(msg[0] & (1 << info->host->this_id)) || in fas216_reselected_intr()
972 target = msg[0] & ~(1 << info->host->this_id); in fas216_reselected_intr()
973 target = ffs(target) - 1; in fas216_reselected_intr()
987 msgqueue_flush(&info->scsi.msgs); in fas216_reselected_intr()
992 if (info->scsi.disconnectable && info->SCpnt) { in fas216_reselected_intr()
993 info->scsi.disconnectable = 0; in fas216_reselected_intr()
994 if (info->SCpnt->device->id == target && in fas216_reselected_intr()
995 info->SCpnt->device->lun == lun && in fas216_reselected_intr()
996 scsi_cmd_to_rq(info->SCpnt)->tag == tag) { in fas216_reselected_intr()
999 queue_add_cmd_tail(&info->queues.disconnected, info->SCpnt); in fas216_reselected_intr()
1001 info->SCpnt = NULL; in fas216_reselected_intr()
1004 if (!info->SCpnt) { in fas216_reselected_intr()
1005 info->SCpnt = queue_remove_tgtluntag(&info->queues.disconnected, in fas216_reselected_intr()
1010 if (info->SCpnt) { in fas216_reselected_intr()
1014 info->scsi.SCp = *arm_scsi_pointer(info->SCpnt); in fas216_reselected_intr()
1017 info->scsi.SCp.ptr, info->scsi.SCp.this_residual); in fas216_reselected_intr()
1018 info->scsi.phase = PHASE_MSGIN; in fas216_reselected_intr()
1021 * Our command structure not found - abort the in fas216_reselected_intr()
1030 msgqueue_addmsg(&info->scsi.msgs, 2, ABORT_TAG, tag); in fas216_reselected_intr()
1033 msgqueue_addmsg(&info->scsi.msgs, 1, ABORT); in fas216_reselected_intr()
1034 info->scsi.phase = PHASE_MSGOUT_EXPECT; in fas216_reselected_intr()
1035 info->scsi.aborting = 1; in fas216_reselected_intr()
1043 info->host->host_no); in fas216_reselected_intr()
1049 msgqueue_flush(&info->scsi.msgs); in fas216_reselected_intr()
1050 msgqueue_addmsg(&info->scsi.msgs, 1, INITIATOR_ERROR); in fas216_reselected_intr()
1051 info->scsi.phase = PHASE_MSGOUT_EXPECT; in fas216_reselected_intr()
1067 info->host->host_no, fas216_target(info)); in fas216_parse_message()
1082 scsi_pointer = arm_scsi_pointer(info->SCpnt); in fas216_parse_message()
1083 *scsi_pointer = info->scsi.SCp; in fas216_parse_message()
1084 scsi_pointer->sent_command = 0; in fas216_parse_message()
1087 info->scsi.SCp.ptr, info->scsi.SCp.this_residual); in fas216_parse_message()
1097 info->scsi.SCp = *arm_scsi_pointer(info->SCpnt); in fas216_parse_message()
1100 info->scsi.SCp.ptr, info->scsi.SCp.this_residual); in fas216_parse_message()
1107 info->scsi.phase = PHASE_MSGIN_DISCONNECT; in fas216_parse_message()
1114 switch (fas216_get_last_msg(info, info->scsi.msgin_fifo)) { in fas216_parse_message()
1121 fas216_get_last_msg(info, info->scsi.msgin_fifo)); in fas216_parse_message()
1149 printk("scsi%d.%c: message was", info->host->host_no, fas216_target(info)); in fas216_parse_message()
1155 * Something strange seems to be happening here - in fas216_parse_message()
1162 msgqueue_flush(&info->scsi.msgs); in fas216_parse_message()
1163 msgqueue_addmsg(&info->scsi.msgs, 1, MESSAGE_REJECT); in fas216_parse_message()
1164 info->scsi.phase = PHASE_MSGOUT_EXPECT; in fas216_parse_message()
1175 for (tout = 1000; tout; tout -= 1) { in fas216_wait_cmd()
1213 fas216_log(info, LOG_ERROR, "timed out waiting for message byte"); in fas216_get_msg_byte()
1214 return -1; in fas216_get_msg_byte()
1218 return -2; in fas216_get_msg_byte()
1222 return -3; in fas216_get_msg_byte()
1226 * fas216_message - handle a function done interrupt from FAS216 chip
1233 unsigned char *message = info->scsi.message; in fas216_message()
1258 if (msgbyte == -3) in fas216_message()
1266 info->host->host_no, fas216_target(info)); in fas216_message()
1279 msgqueue_flush(&info->scsi.msgs); in fas216_message()
1280 msgqueue_addmsg(&info->scsi.msgs, 1, MSG_PARITY_ERROR); in fas216_message()
1281 info->scsi.phase = PHASE_MSGOUT_EXPECT; in fas216_message()
1287 * fas216_send_command - send command after all message bytes have been sent
1302 for (i = info->scsi.SCp.sent_command; i < info->SCpnt->cmd_len; i++) in fas216_send_command()
1303 fas216_writeb(info, REG_FF, info->SCpnt->cmnd[i]); in fas216_send_command()
1307 info->scsi.phase = PHASE_COMMAND; in fas216_send_command()
1311 * fas216_send_messageout - handle bus service to send a message
1319 unsigned int tot_msglen = msgqueue_msglength(&info->scsi.msgs); in fas216_send_messageout()
1329 while ((msg = msgqueue_getmsg(&info->scsi.msgs, msgnr++)) != NULL) { in fas216_send_messageout()
1332 for (i = start; i < msg->length; i++) in fas216_send_messageout()
1333 fas216_writeb(info, REG_FF, msg->msg[i]); in fas216_send_messageout()
1335 msg->fifo = tot_msglen - (fas216_readb(info, REG_CFIS) & CFIS_CF); in fas216_send_messageout()
1343 info->scsi.phase = PHASE_MSGOUT; in fas216_send_messageout()
1347 * fas216_busservice_intr - handle bus service interrupt from FAS216 chip
1360 stat, is, info->scsi.phase); in fas216_busservice_intr()
1362 switch (info->scsi.phase) { in fas216_busservice_intr()
1395 switch (STATE(stat & STAT_BUSMASK, info->scsi.phase)) { in fas216_busservice_intr()
1396 case STATE(STAT_DATAIN, PHASE_SELSTEPS):/* Sel w/ steps -> Data In */ in fas216_busservice_intr()
1397 case STATE(STAT_DATAIN, PHASE_MSGOUT): /* Message Out -> Data In */ in fas216_busservice_intr()
1398 case STATE(STAT_DATAIN, PHASE_COMMAND): /* Command -> Data In */ in fas216_busservice_intr()
1399 case STATE(STAT_DATAIN, PHASE_MSGIN): /* Message In -> Data In */ in fas216_busservice_intr()
1400 info->scsi.phase = PHASE_DATAIN; in fas216_busservice_intr()
1404 case STATE(STAT_DATAIN, PHASE_DATAIN): /* Data In -> Data In */ in fas216_busservice_intr()
1405 case STATE(STAT_DATAOUT, PHASE_DATAOUT):/* Data Out -> Data Out */ in fas216_busservice_intr()
1410 case STATE(STAT_DATAOUT, PHASE_SELSTEPS):/* Sel w/ steps-> Data Out */ in fas216_busservice_intr()
1411 case STATE(STAT_DATAOUT, PHASE_MSGOUT): /* Message Out -> Data Out */ in fas216_busservice_intr()
1412 case STATE(STAT_DATAOUT, PHASE_COMMAND):/* Command -> Data Out */ in fas216_busservice_intr()
1413 case STATE(STAT_DATAOUT, PHASE_MSGIN): /* Message In -> Data Out */ in fas216_busservice_intr()
1415 info->scsi.phase = PHASE_DATAOUT; in fas216_busservice_intr()
1419 case STATE(STAT_STATUS, PHASE_DATAOUT): /* Data Out -> Status */ in fas216_busservice_intr()
1420 case STATE(STAT_STATUS, PHASE_DATAIN): /* Data In -> Status */ in fas216_busservice_intr()
1424 case STATE(STAT_STATUS, PHASE_SELSTEPS):/* Sel w/ steps -> Status */ in fas216_busservice_intr()
1425 case STATE(STAT_STATUS, PHASE_MSGOUT): /* Message Out -> Status */ in fas216_busservice_intr()
1426 case STATE(STAT_STATUS, PHASE_COMMAND): /* Command -> Status */ in fas216_busservice_intr()
1427 case STATE(STAT_STATUS, PHASE_MSGIN): /* Message In -> Status */ in fas216_busservice_intr()
1429 info->scsi.phase = PHASE_STATUS; in fas216_busservice_intr()
1432 case STATE(STAT_MESGIN, PHASE_DATAOUT): /* Data Out -> Message In */ in fas216_busservice_intr()
1433 case STATE(STAT_MESGIN, PHASE_DATAIN): /* Data In -> Message In */ in fas216_busservice_intr()
1437 case STATE(STAT_MESGIN, PHASE_COMMAND): /* Command -> Message In */ in fas216_busservice_intr()
1438 case STATE(STAT_MESGIN, PHASE_SELSTEPS):/* Sel w/ steps -> Message In */ in fas216_busservice_intr()
1439 case STATE(STAT_MESGIN, PHASE_MSGOUT): /* Message Out -> Message In */ in fas216_busservice_intr()
1440 info->scsi.msgin_fifo = fas216_readb(info, REG_CFIS) & CFIS_CF; in fas216_busservice_intr()
1443 info->scsi.phase = PHASE_MSGIN; in fas216_busservice_intr()
1447 info->scsi.msgin_fifo = fas216_readb(info, REG_CFIS) & CFIS_CF; in fas216_busservice_intr()
1451 case STATE(STAT_COMMAND, PHASE_MSGOUT): /* Message Out -> Command */ in fas216_busservice_intr()
1452 case STATE(STAT_COMMAND, PHASE_MSGIN): /* Message In -> Command */ in fas216_busservice_intr()
1454 info->scsi.phase = PHASE_COMMAND; in fas216_busservice_intr()
1459 * Selection -> Message Out in fas216_busservice_intr()
1466 * Message Out -> Message Out in fas216_busservice_intr()
1473 * set of messages. If we have more than one byte to in fas216_busservice_intr()
1476 if (info->device[info->SCpnt->device->id].parity_check) { in fas216_busservice_intr()
1481 info->device[info->SCpnt->device->id].parity_check = 0; in fas216_busservice_intr()
1482 info->device[info->SCpnt->device->id].parity_enabled = 1; in fas216_busservice_intr()
1483 fas216_writeb(info, REG_CNTL1, info->scsi.cfg[0]); in fas216_busservice_intr()
1486 if (msgqueue_msglength(&info->scsi.msgs) > 1) in fas216_busservice_intr()
1491 * Any -> Message Out in fas216_busservice_intr()
1501 case STATE(STAT_COMMAND, PHASE_COMMAND):/* Command -> Command */ in fas216_busservice_intr()
1502 /* error - we've sent out all the command bytes in fas216_busservice_intr()
1510 info->host->host_no, fas216_target(info)); in fas216_busservice_intr()
1514 msgqueue_flush(&info->scsi.msgs); in fas216_busservice_intr()
1515 msgqueue_addmsg(&info->scsi.msgs, 1, INITIATOR_ERROR); in fas216_busservice_intr()
1516 info->scsi.phase = PHASE_MSGOUT_EXPECT; in fas216_busservice_intr()
1520 if (info->scsi.phase == PHASE_MSGIN_DISCONNECT) { in fas216_busservice_intr()
1522 info->host->host_no, fas216_target(info), in fas216_busservice_intr()
1524 msgqueue_flush(&info->scsi.msgs); in fas216_busservice_intr()
1526 msgqueue_addmsg(&info->scsi.msgs, 1, INITIATOR_ERROR); in fas216_busservice_intr()
1527 info->scsi.phase = PHASE_MSGOUT_EXPECT; in fas216_busservice_intr()
1528 info->scsi.aborting = 1; in fas216_busservice_intr()
1533 info->host->host_no, fas216_target(info), in fas216_busservice_intr()
1548 * fas216_funcdone_intr - handle a function done interrupt from FAS216 chip
1563 stat, is, info->scsi.phase); in fas216_funcdone_intr()
1565 switch (info->scsi.phase) { in fas216_funcdone_intr()
1566 case PHASE_STATUS: /* status phase - read status and msg */ in fas216_funcdone_intr()
1571 * Read status then message byte. in fas216_funcdone_intr()
1573 info->scsi.SCp.Status = fas216_readb(info, REG_FF); in fas216_funcdone_intr()
1574 info->scsi.SCp.Message = fas216_readb(info, REG_FF); in fas216_funcdone_intr()
1575 info->scsi.phase = PHASE_DONE; in fas216_funcdone_intr()
1586 info->scsi.msgin_fifo = fifo_len; in fas216_funcdone_intr()
1604 msgqueue_flush(&info->scsi.msgs); in fas216_bus_reset()
1609 if (info->ifcfg.capabilities & (FASCAP_DMA|FASCAP_PSEUDODMA)) in fas216_bus_reset()
1613 info->scsi.phase = PHASE_IDLE; in fas216_bus_reset()
1614 info->SCpnt = NULL; /* bug! */ in fas216_bus_reset()
1615 memset(&info->scsi.SCp, 0, sizeof(info->scsi.SCp)); in fas216_bus_reset()
1618 info->device[i].disconnect_ok = info->ifcfg.disconnect_ok; in fas216_bus_reset()
1619 info->device[i].sync_state = sync_state; in fas216_bus_reset()
1620 info->device[i].period = info->ifcfg.asyncperiod / 4; in fas216_bus_reset()
1621 info->device[i].stp = info->scsi.async_stp; in fas216_bus_reset()
1622 info->device[i].sof = 0; in fas216_bus_reset()
1623 info->device[i].wide_xfer = 0; in fas216_bus_reset()
1626 info->rst_bus_status = 1; in fas216_bus_reset()
1627 wake_up(&info->eh_wait); in fas216_bus_reset()
1631 * fas216_intr - handle interrupts to progress a command
1647 add_debug_list(stat, is, inst, info->scsi.phase); in fas216_intr()
1653 scsi_report_bus_reset(info->host, 0); in fas216_intr()
1686 /* load bus-id and timeout */ in __fas216_start_command()
1687 fas216_writeb(info, REG_SDID, BUSID(SCpnt->device->id)); in __fas216_start_command()
1688 fas216_writeb(info, REG_STIM, info->ifcfg.select_timeout); in __fas216_start_command()
1691 fas216_set_sync(info, SCpnt->device->id); in __fas216_start_command()
1693 tot_msglen = msgqueue_msglength(&info->scsi.msgs); in __fas216_start_command()
1701 info->host->host_no, '0' + SCpnt->device->id); in __fas216_start_command()
1702 while ((msg = msgqueue_getmsg(&info->scsi.msgs, msgnr++)) != NULL) { in __fas216_start_command()
1704 for (i = 0; i < msg->length; i++) in __fas216_start_command()
1705 printk("%02x ", msg->msg[i]); in __fas216_start_command()
1719 info->scsi.phase = PHASE_SELSTEPS; in __fas216_start_command()
1722 while ((msg = msgqueue_getmsg(&info->scsi.msgs, msgnr++)) != NULL) { in __fas216_start_command()
1723 for (i = 0; i < msg->length; i++) in __fas216_start_command()
1724 fas216_writeb(info, REG_FF, msg->msg[i]); in __fas216_start_command()
1725 msg->fifo = tot_msglen - (fas216_readb(info, REG_CFIS) & CFIS_CF); in __fas216_start_command()
1729 for (i = 0; i < SCpnt->cmd_len; i++) in __fas216_start_command()
1730 fas216_writeb(info, REG_FF, SCpnt->cmnd[i]); in __fas216_start_command()
1739 * Load first byte into fifo, and issue SELECT with ATN and in __fas216_start_command()
1742 struct message *msg = msgqueue_getmsg(&info->scsi.msgs, 0); in __fas216_start_command()
1744 fas216_writeb(info, REG_FF, msg->msg[0]); in __fas216_start_command()
1745 msg->fifo = 1; in __fas216_start_command()
1760 info->device[target].parity_check = 0; in parity_test()
1764 return info->device[target].parity_check; in parity_test()
1774 info->scsi.phase = PHASE_SELECTION; in fas216_start_command()
1775 info->scsi.SCp = *arm_scsi_pointer(SCpnt); in fas216_start_command()
1776 info->SCpnt = SCpnt; in fas216_start_command()
1777 info->dma.transfer_type = fasdma_none; in fas216_start_command()
1779 if (parity_test(info, SCpnt->device->id)) in fas216_start_command()
1780 fas216_writeb(info, REG_CNTL1, info->scsi.cfg[0] | CNTL1_PTE); in fas216_start_command()
1782 fas216_writeb(info, REG_CNTL1, info->scsi.cfg[0]); in fas216_start_command()
1787 disconnect_ok = SCpnt->cmnd[0] != REQUEST_SENSE && in fas216_start_command()
1788 info->device[SCpnt->device->id].disconnect_ok; in fas216_start_command()
1793 msgqueue_flush(&info->scsi.msgs); in fas216_start_command()
1794 msgqueue_addmsg(&info->scsi.msgs, 1, IDENTIFY(disconnect_ok, SCpnt->device->lun)); in fas216_start_command()
1799 if (SCpnt->device->simple_tags) in fas216_start_command()
1800 msgqueue_addmsg(&info->scsi.msgs, 2, SIMPLE_QUEUE_TAG, in fas216_start_command()
1801 scsi_cmd_to_rq(SCpnt)->tag); in fas216_start_command()
1805 if ((info->device[SCpnt->device->id].sync_state == neg_wait || in fas216_start_command()
1806 info->device[SCpnt->device->id].sync_state == neg_complete) && in fas216_start_command()
1807 (SCpnt->cmnd[0] == REQUEST_SENSE || in fas216_start_command()
1808 SCpnt->cmnd[0] == INQUIRY)) { in fas216_start_command()
1809 info->device[SCpnt->device->id].sync_state = neg_inprogress; in fas216_start_command()
1810 msgqueue_addmsg(&info->scsi.msgs, 5, in fas216_start_command()
1812 1000 / info->ifcfg.clockrate, in fas216_start_command()
1813 info->ifcfg.sync_max_depth); in fas216_start_command()
1824 set_bit(SCpnt->device->id * 8 + in fas216_allocate_tag()
1825 (u8)(SCpnt->device->lun & 0x7), info->busyluns); in fas216_allocate_tag()
1827 info->stats.removes += 1; in fas216_allocate_tag()
1828 switch (SCpnt->cmnd[0]) { in fas216_allocate_tag()
1832 info->stats.writes += 1; in fas216_allocate_tag()
1837 info->stats.reads += 1; in fas216_allocate_tag()
1840 info->stats.miscs += 1; in fas216_allocate_tag()
1853 info->scsi.phase = PHASE_SELECTION; in fas216_do_bus_device_reset()
1854 info->scsi.SCp = *arm_scsi_pointer(SCpnt); in fas216_do_bus_device_reset()
1855 info->SCpnt = SCpnt; in fas216_do_bus_device_reset()
1856 info->dma.transfer_type = fasdma_none; in fas216_do_bus_device_reset()
1860 msgqueue_flush(&info->scsi.msgs); in fas216_do_bus_device_reset()
1861 msgqueue_addmsg(&info->scsi.msgs, 1, BUS_DEVICE_RESET); in fas216_do_bus_device_reset()
1870 /* load bus-id and timeout */ in fas216_do_bus_device_reset()
1871 fas216_writeb(info, REG_SDID, BUSID(SCpnt->device->id)); in fas216_do_bus_device_reset()
1872 fas216_writeb(info, REG_STIM, info->ifcfg.select_timeout); in fas216_do_bus_device_reset()
1875 fas216_set_sync(info, SCpnt->device->id); in fas216_do_bus_device_reset()
1877 msg = msgqueue_getmsg(&info->scsi.msgs, 0); in fas216_do_bus_device_reset()
1880 msg->fifo = 1; in fas216_do_bus_device_reset()
1886 * fas216_kick - kick a command to the interface
1906 if (info->rstSCpnt) { in fas216_kick()
1907 SCpnt = info->rstSCpnt; in fas216_kick()
1913 if (info->reqSCpnt) { in fas216_kick()
1914 SCpnt = info->reqSCpnt; in fas216_kick()
1915 info->reqSCpnt = NULL; in fas216_kick()
1919 if (info->origSCpnt) { in fas216_kick()
1920 SCpnt = info->origSCpnt; in fas216_kick()
1921 info->origSCpnt = NULL; in fas216_kick()
1927 SCpnt = queue_remove_exclude(&info->queues.issue, in fas216_kick()
1928 info->busyluns); in fas216_kick()
1947 if (info->scsi.disconnectable && info->SCpnt) { in fas216_kick()
1950 info->SCpnt->device->id); in fas216_kick()
1951 queue_add_cmd_tail(&info->queues.disconnected, info->SCpnt); in fas216_kick()
1952 info->scsi.disconnectable = 0; in fas216_kick()
1953 info->SCpnt = NULL; in fas216_kick()
1972 info->scsi.SCp.ptr, info->scsi.SCp.this_residual); in fas216_kick()
1988 info->rstSCpnt = NULL; in fas216_devicereset_done()
1989 info->rst_dev_status = 1; in fas216_devicereset_done()
1990 wake_up(&info->eh_wait); in fas216_devicereset_done()
1994 * fas216_rq_sns_done - Finish processing automatic request sense command
1997 * @result: driver byte of result
2006 fas216_log_target(info, LOG_CONNECT, SCpnt->device->id, in fas216_rq_sns_done()
2008 result, scsi_pointer->Message, scsi_pointer->Status); in fas216_rq_sns_done()
2010 if (result != DID_OK || scsi_pointer->Status != SAM_STAT_GOOD) in fas216_rq_sns_done()
2016 memset(SCpnt->sense_buffer, 0, SCSI_SENSE_BUFFERSIZE); in fas216_rq_sns_done()
2017 //printk("scsi%d.%c: sense buffer: ", info->host->host_no, '0' + SCpnt->device->id); in fas216_rq_sns_done()
2018 //{ int i; for (i = 0; i < 32; i++) printk("%02x ", SCpnt->sense_buffer[i]); printk("\n"); } in fas216_rq_sns_done()
2020 * Note that we don't set SCpnt->result, since that should in fas216_rq_sns_done()
2025 scsi_eh_restore_cmnd(SCpnt, &info->ses); in fas216_rq_sns_done()
2026 fas216_cmd_priv(SCpnt)->scsi_done(SCpnt); in fas216_rq_sns_done()
2030 * fas216_std_done - finish processing of standard command
2033 * @result: driver byte of result
2042 info->stats.fins += 1; in fas216_std_done()
2046 scsi_msg_to_host_byte(SCpnt, info->scsi.SCp.Message); in fas216_std_done()
2047 set_status_byte(SCpnt, info->scsi.SCp.Status); in fas216_std_done()
2050 "command complete, result=0x%08x", SCpnt->result); in fas216_std_done()
2080 if (info->scsi.SCp.ptr) { in fas216_std_done()
2081 switch (SCpnt->cmnd[0]) { in fas216_std_done()
2090 SCpnt->result, info->scsi.SCp.ptr, in fas216_std_done()
2091 info->scsi.SCp.this_residual); in fas216_std_done()
2099 if (fas216_cmd_priv(SCpnt)->scsi_done) { in fas216_std_done()
2100 fas216_cmd_priv(SCpnt)->scsi_done(SCpnt); in fas216_std_done()
2105 info->host->host_no); in fas216_std_done()
2109 if (SCpnt->cmnd[0] == REQUEST_SENSE) in fas216_std_done()
2112 scsi_eh_prep_cmnd(SCpnt, &info->ses, NULL, 0, ~0); in fas216_std_done()
2113 fas216_log_target(info, LOG_CONNECT, SCpnt->device->id, in fas216_std_done()
2116 scsi_pointer->Message = 0; in fas216_std_done()
2117 scsi_pointer->Status = 0; in fas216_std_done()
2118 SCpnt->host_scribble = (void *)fas216_rq_sns_done; in fas216_std_done()
2125 if (info->reqSCpnt) in fas216_std_done()
2127 info->host->host_no, '0' + SCpnt->device->id); in fas216_std_done()
2128 info->reqSCpnt = SCpnt; in fas216_std_done()
2132 * fas216_done - complete processing for current command
2134 * @result: driver byte of result
2146 if (!info->SCpnt) in fas216_done()
2149 SCpnt = info->SCpnt; in fas216_done()
2150 info->SCpnt = NULL; in fas216_done()
2151 info->scsi.phase = PHASE_IDLE; in fas216_done()
2153 if (info->scsi.aborting) { in fas216_done()
2154 fas216_log(info, 0, "uncaught abort - returning DID_ABORT"); in fas216_done()
2156 info->scsi.aborting = 0; in fas216_done()
2160 * Sanity check the completion - if we have zero bytes left in fas216_done()
2163 if (info->scsi.SCp.ptr && info->scsi.SCp.this_residual == 0) { in fas216_done()
2166 info->scsi.SCp.ptr, info->scsi.SCp.this_residual); in fas216_done()
2167 info->scsi.SCp.ptr = NULL; in fas216_done()
2173 * the sense information, fas216_kick will re-assert the busy in fas216_done()
2176 info->device[SCpnt->device->id].parity_check = 0; in fas216_done()
2177 clear_bit(SCpnt->device->id * 8 + in fas216_done()
2178 (u8)(SCpnt->device->lun & 0x7), info->busyluns); in fas216_done()
2180 fn = (void (*)(FAS216_Info *, struct scsi_cmnd *, unsigned int))SCpnt->host_scribble; in fas216_done()
2183 if (info->scsi.irq) { in fas216_done()
2184 spin_lock_irqsave(&info->host_lock, flags); in fas216_done()
2185 if (info->scsi.phase == PHASE_IDLE) in fas216_done()
2187 spin_unlock_irqrestore(&info->host_lock, flags); in fas216_done()
2193 info->host->host_no); in fas216_done()
2197 * fas216_queue_command_internal - queue a command for the adapter to process
2208 FAS216_Info *info = (FAS216_Info *)SCpnt->device->host->hostdata; in fas216_queue_command_internal()
2216 fas216_cmd_priv(SCpnt)->scsi_done = done; in fas216_queue_command_internal()
2217 SCpnt->host_scribble = (void *)fas216_std_done; in fas216_queue_command_internal()
2218 SCpnt->result = 0; in fas216_queue_command_internal()
2222 info->stats.queues += 1; in fas216_queue_command_internal()
2224 spin_lock(&info->host_lock); in fas216_queue_command_internal()
2230 result = !queue_add_cmd_ordered(&info->queues.issue, SCpnt); in fas216_queue_command_internal()
2236 if (result == 0 && info->scsi.phase == PHASE_IDLE) in fas216_queue_command_internal()
2238 spin_unlock(&info->host_lock); in fas216_queue_command_internal()
2240 fas216_log_target(info, LOG_CONNECT, -1, "queue %s", in fas216_queue_command_internal()
2254 * fas216_internal_done - trigger restart of a waiting thread in fas216_noqueue_command in DEF_SCSI_QCMD()
2261 FAS216_Info *info = (FAS216_Info *)SCpnt->device->host->hostdata; in DEF_SCSI_QCMD()
2265 info->internal_done = 1; in DEF_SCSI_QCMD()
2269 * fas216_noqueue_command - process a command for the adapter.
2278 FAS216_Info *info = (FAS216_Info *)SCpnt->device->host->hostdata; in fas216_noqueue_command_lck()
2286 BUG_ON(info->scsi.irq); in fas216_noqueue_command_lck()
2288 info->internal_done = 0; in fas216_noqueue_command_lck()
2293 * complete. We can't sleep either since we may get re-entered! in fas216_noqueue_command_lck()
2294 * However, we must re-enable interrupts, or else we'll be in fas216_noqueue_command_lck()
2297 spin_unlock_irq(info->host->host_lock); in fas216_noqueue_command_lck()
2299 while (!info->internal_done) { in fas216_noqueue_command_lck()
2309 spin_lock_irq(info->host->host_lock); in fas216_noqueue_command_lck()
2311 spin_unlock_irq(info->host->host_lock); in fas216_noqueue_command_lck()
2315 spin_lock_irq(info->host->host_lock); in fas216_noqueue_command_lck()
2334 del_timer(&info->eh_timer); in DEF_SCSI_QCMD()
2336 if (info->rst_bus_status == 0) in DEF_SCSI_QCMD()
2337 info->rst_bus_status = -1; in DEF_SCSI_QCMD()
2338 if (info->rst_dev_status == 0) in DEF_SCSI_QCMD()
2339 info->rst_dev_status = -1; in DEF_SCSI_QCMD()
2341 wake_up(&info->eh_wait); in DEF_SCSI_QCMD()
2351 * fas216_do_abort - decide how to abort a command
2362 if (queue_remove_cmd(&info->queues.issue, SCpnt)) { in fas216_find_command()
2372 } else if (queue_remove_cmd(&info->queues.disconnected, SCpnt)) { in fas216_find_command()
2381 } else if (info->SCpnt == SCpnt) { in fas216_find_command()
2384 switch (info->scsi.phase) { in fas216_find_command()
2390 if (info->scsi.disconnectable) { in fas216_find_command()
2391 info->scsi.disconnectable = 0; in fas216_find_command()
2392 info->SCpnt = NULL; in fas216_find_command()
2400 } else if (info->origSCpnt == SCpnt) { in fas216_find_command()
2407 info->origSCpnt = NULL; in fas216_find_command()
2408 clear_bit(SCpnt->device->id * 8 + in fas216_find_command()
2409 (u8)(SCpnt->device->lun & 0x7), info->busyluns); in fas216_find_command()
2419 * fas216_eh_abort - abort this command
2428 FAS216_Info *info = (FAS216_Info *)SCpnt->device->host->hostdata; in fas216_eh_abort()
2433 info->stats.aborts += 1; in fas216_eh_abort()
2471 * fas216_eh_device_reset - Reset the device associated with this command
2476 * Notes: We won't be re-entered, so we'll only have one device
2481 FAS216_Info *info = (FAS216_Info *)SCpnt->device->host->hostdata; in fas216_eh_device_reset()
2483 int i, res = FAILED, target = SCpnt->device->id; in fas216_eh_device_reset()
2487 spin_lock_irqsave(&info->host_lock, flags); in fas216_eh_device_reset()
2496 if (info->SCpnt && !info->scsi.disconnectable && in fas216_eh_device_reset()
2497 info->SCpnt->device->id == SCpnt->device->id) in fas216_eh_device_reset()
2506 queue_remove_all_target(&info->queues.issue, target); in fas216_eh_device_reset()
2507 queue_remove_all_target(&info->queues.disconnected, target); in fas216_eh_device_reset()
2508 if (info->origSCpnt && info->origSCpnt->device->id == target) in fas216_eh_device_reset()
2509 info->origSCpnt = NULL; in fas216_eh_device_reset()
2510 if (info->reqSCpnt && info->reqSCpnt->device->id == target) in fas216_eh_device_reset()
2511 info->reqSCpnt = NULL; in fas216_eh_device_reset()
2513 clear_bit(target * 8 + i, info->busyluns); in fas216_eh_device_reset()
2519 SCpnt->host_scribble = (void *)fas216_devicereset_done; in fas216_eh_device_reset()
2521 info->rst_dev_status = 0; in fas216_eh_device_reset()
2522 info->rstSCpnt = SCpnt; in fas216_eh_device_reset()
2524 if (info->scsi.phase == PHASE_IDLE) in fas216_eh_device_reset()
2527 mod_timer(&info->eh_timer, jiffies + 30 * HZ); in fas216_eh_device_reset()
2528 spin_unlock_irqrestore(&info->host_lock, flags); in fas216_eh_device_reset()
2533 wait_event(info->eh_wait, info->rst_dev_status); in fas216_eh_device_reset()
2535 del_timer_sync(&info->eh_timer); in fas216_eh_device_reset()
2536 spin_lock_irqsave(&info->host_lock, flags); in fas216_eh_device_reset()
2537 info->rstSCpnt = NULL; in fas216_eh_device_reset()
2539 if (info->rst_dev_status == 1) in fas216_eh_device_reset()
2543 SCpnt->host_scribble = NULL; in fas216_eh_device_reset()
2544 spin_unlock_irqrestore(&info->host_lock, flags); in fas216_eh_device_reset()
2553 * fas216_eh_bus_reset - Reset the bus associated with the command
2562 FAS216_Info *info = (FAS216_Info *)SCpnt->device->host->hostdata; in fas216_eh_bus_reset()
2569 info->stats.bus_resets += 1; in fas216_eh_bus_reset()
2571 spin_lock_irqsave(&info->host_lock, flags); in fas216_eh_bus_reset()
2577 fas216_writeb(info, REG_CNTL3, info->scsi.cfg[2]); in fas216_eh_bus_reset()
2585 info->rst_bus_status = 0; in fas216_eh_bus_reset()
2588 * For each attached hard-reset device, clear out in fas216_eh_bus_reset()
2592 shost_for_each_device(SDpnt, info->host) { in fas216_eh_bus_reset()
2595 if (SDpnt->soft_reset) in fas216_eh_bus_reset()
2598 queue_remove_all_target(&info->queues.issue, SDpnt->id); in fas216_eh_bus_reset()
2599 queue_remove_all_target(&info->queues.disconnected, SDpnt->id); in fas216_eh_bus_reset()
2600 if (info->origSCpnt && info->origSCpnt->device->id == SDpnt->id) in fas216_eh_bus_reset()
2601 info->origSCpnt = NULL; in fas216_eh_bus_reset()
2602 if (info->reqSCpnt && info->reqSCpnt->device->id == SDpnt->id) in fas216_eh_bus_reset()
2603 info->reqSCpnt = NULL; in fas216_eh_bus_reset()
2604 info->SCpnt = NULL; in fas216_eh_bus_reset()
2607 clear_bit(SDpnt->id * 8 + i, info->busyluns); in fas216_eh_bus_reset()
2610 info->scsi.phase = PHASE_IDLE; in fas216_eh_bus_reset()
2618 mod_timer(&info->eh_timer, jiffies + HZ); in fas216_eh_bus_reset()
2619 spin_unlock_irqrestore(&info->host_lock, flags); in fas216_eh_bus_reset()
2624 wait_event(info->eh_wait, info->rst_bus_status); in fas216_eh_bus_reset()
2625 del_timer_sync(&info->eh_timer); in fas216_eh_bus_reset()
2628 info->rst_bus_status == 1 ? "success" : "failed"); in fas216_eh_bus_reset()
2630 return info->rst_bus_status == 1 ? SUCCESS : FAILED; in fas216_eh_bus_reset()
2634 * fas216_init_chip - Initialise FAS216 state after reset
2641 unsigned int clock = ((info->ifcfg.clockrate - 1) / 5 + 1) & 7; in fas216_init_chip()
2643 fas216_writeb(info, REG_CNTL1, info->scsi.cfg[0]); in fas216_init_chip()
2644 fas216_writeb(info, REG_CNTL2, info->scsi.cfg[1]); in fas216_init_chip()
2645 fas216_writeb(info, REG_CNTL3, info->scsi.cfg[2]); in fas216_init_chip()
2646 fas216_writeb(info, REG_STIM, info->ifcfg.select_timeout); in fas216_init_chip()
2648 fas216_writeb(info, REG_STP, info->scsi.async_stp); in fas216_init_chip()
2649 fas216_writeb(info, REG_CNTL1, info->scsi.cfg[0]); in fas216_init_chip()
2653 * fas216_eh_host_reset - Reset the host associated with this command
2662 FAS216_Info *info = (FAS216_Info *)SCpnt->device->host->hostdata; in fas216_eh_host_reset()
2664 spin_lock_irq(info->host->host_lock); in fas216_eh_host_reset()
2681 spin_unlock_irq(info->host->host_lock); in fas216_eh_host_reset()
2683 spin_lock_irq(info->host->host_lock); in fas216_eh_host_reset()
2692 spin_unlock_irq(info->host->host_lock); in fas216_eh_host_reset()
2797 * fas216_reset_state - Initialise driver internal state
2813 memset(info->busyluns, 0, sizeof(info->busyluns)); in fas216_reset_state()
2814 info->scsi.disconnectable = 0; in fas216_reset_state()
2815 info->scsi.aborting = 0; in fas216_reset_state()
2818 info->device[i].parity_enabled = 0; in fas216_reset_state()
2819 info->device[i].parity_check = 1; in fas216_reset_state()
2825 while (queue_remove(&info->queues.disconnected) != NULL); in fas216_reset_state()
2830 info->SCpnt = NULL; in fas216_reset_state()
2831 info->reqSCpnt = NULL; in fas216_reset_state()
2832 info->rstSCpnt = NULL; in fas216_reset_state()
2833 info->origSCpnt = NULL; in fas216_reset_state()
2837 * fas216_init - initialise FAS/NCR/AMD SCSI structures.
2838 * @host: a driver-specific filled-out structure
2845 FAS216_Info *info = (FAS216_Info *)host->hostdata; in fas216_init()
2847 info->magic_start = MAGIC; in fas216_init()
2848 info->magic_end = MAGIC; in fas216_init()
2849 info->host = host; in fas216_init()
2850 info->scsi.cfg[0] = host->this_id | CNTL1_PERE; in fas216_init()
2851 info->scsi.cfg[1] = CNTL2_ENF | CNTL2_S2FE; in fas216_init()
2852 info->scsi.cfg[2] = info->ifcfg.cntl3 | in fas216_init()
2854 info->scsi.async_stp = fas216_syncperiod(info, info->ifcfg.asyncperiod); in fas216_init()
2856 info->rst_dev_status = -1; in fas216_init()
2857 info->rst_bus_status = -1; in fas216_init()
2858 init_waitqueue_head(&info->eh_wait); in fas216_init()
2859 timer_setup(&info->eh_timer, fas216_eh_timer, 0); in fas216_init()
2861 spin_lock_init(&info->host_lock); in fas216_init()
2863 memset(&info->stats, 0, sizeof(info->stats)); in fas216_init()
2865 msgqueue_initialise(&info->scsi.msgs); in fas216_init()
2867 if (!queue_initialise(&info->queues.issue)) in fas216_init()
2868 return -ENOMEM; in fas216_init()
2870 if (!queue_initialise(&info->queues.disconnected)) { in fas216_init()
2871 queue_free(&info->queues.issue); in fas216_init()
2872 return -ENOMEM; in fas216_init()
2879 * fas216_add - initialise FAS/NCR/AMD SCSI ic.
2880 * @host: a driver-specific filled-out structure
2888 FAS216_Info *info = (FAS216_Info *)host->hostdata; in fas216_add()
2891 if (info->ifcfg.clockrate <= 10 || info->ifcfg.clockrate > 40) { in fas216_add()
2893 info->ifcfg.clockrate); in fas216_add()
2894 return -EINVAL; in fas216_add()
2899 info->scsi.type = chip_types[type]; in fas216_add()
2913 fas216_writeb(info, REG_CNTL1, info->scsi.cfg[0] | CNTL1_DISR); in fas216_add()
2919 spin_unlock_irq(info->host->host_lock); in fas216_add()
2921 spin_lock_irq(info->host->host_lock); in fas216_add()
2923 fas216_writeb(info, REG_CNTL1, info->scsi.cfg[0]); in fas216_add()
2939 FAS216_Info *info = (FAS216_Info *)host->hostdata; in fas216_remove()
2949 * fas216_release - release all resources for FAS/NCR/AMD SCSI ic.
2950 * @host: a driver-specific filled-out structure
2956 FAS216_Info *info = (FAS216_Info *)host->hostdata; in fas216_release()
2958 queue_free(&info->queues.disconnected); in fas216_release()
2959 queue_free(&info->queues.issue); in fas216_release()
2969 " DMA : %d\n", in fas216_print_host()
2970 info->scsi.type, info->scsi.io_base, in fas216_print_host()
2971 info->scsi.irq, info->scsi.dma); in fas216_print_host()
2988 info->stats.queues, info->stats.removes, in fas216_print_stats()
2989 info->stats.fins, info->stats.reads, in fas216_print_stats()
2990 info->stats.writes, info->stats.miscs, in fas216_print_stats()
2991 info->stats.disconnects, info->stats.aborts, in fas216_print_stats()
2992 info->stats.bus_resets, info->stats.host_resets); in fas216_print_stats()
3002 shost_for_each_device(scd, info->host) { in fas216_print_devices()
3003 dev = &info->device[scd->id]; in fas216_print_devices()
3004 seq_printf(m, " %d/%llu ", scd->id, scd->lun); in fas216_print_devices()
3005 if (scd->tagged_supported) in fas216_print_devices()
3007 scd->simple_tags ? "en" : "dis"); in fas216_print_devices()
3011 seq_printf(m, "%3sabled ", dev->parity_enabled ? "en" : "dis"); in fas216_print_devices()
3013 if (dev->sof) in fas216_print_devices()
3015 dev->sof, dev->period * 4); in fas216_print_devices()