Lines Matching refs:ha

379 #define IS_ISP1040(ha) (ha->pdev->device == PCI_DEVICE_ID_QLOGIC_ISP1020)  argument
380 #define IS_ISP1x40(ha) (ha->pdev->device == PCI_DEVICE_ID_QLOGIC_ISP1020 || \ argument
381 ha->pdev->device == PCI_DEVICE_ID_QLOGIC_ISP1240)
382 #define IS_ISP1x160(ha) (ha->pdev->device == PCI_DEVICE_ID_QLOGIC_ISP10160 || \ argument
383 ha->pdev->device == PCI_DEVICE_ID_QLOGIC_ISP12160)
570 static int qla1280_read_nvram(struct scsi_qla_host *ha) in qla1280_read_nvram() argument
582 printk(KERN_INFO "scsi(%ld): Reading NVRAM\n", ha->host_no); in qla1280_read_nvram()
584 wptr = (uint16_t *)&ha->nvram; in qla1280_read_nvram()
585 nv = &ha->nvram; in qla1280_read_nvram()
588 *wptr = qla1280_get_nvram_word(ha, cnt); in qla1280_read_nvram()
600 *wptr = qla1280_get_nvram_word(ha, cnt); in qla1280_read_nvram()
616 "settings\n", ha->host_no); in qla1280_read_nvram()
617 ha->nvram_valid = 0; in qla1280_read_nvram()
619 ha->nvram_valid = 1; in qla1280_read_nvram()
658 struct scsi_qla_host *ha; in qla1280_info() local
662 ha = (struct scsi_qla_host *)host->hostdata; in qla1280_info()
663 bdp = &ql1280_board_tbl[ha->devnum]; in qla1280_info()
669 &bdp->name[0], ha->fwver1, ha->fwver2, ha->fwver3, in qla1280_info()
688 struct scsi_qla_host *ha = (struct scsi_qla_host *)host->hostdata; in qla1280_queuecommand_lck() local
706 status = qla1280_64bit_start_scsi(ha, sp); in qla1280_queuecommand_lck()
708 status = qla1280_32bit_start_scsi(ha, sp); in qla1280_queuecommand_lck()
725 struct scsi_qla_host *ha = from_timer(ha, t, mailbox_timer); in qla1280_mailbox_timeout() local
727 reg = ha->iobase; in qla1280_mailbox_timeout()
729 ha->mailbox_out[0] = RD_REG_WORD(&reg->mailbox0); in qla1280_mailbox_timeout()
731 "ictrl %04x, istatus %04x\n", ha->host_no, ha->mailbox_out[0], in qla1280_mailbox_timeout()
733 complete(ha->mailbox_wait); in qla1280_mailbox_timeout()
737 _qla1280_wait_for_single_command(struct scsi_qla_host *ha, struct srb *sp, in _qla1280_wait_for_single_command() argument
743 spin_unlock_irq(ha->host->host_lock); in _qla1280_wait_for_single_command()
745 spin_lock_irq(ha->host->host_lock); in _qla1280_wait_for_single_command()
755 qla1280_wait_for_single_command(struct scsi_qla_host *ha, struct srb *sp) in qla1280_wait_for_single_command() argument
760 return _qla1280_wait_for_single_command(ha, sp, &wait); in qla1280_wait_for_single_command()
764 qla1280_wait_for_pending_commands(struct scsi_qla_host *ha, int bus, int target) in qla1280_wait_for_pending_commands() argument
778 sp = ha->outstanding_cmds[cnt]; in qla1280_wait_for_pending_commands()
787 status = qla1280_wait_for_single_command(ha, sp); in qla1280_wait_for_pending_commands()
812 struct scsi_qla_host *ha; in qla1280_error_action() local
823 ha = (struct scsi_qla_host *)(CMD_HOST(cmd)->hostdata); in qla1280_error_action()
830 RD_REG_WORD(&ha->iobase->istatus)); in qla1280_error_action()
833 RD_REG_WORD(&ha->iobase->host_cmd), in qla1280_error_action()
834 RD_REG_WORD(&ha->iobase->ictrl), jiffies); in qla1280_error_action()
839 ha->host_no, cmd, CMD_HANDLE(cmd), action); in qla1280_error_action()
849 if (sp == ha->outstanding_cmds[i]) { in qla1280_error_action()
861 "already completed.\n", ha->host_no, bus, in qla1280_error_action()
876 qla1280_abort_command(ha, sp, found); in qla1280_error_action()
883 "command.\n", ha->host_no, bus, target, lun); in qla1280_error_action()
884 if (qla1280_device_reset(ha, bus, target) == 0) { in qla1280_error_action()
894 "reset.\n", ha->host_no, bus); in qla1280_error_action()
895 if (qla1280_bus_reset(ha, bus) == 0) { in qla1280_error_action()
906 ha->host_no); in qla1280_error_action()
908 "continue automatically\n", ha->host_no); in qla1280_error_action()
910 ha->flags.reset_active = 1; in qla1280_error_action()
912 if (qla1280_abort_isp(ha) != 0) { /* it's dead */ in qla1280_error_action()
916 ha->flags.reset_active = 0; in qla1280_error_action()
929 result = _qla1280_wait_for_single_command(ha, sp, &wait); in qla1280_error_action()
935 ha->host_no, bus, target, lun); in qla1280_error_action()
949 result = qla1280_wait_for_pending_commands(ha, in qla1280_error_action()
1050 qla1280_disable_intrs(struct scsi_qla_host *ha) in qla1280_disable_intrs() argument
1052 WRT_REG_WORD(&ha->iobase->ictrl, 0); in qla1280_disable_intrs()
1053 RD_REG_WORD(&ha->iobase->ictrl); /* PCI Posted Write flush */ in qla1280_disable_intrs()
1058 qla1280_enable_intrs(struct scsi_qla_host *ha) in qla1280_enable_intrs() argument
1060 WRT_REG_WORD(&ha->iobase->ictrl, (ISP_EN_INT | ISP_EN_RISC)); in qla1280_enable_intrs()
1061 RD_REG_WORD(&ha->iobase->ictrl); /* PCI Posted Write flush */ in qla1280_enable_intrs()
1071 struct scsi_qla_host *ha; in qla1280_intr_handler() local
1077 ha = (struct scsi_qla_host *)dev_id; in qla1280_intr_handler()
1079 spin_lock(ha->host->host_lock); in qla1280_intr_handler()
1081 ha->isr_count++; in qla1280_intr_handler()
1082 reg = ha->iobase; in qla1280_intr_handler()
1084 qla1280_disable_intrs(ha); in qla1280_intr_handler()
1089 qla1280_isr(ha, &ha->done_q); in qla1280_intr_handler()
1092 if (!list_empty(&ha->done_q)) in qla1280_intr_handler()
1093 qla1280_done(ha); in qla1280_intr_handler()
1095 spin_unlock(ha->host->host_lock); in qla1280_intr_handler()
1097 qla1280_enable_intrs(ha); in qla1280_intr_handler()
1105 qla1280_set_target_parameters(struct scsi_qla_host *ha, int bus, int target) in qla1280_set_target_parameters() argument
1112 nv = &ha->nvram; in qla1280_set_target_parameters()
1128 if (IS_ISP1x160(ha)) { in qla1280_set_target_parameters()
1139 status = qla1280_mailbox_command(ha, mr, mb); in qla1280_set_target_parameters()
1148 status |= qla1280_mailbox_command(ha, 0x0f, mb); in qla1280_set_target_parameters()
1154 ha->host_no, bus, target); in qla1280_set_target_parameters()
1173 struct scsi_qla_host *ha; in qla1280_slave_configure() local
1181 ha = (struct scsi_qla_host *)device->host->hostdata; in qla1280_slave_configure()
1182 nv = &ha->nvram; in qla1280_slave_configure()
1184 if (qla1280_check_for_dead_scsi_bus(ha, bus)) in qla1280_slave_configure()
1188 (ha->bus_settings[bus].qtag_enables & (BIT_0 << target))) { in qla1280_slave_configure()
1189 scsi_change_queue_depth(device, ha->bus_settings[bus].hiwat); in qla1280_slave_configure()
1206 if (IS_ISP1x160(ha)) { in qla1280_slave_configure()
1213 spin_lock_irqsave(ha->host->host_lock, flags); in qla1280_slave_configure()
1215 status = qla1280_set_target_parameters(ha, bus, target); in qla1280_slave_configure()
1216 qla1280_get_target_parameters(ha, device); in qla1280_slave_configure()
1217 spin_unlock_irqrestore(ha->host->host_lock, flags); in qla1280_slave_configure()
1230 qla1280_done(struct scsi_qla_host *ha) in qla1280_done() argument
1239 done_q = &ha->done_q; in qla1280_done()
1253 if (!ha->flags.abort_isp_active) in qla1280_done()
1254 qla1280_marker(ha, bus, target, 0, MK_SYNC_ID); in qla1280_done()
1268 ha->actthreads--; in qla1280_done()
1395 qla1280_initialize_adapter(struct scsi_qla_host *ha) in qla1280_initialize_adapter() argument
1405 ha->flags.online = 0; in qla1280_initialize_adapter()
1406 ha->flags.disable_host_adapter = 0; in qla1280_initialize_adapter()
1407 ha->flags.reset_active = 0; in qla1280_initialize_adapter()
1408 ha->flags.abort_isp_active = 0; in qla1280_initialize_adapter()
1411 if (IS_ISP1040(ha)) in qla1280_initialize_adapter()
1416 reg = ha->iobase; in qla1280_initialize_adapter()
1424 if (qla1280_read_nvram(ha)) { in qla1280_initialize_adapter()
1434 spin_lock_irqsave(ha->host->host_lock, flags); in qla1280_initialize_adapter()
1436 status = qla1280_load_firmware(ha); in qla1280_initialize_adapter()
1439 ha->host_no); in qla1280_initialize_adapter()
1444 dprintk(1, "scsi(%ld): Configure NVRAM parameters\n", ha->host_no); in qla1280_initialize_adapter()
1445 qla1280_nvram_config(ha); in qla1280_initialize_adapter()
1447 if (ha->flags.disable_host_adapter) { in qla1280_initialize_adapter()
1452 status = qla1280_init_rings(ha); in qla1280_initialize_adapter()
1457 for (bus = 0; bus < ha->ports; bus++) { in qla1280_initialize_adapter()
1458 if (!ha->bus_settings[bus].disable_scsi_reset && in qla1280_initialize_adapter()
1459 qla1280_bus_reset(ha, bus) && in qla1280_initialize_adapter()
1460 qla1280_bus_reset(ha, bus)) in qla1280_initialize_adapter()
1461 ha->bus_settings[bus].scsi_bus_dead = 1; in qla1280_initialize_adapter()
1464 ha->flags.online = 1; in qla1280_initialize_adapter()
1466 spin_unlock_irqrestore(ha->host->host_lock, flags); in qla1280_initialize_adapter()
1488 qla1280_request_firmware(struct scsi_qla_host *ha) in qla1280_request_firmware() argument
1495 spin_unlock_irq(ha->host->host_lock); in qla1280_request_firmware()
1498 index = ql1280_board_tbl[ha->devnum].fw_index; in qla1280_request_firmware()
1504 err = request_firmware(&fw, fwname, &ha->pdev->dev); in qla1280_request_firmware()
1523 ha->fwver1 = fw->data[0]; in qla1280_request_firmware()
1524 ha->fwver2 = fw->data[1]; in qla1280_request_firmware()
1525 ha->fwver3 = fw->data[2]; in qla1280_request_firmware()
1528 spin_lock_irq(ha->host->host_lock); in qla1280_request_firmware()
1543 qla1280_chip_diag(struct scsi_qla_host *ha) in qla1280_chip_diag() argument
1546 struct device_reg __iomem *reg = ha->iobase; in qla1280_chip_diag()
1552 dprintk(1, "scsi(%ld): Verifying chip\n", ha->host_no); in qla1280_chip_diag()
1621 qla1280_enable_intrs(ha); in qla1280_chip_diag()
1634 status = qla1280_mailbox_command(ha, 0xff, mb); in qla1280_chip_diag()
1653 qla1280_load_firmware_pio(struct scsi_qla_host *ha) in qla1280_load_firmware_pio() argument
1663 fw = qla1280_request_firmware(ha); in qla1280_load_firmware_pio()
1668 ha->fwstart = __le16_to_cpu(fw_data[2]); in qla1280_load_firmware_pio()
1671 risc_address = ha->fwstart; in qla1280_load_firmware_pio()
1680 err = qla1280_mailbox_command(ha, BIT_0 | BIT_1 | BIT_2, mb); in qla1280_load_firmware_pio()
1683 ha->host_no); in qla1280_load_firmware_pio()
1703 qla1280_load_firmware_dma(struct scsi_qla_host *ha) in qla1280_load_firmware_dma() argument
1715 tbuf = dma_alloc_coherent(&ha->pdev->dev, 8000, &p_tbuf, GFP_KERNEL); in qla1280_load_firmware_dma()
1720 fw = qla1280_request_firmware(ha); in qla1280_load_firmware_dma()
1725 ha->fwstart = __le16_to_cpu(fw_data[2]); in qla1280_load_firmware_dma()
1728 risc_address = ha->fwstart; in qla1280_load_firmware_dma()
1748 ((__le16 *)ha->request_ring)[i] = fw_data[i]; in qla1280_load_firmware_dma()
1753 mb[3] = ha->request_dma & 0xffff; in qla1280_load_firmware_dma()
1754 mb[2] = (ha->request_dma >> 16) & 0xffff; in qla1280_load_firmware_dma()
1755 mb[7] = upper_32_bits(ha->request_dma) & 0xffff; in qla1280_load_firmware_dma()
1756 mb[6] = upper_32_bits(ha->request_dma) >> 16; in qla1280_load_firmware_dma()
1759 (void *)(long)ha->request_dma, in qla1280_load_firmware_dma()
1761 err = qla1280_mailbox_command(ha, CMD_ARGS, mb); in qla1280_load_firmware_dma()
1764 "segment of f\n", ha->host_no); in qla1280_load_firmware_dma()
1777 err = qla1280_mailbox_command(ha, CMD_ARGS, mb); in qla1280_load_firmware_dma()
1783 sp = (uint8_t *)ha->request_ring; in qla1280_load_firmware_dma()
1804 dma_free_coherent(&ha->pdev->dev, 8000, tbuf, p_tbuf); in qla1280_load_firmware_dma()
1810 qla1280_start_firmware(struct scsi_qla_host *ha) in qla1280_start_firmware() argument
1821 mb[1] = ha->fwstart; in qla1280_start_firmware()
1822 err = qla1280_mailbox_command(ha, BIT_1 | BIT_0, mb); in qla1280_start_firmware()
1824 printk(KERN_ERR "scsi(%li): RISC checksum failed.\n", ha->host_no); in qla1280_start_firmware()
1831 mb[1] = ha->fwstart; in qla1280_start_firmware()
1832 err = qla1280_mailbox_command(ha, BIT_1 | BIT_0, &mb[0]); in qla1280_start_firmware()
1835 ha->host_no); in qla1280_start_firmware()
1842 qla1280_load_firmware(struct scsi_qla_host *ha) in qla1280_load_firmware() argument
1847 err = qla1280_chip_diag(ha); in qla1280_load_firmware()
1850 if (IS_ISP1040(ha)) in qla1280_load_firmware()
1851 err = qla1280_load_firmware_pio(ha); in qla1280_load_firmware()
1853 err = qla1280_load_firmware_dma(ha); in qla1280_load_firmware()
1856 err = qla1280_start_firmware(ha); in qla1280_load_firmware()
1875 qla1280_init_rings(struct scsi_qla_host *ha) in qla1280_init_rings() argument
1883 memset(ha->outstanding_cmds, 0, in qla1280_init_rings()
1887 ha->request_ring_ptr = ha->request_ring; in qla1280_init_rings()
1888 ha->req_ring_index = 0; in qla1280_init_rings()
1889 ha->req_q_cnt = REQUEST_ENTRY_CNT; in qla1280_init_rings()
1893 mb[3] = ha->request_dma & 0xffff; in qla1280_init_rings()
1894 mb[2] = (ha->request_dma >> 16) & 0xffff; in qla1280_init_rings()
1896 mb[7] = upper_32_bits(ha->request_dma) & 0xffff; in qla1280_init_rings()
1897 mb[6] = upper_32_bits(ha->request_dma) >> 16; in qla1280_init_rings()
1898 if (!(status = qla1280_mailbox_command(ha, BIT_7 | BIT_6 | BIT_4 | in qla1280_init_rings()
1902 ha->response_ring_ptr = ha->response_ring; in qla1280_init_rings()
1903 ha->rsp_ring_index = 0; in qla1280_init_rings()
1907 mb[3] = ha->response_dma & 0xffff; in qla1280_init_rings()
1908 mb[2] = (ha->response_dma >> 16) & 0xffff; in qla1280_init_rings()
1910 mb[7] = upper_32_bits(ha->response_dma) & 0xffff; in qla1280_init_rings()
1911 mb[6] = upper_32_bits(ha->response_dma) >> 16; in qla1280_init_rings()
1912 status = qla1280_mailbox_command(ha, BIT_7 | BIT_6 | BIT_5 | in qla1280_init_rings()
1975 qla1280_set_target_defaults(struct scsi_qla_host *ha, int bus, int target) in qla1280_set_target_defaults() argument
1977 struct nvram *nv = &ha->nvram; in qla1280_set_target_defaults()
1991 if (IS_ISP1x160(ha)) { in qla1280_set_target_defaults()
2006 qla1280_set_defaults(struct scsi_qla_host *ha) in qla1280_set_defaults() argument
2008 struct nvram *nv = &ha->nvram; in qla1280_set_defaults()
2030 if (IS_ISP1040(ha)) in qla1280_set_defaults()
2035 if (IS_ISP1x160(ha)) in qla1280_set_defaults()
2045 if (IS_ISP1040(ha)) { in qla1280_set_defaults()
2055 qla1280_set_target_defaults(ha, bus, target); in qla1280_set_defaults()
2060 qla1280_config_target(struct scsi_qla_host *ha, int bus, int target) in qla1280_config_target() argument
2062 struct nvram *nv = &ha->nvram; in qla1280_config_target()
2079 if (IS_ISP1x160(ha)) in qla1280_config_target()
2084 status = qla1280_mailbox_command(ha, 0x0f, mb); in qla1280_config_target()
2089 ha->bus_settings[bus].qtag_enables |= flag; in qla1280_config_target()
2092 if (IS_ISP1x160(ha)) { in qla1280_config_target()
2094 ha->bus_settings[bus].device_enables |= flag; in qla1280_config_target()
2095 ha->bus_settings[bus].lun_disables |= 0; in qla1280_config_target()
2098 ha->bus_settings[bus].device_enables |= flag; in qla1280_config_target()
2101 ha->bus_settings[bus].lun_disables |= flag; in qla1280_config_target()
2111 status |= qla1280_mailbox_command(ha, 0x0f, mb); in qla1280_config_target()
2118 qla1280_config_bus(struct scsi_qla_host *ha, int bus) in qla1280_config_bus() argument
2120 struct nvram *nv = &ha->nvram; in qla1280_config_bus()
2125 ha->bus_settings[bus].disable_scsi_reset = in qla1280_config_bus()
2129 ha->bus_settings[bus].id = nv->bus[bus].config_1.initiator_id; in qla1280_config_bus()
2131 mb[1] = bus ? ha->bus_settings[bus].id | BIT_7 : in qla1280_config_bus()
2132 ha->bus_settings[bus].id; in qla1280_config_bus()
2133 status = qla1280_mailbox_command(ha, BIT_1 | BIT_0, &mb[0]); in qla1280_config_bus()
2136 ha->bus_settings[bus].bus_reset_delay = in qla1280_config_bus()
2140 ha->bus_settings[bus].hiwat = nv->bus[bus].max_queue_depth - 1; in qla1280_config_bus()
2144 status |= qla1280_config_target(ha, bus, target); in qla1280_config_bus()
2150 qla1280_nvram_config(struct scsi_qla_host *ha) in qla1280_nvram_config() argument
2152 struct device_reg __iomem *reg = ha->iobase; in qla1280_nvram_config()
2153 struct nvram *nv = &ha->nvram; in qla1280_nvram_config()
2159 if (ha->nvram_valid) { in qla1280_nvram_config()
2167 qla1280_set_defaults(ha); in qla1280_nvram_config()
2173 ha->flags.disable_risc_code_load = in qla1280_nvram_config()
2176 if (IS_ISP1040(ha)) { in qla1280_nvram_config()
2200 if (ha->ports > 1) in qla1280_nvram_config()
2218 status |= qla1280_mailbox_command(ha, BIT_1 | BIT_0, &mb[0]); in qla1280_nvram_config()
2220 if (IS_ISP1x40(ha)) { in qla1280_nvram_config()
2224 status |= qla1280_mailbox_command(ha, BIT_1 | BIT_0, mb); in qla1280_nvram_config()
2232 status |= qla1280_mailbox_command(ha, BIT_1 | BIT_0, mb); in qla1280_nvram_config()
2240 status |= qla1280_mailbox_command(ha, BIT_7 | BIT_6 | BIT_2 | in qla1280_nvram_config()
2247 status |= qla1280_mailbox_command(ha, BIT_2 | BIT_1 | BIT_0, &mb[0]); in qla1280_nvram_config()
2261 status |= qla1280_mailbox_command(ha, BIT_2 | BIT_1 | BIT_0, mb); in qla1280_nvram_config()
2265 status |= qla1280_mailbox_command(ha, BIT_1 | BIT_0, mb); in qla1280_nvram_config()
2271 status |= qla1280_mailbox_command(ha, BIT_2 | BIT_1 | BIT_0, mb); in qla1280_nvram_config()
2275 status |= qla1280_mailbox_command(ha, BIT_1 | BIT_0, mb); in qla1280_nvram_config()
2281 status |= qla1280_mailbox_command(ha, BIT_2 | BIT_1 | BIT_0, mb); in qla1280_nvram_config()
2283 for (bus = 0; bus < ha->ports; bus++) in qla1280_nvram_config()
2284 status |= qla1280_config_bus(ha, bus); in qla1280_nvram_config()
2306 qla1280_get_nvram_word(struct scsi_qla_host *ha, uint32_t address) in qla1280_get_nvram_word() argument
2314 data = le16_to_cpu(qla1280_nvram_request(ha, nv_cmd)); in qla1280_get_nvram_word()
2337 qla1280_nvram_request(struct scsi_qla_host *ha, uint32_t nv_cmd) in qla1280_nvram_request() argument
2339 struct device_reg __iomem *reg = ha->iobase; in qla1280_nvram_request()
2349 qla1280_nv_write(ha, NV_DATA_OUT); in qla1280_nvram_request()
2351 qla1280_nv_write(ha, 0); in qla1280_nvram_request()
2380 qla1280_nv_write(struct scsi_qla_host *ha, uint16_t data) in qla1280_nv_write() argument
2382 struct device_reg __iomem *reg = ha->iobase; in qla1280_nv_write()
2411 qla1280_mailbox_command(struct scsi_qla_host *ha, uint8_t mr, uint16_t *mb) in qla1280_mailbox_command() argument
2413 struct device_reg __iomem *reg = ha->iobase; in qla1280_mailbox_command()
2422 if (ha->mailbox_wait) { in qla1280_mailbox_command()
2425 ha->mailbox_wait = &wait; in qla1280_mailbox_command()
2447 timer_setup(&ha->mailbox_timer, qla1280_mailbox_timeout, 0); in qla1280_mailbox_command()
2448 mod_timer(&ha->mailbox_timer, jiffies + 20 * HZ); in qla1280_mailbox_command()
2450 spin_unlock_irq(ha->host->host_lock); in qla1280_mailbox_command()
2455 del_timer_sync(&ha->mailbox_timer); in qla1280_mailbox_command()
2457 spin_lock_irq(ha->host->host_lock); in qla1280_mailbox_command()
2459 ha->mailbox_wait = NULL; in qla1280_mailbox_command()
2462 if (ha->mailbox_out[0] != MBS_CMD_CMP) { in qla1280_mailbox_command()
2466 mb[0], ha->mailbox_out[0], RD_REG_WORD(&reg->istatus)); in qla1280_mailbox_command()
2478 iptr = (uint16_t *) &ha->mailbox_out[0]; in qla1280_mailbox_command()
2482 if (ha->flags.reset_marker) in qla1280_mailbox_command()
2483 qla1280_rst_aen(ha); in qla1280_mailbox_command()
2501 qla1280_poll(struct scsi_qla_host *ha) in qla1280_poll() argument
2503 struct device_reg __iomem *reg = ha->iobase; in qla1280_poll()
2512 qla1280_isr(ha, &done_q); in qla1280_poll()
2514 if (!ha->mailbox_wait) { in qla1280_poll()
2515 if (ha->flags.reset_marker) in qla1280_poll()
2516 qla1280_rst_aen(ha); in qla1280_poll()
2520 qla1280_done(ha); in qla1280_poll()
2537 qla1280_bus_reset(struct scsi_qla_host *ha, int bus) in qla1280_bus_reset() argument
2547 ha->host_no, bus); in qla1280_bus_reset()
2549 reset_delay = ha->bus_settings[bus].bus_reset_delay; in qla1280_bus_reset()
2553 status = qla1280_mailbox_command(ha, BIT_2 | BIT_1 | BIT_0, &mb[0]); in qla1280_bus_reset()
2556 if (ha->bus_settings[bus].failed_reset_count > 2) in qla1280_bus_reset()
2557 ha->bus_settings[bus].scsi_bus_dead = 1; in qla1280_bus_reset()
2558 ha->bus_settings[bus].failed_reset_count++; in qla1280_bus_reset()
2560 spin_unlock_irq(ha->host->host_lock); in qla1280_bus_reset()
2562 spin_lock_irq(ha->host->host_lock); in qla1280_bus_reset()
2564 ha->bus_settings[bus].scsi_bus_dead = 0; in qla1280_bus_reset()
2565 ha->bus_settings[bus].failed_reset_count = 0; in qla1280_bus_reset()
2566 ha->bus_settings[bus].reset_marker = 0; in qla1280_bus_reset()
2568 qla1280_marker(ha, bus, 0, 0, MK_SYNC_ALL); in qla1280_bus_reset()
2597 qla1280_device_reset(struct scsi_qla_host *ha, int bus, int target) in qla1280_device_reset() argument
2607 status = qla1280_mailbox_command(ha, BIT_2 | BIT_1 | BIT_0, &mb[0]); in qla1280_device_reset()
2610 qla1280_marker(ha, bus, target, 0, MK_SYNC_ID); in qla1280_device_reset()
2631 qla1280_abort_command(struct scsi_qla_host *ha, struct srb * sp, int handle) in qla1280_abort_command() argument
2649 status = qla1280_mailbox_command(ha, 0x0f, &mb[0]); in qla1280_abort_command()
2669 qla1280_reset_adapter(struct scsi_qla_host *ha) in qla1280_reset_adapter() argument
2671 struct device_reg __iomem *reg = ha->iobase; in qla1280_reset_adapter()
2676 ha->flags.online = 0; in qla1280_reset_adapter()
2697 qla1280_marker(struct scsi_qla_host *ha, int bus, int id, int lun, u8 type) in qla1280_marker() argument
2704 if ((pkt = (struct mrk_entry *) qla1280_req_pkt(ha))) { in qla1280_marker()
2712 qla1280_isp_cmd(ha); in qla1280_marker()
2733 qla1280_64bit_start_scsi(struct scsi_qla_host *ha, struct srb * sp) in qla1280_64bit_start_scsi() argument
2735 struct device_reg __iomem *reg = ha->iobase; in qla1280_64bit_start_scsi()
2762 if ((req_cnt + 2) >= ha->req_q_cnt) { in qla1280_64bit_start_scsi()
2765 if (ha->req_ring_index < cnt) in qla1280_64bit_start_scsi()
2766 ha->req_q_cnt = cnt - ha->req_ring_index; in qla1280_64bit_start_scsi()
2768 ha->req_q_cnt = in qla1280_64bit_start_scsi()
2769 REQUEST_ENTRY_CNT - (ha->req_ring_index - cnt); in qla1280_64bit_start_scsi()
2773 ha->req_q_cnt, seg_cnt); in qla1280_64bit_start_scsi()
2776 if ((req_cnt + 2) >= ha->req_q_cnt) { in qla1280_64bit_start_scsi()
2779 "0x%xreq_cnt=0x%x", ha->req_ring_index, ha->req_q_cnt, in qla1280_64bit_start_scsi()
2786 ha->outstanding_cmds[cnt] != NULL; cnt++); in qla1280_64bit_start_scsi()
2791 "OUTSTANDING ARRAY, req_q_cnt=0x%x", ha->req_q_cnt); in qla1280_64bit_start_scsi()
2795 ha->outstanding_cmds[cnt] = sp; in qla1280_64bit_start_scsi()
2796 ha->req_q_cnt -= req_cnt; in qla1280_64bit_start_scsi()
2808 pkt = (cmd_a64_entry_t *) ha->request_ring_ptr; in qla1280_64bit_start_scsi()
2812 pkt->sys_define = (uint8_t) ha->req_ring_index; in qla1280_64bit_start_scsi()
2889 ha->req_ring_index++; in qla1280_64bit_start_scsi()
2890 if (ha->req_ring_index == REQUEST_ENTRY_CNT) { in qla1280_64bit_start_scsi()
2891 ha->req_ring_index = 0; in qla1280_64bit_start_scsi()
2892 ha->request_ring_ptr = in qla1280_64bit_start_scsi()
2893 ha->request_ring; in qla1280_64bit_start_scsi()
2895 ha->request_ring_ptr++; in qla1280_64bit_start_scsi()
2897 pkt = (cmd_a64_entry_t *)ha->request_ring_ptr; in qla1280_64bit_start_scsi()
2907 (uint8_t)ha->req_ring_index; in qla1280_64bit_start_scsi()
2943 ha->req_ring_index++; in qla1280_64bit_start_scsi()
2944 if (ha->req_ring_index == REQUEST_ENTRY_CNT) { in qla1280_64bit_start_scsi()
2945 ha->req_ring_index = 0; in qla1280_64bit_start_scsi()
2946 ha->request_ring_ptr = ha->request_ring; in qla1280_64bit_start_scsi()
2948 ha->request_ring_ptr++; in qla1280_64bit_start_scsi()
2954 ha->actthreads++; in qla1280_64bit_start_scsi()
2955 WRT_REG_WORD(&reg->mailbox4, ha->req_ring_index); in qla1280_64bit_start_scsi()
2987 qla1280_32bit_start_scsi(struct scsi_qla_host *ha, struct srb * sp) in qla1280_32bit_start_scsi() argument
2989 struct device_reg __iomem *reg = ha->iobase; in qla1280_32bit_start_scsi()
3024 if ((req_cnt + 2) >= ha->req_q_cnt) { in qla1280_32bit_start_scsi()
3027 if (ha->req_ring_index < cnt) in qla1280_32bit_start_scsi()
3028 ha->req_q_cnt = cnt - ha->req_ring_index; in qla1280_32bit_start_scsi()
3030 ha->req_q_cnt = in qla1280_32bit_start_scsi()
3031 REQUEST_ENTRY_CNT - (ha->req_ring_index - cnt); in qla1280_32bit_start_scsi()
3035 ha->req_q_cnt, seg_cnt); in qla1280_32bit_start_scsi()
3037 if ((req_cnt + 2) >= ha->req_q_cnt) { in qla1280_32bit_start_scsi()
3040 "req_q_cnt=0x%x, req_cnt=0x%x", ha->req_ring_index, in qla1280_32bit_start_scsi()
3041 ha->req_q_cnt, req_cnt); in qla1280_32bit_start_scsi()
3047 ha->outstanding_cmds[cnt]; cnt++); in qla1280_32bit_start_scsi()
3052 "ARRAY, req_q_cnt=0x%x\n", ha->req_q_cnt); in qla1280_32bit_start_scsi()
3057 ha->outstanding_cmds[cnt] = sp; in qla1280_32bit_start_scsi()
3058 ha->req_q_cnt -= req_cnt; in qla1280_32bit_start_scsi()
3063 pkt = (struct cmd_entry *) ha->request_ring_ptr; in qla1280_32bit_start_scsi()
3067 pkt->sys_define = (uint8_t) ha->req_ring_index; in qla1280_32bit_start_scsi()
3134 ha->req_ring_index++; in qla1280_32bit_start_scsi()
3135 if (ha->req_ring_index == REQUEST_ENTRY_CNT) { in qla1280_32bit_start_scsi()
3136 ha->req_ring_index = 0; in qla1280_32bit_start_scsi()
3137 ha->request_ring_ptr = in qla1280_32bit_start_scsi()
3138 ha->request_ring; in qla1280_32bit_start_scsi()
3140 ha->request_ring_ptr++; in qla1280_32bit_start_scsi()
3142 pkt = (struct cmd_entry *)ha->request_ring_ptr; in qla1280_32bit_start_scsi()
3153 (uint8_t) ha->req_ring_index; in qla1280_32bit_start_scsi()
3187 qla1280_dump_buffer(5, (char *)ha->request_ring_ptr, in qla1280_32bit_start_scsi()
3191 ha->req_ring_index++; in qla1280_32bit_start_scsi()
3192 if (ha->req_ring_index == REQUEST_ENTRY_CNT) { in qla1280_32bit_start_scsi()
3193 ha->req_ring_index = 0; in qla1280_32bit_start_scsi()
3194 ha->request_ring_ptr = ha->request_ring; in qla1280_32bit_start_scsi()
3196 ha->request_ring_ptr++; in qla1280_32bit_start_scsi()
3202 ha->actthreads++; in qla1280_32bit_start_scsi()
3203 WRT_REG_WORD(&reg->mailbox4, ha->req_ring_index); in qla1280_32bit_start_scsi()
3227 qla1280_req_pkt(struct scsi_qla_host *ha) in qla1280_req_pkt() argument
3229 struct device_reg __iomem *reg = ha->iobase; in qla1280_req_pkt()
3241 if (ha->req_q_cnt > 0) { in qla1280_req_pkt()
3244 if (ha->req_ring_index < cnt) in qla1280_req_pkt()
3245 ha->req_q_cnt = cnt - ha->req_ring_index; in qla1280_req_pkt()
3247 ha->req_q_cnt = in qla1280_req_pkt()
3248 REQUEST_ENTRY_CNT - (ha->req_ring_index - cnt); in qla1280_req_pkt()
3252 if (ha->req_q_cnt > 0) { in qla1280_req_pkt()
3253 ha->req_q_cnt--; in qla1280_req_pkt()
3254 pkt = ha->request_ring_ptr; in qla1280_req_pkt()
3264 pkt->sys_define = (uint8_t) ha->req_ring_index; in qla1280_req_pkt()
3275 qla1280_poll(ha); in qla1280_req_pkt()
3295 qla1280_isp_cmd(struct scsi_qla_host *ha) in qla1280_isp_cmd() argument
3297 struct device_reg __iomem *reg = ha->iobase; in qla1280_isp_cmd()
3302 qla1280_dump_buffer(5, (char *)ha->request_ring_ptr, in qla1280_isp_cmd()
3306 ha->req_ring_index++; in qla1280_isp_cmd()
3307 if (ha->req_ring_index == REQUEST_ENTRY_CNT) { in qla1280_isp_cmd()
3308 ha->req_ring_index = 0; in qla1280_isp_cmd()
3309 ha->request_ring_ptr = ha->request_ring; in qla1280_isp_cmd()
3311 ha->request_ring_ptr++; in qla1280_isp_cmd()
3316 WRT_REG_WORD(&reg->mailbox4, ha->req_ring_index); in qla1280_isp_cmd()
3334 qla1280_isr(struct scsi_qla_host *ha, struct list_head *done_q) in qla1280_isr() argument
3336 struct device_reg __iomem *reg = ha->iobase; in qla1280_isr()
3388 if (ha->flags.online) { in qla1280_isr()
3394 sp = ha->outstanding_cmds[index]; in qla1280_isr()
3400 ha->outstanding_cmds[index] = NULL; in qla1280_isr()
3419 ha->flags.reset_marker = 1; in qla1280_isr()
3421 ha->bus_settings[index].reset_marker = 1; in qla1280_isr()
3457 ha->flags.reset_marker = 1; in qla1280_isr()
3459 ha->bus_settings[index].reset_marker = 1; in qla1280_isr()
3471 memcpy((uint16_t *) ha->mailbox_out, wptr, in qla1280_isr()
3475 if(ha->mailbox_wait != NULL) in qla1280_isr()
3476 complete(ha->mailbox_wait); in qla1280_isr()
3488 if (!(ha->flags.online && !ha->mailbox_wait)) { in qla1280_isr()
3496 while (ha->rsp_ring_index != mailbox[5]) { in qla1280_isr()
3497 pkt = ha->response_ring_ptr; in qla1280_isr()
3500 " = 0x%x\n", ha->rsp_ring_index, mailbox[5]); in qla1280_isr()
3510 ha->rsp_ring_index, mailbox[5], in qla1280_isr()
3517 ha->rsp_ring_index, mailbox[5]); in qla1280_isr()
3525 ha->outstanding_cmds[pkt->handle]->cmd, in qla1280_isr()
3528 qla1280_status_entry(ha, pkt, done_q); in qla1280_isr()
3530 qla1280_error_entry(ha, pkt, done_q); in qla1280_isr()
3532 ha->rsp_ring_index++; in qla1280_isr()
3533 if (ha->rsp_ring_index == RESPONSE_ENTRY_CNT) { in qla1280_isr()
3534 ha->rsp_ring_index = 0; in qla1280_isr()
3535 ha->response_ring_ptr = ha->response_ring; in qla1280_isr()
3537 ha->response_ring_ptr++; in qla1280_isr()
3538 WRT_REG_WORD(&reg->mailbox5, ha->rsp_ring_index); in qla1280_isr()
3554 qla1280_rst_aen(struct scsi_qla_host *ha) in qla1280_rst_aen() argument
3560 if (ha->flags.online && !ha->flags.reset_active && in qla1280_rst_aen()
3561 !ha->flags.abort_isp_active) { in qla1280_rst_aen()
3562 ha->flags.reset_active = 1; in qla1280_rst_aen()
3563 while (ha->flags.reset_marker) { in qla1280_rst_aen()
3565 ha->flags.reset_marker = 0; in qla1280_rst_aen()
3566 for (bus = 0; bus < ha->ports && in qla1280_rst_aen()
3567 !ha->flags.reset_marker; bus++) { in qla1280_rst_aen()
3568 if (ha->bus_settings[bus].reset_marker) { in qla1280_rst_aen()
3569 ha->bus_settings[bus].reset_marker = 0; in qla1280_rst_aen()
3570 qla1280_marker(ha, bus, 0, 0, in qla1280_rst_aen()
3591 qla1280_status_entry(struct scsi_qla_host *ha, struct response *pkt, in qla1280_status_entry() argument
3605 sp = ha->outstanding_cmds[handle]; in qla1280_status_entry()
3615 ha->outstanding_cmds[handle] = NULL; in qla1280_status_entry()
3684 qla1280_error_entry(struct scsi_qla_host *ha, struct response *pkt, in qla1280_error_entry() argument
3703 sp = ha->outstanding_cmds[handle]; in qla1280_error_entry()
3709 ha->outstanding_cmds[handle] = NULL; in qla1280_error_entry()
3748 qla1280_abort_isp(struct scsi_qla_host *ha) in qla1280_abort_isp() argument
3750 struct device_reg __iomem *reg = ha->iobase; in qla1280_abort_isp()
3758 if (ha->flags.abort_isp_active || !ha->flags.online) in qla1280_abort_isp()
3761 ha->flags.abort_isp_active = 1; in qla1280_abort_isp()
3764 qla1280_disable_intrs(ha); in qla1280_abort_isp()
3769 ha->host_no); in qla1280_abort_isp()
3773 sp = ha->outstanding_cmds[cnt]; in qla1280_abort_isp()
3778 ha->outstanding_cmds[cnt] = NULL; in qla1280_abort_isp()
3779 list_add_tail(&sp->list, &ha->done_q); in qla1280_abort_isp()
3783 qla1280_done(ha); in qla1280_abort_isp()
3785 status = qla1280_load_firmware(ha); in qla1280_abort_isp()
3790 qla1280_nvram_config (ha); in qla1280_abort_isp()
3792 status = qla1280_init_rings(ha); in qla1280_abort_isp()
3797 for (bus = 0; bus < ha->ports; bus++) in qla1280_abort_isp()
3798 qla1280_bus_reset(ha, bus); in qla1280_abort_isp()
3800 ha->flags.abort_isp_active = 0; in qla1280_abort_isp()
3805 qla1280_reset_adapter(ha); in qla1280_abort_isp()
3854 qla1280_check_for_dead_scsi_bus(struct scsi_qla_host *ha, unsigned int bus) in qla1280_check_for_dead_scsi_bus() argument
3857 struct device_reg __iomem *reg = ha->iobase; in qla1280_check_for_dead_scsi_bus()
3859 if (ha->bus_settings[bus].scsi_bus_dead) { in qla1280_check_for_dead_scsi_bus()
3868 ha->bus_settings[bus].scsi_bus_dead = 1; in qla1280_check_for_dead_scsi_bus()
3871 ha->bus_settings[bus].scsi_bus_dead = 0; in qla1280_check_for_dead_scsi_bus()
3872 ha->bus_settings[bus].failed_reset_count = 0; in qla1280_check_for_dead_scsi_bus()
3879 qla1280_get_target_parameters(struct scsi_qla_host *ha, in qla1280_get_target_parameters() argument
3893 qla1280_mailbox_command(ha, BIT_6 | BIT_3 | BIT_2 | BIT_1 | BIT_0, in qla1280_get_target_parameters()
3896 printk(KERN_INFO "scsi(%li:%d:%d:%d):", ha->host_no, bus, target, lun); in qla1280_get_target_parameters()
3947 struct scsi_qla_host *ha; in __qla1280_print_scsi_cmd() local
3953 ha = (struct scsi_qla_host *)host->hostdata; in __qla1280_print_scsi_cmd()
3984 ql1280_dump_device(struct scsi_qla_host *ha) in ql1280_dump_device() argument
3994 if ((sp = ha->outstanding_cmds[i]) == NULL) in ql1280_dump_device()
4143 struct scsi_qla_host *ha; in qla1280_probe_one() local
4165 host = scsi_host_alloc(&qla1280_driver_template, sizeof(*ha)); in qla1280_probe_one()
4172 ha = (struct scsi_qla_host *)host->hostdata; in qla1280_probe_one()
4173 memset(ha, 0, sizeof(struct scsi_qla_host)); in qla1280_probe_one()
4175 ha->pdev = pdev; in qla1280_probe_one()
4176 ha->devnum = devnum; /* specifies microcode load address */ in qla1280_probe_one()
4179 if (dma_set_mask_and_coherent(&ha->pdev->dev, DMA_BIT_MASK(64))) { in qla1280_probe_one()
4180 if (dma_set_mask(&ha->pdev->dev, DMA_BIT_MASK(32))) { in qla1280_probe_one()
4182 "suitable DMA mask - aborting\n", ha->host_no); in qla1280_probe_one()
4188 ha->host_no); in qla1280_probe_one()
4190 if (dma_set_mask(&ha->pdev->dev, DMA_BIT_MASK(32))) { in qla1280_probe_one()
4192 "suitable DMA mask - aborting\n", ha->host_no); in qla1280_probe_one()
4198 ha->request_ring = dma_alloc_coherent(&ha->pdev->dev, in qla1280_probe_one()
4200 &ha->request_dma, GFP_KERNEL); in qla1280_probe_one()
4201 if (!ha->request_ring) { in qla1280_probe_one()
4206 ha->response_ring = dma_alloc_coherent(&ha->pdev->dev, in qla1280_probe_one()
4208 &ha->response_dma, GFP_KERNEL); in qla1280_probe_one()
4209 if (!ha->response_ring) { in qla1280_probe_one()
4214 ha->ports = bdp->numPorts; in qla1280_probe_one()
4216 ha->host = host; in qla1280_probe_one()
4217 ha->host_no = host->host_no; in qla1280_probe_one()
4229 ha->mmpbase = pci_ioremap_bar(ha->pdev, 1); in qla1280_probe_one()
4230 if (!ha->mmpbase) { in qla1280_probe_one()
4235 host->base = (unsigned long)ha->mmpbase; in qla1280_probe_one()
4236 ha->iobase = (struct device_reg __iomem *)ha->mmpbase; in qla1280_probe_one()
4238 host->io_port = pci_resource_start(ha->pdev, 0); in qla1280_probe_one()
4246 ha->iobase = (struct device_reg *)host->io_port; in qla1280_probe_one()
4249 INIT_LIST_HEAD(&ha->done_q); in qla1280_probe_one()
4252 qla1280_disable_intrs(ha); in qla1280_probe_one()
4255 "qla1280", ha)) { in qla1280_probe_one()
4262 if (qla1280_initialize_adapter(ha)) { in qla1280_probe_one()
4268 host->this_id = ha->bus_settings[0].id; in qla1280_probe_one()
4280 qla1280_disable_intrs(ha); in qla1280_probe_one()
4282 free_irq(pdev->irq, ha); in qla1280_probe_one()
4285 iounmap(ha->mmpbase); in qla1280_probe_one()
4290 dma_free_coherent(&ha->pdev->dev, in qla1280_probe_one()
4292 ha->response_ring, ha->response_dma); in qla1280_probe_one()
4294 dma_free_coherent(&ha->pdev->dev, in qla1280_probe_one()
4296 ha->request_ring, ha->request_dma); in qla1280_probe_one()
4310 struct scsi_qla_host *ha = (struct scsi_qla_host *)host->hostdata; in qla1280_remove_one() local
4314 qla1280_disable_intrs(ha); in qla1280_remove_one()
4316 free_irq(pdev->irq, ha); in qla1280_remove_one()
4319 iounmap(ha->mmpbase); in qla1280_remove_one()
4324 dma_free_coherent(&ha->pdev->dev, in qla1280_remove_one()
4326 ha->request_ring, ha->request_dma); in qla1280_remove_one()
4327 dma_free_coherent(&ha->pdev->dev, in qla1280_remove_one()
4329 ha->response_ring, ha->response_dma); in qla1280_remove_one()