20 #define QLA1280_VERSION "3.27.1"
339 #include <linux/module.h>
341 #include <linux/types.h>
342 #include <linux/string.h>
343 #include <linux/errno.h>
344 #include <linux/kernel.h>
348 #include <linux/pci.h>
350 #include <linux/stat.h>
359 #include <asm/byteorder.h>
360 #include <asm/processor.h>
361 #include <asm/types.h>
363 #include <scsi/scsi.h>
369 #if defined(CONFIG_IA64_GENERIC) || defined(CONFIG_IA64_SGI_SN2)
370 #include <asm/sn/io.h>
378 #define DEBUG_QLA1280_INTR 0
379 #define DEBUG_PRINT_NVRAM 0
380 #define DEBUG_QLA1280 0
385 #ifdef CONFIG_X86_VISWS
386 #define MEMORY_MAPPED_IO 0
388 #define MEMORY_MAPPED_IO 1
393 #ifndef BITS_PER_LONG
394 #error "BITS_PER_LONG not defined!"
396 #if (BITS_PER_LONG == 64) || defined CONFIG_HIGHMEM
397 #define QLA_64BIT_PTR 1
401 #define pci_dma_hi32(a) ((a >> 16) >> 16)
403 #define pci_dma_hi32(a) 0
405 #define pci_dma_lo32(a) (a & 0xffffffff)
407 #define NVRAM_DELAY() udelay(500)
409 #if defined(__ia64__) && !defined(ia64_platform_is)
410 #define ia64_platform_is(foo) (!strcmp(x, platform_name))
414 #define IS_ISP1040(ha) (ha->pdev->device == PCI_DEVICE_ID_QLOGIC_ISP1020)
415 #define IS_ISP1x40(ha) (ha->pdev->device == PCI_DEVICE_ID_QLOGIC_ISP1020 || \
416 ha->pdev->device == PCI_DEVICE_ID_QLOGIC_ISP1240)
417 #define IS_ISP1x160(ha) (ha->pdev->device == PCI_DEVICE_ID_QLOGIC_ISP10160 || \
418 ha->pdev->device == PCI_DEVICE_ID_QLOGIC_ISP12160)
422 static void qla1280_remove_one(
struct pci_dev *);
428 static int qla1280_get_token(
char *);
429 static int qla1280_setup(
char *
s)
__init;
440 static int qla1280_device_reset(
struct scsi_qla_host *,
int,
int);
441 static int qla1280_abort_command(
struct scsi_qla_host *,
struct srb *,
int);
463 static int qla1280_check_for_dead_scsi_bus(
struct scsi_qla_host *,
465 static void qla1280_get_target_parameters(
struct scsi_qla_host *,
467 static int qla1280_set_target_parameters(
struct scsi_qla_host *,
int,
int);
476 qla1280_data_direction(
struct scsi_cmnd *cmnd)
497 static void __qla1280_print_scsi_cmd(
struct scsi_cmnd *
cmd);
498 static void __qla1280_dump_buffer(
char *,
int);
506 static char *qla1280;
511 __setup(
"qla1280=", qla1280_setup);
521 #define CMD_SP(Cmnd) &Cmnd->SCp
522 #define CMD_CDBLEN(Cmnd) Cmnd->cmd_len
523 #define CMD_CDBP(Cmnd) Cmnd->cmnd
524 #define CMD_SNSP(Cmnd) Cmnd->sense_buffer
525 #define CMD_SNSLEN(Cmnd) SCSI_SENSE_BUFFERSIZE
526 #define CMD_RESULT(Cmnd) Cmnd->result
527 #define CMD_HANDLE(Cmnd) Cmnd->host_scribble
528 #define CMD_REQUEST(Cmnd) Cmnd->request->cmd
530 #define CMD_HOST(Cmnd) Cmnd->device->host
531 #define SCSI_BUS_32(Cmnd) Cmnd->device->channel
532 #define SCSI_TCN_32(Cmnd) Cmnd->device->id
533 #define SCSI_LUN_32(Cmnd) Cmnd->device->lun
571 #define QL_NUM_FW_IMAGES 3
574 {
"qlogic/1040.bin",
NULL},
575 {
"qlogic/1280.bin",
NULL},
576 {
"qlogic/12160.bin",
NULL},
580 static struct qla_boards ql1280_board_tbl[] = {
581 {.name =
"QLA12160", .numPorts = 2, .fw_index = 2},
582 {.name =
"QLA1040" , .numPorts = 1, .fw_index = 0},
583 {.name =
"QLA1080" , .numPorts = 1, .fw_index = 1},
584 {.name =
"QLA1240" , .numPorts = 2, .fw_index = 1},
585 {.name =
"QLA1280" , .numPorts = 2, .fw_index = 1},
586 {.name =
"QLA10160", .numPorts = 1, .fw_index = 2},
587 {.name =
" ", .numPorts = 0, .fw_index = -1},
590 static int qla1280_verbose = 1;
594 #define dprintk(level, format, a...) \
595 do { if (ql_debug_level >= level) printk(KERN_ERR format, ##a); } while(0)
596 #define qla1280_dump_buffer(level, buf, size) \
597 if (ql_debug_level >= level) __qla1280_dump_buffer(buf, size)
598 #define qla1280_print_scsi_cmd(level, cmd) \
599 if (ql_debug_level >= level) __qla1280_print_scsi_cmd(cmd)
601 #define ql_debug_level 0
602 #define dprintk(level, format, a...) do{}while(0)
603 #define qla1280_dump_buffer(a, b, c) do{}while(0)
604 #define qla1280_print_scsi_cmd(a, b) do{}while(0)
607 #define ENTER(x) dprintk(3, "qla1280 : Entering %s()\n", x);
608 #define LEAVE(x) dprintk(3, "qla1280 : Leaving %s()\n", x);
609 #define ENTER_INTR(x) dprintk(4, "qla1280 : Entering %s()\n", x);
610 #define LEAVE_INTR(x) dprintk(4, "qla1280 : Leaving %s()\n", x);
620 ENTER(
"qla1280_read_nvram");
622 if (driver_setup.no_nvram)
630 for (cnt = 0; cnt < 3; cnt++) {
631 *wptr = qla1280_get_nvram_word(ha, cnt);
632 chksum += *wptr & 0xff;
633 chksum += (*wptr >> 8) & 0xff;
637 if (nv->
id0 !=
'I' || nv->
id1 !=
'S' ||
639 dprintk(2,
"Invalid nvram ID or version!\n");
642 for (; cnt <
sizeof(
struct nvram); cnt++) {
643 *wptr = qla1280_get_nvram_word(ha, cnt);
644 chksum += *wptr & 0xff;
645 chksum += (*wptr >> 8) & 0xff;
650 dprintk(3,
"qla1280_read_nvram: NVRAM Magic ID= %c %c %c %02x"
656 if (!driver_setup.no_nvram)
658 "validate NVRAM checksum, using default "
686 dprintk(1,
"qla1280_read_nvram: Completed Reading NVRAM\n");
687 LEAVE(
"qla1280_read_nvram");
699 static char qla1280_scsi_name_buffer[125];
704 bp = &qla1280_scsi_name_buffer[0];
706 bdp = &ql1280_board_tbl[ha->
devnum];
707 memset(bp, 0,
sizeof(qla1280_scsi_name_buffer));
710 "QLogic %s PCI to SCSI Host Adapter\n"
711 " Firmware version: %2d.%02d.%02d, Driver version %s",
751 status = qla1280_64bit_start_scsi(ha,
sp);
753 status = qla1280_32bit_start_scsi(ha,
sp);
768 static void qla1280_mailbox_timeout(
unsigned long __data)
788 spin_unlock_irq(ha->
host->host_lock);
790 spin_lock_irq(ha->
host->host_lock);
805 return _qla1280_wait_for_single_command(ha, sp, &wait);
832 status = qla1280_wait_for_single_command(ha, sp);
863 int wait_for_target = -1;
866 ENTER(
"qla1280_error_action");
874 dprintk(4,
"error_action %i, istatus 0x%04x\n", action,
877 dprintk(4,
"host_cmd 0x%04x, ictrl 0x%04x, jiffies %li\n",
883 "Handle=0x%p, action=0x%x\n",
903 if (qla1280_verbose) {
905 "scsi(%ld:%d:%d:%d): specified command has "
906 "already completed.\n", ha->
host_no, bus,
914 dprintk(1,
"qla1280: RISC aborting command\n");
921 qla1280_abort_command(ha, sp, found);
927 "scsi(%ld:%d:%d:%d): Queueing device reset "
928 "command.\n", ha->
host_no, bus, target, lun);
929 if (qla1280_device_reset(ha, bus, target) == 0) {
940 if (qla1280_bus_reset(ha, bus) == 0) {
948 if (qla1280_verbose) {
950 "scsi(%ld): Issued ADAPTER RESET\n",
953 "continue automatically\n", ha->
host_no);
955 ha->
flags.reset_active = 1;
957 if (qla1280_abort_isp(ha) != 0) {
961 ha->
flags.reset_active = 0;
974 result = _qla1280_wait_for_single_command(ha, sp, &wait);
976 if (action == ABORT_COMMAND && result !=
SUCCESS) {
978 "scsi(%li:%i:%i:%i): "
979 "Unable to abort command!\n",
980 ha->
host_no, bus, target, lun);
993 if (result ==
SUCCESS && wait_for_bus >= 0) {
994 result = qla1280_wait_for_pending_commands(ha,
995 wait_for_bus, wait_for_target);
998 dprintk(1,
"RESET returning %d\n", result);
1000 LEAVE(
"qla1280_error_action");
1009 qla1280_eh_abort(
struct scsi_cmnd * cmd)
1013 spin_lock_irq(cmd->
device->host->host_lock);
1014 rc = qla1280_error_action(cmd, ABORT_COMMAND);
1015 spin_unlock_irq(cmd->
device->host->host_lock);
1025 qla1280_eh_device_reset(
struct scsi_cmnd *cmd)
1029 spin_lock_irq(cmd->
device->host->host_lock);
1031 spin_unlock_irq(cmd->
device->host->host_lock);
1041 qla1280_eh_bus_reset(
struct scsi_cmnd *cmd)
1045 spin_lock_irq(cmd->
device->host->host_lock);
1046 rc = qla1280_error_action(cmd, BUS_RESET);
1047 spin_unlock_irq(cmd->
device->host->host_lock);
1057 qla1280_eh_adapter_reset(
struct scsi_cmnd *cmd)
1061 spin_lock_irq(cmd->
device->host->host_lock);
1062 rc = qla1280_error_action(cmd, ADAPTER_RESET);
1063 spin_unlock_irq(cmd->
device->host->host_lock);
1076 cylinders = (
unsigned long)capacity / (heads * sectors);
1077 if (cylinders > 1024) {
1080 cylinders = (
unsigned long)capacity / (heads * sectors);
1114 qla1280_intr_handler(
int irq,
void *
dev_id)
1124 spin_lock(ha->
host->host_lock);
1129 qla1280_disable_intrs(ha);
1131 data = qla1280_debounce_register(®->
istatus);
1134 qla1280_isr(ha, &ha->
done_q);
1137 if (!list_empty(&ha->
done_q))
1140 spin_unlock(ha->
host->host_lock);
1142 qla1280_enable_intrs(ha);
1150 qla1280_set_target_parameters(
struct scsi_qla_host *ha,
int bus,
int target)
1164 mb[2] = nv->
bus[
bus].target[
target].parameter.renegotiate_on_error << 8;
1165 mb[2] |= nv->
bus[
bus].target[
target].parameter.stop_queue_on_check << 9;
1166 mb[2] |= nv->
bus[
bus].target[
target].parameter.auto_request_sense << 10;
1167 mb[2] |= nv->
bus[
bus].target[
target].parameter.tag_queuing << 11;
1168 mb[2] |= nv->
bus[
bus].target[
target].parameter.enable_sync << 12;
1169 mb[2] |= nv->
bus[
bus].target[
target].parameter.enable_wide << 13;
1170 mb[2] |= nv->
bus[
bus].target[
target].parameter.parity_checking << 14;
1171 mb[2] |= nv->
bus[
bus].target[
target].parameter.disconnect_allowed << 15;
1174 mb[2] |= nv->
bus[
bus].target[
target].ppr_1x160.flags.enable_ppr << 5;
1175 mb[3] = (nv->
bus[
bus].target[
target].flags.flags1x160.sync_offset << 8);
1176 mb[6] = (nv->
bus[
bus].target[
target].ppr_1x160.flags.ppr_options << 8) |
1177 nv->
bus[bus].target[target].ppr_1x160.flags.ppr_bus_width;
1180 mb[3] = (nv->
bus[
bus].target[
target].flags.flags1x80.sync_offset << 8);
1184 status = qla1280_mailbox_command(ha, mr, mb);
1187 for (lun = 0; lun <
MAX_LUNS; lun++) {
1191 mb[2] = nv->
bus[
bus].max_queue_depth;
1192 mb[3] = nv->
bus[
bus].target[
target].execution_throttle;
1193 status |= qla1280_mailbox_command(ha, 0x0f, mb);
1198 "qla1280_set_target_parameters() failed\n",
1219 int default_depth = 3;
1221 int target = device->
id;
1224 unsigned long flags;
1229 if (qla1280_check_for_dead_scsi_bus(ha, bus))
1244 if (driver_setup.no_sync ||
1245 (driver_setup.sync_mask &&
1246 (~driver_setup.sync_mask & (1 << target))))
1248 if (driver_setup.no_wide ||
1249 (driver_setup.wide_mask &&
1250 (~driver_setup.wide_mask & (1 << target))))
1253 if (driver_setup.no_ppr ||
1254 (driver_setup.ppr_mask &&
1255 (~driver_setup.ppr_mask & (1 << target))))
1256 nv->
bus[
bus].target[
target].ppr_1x160.flags.enable_ppr = 0;
1260 if (nv->
bus[bus].target[target].parameter.enable_sync)
1261 status = qla1280_set_target_parameters(ha, bus, target);
1262 qla1280_get_target_parameters(ha, device);
1263 spin_unlock_irqrestore(ha->
host->host_lock, flags);
1283 ENTER(
"qla1280_done");
1287 while (!list_empty(done_q)) {
1300 if (!ha->
flags.abort_isp_active)
1301 qla1280_marker(ha, bus, target, 0,
MK_SYNC_ID);
1322 LEAVE(
"qla1280_done");
1336 #if DEBUG_QLA1280_INTR
1337 static char *
reason[] = {
1351 ENTER(
"qla1280_return_status");
1353 #if DEBUG_QLA1280_INTR
1360 switch (comp_status) {
1393 dprintk(2,
"Data overrun 0x%x\n", residual_length);
1394 dprintk(2,
"qla1280_return_status: response packet data\n");
1400 if ((scsi_bufflen(cp) - residual_length) <
1403 "scsi: Underflow detected - retrying "
1407 scsi_set_resid(cp, residual_length);
1417 #if DEBUG_QLA1280_INTR
1418 dprintk(1,
"qla1280 ISP status: host status (%s) scsi status %x\n",
1419 reason[host_status], scsi_status);
1422 LEAVE(
"qla1280_return_status");
1424 return (scsi_status & 0xff) | (host_status << 16);
1447 unsigned long flags;
1449 ENTER(
"qla1280_initialize_adapter");
1452 ha->
flags.online = 0;
1453 ha->
flags.disable_host_adapter = 0;
1454 ha->
flags.reset_active = 0;
1455 ha->
flags.abort_isp_active = 0;
1457 #if defined(CONFIG_IA64_GENERIC) || defined(CONFIG_IA64_SGI_SN2)
1460 "dual channel lockup workaround\n", ha->
host_no);
1461 ha->
flags.use_pci_vchannel = 1;
1462 driver_setup.no_nvram = 1;
1468 driver_setup.no_nvram = 1;
1470 dprintk(1,
"Configure PCI space for adapter...\n");
1480 if (qla1280_read_nvram(ha)) {
1481 dprintk(2,
"qla1280_initialize_adapter: failed to read "
1492 status = qla1280_load_firmware(ha);
1500 dprintk(1,
"scsi(%ld): Configure NVRAM parameters\n", ha->
host_no);
1501 qla1280_nvram_config(ha);
1503 if (ha->
flags.disable_host_adapter) {
1508 status = qla1280_init_rings(ha);
1513 for (bus = 0; bus < ha->
ports; bus++) {
1515 qla1280_bus_reset(ha, bus) &&
1516 qla1280_bus_reset(ha, bus))
1520 ha->
flags.online = 1;
1522 spin_unlock_irqrestore(ha->
host->host_lock, flags);
1525 dprintk(2,
"qla1280_initialize_adapter: **** FAILED ****\n");
1527 LEAVE(
"qla1280_initialize_adapter");
1551 spin_unlock_irq(ha->
host->host_lock);
1555 fw = qla1280_fw_tbl[
index].
fw;
1568 if ((fw->
size % 2) || (fw->
size < 6)) {
1584 spin_lock_irq(ha->
host->host_lock);
1606 dprintk(3,
"qla1280_chip_diag: testing device at 0x%p \n", ®->
id_l);
1621 data = qla1280_debounce_register(®->
ictrl);
1625 for (cnt = 1000000; cnt && data &
ISP_RESET; cnt--) {
1634 dprintk(3,
"qla1280_chip_diag: reset register cleared by chip reset\n");
1644 data = qla1280_debounce_register(®->
mailbox0);
1649 for (cnt = 1000000; cnt && data ==
MBS_BUSY; cnt--) {
1658 dprintk(3,
"qla1280_chip_diag: Checking product ID of chip\n");
1666 "0x%x,0x%x,0x%x,0x%x\n",
1677 qla1280_enable_intrs(ha);
1679 dprintk(1,
"qla1280_chip_diag: Checking mailboxes of chip\n");
1690 status = qla1280_mailbox_command(ha, 0xff, mb);
1694 if (mb[1] != 0xAAAA || mb[2] != 0x5555 || mb[3] != 0xAA55 ||
1695 mb[4] != 0x55AA || mb[5] != 0xA5A5 || mb[6] != 0x5A5A ||
1701 dprintk(3,
"qla1280_chip_diag: exiting normally\n");
1704 dprintk(2,
"qla1280_chip_diag: **** FAILED ****\n");
1715 uint16_t risc_address, risc_code_size;
1719 fw = qla1280_request_firmware(ha);
1729 risc_code_size = (fw->
size - 6) / 2;
1731 for (i = 0; i < risc_code_size; i++) {
1733 mb[1] = risc_address +
i;
1747 #define DUMP_IT_BACK 0
1754 uint16_t risc_address, risc_code_size;
1756 int err = 0,
num,
i;
1766 fw = qla1280_request_firmware(ha);
1776 risc_code_size = (fw->
size - 6) / 2;
1778 dprintk(1,
"%s: DMA RISC code (%i) words\n",
1779 __func__, risc_code_size);
1782 while (risc_code_size > 0) {
1787 if (cnt > risc_code_size)
1788 cnt = risc_code_size;
1790 dprintk(2,
"qla1280_setup_chip: loading risc @ =(0x%p),"
1792 fw_data, cnt,
num, risc_address);
1793 for(i = 0; i <
cnt; i++)
1797 mb[1] = risc_address;
1803 dprintk(2,
"%s: op=%d 0x%p = 0x%4x,0x%4x,0x%4x,0x%4x\n",
1806 mb[6], mb[7], mb[2], mb[3]);
1811 "segment of f\n", ha->
host_no);
1817 mb[1] = risc_address;
1819 mb[3] = p_tbuf & 0xffff;
1820 mb[2] = (p_tbuf >> 16) & 0xffff;
1828 "Failed to dump partial segment of f/w\n");
1832 for (i = 0; i < (cnt << 1); i++) {
1833 if (tbuf[i] != sp[i] &&
warn++ < 10) {
1835 "byte(0x%x) loop#=%x\n",
1839 __func__, sp[i], tbuf[i]);
1844 risc_address +=
cnt;
1845 risc_code_size = risc_code_size -
cnt;
1846 fw_data = fw_data +
cnt;
1863 dprintk(1,
"%s: Verifying checksum of loaded RISC code.\n",
1870 err = qla1280_mailbox_command(ha,
BIT_1 |
BIT_0, mb);
1877 dprintk(1,
"%s: start firmware running.\n", __func__);
1880 err = qla1280_mailbox_command(ha,
BIT_1 |
BIT_0, &mb[0]);
1895 err = qla1280_chip_diag(ha);
1899 err = qla1280_load_firmware_pio(ha);
1901 err = qla1280_load_firmware_dma(ha);
1904 err = qla1280_start_firmware(ha);
1928 ENTER(
"qla1280_init_rings");
1932 sizeof(
struct srb *) * MAX_OUTSTANDING_COMMANDS);
1966 dprintk(2,
"qla1280_init_rings: **** FAILED ****\n");
1968 LEAVE(
"qla1280_init_rings");
1973 qla1280_print_settings(
struct nvram *nv)
1975 dprintk(1,
"qla1280 : initiator scsi id bus[0]=%d\n",
1976 nv->
bus[0].config_1.initiator_id);
1977 dprintk(1,
"qla1280 : initiator scsi id bus[1]=%d\n",
1978 nv->
bus[1].config_1.initiator_id);
1980 dprintk(1,
"qla1280 : bus reset delay[0]=%d\n",
1981 nv->
bus[0].bus_reset_delay);
1982 dprintk(1,
"qla1280 : bus reset delay[1]=%d\n",
1983 nv->
bus[1].bus_reset_delay);
1985 dprintk(1,
"qla1280 : retry count[0]=%d\n", nv->
bus[0].retry_count);
1986 dprintk(1,
"qla1280 : retry delay[0]=%d\n", nv->
bus[0].retry_delay);
1987 dprintk(1,
"qla1280 : retry count[1]=%d\n", nv->
bus[1].retry_count);
1988 dprintk(1,
"qla1280 : retry delay[1]=%d\n", nv->
bus[1].retry_delay);
1990 dprintk(1,
"qla1280 : async data setup time[0]=%d\n",
1991 nv->
bus[0].config_2.async_data_setup_time);
1992 dprintk(1,
"qla1280 : async data setup time[1]=%d\n",
1993 nv->
bus[1].config_2.async_data_setup_time);
1995 dprintk(1,
"qla1280 : req/ack active negation[0]=%d\n",
1996 nv->
bus[0].config_2.req_ack_active_negation);
1997 dprintk(1,
"qla1280 : req/ack active negation[1]=%d\n",
1998 nv->
bus[1].config_2.req_ack_active_negation);
2000 dprintk(1,
"qla1280 : data line active negation[0]=%d\n",
2001 nv->
bus[0].config_2.data_line_active_negation);
2002 dprintk(1,
"qla1280 : data line active negation[1]=%d\n",
2003 nv->
bus[1].config_2.data_line_active_negation);
2005 dprintk(1,
"qla1280 : disable loading risc code=%d\n",
2008 dprintk(1,
"qla1280 : enable 64bit addressing=%d\n",
2011 dprintk(1,
"qla1280 : selection timeout limit[0]=%d\n",
2012 nv->
bus[0].selection_timeout);
2013 dprintk(1,
"qla1280 : selection timeout limit[1]=%d\n",
2014 nv->
bus[1].selection_timeout);
2016 dprintk(1,
"qla1280 : max queue depth[0]=%d\n",
2017 nv->
bus[0].max_queue_depth);
2018 dprintk(1,
"qla1280 : max queue depth[1]=%d\n",
2019 nv->
bus[1].max_queue_depth);
2023 qla1280_set_target_defaults(
struct scsi_qla_host *ha,
int bus,
int target)
2027 nv->
bus[
bus].target[
target].parameter.renegotiate_on_error = 1;
2028 nv->
bus[
bus].target[
target].parameter.auto_request_sense = 1;
2035 nv->
bus[
bus].max_queue_depth - 1;
2036 nv->
bus[
bus].target[
target].parameter.parity_checking = 1;
2037 nv->
bus[
bus].target[
target].parameter.disconnect_allowed = 1;
2040 nv->
bus[
bus].target[
target].flags.flags1x160.device_enable = 1;
2041 nv->
bus[
bus].target[
target].flags.flags1x160.sync_offset = 0x0e;
2043 nv->
bus[
bus].target[
target].ppr_1x160.flags.enable_ppr = 1;
2044 nv->
bus[
bus].target[
target].ppr_1x160.flags.ppr_options = 2;
2045 nv->
bus[
bus].target[
target].ppr_1x160.flags.ppr_bus_width = 1;
2047 nv->
bus[
bus].target[
target].flags.flags1x80.device_enable = 1;
2048 nv->
bus[
bus].target[
target].flags.flags1x80.sync_offset = 12;
2059 dprintk(1,
"Using defaults for NVRAM: \n");
2087 nv->
bus[
bus].config_1.initiator_id = 7;
2088 nv->
bus[
bus].config_2.req_ack_active_negation = 1;
2089 nv->
bus[
bus].config_2.data_line_active_negation = 1;
2090 nv->
bus[
bus].selection_timeout = 250;
2091 nv->
bus[
bus].max_queue_depth = 32;
2094 nv->
bus[
bus].bus_reset_delay = 3;
2095 nv->
bus[
bus].config_2.async_data_setup_time = 6;
2096 nv->
bus[
bus].retry_delay = 1;
2098 nv->
bus[
bus].bus_reset_delay = 5;
2099 nv->
bus[
bus].config_2.async_data_setup_time = 8;
2103 qla1280_set_target_defaults(ha, bus, target);
2108 qla1280_config_target(
struct scsi_qla_host *ha,
int bus,
int target)
2128 mb[3] = nv->
bus[bus].target[target].flags.flags1x160.sync_offset << 8;
2130 mb[3] = nv->
bus[bus].target[target].flags.flags1x80.sync_offset << 8;
2131 mb[3] |= nv->
bus[bus].target[target].sync_period;
2132 status = qla1280_mailbox_command(ha, 0x0f, mb);
2136 if (nv->
bus[bus].target[target].parameter.tag_queuing)
2141 if (nv->
bus[bus].target[target].flags.flags1x160.device_enable)
2145 if (nv->
bus[bus].target[target].flags.flags1x80.device_enable)
2148 if (nv->
bus[bus].target[target].flags.flags1x80.lun_disable)
2153 for (lun = 0; lun <
MAX_LUNS; lun++) {
2157 mb[2] = nv->
bus[
bus].max_queue_depth;
2158 mb[3] = nv->
bus[
bus].target[
target].execution_throttle;
2159 status |= qla1280_mailbox_command(ha, 0x0f, mb);
2174 nv->
bus[
bus].config_1.scsi_reset_disable;
2181 status = qla1280_mailbox_command(ha,
BIT_1 |
BIT_0, &mb[0]);
2185 nv->
bus[
bus].bus_reset_delay;
2192 status |= qla1280_config_target(ha, bus, target);
2205 ENTER(
"qla1280_nvram_config");
2210 for (target = 0; target <
MAX_TARGETS; target++) {
2215 qla1280_set_defaults(ha);
2218 qla1280_print_settings(nv);
2221 ha->
flags.disable_risc_code_load =
2225 uint16_t hwrev, cfg1, cdma_conf, ddma_conf;
2267 status |= qla1280_mailbox_command(ha,
BIT_1 |
BIT_0, &mb[0]);
2273 status |= qla1280_mailbox_command(ha,
BIT_1 |
BIT_0, mb);
2281 #if defined(CONFIG_IA64_GENERIC) || defined (CONFIG_IA64_SGI_SN2)
2288 status |= qla1280_mailbox_command(ha,
BIT_1 |
BIT_0, mb);
2292 mb[1] = nv->
bus[0].retry_count;
2293 mb[2] = nv->
bus[0].retry_delay;
2294 mb[6] = nv->
bus[1].retry_count;
2295 mb[7] = nv->
bus[1].retry_delay;
2301 mb[1] = nv->
bus[0].config_2.async_data_setup_time;
2302 mb[2] = nv->
bus[1].config_2.async_data_setup_time;
2308 if (nv->
bus[0].config_2.req_ack_active_negation)
2310 if (nv->
bus[0].config_2.data_line_active_negation)
2313 if (nv->
bus[1].config_2.req_ack_active_negation)
2315 if (nv->
bus[1].config_2.data_line_active_negation)
2321 status |= qla1280_mailbox_command(ha,
BIT_1 |
BIT_0, mb);
2331 status |= qla1280_mailbox_command(ha,
BIT_1 |
BIT_0, mb);
2335 mb[1] = nv->
bus[0].selection_timeout;
2336 mb[2] = nv->
bus[1].selection_timeout;
2339 for (bus = 0; bus < ha->
ports; bus++)
2340 status |= qla1280_config_bus(ha, bus);
2343 dprintk(2,
"qla1280_nvram_config: **** FAILED ****\n");
2345 LEAVE(
"qla1280_nvram_config");
2367 nv_cmd = address << 16;
2370 data =
le16_to_cpu(qla1280_nvram_request(ha, nv_cmd));
2372 dprintk(8,
"qla1280_get_nvram_word: exiting normally NVRAM data = "
2403 for (cnt = 0; cnt < 11; cnt++) {
2407 qla1280_nv_write(ha, 0);
2413 for (cnt = 0; cnt < 16; cnt++) {
2478 ENTER(
"qla1280_mailbox_command");
2508 timer.function = qla1280_mailbox_timeout;
2511 spin_unlock_irq(ha->
host->host_lock);
2513 data = qla1280_debounce_register(®->
istatus);
2518 spin_lock_irq(ha->
host->host_lock);
2525 "mailbox0 = 0x%04x, mailbox_out0 = 0x%04x, istatus = "
2540 mr = MAILBOX_REGISTER_COUNT;
2543 if (ha->
flags.reset_marker)
2544 qla1280_rst_aen(ha);
2547 dprintk(2,
"qla1280_mailbox_command: **** FAILED, mailbox0 = "
2548 "0x%x ****\n", mb[0]);
2550 LEAVE(
"qla1280_mailbox_command");
2572 if (data & RISC_INT)
2573 qla1280_isr(ha, &done_q);
2576 if (ha->
flags.reset_marker)
2577 qla1280_rst_aen(ha);
2580 if (!list_empty(&done_q))
2604 dprintk(3,
"qla1280_bus_reset: entered\n");
2606 if (qla1280_verbose)
2612 mb[1] = reset_delay;
2614 status = qla1280_mailbox_command(ha,
BIT_2 |
BIT_1 | BIT_0, &mb[0]);
2621 spin_unlock_irq(ha->
host->host_lock);
2622 ssleep(reset_delay);
2623 spin_lock_irq(ha->
host->host_lock);
2638 dprintk(2,
"qla1280_bus_reset: **** FAILED ****\n");
2640 dprintk(3,
"qla1280_bus_reset: exiting normally\n");
2658 qla1280_device_reset(
struct scsi_qla_host *ha,
int bus,
int target)
2663 ENTER(
"qla1280_device_reset");
2666 mb[1] = (bus ? (target |
BIT_7) : target) << 8;
2668 status = qla1280_mailbox_command(ha,
BIT_2 |
BIT_1 | BIT_0, &mb[0]);
2671 qla1280_marker(ha, bus, target, 0,
MK_SYNC_ID);
2674 dprintk(2,
"qla1280_device_reset: **** FAILED ****\n");
2676 LEAVE(
"qla1280_device_reset");
2698 ENTER(
"qla1280_abort_command");
2707 mb[1] = (bus ? target |
BIT_7 :
target) << 8 | lun;
2708 mb[2] = handle >> 16;
2709 mb[3] = handle & 0xffff;
2710 status = qla1280_mailbox_command(ha, 0x0f, &mb[0]);
2713 dprintk(2,
"qla1280_abort_command: **** FAILED ****\n");
2718 LEAVE(
"qla1280_abort_command");
2734 ENTER(
"qla1280_reset_adapter");
2737 ha->
flags.online = 0;
2743 LEAVE(
"qla1280_reset_adapter");
2762 ENTER(
"qla1280_marker");
2765 if ((pkt = (
struct mrk_entry *) qla1280_req_pkt(ha))) {
2773 qla1280_isp_cmd(ha);
2776 LEAVE(
"qla1280_marker");
2792 #ifdef QLA_64BIT_PTR
2807 ENTER(
"qla1280_64bit_start_scsi:");
2814 req_cnt += (seg_cnt - 2) / 5;
2815 if ((seg_cnt - 2) % 5)
2818 }
else if (seg_cnt < 0) {
2833 dprintk(3,
"Number of free entries=(%d) seg_cnt=0x%x\n",
2839 dprintk(2,
"qla1280_start_scsi: in-ptr=0x%x req_q_cnt="
2846 for (cnt = 0; cnt < MAX_OUTSTANDING_COMMANDS &&
2849 if (cnt >= MAX_OUTSTANDING_COMMANDS) {
2851 dprintk(2,
"qla1280_start_scsi: NO ROOM IN "
2852 "OUTSTANDING ARRAY, req_q_cnt=0x%x", ha->
req_q_cnt);
2858 CMD_HANDLE(sp->
cmd) = (
unsigned char *)(
unsigned long)(cnt + 1);
2860 dprintk(2,
"start: cmd=%p sp=%p CDB=%xm, handle %lx\n", cmd, sp,
2862 dprintk(2,
" bus %i, target %i, lun %i\n",
2889 if (cmd->
device->simple_tags)
2898 dir = qla1280_data_direction(cmd);
2909 int remseg = seg_cnt;
2911 sg = scsi_sglist(cmd);
2922 #if defined(CONFIG_IA64_GENERIC) || defined(CONFIG_IA64_SGI_SN2)
2923 if (ha->
flags.use_pci_vchannel)
2924 sn_pci_set_vchan(ha->
pdev,
2925 (
unsigned long *)&dma_handle,
2933 dprintk(3,
"S/G Segment phys_addr=%x %x, len=0x%x\n",
2939 dprintk(5,
"qla1280_64bit_start_scsi: Scatter/gather "
2940 "command packet data - b %i, t %i, l %i \n",
2949 dprintk(3,
"S/G Building Continuation...seg_cnt=0x%x "
2950 "remains\n", seg_cnt);
2952 while (remseg > 0) {
2984 #if defined(CONFIG_IA64_GENERIC) || defined(CONFIG_IA64_SGI_SN2)
2985 if (ha->
flags.use_pci_vchannel)
2986 sn_pci_set_vchan(ha->
pdev,
2987 (
unsigned long *)&dma_handle,
2996 dprintk(3,
"S/G Segment Cont. phys_addr=%x %x, len=0x%x\n",
3002 dprintk(5,
"qla1280_64bit_start_scsi: "
3003 "continuation packet data - b %i, t "
3010 dprintk(5,
"qla1280_64bit_start_scsi: No data, command "
3011 "packet data - b %i, t %i, l %i \n",
3025 "qla1280_64bit_start_scsi: Wakeup RISC for pending command\n");
3034 dprintk(2,
"qla1280_64bit_start_scsi: **** FAILED ****\n");
3036 dprintk(3,
"qla1280_64bit_start_scsi: exiting normally\n");
3074 ENTER(
"qla1280_32bit_start_scsi");
3076 dprintk(1,
"32bit_start: cmd=%p sp=%p CDB=%x\n", cmd, sp,
3088 req_cnt += (seg_cnt - 4) / 7;
3089 if ((seg_cnt - 4) % 7)
3092 dprintk(3,
"S/G Transfer cmd=%p seg_cnt=0x%x, req_cnt=%x\n",
3093 cmd, seg_cnt, req_cnt);
3094 }
else if (seg_cnt < 0) {
3109 dprintk(3,
"Number of free entries=(%d) seg_cnt=0x%x\n",
3114 dprintk(2,
"qla1280_32bit_start_scsi: in-ptr=0x%x, "
3121 for (cnt = 0; cnt < MAX_OUTSTANDING_COMMANDS &&
3124 if (cnt >= MAX_OUTSTANDING_COMMANDS) {
3126 dprintk(2,
"qla1280_32bit_start_scsi: NO ROOM IN OUTSTANDING "
3127 "ARRAY, req_q_cnt=0x%x\n", ha->
req_q_cnt);
3131 CMD_HANDLE(sp->
cmd) = (
unsigned char *) (
unsigned long)(cnt + 1);
3158 if (cmd->
device->simple_tags)
3167 dir = qla1280_data_direction(cmd);
3178 int remseg = seg_cnt;
3180 sg = scsi_sglist(cmd);
3185 dprintk(3,
"Building S/G data segments..\n");
3195 dprintk(3,
"S/G Segment phys_addr=0x%lx, len=0x%x\n",
3203 dprintk(3,
"S/G Building Continuation"
3204 "...seg_cnt=0x%x remains\n", seg_cnt);
3205 while (remseg > 0) {
3225 ((
struct cont_entry *) pkt)->entry_count = 1;
3243 "S/G Segment Cont. phys_addr=0x%x, "
3249 dprintk(5,
"qla1280_32bit_start_scsi: "
3250 "continuation packet data - "
3257 dprintk(5,
"qla1280_32bit_start_scsi: No data, command "
3258 "packet data - \n");
3261 dprintk(5,
"qla1280_32bit_start_scsi: First IOCB block:\n");
3274 dprintk(2,
"qla1280_32bit_start_scsi: Wakeup RISC "
3275 "for pending command\n");
3284 dprintk(2,
"qla1280_32bit_start_scsi: **** FAILED ****\n");
3286 LEAVE(
"qla1280_32bit_start_scsi");
3311 ENTER(
"qla1280_req_pkt");
3317 for (timer = 15000000;
timer; timer--) {
3356 dprintk(2,
"qla1280_req_pkt: **** FAILED ****\n");
3358 dprintk(3,
"qla1280_req_pkt: exiting normally\n");
3376 ENTER(
"qla1280_isp_cmd");
3378 dprintk(5,
"qla1280_isp_cmd: IOCB data:\n");
3406 LEAVE(
"qla1280_isp_cmd");
3432 ENTER(
"qla1280_isr");
3435 if (!(istatus & (RISC_INT |
PCI_INT)))
3445 if (mailbox[0] & BIT_0) {
3467 dprintk(5,
"qla1280_isr: mailbox interrupt mailbox[0] = 0x%x",
3471 switch (mailbox[0]) {
3473 dprintk(5,
"qla1280_isr: mailbox SCSI response "
3476 if (ha->
flags.online) {
3478 index = mailbox[2] << 16 | mailbox[1];
3481 if (index < MAX_OUTSTANDING_COMMANDS)
3501 "qla1280: ISP invalid handle\n");
3507 ha->
flags.reset_marker = 1;
3508 index = mailbox[6] &
BIT_0;
3512 "asynchronous BUS_RESET\n", index);
3517 "qla1280: ISP System Error - mbx1=%xh, mbx2="
3518 "%xh, mbx3=%xh\n", mailbox[1], mailbox[2],
3524 "qla1280: ISP Request Transfer Error\n");
3529 "qla1280: ISP Response Transfer Error\n");
3533 dprintk(2,
"qla1280_isr: asynchronous WAKEUP_THRES\n");
3538 "qla1280_isr: asynchronous TIMEOUT_RESET\n");
3543 "BUS_DEVICE_RESET\n");
3545 ha->
flags.reset_marker = 1;
3546 index = mailbox[6] &
BIT_0;
3552 "qla1280_isr: asynchronous BUS_MODE_CHANGE\n");
3560 MAILBOX_REGISTER_COUNT *
3577 dprintk(2,
"qla1280_isr: Response pointer Error\n");
3587 dprintk(5,
"qla1280_isr: ha->rsp_ring_index = 0x%x, mailbox[5]"
3589 dprintk(5,
"qla1280_isr: response packet data\n");
3595 dprintk(2,
"qla1280_isr: ha->rsp_ring_index = "
3596 "0x%x mailbox[5] = 0x%x, comp_status "
3597 "= 0x%x, scsi_status = 0x%x\n",
3603 dprintk(2,
"qla1280_isr: ha->rsp_ring_index = "
3604 "0x%x, mailbox[5] = 0x%x\n",
3606 dprintk(2,
"qla1280_isr: response packet data\n");
3612 dprintk(2,
"status: Cmd %p, handle %i\n",
3616 qla1280_status_entry(ha, pkt, done_q);
3618 qla1280_error_entry(ha, pkt, done_q);
3631 LEAVE(
"qla1280_isr");
3646 ENTER(
"qla1280_rst_aen");
3648 if (ha->
flags.online && !ha->
flags.reset_active &&
3649 !ha->
flags.abort_isp_active) {
3650 ha->
flags.reset_active = 1;
3651 while (ha->
flags.reset_marker) {
3653 ha->
flags.reset_marker = 0;
3654 for (bus = 0; bus < ha->
ports &&
3655 !ha->
flags.reset_marker; bus++) {
3658 qla1280_marker(ha, bus, 0, 0,
3665 LEAVE(
"qla1280_rst_aen");
3690 ENTER(
"qla1280_status_entry");
3693 if (handle < MAX_OUTSTANDING_COMMANDS)
3713 if (comp_status || scsi_status) {
3714 dprintk(3,
"scsi: comp_status = 0x%x, scsi_status = "
3715 "0x%x, handle = 0x%x\n", comp_status,
3716 scsi_status, handle);
3726 CMD_RESULT(cmd) = qla1280_return_status(pkt, cmd);
3733 sense_sz = req_sense_length;
3749 dprintk(2,
"qla1280_status_entry: Check "
3750 "condition Sense data, b %i, t %i, "
3751 "l %i\n", bus, target, lun);
3764 LEAVE(
"qla1280_status_entry");
3783 ENTER(
"qla1280_error_entry");
3786 dprintk(2,
"qla1280_error_entry: BAD PAYLOAD flag error\n");
3788 dprintk(2,
"qla1280_error_entry: BAD HEADER flag error\n");
3790 dprintk(2,
"qla1280_error_entry: FULL flag error\n");
3792 dprintk(2,
"qla1280_error_entry: UNKNOWN flag error\n");
3795 if (handle < MAX_OUTSTANDING_COMMANDS)
3821 #ifdef QLA_64BIT_PTR
3827 LEAVE(
"qla1280_error_entry");
3849 ENTER(
"qla1280_abort_isp");
3851 if (ha->
flags.abort_isp_active || !ha->
flags.online)
3854 ha->
flags.abort_isp_active = 1;
3857 qla1280_disable_intrs(ha);
3878 status = qla1280_load_firmware(ha);
3883 qla1280_nvram_config (ha);
3885 status = qla1280_init_rings(ha);
3890 for (bus = 0; bus < ha->
ports; bus++)
3891 qla1280_bus_reset(ha, bus);
3893 ha->
flags.abort_isp_active = 0;
3897 "qla1280: ISP error recovery failed, board disabled");
3898 qla1280_reset_adapter(ha);
3899 dprintk(2,
"qla1280_abort_isp: **** FAILED ****\n");
3902 LEAVE(
"qla1280_abort_isp");
3933 }
while (ret != ret2);
3944 #define SET_SXP_BANK 0x0100
3945 #define SCSI_PHASE_INVALID 0x87FF
3947 qla1280_check_for_dead_scsi_bus(
struct scsi_qla_host *ha,
unsigned int bus)
3979 target = device->
id;
3992 printk(
" Sync: period %d, offset %d",
3993 (mb[3] & 0xff), (mb[3] >> 8));
3996 if ((mb[2] &
BIT_5) && ((mb[6] >> 8) & 0xff) >= 2)
4009 __qla1280_dump_buffer(
char *
b,
int size)
4015 "Bh Ch Dh Eh Fh\n");
4017 "------------------\n");
4019 for (cnt = 0; cnt <
size;) {
4038 __qla1280_print_scsi_cmd(
struct scsi_cmnd *cmd)
4050 printk(
" chan=%d, target = 0x%02x, lun = 0x%02x, cmd_len = 0x%02x\n",
4054 for (i = 0; i < cmd->
cmd_len; i++) {
4057 printk(
" seg_cnt =%d\n", scsi_sg_count(cmd));
4058 printk(
" request buffer=0x%p, request buffer len=0x%x\n",
4059 scsi_sglist(cmd), scsi_bufflen(cmd));
4066 printk(
" tag=%d, transfersize=0x%x \n",
4069 printk(
" underflow size = 0x%x, direction=0x%x\n",
4130 qla1280_setup(
char *s)
4138 while (cp && (ptr =
strchr(cp,
':'))) {
4140 if (!
strcmp(ptr,
"yes")) {
4143 }
else if (!
strcmp(ptr,
"no")) {
4149 switch ((toke = qla1280_get_token(cp))) {
4152 driver_setup.no_nvram = 1;
4156 driver_setup.no_sync = 1;
4157 else if (val != 0x10000)
4158 driver_setup.sync_mask =
val;
4162 driver_setup.no_wide = 1;
4163 else if (val != 0x10000)
4164 driver_setup.wide_mask =
val;
4168 driver_setup.no_ppr = 1;
4169 else if (val != 0x10000)
4170 driver_setup.ppr_mask =
val;
4173 qla1280_verbose =
val;
4192 qla1280_get_token(
char *
str)
4201 for (i = 0; i <
ARRAY_SIZE(setup_token); i++) {
4202 if (!
strncmp(setup_token[i].
token, str, (sep - str))) {
4203 ret = setup_token[
i].val;
4215 .proc_name =
"qla1280",
4216 .name =
"Qlogic ISP 1280/12160",
4217 .info = qla1280_info,
4218 .slave_configure = qla1280_slave_configure,
4219 .queuecommand = qla1280_queuecommand,
4220 .eh_abort_handler = qla1280_eh_abort,
4221 .eh_device_reset_handler= qla1280_eh_device_reset,
4222 .eh_bus_reset_handler = qla1280_eh_bus_reset,
4223 .eh_host_reset_handler = qla1280_eh_adapter_reset,
4224 .bios_param = qla1280_biosparam,
4225 .can_queue = 0xfffff,
4236 int devnum =
id->driver_data;
4245 "qla1280: Skipping AMI SubSys Vendor ID Chip\n");
4254 "qla1280: Failed to enabled pci device, aborting.\n");
4264 "qla1280: Failed to register host, aborting.\n");
4265 goto error_disable_device;
4274 #ifdef QLA_64BIT_PTR
4278 "suitable DMA mask - aborting\n", ha->
host_no);
4280 goto error_put_host;
4283 dprintk(2,
"scsi(%li): 64 Bit PCI Addressing Enabled\n",
4288 "suitable DMA mask - aborting\n", ha->
host_no);
4290 goto error_put_host;
4299 goto error_put_host;
4307 goto error_free_request_ring;
4324 #if MEMORY_MAPPED_IO
4328 goto error_free_response_ring;
4337 "0x%04lx-0x%04lx - already in use\n",
4339 goto error_free_response_ring;
4345 INIT_LIST_HEAD(&ha->
done_q);
4348 qla1280_disable_intrs(ha);
4352 printk(
"qla1280 : Failed to reserve interrupt %d already "
4353 "in use\n", pdev->
irq);
4354 goto error_release_region;
4358 if (qla1280_initialize_adapter(ha)) {
4360 goto error_free_irq;
4366 pci_set_drvdata(pdev, host);
4368 error = scsi_add_host(host, &pdev->
dev);
4370 goto error_disable_adapter;
4375 error_disable_adapter:
4376 qla1280_disable_intrs(ha);
4379 error_release_region:
4380 #if MEMORY_MAPPED_IO
4385 error_free_response_ring:
4389 error_free_request_ring:
4395 error_disable_device:
4403 qla1280_remove_one(
struct pci_dev *pdev)
4405 struct Scsi_Host *host = pci_get_drvdata(pdev);
4410 qla1280_disable_intrs(ha);
4414 #if MEMORY_MAPPED_IO
4432 static struct pci_driver qla1280_pci_driver = {
4434 .id_table = qla1280_pci_tbl,
4435 .probe = qla1280_probe_one,
4444 "qla1280: struct srb too big, aborting\n");
4462 qla1280_setup(qla1280);
4465 return pci_register_driver(&qla1280_pci_driver);