Lines Matching refs:instance
100 int megasas_transition_to_ready(struct megasas_instance *instance, int ocr);
101 static int megasas_get_pd_list(struct megasas_instance *instance);
102 static int megasas_ld_list_query(struct megasas_instance *instance,
104 static int megasas_issue_init_mfi(struct megasas_instance *instance);
105 static int megasas_register_aen(struct megasas_instance *instance,
158 megasas_complete_cmd(struct megasas_instance *instance, struct megasas_cmd *cmd,
163 megasas_adp_reset_gen2(struct megasas_instance *instance,
167 megasas_init_adapter_mfi(struct megasas_instance *instance);
169 megasas_build_and_issue_cmd(struct megasas_instance *instance,
173 megasas_release_fusion(struct megasas_instance *instance);
175 megasas_ioc_init_fusion(struct megasas_instance *instance);
177 megasas_free_cmds_fusion(struct megasas_instance *instance);
179 megasas_get_map_info(struct megasas_instance *instance);
181 megasas_sync_map_info(struct megasas_instance *instance);
183 wait_and_poll(struct megasas_instance *instance, struct megasas_cmd *cmd,
185 void megasas_reset_reply_desc(struct megasas_instance *instance);
188 static int megasas_get_ld_vf_affiliation(struct megasas_instance *instance,
190 int megasas_check_mpio_paths(struct megasas_instance *instance,
194 megasas_issue_dcmd(struct megasas_instance *instance, struct megasas_cmd *cmd) in megasas_issue_dcmd() argument
196 instance->instancet->fire_cmd(instance, in megasas_issue_dcmd()
197 cmd->frame_phys_addr, 0, instance->reg_set); in megasas_issue_dcmd()
207 *instance) in megasas_get_cmd()
212 spin_lock_irqsave(&instance->mfi_pool_lock, flags); in megasas_get_cmd()
214 if (!list_empty(&instance->cmd_pool)) { in megasas_get_cmd()
215 cmd = list_entry((&instance->cmd_pool)->next, in megasas_get_cmd()
223 spin_unlock_irqrestore(&instance->mfi_pool_lock, flags); in megasas_get_cmd()
233 __megasas_return_cmd(struct megasas_instance *instance, struct megasas_cmd *cmd) in __megasas_return_cmd() argument
249 if ((instance->pdev->device != PCI_DEVICE_ID_LSI_FUSION) && in __megasas_return_cmd()
250 (instance->pdev->device != PCI_DEVICE_ID_LSI_INVADER) && in __megasas_return_cmd()
251 (instance->pdev->device != PCI_DEVICE_ID_LSI_FURY) && in __megasas_return_cmd()
256 list_add(&cmd->list, (&instance->cmd_pool)->next); in __megasas_return_cmd()
265 megasas_return_cmd(struct megasas_instance *instance, struct megasas_cmd *cmd) in megasas_return_cmd() argument
269 spin_lock_irqsave(&instance->mfi_pool_lock, flags); in megasas_return_cmd()
270 __megasas_return_cmd(instance, cmd); in megasas_return_cmd()
271 spin_unlock_irqrestore(&instance->mfi_pool_lock, flags); in megasas_return_cmd()
285 megasas_enable_intr_xscale(struct megasas_instance *instance) in megasas_enable_intr_xscale() argument
288 regs = instance->reg_set; in megasas_enable_intr_xscale()
300 megasas_disable_intr_xscale(struct megasas_instance *instance) in megasas_disable_intr_xscale() argument
304 regs = instance->reg_set; in megasas_disable_intr_xscale()
357 megasas_fire_cmd_xscale(struct megasas_instance *instance, in megasas_fire_cmd_xscale() argument
363 spin_lock_irqsave(&instance->hba_lock, flags); in megasas_fire_cmd_xscale()
366 spin_unlock_irqrestore(&instance->hba_lock, flags); in megasas_fire_cmd_xscale()
374 megasas_adp_reset_xscale(struct megasas_instance *instance, in megasas_adp_reset_xscale() argument
384 pci_read_config_dword(instance->pdev, MFI_1068_PCSR_OFFSET, &pcidata); in megasas_adp_reset_xscale()
389 pci_write_config_dword(instance->pdev, in megasas_adp_reset_xscale()
396 pci_read_config_dword(instance->pdev, in megasas_adp_reset_xscale()
402 pci_write_config_dword(instance->pdev, in megasas_adp_reset_xscale()
414 megasas_check_reset_xscale(struct megasas_instance *instance, in megasas_check_reset_xscale() argument
418 if ((instance->adprecovery != MEGASAS_HBA_OPERATIONAL) && in megasas_check_reset_xscale()
419 (le32_to_cpu(*instance->consumer) == in megasas_check_reset_xscale()
456 megasas_enable_intr_ppc(struct megasas_instance *instance) in megasas_enable_intr_ppc() argument
459 regs = instance->reg_set; in megasas_enable_intr_ppc()
473 megasas_disable_intr_ppc(struct megasas_instance *instance) in megasas_disable_intr_ppc() argument
477 regs = instance->reg_set; in megasas_disable_intr_ppc()
531 megasas_fire_cmd_ppc(struct megasas_instance *instance, in megasas_fire_cmd_ppc() argument
537 spin_lock_irqsave(&instance->hba_lock, flags); in megasas_fire_cmd_ppc()
540 spin_unlock_irqrestore(&instance->hba_lock, flags); in megasas_fire_cmd_ppc()
548 megasas_check_reset_ppc(struct megasas_instance *instance, in megasas_check_reset_ppc() argument
551 if (instance->adprecovery != MEGASAS_HBA_OPERATIONAL) in megasas_check_reset_ppc()
578 megasas_enable_intr_skinny(struct megasas_instance *instance) in megasas_enable_intr_skinny() argument
581 regs = instance->reg_set; in megasas_enable_intr_skinny()
595 megasas_disable_intr_skinny(struct megasas_instance *instance) in megasas_disable_intr_skinny() argument
599 regs = instance->reg_set; in megasas_disable_intr_skinny()
663 megasas_fire_cmd_skinny(struct megasas_instance *instance, in megasas_fire_cmd_skinny() argument
669 spin_lock_irqsave(&instance->hba_lock, flags); in megasas_fire_cmd_skinny()
674 spin_unlock_irqrestore(&instance->hba_lock, flags); in megasas_fire_cmd_skinny()
682 megasas_check_reset_skinny(struct megasas_instance *instance, in megasas_check_reset_skinny() argument
685 if (instance->adprecovery != MEGASAS_HBA_OPERATIONAL) in megasas_check_reset_skinny()
718 megasas_enable_intr_gen2(struct megasas_instance *instance) in megasas_enable_intr_gen2() argument
721 regs = instance->reg_set; in megasas_enable_intr_gen2()
736 megasas_disable_intr_gen2(struct megasas_instance *instance) in megasas_disable_intr_gen2() argument
740 regs = instance->reg_set; in megasas_disable_intr_gen2()
795 megasas_fire_cmd_gen2(struct megasas_instance *instance, in megasas_fire_cmd_gen2() argument
801 spin_lock_irqsave(&instance->hba_lock, flags); in megasas_fire_cmd_gen2()
804 spin_unlock_irqrestore(&instance->hba_lock, flags); in megasas_fire_cmd_gen2()
812 megasas_adp_reset_gen2(struct megasas_instance *instance, in megasas_adp_reset_gen2() argument
820 if (instance->instancet == &megasas_instance_template_skinny) { in megasas_adp_reset_gen2()
872 megasas_check_reset_gen2(struct megasas_instance *instance, in megasas_check_reset_gen2() argument
875 if (instance->adprecovery != MEGASAS_HBA_OPERATIONAL) { in megasas_check_reset_gen2()
916 megasas_issue_polled(struct megasas_instance *instance, struct megasas_cmd *cmd) in megasas_issue_polled() argument
928 instance->instancet->issue_dcmd(instance, cmd); in megasas_issue_polled()
933 if (instance->requestorId) in megasas_issue_polled()
937 return wait_and_poll(instance, cmd, seconds); in megasas_issue_polled()
951 megasas_issue_blocked_cmd(struct megasas_instance *instance, in megasas_issue_blocked_cmd() argument
958 instance->instancet->issue_dcmd(instance, cmd); in megasas_issue_blocked_cmd()
960 ret = wait_event_timeout(instance->int_cmd_wait_q, in megasas_issue_blocked_cmd()
965 wait_event(instance->int_cmd_wait_q, in megasas_issue_blocked_cmd()
983 megasas_issue_blocked_abort_cmd(struct megasas_instance *instance, in megasas_issue_blocked_abort_cmd() argument
990 cmd = megasas_get_cmd(instance); in megasas_issue_blocked_abort_cmd()
1012 instance->instancet->issue_dcmd(instance, cmd); in megasas_issue_blocked_abort_cmd()
1015 ret = wait_event_timeout(instance->abort_cmd_wait_q, in megasas_issue_blocked_abort_cmd()
1018 dev_err(&instance->pdev->dev, "Command timedout" in megasas_issue_blocked_abort_cmd()
1023 wait_event(instance->abort_cmd_wait_q, in megasas_issue_blocked_abort_cmd()
1028 megasas_return_cmd(instance, cmd); in megasas_issue_blocked_abort_cmd()
1042 megasas_make_sgl32(struct megasas_instance *instance, struct scsi_cmnd *scp, in megasas_make_sgl32() argument
1071 megasas_make_sgl64(struct megasas_instance *instance, struct scsi_cmnd *scp, in megasas_make_sgl64() argument
1100 megasas_make_sgl_skinny(struct megasas_instance *instance, in megasas_make_sgl_skinny() argument
1129 static u32 megasas_get_frame_count(struct megasas_instance *instance, in megasas_get_frame_count() argument
1140 if (instance->flag_ieee) { in megasas_get_frame_count()
1151 if (instance->flag_ieee == 1) { in megasas_get_frame_count()
1158 if (instance->flag_ieee == 1) { in megasas_get_frame_count()
1190 megasas_build_dcdb(struct megasas_instance *instance, struct scsi_cmnd *scp, in megasas_build_dcdb() argument
1199 device_id = MEGASAS_DEV_INDEX(instance, scp); in megasas_build_dcdb()
1209 if (instance->flag_ieee == 1) { in megasas_build_dcdb()
1243 if (instance->flag_ieee == 1) { in megasas_build_dcdb()
1245 pthru->sge_count = megasas_make_sgl_skinny(instance, scp, in megasas_build_dcdb()
1249 pthru->sge_count = megasas_make_sgl64(instance, scp, in megasas_build_dcdb()
1252 pthru->sge_count = megasas_make_sgl32(instance, scp, in megasas_build_dcdb()
1255 if (pthru->sge_count > instance->max_num_sge) { in megasas_build_dcdb()
1274 cmd->frame_count = megasas_get_frame_count(instance, pthru->sge_count, in megasas_build_dcdb()
1289 megasas_build_ldio(struct megasas_instance *instance, struct scsi_cmnd *scp, in megasas_build_ldio() argument
1297 device_id = MEGASAS_DEV_INDEX(instance, scp); in megasas_build_ldio()
1305 if (instance->flag_ieee == 1) { in megasas_build_ldio()
1386 if (instance->flag_ieee) { in megasas_build_ldio()
1388 ldio->sge_count = megasas_make_sgl_skinny(instance, scp, in megasas_build_ldio()
1392 ldio->sge_count = megasas_make_sgl64(instance, scp, &ldio->sgl); in megasas_build_ldio()
1394 ldio->sge_count = megasas_make_sgl32(instance, scp, &ldio->sgl); in megasas_build_ldio()
1396 if (ldio->sge_count > instance->max_num_sge) { in megasas_build_ldio()
1413 cmd->frame_count = megasas_get_frame_count(instance, in megasas_build_ldio()
1454 megasas_dump_pending_frames(struct megasas_instance *instance) in megasas_dump_pending_frames() argument
1462 u32 max_cmd = instance->max_fw_cmds; in megasas_dump_pending_frames()
1464 …printk(KERN_ERR "\nmegasas[%d]: Dumping Frame Phys Address of all pending cmds in FW\n",instance->… in megasas_dump_pending_frames()
1465 …(KERN_ERR "megasas[%d]: Total OS Pending cmds : %d\n",instance->host->host_no,atomic_read(&instanc… in megasas_dump_pending_frames()
1467 printk(KERN_ERR "\nmegasas[%d]: 64 bit SGLs were sent to FW\n",instance->host->host_no); in megasas_dump_pending_frames()
1469 printk(KERN_ERR "\nmegasas[%d]: 32 bit SGLs were sent to FW\n",instance->host->host_no); in megasas_dump_pending_frames()
1471 printk(KERN_ERR "megasas[%d]: Pending OS cmds in FW : \n",instance->host->host_no); in megasas_dump_pending_frames()
1473 cmd = instance->cmd_list[i]; in megasas_dump_pending_frames()
1476 …printk(KERN_ERR "megasas[%d]: Frame addr :0x%08lx : ",instance->host->host_no,(unsigned long)cmd->… in megasas_dump_pending_frames()
1483 instance->host->host_no, cmd->frame_count, ldio->cmd, ldio->target_id, in megasas_dump_pending_frames()
1493 instance->host->host_no, cmd->frame_count, pthru->cmd, pthru->target_id, in megasas_dump_pending_frames()
1511 printk(KERN_ERR "\nmegasas[%d]: Pending Internal cmds in FW : \n",instance->host->host_no); in megasas_dump_pending_frames()
1514 cmd = instance->cmd_list[i]; in megasas_dump_pending_frames()
1520 printk(KERN_ERR "megasas[%d]: Dumping Done.\n\n",instance->host->host_no); in megasas_dump_pending_frames()
1524 megasas_build_and_issue_cmd(struct megasas_instance *instance, in megasas_build_and_issue_cmd() argument
1530 cmd = megasas_get_cmd(instance); in megasas_build_and_issue_cmd()
1538 frame_count = megasas_build_ldio(instance, scmd, cmd); in megasas_build_and_issue_cmd()
1540 frame_count = megasas_build_dcdb(instance, scmd, cmd); in megasas_build_and_issue_cmd()
1551 atomic_inc(&instance->fw_outstanding); in megasas_build_and_issue_cmd()
1553 instance->instancet->fire_cmd(instance, cmd->frame_phys_addr, in megasas_build_and_issue_cmd()
1554 cmd->frame_count-1, instance->reg_set); in megasas_build_and_issue_cmd()
1558 megasas_return_cmd(instance, cmd); in megasas_build_and_issue_cmd()
1571 struct megasas_instance *instance; in megasas_queue_command() local
1574 instance = (struct megasas_instance *) in megasas_queue_command()
1577 if (instance->unload == 1) { in megasas_queue_command()
1583 if (instance->issuepend_done == 0) in megasas_queue_command()
1586 spin_lock_irqsave(&instance->hba_lock, flags); in megasas_queue_command()
1589 if (instance->adprecovery == MEGASAS_ADPRESET_SM_INFAULT) { in megasas_queue_command()
1590 if (megasas_check_mpio_paths(instance, scmd) == in megasas_queue_command()
1592 spin_unlock_irqrestore(&instance->hba_lock, flags); in megasas_queue_command()
1595 spin_unlock_irqrestore(&instance->hba_lock, flags); in megasas_queue_command()
1602 if (instance->adprecovery == MEGASAS_HW_CRITICAL_ERROR) { in megasas_queue_command()
1603 spin_unlock_irqrestore(&instance->hba_lock, flags); in megasas_queue_command()
1609 if (instance->adprecovery != MEGASAS_HBA_OPERATIONAL) { in megasas_queue_command()
1610 spin_unlock_irqrestore(&instance->hba_lock, flags); in megasas_queue_command()
1614 spin_unlock_irqrestore(&instance->hba_lock, flags); in megasas_queue_command()
1619 (scmd->device->id >= instance->fw_supported_vd_count || in megasas_queue_command()
1637 if (instance->instancet->build_and_issue_cmd(instance, scmd)) { in megasas_queue_command()
1655 if ((megasas_mgmt_info.instance[i]) && in megasas_lookup_instance()
1656 (megasas_mgmt_info.instance[i]->host->host_no == host_no)) in megasas_lookup_instance()
1657 return megasas_mgmt_info.instance[i]; in megasas_lookup_instance()
1677 struct megasas_instance *instance ; in megasas_slave_alloc() local
1678 instance = megasas_lookup_instance(sdev->host->host_no); in megasas_slave_alloc()
1686 if (instance->pd_list[pd_index].driveState == in megasas_slave_alloc()
1701 void megasas_complete_outstanding_ioctls(struct megasas_instance *instance) in megasas_complete_outstanding_ioctls() argument
1706 struct fusion_context *fusion = instance->ctrl_context; in megasas_complete_outstanding_ioctls()
1710 for (i = 0; i < instance->max_fw_cmds; i++) { in megasas_complete_outstanding_ioctls()
1713 cmd_mfi = instance->cmd_list[cmd_fusion->sync_cmd_idx]; in megasas_complete_outstanding_ioctls()
1716 megasas_complete_cmd(instance, in megasas_complete_outstanding_ioctls()
1721 for (i = 0; i < instance->max_fw_cmds; i++) { in megasas_complete_outstanding_ioctls()
1722 cmd_mfi = instance->cmd_list[i]; in megasas_complete_outstanding_ioctls()
1725 megasas_complete_cmd(instance, cmd_mfi, DID_OK); in megasas_complete_outstanding_ioctls()
1731 void megaraid_sas_kill_hba(struct megasas_instance *instance) in megaraid_sas_kill_hba() argument
1734 instance->adprecovery = MEGASAS_HW_CRITICAL_ERROR; in megaraid_sas_kill_hba()
1737 if ((instance->pdev->device == PCI_DEVICE_ID_LSI_SAS0073SKINNY) || in megaraid_sas_kill_hba()
1738 (instance->pdev->device == PCI_DEVICE_ID_LSI_SAS0071SKINNY) || in megaraid_sas_kill_hba()
1739 (instance->pdev->device == PCI_DEVICE_ID_LSI_FUSION) || in megaraid_sas_kill_hba()
1740 (instance->pdev->device == PCI_DEVICE_ID_LSI_PLASMA) || in megaraid_sas_kill_hba()
1741 (instance->pdev->device == PCI_DEVICE_ID_LSI_INVADER) || in megaraid_sas_kill_hba()
1742 (instance->pdev->device == PCI_DEVICE_ID_LSI_FURY)) { in megaraid_sas_kill_hba()
1744 &instance->reg_set->doorbell); in megaraid_sas_kill_hba()
1746 readl(&instance->reg_set->doorbell); in megaraid_sas_kill_hba()
1747 if (instance->mpio && instance->requestorId) in megaraid_sas_kill_hba()
1748 memset(instance->ld_ids, 0xff, MEGASAS_MAX_LD_IDS); in megaraid_sas_kill_hba()
1751 &instance->reg_set->inbound_doorbell); in megaraid_sas_kill_hba()
1754 megasas_complete_outstanding_ioctls(instance); in megaraid_sas_kill_hba()
1764 megasas_check_and_restore_queue_depth(struct megasas_instance *instance) in megasas_check_and_restore_queue_depth() argument
1768 if (instance->flag & MEGASAS_FW_BUSY in megasas_check_and_restore_queue_depth()
1769 && time_after(jiffies, instance->last_time + 5 * HZ) in megasas_check_and_restore_queue_depth()
1770 && atomic_read(&instance->fw_outstanding) < in megasas_check_and_restore_queue_depth()
1771 instance->throttlequeuedepth + 1) { in megasas_check_and_restore_queue_depth()
1773 spin_lock_irqsave(instance->host->host_lock, flags); in megasas_check_and_restore_queue_depth()
1774 instance->flag &= ~MEGASAS_FW_BUSY; in megasas_check_and_restore_queue_depth()
1776 instance->host->can_queue = instance->max_scsi_cmds; in megasas_check_and_restore_queue_depth()
1777 spin_unlock_irqrestore(instance->host->host_lock, flags); in megasas_check_and_restore_queue_depth()
1793 struct megasas_instance *instance = in megasas_complete_cmd_dpc() local
1798 if (instance->adprecovery == MEGASAS_HW_CRITICAL_ERROR ) in megasas_complete_cmd_dpc()
1801 spin_lock_irqsave(&instance->completion_lock, flags); in megasas_complete_cmd_dpc()
1803 producer = le32_to_cpu(*instance->producer); in megasas_complete_cmd_dpc()
1804 consumer = le32_to_cpu(*instance->consumer); in megasas_complete_cmd_dpc()
1807 context = le32_to_cpu(instance->reply_queue[consumer]); in megasas_complete_cmd_dpc()
1808 if (context >= instance->max_fw_cmds) { in megasas_complete_cmd_dpc()
1814 cmd = instance->cmd_list[context]; in megasas_complete_cmd_dpc()
1816 megasas_complete_cmd(instance, cmd, DID_OK); in megasas_complete_cmd_dpc()
1819 if (consumer == (instance->max_fw_cmds + 1)) { in megasas_complete_cmd_dpc()
1824 *instance->consumer = cpu_to_le32(producer); in megasas_complete_cmd_dpc()
1826 spin_unlock_irqrestore(&instance->completion_lock, flags); in megasas_complete_cmd_dpc()
1831 megasas_check_and_restore_queue_depth(instance); in megasas_complete_cmd_dpc()
1842 void megasas_start_timer(struct megasas_instance *instance, in megasas_start_timer() argument
1848 timer->data = (unsigned long)instance; in megasas_start_timer()
1854 megasas_internal_reset_defer_cmds(struct megasas_instance *instance);
1859 void megasas_do_ocr(struct megasas_instance *instance) in megasas_do_ocr() argument
1861 if ((instance->pdev->device == PCI_DEVICE_ID_LSI_SAS1064R) || in megasas_do_ocr()
1862 (instance->pdev->device == PCI_DEVICE_ID_DELL_PERC5) || in megasas_do_ocr()
1863 (instance->pdev->device == PCI_DEVICE_ID_LSI_VERDE_ZCR)) { in megasas_do_ocr()
1864 *instance->consumer = cpu_to_le32(MEGASAS_ADPRESET_INPROG_SIGN); in megasas_do_ocr()
1866 instance->instancet->disable_intr(instance); in megasas_do_ocr()
1867 instance->adprecovery = MEGASAS_ADPRESET_SM_INFAULT; in megasas_do_ocr()
1868 instance->issuepend_done = 0; in megasas_do_ocr()
1870 atomic_set(&instance->fw_outstanding, 0); in megasas_do_ocr()
1871 megasas_internal_reset_defer_cmds(instance); in megasas_do_ocr()
1872 process_fw_state_change_wq(&instance->work_init); in megasas_do_ocr()
1875 static int megasas_get_ld_vf_affiliation_111(struct megasas_instance *instance, in megasas_get_ld_vf_affiliation_111() argument
1885 cmd = megasas_get_cmd(instance); in megasas_get_ld_vf_affiliation_111()
1890 instance->host->host_no); in megasas_get_ld_vf_affiliation_111()
1896 if (!instance->vf_affiliation_111) { in megasas_get_ld_vf_affiliation_111()
1898 "affiliation for scsi%d.\n", instance->host->host_no); in megasas_get_ld_vf_affiliation_111()
1899 megasas_return_cmd(instance, cmd); in megasas_get_ld_vf_affiliation_111()
1904 memset(instance->vf_affiliation_111, 0, in megasas_get_ld_vf_affiliation_111()
1908 pci_alloc_consistent(instance->pdev, in megasas_get_ld_vf_affiliation_111()
1914 instance->host->host_no); in megasas_get_ld_vf_affiliation_111()
1915 megasas_return_cmd(instance, cmd); in megasas_get_ld_vf_affiliation_111()
1935 instance->vf_affiliation_111_h; in megasas_get_ld_vf_affiliation_111()
1943 "scsi%d\n", instance->host->host_no); in megasas_get_ld_vf_affiliation_111()
1945 megasas_issue_blocked_cmd(instance, cmd, 0); in megasas_get_ld_vf_affiliation_111()
1950 dcmd->cmd_status, instance->host->host_no); in megasas_get_ld_vf_affiliation_111()
1958 if (instance->vf_affiliation_111->map[ld].policy[thisVf] != in megasas_get_ld_vf_affiliation_111()
1963 instance->host->host_no); in megasas_get_ld_vf_affiliation_111()
1964 memcpy(instance->vf_affiliation_111, in megasas_get_ld_vf_affiliation_111()
1973 pci_free_consistent(instance->pdev, in megasas_get_ld_vf_affiliation_111()
1979 if (instance->ctrl_context && cmd->mpt_pthr_cmd_blocked) in megasas_get_ld_vf_affiliation_111()
1980 megasas_return_mfi_mpt_pthr(instance, cmd, in megasas_get_ld_vf_affiliation_111()
1983 megasas_return_cmd(instance, cmd); in megasas_get_ld_vf_affiliation_111()
1988 static int megasas_get_ld_vf_affiliation_12(struct megasas_instance *instance, in megasas_get_ld_vf_affiliation_12() argument
1999 cmd = megasas_get_cmd(instance); in megasas_get_ld_vf_affiliation_12()
2004 instance->host->host_no); in megasas_get_ld_vf_affiliation_12()
2010 if (!instance->vf_affiliation) { in megasas_get_ld_vf_affiliation_12()
2012 "affiliation for scsi%d.\n", instance->host->host_no); in megasas_get_ld_vf_affiliation_12()
2013 megasas_return_cmd(instance, cmd); in megasas_get_ld_vf_affiliation_12()
2018 memset(instance->vf_affiliation, 0, (MAX_LOGICAL_DRIVES + 1) * in megasas_get_ld_vf_affiliation_12()
2022 pci_alloc_consistent(instance->pdev, in megasas_get_ld_vf_affiliation_12()
2029 instance->host->host_no); in megasas_get_ld_vf_affiliation_12()
2030 megasas_return_cmd(instance, cmd); in megasas_get_ld_vf_affiliation_12()
2050 dcmd->sgl.sge32[0].phys_addr = instance->vf_affiliation_h; in megasas_get_ld_vf_affiliation_12()
2058 "scsi%d\n", instance->host->host_no); in megasas_get_ld_vf_affiliation_12()
2060 megasas_issue_blocked_cmd(instance, cmd, 0); in megasas_get_ld_vf_affiliation_12()
2065 dcmd->cmd_status, instance->host->host_no); in megasas_get_ld_vf_affiliation_12()
2074 instance->host->host_no); in megasas_get_ld_vf_affiliation_12()
2079 savedmap = instance->vf_affiliation->map; in megasas_get_ld_vf_affiliation_12()
2083 for (j = 0; j < instance->vf_affiliation->ldCount; in megasas_get_ld_vf_affiliation_12()
2108 savedmap = instance->vf_affiliation->map; in megasas_get_ld_vf_affiliation_12()
2110 for (i = 0 ; i < instance->vf_affiliation->ldCount; i++) { in megasas_get_ld_vf_affiliation_12()
2139 "affiliation for scsi%d.\n", instance->host->host_no); in megasas_get_ld_vf_affiliation_12()
2140 memcpy(instance->vf_affiliation, new_affiliation, in megasas_get_ld_vf_affiliation_12()
2146 pci_free_consistent(instance->pdev, in megasas_get_ld_vf_affiliation_12()
2150 if (instance->ctrl_context && cmd->mpt_pthr_cmd_blocked) in megasas_get_ld_vf_affiliation_12()
2151 megasas_return_mfi_mpt_pthr(instance, cmd, in megasas_get_ld_vf_affiliation_12()
2154 megasas_return_cmd(instance, cmd); in megasas_get_ld_vf_affiliation_12()
2160 static int megasas_get_ld_vf_affiliation(struct megasas_instance *instance, in megasas_get_ld_vf_affiliation() argument
2165 if (instance->PlasmaFW111) in megasas_get_ld_vf_affiliation()
2166 retval = megasas_get_ld_vf_affiliation_111(instance, initial); in megasas_get_ld_vf_affiliation()
2168 retval = megasas_get_ld_vf_affiliation_12(instance, initial); in megasas_get_ld_vf_affiliation()
2173 int megasas_sriov_start_heartbeat(struct megasas_instance *instance, in megasas_sriov_start_heartbeat() argument
2180 cmd = megasas_get_cmd(instance); in megasas_sriov_start_heartbeat()
2185 instance->host->host_no); in megasas_sriov_start_heartbeat()
2192 instance->hb_host_mem = in megasas_sriov_start_heartbeat()
2193 pci_zalloc_consistent(instance->pdev, in megasas_sriov_start_heartbeat()
2195 &instance->hb_host_mem_h); in megasas_sriov_start_heartbeat()
2196 if (!instance->hb_host_mem) { in megasas_sriov_start_heartbeat()
2199 "scsi%d.\n", instance->host->host_no); in megasas_sriov_start_heartbeat()
2216 dcmd->sgl.sge32[0].phys_addr = instance->hb_host_mem_h; in megasas_sriov_start_heartbeat()
2220 instance->host->host_no); in megasas_sriov_start_heartbeat()
2222 if (!megasas_issue_polled(instance, cmd)) { in megasas_sriov_start_heartbeat()
2227 instance->host->host_no); in megasas_sriov_start_heartbeat()
2237 instance->host->host_no); in megasas_sriov_start_heartbeat()
2243 megasas_return_cmd(instance, cmd); in megasas_sriov_start_heartbeat()
2251 struct megasas_instance *instance = in megasas_sriov_heartbeat_handler() local
2254 if (instance->hb_host_mem->HB.fwCounter != in megasas_sriov_heartbeat_handler()
2255 instance->hb_host_mem->HB.driverCounter) { in megasas_sriov_heartbeat_handler()
2256 instance->hb_host_mem->HB.driverCounter = in megasas_sriov_heartbeat_handler()
2257 instance->hb_host_mem->HB.fwCounter; in megasas_sriov_heartbeat_handler()
2258 mod_timer(&instance->sriov_heartbeat_timer, in megasas_sriov_heartbeat_handler()
2262 "completed for scsi%d\n", instance->host->host_no); in megasas_sriov_heartbeat_handler()
2263 schedule_work(&instance->work_init); in megasas_sriov_heartbeat_handler()
2275 static int megasas_wait_for_outstanding(struct megasas_instance *instance) in megasas_wait_for_outstanding() argument
2287 spin_lock_irqsave(&instance->hba_lock, flags); in megasas_wait_for_outstanding()
2288 adprecovery = instance->adprecovery; in megasas_wait_for_outstanding()
2289 spin_unlock_irqrestore(&instance->hba_lock, flags); in megasas_wait_for_outstanding()
2294 spin_lock_irqsave(&instance->hba_lock, flags); in megasas_wait_for_outstanding()
2295 list_splice_init(&instance->internal_reset_pending_q, in megasas_wait_for_outstanding()
2297 spin_unlock_irqrestore(&instance->hba_lock, flags); in megasas_wait_for_outstanding()
2302 spin_lock_irqsave(&instance->hba_lock, flags); in megasas_wait_for_outstanding()
2303 adprecovery = instance->adprecovery; in megasas_wait_for_outstanding()
2304 spin_unlock_irqrestore(&instance->hba_lock, flags); in megasas_wait_for_outstanding()
2311 spin_lock_irqsave(&instance->hba_lock, flags); in megasas_wait_for_outstanding()
2312 instance->adprecovery = MEGASAS_HW_CRITICAL_ERROR; in megasas_wait_for_outstanding()
2313 spin_unlock_irqrestore(&instance->hba_lock, flags); in megasas_wait_for_outstanding()
2329 megasas_return_cmd(instance, reset_cmd); in megasas_wait_for_outstanding()
2336 instance->instancet->fire_cmd(instance, in megasas_wait_for_outstanding()
2338 0, instance->reg_set); in megasas_wait_for_outstanding()
2352 int outstanding = atomic_read(&instance->fw_outstanding); in megasas_wait_for_outstanding()
2364 megasas_complete_cmd_dpc((unsigned long)instance); in megasas_wait_for_outstanding()
2373 fw_state = instance->instancet->read_fw_status_reg( in megasas_wait_for_outstanding()
2374 instance->reg_set) & MFI_STATE_MASK; in megasas_wait_for_outstanding()
2376 (instance->disableOnlineCtrlReset == 0)) { in megasas_wait_for_outstanding()
2381 megasas_do_ocr(instance); in megasas_wait_for_outstanding()
2390 if (atomic_read(&instance->fw_outstanding) && in megasas_wait_for_outstanding()
2392 if (instance->disableOnlineCtrlReset == 0) { in megasas_wait_for_outstanding()
2394 megasas_do_ocr(instance); in megasas_wait_for_outstanding()
2399 atomic_read(&instance->fw_outstanding); in megasas_wait_for_outstanding()
2407 if (atomic_read(&instance->fw_outstanding) || in megasas_wait_for_outstanding()
2414 if ((instance->pdev->device == in megasas_wait_for_outstanding()
2416 (instance->pdev->device == in megasas_wait_for_outstanding()
2419 &instance->reg_set->doorbell); in megasas_wait_for_outstanding()
2422 &instance->reg_set->inbound_doorbell); in megasas_wait_for_outstanding()
2424 megasas_dump_pending_frames(instance); in megasas_wait_for_outstanding()
2425 spin_lock_irqsave(&instance->hba_lock, flags); in megasas_wait_for_outstanding()
2426 instance->adprecovery = MEGASAS_HW_CRITICAL_ERROR; in megasas_wait_for_outstanding()
2427 spin_unlock_irqrestore(&instance->hba_lock, flags); in megasas_wait_for_outstanding()
2447 struct megasas_instance *instance; in megasas_generic_reset() local
2449 instance = (struct megasas_instance *)scmd->device->host->hostdata; in megasas_generic_reset()
2454 if (instance->adprecovery == MEGASAS_HW_CRITICAL_ERROR) { in megasas_generic_reset()
2460 ret_val = megasas_wait_for_outstanding(instance); in megasas_generic_reset()
2479 struct megasas_instance *instance; in megasas_reset_timer() local
2487 instance = (struct megasas_instance *)scmd->device->host->hostdata; in megasas_reset_timer()
2488 if (!(instance->flag & MEGASAS_FW_BUSY)) { in megasas_reset_timer()
2490 spin_lock_irqsave(instance->host->host_lock, flags); in megasas_reset_timer()
2492 instance->host->can_queue = instance->throttlequeuedepth; in megasas_reset_timer()
2493 instance->last_time = jiffies; in megasas_reset_timer()
2494 instance->flag |= MEGASAS_FW_BUSY; in megasas_reset_timer()
2496 spin_unlock_irqrestore(instance->host->host_lock, flags); in megasas_reset_timer()
2522 struct megasas_instance *instance; in megasas_reset_bus_host() local
2523 instance = (struct megasas_instance *)scmd->device->host->hostdata; in megasas_reset_bus_host()
2528 if ((instance->pdev->device == PCI_DEVICE_ID_LSI_FUSION) || in megasas_reset_bus_host()
2529 (instance->pdev->device == PCI_DEVICE_ID_LSI_PLASMA) || in megasas_reset_bus_host()
2530 (instance->pdev->device == PCI_DEVICE_ID_LSI_INVADER) || in megasas_reset_bus_host()
2531 (instance->pdev->device == PCI_DEVICE_ID_LSI_FURY)) in megasas_reset_bus_host()
2597 megasas_service_aen(struct megasas_instance *instance, struct megasas_cmd *cmd) in megasas_service_aen() argument
2603 if ((!cmd->abort_aen) && (instance->unload == 0)) { in megasas_service_aen()
2613 instance->aen_cmd = NULL; in megasas_service_aen()
2615 if (instance->ctrl_context && cmd->mpt_pthr_cmd_blocked) in megasas_service_aen()
2616 megasas_return_mfi_mpt_pthr(instance, cmd, in megasas_service_aen()
2619 megasas_return_cmd(instance, cmd); in megasas_service_aen()
2621 if ((instance->unload == 0) && in megasas_service_aen()
2622 ((instance->issuepend_done == 1))) { in megasas_service_aen()
2628 ev->instance = instance; in megasas_service_aen()
2629 instance->ev = ev; in megasas_service_aen()
2642 struct megasas_instance *instance = in megasas_fw_crash_buffer_store() local
2650 spin_lock_irqsave(&instance->crashdump_lock, flags); in megasas_fw_crash_buffer_store()
2651 instance->fw_crash_buffer_offset = val; in megasas_fw_crash_buffer_store()
2652 spin_unlock_irqrestore(&instance->crashdump_lock, flags); in megasas_fw_crash_buffer_store()
2661 struct megasas_instance *instance = in megasas_fw_crash_buffer_show() local
2670 spin_lock_irqsave(&instance->crashdump_lock, flags); in megasas_fw_crash_buffer_show()
2671 buff_offset = instance->fw_crash_buffer_offset; in megasas_fw_crash_buffer_show()
2672 if (!instance->crash_dump_buf && in megasas_fw_crash_buffer_show()
2673 !((instance->fw_crash_state == AVAILABLE) || in megasas_fw_crash_buffer_show()
2674 (instance->fw_crash_state == COPYING))) { in megasas_fw_crash_buffer_show()
2675 dev_err(&instance->pdev->dev, in megasas_fw_crash_buffer_show()
2677 spin_unlock_irqrestore(&instance->crashdump_lock, flags); in megasas_fw_crash_buffer_show()
2684 (instance->fw_crash_buffer_size * dmachunk)) { in megasas_fw_crash_buffer_show()
2685 dev_err(&instance->pdev->dev, in megasas_fw_crash_buffer_show()
2687 spin_unlock_irqrestore(&instance->crashdump_lock, flags); in megasas_fw_crash_buffer_show()
2691 size = (instance->fw_crash_buffer_size * dmachunk) - buff_offset; in megasas_fw_crash_buffer_show()
2694 src_addr = (unsigned long)instance->crash_buf[buff_offset / dmachunk] + in megasas_fw_crash_buffer_show()
2697 spin_unlock_irqrestore(&instance->crashdump_lock, flags); in megasas_fw_crash_buffer_show()
2707 struct megasas_instance *instance = in megasas_fw_crash_buffer_size_show() local
2711 ((instance->fw_crash_buffer_size) * 1024 * 1024)/PAGE_SIZE); in megasas_fw_crash_buffer_size_show()
2719 struct megasas_instance *instance = in megasas_fw_crash_state_store() local
2728 dev_err(&instance->pdev->dev, "application updates invalid " in megasas_fw_crash_state_store()
2733 instance->fw_crash_state = val; in megasas_fw_crash_state_store()
2736 spin_lock_irqsave(&instance->crashdump_lock, flags); in megasas_fw_crash_state_store()
2737 megasas_free_host_crash_buffer(instance); in megasas_fw_crash_state_store()
2738 spin_unlock_irqrestore(&instance->crashdump_lock, flags); in megasas_fw_crash_state_store()
2740 dev_info(&instance->pdev->dev, "application failed to " in megasas_fw_crash_state_store()
2743 dev_info(&instance->pdev->dev, "Firmware crash dump " in megasas_fw_crash_state_store()
2754 struct megasas_instance *instance = in megasas_fw_crash_state_show() local
2756 return snprintf(buf, PAGE_SIZE, "%d\n", instance->fw_crash_state); in megasas_fw_crash_state_show()
2815 megasas_complete_int_cmd(struct megasas_instance *instance, in megasas_complete_int_cmd() argument
2823 wake_up(&instance->int_cmd_wait_q); in megasas_complete_int_cmd()
2836 megasas_complete_abort(struct megasas_instance *instance, in megasas_complete_abort() argument
2842 wake_up(&instance->abort_cmd_wait_q); in megasas_complete_abort()
2859 megasas_complete_cmd(struct megasas_instance *instance, struct megasas_cmd *cmd, in megasas_complete_cmd() argument
2865 struct fusion_context *fusion = instance->ctrl_context; in megasas_complete_cmd()
2895 megasas_complete_int_cmd(instance, cmd); in megasas_complete_cmd()
2909 atomic_dec(&instance->fw_outstanding); in megasas_complete_cmd()
2913 megasas_return_cmd(instance, cmd); in megasas_complete_cmd()
2957 atomic_dec(&instance->fw_outstanding); in megasas_complete_cmd()
2961 megasas_return_cmd(instance, cmd); in megasas_complete_cmd()
2973 spin_lock_irqsave(instance->host->host_lock, flags); in megasas_complete_cmd()
2981 megasas_return_mfi_mpt_pthr(instance, in megasas_complete_cmd()
2984 instance->host->host_lock, in megasas_complete_cmd()
2989 instance->map_id++; in megasas_complete_cmd()
2990 megasas_return_mfi_mpt_pthr(instance, cmd, in megasas_complete_cmd()
2998 if (MR_ValidateMapInfo(instance)) in megasas_complete_cmd()
3002 megasas_sync_map_info(instance); in megasas_complete_cmd()
3003 spin_unlock_irqrestore(instance->host->host_lock, in megasas_complete_cmd()
3018 megasas_service_aen(instance, cmd); in megasas_complete_cmd()
3020 megasas_complete_int_cmd(instance, cmd); in megasas_complete_cmd()
3028 megasas_complete_abort(instance, cmd); in megasas_complete_cmd()
3044 megasas_issue_pending_cmds_again(struct megasas_instance *instance) in megasas_issue_pending_cmds_again() argument
3053 spin_lock_irqsave(&instance->hba_lock, flags); in megasas_issue_pending_cmds_again()
3054 list_splice_init(&instance->internal_reset_pending_q, &clist_local); in megasas_issue_pending_cmds_again()
3055 spin_unlock_irqrestore(&instance->hba_lock, flags); in megasas_issue_pending_cmds_again()
3074 instance->instancet->disable_intr(instance); in megasas_issue_pending_cmds_again()
3075 atomic_set(&instance->fw_reset_no_pci_access, 1); in megasas_issue_pending_cmds_again()
3076 megaraid_sas_kill_hba(instance); in megasas_issue_pending_cmds_again()
3090 instance->instancet->fire_cmd(instance, in megasas_issue_pending_cmds_again()
3092 0, instance->reg_set); in megasas_issue_pending_cmds_again()
3098 atomic_inc(&instance->fw_outstanding); in megasas_issue_pending_cmds_again()
3099 instance->instancet->fire_cmd(instance, in megasas_issue_pending_cmds_again()
3101 cmd->frame_count-1, instance->reg_set); in megasas_issue_pending_cmds_again()
3109 if (instance->aen_cmd) { in megasas_issue_pending_cmds_again()
3111 megasas_return_cmd(instance, instance->aen_cmd); in megasas_issue_pending_cmds_again()
3113 instance->aen_cmd = NULL; in megasas_issue_pending_cmds_again()
3119 seq_num = instance->last_seq_num; in megasas_issue_pending_cmds_again()
3124 megasas_register_aen(instance, seq_num, class_locale.word); in megasas_issue_pending_cmds_again()
3137 megasas_internal_reset_defer_cmds(struct megasas_instance *instance) in megasas_internal_reset_defer_cmds() argument
3141 u32 max_cmd = instance->max_fw_cmds; in megasas_internal_reset_defer_cmds()
3146 spin_lock_irqsave(&instance->mfi_pool_lock, flags); in megasas_internal_reset_defer_cmds()
3148 cmd = instance->cmd_list[i]; in megasas_internal_reset_defer_cmds()
3164 &instance->internal_reset_pending_q); in megasas_internal_reset_defer_cmds()
3167 spin_unlock_irqrestore(&instance->mfi_pool_lock, flags); in megasas_internal_reset_defer_cmds()
3174 struct megasas_instance *instance = in process_fw_state_change_wq() local
3179 if (instance->adprecovery != MEGASAS_ADPRESET_SM_INFAULT) { in process_fw_state_change_wq()
3181 instance->adprecovery); in process_fw_state_change_wq()
3185 if (instance->adprecovery == MEGASAS_ADPRESET_SM_INFAULT) { in process_fw_state_change_wq()
3189 instance->instancet->disable_intr(instance); in process_fw_state_change_wq()
3190 atomic_set(&instance->fw_outstanding, 0); in process_fw_state_change_wq()
3192 atomic_set(&instance->fw_reset_no_pci_access, 1); in process_fw_state_change_wq()
3193 instance->instancet->adp_reset(instance, instance->reg_set); in process_fw_state_change_wq()
3194 atomic_set(&instance->fw_reset_no_pci_access, 0 ); in process_fw_state_change_wq()
3207 if (megasas_transition_to_ready(instance, 1)) { in process_fw_state_change_wq()
3210 atomic_set(&instance->fw_reset_no_pci_access, 1); in process_fw_state_change_wq()
3211 megaraid_sas_kill_hba(instance); in process_fw_state_change_wq()
3215 if ((instance->pdev->device == PCI_DEVICE_ID_LSI_SAS1064R) || in process_fw_state_change_wq()
3216 (instance->pdev->device == PCI_DEVICE_ID_DELL_PERC5) || in process_fw_state_change_wq()
3217 (instance->pdev->device == PCI_DEVICE_ID_LSI_VERDE_ZCR) in process_fw_state_change_wq()
3219 *instance->consumer = *instance->producer; in process_fw_state_change_wq()
3221 *instance->consumer = 0; in process_fw_state_change_wq()
3222 *instance->producer = 0; in process_fw_state_change_wq()
3225 megasas_issue_init_mfi(instance); in process_fw_state_change_wq()
3227 spin_lock_irqsave(&instance->hba_lock, flags); in process_fw_state_change_wq()
3228 instance->adprecovery = MEGASAS_HBA_OPERATIONAL; in process_fw_state_change_wq()
3229 spin_unlock_irqrestore(&instance->hba_lock, flags); in process_fw_state_change_wq()
3230 instance->instancet->enable_intr(instance); in process_fw_state_change_wq()
3232 megasas_issue_pending_cmds_again(instance); in process_fw_state_change_wq()
3233 instance->issuepend_done = 1; in process_fw_state_change_wq()
3247 megasas_deplete_reply_queue(struct megasas_instance *instance, in megasas_deplete_reply_queue() argument
3253 if ((mfiStatus = instance->instancet->check_reset(instance, in megasas_deplete_reply_queue()
3254 instance->reg_set)) == 1) { in megasas_deplete_reply_queue()
3258 if ((mfiStatus = instance->instancet->clear_intr( in megasas_deplete_reply_queue()
3259 instance->reg_set) in megasas_deplete_reply_queue()
3262 if (!instance->msix_vectors) in megasas_deplete_reply_queue()
3266 instance->mfiStatus = mfiStatus; in megasas_deplete_reply_queue()
3269 fw_state = instance->instancet->read_fw_status_reg( in megasas_deplete_reply_queue()
3270 instance->reg_set) & MFI_STATE_MASK; in megasas_deplete_reply_queue()
3278 (instance->disableOnlineCtrlReset == 0)) { in megasas_deplete_reply_queue()
3281 if ((instance->pdev->device == in megasas_deplete_reply_queue()
3283 (instance->pdev->device == in megasas_deplete_reply_queue()
3285 (instance->pdev->device == in megasas_deplete_reply_queue()
3288 *instance->consumer = in megasas_deplete_reply_queue()
3293 instance->instancet->disable_intr(instance); in megasas_deplete_reply_queue()
3294 instance->adprecovery = MEGASAS_ADPRESET_SM_INFAULT; in megasas_deplete_reply_queue()
3295 instance->issuepend_done = 0; in megasas_deplete_reply_queue()
3297 atomic_set(&instance->fw_outstanding, 0); in megasas_deplete_reply_queue()
3298 megasas_internal_reset_defer_cmds(instance); in megasas_deplete_reply_queue()
3301 fw_state, instance->adprecovery); in megasas_deplete_reply_queue()
3303 schedule_work(&instance->work_init); in megasas_deplete_reply_queue()
3308 fw_state, instance->disableOnlineCtrlReset); in megasas_deplete_reply_queue()
3312 tasklet_schedule(&instance->isr_tasklet); in megasas_deplete_reply_queue()
3321 struct megasas_instance *instance = irq_context->instance; in megasas_isr() local
3325 if (atomic_read(&instance->fw_reset_no_pci_access)) in megasas_isr()
3328 spin_lock_irqsave(&instance->hba_lock, flags); in megasas_isr()
3329 rc = megasas_deplete_reply_queue(instance, DID_OK); in megasas_isr()
3330 spin_unlock_irqrestore(&instance->hba_lock, flags); in megasas_isr()
3345 megasas_transition_to_ready(struct megasas_instance *instance, int ocr) in megasas_transition_to_ready() argument
3353 abs_state = instance->instancet->read_fw_status_reg(instance->reg_set); in megasas_transition_to_ready()
3377 if ((instance->pdev->device == in megasas_transition_to_ready()
3379 (instance->pdev->device == in megasas_transition_to_ready()
3381 (instance->pdev->device == in megasas_transition_to_ready()
3383 (instance->pdev->device == in megasas_transition_to_ready()
3385 (instance->pdev->device == in megasas_transition_to_ready()
3387 (instance->pdev->device == in megasas_transition_to_ready()
3391 &instance->reg_set->doorbell); in megasas_transition_to_ready()
3395 &instance->reg_set->inbound_doorbell); in megasas_transition_to_ready()
3403 if ((instance->pdev->device == in megasas_transition_to_ready()
3405 (instance->pdev->device == in megasas_transition_to_ready()
3407 (instance->pdev->device == in megasas_transition_to_ready()
3409 (instance->pdev->device == in megasas_transition_to_ready()
3411 (instance->pdev->device == in megasas_transition_to_ready()
3413 (instance->pdev->device == in megasas_transition_to_ready()
3416 &instance->reg_set->doorbell); in megasas_transition_to_ready()
3419 &instance->reg_set->inbound_doorbell); in megasas_transition_to_ready()
3429 instance->instancet->disable_intr(instance); in megasas_transition_to_ready()
3430 if ((instance->pdev->device == in megasas_transition_to_ready()
3432 (instance->pdev->device == in megasas_transition_to_ready()
3434 (instance->pdev->device in megasas_transition_to_ready()
3436 (instance->pdev->device in megasas_transition_to_ready()
3438 (instance->pdev->device in megasas_transition_to_ready()
3440 (instance->pdev->device in megasas_transition_to_ready()
3443 &instance->reg_set->doorbell); in megasas_transition_to_ready()
3444 if ((instance->pdev->device == in megasas_transition_to_ready()
3446 (instance->pdev->device == in megasas_transition_to_ready()
3448 (instance->pdev->device == in megasas_transition_to_ready()
3450 (instance->pdev->device == in megasas_transition_to_ready()
3454 &instance-> in megasas_transition_to_ready()
3464 &instance->reg_set->inbound_doorbell); in megasas_transition_to_ready()
3513 curr_abs_state = instance->instancet-> in megasas_transition_to_ready()
3514 read_fw_status_reg(instance->reg_set); in megasas_transition_to_ready()
3543 static void megasas_teardown_frame_pool(struct megasas_instance *instance) in megasas_teardown_frame_pool() argument
3546 u32 max_cmd = instance->max_mfi_cmds; in megasas_teardown_frame_pool()
3549 if (!instance->frame_dma_pool) in megasas_teardown_frame_pool()
3557 cmd = instance->cmd_list[i]; in megasas_teardown_frame_pool()
3560 pci_pool_free(instance->frame_dma_pool, cmd->frame, in megasas_teardown_frame_pool()
3564 pci_pool_free(instance->sense_dma_pool, cmd->sense, in megasas_teardown_frame_pool()
3571 pci_pool_destroy(instance->frame_dma_pool); in megasas_teardown_frame_pool()
3572 pci_pool_destroy(instance->sense_dma_pool); in megasas_teardown_frame_pool()
3574 instance->frame_dma_pool = NULL; in megasas_teardown_frame_pool()
3575 instance->sense_dma_pool = NULL; in megasas_teardown_frame_pool()
3587 static int megasas_create_frame_pool(struct megasas_instance *instance) in megasas_create_frame_pool() argument
3596 max_cmd = instance->max_mfi_cmds; in megasas_create_frame_pool()
3605 if (instance->flag_ieee) { in megasas_create_frame_pool()
3620 frame_count = instance->ctrl_context ? (3 + 1) : (15 + 1); in megasas_create_frame_pool()
3625 instance->frame_dma_pool = pci_pool_create("megasas frame pool", in megasas_create_frame_pool()
3626 instance->pdev, total_sz, 256, 0); in megasas_create_frame_pool()
3628 if (!instance->frame_dma_pool) { in megasas_create_frame_pool()
3633 instance->sense_dma_pool = pci_pool_create("megasas sense pool", in megasas_create_frame_pool()
3634 instance->pdev, 128, 4, 0); in megasas_create_frame_pool()
3636 if (!instance->sense_dma_pool) { in megasas_create_frame_pool()
3639 pci_pool_destroy(instance->frame_dma_pool); in megasas_create_frame_pool()
3640 instance->frame_dma_pool = NULL; in megasas_create_frame_pool()
3652 cmd = instance->cmd_list[i]; in megasas_create_frame_pool()
3654 cmd->frame = pci_pool_alloc(instance->frame_dma_pool, in megasas_create_frame_pool()
3657 cmd->sense = pci_pool_alloc(instance->sense_dma_pool, in megasas_create_frame_pool()
3666 megasas_teardown_frame_pool(instance); in megasas_create_frame_pool()
3673 if ((instance->pdev->device != PCI_DEVICE_ID_LSI_FUSION) && in megasas_create_frame_pool()
3674 (instance->pdev->device != PCI_DEVICE_ID_LSI_PLASMA) && in megasas_create_frame_pool()
3675 (instance->pdev->device != PCI_DEVICE_ID_LSI_INVADER) && in megasas_create_frame_pool()
3676 (instance->pdev->device != PCI_DEVICE_ID_LSI_FURY) && in megasas_create_frame_pool()
3688 void megasas_free_cmds(struct megasas_instance *instance) in megasas_free_cmds() argument
3692 megasas_teardown_frame_pool(instance); in megasas_free_cmds()
3695 for (i = 0; i < instance->max_mfi_cmds; i++) in megasas_free_cmds()
3697 kfree(instance->cmd_list[i]); in megasas_free_cmds()
3700 kfree(instance->cmd_list); in megasas_free_cmds()
3701 instance->cmd_list = NULL; in megasas_free_cmds()
3703 INIT_LIST_HEAD(&instance->cmd_pool); in megasas_free_cmds()
3724 int megasas_alloc_cmds(struct megasas_instance *instance) in megasas_alloc_cmds() argument
3732 fusion = instance->ctrl_context; in megasas_alloc_cmds()
3733 max_cmd = instance->max_mfi_cmds; in megasas_alloc_cmds()
3740 instance->cmd_list = kcalloc(max_cmd, sizeof(struct megasas_cmd*), GFP_KERNEL); in megasas_alloc_cmds()
3742 if (!instance->cmd_list) { in megasas_alloc_cmds()
3747 memset(instance->cmd_list, 0, sizeof(struct megasas_cmd *) *max_cmd); in megasas_alloc_cmds()
3750 instance->cmd_list[i] = kmalloc(sizeof(struct megasas_cmd), in megasas_alloc_cmds()
3753 if (!instance->cmd_list[i]) { in megasas_alloc_cmds()
3756 kfree(instance->cmd_list[j]); in megasas_alloc_cmds()
3758 kfree(instance->cmd_list); in megasas_alloc_cmds()
3759 instance->cmd_list = NULL; in megasas_alloc_cmds()
3766 cmd = instance->cmd_list[i]; in megasas_alloc_cmds()
3771 cmd->instance = instance; in megasas_alloc_cmds()
3773 list_add_tail(&cmd->list, &instance->cmd_pool); in megasas_alloc_cmds()
3779 if (megasas_create_frame_pool(instance)) { in megasas_alloc_cmds()
3781 megasas_free_cmds(instance); in megasas_alloc_cmds()
3797 megasas_get_pd_list(struct megasas_instance *instance) in megasas_get_pd_list() argument
3806 cmd = megasas_get_cmd(instance); in megasas_get_pd_list()
3815 ci = pci_alloc_consistent(instance->pdev, in megasas_get_pd_list()
3820 megasas_return_cmd(instance, cmd); in megasas_get_pd_list()
3840 if (instance->ctrl_context && !instance->mask_interrupts) in megasas_get_pd_list()
3841 ret = megasas_issue_blocked_cmd(instance, cmd, in megasas_get_pd_list()
3844 ret = megasas_issue_polled(instance, cmd); in megasas_get_pd_list()
3856 memset(instance->local_pd_list, 0, in megasas_get_pd_list()
3861 instance->local_pd_list[le16_to_cpu(pd_addr->deviceId)].tid = in megasas_get_pd_list()
3863 instance->local_pd_list[le16_to_cpu(pd_addr->deviceId)].driveType = in megasas_get_pd_list()
3865 instance->local_pd_list[le16_to_cpu(pd_addr->deviceId)].driveState = in megasas_get_pd_list()
3869 memcpy(instance->pd_list, instance->local_pd_list, in megasas_get_pd_list()
3870 sizeof(instance->pd_list)); in megasas_get_pd_list()
3873 pci_free_consistent(instance->pdev, in megasas_get_pd_list()
3877 if (instance->ctrl_context && cmd->mpt_pthr_cmd_blocked) in megasas_get_pd_list()
3878 megasas_return_mfi_mpt_pthr(instance, cmd, in megasas_get_pd_list()
3881 megasas_return_cmd(instance, cmd); in megasas_get_pd_list()
3896 megasas_get_ld_list(struct megasas_instance *instance) in megasas_get_ld_list() argument
3905 cmd = megasas_get_cmd(instance); in megasas_get_ld_list()
3914 ci = pci_alloc_consistent(instance->pdev, in megasas_get_ld_list()
3920 megasas_return_cmd(instance, cmd); in megasas_get_ld_list()
3927 if (instance->supportmax256vd) in megasas_get_ld_list()
3940 if (instance->ctrl_context && !instance->mask_interrupts) in megasas_get_ld_list()
3941 ret = megasas_issue_blocked_cmd(instance, cmd, in megasas_get_ld_list()
3944 ret = megasas_issue_polled(instance, cmd); in megasas_get_ld_list()
3951 if ((ret == 0) && (ld_count <= instance->fw_supported_vd_count)) { in megasas_get_ld_list()
3952 memset(instance->ld_ids, 0xff, MAX_LOGICAL_DRIVES_EXT); in megasas_get_ld_list()
3957 instance->ld_ids[ids] = in megasas_get_ld_list()
3963 pci_free_consistent(instance->pdev, in megasas_get_ld_list()
3968 if (instance->ctrl_context && cmd->mpt_pthr_cmd_blocked) in megasas_get_ld_list()
3969 megasas_return_mfi_mpt_pthr(instance, cmd, in megasas_get_ld_list()
3972 megasas_return_cmd(instance, cmd); in megasas_get_ld_list()
3986 megasas_ld_list_query(struct megasas_instance *instance, u8 query_type) in megasas_ld_list_query() argument
3995 cmd = megasas_get_cmd(instance); in megasas_ld_list_query()
4005 ci = pci_alloc_consistent(instance->pdev, in megasas_ld_list_query()
4011 megasas_return_cmd(instance, cmd); in megasas_ld_list_query()
4019 if (instance->supportmax256vd) in megasas_ld_list_query()
4033 if (instance->ctrl_context && !instance->mask_interrupts) in megasas_ld_list_query()
4034 ret = megasas_issue_blocked_cmd(instance, cmd, in megasas_ld_list_query()
4037 ret = megasas_issue_polled(instance, cmd); in megasas_ld_list_query()
4041 if ((ret == 0) && (tgtid_count <= (instance->fw_supported_vd_count))) { in megasas_ld_list_query()
4042 memset(instance->ld_ids, 0xff, MEGASAS_MAX_LD_IDS); in megasas_ld_list_query()
4045 instance->ld_ids[ids] = ci->targetId[ld_index]; in megasas_ld_list_query()
4050 pci_free_consistent(instance->pdev, sizeof(struct MR_LD_TARGETID_LIST), in megasas_ld_list_query()
4053 if (instance->ctrl_context && cmd->mpt_pthr_cmd_blocked) in megasas_ld_list_query()
4054 megasas_return_mfi_mpt_pthr(instance, cmd, in megasas_ld_list_query()
4057 megasas_return_cmd(instance, cmd); in megasas_ld_list_query()
4066 static void megasas_update_ext_vd_details(struct megasas_instance *instance) in megasas_update_ext_vd_details() argument
4072 fusion = instance->ctrl_context; in megasas_update_ext_vd_details()
4077 instance->supportmax256vd = in megasas_update_ext_vd_details()
4078 instance->ctrl_info->adapterOperations3.supportMaxExtLDs; in megasas_update_ext_vd_details()
4080 if (instance->ctrl_info->max_lds > 64) in megasas_update_ext_vd_details()
4081 instance->supportmax256vd = 1; in megasas_update_ext_vd_details()
4083 instance->drv_supported_vd_count = MEGASAS_MAX_LD_CHANNELS in megasas_update_ext_vd_details()
4085 instance->drv_supported_pd_count = MEGASAS_MAX_PD_CHANNELS in megasas_update_ext_vd_details()
4087 if (instance->supportmax256vd) { in megasas_update_ext_vd_details()
4088 instance->fw_supported_vd_count = MAX_LOGICAL_DRIVES_EXT; in megasas_update_ext_vd_details()
4089 instance->fw_supported_pd_count = MAX_PHYSICAL_DEVICES; in megasas_update_ext_vd_details()
4091 instance->fw_supported_vd_count = MAX_LOGICAL_DRIVES; in megasas_update_ext_vd_details()
4092 instance->fw_supported_pd_count = MAX_PHYSICAL_DEVICES; in megasas_update_ext_vd_details()
4094 dev_info(&instance->pdev->dev, "Firmware supports %d VD %d PD\n", in megasas_update_ext_vd_details()
4095 instance->fw_supported_vd_count, in megasas_update_ext_vd_details()
4096 instance->fw_supported_pd_count); in megasas_update_ext_vd_details()
4097 dev_info(&instance->pdev->dev, "Driver supports %d VD %d PD\n", in megasas_update_ext_vd_details()
4098 instance->drv_supported_vd_count, in megasas_update_ext_vd_details()
4099 instance->drv_supported_pd_count); in megasas_update_ext_vd_details()
4103 (instance->fw_supported_vd_count - 1)); in megasas_update_ext_vd_details()
4107 (instance->drv_supported_vd_count - 1)); in megasas_update_ext_vd_details()
4112 if (instance->supportmax256vd) in megasas_update_ext_vd_details()
4128 megasas_get_ctrl_info(struct megasas_instance *instance) in megasas_get_ctrl_info() argument
4137 ctrl_info = instance->ctrl_info; in megasas_get_ctrl_info()
4139 cmd = megasas_get_cmd(instance); in megasas_get_ctrl_info()
4148 ci = pci_alloc_consistent(instance->pdev, in megasas_get_ctrl_info()
4153 megasas_return_cmd(instance, cmd); in megasas_get_ctrl_info()
4172 if (instance->ctrl_context && !instance->mask_interrupts) in megasas_get_ctrl_info()
4173 ret = megasas_issue_blocked_cmd(instance, cmd, in megasas_get_ctrl_info()
4176 ret = megasas_issue_polled(instance, cmd); in megasas_get_ctrl_info()
4183 megasas_update_ext_vd_details(instance); in megasas_get_ctrl_info()
4186 pci_free_consistent(instance->pdev, sizeof(struct megasas_ctrl_info), in megasas_get_ctrl_info()
4189 if (instance->ctrl_context && cmd->mpt_pthr_cmd_blocked) in megasas_get_ctrl_info()
4190 megasas_return_mfi_mpt_pthr(instance, cmd, in megasas_get_ctrl_info()
4193 megasas_return_cmd(instance, cmd); in megasas_get_ctrl_info()
4212 int megasas_set_crash_dump_params(struct megasas_instance *instance, in megasas_set_crash_dump_params() argument
4219 cmd = megasas_get_cmd(instance); in megasas_set_crash_dump_params()
4222 dev_err(&instance->pdev->dev, "Failed to get a free cmd\n"); in megasas_set_crash_dump_params()
4239 dcmd->sgl.sge32[0].phys_addr = cpu_to_le32(instance->crash_dump_h); in megasas_set_crash_dump_params()
4242 if (instance->ctrl_context && !instance->mask_interrupts) in megasas_set_crash_dump_params()
4243 ret = megasas_issue_blocked_cmd(instance, cmd, in megasas_set_crash_dump_params()
4246 ret = megasas_issue_polled(instance, cmd); in megasas_set_crash_dump_params()
4248 if (instance->ctrl_context && cmd->mpt_pthr_cmd_blocked) in megasas_set_crash_dump_params()
4249 megasas_return_mfi_mpt_pthr(instance, cmd, in megasas_set_crash_dump_params()
4252 megasas_return_cmd(instance, cmd); in megasas_set_crash_dump_params()
4263 megasas_issue_init_mfi(struct megasas_instance *instance) in megasas_issue_init_mfi() argument
4282 cmd = megasas_get_cmd(instance); in megasas_issue_init_mfi()
4296 initq_info->reply_queue_entries = cpu_to_le32(instance->max_fw_cmds + 1); in megasas_issue_init_mfi()
4297 initq_info->reply_queue_start_phys_addr_lo = cpu_to_le32(instance->reply_queue_h); in megasas_issue_init_mfi()
4299 initq_info->producer_index_phys_addr_lo = cpu_to_le32(instance->producer_h); in megasas_issue_init_mfi()
4300 initq_info->consumer_index_phys_addr_lo = cpu_to_le32(instance->consumer_h); in megasas_issue_init_mfi()
4314 instance->instancet->disable_intr(instance); in megasas_issue_init_mfi()
4320 if (megasas_issue_polled(instance, cmd)) { in megasas_issue_init_mfi()
4322 megasas_return_cmd(instance, cmd); in megasas_issue_init_mfi()
4326 megasas_return_cmd(instance, cmd); in megasas_issue_init_mfi()
4335 megasas_init_adapter_mfi(struct megasas_instance *instance) in megasas_init_adapter_mfi() argument
4341 reg_set = instance->reg_set; in megasas_init_adapter_mfi()
4346 instance->max_fw_cmds = instance->instancet->read_fw_status_reg(reg_set) & 0x00FFFF; in megasas_init_adapter_mfi()
4352 instance->max_fw_cmds = instance->max_fw_cmds-1; in megasas_init_adapter_mfi()
4353 instance->max_mfi_cmds = instance->max_fw_cmds; in megasas_init_adapter_mfi()
4354 instance->max_num_sge = (instance->instancet->read_fw_status_reg(reg_set) & 0xFF0000) >> in megasas_init_adapter_mfi()
4359 if (megasas_alloc_cmds(instance)) in megasas_init_adapter_mfi()
4372 reply_q_sz = context_sz * (instance->max_fw_cmds + 1); in megasas_init_adapter_mfi()
4374 instance->reply_queue = pci_alloc_consistent(instance->pdev, in megasas_init_adapter_mfi()
4376 &instance->reply_queue_h); in megasas_init_adapter_mfi()
4378 if (!instance->reply_queue) { in megasas_init_adapter_mfi()
4383 if (megasas_issue_init_mfi(instance)) in megasas_init_adapter_mfi()
4386 if (megasas_get_ctrl_info(instance)) { in megasas_init_adapter_mfi()
4387 dev_err(&instance->pdev->dev, "(%d): Could get controller info " in megasas_init_adapter_mfi()
4388 "Fail from %s %d\n", instance->unique_id, in megasas_init_adapter_mfi()
4393 instance->fw_support_ieee = 0; in megasas_init_adapter_mfi()
4394 instance->fw_support_ieee = in megasas_init_adapter_mfi()
4395 (instance->instancet->read_fw_status_reg(reg_set) & in megasas_init_adapter_mfi()
4399 instance->fw_support_ieee); in megasas_init_adapter_mfi()
4401 if (instance->fw_support_ieee) in megasas_init_adapter_mfi()
4402 instance->flag_ieee = 1; in megasas_init_adapter_mfi()
4408 pci_free_consistent(instance->pdev, reply_q_sz, in megasas_init_adapter_mfi()
4409 instance->reply_queue, instance->reply_queue_h); in megasas_init_adapter_mfi()
4411 megasas_free_cmds(instance); in megasas_init_adapter_mfi()
4424 static int megasas_init_fw(struct megasas_instance *instance) in megasas_init_fw() argument
4437 bar_list = pci_select_bars(instance->pdev, IORESOURCE_MEM); in megasas_init_fw()
4438 instance->bar = find_first_bit(&bar_list, sizeof(unsigned long)); in megasas_init_fw()
4439 if (pci_request_selected_regions(instance->pdev, instance->bar, in megasas_init_fw()
4445 base_addr = pci_resource_start(instance->pdev, instance->bar); in megasas_init_fw()
4446 instance->reg_set = ioremap_nocache(base_addr, 8192); in megasas_init_fw()
4448 if (!instance->reg_set) { in megasas_init_fw()
4453 reg_set = instance->reg_set; in megasas_init_fw()
4455 switch (instance->pdev->device) { in megasas_init_fw()
4460 instance->instancet = &megasas_instance_template_fusion; in megasas_init_fw()
4464 instance->instancet = &megasas_instance_template_ppc; in megasas_init_fw()
4468 instance->instancet = &megasas_instance_template_gen2; in megasas_init_fw()
4472 instance->instancet = &megasas_instance_template_skinny; in megasas_init_fw()
4477 instance->instancet = &megasas_instance_template_xscale; in megasas_init_fw()
4481 if (megasas_transition_to_ready(instance, 0)) { in megasas_init_fw()
4482 atomic_set(&instance->fw_reset_no_pci_access, 1); in megasas_init_fw()
4483 instance->instancet->adp_reset in megasas_init_fw()
4484 (instance, instance->reg_set); in megasas_init_fw()
4485 atomic_set(&instance->fw_reset_no_pci_access, 0); in megasas_init_fw()
4486 dev_info(&instance->pdev->dev, in megasas_init_fw()
4493 if (megasas_transition_to_ready(instance, 0)) in megasas_init_fw()
4501 instance->reply_post_host_index_addr[0] = in megasas_init_fw()
4502 (u32 *)((u8 *)instance->reg_set + in megasas_init_fw()
4506 msix_enable = (instance->instancet->read_fw_status_reg(reg_set) & in megasas_init_fw()
4510 (&instance->reg_set->outbound_scratch_pad_2); in megasas_init_fw()
4512 if ((instance->pdev->device == PCI_DEVICE_ID_LSI_FUSION) || in megasas_init_fw()
4513 (instance->pdev->device == PCI_DEVICE_ID_LSI_PLASMA)) { in megasas_init_fw()
4514 instance->msix_vectors = (scratch_pad_2 in megasas_init_fw()
4516 fw_msix_count = instance->msix_vectors; in megasas_init_fw()
4518 instance->msix_vectors = in megasas_init_fw()
4520 instance->msix_vectors); in megasas_init_fw()
4521 } else if ((instance->pdev->device == PCI_DEVICE_ID_LSI_INVADER) in megasas_init_fw()
4522 || (instance->pdev->device == PCI_DEVICE_ID_LSI_FURY)) { in megasas_init_fw()
4524 instance->msix_vectors = ((scratch_pad_2 in megasas_init_fw()
4527 fw_msix_count = instance->msix_vectors; in megasas_init_fw()
4533 instance->reply_post_host_index_addr[loop] = in megasas_init_fw()
4534 (u32 *)((u8 *)instance->reg_set + in megasas_init_fw()
4539 instance->msix_vectors = min(msix_vectors, in megasas_init_fw()
4540 instance->msix_vectors); in megasas_init_fw()
4542 instance->msix_vectors = 1; in megasas_init_fw()
4544 instance->msix_vectors = min(instance->msix_vectors, in megasas_init_fw()
4546 for (i = 0; i < instance->msix_vectors; i++) in megasas_init_fw()
4547 instance->msixentry[i].entry = i; in megasas_init_fw()
4548 i = pci_enable_msix_range(instance->pdev, instance->msixentry, in megasas_init_fw()
4549 1, instance->msix_vectors); in megasas_init_fw()
4551 instance->msix_vectors = i; in megasas_init_fw()
4553 instance->msix_vectors = 0; in megasas_init_fw()
4555 dev_info(&instance->pdev->dev, "[scsi%d]: FW supports" in megasas_init_fw()
4557 "Current MSIX <%d>\n", instance->host->host_no, in megasas_init_fw()
4559 instance->msix_vectors); in megasas_init_fw()
4562 instance->ctrl_info = kzalloc(sizeof(struct megasas_ctrl_info), in megasas_init_fw()
4564 if (instance->ctrl_info == NULL) in megasas_init_fw()
4571 instance->fw_supported_vd_count = MAX_LOGICAL_DRIVES; in megasas_init_fw()
4572 instance->fw_supported_pd_count = MAX_PHYSICAL_DEVICES; in megasas_init_fw()
4574 if (instance->instancet->init_adapter(instance)) in megasas_init_fw()
4583 memset(instance->pd_list, 0 , in megasas_init_fw()
4585 if (megasas_get_pd_list(instance) < 0) { in megasas_init_fw()
4590 memset(instance->ld_ids, 0xff, MEGASAS_MAX_LD_IDS); in megasas_init_fw()
4591 if (megasas_ld_list_query(instance, in megasas_init_fw()
4593 megasas_get_ld_list(instance); in megasas_init_fw()
4605 ctrl_info = instance->ctrl_info; in megasas_init_fw()
4615 instance->is_imr = 0; in megasas_init_fw()
4616 dev_info(&instance->pdev->dev, "Controller type: MR," in megasas_init_fw()
4620 instance->is_imr = 1; in megasas_init_fw()
4621 dev_info(&instance->pdev->dev, in megasas_init_fw()
4624 instance->disableOnlineCtrlReset = in megasas_init_fw()
4626 instance->mpio = ctrl_info->adapterOperations2.mpio; in megasas_init_fw()
4627 instance->UnevenSpanSupport = in megasas_init_fw()
4629 if (instance->UnevenSpanSupport) { in megasas_init_fw()
4630 struct fusion_context *fusion = instance->ctrl_context; in megasas_init_fw()
4632 dev_info(&instance->pdev->dev, "FW supports: " in megasas_init_fw()
4633 "UnevenSpanSupport=%x\n", instance->UnevenSpanSupport); in megasas_init_fw()
4634 if (MR_ValidateMapInfo(instance)) in megasas_init_fw()
4642 instance->PlasmaFW111 = 1; in megasas_init_fw()
4644 if (!instance->PlasmaFW111) in megasas_init_fw()
4645 instance->requestorId = in megasas_init_fw()
4649 instance->requestorId = iovPtr->requestorId; in megasas_init_fw()
4651 dev_warn(&instance->pdev->dev, "I am VF " in megasas_init_fw()
4652 "requestorId %d\n", instance->requestorId); in megasas_init_fw()
4655 instance->crash_dump_fw_support = in megasas_init_fw()
4657 instance->crash_dump_drv_support = in megasas_init_fw()
4658 (instance->crash_dump_fw_support && in megasas_init_fw()
4659 instance->crash_dump_buf); in megasas_init_fw()
4660 if (instance->crash_dump_drv_support) { in megasas_init_fw()
4661 dev_info(&instance->pdev->dev, "Firmware Crash dump " in megasas_init_fw()
4663 megasas_set_crash_dump_params(instance, in megasas_init_fw()
4667 if (instance->crash_dump_buf) in megasas_init_fw()
4668 pci_free_consistent(instance->pdev, in megasas_init_fw()
4670 instance->crash_dump_buf, in megasas_init_fw()
4671 instance->crash_dump_h); in megasas_init_fw()
4672 instance->crash_dump_buf = NULL; in megasas_init_fw()
4675 instance->secure_jbod_support = in megasas_init_fw()
4677 if (instance->secure_jbod_support) in megasas_init_fw()
4678 dev_info(&instance->pdev->dev, "Firmware supports Secure JBOD\n"); in megasas_init_fw()
4679 instance->max_sectors_per_req = instance->max_num_sge * in megasas_init_fw()
4681 if (tmp_sectors && (instance->max_sectors_per_req > tmp_sectors)) in megasas_init_fw()
4682 instance->max_sectors_per_req = tmp_sectors; in megasas_init_fw()
4692 if (instance->ctrl_context) { in megasas_init_fw()
4693 instance->max_scsi_cmds = instance->max_fw_cmds - in megasas_init_fw()
4696 sema_init(&instance->ioctl_sem, MEGASAS_FUSION_IOCTL_CMDS); in megasas_init_fw()
4697 } else if ((instance->pdev->device == PCI_DEVICE_ID_LSI_SAS0073SKINNY) || in megasas_init_fw()
4698 (instance->pdev->device == PCI_DEVICE_ID_LSI_SAS0071SKINNY)) { in megasas_init_fw()
4699 instance->max_scsi_cmds = instance->max_fw_cmds - in megasas_init_fw()
4701 sema_init(&instance->ioctl_sem, MEGASAS_SKINNY_INT_CMDS); in megasas_init_fw()
4703 instance->max_scsi_cmds = instance->max_fw_cmds - in megasas_init_fw()
4705 sema_init(&instance->ioctl_sem, (MEGASAS_INT_CMDS - 5)); in megasas_init_fw()
4710 throttlequeuedepth <= instance->max_scsi_cmds) in megasas_init_fw()
4711 instance->throttlequeuedepth = throttlequeuedepth; in megasas_init_fw()
4713 instance->throttlequeuedepth = in megasas_init_fw()
4720 tasklet_init(&instance->isr_tasklet, instance->instancet->tasklet, in megasas_init_fw()
4721 (unsigned long)instance); in megasas_init_fw()
4724 if (instance->requestorId) { in megasas_init_fw()
4725 if (!megasas_sriov_start_heartbeat(instance, 1)) in megasas_init_fw()
4726 megasas_start_timer(instance, in megasas_init_fw()
4727 &instance->sriov_heartbeat_timer, in megasas_init_fw()
4731 instance->skip_heartbeat_timer_del = 1; in megasas_init_fw()
4738 kfree(instance->ctrl_info); in megasas_init_fw()
4739 instance->ctrl_info = NULL; in megasas_init_fw()
4740 iounmap(instance->reg_set); in megasas_init_fw()
4743 pci_release_selected_regions(instance->pdev, instance->bar); in megasas_init_fw()
4752 static void megasas_release_mfi(struct megasas_instance *instance) in megasas_release_mfi() argument
4754 u32 reply_q_sz = sizeof(u32) *(instance->max_mfi_cmds + 1); in megasas_release_mfi()
4756 if (instance->reply_queue) in megasas_release_mfi()
4757 pci_free_consistent(instance->pdev, reply_q_sz, in megasas_release_mfi()
4758 instance->reply_queue, instance->reply_queue_h); in megasas_release_mfi()
4760 megasas_free_cmds(instance); in megasas_release_mfi()
4762 iounmap(instance->reg_set); in megasas_release_mfi()
4764 pci_release_selected_regions(instance->pdev, instance->bar); in megasas_release_mfi()
4780 megasas_get_seq_num(struct megasas_instance *instance, in megasas_get_seq_num() argument
4788 cmd = megasas_get_cmd(instance); in megasas_get_seq_num()
4795 el_info = pci_alloc_consistent(instance->pdev, in megasas_get_seq_num()
4800 megasas_return_cmd(instance, cmd); in megasas_get_seq_num()
4818 if (megasas_issue_blocked_cmd(instance, cmd, 30)) in megasas_get_seq_num()
4819 dev_err(&instance->pdev->dev, "Command timedout" in megasas_get_seq_num()
4832 pci_free_consistent(instance->pdev, sizeof(struct megasas_evt_log_info), in megasas_get_seq_num()
4835 if (instance->ctrl_context && cmd->mpt_pthr_cmd_blocked) in megasas_get_seq_num()
4836 megasas_return_mfi_mpt_pthr(instance, cmd, in megasas_get_seq_num()
4839 megasas_return_cmd(instance, cmd); in megasas_get_seq_num()
4854 megasas_register_aen(struct megasas_instance *instance, u32 seq_num, in megasas_register_aen() argument
4878 if (instance->aen_cmd) { in megasas_register_aen()
4880 prev_aen.word = instance->aen_cmd->frame->dcmd.mbox.w[1]; in megasas_register_aen()
4907 instance->aen_cmd->abort_aen = 1; in megasas_register_aen()
4908 ret_val = megasas_issue_blocked_abort_cmd(instance, in megasas_register_aen()
4909 instance-> in megasas_register_aen()
4920 cmd = megasas_get_cmd(instance); in megasas_register_aen()
4927 memset(instance->evt_detail, 0, sizeof(struct megasas_evt_detail)); in megasas_register_aen()
4943 instance->last_seq_num = seq_num; in megasas_register_aen()
4945 dcmd->sgl.sge32[0].phys_addr = cpu_to_le32(instance->evt_detail_h); in megasas_register_aen()
4948 if (instance->aen_cmd != NULL) { in megasas_register_aen()
4949 megasas_return_cmd(instance, cmd); in megasas_register_aen()
4958 instance->aen_cmd = cmd; in megasas_register_aen()
4963 instance->instancet->issue_dcmd(instance, cmd); in megasas_register_aen()
4972 static int megasas_start_aen(struct megasas_instance *instance) in megasas_start_aen() argument
4982 if (megasas_get_seq_num(instance, &eli)) in megasas_start_aen()
4992 return megasas_register_aen(instance, in megasas_start_aen()
5001 static int megasas_io_attach(struct megasas_instance *instance) in megasas_io_attach() argument
5003 struct Scsi_Host *host = instance->host; in megasas_io_attach()
5008 host->irq = instance->pdev->irq; in megasas_io_attach()
5009 host->unique_id = instance->unique_id; in megasas_io_attach()
5010 host->can_queue = instance->max_scsi_cmds; in megasas_io_attach()
5011 host->this_id = instance->init_id; in megasas_io_attach()
5012 host->sg_tablesize = instance->max_num_sge; in megasas_io_attach()
5014 if (instance->fw_support_ieee) in megasas_io_attach()
5015 instance->max_sectors_per_req = MEGASAS_MAX_SECTORS_IEEE; in megasas_io_attach()
5020 if (max_sectors && max_sectors < instance->max_sectors_per_req) in megasas_io_attach()
5021 instance->max_sectors_per_req = max_sectors; in megasas_io_attach()
5024 if (((instance->pdev->device == in megasas_io_attach()
5026 (instance->pdev->device == in megasas_io_attach()
5029 instance->max_sectors_per_req = max_sectors; in megasas_io_attach()
5033 instance->max_sectors_per_req); in megasas_io_attach()
5038 host->max_sectors = instance->max_sectors_per_req; in megasas_io_attach()
5046 if ((instance->pdev->device == PCI_DEVICE_ID_LSI_FUSION) || in megasas_io_attach()
5047 (instance->pdev->device == PCI_DEVICE_ID_LSI_PLASMA) || in megasas_io_attach()
5048 (instance->pdev->device == PCI_DEVICE_ID_LSI_INVADER) || in megasas_io_attach()
5049 (instance->pdev->device == PCI_DEVICE_ID_LSI_FURY)) { in megasas_io_attach()
5057 if (scsi_add_host(host, &instance->pdev->dev)) { in megasas_io_attach()
5111 struct megasas_instance *instance; in megasas_probe_one() local
5163 instance = (struct megasas_instance *)host->hostdata; in megasas_probe_one()
5164 memset(instance, 0, sizeof(*instance)); in megasas_probe_one()
5165 atomic_set( &instance->fw_reset_no_pci_access, 0 ); in megasas_probe_one()
5166 instance->pdev = pdev; in megasas_probe_one()
5168 switch (instance->pdev->device) { in megasas_probe_one()
5174 instance->ctrl_context_pages = in megasas_probe_one()
5176 instance->ctrl_context = (void *)__get_free_pages(GFP_KERNEL, in megasas_probe_one()
5177 instance->ctrl_context_pages); in megasas_probe_one()
5178 if (!instance->ctrl_context) { in megasas_probe_one()
5183 fusion = instance->ctrl_context; in megasas_probe_one()
5185 ((1 << PAGE_SHIFT) << instance->ctrl_context_pages)); in megasas_probe_one()
5192 instance->producer = in megasas_probe_one()
5194 &instance->producer_h); in megasas_probe_one()
5195 instance->consumer = in megasas_probe_one()
5197 &instance->consumer_h); in megasas_probe_one()
5199 if (!instance->producer || !instance->consumer) { in megasas_probe_one()
5205 *instance->producer = 0; in megasas_probe_one()
5206 *instance->consumer = 0; in megasas_probe_one()
5211 instance->drv_buf_index = 0; in megasas_probe_one()
5212 instance->drv_buf_alloc = 0; in megasas_probe_one()
5213 instance->crash_dump_fw_support = 0; in megasas_probe_one()
5214 instance->crash_dump_app_support = 0; in megasas_probe_one()
5215 instance->fw_crash_state = UNAVAILABLE; in megasas_probe_one()
5216 spin_lock_init(&instance->crashdump_lock); in megasas_probe_one()
5217 instance->crash_dump_buf = NULL; in megasas_probe_one()
5220 instance->crash_dump_buf = pci_alloc_consistent(pdev, in megasas_probe_one()
5222 &instance->crash_dump_h); in megasas_probe_one()
5223 if (!instance->crash_dump_buf) in megasas_probe_one()
5224 dev_err(&instance->pdev->dev, "Can't allocate Firmware " in megasas_probe_one()
5228 instance->flag_ieee = 0; in megasas_probe_one()
5229 instance->ev = NULL; in megasas_probe_one()
5230 instance->issuepend_done = 1; in megasas_probe_one()
5231 instance->adprecovery = MEGASAS_HBA_OPERATIONAL; in megasas_probe_one()
5232 instance->is_imr = 0; in megasas_probe_one()
5234 instance->evt_detail = pci_alloc_consistent(pdev, in megasas_probe_one()
5237 &instance->evt_detail_h); in megasas_probe_one()
5239 if (!instance->evt_detail) { in megasas_probe_one()
5248 INIT_LIST_HEAD(&instance->cmd_pool); in megasas_probe_one()
5249 INIT_LIST_HEAD(&instance->internal_reset_pending_q); in megasas_probe_one()
5251 atomic_set(&instance->fw_outstanding,0); in megasas_probe_one()
5253 init_waitqueue_head(&instance->int_cmd_wait_q); in megasas_probe_one()
5254 init_waitqueue_head(&instance->abort_cmd_wait_q); in megasas_probe_one()
5256 spin_lock_init(&instance->mfi_pool_lock); in megasas_probe_one()
5257 spin_lock_init(&instance->hba_lock); in megasas_probe_one()
5258 spin_lock_init(&instance->completion_lock); in megasas_probe_one()
5260 mutex_init(&instance->aen_mutex); in megasas_probe_one()
5261 mutex_init(&instance->reset_mutex); in megasas_probe_one()
5266 instance->host = host; in megasas_probe_one()
5267 instance->unique_id = pdev->bus->number << 8 | pdev->devfn; in megasas_probe_one()
5268 instance->init_id = MEGASAS_DEFAULT_INIT_ID; in megasas_probe_one()
5269 instance->ctrl_info = NULL; in megasas_probe_one()
5272 if ((instance->pdev->device == PCI_DEVICE_ID_LSI_SAS0073SKINNY) || in megasas_probe_one()
5273 (instance->pdev->device == PCI_DEVICE_ID_LSI_SAS0071SKINNY)) in megasas_probe_one()
5274 instance->flag_ieee = 1; in megasas_probe_one()
5277 instance->flag = 0; in megasas_probe_one()
5278 instance->unload = 1; in megasas_probe_one()
5279 instance->last_time = 0; in megasas_probe_one()
5280 instance->disableOnlineCtrlReset = 1; in megasas_probe_one()
5281 instance->UnevenSpanSupport = 0; in megasas_probe_one()
5283 if ((instance->pdev->device == PCI_DEVICE_ID_LSI_FUSION) || in megasas_probe_one()
5284 (instance->pdev->device == PCI_DEVICE_ID_LSI_PLASMA) || in megasas_probe_one()
5285 (instance->pdev->device == PCI_DEVICE_ID_LSI_INVADER) || in megasas_probe_one()
5286 (instance->pdev->device == PCI_DEVICE_ID_LSI_FURY)) { in megasas_probe_one()
5287 INIT_WORK(&instance->work_init, megasas_fusion_ocr_wq); in megasas_probe_one()
5288 INIT_WORK(&instance->crash_init, megasas_fusion_crash_dump_wq); in megasas_probe_one()
5290 INIT_WORK(&instance->work_init, process_fw_state_change_wq); in megasas_probe_one()
5295 if (megasas_init_fw(instance)) in megasas_probe_one()
5298 if (instance->requestorId) { in megasas_probe_one()
5299 if (instance->PlasmaFW111) { in megasas_probe_one()
5300 instance->vf_affiliation_111 = in megasas_probe_one()
5302 &instance->vf_affiliation_111_h); in megasas_probe_one()
5303 if (!instance->vf_affiliation_111) in megasas_probe_one()
5307 instance->vf_affiliation = in megasas_probe_one()
5311 &instance->vf_affiliation_h); in megasas_probe_one()
5312 if (!instance->vf_affiliation) in megasas_probe_one()
5322 if (instance->msix_vectors) { in megasas_probe_one()
5324 for (i = 0; i < instance->msix_vectors; i++) { in megasas_probe_one()
5325 instance->irq_context[i].instance = instance; in megasas_probe_one()
5326 instance->irq_context[i].MSIxIndex = i; in megasas_probe_one()
5327 if (request_irq(instance->msixentry[i].vector, in megasas_probe_one()
5328 instance->instancet->service_isr, 0, in megasas_probe_one()
5330 &instance->irq_context[i])) { in megasas_probe_one()
5336 instance->msixentry[j].vector, NULL); in megasas_probe_one()
5338 instance->msixentry[j].vector, in megasas_probe_one()
5339 &instance->irq_context[j]); in megasas_probe_one()
5342 instance->msix_vectors = 0; in megasas_probe_one()
5346 if (irq_set_affinity_hint(instance->msixentry[i].vector, in megasas_probe_one()
5348 dev_err(&instance->pdev->dev, in megasas_probe_one()
5355 instance->irq_context[0].instance = instance; in megasas_probe_one()
5356 instance->irq_context[0].MSIxIndex = 0; in megasas_probe_one()
5357 if (request_irq(pdev->irq, instance->instancet->service_isr, in megasas_probe_one()
5359 &instance->irq_context[0])) { in megasas_probe_one()
5365 instance->instancet->enable_intr(instance); in megasas_probe_one()
5370 pci_set_drvdata(pdev, instance); in megasas_probe_one()
5377 megasas_mgmt_info.instance[megasas_mgmt_info.max_index] = instance; in megasas_probe_one()
5383 if (megasas_io_attach(instance)) in megasas_probe_one()
5386 instance->unload = 0; in megasas_probe_one()
5395 if (megasas_start_aen(instance)) { in megasas_probe_one()
5401 if (instance->requestorId) in megasas_probe_one()
5402 megasas_get_ld_vf_affiliation(instance, 1); in megasas_probe_one()
5409 megasas_mgmt_info.instance[megasas_mgmt_info.max_index] = NULL; in megasas_probe_one()
5412 instance->instancet->disable_intr(instance); in megasas_probe_one()
5413 if (instance->msix_vectors) in megasas_probe_one()
5414 for (i = 0; i < instance->msix_vectors; i++) { in megasas_probe_one()
5417 instance->msixentry[i].vector, NULL); in megasas_probe_one()
5418 free_irq(instance->msixentry[i].vector, in megasas_probe_one()
5419 &instance->irq_context[i]); in megasas_probe_one()
5422 free_irq(instance->pdev->irq, &instance->irq_context[0]); in megasas_probe_one()
5424 if ((instance->pdev->device == PCI_DEVICE_ID_LSI_FUSION) || in megasas_probe_one()
5425 (instance->pdev->device == PCI_DEVICE_ID_LSI_PLASMA) || in megasas_probe_one()
5426 (instance->pdev->device == PCI_DEVICE_ID_LSI_INVADER) || in megasas_probe_one()
5427 (instance->pdev->device == PCI_DEVICE_ID_LSI_FURY)) in megasas_probe_one()
5428 megasas_release_fusion(instance); in megasas_probe_one()
5430 megasas_release_mfi(instance); in megasas_probe_one()
5432 if (instance->msix_vectors) in megasas_probe_one()
5433 pci_disable_msix(instance->pdev); in megasas_probe_one()
5435 if (instance->evt_detail) in megasas_probe_one()
5437 instance->evt_detail, in megasas_probe_one()
5438 instance->evt_detail_h); in megasas_probe_one()
5440 if (instance->producer) in megasas_probe_one()
5441 pci_free_consistent(pdev, sizeof(u32), instance->producer, in megasas_probe_one()
5442 instance->producer_h); in megasas_probe_one()
5443 if (instance->consumer) in megasas_probe_one()
5444 pci_free_consistent(pdev, sizeof(u32), instance->consumer, in megasas_probe_one()
5445 instance->consumer_h); in megasas_probe_one()
5459 static void megasas_flush_cache(struct megasas_instance *instance) in megasas_flush_cache() argument
5464 if (instance->adprecovery == MEGASAS_HW_CRITICAL_ERROR) in megasas_flush_cache()
5467 cmd = megasas_get_cmd(instance); in megasas_flush_cache()
5486 if (megasas_issue_blocked_cmd(instance, cmd, 30)) in megasas_flush_cache()
5487 dev_err(&instance->pdev->dev, "Command timedout" in megasas_flush_cache()
5490 if (instance->ctrl_context && cmd->mpt_pthr_cmd_blocked) in megasas_flush_cache()
5491 megasas_return_mfi_mpt_pthr(instance, cmd, in megasas_flush_cache()
5494 megasas_return_cmd(instance, cmd); in megasas_flush_cache()
5504 static void megasas_shutdown_controller(struct megasas_instance *instance, in megasas_shutdown_controller() argument
5510 if (instance->adprecovery == MEGASAS_HW_CRITICAL_ERROR) in megasas_shutdown_controller()
5513 cmd = megasas_get_cmd(instance); in megasas_shutdown_controller()
5518 if (instance->aen_cmd) in megasas_shutdown_controller()
5519 megasas_issue_blocked_abort_cmd(instance, in megasas_shutdown_controller()
5520 instance->aen_cmd, 30); in megasas_shutdown_controller()
5521 if (instance->map_update_cmd) in megasas_shutdown_controller()
5522 megasas_issue_blocked_abort_cmd(instance, in megasas_shutdown_controller()
5523 instance->map_update_cmd, 30); in megasas_shutdown_controller()
5537 if (megasas_issue_blocked_cmd(instance, cmd, 30)) in megasas_shutdown_controller()
5538 dev_err(&instance->pdev->dev, "Command timedout" in megasas_shutdown_controller()
5541 if (instance->ctrl_context && cmd->mpt_pthr_cmd_blocked) in megasas_shutdown_controller()
5542 megasas_return_mfi_mpt_pthr(instance, cmd, in megasas_shutdown_controller()
5545 megasas_return_cmd(instance, cmd); in megasas_shutdown_controller()
5560 struct megasas_instance *instance; in megasas_suspend() local
5563 instance = pci_get_drvdata(pdev); in megasas_suspend()
5564 host = instance->host; in megasas_suspend()
5565 instance->unload = 1; in megasas_suspend()
5568 if (instance->requestorId && !instance->skip_heartbeat_timer_del) in megasas_suspend()
5569 del_timer_sync(&instance->sriov_heartbeat_timer); in megasas_suspend()
5571 megasas_flush_cache(instance); in megasas_suspend()
5572 megasas_shutdown_controller(instance, MR_DCMD_HIBERNATE_SHUTDOWN); in megasas_suspend()
5575 if (instance->ev != NULL) { in megasas_suspend()
5576 struct megasas_aen_event *ev = instance->ev; in megasas_suspend()
5578 instance->ev = NULL; in megasas_suspend()
5581 tasklet_kill(&instance->isr_tasklet); in megasas_suspend()
5583 pci_set_drvdata(instance->pdev, instance); in megasas_suspend()
5584 instance->instancet->disable_intr(instance); in megasas_suspend()
5586 if (instance->msix_vectors) in megasas_suspend()
5587 for (i = 0; i < instance->msix_vectors; i++) { in megasas_suspend()
5590 instance->msixentry[i].vector, NULL); in megasas_suspend()
5591 free_irq(instance->msixentry[i].vector, in megasas_suspend()
5592 &instance->irq_context[i]); in megasas_suspend()
5595 free_irq(instance->pdev->irq, &instance->irq_context[0]); in megasas_suspend()
5596 if (instance->msix_vectors) in megasas_suspend()
5597 pci_disable_msix(instance->pdev); in megasas_suspend()
5616 struct megasas_instance *instance; in megasas_resume() local
5618 instance = pci_get_drvdata(pdev); in megasas_resume()
5619 host = instance->host; in megasas_resume()
5643 atomic_set(&instance->fw_outstanding, 0); in megasas_resume()
5648 if (megasas_transition_to_ready(instance, 0)) in megasas_resume()
5652 if (instance->msix_vectors && in megasas_resume()
5653 pci_enable_msix_exact(instance->pdev, instance->msixentry, in megasas_resume()
5654 instance->msix_vectors)) in megasas_resume()
5657 switch (instance->pdev->device) { in megasas_resume()
5663 megasas_reset_reply_desc(instance); in megasas_resume()
5664 if (megasas_ioc_init_fusion(instance)) { in megasas_resume()
5665 megasas_free_cmds(instance); in megasas_resume()
5666 megasas_free_cmds_fusion(instance); in megasas_resume()
5669 if (!megasas_get_map_info(instance)) in megasas_resume()
5670 megasas_sync_map_info(instance); in megasas_resume()
5674 *instance->producer = 0; in megasas_resume()
5675 *instance->consumer = 0; in megasas_resume()
5676 if (megasas_issue_init_mfi(instance)) in megasas_resume()
5681 tasklet_init(&instance->isr_tasklet, instance->instancet->tasklet, in megasas_resume()
5682 (unsigned long)instance); in megasas_resume()
5687 if (instance->msix_vectors) { in megasas_resume()
5689 for (i = 0 ; i < instance->msix_vectors; i++) { in megasas_resume()
5690 instance->irq_context[i].instance = instance; in megasas_resume()
5691 instance->irq_context[i].MSIxIndex = i; in megasas_resume()
5692 if (request_irq(instance->msixentry[i].vector, in megasas_resume()
5693 instance->instancet->service_isr, 0, in megasas_resume()
5695 &instance->irq_context[i])) { in megasas_resume()
5701 instance->msixentry[j].vector, NULL); in megasas_resume()
5703 instance->msixentry[j].vector, in megasas_resume()
5704 &instance->irq_context[j]); in megasas_resume()
5710 if (irq_set_affinity_hint(instance->msixentry[i].vector, in megasas_resume()
5712 dev_err(&instance->pdev->dev, "Error " in megasas_resume()
5719 instance->irq_context[0].instance = instance; in megasas_resume()
5720 instance->irq_context[0].MSIxIndex = 0; in megasas_resume()
5721 if (request_irq(pdev->irq, instance->instancet->service_isr, in megasas_resume()
5723 &instance->irq_context[0])) { in megasas_resume()
5730 if (instance->requestorId) { in megasas_resume()
5731 if (!megasas_sriov_start_heartbeat(instance, 0)) in megasas_resume()
5732 megasas_start_timer(instance, in megasas_resume()
5733 &instance->sriov_heartbeat_timer, in megasas_resume()
5737 instance->skip_heartbeat_timer_del = 1; in megasas_resume()
5740 instance->instancet->enable_intr(instance); in megasas_resume()
5741 instance->unload = 0; in megasas_resume()
5746 if (megasas_start_aen(instance)) in megasas_resume()
5753 if (instance->evt_detail) in megasas_resume()
5755 instance->evt_detail, in megasas_resume()
5756 instance->evt_detail_h); in megasas_resume()
5758 if (instance->producer) in megasas_resume()
5759 pci_free_consistent(pdev, sizeof(u32), instance->producer, in megasas_resume()
5760 instance->producer_h); in megasas_resume()
5761 if (instance->consumer) in megasas_resume()
5762 pci_free_consistent(pdev, sizeof(u32), instance->consumer, in megasas_resume()
5763 instance->consumer_h); in megasas_resume()
5787 struct megasas_instance *instance; in megasas_detach_one() local
5790 instance = pci_get_drvdata(pdev); in megasas_detach_one()
5791 instance->unload = 1; in megasas_detach_one()
5792 host = instance->host; in megasas_detach_one()
5793 fusion = instance->ctrl_context; in megasas_detach_one()
5796 if (instance->requestorId && !instance->skip_heartbeat_timer_del) in megasas_detach_one()
5797 del_timer_sync(&instance->sriov_heartbeat_timer); in megasas_detach_one()
5799 if (instance->fw_crash_state != UNAVAILABLE) in megasas_detach_one()
5800 megasas_free_host_crash_buffer(instance); in megasas_detach_one()
5801 scsi_remove_host(instance->host); in megasas_detach_one()
5802 megasas_flush_cache(instance); in megasas_detach_one()
5803 megasas_shutdown_controller(instance, MR_DCMD_CTRL_SHUTDOWN); in megasas_detach_one()
5806 if (instance->ev != NULL) { in megasas_detach_one()
5807 struct megasas_aen_event *ev = instance->ev; in megasas_detach_one()
5809 instance->ev = NULL; in megasas_detach_one()
5813 wake_up_all(&instance->int_cmd_wait_q); in megasas_detach_one()
5815 tasklet_kill(&instance->isr_tasklet); in megasas_detach_one()
5822 if (megasas_mgmt_info.instance[i] == instance) { in megasas_detach_one()
5824 megasas_mgmt_info.instance[i] = NULL; in megasas_detach_one()
5830 instance->instancet->disable_intr(instance); in megasas_detach_one()
5832 if (instance->msix_vectors) in megasas_detach_one()
5833 for (i = 0; i < instance->msix_vectors; i++) { in megasas_detach_one()
5836 instance->msixentry[i].vector, NULL); in megasas_detach_one()
5837 free_irq(instance->msixentry[i].vector, in megasas_detach_one()
5838 &instance->irq_context[i]); in megasas_detach_one()
5841 free_irq(instance->pdev->irq, &instance->irq_context[0]); in megasas_detach_one()
5842 if (instance->msix_vectors) in megasas_detach_one()
5843 pci_disable_msix(instance->pdev); in megasas_detach_one()
5845 switch (instance->pdev->device) { in megasas_detach_one()
5850 megasas_release_fusion(instance); in megasas_detach_one()
5853 dma_free_coherent(&instance->pdev->dev, in megasas_detach_one()
5861 free_pages((ulong)instance->ctrl_context, in megasas_detach_one()
5862 instance->ctrl_context_pages); in megasas_detach_one()
5865 megasas_release_mfi(instance); in megasas_detach_one()
5867 instance->producer, in megasas_detach_one()
5868 instance->producer_h); in megasas_detach_one()
5870 instance->consumer, in megasas_detach_one()
5871 instance->consumer_h); in megasas_detach_one()
5875 kfree(instance->ctrl_info); in megasas_detach_one()
5877 if (instance->evt_detail) in megasas_detach_one()
5879 instance->evt_detail, instance->evt_detail_h); in megasas_detach_one()
5881 if (instance->vf_affiliation) in megasas_detach_one()
5884 instance->vf_affiliation, in megasas_detach_one()
5885 instance->vf_affiliation_h); in megasas_detach_one()
5887 if (instance->vf_affiliation_111) in megasas_detach_one()
5890 instance->vf_affiliation_111, in megasas_detach_one()
5891 instance->vf_affiliation_111_h); in megasas_detach_one()
5893 if (instance->hb_host_mem) in megasas_detach_one()
5895 instance->hb_host_mem, in megasas_detach_one()
5896 instance->hb_host_mem_h); in megasas_detach_one()
5898 if (instance->crash_dump_buf) in megasas_detach_one()
5900 instance->crash_dump_buf, instance->crash_dump_h); in megasas_detach_one()
5916 struct megasas_instance *instance = pci_get_drvdata(pdev); in megasas_shutdown() local
5918 instance->unload = 1; in megasas_shutdown()
5919 megasas_flush_cache(instance); in megasas_shutdown()
5920 megasas_shutdown_controller(instance, MR_DCMD_CTRL_SHUTDOWN); in megasas_shutdown()
5921 instance->instancet->disable_intr(instance); in megasas_shutdown()
5922 if (instance->msix_vectors) in megasas_shutdown()
5923 for (i = 0; i < instance->msix_vectors; i++) { in megasas_shutdown()
5926 instance->msixentry[i].vector, NULL); in megasas_shutdown()
5927 free_irq(instance->msixentry[i].vector, in megasas_shutdown()
5928 &instance->irq_context[i]); in megasas_shutdown()
5931 free_irq(instance->pdev->irq, &instance->irq_context[0]); in megasas_shutdown()
5932 if (instance->msix_vectors) in megasas_shutdown()
5933 pci_disable_msix(instance->pdev); in megasas_shutdown()
6012 local_instance = megasas_mgmt_info.instance[i]; in megasas_set_crash_dump_params_ioctl()
6041 megasas_mgmt_fw_ioctl(struct megasas_instance *instance, in megasas_mgmt_fw_ioctl() argument
6062 cmd = megasas_get_cmd(instance); in megasas_mgmt_fw_ioctl()
6083 megasas_return_cmd(instance, cmd); in megasas_mgmt_fw_ioctl()
6105 kbuff_arr[i] = dma_alloc_coherent(&instance->pdev->dev, in megasas_mgmt_fw_ioctl()
6134 sense = dma_alloc_coherent(&instance->pdev->dev, ioc->sense_len, in megasas_mgmt_fw_ioctl()
6151 megasas_issue_blocked_cmd(instance, cmd, 0); in megasas_mgmt_fw_ioctl()
6154 if (instance->unload == 1) { in megasas_mgmt_fw_ioctl()
6155 dev_info(&instance->pdev->dev, "Driver unload is in progress " in megasas_mgmt_fw_ioctl()
6201 dma_free_coherent(&instance->pdev->dev, ioc->sense_len, in megasas_mgmt_fw_ioctl()
6207 dma_free_coherent(&instance->pdev->dev, in megasas_mgmt_fw_ioctl()
6214 if (instance->ctrl_context && cmd->mpt_pthr_cmd_blocked) in megasas_mgmt_fw_ioctl()
6215 megasas_return_mfi_mpt_pthr(instance, cmd, in megasas_mgmt_fw_ioctl()
6218 megasas_return_cmd(instance, cmd); in megasas_mgmt_fw_ioctl()
6227 struct megasas_instance *instance; in megasas_mgmt_ioctl_fw() local
6242 instance = megasas_lookup_instance(ioc->host_no); in megasas_mgmt_ioctl_fw()
6243 if (!instance) { in megasas_mgmt_ioctl_fw()
6249 if (instance->requestorId) in megasas_mgmt_ioctl_fw()
6253 if (instance->requestorId && !allow_vf_ioctls) { in megasas_mgmt_ioctl_fw()
6258 if (instance->adprecovery == MEGASAS_HW_CRITICAL_ERROR) { in megasas_mgmt_ioctl_fw()
6264 if (instance->unload == 1) { in megasas_mgmt_ioctl_fw()
6269 if (down_interruptible(&instance->ioctl_sem)) { in megasas_mgmt_ioctl_fw()
6276 spin_lock_irqsave(&instance->hba_lock, flags); in megasas_mgmt_ioctl_fw()
6277 if (instance->adprecovery == MEGASAS_HBA_OPERATIONAL) { in megasas_mgmt_ioctl_fw()
6278 spin_unlock_irqrestore(&instance->hba_lock, flags); in megasas_mgmt_ioctl_fw()
6281 spin_unlock_irqrestore(&instance->hba_lock, flags); in megasas_mgmt_ioctl_fw()
6291 spin_lock_irqsave(&instance->hba_lock, flags); in megasas_mgmt_ioctl_fw()
6292 if (instance->adprecovery != MEGASAS_HBA_OPERATIONAL) { in megasas_mgmt_ioctl_fw()
6293 spin_unlock_irqrestore(&instance->hba_lock, flags); in megasas_mgmt_ioctl_fw()
6300 spin_unlock_irqrestore(&instance->hba_lock, flags); in megasas_mgmt_ioctl_fw()
6302 error = megasas_mgmt_fw_ioctl(instance, user_ioc, ioc); in megasas_mgmt_ioctl_fw()
6304 up(&instance->ioctl_sem); in megasas_mgmt_ioctl_fw()
6313 struct megasas_instance *instance; in megasas_mgmt_ioctl_aen() local
6329 instance = megasas_lookup_instance(aen.host_no); in megasas_mgmt_ioctl_aen()
6331 if (!instance) in megasas_mgmt_ioctl_aen()
6334 if (instance->adprecovery == MEGASAS_HW_CRITICAL_ERROR) { in megasas_mgmt_ioctl_aen()
6338 if (instance->unload == 1) { in megasas_mgmt_ioctl_aen()
6344 spin_lock_irqsave(&instance->hba_lock, flags); in megasas_mgmt_ioctl_aen()
6345 if (instance->adprecovery == MEGASAS_HBA_OPERATIONAL) { in megasas_mgmt_ioctl_aen()
6346 spin_unlock_irqrestore(&instance->hba_lock, in megasas_mgmt_ioctl_aen()
6351 spin_unlock_irqrestore(&instance->hba_lock, flags); in megasas_mgmt_ioctl_aen()
6361 spin_lock_irqsave(&instance->hba_lock, flags); in megasas_mgmt_ioctl_aen()
6362 if (instance->adprecovery != MEGASAS_HBA_OPERATIONAL) { in megasas_mgmt_ioctl_aen()
6363 spin_unlock_irqrestore(&instance->hba_lock, flags); in megasas_mgmt_ioctl_aen()
6368 spin_unlock_irqrestore(&instance->hba_lock, flags); in megasas_mgmt_ioctl_aen()
6370 mutex_lock(&instance->aen_mutex); in megasas_mgmt_ioctl_aen()
6371 error = megasas_register_aen(instance, aen.seq_num, in megasas_mgmt_ioctl_aen()
6373 mutex_unlock(&instance->aen_mutex); in megasas_mgmt_ioctl_aen()
6547 struct megasas_instance *instance = ev->instance; in megasas_aen_polling() local
6557 if (!instance) { in megasas_aen_polling()
6564 if (instance->requestorId) in megasas_aen_polling()
6569 if (instance->adprecovery == MEGASAS_HBA_OPERATIONAL) in megasas_aen_polling()
6574 __func__, instance->host->host_no); in megasas_aen_polling()
6579 instance->ev = NULL; in megasas_aen_polling()
6580 host = instance->host; in megasas_aen_polling()
6581 if (instance->evt_detail) { in megasas_aen_polling()
6583 switch (le32_to_cpu(instance->evt_detail->code)) { in megasas_aen_polling()
6585 if (megasas_get_pd_list(instance) == 0) { in megasas_aen_polling()
6597 if (instance->pd_list[pd_index].driveState in megasas_aen_polling()
6613 if (megasas_get_pd_list(instance) == 0) { in megasas_aen_polling()
6625 if (instance->pd_list[pd_index].driveState in megasas_aen_polling()
6645 if (!instance->requestorId || in megasas_aen_polling()
6646 (instance->requestorId && in megasas_aen_polling()
6647 megasas_get_ld_vf_affiliation(instance, 0))) { in megasas_aen_polling()
6648 if (megasas_ld_list_query(instance, in megasas_aen_polling()
6650 megasas_get_ld_list(instance); in megasas_aen_polling()
6661 if (instance->ld_ids[ld_index] in megasas_aen_polling()
6677 if (!instance->requestorId || in megasas_aen_polling()
6678 (instance->requestorId && in megasas_aen_polling()
6679 megasas_get_ld_vf_affiliation(instance, 0))) { in megasas_aen_polling()
6680 if (megasas_ld_list_query(instance, in megasas_aen_polling()
6682 megasas_get_ld_list(instance); in megasas_aen_polling()
6692 if (instance->ld_ids[ld_index] in megasas_aen_polling()
6721 instance->host->host_no); in megasas_aen_polling()
6722 if (megasas_get_pd_list(instance) == 0) { in megasas_aen_polling()
6727 if (instance->pd_list[pd_index].driveState == in megasas_aen_polling()
6744 if (!instance->requestorId || in megasas_aen_polling()
6745 (instance->requestorId && in megasas_aen_polling()
6746 megasas_get_ld_vf_affiliation(instance, 0))) { in megasas_aen_polling()
6747 if (megasas_ld_list_query(instance, in megasas_aen_polling()
6749 megasas_get_ld_list(instance); in megasas_aen_polling()
6758 if (instance->ld_ids[ld_index] in megasas_aen_polling()
6775 if ( instance->aen_cmd != NULL ) { in megasas_aen_polling()
6780 seq_num = le32_to_cpu(instance->evt_detail->seq_num) + 1; in megasas_aen_polling()
6786 mutex_lock(&instance->aen_mutex); in megasas_aen_polling()
6787 error = megasas_register_aen(instance, seq_num, in megasas_aen_polling()
6789 mutex_unlock(&instance->aen_mutex); in megasas_aen_polling()