267 #undef HAVE_OLD_UX4F_FIRMWARE
408 #include <linux/string.h>
409 #include <linux/kernel.h>
413 #include <asm/byteorder.h>
417 #include <linux/stat.h>
418 #include <linux/pci.h>
420 #include <linux/ctype.h>
422 #include <linux/slab.h>
426 #include <scsi/scsi.h>
434 static int u14_34f_release(
struct Scsi_Host *);
436 static int u14_34f_eh_abort(
struct scsi_cmnd *);
437 static int u14_34f_eh_host_reset(
struct scsi_cmnd *);
440 static int u14_34f_slave_configure(
struct scsi_device *);
443 .name =
"UltraStor 14F/34F rev. 8.10.00 ",
444 .detect = u14_34f_detect,
445 .release = u14_34f_release,
446 .queuecommand = u14_34f_queuecommand,
447 .eh_abort_handler = u14_34f_eh_abort,
448 .eh_host_reset_handler = u14_34f_eh_host_reset,
449 .bios_param = u14_34f_bios_param,
450 .slave_configure = u14_34f_slave_configure,
452 .unchecked_isa_dma = 1,
456 #if !defined(__BIG_ENDIAN_BITFIELD) && !defined(__LITTLE_ENDIAN_BITFIELD)
457 #error "Adjust your <asm/byteorder.h> defines"
461 #define PRODUCT_ID1 0x56
462 #define PRODUCT_ID2 0x40
468 #define OP_HOST_ADAPTER 0x1
475 #define HA_CMD_INQUIRY 0x1
476 #define HA_CMD_SELF_DIAG 0x2
477 #define HA_CMD_READ_BUFF 0x3
478 #define HA_CMD_WRITE_BUFF 0x4
480 #undef DEBUG_LINKED_COMMANDS
482 #undef DEBUG_INTERRUPT
484 #undef DEBUG_GENERATE_ERRORS
485 #undef DEBUG_GENERATE_ABORTS
486 #undef DEBUG_GEOMETRY
492 #define MAX_BOARDS (MAX_ISA + MAX_VESA + MAX_EISA + MAX_PCI)
493 #define MAX_CHANNEL 1
496 #define MAX_MAILBOXES 16
497 #define MAX_SGLIST 32
498 #define MAX_SAFE_SGLIST 16
499 #define MAX_INTERNAL_RETRIES 64
500 #define MAX_CMD_PER_LUN 2
501 #define MAX_TAGGED_CMD_PER_LUN (MAX_MAILBOXES - MAX_CMD_PER_LUN)
503 #define SKIP ULONG_MAX
514 #define MAXLOOP 10000
515 #define TAG_DISABLED 0
517 #define TAG_ORDERED 2
519 #define REG_LCL_MASK 0
520 #define REG_LCL_INTR 1
521 #define REG_SYS_MASK 2
522 #define REG_SYS_INTR 3
523 #define REG_PRODUCT_ID1 4
524 #define REG_PRODUCT_ID2 5
525 #define REG_CONFIG1 6
526 #define REG_CONFIG2 7
529 #define REGION_SIZE 13UL
530 #define BSY_ASSERTED 0x01
531 #define IRQ_ASSERTED 0x01
532 #define CMD_RESET 0xc0
533 #define CMD_OGM_INTR 0x01
534 #define CMD_CLR_INTR 0x01
535 #define CMD_ENA_INTR 0x81
539 #define YESNO(a) ((a) ? 'y' : 'n')
540 #define TLDEV(type) ((type) == TYPE_DISK || (type) == TYPE_ROM)
542 #define PACKED __attribute__((packed))
552 #if defined(__BIG_ENDIAN_BITFIELD)
588 #define CP_TAIL_SIZE (sizeof(struct sglist *) + sizeof(dma_addr_t))
591 struct mscp cp[MAX_MAILBOXES];
617 static unsigned long io_port[] = {
624 0x330, 0x340, 0x230, 0x240, 0x210, 0x130, 0x140,
630 #define HD(board) ((struct hostdata *) &sh[board]->hostdata)
631 #define BN(board) (HD(board)->board_name)
634 #define H2DEV(x) cpu_to_le32(x)
635 #define DEV2H(x) le32_to_cpu(x)
637 static irqreturn_t do_interrupt_handler(
int,
void *);
638 static void flush_dev(
struct scsi_device *,
unsigned long,
unsigned int,
unsigned int);
639 static int do_trace =
FALSE;
640 static int setup_done =
FALSE;
642 static int ext_tran =
FALSE;
644 #if defined(HAVE_OLD_UX4F_FIRMWARE)
645 static int have_old_firmware =
TRUE;
647 static int have_old_firmware =
FALSE;
650 #if defined(CONFIG_SCSI_U14_34F_TAGGED_QUEUE)
656 #if defined(CONFIG_SCSI_U14_34F_LINKED_COMMANDS)
657 static int linked_comm =
TRUE;
659 static int linked_comm =
FALSE;
662 #if defined(CONFIG_SCSI_U14_34F_MAX_TAGS)
668 #define MAX_INT_PARAM 10
669 #define MAX_BOOT_OPTIONS_SIZE 256
673 #include <linux/module.h>
677 MODULE_PARM_DESC(u14_34f,
" equivalent to the \"u14-34f=...\" kernel boot " \
679 " Example: modprobe u14-34f \"u14_34f=0x340,0x330,lc:y,tm:0,mq:4\"");
688 char *tag_suffix, *link_suffix;
691 j = ((
struct hostdata *) host->hostdata)->board_number;
700 tag_suffix =
", simple tags";
704 tag_suffix =
", ordered tags";
708 tag_suffix =
", no tags";
711 else if (
TLDEV(dev->
type) && linked_comm) {
713 tag_suffix =
", untagged";
722 link_suffix =
", sorted";
724 link_suffix =
", unsorted";
734 static int wait_on_busy(
unsigned long iobase,
unsigned int loop) {
738 if (--loop == 0)
return TRUE;
744 static int board_inquiry(
unsigned int j) {
747 unsigned int limit = 0;
750 id_dma_addr = pci_map_single(
HD(j)->pdev,
HD(j)->
board_id,
764 printk(
"%s: board_inquiry, adapter busy.\n",
BN(j));
779 spin_unlock_irq(&driver_lock);
781 while ((jiffies - time) <
HZ && limit++ < 20000)
udelay(100L);
782 spin_lock_irq(&driver_lock);
792 pci_unmap_single(
HD(j)->pdev, id_dma_addr,
sizeof(
HD(j)->
board_id),
797 static int port_detect \
800 unsigned char in_byte;
804 unsigned long bios_segment_table[8] = {
806 0xc4000, 0xc8000, 0xcc000, 0xd0000,
807 0xd4000, 0xd8000, 0xdc000
811 unsigned char interrupt_table[4] = { 15, 14, 11, 10 };
814 unsigned char dma_channel_table[4] = { 5, 6, 7, 0 };
820 } mapping_table[4] = {
821 { 16, 63 }, { 64, 32 }, { 64, 63 }, { 64, 32 }
826 #if defined(__BIG_ENDIAN_BITFIELD)
827 unsigned char dma_channel: 2,
interrupt:2,
828 removable_disks_as_fixed:1, bios_segment: 3;
830 unsigned char bios_segment: 3, removable_disks_as_fixed: 1,
838 #if defined(__BIG_ENDIAN_BITFIELD)
839 unsigned char tfr_port: 2, bios_drive_number: 1,
840 mapping_mode: 2, ha_scsi_id: 3;
842 unsigned char ha_scsi_id: 3, mapping_mode: 2,
843 bios_drive_number: 1, tfr_port: 2;
853 #if defined(DEBUG_DETECT)
854 printk(
"%s: address 0x%03lx in use, skipping probe.\n", name, port_base);
859 spin_lock_irq(&driver_lock);
870 irq = interrupt_table[config_1.interrupt];
871 dma_channel = dma_channel_table[config_1.dma_channel];
872 subversion = (in_byte & 0x0f);
878 printk(
"%s: unable to allocate IRQ %u, detaching.\n", name, irq);
883 printk(
"%s: unable to allocate DMA channel %u, detaching.\n",
890 spin_unlock_irq(&driver_lock);
892 spin_lock_irq(&driver_lock);
895 printk(
"%s: unable to register host, detaching.\n", name);
902 sh[
j]->
base = bios_segment_table[config_1.bios_segment];
905 sh[
j]->
this_id = config_2.ha_scsi_id;
909 #if defined(DEBUG_DETECT)
911 unsigned char sys_mask, lcl_mask;
915 printk(
"SYS_MASK 0x%x, LCL_MASK 0x%x.\n", sys_mask, lcl_mask);
920 if (sh[j]->this_id == 0) sh[
j]->
this_id = -1;
926 HD(j)->heads = mapping_table[config_2.mapping_mode].heads;
927 HD(j)->sectors = mapping_table[config_2.mapping_mode].sectors;
928 HD(j)->subversion = subversion;
930 HD(j)->board_number =
j;
934 if (
HD(j)->subversion ==
ESA) {
946 clear_dma_ff(dma_channel);
960 if (
HD(j)->subversion ==
ISA && !board_inquiry(j)) {
961 HD(j)->board_id[40] = 0;
965 printk(
"%s: firmware %s is outdated, FW PROM should be 28004-006.\n",
973 else sprintf(dma_name,
"DMA %u", dma_channel);
975 spin_unlock_irq(&driver_lock);
978 HD(j)->cp[
i].cp_dma_addr = pci_map_single(
HD(j)->pdev,
983 sh[j]->sg_tablesize *
sizeof(
struct sg_list),
985 printk(
"%s: kmalloc SGlist failed, mbox %d, detaching.\n",
BN(j), i);
998 printk(
"UltraStor 14F/34F: Copyright (C) 1994-2003 Dario Ballabio.\n");
999 printk(
"%s config options -> of:%c, tm:%d, lc:%c, mq:%d, et:%c.\n",
1004 printk(
"%s: %s 0x%03lx, BIOS 0x%05x, IRQ %u, %s, SG %d, MB %d.\n",
1005 BN(j), bus_type, (
unsigned long)sh[j]->
io_port, (
int)sh[j]->base,
1006 sh[j]->irq, dma_name, sh[j]->sg_tablesize, sh[j]->
can_queue);
1008 if (sh[j]->max_id > 8 || sh[j]->max_lun > 8)
1009 printk(
"%s: wide SCSI support enabled, max_id %u, max_lun %u.\n",
1010 BN(j), sh[j]->max_id, sh[j]->max_lun);
1013 printk(
"%s: SCSI channel %u enabled, host target ID %d.\n",
1014 BN(j), i, sh[j]->this_id);
1023 spin_unlock_irq(&driver_lock);
1029 u14_34f_release(sh[j]);
1033 static void internal_setup(
char *
str,
int *ints) {
1034 int i,
argc = ints[0];
1041 for (i = 0; i <
argc; i++)
io_port[i] = ints[i + 1];
1047 while (cur && (pc =
strchr(cur,
':'))) {
1050 if (
c ==
'n' ||
c ==
'N') val =
FALSE;
1051 else if (
c ==
'y' ||
c ==
'Y') val =
TRUE;
1054 if (!
strncmp(cur,
"lc:", 3)) linked_comm = val;
1055 else if (!
strncmp(cur,
"of:", 3)) have_old_firmware = val;
1056 else if (!
strncmp(cur,
"tm:", 3)) tag_mode = val;
1057 else if (!
strncmp(cur,
"tc:", 3)) tag_mode = val;
1060 else if (!
strncmp(cur,
"et:", 3)) ext_tran = val;
1062 if ((cur =
strchr(cur,
','))) ++cur;
1080 internal_setup(cur, ints);
1085 unsigned int j = 0,
k;
1105 if (j < MAX_BOARDS && port_detect(
io_port[
k], j, tpnt)) j++;
1112 static void map_dma(
unsigned int i,
unsigned int j) {
1114 unsigned int k, pci_dir;
1120 cpp = &
HD(j)->cp[
i]; SCpnt = cpp->
SCpnt;
1129 if (scsi_bufflen(SCpnt)) {
1140 cpp->
use_sg = scsi_sg_count(SCpnt);
1153 static void unmap_dma(
unsigned int i,
unsigned int j) {
1154 unsigned int pci_dir;
1158 cpp = &
HD(j)->cp[
i]; SCpnt = cpp->
SCpnt;
1174 static void sync_dma(
unsigned int i,
unsigned int j) {
1175 unsigned int pci_dir;
1179 cpp = &
HD(j)->cp[
i]; SCpnt = cpp->
SCpnt;
1186 if (scsi_sg_count(SCpnt))
1187 pci_dma_sync_sg_for_cpu(
HD(j)->pdev, scsi_sglist(SCpnt),
1188 scsi_sg_count(SCpnt), pci_dir);
1197 static void scsi_to_dev_dir(
unsigned int i,
unsigned int j) {
1200 static const unsigned char data_out_cmds[] = {
1201 0x0a, 0x2a, 0x15, 0x55, 0x04, 0x07, 0x18, 0x1d, 0x24, 0x2e,
1202 0x30, 0x31, 0x32, 0x38, 0x39, 0x3a, 0x3b, 0x3d, 0x3f, 0x40,
1203 0x41, 0x4c, 0xaa, 0xae, 0xb0, 0xb1, 0xb2, 0xb6, 0xea, 0x1b, 0x5d
1206 static const unsigned char data_none_cmds[] = {
1207 0x01, 0x0b, 0x10, 0x11, 0x13, 0x16, 0x17, 0x19, 0x2b, 0x1e,
1208 0x2c, 0xac, 0x2f, 0xaf, 0x33, 0xb3, 0x35, 0x36, 0x45, 0x47,
1209 0x48, 0x49, 0xa9, 0x4b, 0xa5, 0xa6, 0xb5, 0x00
1215 cpp = &
HD(j)->cp[
i]; SCpnt = cpp->
SCpnt;
1231 panic(
"%s: qcomm, invalid SCpnt->sc_data_direction.\n",
BN(j));
1235 for (k = 0; k <
ARRAY_SIZE(data_out_cmds); k++)
1236 if (SCpnt->
cmnd[0] == data_out_cmds[k]) {
1242 for (k = 0; k <
ARRAY_SIZE(data_none_cmds); k++)
1243 if (SCpnt->
cmnd[0] == data_none_cmds[k]) {
1251 unsigned int i,
j,
k;
1255 j = ((
struct hostdata *) SCpnt->
device->host->hostdata)->board_number;
1258 panic(
"%s: qcomm, SCpnt %p already active.\n",
1263 i =
HD(j)->last_cp_used + 1;
1265 for (k = 0; k < sh[
j]->
can_queue; k++, i++) {
1270 HD(j)->last_cp_used =
i;
1276 printk(
"%s: qcomm, no free mailbox.\n",
BN(j));
1281 cpp = &
HD(j)->cp[
i];
1288 if (do_trace)
printk(
"%s: qcomm, mbox %d, target %d.%d:%d.\n",
1301 scsi_to_dev_dir(i, j);
1306 if (linked_comm && SCpnt->
device->queue_depth > 2
1317 "qcomm, adapter busy.\n");
1336 j = ((
struct hostdata *) SCarg->device->host->hostdata)->board_number;
1338 if (SCarg->host_scribble ==
NULL) {
1343 i = *(
unsigned int *)SCarg->host_scribble;
1347 panic(
"%s: abort, invalid SCarg->host_scribble.\n",
BN(j));
1350 printk(
"%s: abort, timeout error.\n",
BN(j));
1355 printk(
"%s: abort, mbox %d is free.\n",
BN(j), i);
1360 printk(
"%s: abort, mbox %d is in use.\n",
BN(j), i);
1362 if (SCarg !=
HD(j)->
cp[i].SCpnt)
1363 panic(
"%s: abort, mbox %d, SCarg %p, cp SCpnt %p.\n",
1364 BN(j), i, SCarg,
HD(j)->
cp[i].SCpnt);
1367 printk(
"%s: abort, mbox %d, interrupt pending.\n",
BN(j), i);
1373 printk(
"%s: abort, mbox %d is in reset.\n",
BN(j), i);
1378 printk(
"%s: abort, mbox %d is locked.\n",
BN(j), i);
1385 SCarg->host_scribble =
NULL;
1387 printk(
"%s, abort, mbox %d ready, DID_ABORT, done.\n",
BN(j), i);
1388 SCarg->scsi_done(SCarg);
1392 panic(
"%s: abort, mbox %d, invalid cp_stat.\n",
BN(j), i);
1395 static int u14_34f_eh_host_reset(
struct scsi_cmnd *SCarg) {
1396 unsigned int i,
j,
k,
c, limit = 0;
1398 int arg_done =
FALSE;
1401 j = ((
struct hostdata *) SCarg->
device->host->hostdata)->board_number;
1404 spin_lock_irq(sh[j]->host_lock);
1407 printk(
"%s: reset, inactive.\n",
BN(j));
1410 printk(
"%s: reset, exit, already in reset.\n",
BN(j));
1411 spin_unlock_irq(sh[j]->host_lock);
1416 printk(
"%s: reset, exit, timeout error.\n",
BN(j));
1417 spin_unlock_irq(sh[j]->host_lock);
1424 for (k = 0; k < sh[
j]->
max_id; k++) {
1426 HD(j)->target_to[
k][
c] = 0;
1435 printk(
"%s: reset, locked mbox %d forced free.\n",
BN(j), i);
1439 if (!(SCpnt =
HD(j)->
cp[i].SCpnt))
1440 panic(
"%s: reset, mbox %d, SCpnt == NULL.\n",
BN(j), i);
1444 printk(
"%s: reset, mbox %d aborting.\n",
BN(j), i);
1449 printk(
"%s: reset, mbox %d in reset.\n",
BN(j), i);
1452 if (SCpnt->host_scribble ==
NULL)
1453 panic(
"%s: reset, mbox %d, garbled SCpnt.\n",
BN(j), i);
1455 if (*(
unsigned int *)SCpnt->host_scribble != i)
1456 panic(
"%s: reset, mbox %d, index mismatch.\n",
BN(j), i);
1458 if (SCpnt->scsi_done ==
NULL)
1459 panic(
"%s: reset, mbox %d, SCpnt->scsi_done == NULL.\n",
BN(j), i);
1461 if (SCpnt == SCarg) arg_done =
TRUE;
1465 printk(
"%s: reset, cannot reset, timeout error.\n",
BN(j));
1466 spin_unlock_irq(sh[j]->host_lock);
1471 printk(
"%s: reset, board reset done, enabling interrupts.\n",
BN(j));
1473 #if defined(DEBUG_RESET)
1479 spin_unlock_irq(sh[j]->host_lock);
1481 while ((jiffies - time) < (10 *
HZ) && limit++ < 200000)
udelay(100L);
1482 spin_lock_irq(sh[j]->host_lock);
1484 printk(
"%s: reset, interrupts disabled, loops %d.\n",
BN(j), limit);
1489 SCpnt =
HD(j)->cp[
i].SCpnt;
1492 SCpnt->host_scribble =
NULL;
1497 printk(
"%s, reset, mbox %d locked, DID_RESET, done.\n",
BN(j), i);
1501 SCpnt =
HD(j)->cp[
i].SCpnt;
1504 SCpnt->host_scribble =
NULL;
1509 printk(
"%s, reset, mbox %d aborting, DID_RESET, done.\n",
BN(j), i);
1517 SCpnt->scsi_done(SCpnt);
1523 if (arg_done)
printk(
"%s: reset, exit, done.\n",
BN(j));
1524 else printk(
"%s: reset, exit.\n",
BN(j));
1526 spin_unlock_irq(sh[j]->host_lock);
1530 static int u14_34f_bios_param(
struct scsi_device *disk,
1535 dkinfo[0] =
HD(j)->heads;
1536 dkinfo[1] =
HD(j)->sectors;
1537 dkinfo[2] = size / (
HD(j)->heads *
HD(j)->sectors);
1542 dkinfo[2] = size / (dkinfo[0] * dkinfo[1]);
1545 #if defined (DEBUG_GEOMETRY)
1547 dkinfo[0], dkinfo[1], dkinfo[2]);
1553 static void sort(
unsigned long sk[],
unsigned int da[],
unsigned int n,
1555 unsigned int i,
j,
k,
y;
1558 for (i = 0; i < n - 1; i++) {
1561 for (j = k + 1; j <
n; j++)
1563 if (sk[j] > sk[k]) k =
j;
1566 if (sk[j] < sk[k]) k =
j;
1570 x = sk[
k]; sk[
k] = sk[
i]; sk[
i] =
x;
1571 y = da[
k]; da[
k] = da[
i]; da[
i] =
y;
1578 static int reorder(
unsigned int j,
unsigned long cursec,
1579 unsigned int ihdlr,
unsigned int il[],
unsigned int n_ready) {
1584 unsigned int input_only =
TRUE, overlap =
FALSE;
1585 unsigned long sl[n_ready],
pl[n_ready], ll[n_ready];
1586 unsigned long maxsec = 0, minsec =
ULONG_MAX,
seek = 0, iseek = 0;
1587 unsigned long ioseek = 0;
1589 static unsigned int flushcount = 0, batchcount = 0, sortcount = 0;
1590 static unsigned int readycount = 0, ovlcount = 0, inputcount = 0;
1591 static unsigned int readysorted = 0, revcount = 0;
1592 static unsigned long seeksorted = 0, seeknosort = 0;
1595 printk(
"fc %d bc %d ic %d oc %d rc %d rs %d sc %d re %d"\
1596 " av %ldK as %ldK.\n", flushcount, batchcount, inputcount,
1597 ovlcount, readycount, readysorted, sortcount, revcount,
1598 seeknosort / (readycount + 1),
1599 seeksorted / (readycount + 1));
1601 if (n_ready <= 1)
return FALSE;
1603 for (n = 0; n < n_ready; n++) {
1604 k = il[
n]; cpp = &
HD(j)->cp[
k]; SCpnt = cpp->
SCpnt;
1608 if (blk_rq_pos(SCpnt->
request) < minsec)
1609 minsec = blk_rq_pos(SCpnt->
request);
1610 if (blk_rq_pos(SCpnt->
request) > maxsec)
1611 maxsec = blk_rq_pos(SCpnt->
request);
1613 sl[
n] = blk_rq_pos(SCpnt->
request);
1614 ioseek += blk_rq_sectors(SCpnt->
request);
1618 if (sl[n] < sl[n - 1]) s =
FALSE;
1619 if (sl[n] > sl[n - 1]) r =
FALSE;
1621 if (link_statistics) {
1622 if (sl[n] > sl[n - 1])
1623 seek += sl[
n] - sl[n - 1];
1625 seek += sl[n - 1] - sl[
n];
1630 if (link_statistics) {
1631 if (cursec > sl[0]) seek += cursec - sl[0];
else seek += sl[0] - cursec;
1634 if (cursec > ((maxsec + minsec) / 2)) rev =
TRUE;
1636 if (ioseek > ((maxsec - minsec) / 2)) rev =
FALSE;
1638 if (!((rev && r) || (!rev && s))) sort(sl, il, n_ready, rev);
1640 if (!input_only)
for (n = 0; n < n_ready; n++) {
1641 k = il[
n]; cpp = &
HD(j)->cp[
k]; SCpnt = cpp->
SCpnt;
1646 if ((sl[n] == sl[n - 1]) || (!rev && ((sl[n - 1] + ll[n - 1]) > sl[n]))
1647 || (rev && ((sl[n] + ll[n]) > sl[n - 1]))) overlap =
TRUE;
1650 if (overlap) sort(pl, il, n_ready,
FALSE);
1652 if (link_statistics) {
1653 if (cursec > sl[0]) iseek = cursec - sl[0];
else iseek = sl[0] - cursec;
1654 batchcount++; readycount += n_ready; seeknosort += seek / 1024;
1655 if (input_only) inputcount++;
1656 if (overlap) { ovlcount++; seeksorted += iseek / 1024; }
1657 else seeksorted += (iseek + maxsec - minsec) / 1024;
1658 if (rev && !r) { revcount++; readysorted += n_ready; }
1659 if (!rev && !s) { sortcount++; readysorted += n_ready; }
1662 #if defined(DEBUG_LINKED_COMMANDS)
1663 if (link_statistics && (overlap || !(flushcount % link_statistics)))
1664 for (n = 0; n < n_ready; n++) {
1665 k = il[
n]; cpp = &
HD(j)->cp[
k]; SCpnt = cpp->
SCpnt;
1666 printk(
"%s %d.%d:%d mb %d fc %d nr %d sec %ld ns %u"\
1667 " cur %ld s:%c r:%c rev:%c in:%c ov:%c xd %d.\n",
1668 (ihdlr ?
"ihdlr" :
"qcomm"), SCpnt->channel, SCpnt->target,
1669 SCpnt->lun, k, flushcount, n_ready,
1678 static void flush_dev(
struct scsi_device *dev,
unsigned long cursec,
unsigned int j,
1679 unsigned int ihdlr) {
1686 if (
HD(j)->cp_stat[k] !=
READY &&
HD(j)->cp_stat[k] !=
IN_USE)
continue;
1688 cpp = &
HD(j)->cp[
k]; SCpnt = cpp->
SCpnt;
1690 if (SCpnt->
device != dev)
continue;
1692 if (
HD(j)->cp_stat[k] ==
IN_USE)
return;
1697 if (
reorder(j, cursec, ihdlr, il, n_ready)) n_ready = 1;
1699 for (n = 0; n < n_ready; n++) {
1700 k = il[
n]; cpp = &
HD(j)->cp[
k]; SCpnt = cpp->
SCpnt;
1704 "%s, mbox %d, adapter"
1705 " busy, will abort.\n", (ihdlr ?
"ihdlr" :
"qcomm"),
1723 int irq = sh[
j]->
irq;
1730 if (do_trace)
printk(
"%s: ihdlr, enter, irq %d, count %d.\n",
BN(j), irq,
1736 printk(
"%s: ihdlr, busy timeout error, irq %d, reg 0x%x, count %d.\n",
1737 BN(j), irq, reg,
HD(j)->iocount);
1751 panic(
"%s: ihdlr, invalid mscp bus address %p, cp0 %p.\n",
BN(j),
1752 (
void *)ret, (
void *)
H2DEV(
HD(j)->
cp[0].cp_dma_addr));
1754 cpp = &(
HD(j)->cp[
i]);
1757 #if defined(DEBUG_GENERATE_ABORTS)
1758 if ((
HD(j)->iocount > 500) && ((
HD(j)->iocount % 500) < 3))
goto handled;
1765 else if (
HD(j)->cp_stat[i] ==
LOCKED) {
1767 printk(
"%s: ihdlr, mbox %d unlocked, count %d.\n",
BN(j), i,
1771 else if (
HD(j)->cp_stat[i] ==
FREE) {
1772 printk(
"%s: ihdlr, mbox %d is free, count %d.\n",
BN(j), i,
1777 printk(
"%s: ihdlr, mbox %d is in reset.\n",
BN(j), i);
1778 else if (
HD(j)->cp_stat[i] !=
IN_USE)
1779 panic(
"%s: ihdlr, mbox %d, invalid cp_stat: %d.\n",
1780 BN(j), i,
HD(j)->cp_stat[i]);
1785 if (SCpnt ==
NULL)
panic(
"%s: ihdlr, mbox %d, SCpnt == NULL.\n",
BN(j), i);
1788 panic(
"%s: ihdlr, mbox %d, SCpnt %p garbled.\n",
BN(j), i,
1792 panic(
"%s: ihdlr, mbox %d, index mismatch %d.\n",
1797 if (linked_comm && SCpnt->
device->queue_depth > 2
1803 #if defined(DEBUG_GENERATE_ERRORS)
1804 if ((
HD(j)->iocount > 500) && ((
HD(j)->iocount % 200) < 2))
1829 if (tstatus ==
GOOD)
1836 "ihdlr, target_status 0x%x, sense key 0x%x.\n",
1863 for (k = 0; k < sh[
j]->
max_id; k++)
1872 #if defined(DID_SOFT_ERROR)
1899 #if defined(DEBUG_INTERRUPT)
1900 if (SCpnt->
result || do_trace)
1908 " reg 0x%x, count %d.\n",
1910 reg,
HD(j)->iocount);
1919 if (do_trace)
printk(
"%s: ihdlr, exit, irq %d, count %d.\n",
BN(j), irq,
1928 static irqreturn_t do_interrupt_handler(
int irq,
void *shap) {
1930 unsigned long spin_flags;
1934 if ((j = (
unsigned int)((
char *)shap - sha)) >= num_boards)
return IRQ_NONE;
1938 spin_unlock_irqrestore(sh[j]->host_lock, spin_flags);
1942 static int u14_34f_release(
struct Scsi_Host *shpnt) {
1945 for (j = 0; sh[
j] !=
NULL && sh[
j] != shpnt; j++);
1954 pci_unmap_single(
HD(j)->pdev,
HD(j)->
cp[i].cp_dma_addr,
1959 if (sh[j]->dma_channel !=
NO_DMA)