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)
577 static int qla1280_read_nvram(struct scsi_qla_host *ha) in qla1280_read_nvram() argument
589 printk(KERN_INFO "scsi(%ld): Reading NVRAM\n", ha->host_no); in qla1280_read_nvram()
591 wptr = (uint16_t *)&ha->nvram; in qla1280_read_nvram()
592 nv = &ha->nvram; in qla1280_read_nvram()
595 *wptr = qla1280_get_nvram_word(ha, cnt); in qla1280_read_nvram()
607 *wptr = qla1280_get_nvram_word(ha, cnt); in qla1280_read_nvram()
623 "settings\n", ha->host_no); in qla1280_read_nvram()
624 ha->nvram_valid = 0; in qla1280_read_nvram()
626 ha->nvram_valid = 1; in qla1280_read_nvram()
665 struct scsi_qla_host *ha; in qla1280_info() local
669 ha = (struct scsi_qla_host *)host->hostdata; in qla1280_info()
670 bdp = &ql1280_board_tbl[ha->devnum]; in qla1280_info()
676 &bdp->name[0], ha->fwver1, ha->fwver2, ha->fwver3, in qla1280_info()
695 struct scsi_qla_host *ha = (struct scsi_qla_host *)host->hostdata; in qla1280_queuecommand_lck() local
713 status = qla1280_64bit_start_scsi(ha, sp); in qla1280_queuecommand_lck()
715 status = qla1280_32bit_start_scsi(ha, sp); in qla1280_queuecommand_lck()
732 struct scsi_qla_host *ha = from_timer(ha, t, mailbox_timer); in qla1280_mailbox_timeout() local
734 reg = ha->iobase; in qla1280_mailbox_timeout()
736 ha->mailbox_out[0] = RD_REG_WORD(®->mailbox0); in qla1280_mailbox_timeout()
738 "ictrl %04x, istatus %04x\n", ha->host_no, ha->mailbox_out[0], in qla1280_mailbox_timeout()
740 complete(ha->mailbox_wait); in qla1280_mailbox_timeout()
744 _qla1280_wait_for_single_command(struct scsi_qla_host *ha, struct srb *sp, in _qla1280_wait_for_single_command() argument
750 spin_unlock_irq(ha->host->host_lock); in _qla1280_wait_for_single_command()
752 spin_lock_irq(ha->host->host_lock); in _qla1280_wait_for_single_command()
762 qla1280_wait_for_single_command(struct scsi_qla_host *ha, struct srb *sp) in qla1280_wait_for_single_command() argument
767 return _qla1280_wait_for_single_command(ha, sp, &wait); in qla1280_wait_for_single_command()
771 qla1280_wait_for_pending_commands(struct scsi_qla_host *ha, int bus, int target) in qla1280_wait_for_pending_commands() argument
785 sp = ha->outstanding_cmds[cnt]; in qla1280_wait_for_pending_commands()
794 status = qla1280_wait_for_single_command(ha, sp); in qla1280_wait_for_pending_commands()
819 struct scsi_qla_host *ha; in qla1280_error_action() local
830 ha = (struct scsi_qla_host *)(CMD_HOST(cmd)->hostdata); in qla1280_error_action()
837 RD_REG_WORD(&ha->iobase->istatus)); in qla1280_error_action()
840 RD_REG_WORD(&ha->iobase->host_cmd), in qla1280_error_action()
841 RD_REG_WORD(&ha->iobase->ictrl), jiffies); in qla1280_error_action()
846 ha->host_no, cmd, CMD_HANDLE(cmd), action); in qla1280_error_action()
856 if (sp == ha->outstanding_cmds[i]) { in qla1280_error_action()
868 "already completed.\n", ha->host_no, bus, in qla1280_error_action()
883 qla1280_abort_command(ha, sp, found); in qla1280_error_action()
890 "command.\n", ha->host_no, bus, target, lun); in qla1280_error_action()
891 if (qla1280_device_reset(ha, bus, target) == 0) { in qla1280_error_action()
901 "reset.\n", ha->host_no, bus); in qla1280_error_action()
902 if (qla1280_bus_reset(ha, bus) == 0) { in qla1280_error_action()
913 ha->host_no); in qla1280_error_action()
915 "continue automatically\n", ha->host_no); in qla1280_error_action()
917 ha->flags.reset_active = 1; in qla1280_error_action()
919 if (qla1280_abort_isp(ha) != 0) { /* it's dead */ in qla1280_error_action()
923 ha->flags.reset_active = 0; in qla1280_error_action()
936 result = _qla1280_wait_for_single_command(ha, sp, &wait); in qla1280_error_action()
942 ha->host_no, bus, target, lun); in qla1280_error_action()
956 result = qla1280_wait_for_pending_commands(ha, in qla1280_error_action()
1057 qla1280_disable_intrs(struct scsi_qla_host *ha) in qla1280_disable_intrs() argument
1059 WRT_REG_WORD(&ha->iobase->ictrl, 0); in qla1280_disable_intrs()
1060 RD_REG_WORD(&ha->iobase->ictrl); /* PCI Posted Write flush */ in qla1280_disable_intrs()
1065 qla1280_enable_intrs(struct scsi_qla_host *ha) in qla1280_enable_intrs() argument
1067 WRT_REG_WORD(&ha->iobase->ictrl, (ISP_EN_INT | ISP_EN_RISC)); in qla1280_enable_intrs()
1068 RD_REG_WORD(&ha->iobase->ictrl); /* PCI Posted Write flush */ in qla1280_enable_intrs()
1078 struct scsi_qla_host *ha; in qla1280_intr_handler() local
1084 ha = (struct scsi_qla_host *)dev_id; in qla1280_intr_handler()
1086 spin_lock(ha->host->host_lock); in qla1280_intr_handler()
1088 ha->isr_count++; in qla1280_intr_handler()
1089 reg = ha->iobase; in qla1280_intr_handler()
1091 qla1280_disable_intrs(ha); in qla1280_intr_handler()
1096 qla1280_isr(ha, &ha->done_q); in qla1280_intr_handler()
1099 if (!list_empty(&ha->done_q)) in qla1280_intr_handler()
1100 qla1280_done(ha); in qla1280_intr_handler()
1102 spin_unlock(ha->host->host_lock); in qla1280_intr_handler()
1104 qla1280_enable_intrs(ha); in qla1280_intr_handler()
1112 qla1280_set_target_parameters(struct scsi_qla_host *ha, int bus, int target) in qla1280_set_target_parameters() argument
1119 nv = &ha->nvram; in qla1280_set_target_parameters()
1135 if (IS_ISP1x160(ha)) { in qla1280_set_target_parameters()
1146 status = qla1280_mailbox_command(ha, mr, mb); in qla1280_set_target_parameters()
1155 status |= qla1280_mailbox_command(ha, 0x0f, mb); in qla1280_set_target_parameters()
1161 ha->host_no, bus, target); in qla1280_set_target_parameters()
1180 struct scsi_qla_host *ha; in qla1280_slave_configure() local
1188 ha = (struct scsi_qla_host *)device->host->hostdata; in qla1280_slave_configure()
1189 nv = &ha->nvram; in qla1280_slave_configure()
1191 if (qla1280_check_for_dead_scsi_bus(ha, bus)) in qla1280_slave_configure()
1195 (ha->bus_settings[bus].qtag_enables & (BIT_0 << target))) { in qla1280_slave_configure()
1196 scsi_change_queue_depth(device, ha->bus_settings[bus].hiwat); in qla1280_slave_configure()
1213 if (IS_ISP1x160(ha)) { in qla1280_slave_configure()
1220 spin_lock_irqsave(ha->host->host_lock, flags); in qla1280_slave_configure()
1222 status = qla1280_set_target_parameters(ha, bus, target); in qla1280_slave_configure()
1223 qla1280_get_target_parameters(ha, device); in qla1280_slave_configure()
1224 spin_unlock_irqrestore(ha->host->host_lock, flags); in qla1280_slave_configure()
1237 qla1280_done(struct scsi_qla_host *ha) in qla1280_done() argument
1246 done_q = &ha->done_q; in qla1280_done()
1260 if (!ha->flags.abort_isp_active) in qla1280_done()
1261 qla1280_marker(ha, bus, target, 0, MK_SYNC_ID); in qla1280_done()
1275 ha->actthreads--; in qla1280_done()
1402 qla1280_initialize_adapter(struct scsi_qla_host *ha) in qla1280_initialize_adapter() argument
1412 ha->flags.online = 0; in qla1280_initialize_adapter()
1413 ha->flags.disable_host_adapter = 0; in qla1280_initialize_adapter()
1414 ha->flags.reset_active = 0; in qla1280_initialize_adapter()
1415 ha->flags.abort_isp_active = 0; in qla1280_initialize_adapter()
1418 if (IS_ISP1040(ha)) in qla1280_initialize_adapter()
1423 reg = ha->iobase; in qla1280_initialize_adapter()
1431 if (qla1280_read_nvram(ha)) { in qla1280_initialize_adapter()
1441 spin_lock_irqsave(ha->host->host_lock, flags); in qla1280_initialize_adapter()
1443 status = qla1280_load_firmware(ha); in qla1280_initialize_adapter()
1446 ha->host_no); in qla1280_initialize_adapter()
1451 dprintk(1, "scsi(%ld): Configure NVRAM parameters\n", ha->host_no); in qla1280_initialize_adapter()
1452 qla1280_nvram_config(ha); in qla1280_initialize_adapter()
1454 if (ha->flags.disable_host_adapter) { in qla1280_initialize_adapter()
1459 status = qla1280_init_rings(ha); in qla1280_initialize_adapter()
1464 for (bus = 0; bus < ha->ports; bus++) { in qla1280_initialize_adapter()
1465 if (!ha->bus_settings[bus].disable_scsi_reset && in qla1280_initialize_adapter()
1466 qla1280_bus_reset(ha, bus) && in qla1280_initialize_adapter()
1467 qla1280_bus_reset(ha, bus)) in qla1280_initialize_adapter()
1468 ha->bus_settings[bus].scsi_bus_dead = 1; in qla1280_initialize_adapter()
1471 ha->flags.online = 1; in qla1280_initialize_adapter()
1473 spin_unlock_irqrestore(ha->host->host_lock, flags); in qla1280_initialize_adapter()
1495 qla1280_request_firmware(struct scsi_qla_host *ha) in qla1280_request_firmware() argument
1502 spin_unlock_irq(ha->host->host_lock); in qla1280_request_firmware()
1505 index = ql1280_board_tbl[ha->devnum].fw_index; in qla1280_request_firmware()
1511 err = request_firmware(&fw, fwname, &ha->pdev->dev); in qla1280_request_firmware()
1530 ha->fwver1 = fw->data[0]; in qla1280_request_firmware()
1531 ha->fwver2 = fw->data[1]; in qla1280_request_firmware()
1532 ha->fwver3 = fw->data[2]; in qla1280_request_firmware()
1535 spin_lock_irq(ha->host->host_lock); in qla1280_request_firmware()
1550 qla1280_chip_diag(struct scsi_qla_host *ha) in qla1280_chip_diag() argument
1553 struct device_reg __iomem *reg = ha->iobase; in qla1280_chip_diag()
1559 dprintk(1, "scsi(%ld): Verifying chip\n", ha->host_no); in qla1280_chip_diag()
1628 qla1280_enable_intrs(ha); in qla1280_chip_diag()
1641 status = qla1280_mailbox_command(ha, 0xff, mb); in qla1280_chip_diag()
1660 qla1280_load_firmware_pio(struct scsi_qla_host *ha) in qla1280_load_firmware_pio() argument
1670 fw = qla1280_request_firmware(ha); in qla1280_load_firmware_pio()
1675 ha->fwstart = __le16_to_cpu(fw_data[2]); in qla1280_load_firmware_pio()
1678 risc_address = ha->fwstart; in qla1280_load_firmware_pio()
1687 err = qla1280_mailbox_command(ha, BIT_0 | BIT_1 | BIT_2, mb); in qla1280_load_firmware_pio()
1690 ha->host_no); in qla1280_load_firmware_pio()
1710 qla1280_load_firmware_dma(struct scsi_qla_host *ha) in qla1280_load_firmware_dma() argument
1722 tbuf = dma_alloc_coherent(&ha->pdev->dev, 8000, &p_tbuf, GFP_KERNEL); in qla1280_load_firmware_dma()
1727 fw = qla1280_request_firmware(ha); in qla1280_load_firmware_dma()
1732 ha->fwstart = __le16_to_cpu(fw_data[2]); in qla1280_load_firmware_dma()
1735 risc_address = ha->fwstart; in qla1280_load_firmware_dma()
1755 ((__le16 *)ha->request_ring)[i] = fw_data[i]; in qla1280_load_firmware_dma()
1760 mb[3] = ha->request_dma & 0xffff; in qla1280_load_firmware_dma()
1761 mb[2] = (ha->request_dma >> 16) & 0xffff; in qla1280_load_firmware_dma()
1762 mb[7] = upper_32_bits(ha->request_dma) & 0xffff; in qla1280_load_firmware_dma()
1763 mb[6] = upper_32_bits(ha->request_dma) >> 16; in qla1280_load_firmware_dma()
1766 (void *)(long)ha->request_dma, in qla1280_load_firmware_dma()
1768 err = qla1280_mailbox_command(ha, CMD_ARGS, mb); in qla1280_load_firmware_dma()
1771 "segment of f\n", ha->host_no); in qla1280_load_firmware_dma()
1784 err = qla1280_mailbox_command(ha, CMD_ARGS, mb); in qla1280_load_firmware_dma()
1790 sp = (uint8_t *)ha->request_ring; in qla1280_load_firmware_dma()
1811 dma_free_coherent(&ha->pdev->dev, 8000, tbuf, p_tbuf); in qla1280_load_firmware_dma()
1817 qla1280_start_firmware(struct scsi_qla_host *ha) in qla1280_start_firmware() argument
1828 mb[1] = ha->fwstart; in qla1280_start_firmware()
1829 err = qla1280_mailbox_command(ha, BIT_1 | BIT_0, mb); in qla1280_start_firmware()
1831 printk(KERN_ERR "scsi(%li): RISC checksum failed.\n", ha->host_no); in qla1280_start_firmware()
1838 mb[1] = ha->fwstart; in qla1280_start_firmware()
1839 err = qla1280_mailbox_command(ha, BIT_1 | BIT_0, &mb[0]); in qla1280_start_firmware()
1842 ha->host_no); in qla1280_start_firmware()
1849 qla1280_load_firmware(struct scsi_qla_host *ha) in qla1280_load_firmware() argument
1854 err = qla1280_chip_diag(ha); in qla1280_load_firmware()
1857 if (IS_ISP1040(ha)) in qla1280_load_firmware()
1858 err = qla1280_load_firmware_pio(ha); in qla1280_load_firmware()
1860 err = qla1280_load_firmware_dma(ha); in qla1280_load_firmware()
1863 err = qla1280_start_firmware(ha); in qla1280_load_firmware()
1882 qla1280_init_rings(struct scsi_qla_host *ha) in qla1280_init_rings() argument
1890 memset(ha->outstanding_cmds, 0, in qla1280_init_rings()
1894 ha->request_ring_ptr = ha->request_ring; in qla1280_init_rings()
1895 ha->req_ring_index = 0; in qla1280_init_rings()
1896 ha->req_q_cnt = REQUEST_ENTRY_CNT; in qla1280_init_rings()
1900 mb[3] = ha->request_dma & 0xffff; in qla1280_init_rings()
1901 mb[2] = (ha->request_dma >> 16) & 0xffff; in qla1280_init_rings()
1903 mb[7] = upper_32_bits(ha->request_dma) & 0xffff; in qla1280_init_rings()
1904 mb[6] = upper_32_bits(ha->request_dma) >> 16; in qla1280_init_rings()
1905 if (!(status = qla1280_mailbox_command(ha, BIT_7 | BIT_6 | BIT_4 | in qla1280_init_rings()
1909 ha->response_ring_ptr = ha->response_ring; in qla1280_init_rings()
1910 ha->rsp_ring_index = 0; in qla1280_init_rings()
1914 mb[3] = ha->response_dma & 0xffff; in qla1280_init_rings()
1915 mb[2] = (ha->response_dma >> 16) & 0xffff; in qla1280_init_rings()
1917 mb[7] = upper_32_bits(ha->response_dma) & 0xffff; in qla1280_init_rings()
1918 mb[6] = upper_32_bits(ha->response_dma) >> 16; in qla1280_init_rings()
1919 status = qla1280_mailbox_command(ha, BIT_7 | BIT_6 | BIT_5 | in qla1280_init_rings()
1982 qla1280_set_target_defaults(struct scsi_qla_host *ha, int bus, int target) in qla1280_set_target_defaults() argument
1984 struct nvram *nv = &ha->nvram; in qla1280_set_target_defaults()
1998 if (IS_ISP1x160(ha)) { in qla1280_set_target_defaults()
2013 qla1280_set_defaults(struct scsi_qla_host *ha) in qla1280_set_defaults() argument
2015 struct nvram *nv = &ha->nvram; in qla1280_set_defaults()
2037 if (IS_ISP1040(ha)) in qla1280_set_defaults()
2042 if (IS_ISP1x160(ha)) in qla1280_set_defaults()
2052 if (IS_ISP1040(ha)) { in qla1280_set_defaults()
2062 qla1280_set_target_defaults(ha, bus, target); in qla1280_set_defaults()
2067 qla1280_config_target(struct scsi_qla_host *ha, int bus, int target) in qla1280_config_target() argument
2069 struct nvram *nv = &ha->nvram; in qla1280_config_target()
2086 if (IS_ISP1x160(ha)) in qla1280_config_target()
2091 status = qla1280_mailbox_command(ha, 0x0f, mb); in qla1280_config_target()
2096 ha->bus_settings[bus].qtag_enables |= flag; in qla1280_config_target()
2099 if (IS_ISP1x160(ha)) { in qla1280_config_target()
2101 ha->bus_settings[bus].device_enables |= flag; in qla1280_config_target()
2102 ha->bus_settings[bus].lun_disables |= 0; in qla1280_config_target()
2105 ha->bus_settings[bus].device_enables |= flag; in qla1280_config_target()
2108 ha->bus_settings[bus].lun_disables |= flag; in qla1280_config_target()
2118 status |= qla1280_mailbox_command(ha, 0x0f, mb); in qla1280_config_target()
2125 qla1280_config_bus(struct scsi_qla_host *ha, int bus) in qla1280_config_bus() argument
2127 struct nvram *nv = &ha->nvram; in qla1280_config_bus()
2132 ha->bus_settings[bus].disable_scsi_reset = in qla1280_config_bus()
2136 ha->bus_settings[bus].id = nv->bus[bus].config_1.initiator_id; in qla1280_config_bus()
2138 mb[1] = bus ? ha->bus_settings[bus].id | BIT_7 : in qla1280_config_bus()
2139 ha->bus_settings[bus].id; in qla1280_config_bus()
2140 status = qla1280_mailbox_command(ha, BIT_1 | BIT_0, &mb[0]); in qla1280_config_bus()
2143 ha->bus_settings[bus].bus_reset_delay = in qla1280_config_bus()
2147 ha->bus_settings[bus].hiwat = nv->bus[bus].max_queue_depth - 1; in qla1280_config_bus()
2151 status |= qla1280_config_target(ha, bus, target); in qla1280_config_bus()
2157 qla1280_nvram_config(struct scsi_qla_host *ha) in qla1280_nvram_config() argument
2159 struct device_reg __iomem *reg = ha->iobase; in qla1280_nvram_config()
2160 struct nvram *nv = &ha->nvram; in qla1280_nvram_config()
2166 if (ha->nvram_valid) { in qla1280_nvram_config()
2174 qla1280_set_defaults(ha); in qla1280_nvram_config()
2180 ha->flags.disable_risc_code_load = in qla1280_nvram_config()
2183 if (IS_ISP1040(ha)) { in qla1280_nvram_config()
2207 if (ha->ports > 1) in qla1280_nvram_config()
2225 status |= qla1280_mailbox_command(ha, BIT_1 | BIT_0, &mb[0]); in qla1280_nvram_config()
2227 if (IS_ISP1x40(ha)) { in qla1280_nvram_config()
2231 status |= qla1280_mailbox_command(ha, BIT_1 | BIT_0, mb); in qla1280_nvram_config()
2239 status |= qla1280_mailbox_command(ha, BIT_1 | BIT_0, mb); in qla1280_nvram_config()
2247 status |= qla1280_mailbox_command(ha, BIT_7 | BIT_6 | BIT_2 | in qla1280_nvram_config()
2254 status |= qla1280_mailbox_command(ha, BIT_2 | BIT_1 | BIT_0, &mb[0]); in qla1280_nvram_config()
2268 status |= qla1280_mailbox_command(ha, BIT_2 | BIT_1 | BIT_0, mb); in qla1280_nvram_config()
2272 status |= qla1280_mailbox_command(ha, BIT_1 | BIT_0, mb); in qla1280_nvram_config()
2278 status |= qla1280_mailbox_command(ha, BIT_2 | BIT_1 | BIT_0, mb); in qla1280_nvram_config()
2282 status |= qla1280_mailbox_command(ha, BIT_1 | BIT_0, mb); in qla1280_nvram_config()
2288 status |= qla1280_mailbox_command(ha, BIT_2 | BIT_1 | BIT_0, mb); in qla1280_nvram_config()
2290 for (bus = 0; bus < ha->ports; bus++) in qla1280_nvram_config()
2291 status |= qla1280_config_bus(ha, bus); in qla1280_nvram_config()
2313 qla1280_get_nvram_word(struct scsi_qla_host *ha, uint32_t address) in qla1280_get_nvram_word() argument
2321 data = le16_to_cpu(qla1280_nvram_request(ha, nv_cmd)); in qla1280_get_nvram_word()
2344 qla1280_nvram_request(struct scsi_qla_host *ha, uint32_t nv_cmd) in qla1280_nvram_request() argument
2346 struct device_reg __iomem *reg = ha->iobase; in qla1280_nvram_request()
2356 qla1280_nv_write(ha, NV_DATA_OUT); in qla1280_nvram_request()
2358 qla1280_nv_write(ha, 0); in qla1280_nvram_request()
2387 qla1280_nv_write(struct scsi_qla_host *ha, uint16_t data) in qla1280_nv_write() argument
2389 struct device_reg __iomem *reg = ha->iobase; in qla1280_nv_write()
2418 qla1280_mailbox_command(struct scsi_qla_host *ha, uint8_t mr, uint16_t *mb) in qla1280_mailbox_command() argument
2420 struct device_reg __iomem *reg = ha->iobase; in qla1280_mailbox_command()
2429 if (ha->mailbox_wait) { in qla1280_mailbox_command()
2432 ha->mailbox_wait = &wait; in qla1280_mailbox_command()
2454 timer_setup(&ha->mailbox_timer, qla1280_mailbox_timeout, 0); in qla1280_mailbox_command()
2455 mod_timer(&ha->mailbox_timer, jiffies + 20 * HZ); in qla1280_mailbox_command()
2457 spin_unlock_irq(ha->host->host_lock); in qla1280_mailbox_command()
2462 del_timer_sync(&ha->mailbox_timer); in qla1280_mailbox_command()
2464 spin_lock_irq(ha->host->host_lock); in qla1280_mailbox_command()
2466 ha->mailbox_wait = NULL; in qla1280_mailbox_command()
2469 if (ha->mailbox_out[0] != MBS_CMD_CMP) { in qla1280_mailbox_command()
2473 mb[0], ha->mailbox_out[0], RD_REG_WORD(®->istatus)); in qla1280_mailbox_command()
2485 iptr = (uint16_t *) &ha->mailbox_out[0]; in qla1280_mailbox_command()
2489 if (ha->flags.reset_marker) in qla1280_mailbox_command()
2490 qla1280_rst_aen(ha); in qla1280_mailbox_command()
2508 qla1280_poll(struct scsi_qla_host *ha) in qla1280_poll() argument
2510 struct device_reg __iomem *reg = ha->iobase; in qla1280_poll()
2519 qla1280_isr(ha, &done_q); in qla1280_poll()
2521 if (!ha->mailbox_wait) { in qla1280_poll()
2522 if (ha->flags.reset_marker) in qla1280_poll()
2523 qla1280_rst_aen(ha); in qla1280_poll()
2527 qla1280_done(ha); in qla1280_poll()
2544 qla1280_bus_reset(struct scsi_qla_host *ha, int bus) in qla1280_bus_reset() argument
2554 ha->host_no, bus); in qla1280_bus_reset()
2556 reset_delay = ha->bus_settings[bus].bus_reset_delay; in qla1280_bus_reset()
2560 status = qla1280_mailbox_command(ha, BIT_2 | BIT_1 | BIT_0, &mb[0]); in qla1280_bus_reset()
2563 if (ha->bus_settings[bus].failed_reset_count > 2) in qla1280_bus_reset()
2564 ha->bus_settings[bus].scsi_bus_dead = 1; in qla1280_bus_reset()
2565 ha->bus_settings[bus].failed_reset_count++; in qla1280_bus_reset()
2567 spin_unlock_irq(ha->host->host_lock); in qla1280_bus_reset()
2569 spin_lock_irq(ha->host->host_lock); in qla1280_bus_reset()
2571 ha->bus_settings[bus].scsi_bus_dead = 0; in qla1280_bus_reset()
2572 ha->bus_settings[bus].failed_reset_count = 0; in qla1280_bus_reset()
2573 ha->bus_settings[bus].reset_marker = 0; in qla1280_bus_reset()
2575 qla1280_marker(ha, bus, 0, 0, MK_SYNC_ALL); in qla1280_bus_reset()
2604 qla1280_device_reset(struct scsi_qla_host *ha, int bus, int target) in qla1280_device_reset() argument
2614 status = qla1280_mailbox_command(ha, BIT_2 | BIT_1 | BIT_0, &mb[0]); in qla1280_device_reset()
2617 qla1280_marker(ha, bus, target, 0, MK_SYNC_ID); in qla1280_device_reset()
2638 qla1280_abort_command(struct scsi_qla_host *ha, struct srb * sp, int handle) in qla1280_abort_command() argument
2656 status = qla1280_mailbox_command(ha, 0x0f, &mb[0]); in qla1280_abort_command()
2676 qla1280_reset_adapter(struct scsi_qla_host *ha) in qla1280_reset_adapter() argument
2678 struct device_reg __iomem *reg = ha->iobase; in qla1280_reset_adapter()
2683 ha->flags.online = 0; in qla1280_reset_adapter()
2704 qla1280_marker(struct scsi_qla_host *ha, int bus, int id, int lun, u8 type) in qla1280_marker() argument
2711 if ((pkt = (struct mrk_entry *) qla1280_req_pkt(ha))) { in qla1280_marker()
2719 qla1280_isp_cmd(ha); in qla1280_marker()
2740 qla1280_64bit_start_scsi(struct scsi_qla_host *ha, struct srb * sp) in qla1280_64bit_start_scsi() argument
2742 struct device_reg __iomem *reg = ha->iobase; in qla1280_64bit_start_scsi()
2769 if ((req_cnt + 2) >= ha->req_q_cnt) { in qla1280_64bit_start_scsi()
2772 if (ha->req_ring_index < cnt) in qla1280_64bit_start_scsi()
2773 ha->req_q_cnt = cnt - ha->req_ring_index; in qla1280_64bit_start_scsi()
2775 ha->req_q_cnt = in qla1280_64bit_start_scsi()
2776 REQUEST_ENTRY_CNT - (ha->req_ring_index - cnt); in qla1280_64bit_start_scsi()
2780 ha->req_q_cnt, seg_cnt); in qla1280_64bit_start_scsi()
2783 if ((req_cnt + 2) >= ha->req_q_cnt) { in qla1280_64bit_start_scsi()
2786 "0x%xreq_cnt=0x%x", ha->req_ring_index, ha->req_q_cnt, in qla1280_64bit_start_scsi()
2793 ha->outstanding_cmds[cnt] != NULL; cnt++); in qla1280_64bit_start_scsi()
2798 "OUTSTANDING ARRAY, req_q_cnt=0x%x", ha->req_q_cnt); in qla1280_64bit_start_scsi()
2802 ha->outstanding_cmds[cnt] = sp; in qla1280_64bit_start_scsi()
2803 ha->req_q_cnt -= req_cnt; in qla1280_64bit_start_scsi()
2815 pkt = (cmd_a64_entry_t *) ha->request_ring_ptr; in qla1280_64bit_start_scsi()
2819 pkt->sys_define = (uint8_t) ha->req_ring_index; in qla1280_64bit_start_scsi()
2896 ha->req_ring_index++; in qla1280_64bit_start_scsi()
2897 if (ha->req_ring_index == REQUEST_ENTRY_CNT) { in qla1280_64bit_start_scsi()
2898 ha->req_ring_index = 0; in qla1280_64bit_start_scsi()
2899 ha->request_ring_ptr = in qla1280_64bit_start_scsi()
2900 ha->request_ring; in qla1280_64bit_start_scsi()
2902 ha->request_ring_ptr++; in qla1280_64bit_start_scsi()
2904 pkt = (cmd_a64_entry_t *)ha->request_ring_ptr; in qla1280_64bit_start_scsi()
2914 (uint8_t)ha->req_ring_index; in qla1280_64bit_start_scsi()
2950 ha->req_ring_index++; in qla1280_64bit_start_scsi()
2951 if (ha->req_ring_index == REQUEST_ENTRY_CNT) { in qla1280_64bit_start_scsi()
2952 ha->req_ring_index = 0; in qla1280_64bit_start_scsi()
2953 ha->request_ring_ptr = ha->request_ring; in qla1280_64bit_start_scsi()
2955 ha->request_ring_ptr++; in qla1280_64bit_start_scsi()
2961 ha->actthreads++; in qla1280_64bit_start_scsi()
2962 WRT_REG_WORD(®->mailbox4, ha->req_ring_index); in qla1280_64bit_start_scsi()
2994 qla1280_32bit_start_scsi(struct scsi_qla_host *ha, struct srb * sp) in qla1280_32bit_start_scsi() argument
2996 struct device_reg __iomem *reg = ha->iobase; in qla1280_32bit_start_scsi()
3031 if ((req_cnt + 2) >= ha->req_q_cnt) { in qla1280_32bit_start_scsi()
3034 if (ha->req_ring_index < cnt) in qla1280_32bit_start_scsi()
3035 ha->req_q_cnt = cnt - ha->req_ring_index; in qla1280_32bit_start_scsi()
3037 ha->req_q_cnt = in qla1280_32bit_start_scsi()
3038 REQUEST_ENTRY_CNT - (ha->req_ring_index - cnt); in qla1280_32bit_start_scsi()
3042 ha->req_q_cnt, seg_cnt); in qla1280_32bit_start_scsi()
3044 if ((req_cnt + 2) >= ha->req_q_cnt) { in qla1280_32bit_start_scsi()
3047 "req_q_cnt=0x%x, req_cnt=0x%x", ha->req_ring_index, in qla1280_32bit_start_scsi()
3048 ha->req_q_cnt, req_cnt); in qla1280_32bit_start_scsi()
3054 ha->outstanding_cmds[cnt]; cnt++); in qla1280_32bit_start_scsi()
3059 "ARRAY, req_q_cnt=0x%x\n", ha->req_q_cnt); in qla1280_32bit_start_scsi()
3064 ha->outstanding_cmds[cnt] = sp; in qla1280_32bit_start_scsi()
3065 ha->req_q_cnt -= req_cnt; in qla1280_32bit_start_scsi()
3070 pkt = (struct cmd_entry *) ha->request_ring_ptr; in qla1280_32bit_start_scsi()
3074 pkt->sys_define = (uint8_t) ha->req_ring_index; in qla1280_32bit_start_scsi()
3141 ha->req_ring_index++; in qla1280_32bit_start_scsi()
3142 if (ha->req_ring_index == REQUEST_ENTRY_CNT) { in qla1280_32bit_start_scsi()
3143 ha->req_ring_index = 0; in qla1280_32bit_start_scsi()
3144 ha->request_ring_ptr = in qla1280_32bit_start_scsi()
3145 ha->request_ring; in qla1280_32bit_start_scsi()
3147 ha->request_ring_ptr++; in qla1280_32bit_start_scsi()
3149 pkt = (struct cmd_entry *)ha->request_ring_ptr; in qla1280_32bit_start_scsi()
3160 (uint8_t) ha->req_ring_index; in qla1280_32bit_start_scsi()
3194 qla1280_dump_buffer(5, (char *)ha->request_ring_ptr, in qla1280_32bit_start_scsi()
3198 ha->req_ring_index++; in qla1280_32bit_start_scsi()
3199 if (ha->req_ring_index == REQUEST_ENTRY_CNT) { in qla1280_32bit_start_scsi()
3200 ha->req_ring_index = 0; in qla1280_32bit_start_scsi()
3201 ha->request_ring_ptr = ha->request_ring; in qla1280_32bit_start_scsi()
3203 ha->request_ring_ptr++; in qla1280_32bit_start_scsi()
3209 ha->actthreads++; in qla1280_32bit_start_scsi()
3210 WRT_REG_WORD(®->mailbox4, ha->req_ring_index); in qla1280_32bit_start_scsi()
3234 qla1280_req_pkt(struct scsi_qla_host *ha) in qla1280_req_pkt() argument
3236 struct device_reg __iomem *reg = ha->iobase; in qla1280_req_pkt()
3248 if (ha->req_q_cnt > 0) { in qla1280_req_pkt()
3251 if (ha->req_ring_index < cnt) in qla1280_req_pkt()
3252 ha->req_q_cnt = cnt - ha->req_ring_index; in qla1280_req_pkt()
3254 ha->req_q_cnt = in qla1280_req_pkt()
3255 REQUEST_ENTRY_CNT - (ha->req_ring_index - cnt); in qla1280_req_pkt()
3259 if (ha->req_q_cnt > 0) { in qla1280_req_pkt()
3260 ha->req_q_cnt--; in qla1280_req_pkt()
3261 pkt = ha->request_ring_ptr; in qla1280_req_pkt()
3271 pkt->sys_define = (uint8_t) ha->req_ring_index; in qla1280_req_pkt()
3282 qla1280_poll(ha); in qla1280_req_pkt()
3302 qla1280_isp_cmd(struct scsi_qla_host *ha) in qla1280_isp_cmd() argument
3304 struct device_reg __iomem *reg = ha->iobase; in qla1280_isp_cmd()
3309 qla1280_dump_buffer(5, (char *)ha->request_ring_ptr, in qla1280_isp_cmd()
3313 ha->req_ring_index++; in qla1280_isp_cmd()
3314 if (ha->req_ring_index == REQUEST_ENTRY_CNT) { in qla1280_isp_cmd()
3315 ha->req_ring_index = 0; in qla1280_isp_cmd()
3316 ha->request_ring_ptr = ha->request_ring; in qla1280_isp_cmd()
3318 ha->request_ring_ptr++; in qla1280_isp_cmd()
3323 WRT_REG_WORD(®->mailbox4, ha->req_ring_index); in qla1280_isp_cmd()
3341 qla1280_isr(struct scsi_qla_host *ha, struct list_head *done_q) in qla1280_isr() argument
3343 struct device_reg __iomem *reg = ha->iobase; in qla1280_isr()
3395 if (ha->flags.online) { in qla1280_isr()
3401 sp = ha->outstanding_cmds[index]; in qla1280_isr()
3407 ha->outstanding_cmds[index] = NULL; in qla1280_isr()
3426 ha->flags.reset_marker = 1; in qla1280_isr()
3428 ha->bus_settings[index].reset_marker = 1; in qla1280_isr()
3464 ha->flags.reset_marker = 1; in qla1280_isr()
3466 ha->bus_settings[index].reset_marker = 1; in qla1280_isr()
3478 memcpy((uint16_t *) ha->mailbox_out, wptr, in qla1280_isr()
3482 if(ha->mailbox_wait != NULL) in qla1280_isr()
3483 complete(ha->mailbox_wait); in qla1280_isr()
3495 if (!(ha->flags.online && !ha->mailbox_wait)) { in qla1280_isr()
3503 while (ha->rsp_ring_index != mailbox[5]) { in qla1280_isr()
3504 pkt = ha->response_ring_ptr; in qla1280_isr()
3507 " = 0x%x\n", ha->rsp_ring_index, mailbox[5]); in qla1280_isr()
3517 ha->rsp_ring_index, mailbox[5], in qla1280_isr()
3524 ha->rsp_ring_index, mailbox[5]); in qla1280_isr()
3532 ha->outstanding_cmds[pkt->handle]->cmd, in qla1280_isr()
3535 qla1280_status_entry(ha, pkt, done_q); in qla1280_isr()
3537 qla1280_error_entry(ha, pkt, done_q); in qla1280_isr()
3539 ha->rsp_ring_index++; in qla1280_isr()
3540 if (ha->rsp_ring_index == RESPONSE_ENTRY_CNT) { in qla1280_isr()
3541 ha->rsp_ring_index = 0; in qla1280_isr()
3542 ha->response_ring_ptr = ha->response_ring; in qla1280_isr()
3544 ha->response_ring_ptr++; in qla1280_isr()
3545 WRT_REG_WORD(®->mailbox5, ha->rsp_ring_index); in qla1280_isr()
3561 qla1280_rst_aen(struct scsi_qla_host *ha) in qla1280_rst_aen() argument
3567 if (ha->flags.online && !ha->flags.reset_active && in qla1280_rst_aen()
3568 !ha->flags.abort_isp_active) { in qla1280_rst_aen()
3569 ha->flags.reset_active = 1; in qla1280_rst_aen()
3570 while (ha->flags.reset_marker) { in qla1280_rst_aen()
3572 ha->flags.reset_marker = 0; in qla1280_rst_aen()
3573 for (bus = 0; bus < ha->ports && in qla1280_rst_aen()
3574 !ha->flags.reset_marker; bus++) { in qla1280_rst_aen()
3575 if (ha->bus_settings[bus].reset_marker) { in qla1280_rst_aen()
3576 ha->bus_settings[bus].reset_marker = 0; in qla1280_rst_aen()
3577 qla1280_marker(ha, bus, 0, 0, in qla1280_rst_aen()
3598 qla1280_status_entry(struct scsi_qla_host *ha, struct response *pkt, in qla1280_status_entry() argument
3612 sp = ha->outstanding_cmds[handle]; in qla1280_status_entry()
3622 ha->outstanding_cmds[handle] = NULL; in qla1280_status_entry()
3691 qla1280_error_entry(struct scsi_qla_host *ha, struct response *pkt, in qla1280_error_entry() argument
3710 sp = ha->outstanding_cmds[handle]; in qla1280_error_entry()
3716 ha->outstanding_cmds[handle] = NULL; in qla1280_error_entry()
3755 qla1280_abort_isp(struct scsi_qla_host *ha) in qla1280_abort_isp() argument
3757 struct device_reg __iomem *reg = ha->iobase; in qla1280_abort_isp()
3765 if (ha->flags.abort_isp_active || !ha->flags.online) in qla1280_abort_isp()
3768 ha->flags.abort_isp_active = 1; in qla1280_abort_isp()
3771 qla1280_disable_intrs(ha); in qla1280_abort_isp()
3776 ha->host_no); in qla1280_abort_isp()
3780 sp = ha->outstanding_cmds[cnt]; in qla1280_abort_isp()
3785 ha->outstanding_cmds[cnt] = NULL; in qla1280_abort_isp()
3786 list_add_tail(&sp->list, &ha->done_q); in qla1280_abort_isp()
3790 qla1280_done(ha); in qla1280_abort_isp()
3792 status = qla1280_load_firmware(ha); in qla1280_abort_isp()
3797 qla1280_nvram_config (ha); in qla1280_abort_isp()
3799 status = qla1280_init_rings(ha); in qla1280_abort_isp()
3804 for (bus = 0; bus < ha->ports; bus++) in qla1280_abort_isp()
3805 qla1280_bus_reset(ha, bus); in qla1280_abort_isp()
3807 ha->flags.abort_isp_active = 0; in qla1280_abort_isp()
3812 qla1280_reset_adapter(ha); in qla1280_abort_isp()
3861 qla1280_check_for_dead_scsi_bus(struct scsi_qla_host *ha, unsigned int bus) in qla1280_check_for_dead_scsi_bus() argument
3864 struct device_reg __iomem *reg = ha->iobase; in qla1280_check_for_dead_scsi_bus()
3866 if (ha->bus_settings[bus].scsi_bus_dead) { in qla1280_check_for_dead_scsi_bus()
3875 ha->bus_settings[bus].scsi_bus_dead = 1; in qla1280_check_for_dead_scsi_bus()
3878 ha->bus_settings[bus].scsi_bus_dead = 0; in qla1280_check_for_dead_scsi_bus()
3879 ha->bus_settings[bus].failed_reset_count = 0; in qla1280_check_for_dead_scsi_bus()
3886 qla1280_get_target_parameters(struct scsi_qla_host *ha, in qla1280_get_target_parameters() argument
3900 qla1280_mailbox_command(ha, BIT_6 | BIT_3 | BIT_2 | BIT_1 | BIT_0, in qla1280_get_target_parameters()
3903 printk(KERN_INFO "scsi(%li:%d:%d:%d):", ha->host_no, bus, target, lun); in qla1280_get_target_parameters()
3954 struct scsi_qla_host *ha; in __qla1280_print_scsi_cmd() local
3960 ha = (struct scsi_qla_host *)host->hostdata; in __qla1280_print_scsi_cmd()
3992 ql1280_dump_device(struct scsi_qla_host *ha) in ql1280_dump_device() argument
4002 if ((sp = ha->outstanding_cmds[i]) == NULL) in ql1280_dump_device()
4151 struct scsi_qla_host *ha; in qla1280_probe_one() local
4173 host = scsi_host_alloc(&qla1280_driver_template, sizeof(*ha)); in qla1280_probe_one()
4180 ha = (struct scsi_qla_host *)host->hostdata; in qla1280_probe_one()
4181 memset(ha, 0, sizeof(struct scsi_qla_host)); in qla1280_probe_one()
4183 ha->pdev = pdev; in qla1280_probe_one()
4184 ha->devnum = devnum; /* specifies microcode load address */ in qla1280_probe_one()
4187 if (dma_set_mask_and_coherent(&ha->pdev->dev, DMA_BIT_MASK(64))) { in qla1280_probe_one()
4188 if (dma_set_mask(&ha->pdev->dev, DMA_BIT_MASK(32))) { in qla1280_probe_one()
4190 "suitable DMA mask - aborting\n", ha->host_no); in qla1280_probe_one()
4196 ha->host_no); in qla1280_probe_one()
4198 if (dma_set_mask(&ha->pdev->dev, DMA_BIT_MASK(32))) { in qla1280_probe_one()
4200 "suitable DMA mask - aborting\n", ha->host_no); in qla1280_probe_one()
4206 ha->request_ring = dma_alloc_coherent(&ha->pdev->dev, in qla1280_probe_one()
4208 &ha->request_dma, GFP_KERNEL); in qla1280_probe_one()
4209 if (!ha->request_ring) { in qla1280_probe_one()
4214 ha->response_ring = dma_alloc_coherent(&ha->pdev->dev, in qla1280_probe_one()
4216 &ha->response_dma, GFP_KERNEL); in qla1280_probe_one()
4217 if (!ha->response_ring) { in qla1280_probe_one()
4222 ha->ports = bdp->numPorts; in qla1280_probe_one()
4224 ha->host = host; in qla1280_probe_one()
4225 ha->host_no = host->host_no; in qla1280_probe_one()
4237 ha->mmpbase = pci_ioremap_bar(ha->pdev, 1); in qla1280_probe_one()
4238 if (!ha->mmpbase) { in qla1280_probe_one()
4243 host->base = (unsigned long)ha->mmpbase; in qla1280_probe_one()
4244 ha->iobase = (struct device_reg __iomem *)ha->mmpbase; in qla1280_probe_one()
4246 host->io_port = pci_resource_start(ha->pdev, 0); in qla1280_probe_one()
4254 ha->iobase = (struct device_reg *)host->io_port; in qla1280_probe_one()
4257 INIT_LIST_HEAD(&ha->done_q); in qla1280_probe_one()
4260 qla1280_disable_intrs(ha); in qla1280_probe_one()
4263 "qla1280", ha)) { in qla1280_probe_one()
4270 if (qla1280_initialize_adapter(ha)) { in qla1280_probe_one()
4276 host->this_id = ha->bus_settings[0].id; in qla1280_probe_one()
4288 qla1280_disable_intrs(ha); in qla1280_probe_one()
4290 free_irq(pdev->irq, ha); in qla1280_probe_one()
4293 iounmap(ha->mmpbase); in qla1280_probe_one()
4298 dma_free_coherent(&ha->pdev->dev, in qla1280_probe_one()
4300 ha->response_ring, ha->response_dma); in qla1280_probe_one()
4302 dma_free_coherent(&ha->pdev->dev, in qla1280_probe_one()
4304 ha->request_ring, ha->request_dma); in qla1280_probe_one()
4318 struct scsi_qla_host *ha = (struct scsi_qla_host *)host->hostdata; in qla1280_remove_one() local
4322 qla1280_disable_intrs(ha); in qla1280_remove_one()
4324 free_irq(pdev->irq, ha); in qla1280_remove_one()
4327 iounmap(ha->mmpbase); in qla1280_remove_one()
4332 dma_free_coherent(&ha->pdev->dev, in qla1280_remove_one()
4334 ha->request_ring, ha->request_dma); in qla1280_remove_one()
4335 dma_free_coherent(&ha->pdev->dev, in qla1280_remove_one()
4337 ha->response_ring, ha->response_dma); in qla1280_remove_one()