• Home
  • Raw
  • Download

Lines Matching refs:info

144 static inline unsigned char fas216_readb(FAS216_Info *info, unsigned int reg)  in fas216_readb()  argument
146 unsigned int off = reg << info->scsi.io_shift; in fas216_readb()
147 return readb(info->scsi.io_base + off); in fas216_readb()
150 static inline void fas216_writeb(FAS216_Info *info, unsigned int reg, unsigned int val) in fas216_writeb() argument
152 unsigned int off = reg << info->scsi.io_shift; in fas216_writeb()
153 writeb(val, info->scsi.io_base + off); in fas216_writeb()
156 static void fas216_dumpstate(FAS216_Info *info) in fas216_dumpstate() argument
160 is = fas216_readb(info, REG_IS); in fas216_dumpstate()
161 stat = fas216_readb(info, REG_STAT); in fas216_dumpstate()
162 inst = fas216_readb(info, REG_INST); in fas216_dumpstate()
166 fas216_readb(info, REG_CTCL), in fas216_dumpstate()
167 fas216_readb(info, REG_CTCM), in fas216_dumpstate()
168 fas216_readb(info, REG_CMD), stat, inst, is, in fas216_dumpstate()
169 fas216_readb(info, REG_CFIS)); in fas216_dumpstate()
171 fas216_readb(info, REG_CNTL1), in fas216_dumpstate()
172 fas216_readb(info, REG_CNTL2), in fas216_dumpstate()
173 fas216_readb(info, REG_CNTL3), in fas216_dumpstate()
174 fas216_readb(info, REG_CTCH)); in fas216_dumpstate()
185 static void fas216_dumpinfo(FAS216_Info *info) in fas216_dumpinfo() argument
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()
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()
229 static void __fas216_checkmagic(FAS216_Info *info, const char *func) in __fas216_checkmagic() argument
232 if (info->magic_start != MAGIC) { in __fas216_checkmagic()
236 if (info->magic_end != MAGIC) { in __fas216_checkmagic()
241 fas216_dumpinfo(info); in __fas216_checkmagic()
245 #define fas216_checkmagic(info) __fas216_checkmagic((info), __func__) argument
247 #define fas216_checkmagic(info) argument
262 static const char *fas216_drv_phase(FAS216_Info *info) in fas216_drv_phase() argument
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()
284 static char fas216_target(FAS216_Info *info) in fas216_target() argument
286 if (info->SCpnt) in fas216_target()
287 return '0' + info->SCpnt->device->id; in fas216_target()
293 fas216_do_log(FAS216_Info *info, char target, char *fmt, va_list ap) in fas216_do_log() argument
298 printk("scsi%d.%c: %s", info->host->host_no, target, buf); in fas216_do_log()
301 static void fas216_log_command(FAS216_Info *info, int level, in fas216_log_command() argument
310 fas216_do_log(info, '0' + SCpnt->device->id, fmt, args); in fas216_log_command()
317 fas216_log_target(FAS216_Info *info, int level, int target, char *fmt, ...) in fas216_log_target() argument
330 fas216_do_log(info, target, fmt, args); in fas216_log_target()
336 static void fas216_log(FAS216_Info *info, int level, char *fmt, ...) in fas216_log() argument
344 fas216_do_log(info, fas216_target(info), fmt, args); in fas216_log()
368 static void fas216_cmd(FAS216_Info *info, unsigned int command) in fas216_cmd() argument
375 fas216_writeb(info, REG_CMD, command); in fas216_cmd()
405 static void fas216_done(FAS216_Info *info, unsigned int result);
415 fas216_get_last_msg(FAS216_Info *info, int pos) in fas216_get_last_msg() argument
421 while ((msg = msgqueue_getmsg(&info->scsi.msgs, msgnr++)) != NULL) { in fas216_get_last_msg()
433 fas216_log(info, LOG_MESSAGES, in fas216_get_last_msg()
447 static int fas216_syncperiod(FAS216_Info *info, int ns) in fas216_syncperiod() argument
449 int value = (info->ifcfg.clockrate * ns) / 1000; in fas216_syncperiod()
451 fas216_checkmagic(info); in fas216_syncperiod()
471 static void fas216_set_sync(FAS216_Info *info, int target) in fas216_set_sync() argument
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()
482 fas216_writeb(info, REG_CNTL3, cntl3); in fas216_set_sync()
516 static void fas216_handlesync(FAS216_Info *info, char *msg) in fas216_handlesync() argument
518 struct fas216_device *dev = &info->device[info->SCpnt->device->id]; in fas216_handlesync()
557 fas216_cmd(info, CMD_SETATN); 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()
584 if (msg[4] <= info->ifcfg.sync_max_depth && in fas216_handlesync()
585 msg[3] >= 1000 / info->ifcfg.clockrate) { 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()
605 fas216_cmd(info, CMD_SETATN); 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()
614 dev->stp = info->scsi.async_stp; in fas216_handlesync()
615 fas216_set_sync(info, info->SCpnt->device->id); in fas216_handlesync()
630 static void fas216_updateptrs(FAS216_Info *info, int bytes_transferred) in fas216_updateptrs() argument
632 struct scsi_pointer *SCp = &info->scsi.SCp; in fas216_updateptrs()
634 fas216_checkmagic(info); in fas216_updateptrs()
650 info->host->host_no, '0' + info->SCpnt->device->id); in fas216_updateptrs()
670 static void fas216_pio(FAS216_Info *info, fasdmadir_t direction) in fas216_pio() argument
672 struct scsi_pointer *SCp = &info->scsi.SCp; in fas216_pio()
674 fas216_checkmagic(info); in fas216_pio()
677 fas216_writeb(info, REG_FF, get_next_SCp_byte(SCp)); in fas216_pio()
679 put_next_SCp_byte(SCp, fas216_readb(info, REG_FF)); in fas216_pio()
685 static void fas216_set_stc(FAS216_Info *info, unsigned int length) in fas216_set_stc() argument
687 fas216_writeb(info, REG_STCL, length); in fas216_set_stc()
688 fas216_writeb(info, REG_STCM, length >> 8); in fas216_set_stc()
689 fas216_writeb(info, REG_STCH, length >> 16); in fas216_set_stc()
692 static unsigned int fas216_get_ctc(FAS216_Info *info) in fas216_get_ctc() argument
694 return fas216_readb(info, REG_CTCL) + in fas216_get_ctc()
695 (fas216_readb(info, REG_CTCM) << 8) + in fas216_get_ctc()
696 (fas216_readb(info, REG_CTCH) << 16); in fas216_get_ctc()
706 static void fas216_cleanuptransfer(FAS216_Info *info) in fas216_cleanuptransfer() argument
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()
724 residual = fas216_get_ctc(info); in fas216_cleanuptransfer()
726 fifo = fas216_readb(info, REG_CFIS) & CFIS_CF; in fas216_cleanuptransfer()
728 fas216_log(info, LOG_BUFFER, "cleaning up from previous " in fas216_cleanuptransfer()
738 if (info->scsi.phase == PHASE_DATAOUT) in fas216_cleanuptransfer()
741 fas216_updateptrs(info, total - residual); in fas216_cleanuptransfer()
750 static void fas216_transfer(FAS216_Info *info) in fas216_transfer() argument
755 fas216_log(info, LOG_BUFFER, in fas216_transfer()
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()
761 fas216_log(info, LOG_ERROR, "null buffer passed to " 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()
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()
795 fas216_log(info, LOG_BUFFER, "PIO transfer"); in fas216_transfer()
796 fas216_writeb(info, REG_SOF, 0); in fas216_transfer()
797 fas216_writeb(info, REG_STP, info->scsi.async_stp); in fas216_transfer()
798 fas216_cmd(info, CMD_TRANSFERINFO); in fas216_transfer()
799 fas216_pio(info, direction); in fas216_transfer()
803 fas216_log(info, LOG_BUFFER, "pseudo transfer"); in fas216_transfer()
804 fas216_cmd(info, CMD_TRANSFERINFO | CMD_WITHDMA); 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()
811 fas216_cmd(info, CMD_TRANSFERINFO | CMD_WITHDMA); in fas216_transfer()
815 fas216_log(info, LOG_BUFFER, "total dma transfer"); in fas216_transfer()
816 fas216_cmd(info, CMD_TRANSFERINFO | CMD_WITHDMA); in fas216_transfer()
820 fas216_log(info, LOG_BUFFER | LOG_ERROR, in fas216_transfer()
832 static void fas216_stoptransfer(FAS216_Info *info) in fas216_stoptransfer() argument
834 fas216_checkmagic(info); in fas216_stoptransfer()
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()
840 fas216_cleanuptransfer(info); in fas216_stoptransfer()
842 if (info->scsi.phase == PHASE_DATAIN) { in fas216_stoptransfer()
850 fifo = fas216_readb(info, REG_CFIS) & CFIS_CF; 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()
853 fas216_updateptrs(info, 1); in fas216_stoptransfer()
861 fas216_cmd(info, CMD_FLUSHFIFO); in fas216_stoptransfer()
865 static void fas216_aborttransfer(FAS216_Info *info) in fas216_aborttransfer() argument
867 fas216_checkmagic(info); in fas216_aborttransfer()
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()
874 fas216_cmd(info, CMD_FLUSHFIFO); in fas216_aborttransfer()
877 static void fas216_kick(FAS216_Info *info);
885 static void fas216_disconnect_intr(FAS216_Info *info) in fas216_disconnect_intr() argument
889 fas216_checkmagic(info); in fas216_disconnect_intr()
891 fas216_log(info, LOG_CONNECT, "disconnect phase=%02x", in fas216_disconnect_intr()
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()
899 fas216_done(info, DID_NO_CONNECT); 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()
908 fas216_kick(info); in fas216_disconnect_intr()
909 spin_unlock_irqrestore(&info->host_lock, flags); in fas216_disconnect_intr()
913 fas216_done(info, DID_OK); 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()
919 fas216_done(info, DID_ABORT); in fas216_disconnect_intr()
926 info->host->host_no, fas216_target(info), fas216_drv_phase(info)); in fas216_disconnect_intr()
928 fas216_stoptransfer(info); in fas216_disconnect_intr()
929 fas216_done(info, DID_ERROR); in fas216_disconnect_intr()
941 fas216_reselected_intr(FAS216_Info *info) in fas216_reselected_intr() argument
947 fas216_checkmagic(info); in fas216_reselected_intr()
949 WARN_ON(info->scsi.phase == PHASE_SELECTION || in fas216_reselected_intr()
950 info->scsi.phase == PHASE_SELSTEPS); in fas216_reselected_intr()
952 cfis = fas216_readb(info, REG_CFIS); in fas216_reselected_intr()
954 fas216_log(info, LOG_CONNECT, "reconnect phase=%02x cfis=%02x", in fas216_reselected_intr()
955 info->scsi.phase, cfis); in fas216_reselected_intr()
961 info->host->host_no); in fas216_reselected_intr()
966 msg[i] = fas216_readb(info, REG_FF); 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()
985 fas216_writeb(info, REG_SDID, target); in fas216_reselected_intr()
986 fas216_set_sync(info, target); in fas216_reselected_intr()
987 msgqueue_flush(&info->scsi.msgs); in fas216_reselected_intr()
989 fas216_log(info, LOG_CONNECT, "Reconnected: target %1x lun %1x tag %02x", 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()
997 fas216_log(info, LOG_CONNECT, "reconnected previously executing command"); in fas216_reselected_intr()
999 queue_add_cmd_tail(&info->queues.disconnected, info->SCpnt); in fas216_reselected_intr()
1000 fas216_log(info, LOG_CONNECT, "had to move command to disconnected queue"); 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()
1007 fas216_log(info, LOG_CONNECT, "had to get command"); 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()
1016 fas216_log(info, LOG_CONNECT, "data pointers: [%p, %X]", 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()
1026 fas216_cmd(info, CMD_SETATN); 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()
1038 fas216_cmd(info, CMD_MSGACCEPTED); in fas216_reselected_intr()
1043 info->host->host_no); in fas216_reselected_intr()
1048 fas216_cmd(info, CMD_SETATN); 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()
1052 fas216_cmd(info, CMD_MSGACCEPTED); in fas216_reselected_intr()
1055 static void fas216_parse_message(FAS216_Info *info, unsigned char *message, int msglen) in fas216_parse_message() argument
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()
1085 fas216_log(info, LOG_CONNECT | LOG_MESSAGES | LOG_BUFFER, 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()
1098 fas216_log(info, LOG_CONNECT | LOG_MESSAGES | LOG_BUFFER, 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()
1116 fas216_handlesync(info, message); in fas216_parse_message()
1120 fas216_log(info, 0, "reject, last message 0x%04x", in fas216_parse_message()
1121 fas216_get_last_msg(info, info->scsi.msgin_fifo)); in fas216_parse_message()
1134 fas216_handlesync(info, message); in fas216_parse_message()
1148 fas216_log(info, 0, "unrecognised message, rejecting"); in fas216_parse_message()
1149 printk("scsi%d.%c: message was", info->host->host_no, fas216_target(info)); in fas216_parse_message()
1159 fas216_cmd(info, CMD_NOP); in fas216_parse_message()
1160 fas216_dumpstate(info); in fas216_parse_message()
1161 fas216_cmd(info, CMD_SETATN); 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()
1165 fas216_dumpstate(info); in fas216_parse_message()
1168 static int fas216_wait_cmd(FAS216_Info *info, int cmd) in fas216_wait_cmd() argument
1173 fas216_cmd(info, cmd); in fas216_wait_cmd()
1176 stat = fas216_readb(info, REG_STAT); in fas216_wait_cmd()
1185 static int fas216_get_msg_byte(FAS216_Info *info) in fas216_get_msg_byte() argument
1187 unsigned int stat = fas216_wait_cmd(info, CMD_MSGACCEPTED); in fas216_get_msg_byte()
1195 fas216_readb(info, REG_INST); in fas216_get_msg_byte()
1197 stat = fas216_wait_cmd(info, CMD_TRANSFERINFO); in fas216_get_msg_byte()
1208 fas216_readb(info, REG_INST); in fas216_get_msg_byte()
1210 return fas216_readb(info, REG_FF); in fas216_get_msg_byte()
1213 fas216_log(info, LOG_ERROR, "timed out waiting for message byte"); in fas216_get_msg_byte()
1217 fas216_log(info, LOG_ERROR, "unexpected phase change: status = %02x", stat); in fas216_get_msg_byte()
1221 fas216_log(info, LOG_ERROR, "parity error during message in phase"); in fas216_get_msg_byte()
1231 static void fas216_message(FAS216_Info *info) in fas216_message() argument
1233 unsigned char *message = info->scsi.message; in fas216_message()
1237 fas216_checkmagic(info); in fas216_message()
1239 message[0] = fas216_readb(info, REG_FF); in fas216_message()
1242 msgbyte = fas216_get_msg_byte(info); in fas216_message()
1248 msgbyte = fas216_get_msg_byte(info); in fas216_message()
1266 info->host->host_no, fas216_target(info)); in fas216_message()
1273 fas216_parse_message(info, message, msglen); in fas216_message()
1274 fas216_cmd(info, CMD_MSGACCEPTED); in fas216_message()
1278 fas216_cmd(info, CMD_SETATN); 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()
1282 fas216_cmd(info, CMD_MSGACCEPTED); in fas216_message()
1292 static void fas216_send_command(FAS216_Info *info) in fas216_send_command() argument
1296 fas216_checkmagic(info); in fas216_send_command()
1298 fas216_cmd(info, CMD_NOP|CMD_WITHDMA); in fas216_send_command()
1299 fas216_cmd(info, CMD_FLUSHFIFO); in fas216_send_command()
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()
1305 fas216_cmd(info, CMD_TRANSFERINFO); in fas216_send_command()
1307 info->scsi.phase = PHASE_COMMAND; in fas216_send_command()
1317 static void fas216_send_messageout(FAS216_Info *info, int start) in fas216_send_messageout() argument
1319 unsigned int tot_msglen = msgqueue_msglength(&info->scsi.msgs); in fas216_send_messageout()
1321 fas216_checkmagic(info); in fas216_send_messageout()
1323 fas216_cmd(info, CMD_FLUSHFIFO); in fas216_send_messageout()
1329 while ((msg = msgqueue_getmsg(&info->scsi.msgs, msgnr++)) != NULL) { 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()
1339 fas216_writeb(info, REG_FF, NOP); in fas216_send_messageout()
1341 fas216_cmd(info, CMD_TRANSFERINFO); in fas216_send_messageout()
1343 info->scsi.phase = PHASE_MSGOUT; in fas216_send_messageout()
1354 static void fas216_busservice_intr(FAS216_Info *info, unsigned int stat, unsigned int is) in fas216_busservice_intr() argument
1356 fas216_checkmagic(info); in fas216_busservice_intr()
1358 fas216_log(info, LOG_BUSSERVICE, in fas216_busservice_intr()
1360 stat, is, info->scsi.phase); in fas216_busservice_intr()
1362 switch (info->scsi.phase) { in fas216_busservice_intr()
1389 fas216_cmd(info, CMD_NOP); in fas216_busservice_intr()
1395 switch (STATE(stat & STAT_BUSMASK, info->scsi.phase)) { in fas216_busservice_intr()
1400 info->scsi.phase = PHASE_DATAIN; in fas216_busservice_intr()
1401 fas216_transfer(info); in fas216_busservice_intr()
1406 fas216_cleanuptransfer(info); in fas216_busservice_intr()
1407 fas216_transfer(info); in fas216_busservice_intr()
1414 fas216_cmd(info, CMD_FLUSHFIFO); in fas216_busservice_intr()
1415 info->scsi.phase = PHASE_DATAOUT; in fas216_busservice_intr()
1416 fas216_transfer(info); in fas216_busservice_intr()
1421 fas216_stoptransfer(info); in fas216_busservice_intr()
1428 fas216_cmd(info, CMD_INITCMDCOMPLETE); in fas216_busservice_intr()
1429 info->scsi.phase = PHASE_STATUS; in fas216_busservice_intr()
1434 fas216_stoptransfer(info); in fas216_busservice_intr()
1440 info->scsi.msgin_fifo = fas216_readb(info, REG_CFIS) & CFIS_CF; in fas216_busservice_intr()
1441 fas216_cmd(info, CMD_FLUSHFIFO); in fas216_busservice_intr()
1442 fas216_cmd(info, CMD_TRANSFERINFO); 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()
1448 fas216_cmd(info, CMD_TRANSFERINFO); in fas216_busservice_intr()
1453 fas216_send_command(info); in fas216_busservice_intr()
1454 info->scsi.phase = PHASE_COMMAND; in fas216_busservice_intr()
1462 fas216_send_messageout(info, 1); 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()
1487 fas216_cmd(info, CMD_SETATN); in fas216_busservice_intr()
1494 fas216_send_messageout(info, 0); in fas216_busservice_intr()
1510 info->host->host_no, fas216_target(info)); in fas216_busservice_intr()
1511 fas216_cmd(info, CMD_SETATN); in fas216_busservice_intr()
1512 fas216_set_stc(info, 15); in fas216_busservice_intr()
1513 fas216_cmd(info, CMD_PADBYTES | CMD_WITHDMA); 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()
1525 fas216_cmd(info, CMD_SETATN); 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()
1529 fas216_cmd(info, CMD_TRANSFERINFO); in fas216_busservice_intr()
1533 info->host->host_no, fas216_target(info), in fas216_busservice_intr()
1535 fas216_drv_phase(info)); in fas216_busservice_intr()
1540 fas216_log(info, 0, "bus service at step %d?", is & IS_BITS); in fas216_busservice_intr()
1541 fas216_dumpstate(info); in fas216_busservice_intr()
1544 fas216_done(info, DID_ERROR); in fas216_busservice_intr()
1555 static void fas216_funcdone_intr(FAS216_Info *info, unsigned int stat, unsigned int is) in fas216_funcdone_intr() argument
1557 unsigned int fifo_len = fas216_readb(info, REG_CFIS) & CFIS_CF; in fas216_funcdone_intr()
1559 fas216_checkmagic(info); in fas216_funcdone_intr()
1561 fas216_log(info, LOG_FUNCTIONDONE, in fas216_funcdone_intr()
1563 stat, is, info->scsi.phase); in fas216_funcdone_intr()
1565 switch (info->scsi.phase) { in fas216_funcdone_intr()
1568 fas216_log(info, 0, "odd number of bytes in FIFO: %d", fifo_len); 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()
1576 fas216_cmd(info, CMD_MSGACCEPTED); in fas216_funcdone_intr()
1586 info->scsi.msgin_fifo = fifo_len; in fas216_funcdone_intr()
1587 fas216_message(info); in fas216_funcdone_intr()
1593 fas216_log(info, 0, "internal phase %s for function done?" in fas216_funcdone_intr()
1595 fas216_target(info), fas216_drv_phase(info)); in fas216_funcdone_intr()
1599 static void fas216_bus_reset(FAS216_Info *info) in fas216_bus_reset() argument
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()
1636 irqreturn_t fas216_intr(FAS216_Info *info) in fas216_intr() argument
1641 fas216_checkmagic(info); in fas216_intr()
1643 stat = fas216_readb(info, REG_STAT); in fas216_intr()
1644 is = fas216_readb(info, REG_IS); in fas216_intr()
1645 inst = fas216_readb(info, REG_INST); in fas216_intr()
1647 add_debug_list(stat, is, inst, info->scsi.phase); in fas216_intr()
1651 fas216_log(info, 0, "bus reset detected"); in fas216_intr()
1652 fas216_bus_reset(info); in fas216_intr()
1653 scsi_report_bus_reset(info->host, 0); in fas216_intr()
1655 fas216_log(info, LOG_ERROR, "illegal command given\n"); in fas216_intr()
1656 fas216_dumpstate(info); in fas216_intr()
1659 fas216_disconnect_intr(info); in fas216_intr()
1661 fas216_reselected_intr(info); in fas216_intr()
1663 fas216_busservice_intr(info, stat, is); in fas216_intr()
1665 fas216_funcdone_intr(info, stat, is); in fas216_intr()
1667 fas216_log(info, 0, "unknown interrupt received:" in fas216_intr()
1669 fas216_drv_phase(info), inst, is, stat); in fas216_intr()
1675 static void __fas216_start_command(FAS216_Info *info, struct scsi_cmnd *SCpnt) in __fas216_start_command() argument
1680 fas216_set_stc(info, 0); in __fas216_start_command()
1681 fas216_cmd(info, CMD_NOP | CMD_WITHDMA); in __fas216_start_command()
1684 fas216_cmd(info, CMD_FLUSHFIFO); 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()
1719 info->scsi.phase = PHASE_SELSTEPS; in __fas216_start_command()
1722 while ((msg = msgqueue_getmsg(&info->scsi.msgs, msgnr++)) != NULL) { 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()
1730 fas216_writeb(info, REG_FF, SCpnt->cmnd[i]); in __fas216_start_command()
1733 fas216_cmd(info, CMD_SELECTATN); in __fas216_start_command()
1735 fas216_cmd(info, CMD_SELECTATN3); 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()
1747 fas216_cmd(info, CMD_SELECTATNSTOP); in __fas216_start_command()
1756 static int parity_test(FAS216_Info *info, int target) in parity_test() argument
1760 info->device[target].parity_check = 0; in parity_test()
1764 return info->device[target].parity_check; in parity_test()
1767 static void fas216_start_command(FAS216_Info *info, struct scsi_cmnd *SCpnt) in fas216_start_command() argument
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()
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()
1800 msgqueue_addmsg(&info->scsi.msgs, 2, SIMPLE_QUEUE_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()
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()
1819 __fas216_start_command(info, SCpnt); in fas216_start_command()
1822 static void fas216_allocate_tag(FAS216_Info *info, struct scsi_cmnd *SCpnt) in fas216_allocate_tag() argument
1825 (u8)(SCpnt->device->lun & 0x7), info->busyluns); in fas216_allocate_tag()
1827 info->stats.removes += 1; 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()
1845 static void fas216_do_bus_device_reset(FAS216_Info *info, in fas216_do_bus_device_reset() argument
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()
1858 fas216_log(info, LOG_ERROR, "sending bus device reset"); 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()
1864 fas216_set_stc(info, 0); in fas216_do_bus_device_reset()
1865 fas216_cmd(info, CMD_NOP | CMD_WITHDMA); in fas216_do_bus_device_reset()
1868 fas216_cmd(info, CMD_FLUSHFIFO); 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()
1879 fas216_writeb(info, REG_FF, BUS_DEVICE_RESET); in fas216_do_bus_device_reset()
1882 fas216_cmd(info, CMD_SELECTATNSTOP); in fas216_do_bus_device_reset()
1892 static void fas216_kick(FAS216_Info *info) in fas216_kick() argument
1900 fas216_checkmagic(info); in fas216_kick()
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()
1938 fas216_cmd(info, CMD_ENABLESEL); in fas216_kick()
1945 fas216_cmd(info, CMD_DISABLESEL); in fas216_kick()
1947 if (info->scsi.disconnectable && info->SCpnt) { in fas216_kick()
1948 fas216_log(info, LOG_CONNECT, 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()
1956 fas216_log_command(info, LOG_CONNECT | LOG_MESSAGES, SCpnt, in fas216_kick()
1961 fas216_allocate_tag(info, SCpnt); in fas216_kick()
1964 fas216_start_command(info, SCpnt); in fas216_kick()
1967 fas216_do_bus_device_reset(info, SCpnt); in fas216_kick()
1971 fas216_log(info, LOG_CONNECT, "select: data pointers [%p, %X]", in fas216_kick()
1972 info->scsi.SCp.ptr, info->scsi.SCp.this_residual); in fas216_kick()
1983 static void fas216_devicereset_done(FAS216_Info *info, struct scsi_cmnd *SCpnt, in fas216_devicereset_done() argument
1986 fas216_log(info, LOG_ERROR, "fas216 device reset complete"); in fas216_devicereset_done()
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()
2001 static void fas216_rq_sns_done(FAS216_Info *info, struct scsi_cmnd *SCpnt, in fas216_rq_sns_done() argument
2006 fas216_log_target(info, LOG_CONNECT, SCpnt->device->id, in fas216_rq_sns_done()
2025 scsi_eh_restore_cmnd(SCpnt, &info->ses); in fas216_rq_sns_done()
2038 fas216_std_done(FAS216_Info *info, struct scsi_cmnd *SCpnt, unsigned int result) in fas216_std_done() argument
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()
2049 fas216_log_command(info, LOG_CONNECT, SCpnt, in fas216_std_done()
2080 if (info->scsi.SCp.ptr) { 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()
2105 info->host->host_no); 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()
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()
2138 static void fas216_done(FAS216_Info *info, unsigned int result) in fas216_done() argument
2144 fas216_checkmagic(info); in fas216_done()
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()
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()
2176 info->device[SCpnt->device->id].parity_check = 0; in fas216_done()
2178 (u8)(SCpnt->device->lun & 0x7), info->busyluns); in fas216_done()
2181 fn(info, SCpnt, result); 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()
2186 fas216_kick(info); in fas216_done()
2187 spin_unlock_irqrestore(&info->host_lock, flags); in fas216_done()
2193 info->host->host_no); in fas216_done()
2208 FAS216_Info *info = (FAS216_Info *)SCpnt->device->host->hostdata; in fas216_queue_command_internal() local
2211 fas216_checkmagic(info); in fas216_queue_command_internal()
2213 fas216_log_command(info, LOG_CONNECT, SCpnt, 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()
2237 fas216_kick(info); 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()
2261 FAS216_Info *info = (FAS216_Info *)SCpnt->device->host->hostdata; in DEF_SCSI_QCMD() local
2263 fas216_checkmagic(info); in DEF_SCSI_QCMD()
2265 info->internal_done = 1; in DEF_SCSI_QCMD()
2278 FAS216_Info *info = (FAS216_Info *)SCpnt->device->host->hostdata; in fas216_noqueue_command_lck() local
2280 fas216_checkmagic(info); 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()
2297 spin_unlock_irq(info->host->host_lock); in fas216_noqueue_command_lck()
2299 while (!info->internal_done) { in fas216_noqueue_command_lck()
2308 if (fas216_readb(info, REG_STAT) & STAT_INT) { in fas216_noqueue_command_lck()
2309 spin_lock_irq(info->host->host_lock); in fas216_noqueue_command_lck()
2310 fas216_intr(info); 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()
2330 FAS216_Info *info = from_timer(info, t, eh_timer); in DEF_SCSI_QCMD() local
2332 fas216_log(info, LOG_ERROR, "error handling timed out\n"); in DEF_SCSI_QCMD()
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()
2357 static enum res_find fas216_find_command(FAS216_Info *info, in fas216_find_command() argument
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()
2409 (u8)(SCpnt->device->lun & 0x7), info->busyluns); in fas216_find_command()
2428 FAS216_Info *info = (FAS216_Info *)SCpnt->device->host->hostdata; in fas216_eh_abort() local
2431 fas216_checkmagic(info); in fas216_eh_abort()
2433 info->stats.aborts += 1; in fas216_eh_abort()
2438 fas216_dumpstate(info); in fas216_eh_abort()
2440 switch (fas216_find_command(info, SCpnt)) { in fas216_eh_abort()
2481 FAS216_Info *info = (FAS216_Info *)SCpnt->device->host->hostdata; in fas216_eh_device_reset() local
2485 fas216_log(info, LOG_ERROR, "device reset for target %d", target); 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()
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()
2525 fas216_kick(info); 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()
2544 spin_unlock_irqrestore(&info->host_lock, flags); in fas216_eh_device_reset()
2546 fas216_log(info, LOG_ERROR, "device reset complete: %s\n", in fas216_eh_device_reset()
2562 FAS216_Info *info = (FAS216_Info *)SCpnt->device->host->hostdata; in fas216_eh_bus_reset() local
2566 fas216_checkmagic(info); in fas216_eh_bus_reset()
2567 fas216_log(info, LOG_ERROR, "resetting bus"); 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()
2576 fas216_aborttransfer(info); in fas216_eh_bus_reset()
2577 fas216_writeb(info, REG_CNTL3, info->scsi.cfg[2]); in fas216_eh_bus_reset()
2582 while (fas216_readb(info, REG_STAT) & STAT_INT) in fas216_eh_bus_reset()
2583 fas216_readb(info, REG_INST); in fas216_eh_bus_reset()
2585 info->rst_bus_status = 0; in fas216_eh_bus_reset()
2592 shost_for_each_device(SDpnt, info->host) { 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()
2616 fas216_cmd(info, CMD_RESETSCSI); 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()
2627 fas216_log(info, LOG_ERROR, "bus reset complete: %s\n", 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()
2639 static void fas216_init_chip(FAS216_Info *info) in fas216_init_chip() argument
2641 unsigned int clock = ((info->ifcfg.clockrate - 1) / 5 + 1) & 7; in fas216_init_chip()
2642 fas216_writeb(info, REG_CLKF, clock); 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()
2647 fas216_writeb(info, REG_SOF, 0); 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()
2662 FAS216_Info *info = (FAS216_Info *)SCpnt->device->host->hostdata; in fas216_eh_host_reset() local
2664 spin_lock_irq(info->host->host_lock); in fas216_eh_host_reset()
2666 fas216_checkmagic(info); in fas216_eh_host_reset()
2668 fas216_log(info, LOG_ERROR, "resetting host"); in fas216_eh_host_reset()
2673 fas216_cmd(info, CMD_RESETCHIP); 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()
2688 fas216_cmd(info, CMD_NOP); in fas216_eh_host_reset()
2690 fas216_init_chip(info); in fas216_eh_host_reset()
2692 spin_unlock_irq(info->host->host_lock); in fas216_eh_host_reset()
2714 static int fas216_detect_type(FAS216_Info *info) in fas216_detect_type() argument
2721 fas216_writeb(info, REG_CMD, CMD_RESETCHIP); in fas216_detect_type()
2723 fas216_writeb(info, REG_CMD, CMD_NOP); in fas216_detect_type()
2728 fas216_writeb(info, REG_CNTL3, 0); in fas216_detect_type()
2729 fas216_writeb(info, REG_CNTL2, CNTL2_S2FE); in fas216_detect_type()
2736 if ((fas216_readb(info, REG_CNTL2) & (~0xe0)) != CNTL2_S2FE) in fas216_detect_type()
2742 fas216_writeb(info, REG_CNTL2, 0); in fas216_detect_type()
2743 fas216_writeb(info, REG_CNTL3, 0); in fas216_detect_type()
2744 fas216_writeb(info, REG_CNTL3, 5); in fas216_detect_type()
2750 if (fas216_readb(info, REG_CNTL3) != 5) in fas216_detect_type()
2756 fas216_writeb(info, REG_CNTL3, 0); in fas216_detect_type()
2758 fas216_writeb(info, REG_CNTL3, CNTL3_ADIDCHK); in fas216_detect_type()
2759 fas216_writeb(info, REG_CNTL3, 0); in fas216_detect_type()
2761 fas216_writeb(info, REG_CMD, CMD_RESETCHIP); in fas216_detect_type()
2763 fas216_writeb(info, REG_CMD, CMD_WITHDMA | CMD_NOP); in fas216_detect_type()
2765 fas216_writeb(info, REG_CNTL2, CNTL2_ENF); in fas216_detect_type()
2766 fas216_writeb(info, REG_CMD, CMD_RESETCHIP); in fas216_detect_type()
2768 fas216_writeb(info, REG_CMD, CMD_NOP); in fas216_detect_type()
2770 rev = fas216_readb(info, REG_ID); in fas216_detect_type()
2802 static void fas216_reset_state(FAS216_Info *info) in fas216_reset_state() argument
2806 fas216_checkmagic(info); in fas216_reset_state()
2808 fas216_bus_reset(info); in fas216_reset_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()
2845 FAS216_Info *info = (FAS216_Info *)host->hostdata; in fas216_init() local
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()
2870 if (!queue_initialise(&info->queues.disconnected)) { in fas216_init()
2871 queue_free(&info->queues.issue); in fas216_init()
2888 FAS216_Info *info = (FAS216_Info *)host->hostdata; in fas216_add() local
2891 if (info->ifcfg.clockrate <= 10 || info->ifcfg.clockrate > 40) { in fas216_add()
2893 info->ifcfg.clockrate); in fas216_add()
2897 fas216_reset_state(info); in fas216_add()
2898 type = fas216_detect_type(info); in fas216_add()
2899 info->scsi.type = chip_types[type]; in fas216_add()
2906 fas216_init_chip(info); in fas216_add()
2913 fas216_writeb(info, REG_CNTL1, info->scsi.cfg[0] | CNTL1_DISR); in fas216_add()
2914 fas216_writeb(info, REG_CMD, CMD_RESETSCSI); 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()
2924 fas216_readb(info, REG_INST); in fas216_add()
2926 fas216_checkmagic(info); in fas216_add()
2930 fas216_writeb(info, REG_CMD, CMD_RESETCHIP); in fas216_add()
2939 FAS216_Info *info = (FAS216_Info *)host->hostdata; in fas216_remove() local
2941 fas216_checkmagic(info); in fas216_remove()
2944 fas216_writeb(info, REG_CMD, CMD_RESETCHIP); in fas216_remove()
2956 FAS216_Info *info = (FAS216_Info *)host->hostdata; in fas216_release() local
2958 queue_free(&info->queues.disconnected); in fas216_release()
2959 queue_free(&info->queues.issue); in fas216_release()
2962 void fas216_print_host(FAS216_Info *info, struct seq_file *m) in fas216_print_host() argument
2970 info->scsi.type, info->scsi.io_base, in fas216_print_host()
2971 info->scsi.irq, info->scsi.dma); in fas216_print_host()
2974 void fas216_print_stats(FAS216_Info *info, struct seq_file *m) in fas216_print_stats() argument
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()
2995 void fas216_print_devices(FAS216_Info *info, struct seq_file *m) in fas216_print_devices() argument
3002 shost_for_each_device(scd, info->host) { in fas216_print_devices()
3003 dev = &info->device[scd->id]; in fas216_print_devices()