37 #include <linux/module.h>
39 #include <linux/kernel.h>
40 #include <linux/string.h>
44 #include <linux/bitops.h>
88 #undef CHECK_STRUCTURE
90 #define LOG_CONNECT (1 << 0)
91 #define LOG_BUSSERVICE (1 << 1)
92 #define LOG_FUNCTIONDONE (1 << 2)
93 #define LOG_MESSAGES (1 << 3)
94 #define LOG_BUFFER (1 << 4)
95 #define LOG_ERROR (1 << 8)
101 static int __init fas216_log_setup(
char *
str)
110 if (
strcmp(s,
"all") == 0)
129 if (
strcmp(s,
"none") == 0)
140 __setup(
"fas216_logging=", fas216_log_setup);
144 unsigned int off = reg << info->
scsi.io_shift;
150 unsigned int off = reg << info->
scsi.io_shift;
156 unsigned char is,
stat, inst;
158 is = fas216_readb(info,
REG_IS);
159 stat = fas216_readb(info,
REG_STAT);
160 inst = fas216_readb(info,
REG_INST);
162 printk(
"FAS216: CTCL=%02X CTCM=%02X CMD=%02X STAT=%02X"
163 " INST=%02X IS=%02X CFIS=%02X",
166 fas216_readb(info,
REG_CMD), stat, inst, is,
168 printk(
" CNTL1=%02X CNTL2=%02X CNTL3=%02X CTCH=%02X\n",
175 static void print_SCp(
struct scsi_pointer *SCp,
const char *
prefix,
const char *suffix)
177 printk(
"%sptr %p this_residual 0x%x buffer %p buffers_residual 0x%x%s",
182 #ifdef CHECK_STRUCTURE
192 printk(
" { magic_start=%lX host=%p SCpnt=%p origSCpnt=%p\n",
195 printk(
" scsi={ io_shift=%X irq=%X cfg={ %X %X %X %X }\n",
196 info->
scsi.io_shift, info->
scsi.irq,
197 info->
scsi.cfg[0], info->
scsi.cfg[1], info->
scsi.cfg[2],
199 printk(
" type=%p phase=%X\n",
201 print_SCp(&info->
scsi.SCp,
" SCp={ ",
" }\n");
202 printk(
" msgs async_stp=%X disconnectable=%d aborting=%d }\n",
203 info->
scsi.async_stp,
204 info->
scsi.disconnectable, info->
scsi.aborting);
205 printk(
" stats={ queues=%X removes=%X fins=%X reads=%X writes=%X miscs=%X\n"
206 " disconnects=%X aborts=%X bus_resets=%X host_resets=%X}\n",
210 info->
stats.host_resets);
211 printk(
" ifcfg={ clockrate=%X select_timeout=%X asyncperiod=%X sync_max_depth=%X }\n",
212 info->
ifcfg.clockrate, info->
ifcfg.select_timeout,
213 info->
ifcfg.asyncperiod, info->
ifcfg.sync_max_depth);
214 for (i = 0; i < 8; i++) {
215 printk(
" busyluns[%d]=%08lx dev[%d]={ disconnect_ok=%d stp=%X sof=%X sync_state=%X }\n",
220 printk(
" dma={ transfer_type=%X setup=%p pseudo=%p stop=%p }\n",
221 info->
dma.transfer_type, info->
dma.setup,
222 info->
dma.pseudo, info->
dma.stop);
223 printk(
" internal_done=%X magic_end=%lX }\n",
239 fas216_dumpinfo(info);
240 panic(
"scsi memory space corrupted in %s", func);
243 #define fas216_checkmagic(info) __fas216_checkmagic((info), __func__)
245 #define fas216_checkmagic(info)
248 static const char *fas216_bus_phase(
int stat)
250 static const char *
phases[] = {
251 "DATA OUT",
"DATA IN",
253 "MISC OUT",
"MISC IN",
254 "MESG OUT",
"MESG IN"
260 static const char *fas216_drv_phase(
FAS216_Info *info)
262 static const char *
phases[] = {
277 phases[info->
scsi.phase])
278 return phases[info->
scsi.phase];
285 return '0' + info->
SCpnt->device->id;
293 static char buf[1024];
296 printk(
"scsi%d.%c: %s", info->
host->host_no, target, buf);
304 if (level != 0 && !(level & level_mask))
308 fas216_do_log(info,
'0' + SCpnt->
device->id, fmt, args);
316 fas216_log_target(
FAS216_Info *info,
int level,
int target,
char *fmt, ...)
320 if (level != 0 && !(level & level_mask))
329 fas216_do_log(info, target, fmt, args);
335 static void fas216_log(
FAS216_Info *info,
int level,
char *fmt, ...)
339 if (level != 0 && !(level & level_mask))
343 fas216_do_log(info, fas216_target(info), fmt, args);
354 static void add_debug_list(
int stat,
int ssr,
int isr,
int ph)
356 ph_list[ph_ptr].stat =
stat;
357 ph_list[ph_ptr].ssr =
ssr;
358 ph_list[ph_ptr].isr =
isr;
359 ph_list[ph_ptr].ph =
ph;
361 ph_ptr = (ph_ptr + 1) & (
PH_SIZE-1);
369 cmd_list[cmd_ptr].command =
command;
370 cmd_list[cmd_ptr].from = __builtin_return_address(0);
372 cmd_ptr = (cmd_ptr + 1) & 7;
374 fas216_writeb(info,
REG_CMD, command);
377 static void print_debug_list(
void)
385 printk(
" %02x:%02x:%02x:%1x",
386 ph_list[i].stat, ph_list[i].ssr,
387 ph_list[i].isr, ph_list[i].ph);
389 if (((i ^ ph_ptr) & 7) == 0)
391 }
while (i != ph_ptr);
392 if ((i ^ ph_ptr) & 7)
400 }
while (i != cmd_ptr);
413 static inline unsigned short
416 unsigned short packed_msg =
NOP;
421 if (pos >= msg->
fifo)
429 packed_msg = msg->
msg[0];
433 "Message: %04x found at position %02x\n", packed_msg, pos);
470 static void fas216_set_sync(
FAS216_Info *info,
int target)
477 cntl3 = info->
scsi.cfg[2];
478 if (info->
device[target].period >= (200 / 4))
515 static void fas216_handlesync(
FAS216_Info *info,
char *msg)
517 struct fas216_device *
dev = &info->
device[info->
SCpnt->device->id];
540 switch (dev->sync_state) {
557 if (msg[4] > info->
ifcfg.sync_max_depth)
558 msg[4] = info->
ifcfg.sync_max_depth;
559 if (msg[3] < 1000 / info->
ifcfg.clockrate)
560 msg[3] = 1000 / info->
ifcfg.clockrate;
583 if (msg[4] <= info->
ifcfg.sync_max_depth &&
584 msg[3] >= 1000 / info->
ifcfg.clockrate) {
597 dev->period = msg[3];
599 dev->stp = fas216_syncperiod(info, msg[3] * 4);
600 fas216_set_sync(info, info->
SCpnt->device->id);
610 dev->period = info->
ifcfg.asyncperiod / 4;
612 dev->stp = info->
scsi.async_stp;
613 fas216_set_sync(info, info->
SCpnt->device->id);
628 static void fas216_updateptrs(
FAS216_Info *info,
int bytes_transferred)
634 BUG_ON(bytes_transferred < 0);
636 SCp->
phase -= bytes_transferred;
638 while (bytes_transferred != 0) {
646 if (!next_SCp(SCp) && bytes_transferred) {
648 info->
host->host_no,
'0' + info->
SCpnt->device->id);
655 SCp->
ptr += bytes_transferred;
675 fas216_writeb(info,
REG_FF, get_next_SCp_byte(SCp));
677 put_next_SCp_byte(SCp, fas216_readb(info,
REG_FF));
685 fas216_writeb(info,
REG_STCL, length);
686 fas216_writeb(info,
REG_STCM, length >> 8);
687 fas216_writeb(info,
REG_STCH, length >> 16);
690 static unsigned int fas216_get_ctc(
FAS216_Info *info)
692 return fas216_readb(info,
REG_CTCL) +
693 (fas216_readb(info,
REG_CTCM) << 8) +
694 (fas216_readb(info,
REG_CTCH) << 16);
704 static void fas216_cleanuptransfer(
FAS216_Info *info)
718 total = info->
scsi.SCp.phase;
720 total = info->
scsi.SCp.this_residual;
722 residual = fas216_get_ctc(info);
726 fas216_log(info,
LOG_BUFFER,
"cleaning up from previous "
727 "transfer: length 0x%06x, residual 0x%x, fifo %d",
728 total, residual, fifo);
739 fas216_updateptrs(info, total - residual);
754 "starttransfer: buffer %p length 0x%06x reqlen 0x%06x",
755 info->
scsi.SCp.ptr, info->
scsi.SCp.this_residual,
756 info->
scsi.SCp.phase);
758 if (!info->
scsi.SCp.ptr) {
759 fas216_log(info,
LOG_ERROR,
"null buffer passed to "
760 "fas216_starttransfer");
761 print_SCp(&info->
scsi.SCp,
"SCp: ",
"\n");
762 print_SCp(&info->
SCpnt->SCp,
"Cmnd SCp: ",
"\n");
782 dmatype = info->
dma.setup(info->
host, &info->
scsi.SCp,
784 info->
dma.transfer_type = dmatype;
787 fas216_set_stc(info, info->
scsi.SCp.phase);
789 fas216_set_stc(info, info->
scsi.SCp.this_residual);
794 fas216_writeb(info,
REG_SOF, 0);
795 fas216_writeb(info,
REG_STP, info->
scsi.async_stp);
797 fas216_pio(info, direction);
801 fas216_log(info,
LOG_BUFFER,
"pseudo transfer");
804 direction, info->
SCpnt->transfersize);
808 fas216_log(info,
LOG_BUFFER,
"block dma transfer");
813 fas216_log(info,
LOG_BUFFER,
"total dma transfer");
819 "invalid FAS216 DMA type");
838 fas216_cleanuptransfer(info);
849 while (fifo && info->
scsi.SCp.ptr) {
850 *info->
scsi.SCp.ptr = fas216_readb(info,
REG_FF);
851 fas216_updateptrs(info, 1);
863 static void fas216_aborttransfer(
FAS216_Info *info)
883 static void fas216_disconnect_intr(
FAS216_Info *info)
889 fas216_log(info,
LOG_CONNECT,
"disconnect phase=%02x",
894 switch (info->
scsi.phase) {
901 info->
scsi.disconnectable = 1;
903 info->
stats.disconnects += 1;
907 spin_unlock_irqrestore(&info->
host_lock, flags);
911 fas216_done(info,
DID_OK);
915 if (fas216_get_last_msg(info, info->
scsi.msgin_fifo) ==
ABORT) {
916 info->
scsi.aborting = 0;
923 info->
host->host_no, fas216_target(info), fas216_drv_phase(info));
925 fas216_stoptransfer(info);
940 unsigned int cfis,
i;
941 unsigned char msg[4];
949 cfis = fas216_readb(info,
REG_CFIS);
951 fas216_log(info,
LOG_CONNECT,
"reconnect phase=%02x cfis=%02x",
952 info->
scsi.phase, cfis);
956 if (cfis < 2 || cfis > 4) {
957 printk(
KERN_ERR "scsi%d.H: incorrect number of bytes after reselect\n",
958 info->
host->host_no);
962 for (i = 0; i < cfis; i++)
963 msg[i] = fas216_readb(info,
REG_FF);
965 if (!(msg[0] & (1 << info->
host->this_id)) ||
967 goto initiator_error;
969 target = msg[0] & ~(1 << info->
host->this_id);
970 target =
ffs(target) - 1;
976 goto initiator_error;
982 fas216_writeb(info,
REG_SDID, target);
983 fas216_set_sync(info, target);
986 fas216_log(info,
LOG_CONNECT,
"Reconnected: target %1x lun %1x tag %02x",
989 if (info->
scsi.disconnectable && info->
SCpnt) {
990 info->
scsi.disconnectable = 0;
991 if (info->
SCpnt->device->id == target &&
992 info->
SCpnt->device->lun == lun &&
993 info->
SCpnt->tag == tag) {
994 fas216_log(info,
LOG_CONNECT,
"reconnected previously executing command");
997 fas216_log(info,
LOG_CONNECT,
"had to move command to disconnected queue");
1004 fas216_log(info,
LOG_CONNECT,
"had to get command");
1013 fas216_log(info,
LOG_CONNECT,
"data pointers: [%p, %X]",
1014 info->
scsi.SCp.ptr, info->
scsi.SCp.this_residual);
1032 info->
scsi.aborting = 1;
1040 info->
host->host_no);
1041 for (i = 0; i < cfis; i++)
1056 switch (message[0]) {
1062 "status in MESSAGE_IN?\n",
1063 info->
host->host_no, fas216_target(info));
1079 info->
SCpnt->SCp.sent_command = 0;
1081 "save data pointers: [%p, %X]",
1082 info->
scsi.SCp.ptr, info->
scsi.SCp.this_residual);
1094 "restore data pointers: [%p, 0x%x]",
1095 info->
scsi.SCp.ptr, info->
scsi.SCp.this_residual);
1109 switch (fas216_get_last_msg(info, info->
scsi.msgin_fifo)) {
1111 fas216_handlesync(info, message);
1115 fas216_log(info, 0,
"reject, last message 0x%04x",
1116 fas216_get_last_msg(info, info->
scsi.msgin_fifo));
1127 switch (message[2]) {
1129 fas216_handlesync(info, message);
1143 fas216_log(info, 0,
"unrecognised message, rejecting");
1144 printk(
"scsi%d.%c: message was", info->
host->host_no, fas216_target(info));
1145 for (i = 0; i <
msglen; i++)
1146 printk(
"%s%02X", i & 31 ?
" " :
"\n ", message[i]);
1155 fas216_dumpstate(info);
1160 fas216_dumpstate(info);
1168 fas216_cmd(info, cmd);
1170 for (tout = 1000; tout; tout -= 1) {
1171 stat = fas216_readb(info,
REG_STAT);
1188 goto unexpected_phase_change;
1194 if ((stat & STAT_INT) == 0)
1201 goto unexpected_phase_change;
1205 return fas216_readb(info,
REG_FF);
1208 fas216_log(info,
LOG_ERROR,
"timed out waiting for message byte");
1211 unexpected_phase_change:
1212 fas216_log(info,
LOG_ERROR,
"unexpected phase change: status = %02x", stat);
1216 fas216_log(info,
LOG_ERROR,
"parity error during message in phase");
1228 unsigned char *message = info->
scsi.message;
1229 unsigned int msglen = 1;
1234 message[0] = fas216_readb(info,
REG_FF);
1237 msgbyte = fas216_get_msg_byte(info);
1240 message[1] = msgbyte;
1242 for (msglen = 2; msglen < message[1] + 2; msglen++) {
1243 msgbyte = fas216_get_msg_byte(info);
1246 message[
msglen] = msgbyte;
1256 #ifdef DEBUG_MESSAGES
1260 printk(
"scsi%d.%c: message in: ",
1261 info->
host->host_no, fas216_target(info));
1262 for (i = 0; i <
msglen; i++)
1263 printk(
"%02X ", message[i]);
1268 fas216_parse_message(info, message, msglen);
1287 static void fas216_send_command(
FAS216_Info *info)
1297 for (i = info->
scsi.SCp.sent_command; i < info->SCpnt->
cmd_len; i++)
1298 fas216_writeb(info,
REG_FF, info->
SCpnt->cmnd[i]);
1321 struct message *
msg;
1327 for (i = start; i < msg->
length; i++)
1328 fas216_writeb(info,
REG_FF, msg->
msg[i]);
1349 static void fas216_busservice_intr(
FAS216_Info *info,
unsigned int stat,
unsigned int is)
1354 "bus service: stat=%02x is=%02x phase=%02x",
1355 stat, is, info->
scsi.phase);
1357 switch (info->
scsi.phase) {
1364 switch (is & IS_BITS) {
1385 #define STATE(st,ph) ((ph) << 3 | (st))
1389 switch (
STATE(stat & STAT_BUSMASK, info->
scsi.phase)) {
1395 fas216_transfer(info);
1400 fas216_cleanuptransfer(info);
1401 fas216_transfer(info);
1410 fas216_transfer(info);
1415 fas216_stoptransfer(info);
1426 fas216_stoptransfer(info);
1443 fas216_send_command(info);
1452 fas216_send_messageout(info, 1);
1471 info->
device[info->
SCpnt->device->id].parity_check = 0;
1472 info->
device[info->
SCpnt->device->id].parity_enabled = 1;
1484 fas216_send_messageout(info, 0);
1499 "target trying to receive more command bytes\n",
1502 fas216_set_stc(info, 15);
1511 printk(
KERN_ERR "scsi%d.%c: disconnect message received, but bus service %s?\n",
1512 info->
host->host_no, fas216_target(info),
1513 fas216_bus_phase(stat));
1518 info->
scsi.aborting = 1;
1523 info->
host->host_no, fas216_target(info),
1524 fas216_bus_phase(stat),
1525 fas216_drv_phase(info));
1530 fas216_log(info, 0,
"bus service at step %d?", is & IS_BITS);
1531 fas216_dumpstate(info);
1545 static void fas216_funcdone_intr(
FAS216_Info *info,
unsigned int stat,
unsigned int is)
1552 "function done: stat=%02x is=%02x phase=%02x",
1553 stat, is, info->
scsi.phase);
1555 switch (info->
scsi.phase) {
1557 if (fifo_len != 2) {
1558 fas216_log(info, 0,
"odd number of bytes in FIFO: %d", fifo_len);
1563 info->
scsi.SCp.Status = fas216_readb(info,
REG_FF);
1564 info->
scsi.SCp.Message = fas216_readb(info,
REG_FF);
1576 info->
scsi.msgin_fifo = fifo_len;
1577 fas216_message(info);
1582 fas216_log(info, 0,
"internal phase %s for function done?"
1583 " What do I do with this?",
1584 fas216_target(info), fas216_drv_phase(info));
1606 for (i = 0; i < 8; i++) {
1607 info->
device[
i].disconnect_ok = info->
ifcfg.disconnect_ok;
1608 info->
device[
i].sync_state = sync_state;
1612 info->
device[
i].wide_xfer = 0;
1627 unsigned char inst,
is,
stat;
1632 stat = fas216_readb(info,
REG_STAT);
1633 is = fas216_readb(info,
REG_IS);
1634 inst = fas216_readb(info,
REG_INST);
1636 add_debug_list(stat, is, inst, info->
scsi.phase);
1638 if (stat & STAT_INT) {
1640 fas216_log(info, 0,
"bus reset detected");
1641 fas216_bus_reset(info);
1644 fas216_log(info,
LOG_ERROR,
"illegal command given\n");
1645 fas216_dumpstate(info);
1648 fas216_disconnect_intr(info);
1650 fas216_reselected_intr(info);
1652 fas216_busservice_intr(info, stat, is);
1654 fas216_funcdone_intr(info, stat, is);
1656 fas216_log(info, 0,
"unknown interrupt received:"
1657 " phase %s inst %02X is %02X stat %02X",
1658 fas216_drv_phase(info), inst, is, stat);
1669 fas216_set_stc(info, 0);
1680 fas216_set_sync(info, SCpnt->
device->id);
1684 #ifdef DEBUG_MESSAGES
1686 struct message *
msg;
1689 printk(
"scsi%d.%c: message out: ",
1690 info->
host->host_no,
'0' + SCpnt->
device->id);
1693 for (i = 0; i < msg->
length; i++)
1701 if (tot_msglen == 1 || tot_msglen == 3) {
1705 struct message *
msg;
1712 for (i = 0; i < msg->
length; i++)
1713 fas216_writeb(info,
REG_FF, msg->
msg[i]);
1718 for (i = 0; i < SCpnt->
cmd_len; i++)
1721 if (tot_msglen == 1)
1733 fas216_writeb(info,
REG_FF, msg->
msg[0]);
1745 static int parity_test(
FAS216_Info *info,
int target)
1765 info->
SCpnt = SCpnt;
1768 if (parity_test(info, SCpnt->
device->id))
1800 1000 / info->
ifcfg.clockrate,
1801 info->
ifcfg.sync_max_depth);
1807 __fas216_start_command(info, SCpnt);
1818 SCpnt->
device->current_tag += 1;
1819 if (SCpnt->
device->current_tag == 0)
1820 SCpnt->
device->current_tag = 1;
1821 SCpnt->
tag = SCpnt->
device->current_tag;
1826 info->
stats.removes += 1;
1827 switch (SCpnt->
cmnd[0]) {
1831 info->
stats.writes += 1;
1836 info->
stats.reads += 1;
1839 info->
stats.miscs += 1;
1844 static void fas216_do_bus_device_reset(
FAS216_Info *info,
1847 struct message *
msg;
1854 info->
SCpnt = SCpnt;
1857 fas216_log(info,
LOG_ERROR,
"sending bus device reset");
1863 fas216_set_stc(info, 0);
1874 fas216_set_sync(info, SCpnt->
device->id);
1894 #define TYPE_OTHER 0
1895 #define TYPE_RESET 1
1896 #define TYPE_QUEUE 2
1946 if (info->
scsi.disconnectable && info->
SCpnt) {
1948 "moved command for %d to disconnected queue",
1949 info->
SCpnt->device->id);
1951 info->
scsi.disconnectable = 0;
1958 switch (where_from) {
1960 fas216_allocate_tag(info, SCpnt);
1962 fas216_start_command(info, SCpnt);
1965 fas216_do_bus_device_reset(info, SCpnt);
1969 fas216_log(info,
LOG_CONNECT,
"select: data pointers [%p, %X]",
1970 info->
scsi.SCp.ptr, info->
scsi.SCp.this_residual);
1984 fas216_log(info,
LOG_ERROR,
"fas216 device reset complete");
2003 "request sense complete, result=0x%04x%02x%02x",
2004 result, SCpnt->
SCp.Message, SCpnt->
SCp.Status);
2036 info->
stats.fins += 1;
2038 SCpnt->
result = result << 16 | info->
scsi.SCp.Message << 8 |
2039 info->
scsi.SCp.Status;
2042 "command complete, result=0x%08x", SCpnt->
result);
2073 if (info->
scsi.SCp.ptr) {
2074 switch (SCpnt->
cmnd[0]) {
2082 "detected: res=%08X ptr=%p len=%X CDB: ",
2083 info->
host->host_no,
'0' + SCpnt->
device->id,
2085 info->
scsi.SCp.this_residual);
2087 SCpnt->
result &= ~(255 << 16);
2099 panic(
"scsi%d.H: null scsi_done function in fas216_done",
2100 info->
host->host_no);
2109 "requesting sense");
2111 SCpnt->
SCp.Message = 0;
2112 SCpnt->
SCp.Status = 0;
2123 info->
host->host_no,
'0' + SCpnt->
device->id);
2134 static void fas216_done(
FAS216_Info *info,
unsigned int result)
2138 unsigned long flags;
2145 SCpnt = info->
SCpnt;
2149 if (info->
scsi.aborting) {
2150 fas216_log(info, 0,
"uncaught abort - returning DID_ABORT");
2152 info->
scsi.aborting = 0;
2159 if (info->
scsi.SCp.ptr && info->
scsi.SCp.this_residual == 0) {
2160 printk(
"scsi%d.%c: zero bytes left to transfer, but "
2161 "buffer pointer still valid: ptr=%p len=%08x CDB: ",
2162 info->
host->host_no,
'0' + SCpnt->
device->id,
2163 info->
scsi.SCp.ptr, info->
scsi.SCp.this_residual);
2177 fn(info, SCpnt, result);
2179 if (info->
scsi.irq) {
2183 spin_unlock_irqrestore(&info->
host_lock, flags);
2188 panic(
"scsi%d.H: null command in fas216_done",
2189 info->
host->host_no);
2201 static int fas216_queue_command_lck(
struct scsi_cmnd *SCpnt,
2210 "received command (%p)", SCpnt);
2218 info->
stats.queues += 1;
2237 fas216_log_target(info,
LOG_CONNECT, -1,
"queue %s",
2238 result ?
"failure" :
"success");
2268 static int fas216_noqueue_command_lck(
struct scsi_cmnd *SCpnt,
2282 fas216_queue_command_lck(SCpnt, fas216_internal_done);
2290 spin_unlock_irq(info->
host->host_lock);
2301 if (fas216_readb(info,
REG_STAT) & STAT_INT) {
2302 spin_lock_irq(info->
host->host_lock);
2304 spin_unlock_irq(info->
host->host_lock);
2308 spin_lock_irq(info->
host->host_lock);
2321 static
void fas216_eh_timer(
unsigned long data)
2325 fas216_log(info,
LOG_ERROR,
"error handling timed out\n");
2362 printk(
"on issue queue ");
2371 printk(
"on disconnected queue ");
2374 }
else if (info->
SCpnt == SCpnt) {
2377 switch (info->
scsi.phase) {
2383 if (info->
scsi.disconnectable) {
2384 info->
scsi.disconnectable = 0;
2402 printk(
"waiting for execution ");
2425 info->
stats.aborts += 1;
2431 fas216_dumpstate(info);
2435 switch (fas216_find_command(info, SCpnt)) {
2478 unsigned long flags;
2481 fas216_log(info,
LOG_ERROR,
"device reset for target %d", target);
2492 if (info->
SCpnt && !info->
scsi.disconnectable &&
2508 for (i = 0; i < 8; i++)
2524 spin_unlock_irqrestore(&info->
host_lock, flags);
2540 spin_unlock_irqrestore(&info->
host_lock, flags);
2542 fas216_log(info,
LOG_ERROR,
"device reset complete: %s\n",
2543 res ==
SUCCESS ?
"success" :
"failed");
2559 unsigned long flags;
2563 fas216_log(info,
LOG_ERROR,
"resetting bus");
2565 info->
stats.bus_resets += 1;
2572 fas216_aborttransfer(info);
2578 while (fas216_readb(info,
REG_STAT) & STAT_INT)
2591 if (SDpnt->soft_reset)
2602 for (i = 0; i < 8; i++)
2615 spin_unlock_irqrestore(&info->
host_lock, flags);
2623 fas216_log(info,
LOG_ERROR,
"bus reset complete: %s\n",
2637 unsigned int clock = ((info->
ifcfg.clockrate - 1) / 5 + 1) & 7;
2638 fas216_writeb(info,
REG_CLKF, clock);
2643 fas216_writeb(info,
REG_SOF, 0);
2644 fas216_writeb(info,
REG_STP, info->
scsi.async_stp);
2660 spin_lock_irq(info->
host->host_lock);
2664 printk(
"scsi%d.%c: %s: resetting host\n",
2665 info->
host->host_no,
'0' + SCpnt->
device->id, __func__);
2678 spin_unlock_irq(info->
host->host_lock);
2680 spin_lock_irq(info->
host->host_lock);
2687 fas216_init_chip(info);
2689 spin_unlock_irq(info->
host->host_lock);
2693 #define TYPE_UNKNOWN 0
2694 #define TYPE_NCR53C90 1
2695 #define TYPE_NCR53C90A 2
2696 #define TYPE_NCR53C9x 3
2697 #define TYPE_Am53CF94 4
2698 #define TYPE_EmFAS216 5
2699 #define TYPE_QLFAS216 6
2767 rev = fas216_readb(info,
REG_ID);
2789 printk(
"family %x rev %x\n", family, rev);
2805 fas216_bus_reset(info);
2811 info->
scsi.disconnectable = 0;
2812 info->
scsi.aborting = 0;
2814 for (i = 0; i < 8; i++) {
2815 info->
device[
i].parity_enabled = 0;
2816 info->
device[
i].parity_check = 1;
2851 info->
scsi.async_stp = fas216_syncperiod(info, info->
ifcfg.asyncperiod);
2858 info->
eh_timer.function = fas216_eh_timer;
2890 if (info->
ifcfg.clockrate <= 10 || info->
ifcfg.clockrate > 40) {
2892 info->
ifcfg.clockrate);
2896 fas216_reset_state(info);
2897 type = fas216_detect_type(info);
2898 info->
scsi.type = chip_types[
type];
2905 fas216_init_chip(info);
2918 spin_unlock_irq(info->
host->host_lock);
2920 spin_lock_irq(info->
host->host_lock);
2927 ret = scsi_add_host(host, dev);
2969 info->
scsi.type, info->
scsi.io_base,
2978 "Command Statistics:\n"
2985 " Disconnects: %u\n"
2987 " Bus resets : %u\n"
2988 " Host resets: %u\n",
2993 info->
stats.bus_resets, info->
stats.host_resets);
3000 struct fas216_device *
dev;
3004 p +=
sprintf(p,
"Device/Lun TaggedQ Parity Sync\n");
3010 p +=
sprintf(p,
"%3sabled(%3d) ",
3014 p +=
sprintf(p,
"unsupported ");
3016 p +=
sprintf(p,
"%3sabled ", dev->parity_enabled ?
"en" :
"dis");
3019 p +=
sprintf(p,
"offset %d, %d ns\n",
3020 dev->sof, dev->period * 4);