Lines Matching refs:instance
135 int megasas_transition_to_ready(struct megasas_instance *instance, int ocr);
136 static int megasas_get_pd_list(struct megasas_instance *instance);
137 static int megasas_ld_list_query(struct megasas_instance *instance,
139 static int megasas_issue_init_mfi(struct megasas_instance *instance);
140 static int megasas_register_aen(struct megasas_instance *instance,
142 static void megasas_get_pd_info(struct megasas_instance *instance,
145 megasas_set_ld_removed_by_fw(struct megasas_instance *instance);
224 megasas_complete_cmd(struct megasas_instance *instance, struct megasas_cmd *cmd,
227 megasas_read_fw_status_reg_gen2(struct megasas_instance *instance);
229 megasas_adp_reset_gen2(struct megasas_instance *instance,
233 megasas_init_adapter_mfi(struct megasas_instance *instance);
235 megasas_build_and_issue_cmd(struct megasas_instance *instance,
239 wait_and_poll(struct megasas_instance *instance, struct megasas_cmd *cmd,
242 static int megasas_get_ld_vf_affiliation(struct megasas_instance *instance,
245 megasas_set_dma_mask(struct megasas_instance *instance);
247 megasas_alloc_ctrl_mem(struct megasas_instance *instance);
249 megasas_free_ctrl_mem(struct megasas_instance *instance);
251 megasas_alloc_ctrl_dma_buffers(struct megasas_instance *instance);
253 megasas_free_ctrl_dma_buffers(struct megasas_instance *instance);
255 megasas_init_ctrl_params(struct megasas_instance *instance);
257 u32 megasas_readl(struct megasas_instance *instance, in megasas_readl() argument
268 if (instance->adapter_type == AERO_SERIES) { in megasas_readl()
287 void megasas_set_dma_settings(struct megasas_instance *instance, in megasas_set_dma_settings() argument
291 if (instance->consistent_mask_64bit) { in megasas_set_dma_settings()
305 megasas_issue_dcmd(struct megasas_instance *instance, struct megasas_cmd *cmd) in megasas_issue_dcmd() argument
307 instance->instancet->fire_cmd(instance, in megasas_issue_dcmd()
308 cmd->frame_phys_addr, 0, instance->reg_set); in megasas_issue_dcmd()
319 *instance) in megasas_get_cmd()
324 spin_lock_irqsave(&instance->mfi_pool_lock, flags); in megasas_get_cmd()
326 if (!list_empty(&instance->cmd_pool)) { in megasas_get_cmd()
327 cmd = list_entry((&instance->cmd_pool)->next, in megasas_get_cmd()
331 dev_err(&instance->pdev->dev, "Command pool empty!\n"); in megasas_get_cmd()
334 spin_unlock_irqrestore(&instance->mfi_pool_lock, flags); in megasas_get_cmd()
344 megasas_return_cmd(struct megasas_instance *instance, struct megasas_cmd *cmd) in megasas_return_cmd() argument
349 struct fusion_context *fusion = instance->ctrl_context; in megasas_return_cmd()
357 spin_lock_irqsave(&instance->mfi_pool_lock, flags); in megasas_return_cmd()
360 blk_tags = instance->max_scsi_cmds + cmd->index; in megasas_return_cmd()
362 megasas_return_cmd_fusion(instance, cmd_fusion); in megasas_return_cmd()
367 memset(cmd->frame, 0, instance->mfi_frame_size); in megasas_return_cmd()
371 list_add(&cmd->list, (&instance->cmd_pool)->next); in megasas_return_cmd()
373 spin_unlock_irqrestore(&instance->mfi_pool_lock, flags); in megasas_return_cmd()
422 megasas_decode_evt(struct megasas_instance *instance) in megasas_decode_evt() argument
424 struct megasas_evt_detail *evt_detail = instance->evt_detail; in megasas_decode_evt()
435 dev_info(&instance->pdev->dev, "%d (%s/0x%04x/%s) - %s\n", in megasas_decode_evt()
443 dev_info(&instance->pdev->dev, in megasas_decode_evt()
459 megasas_enable_intr_xscale(struct megasas_instance *instance) in megasas_enable_intr_xscale() argument
463 regs = instance->reg_set; in megasas_enable_intr_xscale()
475 megasas_disable_intr_xscale(struct megasas_instance *instance) in megasas_disable_intr_xscale() argument
480 regs = instance->reg_set; in megasas_disable_intr_xscale()
491 megasas_read_fw_status_reg_xscale(struct megasas_instance *instance) in megasas_read_fw_status_reg_xscale() argument
493 return readl(&instance->reg_set->outbound_msg_0); in megasas_read_fw_status_reg_xscale()
500 megasas_clear_intr_xscale(struct megasas_instance *instance) in megasas_clear_intr_xscale() argument
505 regs = instance->reg_set; in megasas_clear_intr_xscale()
537 megasas_fire_cmd_xscale(struct megasas_instance *instance, in megasas_fire_cmd_xscale() argument
544 spin_lock_irqsave(&instance->hba_lock, flags); in megasas_fire_cmd_xscale()
547 spin_unlock_irqrestore(&instance->hba_lock, flags); in megasas_fire_cmd_xscale()
556 megasas_adp_reset_xscale(struct megasas_instance *instance, in megasas_adp_reset_xscale() argument
567 pci_read_config_dword(instance->pdev, MFI_1068_PCSR_OFFSET, &pcidata); in megasas_adp_reset_xscale()
568 dev_notice(&instance->pdev->dev, "pcidata = %x\n", pcidata); in megasas_adp_reset_xscale()
570 dev_notice(&instance->pdev->dev, "mfi 1068 offset read=%x\n", pcidata); in megasas_adp_reset_xscale()
572 pci_write_config_dword(instance->pdev, in megasas_adp_reset_xscale()
579 pci_read_config_dword(instance->pdev, in megasas_adp_reset_xscale()
581 dev_notice(&instance->pdev->dev, "1068 offset handshake read=%x\n", pcidata); in megasas_adp_reset_xscale()
583 dev_notice(&instance->pdev->dev, "1068 offset pcidt=%x\n", pcidata); in megasas_adp_reset_xscale()
585 pci_write_config_dword(instance->pdev, in megasas_adp_reset_xscale()
598 megasas_check_reset_xscale(struct megasas_instance *instance, in megasas_check_reset_xscale() argument
601 if ((atomic_read(&instance->adprecovery) != MEGASAS_HBA_OPERATIONAL) && in megasas_check_reset_xscale()
602 (le32_to_cpu(*instance->consumer) == in megasas_check_reset_xscale()
639 megasas_enable_intr_ppc(struct megasas_instance *instance) in megasas_enable_intr_ppc() argument
643 regs = instance->reg_set; in megasas_enable_intr_ppc()
657 megasas_disable_intr_ppc(struct megasas_instance *instance) in megasas_disable_intr_ppc() argument
662 regs = instance->reg_set; in megasas_disable_intr_ppc()
673 megasas_read_fw_status_reg_ppc(struct megasas_instance *instance) in megasas_read_fw_status_reg_ppc() argument
675 return readl(&instance->reg_set->outbound_scratch_pad_0); in megasas_read_fw_status_reg_ppc()
683 megasas_clear_intr_ppc(struct megasas_instance *instance) in megasas_clear_intr_ppc() argument
687 regs = instance->reg_set; in megasas_clear_intr_ppc()
719 megasas_fire_cmd_ppc(struct megasas_instance *instance, in megasas_fire_cmd_ppc() argument
726 spin_lock_irqsave(&instance->hba_lock, flags); in megasas_fire_cmd_ppc()
729 spin_unlock_irqrestore(&instance->hba_lock, flags); in megasas_fire_cmd_ppc()
738 megasas_check_reset_ppc(struct megasas_instance *instance, in megasas_check_reset_ppc() argument
741 if (atomic_read(&instance->adprecovery) != MEGASAS_HBA_OPERATIONAL) in megasas_check_reset_ppc()
768 megasas_enable_intr_skinny(struct megasas_instance *instance) in megasas_enable_intr_skinny() argument
772 regs = instance->reg_set; in megasas_enable_intr_skinny()
786 megasas_disable_intr_skinny(struct megasas_instance *instance) in megasas_disable_intr_skinny() argument
791 regs = instance->reg_set; in megasas_disable_intr_skinny()
802 megasas_read_fw_status_reg_skinny(struct megasas_instance *instance) in megasas_read_fw_status_reg_skinny() argument
804 return readl(&instance->reg_set->outbound_scratch_pad_0); in megasas_read_fw_status_reg_skinny()
812 megasas_clear_intr_skinny(struct megasas_instance *instance) in megasas_clear_intr_skinny() argument
817 regs = instance->reg_set; in megasas_clear_intr_skinny()
831 if ((megasas_read_fw_status_reg_skinny(instance) & MFI_STATE_MASK) == in megasas_clear_intr_skinny()
858 megasas_fire_cmd_skinny(struct megasas_instance *instance, in megasas_fire_cmd_skinny() argument
865 spin_lock_irqsave(&instance->hba_lock, flags); in megasas_fire_cmd_skinny()
870 spin_unlock_irqrestore(&instance->hba_lock, flags); in megasas_fire_cmd_skinny()
879 megasas_check_reset_skinny(struct megasas_instance *instance, in megasas_check_reset_skinny() argument
882 if (atomic_read(&instance->adprecovery) != MEGASAS_HBA_OPERATIONAL) in megasas_check_reset_skinny()
915 megasas_enable_intr_gen2(struct megasas_instance *instance) in megasas_enable_intr_gen2() argument
919 regs = instance->reg_set; in megasas_enable_intr_gen2()
934 megasas_disable_intr_gen2(struct megasas_instance *instance) in megasas_disable_intr_gen2() argument
939 regs = instance->reg_set; in megasas_disable_intr_gen2()
950 megasas_read_fw_status_reg_gen2(struct megasas_instance *instance) in megasas_read_fw_status_reg_gen2() argument
952 return readl(&instance->reg_set->outbound_scratch_pad_0); in megasas_read_fw_status_reg_gen2()
960 megasas_clear_intr_gen2(struct megasas_instance *instance) in megasas_clear_intr_gen2() argument
965 regs = instance->reg_set; in megasas_clear_intr_gen2()
999 megasas_fire_cmd_gen2(struct megasas_instance *instance, in megasas_fire_cmd_gen2() argument
1006 spin_lock_irqsave(&instance->hba_lock, flags); in megasas_fire_cmd_gen2()
1009 spin_unlock_irqrestore(&instance->hba_lock, flags); in megasas_fire_cmd_gen2()
1018 megasas_adp_reset_gen2(struct megasas_instance *instance, in megasas_adp_reset_gen2() argument
1026 if (instance->instancet == &megasas_instance_template_skinny) { in megasas_adp_reset_gen2()
1045 dev_notice(&instance->pdev->dev, "RESETGEN2: retry=%x, hostdiag=%x\n", in megasas_adp_reset_gen2()
1053 dev_notice(&instance->pdev->dev, "ADP_RESET_GEN2: HostDiag=%x\n", HostDiag); in megasas_adp_reset_gen2()
1063 dev_notice(&instance->pdev->dev, "RESET_GEN2: retry=%x, hostdiag=%x\n", in megasas_adp_reset_gen2()
1079 megasas_check_reset_gen2(struct megasas_instance *instance, in megasas_check_reset_gen2() argument
1082 if (atomic_read(&instance->adprecovery) != MEGASAS_HBA_OPERATIONAL) in megasas_check_reset_gen2()
1122 megasas_issue_polled(struct megasas_instance *instance, struct megasas_cmd *cmd) in megasas_issue_polled() argument
1129 if (atomic_read(&instance->adprecovery) == MEGASAS_HW_CRITICAL_ERROR) { in megasas_issue_polled()
1130 dev_err(&instance->pdev->dev, "Failed from %s %d\n", in megasas_issue_polled()
1135 instance->instancet->issue_dcmd(instance, cmd); in megasas_issue_polled()
1137 return wait_and_poll(instance, cmd, instance->requestorId ? in megasas_issue_polled()
1152 megasas_issue_blocked_cmd(struct megasas_instance *instance, in megasas_issue_blocked_cmd() argument
1158 if (atomic_read(&instance->adprecovery) == MEGASAS_HW_CRITICAL_ERROR) { in megasas_issue_blocked_cmd()
1159 dev_err(&instance->pdev->dev, "Failed from %s %d\n", in megasas_issue_blocked_cmd()
1164 instance->instancet->issue_dcmd(instance, cmd); in megasas_issue_blocked_cmd()
1167 ret = wait_event_timeout(instance->int_cmd_wait_q, in megasas_issue_blocked_cmd()
1170 dev_err(&instance->pdev->dev, in megasas_issue_blocked_cmd()
1176 wait_event(instance->int_cmd_wait_q, in megasas_issue_blocked_cmd()
1194 megasas_issue_blocked_abort_cmd(struct megasas_instance *instance, in megasas_issue_blocked_abort_cmd() argument
1202 cmd = megasas_get_cmd(instance); in megasas_issue_blocked_abort_cmd()
1224 if (atomic_read(&instance->adprecovery) == MEGASAS_HW_CRITICAL_ERROR) { in megasas_issue_blocked_abort_cmd()
1225 dev_err(&instance->pdev->dev, "Failed from %s %d\n", in megasas_issue_blocked_abort_cmd()
1230 instance->instancet->issue_dcmd(instance, cmd); in megasas_issue_blocked_abort_cmd()
1233 ret = wait_event_timeout(instance->abort_cmd_wait_q, in megasas_issue_blocked_abort_cmd()
1237 dev_err(&instance->pdev->dev, in megasas_issue_blocked_abort_cmd()
1243 wait_event(instance->abort_cmd_wait_q, in megasas_issue_blocked_abort_cmd()
1248 megasas_return_cmd(instance, cmd); in megasas_issue_blocked_abort_cmd()
1262 megasas_make_sgl32(struct megasas_instance *instance, struct scsi_cmnd *scp, in megasas_make_sgl32() argument
1291 megasas_make_sgl64(struct megasas_instance *instance, struct scsi_cmnd *scp, in megasas_make_sgl64() argument
1320 megasas_make_sgl_skinny(struct megasas_instance *instance, in megasas_make_sgl_skinny() argument
1349 static u32 megasas_get_frame_count(struct megasas_instance *instance, in megasas_get_frame_count() argument
1360 if (instance->flag_ieee) { in megasas_get_frame_count()
1371 if (instance->flag_ieee == 1) { in megasas_get_frame_count()
1378 if (instance->flag_ieee == 1) { in megasas_get_frame_count()
1410 megasas_build_dcdb(struct megasas_instance *instance, struct scsi_cmnd *scp, in megasas_build_dcdb() argument
1429 if (instance->flag_ieee == 1) { in megasas_build_dcdb()
1463 if (instance->flag_ieee == 1) { in megasas_build_dcdb()
1465 pthru->sge_count = megasas_make_sgl_skinny(instance, scp, in megasas_build_dcdb()
1469 pthru->sge_count = megasas_make_sgl64(instance, scp, in megasas_build_dcdb()
1472 pthru->sge_count = megasas_make_sgl32(instance, scp, in megasas_build_dcdb()
1475 if (pthru->sge_count > instance->max_num_sge) { in megasas_build_dcdb()
1476 dev_err(&instance->pdev->dev, "DCDB too many SGE NUM=%x\n", in megasas_build_dcdb()
1494 cmd->frame_count = megasas_get_frame_count(instance, pthru->sge_count, in megasas_build_dcdb()
1509 megasas_build_ldio(struct megasas_instance *instance, struct scsi_cmnd *scp, in megasas_build_ldio() argument
1525 if (instance->flag_ieee == 1) { in megasas_build_ldio()
1606 if (instance->flag_ieee) { in megasas_build_ldio()
1608 ldio->sge_count = megasas_make_sgl_skinny(instance, scp, in megasas_build_ldio()
1612 ldio->sge_count = megasas_make_sgl64(instance, scp, &ldio->sgl); in megasas_build_ldio()
1614 ldio->sge_count = megasas_make_sgl32(instance, scp, &ldio->sgl); in megasas_build_ldio()
1616 if (ldio->sge_count > instance->max_num_sge) { in megasas_build_ldio()
1617 dev_err(&instance->pdev->dev, "build_ld_io: sge_count = %x\n", in megasas_build_ldio()
1633 cmd->frame_count = megasas_get_frame_count(instance, in megasas_build_ldio()
1674 megasas_dump_pending_frames(struct megasas_instance *instance) in megasas_dump_pending_frames() argument
1682 u16 max_cmd = instance->max_fw_cmds; in megasas_dump_pending_frames()
1684 …dev_err(&instance->pdev->dev, "[%d]: Dumping Frame Phys Address of all pending cmds in FW\n",insta… in megasas_dump_pending_frames()
1685 …dev_err(&instance->pdev->dev, "[%d]: Total OS Pending cmds : %d\n",instance->host->host_no,atomic_… in megasas_dump_pending_frames()
1687 dev_err(&instance->pdev->dev, "[%d]: 64 bit SGLs were sent to FW\n",instance->host->host_no); in megasas_dump_pending_frames()
1689 dev_err(&instance->pdev->dev, "[%d]: 32 bit SGLs were sent to FW\n",instance->host->host_no); in megasas_dump_pending_frames()
1691 dev_err(&instance->pdev->dev, "[%d]: Pending OS cmds in FW : \n",instance->host->host_no); in megasas_dump_pending_frames()
1693 cmd = instance->cmd_list[i]; in megasas_dump_pending_frames()
1696 …dev_err(&instance->pdev->dev, "[%d]: Frame addr :0x%08lx : ",instance->host->host_no,(unsigned lon… in megasas_dump_pending_frames()
1701 dev_err(&instance->pdev->dev, "[%d]: frame count : 0x%x, Cmd : 0x%x, Tgt id : 0x%x," in megasas_dump_pending_frames()
1703 instance->host->host_no, cmd->frame_count, ldio->cmd, ldio->target_id, in megasas_dump_pending_frames()
1710 dev_err(&instance->pdev->dev, "[%d]: frame count : 0x%x, Cmd : 0x%x, Tgt id : 0x%x, " in megasas_dump_pending_frames()
1712 instance->host->host_no, cmd->frame_count, pthru->cmd, pthru->target_id, in megasas_dump_pending_frames()
1719 dev_err(&instance->pdev->dev, "sgl len : 0x%x, sgl addr : 0x%llx\n", in megasas_dump_pending_frames()
1723 dev_err(&instance->pdev->dev, "sgl len : 0x%x, sgl addr : 0x%x\n", in megasas_dump_pending_frames()
1729 dev_err(&instance->pdev->dev, "[%d]: Pending Internal cmds in FW : \n",instance->host->host_no); in megasas_dump_pending_frames()
1732 cmd = instance->cmd_list[i]; in megasas_dump_pending_frames()
1735 dev_err(&instance->pdev->dev, "0x%08lx : ", (unsigned long)cmd->frame_phys_addr); in megasas_dump_pending_frames()
1737 dev_err(&instance->pdev->dev, "[%d]: Dumping Done\n\n",instance->host->host_no); in megasas_dump_pending_frames()
1741 megasas_build_and_issue_cmd(struct megasas_instance *instance, in megasas_build_and_issue_cmd() argument
1747 cmd = megasas_get_cmd(instance); in megasas_build_and_issue_cmd()
1755 frame_count = megasas_build_ldio(instance, scmd, cmd); in megasas_build_and_issue_cmd()
1757 frame_count = megasas_build_dcdb(instance, scmd, cmd); in megasas_build_and_issue_cmd()
1768 atomic_inc(&instance->fw_outstanding); in megasas_build_and_issue_cmd()
1770 instance->instancet->fire_cmd(instance, cmd->frame_phys_addr, in megasas_build_and_issue_cmd()
1771 cmd->frame_count-1, instance->reg_set); in megasas_build_and_issue_cmd()
1775 megasas_return_cmd(instance, cmd); in megasas_build_and_issue_cmd()
1788 struct megasas_instance *instance; in megasas_queue_command() local
1792 instance = (struct megasas_instance *) in megasas_queue_command()
1795 if (instance->unload == 1) { in megasas_queue_command()
1801 if (instance->issuepend_done == 0) in megasas_queue_command()
1806 if (atomic_read(&instance->adprecovery) == MEGASAS_ADPRESET_SM_INFAULT) { in megasas_queue_command()
1807 if (megasas_check_mpio_paths(instance, scmd) == in megasas_queue_command()
1819 (atomic_read(&instance->adprecovery) == MEGASAS_HW_CRITICAL_ERROR)) { in megasas_queue_command()
1827 if (instance->ld_tgtid_status[ld_tgt_id] == LD_TARGET_ID_DELETED) { in megasas_queue_command()
1834 if (atomic_read(&instance->adprecovery) != MEGASAS_HBA_OPERATIONAL) in megasas_queue_command()
1844 (scmd->device->id >= instance->fw_supported_vd_count || in megasas_queue_command()
1852 (!instance->fw_sync_cache_support)) { in megasas_queue_command()
1857 return instance->instancet->build_and_issue_cmd(instance, scmd); in megasas_queue_command()
1870 if ((megasas_mgmt_info.instance[i]) && in megasas_lookup_instance()
1871 (megasas_mgmt_info.instance[i]->host->host_no == host_no)) in megasas_lookup_instance()
1872 return megasas_mgmt_info.instance[i]; in megasas_lookup_instance()
1895 struct megasas_instance *instance; in megasas_set_dynamic_target_properties() local
1902 instance = megasas_lookup_instance(sdev->host->host_no); in megasas_set_dynamic_target_properties()
1903 fusion = instance->ctrl_context; in megasas_set_dynamic_target_properties()
1912 local_map_ptr = fusion->ld_drv_map[(instance->map_id & 1)]; in megasas_set_dynamic_target_properties()
1914 if (ld >= instance->fw_supported_vd_count) in megasas_set_dynamic_target_properties()
1929 } else if (instance->use_seqnum_jbod_fp) { in megasas_set_dynamic_target_properties()
1933 [(instance->pd_seq_map_id - 1) & 1]; in megasas_set_dynamic_target_properties()
1938 if (is_target_prop && instance->tgt_prop->reset_tmo) { in megasas_set_dynamic_target_properties()
1944 min_t(u8, instance->max_reset_tmo, in megasas_set_dynamic_target_properties()
1945 instance->tgt_prop->reset_tmo); in megasas_set_dynamic_target_properties()
1946 mr_device_priv_data->task_abort_tmo = instance->task_abort_tmo; in megasas_set_dynamic_target_properties()
1975 struct megasas_instance *instance; in megasas_set_nvme_device_properties() local
1978 instance = (struct megasas_instance *)sdev->host->hostdata; in megasas_set_nvme_device_properties()
1979 mr_nvme_pg_size = max_t(u32, instance->nvme_page_size, in megasas_set_nvme_device_properties()
2000 struct megasas_instance *instance; in megasas_set_fw_assisted_qd() local
2003 instance = megasas_lookup_instance(sdev->host->host_no); in megasas_set_fw_assisted_qd()
2020 tgt_device_qd = le32_to_cpu(instance->tgt_prop->device_qdepth); in megasas_set_fw_assisted_qd()
2022 device_qd = min(instance->host->can_queue, in megasas_set_fw_assisted_qd()
2026 if (instance->enable_sdev_max_qd && interface_type != UNKNOWN_DRIVE) in megasas_set_fw_assisted_qd()
2027 device_qd = instance->host->can_queue; in megasas_set_fw_assisted_qd()
2048 struct megasas_instance *instance; in megasas_set_static_target_properties() local
2050 instance = megasas_lookup_instance(sdev->host->host_no); in megasas_set_static_target_properties()
2061 max_io_size_kb = le32_to_cpu(instance->tgt_prop->max_io_size_kb); in megasas_set_static_target_properties()
2063 if (instance->nvme_page_size && max_io_size_kb) in megasas_set_static_target_properties()
2075 struct megasas_instance *instance; in megasas_device_configure() local
2079 instance = megasas_lookup_instance(sdev->host->host_no); in megasas_device_configure()
2080 if (instance->pd_list_not_supported) { in megasas_device_configure()
2084 if (instance->pd_list[pd_index].driveState != in megasas_device_configure()
2090 mutex_lock(&instance->reset_mutex); in megasas_device_configure()
2092 if ((instance->pd_info) && !MEGASAS_IS_LOGICAL(sdev)) in megasas_device_configure()
2093 megasas_get_pd_info(instance, sdev); in megasas_device_configure()
2098 if ((instance->tgt_prop) && (instance->nvme_page_size)) in megasas_device_configure()
2099 ret_target_prop = megasas_get_target_prop(instance, sdev); in megasas_device_configure()
2107 mutex_unlock(&instance->reset_mutex); in megasas_device_configure()
2115 struct megasas_instance *instance ; in megasas_slave_alloc() local
2118 instance = megasas_lookup_instance(sdev->host->host_no); in megasas_slave_alloc()
2126 if ((instance->pd_list_not_supported || in megasas_slave_alloc()
2127 instance->pd_list[pd_index].driveState == in megasas_slave_alloc()
2145 instance->ld_tgtid_status[ld_tgt_id] = LD_TARGET_ID_ACTIVE; in megasas_slave_alloc()
2153 instance->r1_ldio_hint_default); in megasas_slave_alloc()
2160 struct megasas_instance *instance; in megasas_slave_destroy() local
2162 instance = megasas_lookup_instance(sdev->host->host_no); in megasas_slave_destroy()
2170 instance->ld_tgtid_status[ld_tgt_id] = LD_TARGET_ID_DELETED; in megasas_slave_destroy()
2186 static void megasas_complete_outstanding_ioctls(struct megasas_instance *instance) in megasas_complete_outstanding_ioctls() argument
2191 struct fusion_context *fusion = instance->ctrl_context; in megasas_complete_outstanding_ioctls()
2195 for (i = 0; i < instance->max_fw_cmds; i++) { in megasas_complete_outstanding_ioctls()
2198 cmd_mfi = instance->cmd_list[cmd_fusion->sync_cmd_idx]; in megasas_complete_outstanding_ioctls()
2203 megasas_complete_cmd(instance, in megasas_complete_outstanding_ioctls()
2209 for (i = 0; i < instance->max_fw_cmds; i++) { in megasas_complete_outstanding_ioctls()
2210 cmd_mfi = instance->cmd_list[i]; in megasas_complete_outstanding_ioctls()
2213 megasas_complete_cmd(instance, cmd_mfi, DID_OK); in megasas_complete_outstanding_ioctls()
2219 void megaraid_sas_kill_hba(struct megasas_instance *instance) in megaraid_sas_kill_hba() argument
2221 if (atomic_read(&instance->adprecovery) == MEGASAS_HW_CRITICAL_ERROR) { in megaraid_sas_kill_hba()
2222 dev_warn(&instance->pdev->dev, in megaraid_sas_kill_hba()
2228 atomic_set(&instance->adprecovery, MEGASAS_HW_CRITICAL_ERROR); in megaraid_sas_kill_hba()
2231 if ((instance->pdev->device == PCI_DEVICE_ID_LSI_SAS0073SKINNY) || in megaraid_sas_kill_hba()
2232 (instance->pdev->device == PCI_DEVICE_ID_LSI_SAS0071SKINNY) || in megaraid_sas_kill_hba()
2233 (instance->adapter_type != MFI_SERIES)) { in megaraid_sas_kill_hba()
2234 if (!instance->requestorId) { in megaraid_sas_kill_hba()
2235 writel(MFI_STOP_ADP, &instance->reg_set->doorbell); in megaraid_sas_kill_hba()
2237 readl(&instance->reg_set->doorbell); in megaraid_sas_kill_hba()
2239 if (instance->requestorId && instance->peerIsPresent) in megaraid_sas_kill_hba()
2240 memset(instance->ld_ids, 0xff, MEGASAS_MAX_LD_IDS); in megaraid_sas_kill_hba()
2243 &instance->reg_set->inbound_doorbell); in megaraid_sas_kill_hba()
2246 megasas_complete_outstanding_ioctls(instance); in megaraid_sas_kill_hba()
2256 megasas_check_and_restore_queue_depth(struct megasas_instance *instance) in megasas_check_and_restore_queue_depth() argument
2260 if (instance->flag & MEGASAS_FW_BUSY in megasas_check_and_restore_queue_depth()
2261 && time_after(jiffies, instance->last_time + 5 * HZ) in megasas_check_and_restore_queue_depth()
2262 && atomic_read(&instance->fw_outstanding) < in megasas_check_and_restore_queue_depth()
2263 instance->throttlequeuedepth + 1) { in megasas_check_and_restore_queue_depth()
2265 spin_lock_irqsave(instance->host->host_lock, flags); in megasas_check_and_restore_queue_depth()
2266 instance->flag &= ~MEGASAS_FW_BUSY; in megasas_check_and_restore_queue_depth()
2268 instance->host->can_queue = instance->cur_can_queue; in megasas_check_and_restore_queue_depth()
2269 spin_unlock_irqrestore(instance->host->host_lock, flags); in megasas_check_and_restore_queue_depth()
2285 struct megasas_instance *instance = in megasas_complete_cmd_dpc() local
2290 if (atomic_read(&instance->adprecovery) == MEGASAS_HW_CRITICAL_ERROR) in megasas_complete_cmd_dpc()
2293 spin_lock_irqsave(&instance->completion_lock, flags); in megasas_complete_cmd_dpc()
2295 producer = le32_to_cpu(*instance->producer); in megasas_complete_cmd_dpc()
2296 consumer = le32_to_cpu(*instance->consumer); in megasas_complete_cmd_dpc()
2299 context = le32_to_cpu(instance->reply_queue[consumer]); in megasas_complete_cmd_dpc()
2300 if (context >= instance->max_fw_cmds) { in megasas_complete_cmd_dpc()
2301 dev_err(&instance->pdev->dev, "Unexpected context value %x\n", in megasas_complete_cmd_dpc()
2306 cmd = instance->cmd_list[context]; in megasas_complete_cmd_dpc()
2308 megasas_complete_cmd(instance, cmd, DID_OK); in megasas_complete_cmd_dpc()
2311 if (consumer == (instance->max_fw_cmds + 1)) { in megasas_complete_cmd_dpc()
2316 *instance->consumer = cpu_to_le32(producer); in megasas_complete_cmd_dpc()
2318 spin_unlock_irqrestore(&instance->completion_lock, flags); in megasas_complete_cmd_dpc()
2323 megasas_check_and_restore_queue_depth(instance); in megasas_complete_cmd_dpc()
2333 void megasas_start_timer(struct megasas_instance *instance) in megasas_start_timer() argument
2335 struct timer_list *timer = &instance->sriov_heartbeat_timer; in megasas_start_timer()
2343 megasas_internal_reset_defer_cmds(struct megasas_instance *instance);
2348 static void megasas_do_ocr(struct megasas_instance *instance) in megasas_do_ocr() argument
2350 if ((instance->pdev->device == PCI_DEVICE_ID_LSI_SAS1064R) || in megasas_do_ocr()
2351 (instance->pdev->device == PCI_DEVICE_ID_DELL_PERC5) || in megasas_do_ocr()
2352 (instance->pdev->device == PCI_DEVICE_ID_LSI_VERDE_ZCR)) { in megasas_do_ocr()
2353 *instance->consumer = cpu_to_le32(MEGASAS_ADPRESET_INPROG_SIGN); in megasas_do_ocr()
2355 instance->instancet->disable_intr(instance); in megasas_do_ocr()
2356 atomic_set(&instance->adprecovery, MEGASAS_ADPRESET_SM_INFAULT); in megasas_do_ocr()
2357 instance->issuepend_done = 0; in megasas_do_ocr()
2359 atomic_set(&instance->fw_outstanding, 0); in megasas_do_ocr()
2360 megasas_internal_reset_defer_cmds(instance); in megasas_do_ocr()
2361 process_fw_state_change_wq(&instance->work_init); in megasas_do_ocr()
2364 static int megasas_get_ld_vf_affiliation_111(struct megasas_instance *instance, in megasas_get_ld_vf_affiliation_111() argument
2374 cmd = megasas_get_cmd(instance); in megasas_get_ld_vf_affiliation_111()
2377 dev_printk(KERN_DEBUG, &instance->pdev->dev, "megasas_get_ld_vf_affiliation_111:" in megasas_get_ld_vf_affiliation_111()
2379 instance->host->host_no); in megasas_get_ld_vf_affiliation_111()
2385 if (!instance->vf_affiliation_111) { in megasas_get_ld_vf_affiliation_111()
2386 dev_warn(&instance->pdev->dev, "SR-IOV: Couldn't get LD/VF " in megasas_get_ld_vf_affiliation_111()
2387 "affiliation for scsi%d\n", instance->host->host_no); in megasas_get_ld_vf_affiliation_111()
2388 megasas_return_cmd(instance, cmd); in megasas_get_ld_vf_affiliation_111()
2393 memset(instance->vf_affiliation_111, 0, in megasas_get_ld_vf_affiliation_111()
2397 dma_alloc_coherent(&instance->pdev->dev, in megasas_get_ld_vf_affiliation_111()
2401 dev_printk(KERN_DEBUG, &instance->pdev->dev, "SR-IOV: Couldn't allocate " in megasas_get_ld_vf_affiliation_111()
2403 instance->host->host_no); in megasas_get_ld_vf_affiliation_111()
2404 megasas_return_cmd(instance, cmd); in megasas_get_ld_vf_affiliation_111()
2423 cpu_to_le32(instance->vf_affiliation_111_h); in megasas_get_ld_vf_affiliation_111()
2431 dev_warn(&instance->pdev->dev, "SR-IOV: Getting LD/VF affiliation for " in megasas_get_ld_vf_affiliation_111()
2432 "scsi%d\n", instance->host->host_no); in megasas_get_ld_vf_affiliation_111()
2434 if (megasas_issue_blocked_cmd(instance, cmd, 0) != DCMD_SUCCESS) { in megasas_get_ld_vf_affiliation_111()
2435 dev_warn(&instance->pdev->dev, "SR-IOV: LD/VF affiliation DCMD" in megasas_get_ld_vf_affiliation_111()
2437 dcmd->cmd_status, instance->host->host_no); in megasas_get_ld_vf_affiliation_111()
2445 if (instance->vf_affiliation_111->map[ld].policy[thisVf] != in megasas_get_ld_vf_affiliation_111()
2447 dev_warn(&instance->pdev->dev, "SR-IOV: " in megasas_get_ld_vf_affiliation_111()
2449 instance->host->host_no); in megasas_get_ld_vf_affiliation_111()
2450 memcpy(instance->vf_affiliation_111, in megasas_get_ld_vf_affiliation_111()
2459 dma_free_coherent(&instance->pdev->dev, in megasas_get_ld_vf_affiliation_111()
2465 megasas_return_cmd(instance, cmd); in megasas_get_ld_vf_affiliation_111()
2470 static int megasas_get_ld_vf_affiliation_12(struct megasas_instance *instance, in megasas_get_ld_vf_affiliation_12() argument
2481 cmd = megasas_get_cmd(instance); in megasas_get_ld_vf_affiliation_12()
2484 dev_printk(KERN_DEBUG, &instance->pdev->dev, "megasas_get_ld_vf_affiliation12: " in megasas_get_ld_vf_affiliation_12()
2486 instance->host->host_no); in megasas_get_ld_vf_affiliation_12()
2492 if (!instance->vf_affiliation) { in megasas_get_ld_vf_affiliation_12()
2493 dev_warn(&instance->pdev->dev, "SR-IOV: Couldn't get LD/VF " in megasas_get_ld_vf_affiliation_12()
2494 "affiliation for scsi%d\n", instance->host->host_no); in megasas_get_ld_vf_affiliation_12()
2495 megasas_return_cmd(instance, cmd); in megasas_get_ld_vf_affiliation_12()
2500 memset(instance->vf_affiliation, 0, (MAX_LOGICAL_DRIVES + 1) * in megasas_get_ld_vf_affiliation_12()
2504 dma_alloc_coherent(&instance->pdev->dev, in megasas_get_ld_vf_affiliation_12()
2508 dev_printk(KERN_DEBUG, &instance->pdev->dev, "SR-IOV: Couldn't allocate " in megasas_get_ld_vf_affiliation_12()
2510 instance->host->host_no); in megasas_get_ld_vf_affiliation_12()
2511 megasas_return_cmd(instance, cmd); in megasas_get_ld_vf_affiliation_12()
2530 cpu_to_le32(instance->vf_affiliation_h); in megasas_get_ld_vf_affiliation_12()
2538 dev_warn(&instance->pdev->dev, "SR-IOV: Getting LD/VF affiliation for " in megasas_get_ld_vf_affiliation_12()
2539 "scsi%d\n", instance->host->host_no); in megasas_get_ld_vf_affiliation_12()
2542 if (megasas_issue_blocked_cmd(instance, cmd, 0) != DCMD_SUCCESS) { in megasas_get_ld_vf_affiliation_12()
2543 dev_warn(&instance->pdev->dev, "SR-IOV: LD/VF affiliation DCMD" in megasas_get_ld_vf_affiliation_12()
2545 dcmd->cmd_status, instance->host->host_no); in megasas_get_ld_vf_affiliation_12()
2552 dev_warn(&instance->pdev->dev, "SR-IOV: Got new LD/VF " in megasas_get_ld_vf_affiliation_12()
2554 instance->host->host_no); in megasas_get_ld_vf_affiliation_12()
2559 savedmap = instance->vf_affiliation->map; in megasas_get_ld_vf_affiliation_12()
2563 for (j = 0; j < instance->vf_affiliation->ldCount; in megasas_get_ld_vf_affiliation_12()
2588 savedmap = instance->vf_affiliation->map; in megasas_get_ld_vf_affiliation_12()
2590 for (i = 0 ; i < instance->vf_affiliation->ldCount; i++) { in megasas_get_ld_vf_affiliation_12()
2618 dev_warn(&instance->pdev->dev, "SR-IOV: Got new LD/VF " in megasas_get_ld_vf_affiliation_12()
2619 "affiliation for scsi%d\n", instance->host->host_no); in megasas_get_ld_vf_affiliation_12()
2620 memcpy(instance->vf_affiliation, new_affiliation, in megasas_get_ld_vf_affiliation_12()
2626 dma_free_coherent(&instance->pdev->dev, in megasas_get_ld_vf_affiliation_12()
2630 megasas_return_cmd(instance, cmd); in megasas_get_ld_vf_affiliation_12()
2636 static int megasas_get_ld_vf_affiliation(struct megasas_instance *instance, in megasas_get_ld_vf_affiliation() argument
2641 if (instance->PlasmaFW111) in megasas_get_ld_vf_affiliation()
2642 retval = megasas_get_ld_vf_affiliation_111(instance, initial); in megasas_get_ld_vf_affiliation()
2644 retval = megasas_get_ld_vf_affiliation_12(instance, initial); in megasas_get_ld_vf_affiliation()
2649 int megasas_sriov_start_heartbeat(struct megasas_instance *instance, in megasas_sriov_start_heartbeat() argument
2656 cmd = megasas_get_cmd(instance); in megasas_sriov_start_heartbeat()
2659 dev_printk(KERN_DEBUG, &instance->pdev->dev, "megasas_sriov_start_heartbeat: " in megasas_sriov_start_heartbeat()
2661 instance->host->host_no); in megasas_sriov_start_heartbeat()
2668 instance->hb_host_mem = in megasas_sriov_start_heartbeat()
2669 dma_alloc_coherent(&instance->pdev->dev, in megasas_sriov_start_heartbeat()
2671 &instance->hb_host_mem_h, in megasas_sriov_start_heartbeat()
2673 if (!instance->hb_host_mem) { in megasas_sriov_start_heartbeat()
2674 dev_printk(KERN_DEBUG, &instance->pdev->dev, "SR-IOV: Couldn't allocate" in megasas_sriov_start_heartbeat()
2676 instance->host->host_no); in megasas_sriov_start_heartbeat()
2694 megasas_set_dma_settings(instance, dcmd, instance->hb_host_mem_h, in megasas_sriov_start_heartbeat()
2697 dev_warn(&instance->pdev->dev, "SR-IOV: Starting heartbeat for scsi%d\n", in megasas_sriov_start_heartbeat()
2698 instance->host->host_no); in megasas_sriov_start_heartbeat()
2700 if ((instance->adapter_type != MFI_SERIES) && in megasas_sriov_start_heartbeat()
2701 !instance->mask_interrupts) in megasas_sriov_start_heartbeat()
2702 retval = megasas_issue_blocked_cmd(instance, cmd, in megasas_sriov_start_heartbeat()
2705 retval = megasas_issue_polled(instance, cmd); in megasas_sriov_start_heartbeat()
2708 dev_warn(&instance->pdev->dev, "SR-IOV: MR_DCMD_CTRL_SHARED_HOST" in megasas_sriov_start_heartbeat()
2711 "timed out" : "failed", instance->host->host_no); in megasas_sriov_start_heartbeat()
2716 megasas_return_cmd(instance, cmd); in megasas_sriov_start_heartbeat()
2724 struct megasas_instance *instance = in megasas_sriov_heartbeat_handler() local
2725 from_timer(instance, t, sriov_heartbeat_timer); in megasas_sriov_heartbeat_handler()
2727 if (instance->hb_host_mem->HB.fwCounter != in megasas_sriov_heartbeat_handler()
2728 instance->hb_host_mem->HB.driverCounter) { in megasas_sriov_heartbeat_handler()
2729 instance->hb_host_mem->HB.driverCounter = in megasas_sriov_heartbeat_handler()
2730 instance->hb_host_mem->HB.fwCounter; in megasas_sriov_heartbeat_handler()
2731 mod_timer(&instance->sriov_heartbeat_timer, in megasas_sriov_heartbeat_handler()
2734 dev_warn(&instance->pdev->dev, "SR-IOV: Heartbeat never " in megasas_sriov_heartbeat_handler()
2735 "completed for scsi%d\n", instance->host->host_no); in megasas_sriov_heartbeat_handler()
2736 schedule_work(&instance->work_init); in megasas_sriov_heartbeat_handler()
2748 static int megasas_wait_for_outstanding(struct megasas_instance *instance) in megasas_wait_for_outstanding() argument
2758 if (atomic_read(&instance->adprecovery) == MEGASAS_HW_CRITICAL_ERROR) { in megasas_wait_for_outstanding()
2759 dev_info(&instance->pdev->dev, "%s:%d HBA is killed.\n", in megasas_wait_for_outstanding()
2764 if (atomic_read(&instance->adprecovery) != MEGASAS_HBA_OPERATIONAL) { in megasas_wait_for_outstanding()
2767 spin_lock_irqsave(&instance->hba_lock, flags); in megasas_wait_for_outstanding()
2768 list_splice_init(&instance->internal_reset_pending_q, in megasas_wait_for_outstanding()
2770 spin_unlock_irqrestore(&instance->hba_lock, flags); in megasas_wait_for_outstanding()
2772 dev_notice(&instance->pdev->dev, "HBA reset wait ...\n"); in megasas_wait_for_outstanding()
2775 if (atomic_read(&instance->adprecovery) == MEGASAS_HBA_OPERATIONAL) in megasas_wait_for_outstanding()
2779 if (atomic_read(&instance->adprecovery) != MEGASAS_HBA_OPERATIONAL) { in megasas_wait_for_outstanding()
2780 dev_notice(&instance->pdev->dev, "reset: Stopping HBA.\n"); in megasas_wait_for_outstanding()
2781 atomic_set(&instance->adprecovery, MEGASAS_HW_CRITICAL_ERROR); in megasas_wait_for_outstanding()
2792 dev_notice(&instance->pdev->dev, "%d:%p reset [%02x]\n", in megasas_wait_for_outstanding()
2797 megasas_return_cmd(instance, reset_cmd); in megasas_wait_for_outstanding()
2799 dev_notice(&instance->pdev->dev, "%p synch cmds" in megasas_wait_for_outstanding()
2804 instance->instancet->fire_cmd(instance, in megasas_wait_for_outstanding()
2806 0, instance->reg_set); in megasas_wait_for_outstanding()
2808 dev_notice(&instance->pdev->dev, "%p unexpected" in megasas_wait_for_outstanding()
2819 outstanding = atomic_read(&instance->fw_outstanding); in megasas_wait_for_outstanding()
2825 dev_notice(&instance->pdev->dev, "[%2d]waiting for %d " in megasas_wait_for_outstanding()
2831 megasas_complete_cmd_dpc((unsigned long)instance); in megasas_wait_for_outstanding()
2838 outstanding = atomic_read(&instance->fw_outstanding); in megasas_wait_for_outstanding()
2839 fw_state = instance->instancet->read_fw_status_reg(instance) & MFI_STATE_MASK; in megasas_wait_for_outstanding()
2844 if (instance->disableOnlineCtrlReset) in megasas_wait_for_outstanding()
2847 if ((fw_state == MFI_STATE_FAULT) || atomic_read(&instance->fw_outstanding)) { in megasas_wait_for_outstanding()
2848 dev_info(&instance->pdev->dev, in megasas_wait_for_outstanding()
2850 __func__, __LINE__, fw_state, atomic_read(&instance->fw_outstanding)); in megasas_wait_for_outstanding()
2853 megasas_do_ocr(instance); in megasas_wait_for_outstanding()
2855 if (atomic_read(&instance->adprecovery) == MEGASAS_HW_CRITICAL_ERROR) { in megasas_wait_for_outstanding()
2856 dev_info(&instance->pdev->dev, "%s:%d OCR failed and HBA is killed.\n", in megasas_wait_for_outstanding()
2860 dev_info(&instance->pdev->dev, "%s:%d waiting_for_outstanding: after issue OCR.\n", in megasas_wait_for_outstanding()
2866 outstanding = atomic_read(&instance->fw_outstanding); in megasas_wait_for_outstanding()
2868 fw_state = instance->instancet->read_fw_status_reg(instance) & MFI_STATE_MASK; in megasas_wait_for_outstanding()
2877 dev_info(&instance->pdev->dev, "%s:%d no more pending commands remain after reset handling.\n", in megasas_wait_for_outstanding()
2884 dev_info(&instance->pdev->dev, "%s:%d killing adapter scsi%d" in megasas_wait_for_outstanding()
2886 __func__, __LINE__, instance->host->host_no, instance->disableOnlineCtrlReset, in megasas_wait_for_outstanding()
2887 atomic_read(&instance->fw_outstanding)); in megasas_wait_for_outstanding()
2888 megasas_dump_pending_frames(instance); in megasas_wait_for_outstanding()
2889 megaraid_sas_kill_hba(instance); in megasas_wait_for_outstanding()
2905 struct megasas_instance *instance; in megasas_generic_reset() local
2907 instance = (struct megasas_instance *)scmd->device->host->hostdata; in megasas_generic_reset()
2912 if (atomic_read(&instance->adprecovery) == MEGASAS_HW_CRITICAL_ERROR) { in megasas_generic_reset()
2913 dev_err(&instance->pdev->dev, "cannot recover from previous reset failures\n"); in megasas_generic_reset()
2917 ret_val = megasas_wait_for_outstanding(instance); in megasas_generic_reset()
2919 dev_notice(&instance->pdev->dev, "reset successful\n"); in megasas_generic_reset()
2921 dev_err(&instance->pdev->dev, "failed to do reset\n"); in megasas_generic_reset()
2935 struct megasas_instance *instance; in megasas_reset_timer() local
2943 instance = (struct megasas_instance *)scmd->device->host->hostdata; in megasas_reset_timer()
2944 if (!(instance->flag & MEGASAS_FW_BUSY)) { in megasas_reset_timer()
2946 spin_lock_irqsave(instance->host->host_lock, flags); in megasas_reset_timer()
2948 instance->host->can_queue = instance->throttlequeuedepth; in megasas_reset_timer()
2949 instance->last_time = jiffies; in megasas_reset_timer()
2950 instance->flag |= MEGASAS_FW_BUSY; in megasas_reset_timer()
2952 spin_unlock_irqrestore(instance->host->host_lock, flags); in megasas_reset_timer()
3006 struct megasas_instance *instance; in megasas_dump_fusion_io() local
3008 instance = (struct megasas_instance *)scmd->device->host->hostdata; in megasas_dump_fusion_io()
3029 instance->max_chain_frame_sz, 8); in megasas_dump_fusion_io()
3065 struct megasas_instance *instance; in megasas_reset_bus_host() local
3067 instance = (struct megasas_instance *)scmd->device->host->hostdata; in megasas_reset_bus_host()
3076 atomic_read(&instance->fw_outstanding)); in megasas_reset_bus_host()
3080 if (instance->adapter_type == MFI_SERIES) { in megasas_reset_bus_host()
3099 struct megasas_instance *instance; in megasas_task_abort() local
3101 instance = (struct megasas_instance *)scmd->device->host->hostdata; in megasas_task_abort()
3103 if (instance->adapter_type != MFI_SERIES) in megasas_task_abort()
3121 struct megasas_instance *instance; in megasas_reset_target() local
3123 instance = (struct megasas_instance *)scmd->device->host->hostdata; in megasas_reset_target()
3125 if (instance->adapter_type != MFI_SERIES) in megasas_reset_target()
3181 struct megasas_instance *instance; in megasas_map_queues() local
3185 instance = (struct megasas_instance *)shost->hostdata; in megasas_map_queues()
3190 offset = instance->low_latency_index_start; in megasas_map_queues()
3194 map->nr_queues = instance->msix_vectors - offset; in megasas_map_queues()
3196 blk_mq_pci_map_queues(map, instance->pdev, offset); in megasas_map_queues()
3205 map->nr_queues = instance->iopoll_q_count; in megasas_map_queues()
3231 megasas_service_aen(struct megasas_instance *instance, struct megasas_cmd *cmd) in megasas_service_aen() argument
3238 if ((!cmd->abort_aen) && (instance->unload == 0)) { in megasas_service_aen()
3248 instance->aen_cmd = NULL; in megasas_service_aen()
3250 megasas_return_cmd(instance, cmd); in megasas_service_aen()
3252 if ((instance->unload == 0) && in megasas_service_aen()
3253 ((instance->issuepend_done == 1))) { in megasas_service_aen()
3258 dev_err(&instance->pdev->dev, "megasas_service_aen: out of memory\n"); in megasas_service_aen()
3260 ev->instance = instance; in megasas_service_aen()
3261 instance->ev = ev; in megasas_service_aen()
3274 struct megasas_instance *instance = in fw_crash_buffer_store() local
3281 mutex_lock(&instance->crashdump_lock); in fw_crash_buffer_store()
3282 instance->fw_crash_buffer_offset = val; in fw_crash_buffer_store()
3283 mutex_unlock(&instance->crashdump_lock); in fw_crash_buffer_store()
3292 struct megasas_instance *instance = in fw_crash_buffer_show() local
3300 mutex_lock(&instance->crashdump_lock); in fw_crash_buffer_show()
3301 buff_offset = instance->fw_crash_buffer_offset; in fw_crash_buffer_show()
3302 if (!instance->crash_dump_buf || in fw_crash_buffer_show()
3303 !((instance->fw_crash_state == AVAILABLE) || in fw_crash_buffer_show()
3304 (instance->fw_crash_state == COPYING))) { in fw_crash_buffer_show()
3305 dev_err(&instance->pdev->dev, in fw_crash_buffer_show()
3307 mutex_unlock(&instance->crashdump_lock); in fw_crash_buffer_show()
3311 if (buff_offset > (instance->fw_crash_buffer_size * dmachunk)) { in fw_crash_buffer_show()
3312 dev_err(&instance->pdev->dev, in fw_crash_buffer_show()
3314 mutex_unlock(&instance->crashdump_lock); in fw_crash_buffer_show()
3318 size = (instance->fw_crash_buffer_size * dmachunk) - buff_offset; in fw_crash_buffer_show()
3323 src_addr = (unsigned long)instance->crash_buf[buff_offset / dmachunk] + in fw_crash_buffer_show()
3326 mutex_unlock(&instance->crashdump_lock); in fw_crash_buffer_show()
3336 struct megasas_instance *instance = in fw_crash_buffer_size_show() local
3340 ((instance->fw_crash_buffer_size) * 1024 * 1024)/PAGE_SIZE); in fw_crash_buffer_size_show()
3348 struct megasas_instance *instance = in fw_crash_state_store() local
3356 dev_err(&instance->pdev->dev, "application updates invalid " in fw_crash_state_store()
3361 instance->fw_crash_state = val; in fw_crash_state_store()
3364 mutex_lock(&instance->crashdump_lock); in fw_crash_state_store()
3365 megasas_free_host_crash_buffer(instance); in fw_crash_state_store()
3366 mutex_unlock(&instance->crashdump_lock); in fw_crash_state_store()
3368 dev_info(&instance->pdev->dev, "application failed to " in fw_crash_state_store()
3371 dev_info(&instance->pdev->dev, "Firmware crash dump " in fw_crash_state_store()
3382 struct megasas_instance *instance = in fw_crash_state_show() local
3385 return snprintf(buf, PAGE_SIZE, "%d\n", instance->fw_crash_state); in fw_crash_state_show()
3400 struct megasas_instance *instance = (struct megasas_instance *)shost->hostdata; in ldio_outstanding_show() local
3402 return snprintf(buf, PAGE_SIZE, "%d\n", atomic_read(&instance->ldio_outstanding)); in ldio_outstanding_show()
3410 struct megasas_instance *instance = (struct megasas_instance *)shost->hostdata; in fw_cmds_outstanding_show() local
3412 return snprintf(buf, PAGE_SIZE, "%d\n", atomic_read(&instance->fw_outstanding)); in fw_cmds_outstanding_show()
3420 struct megasas_instance *instance = (struct megasas_instance *)shost->hostdata; in enable_sdev_max_qd_show() local
3422 return snprintf(buf, PAGE_SIZE, "%d\n", instance->enable_sdev_max_qd); in enable_sdev_max_qd_show()
3430 struct megasas_instance *instance = (struct megasas_instance *)shost->hostdata; in enable_sdev_max_qd_store() local
3441 mutex_lock(&instance->reset_mutex); in enable_sdev_max_qd_store()
3443 instance->enable_sdev_max_qd = true; in enable_sdev_max_qd_store()
3445 instance->enable_sdev_max_qd = false; in enable_sdev_max_qd_store()
3448 ret_target_prop = megasas_get_target_prop(instance, sdev); in enable_sdev_max_qd_store()
3452 mutex_unlock(&instance->reset_mutex); in enable_sdev_max_qd_store()
3462 struct megasas_instance *instance = in dump_system_regs_show() local
3465 return megasas_dump_sys_regs(instance->reg_set, buf); in dump_system_regs_show()
3473 struct megasas_instance *instance = in raid_map_id_show() local
3477 (unsigned long)instance->map_id); in raid_map_id_show()
3540 megasas_complete_int_cmd(struct megasas_instance *instance, in megasas_complete_int_cmd() argument
3548 wake_up(&instance->int_cmd_wait_q); in megasas_complete_int_cmd()
3561 megasas_complete_abort(struct megasas_instance *instance, in megasas_complete_abort() argument
3567 wake_up(&instance->abort_cmd_wait_q); in megasas_complete_abort()
3572 megasas_set_ld_removed_by_fw(struct megasas_instance *instance) in megasas_set_ld_removed_by_fw() argument
3577 if (instance->ld_ids_prev[i] != 0xff && in megasas_set_ld_removed_by_fw()
3578 instance->ld_ids_from_raidmap[i] == 0xff) { in megasas_set_ld_removed_by_fw()
3580 dev_info(&instance->pdev->dev, in megasas_set_ld_removed_by_fw()
3582 instance->ld_tgtid_status[i] = LD_TARGET_ID_DELETED; in megasas_set_ld_removed_by_fw()
3598 megasas_complete_cmd(struct megasas_instance *instance, struct megasas_cmd *cmd, in megasas_complete_cmd() argument
3604 struct fusion_context *fusion = instance->ctrl_context; in megasas_complete_cmd()
3619 dev_warn(&instance->pdev->dev, "MFI_CMD_INVALID command " in megasas_complete_cmd()
3621 dev_warn(&instance->pdev->dev, "If you have a controller " in megasas_complete_cmd()
3634 megasas_complete_int_cmd(instance, cmd); in megasas_complete_cmd()
3649 atomic_dec(&instance->fw_outstanding); in megasas_complete_cmd()
3653 megasas_return_cmd(instance, cmd); in megasas_complete_cmd()
3689 dev_printk(KERN_DEBUG, &instance->pdev->dev, "MFI FW status %#x\n", in megasas_complete_cmd()
3695 atomic_dec(&instance->fw_outstanding); in megasas_complete_cmd()
3699 megasas_return_cmd(instance, cmd); in megasas_complete_cmd()
3707 megasas_complete_int_cmd(instance, cmd); in megasas_complete_cmd()
3716 spin_lock_irqsave(instance->host->host_lock, flags); in megasas_complete_cmd()
3718 instance->map_update_cmd = NULL; in megasas_complete_cmd()
3721 dev_warn(&instance->pdev->dev, "map syncfailed, status = 0x%x\n", in megasas_complete_cmd()
3724 megasas_return_cmd(instance, cmd); in megasas_complete_cmd()
3726 instance->host->host_lock, in megasas_complete_cmd()
3732 megasas_return_cmd(instance, cmd); in megasas_complete_cmd()
3740 (MR_ValidateMapInfo(instance, (instance->map_id + 1)))) { in megasas_complete_cmd()
3741 instance->map_id++; in megasas_complete_cmd()
3747 if (instance->adapter_type >= INVADER_SERIES) in megasas_complete_cmd()
3748 megasas_set_ld_removed_by_fw(instance); in megasas_complete_cmd()
3750 megasas_sync_map_info(instance); in megasas_complete_cmd()
3751 spin_unlock_irqrestore(instance->host->host_lock, in megasas_complete_cmd()
3767 spin_lock_irqsave(instance->host->host_lock, flags); in megasas_complete_cmd()
3769 instance->jbod_seq_cmd = NULL; in megasas_complete_cmd()
3770 megasas_return_cmd(instance, cmd); in megasas_complete_cmd()
3773 instance->pd_seq_map_id++; in megasas_complete_cmd()
3775 if (megasas_sync_pd_seq_num(instance, true)) in megasas_complete_cmd()
3776 instance->use_seqnum_jbod_fp = false; in megasas_complete_cmd()
3778 instance->use_seqnum_jbod_fp = false; in megasas_complete_cmd()
3780 spin_unlock_irqrestore(instance->host->host_lock, flags); in megasas_complete_cmd()
3788 megasas_service_aen(instance, cmd); in megasas_complete_cmd()
3790 megasas_complete_int_cmd(instance, cmd); in megasas_complete_cmd()
3798 megasas_complete_abort(instance, cmd); in megasas_complete_cmd()
3802 dev_info(&instance->pdev->dev, "Unknown command completed! [0x%X]\n", in megasas_complete_cmd()
3804 megasas_complete_int_cmd(instance, cmd); in megasas_complete_cmd()
3815 megasas_issue_pending_cmds_again(struct megasas_instance *instance) in megasas_issue_pending_cmds_again() argument
3824 spin_lock_irqsave(&instance->hba_lock, flags); in megasas_issue_pending_cmds_again()
3825 list_splice_init(&instance->internal_reset_pending_q, &clist_local); in megasas_issue_pending_cmds_again()
3826 spin_unlock_irqrestore(&instance->hba_lock, flags); in megasas_issue_pending_cmds_again()
3834 dev_notice(&instance->pdev->dev, "command %p, %p:%d" in megasas_issue_pending_cmds_again()
3841 dev_notice(&instance->pdev->dev, "cmd %p, %p:%d" in megasas_issue_pending_cmds_again()
3845 instance->instancet->disable_intr(instance); in megasas_issue_pending_cmds_again()
3846 atomic_set(&instance->fw_reset_no_pci_access, 1); in megasas_issue_pending_cmds_again()
3847 megaraid_sas_kill_hba(instance); in megasas_issue_pending_cmds_again()
3854 dev_notice(&instance->pdev->dev, "unexpected" in megasas_issue_pending_cmds_again()
3857 dev_notice(&instance->pdev->dev, "%p synchronous cmd" in megasas_issue_pending_cmds_again()
3861 instance->instancet->fire_cmd(instance, in megasas_issue_pending_cmds_again()
3863 0, instance->reg_set); in megasas_issue_pending_cmds_again()
3865 dev_notice(&instance->pdev->dev, "%p scsi cmd [%02x]" in megasas_issue_pending_cmds_again()
3869 atomic_inc(&instance->fw_outstanding); in megasas_issue_pending_cmds_again()
3870 instance->instancet->fire_cmd(instance, in megasas_issue_pending_cmds_again()
3872 cmd->frame_count-1, instance->reg_set); in megasas_issue_pending_cmds_again()
3874 dev_notice(&instance->pdev->dev, "%p unexpected cmd on the" in megasas_issue_pending_cmds_again()
3880 if (instance->aen_cmd) { in megasas_issue_pending_cmds_again()
3881 dev_notice(&instance->pdev->dev, "aen_cmd in def process\n"); in megasas_issue_pending_cmds_again()
3882 megasas_return_cmd(instance, instance->aen_cmd); in megasas_issue_pending_cmds_again()
3884 instance->aen_cmd = NULL; in megasas_issue_pending_cmds_again()
3890 seq_num = instance->last_seq_num; in megasas_issue_pending_cmds_again()
3895 megasas_register_aen(instance, seq_num, class_locale.word); in megasas_issue_pending_cmds_again()
3908 megasas_internal_reset_defer_cmds(struct megasas_instance *instance) in megasas_internal_reset_defer_cmds() argument
3912 u16 max_cmd = instance->max_fw_cmds; in megasas_internal_reset_defer_cmds()
3917 spin_lock_irqsave(&instance->mfi_pool_lock, flags); in megasas_internal_reset_defer_cmds()
3919 cmd = instance->cmd_list[i]; in megasas_internal_reset_defer_cmds()
3921 dev_notice(&instance->pdev->dev, "moving cmd[%d]:%p:%d:%p" in megasas_internal_reset_defer_cmds()
3926 dev_notice(&instance->pdev->dev, "ERROR while" in megasas_internal_reset_defer_cmds()
3935 &instance->internal_reset_pending_q); in megasas_internal_reset_defer_cmds()
3938 spin_unlock_irqrestore(&instance->mfi_pool_lock, flags); in megasas_internal_reset_defer_cmds()
3945 struct megasas_instance *instance = in process_fw_state_change_wq() local
3950 if (atomic_read(&instance->adprecovery) != MEGASAS_ADPRESET_SM_INFAULT) { in process_fw_state_change_wq()
3951 dev_notice(&instance->pdev->dev, "error, recovery st %x\n", in process_fw_state_change_wq()
3952 atomic_read(&instance->adprecovery)); in process_fw_state_change_wq()
3956 if (atomic_read(&instance->adprecovery) == MEGASAS_ADPRESET_SM_INFAULT) { in process_fw_state_change_wq()
3957 dev_notice(&instance->pdev->dev, "FW detected to be in fault" in process_fw_state_change_wq()
3960 instance->instancet->disable_intr(instance); in process_fw_state_change_wq()
3961 atomic_set(&instance->fw_outstanding, 0); in process_fw_state_change_wq()
3963 atomic_set(&instance->fw_reset_no_pci_access, 1); in process_fw_state_change_wq()
3964 instance->instancet->adp_reset(instance, instance->reg_set); in process_fw_state_change_wq()
3965 atomic_set(&instance->fw_reset_no_pci_access, 0); in process_fw_state_change_wq()
3967 dev_notice(&instance->pdev->dev, "FW restarted successfully," in process_fw_state_change_wq()
3970 dev_notice(&instance->pdev->dev, "HBA recovery state machine," in process_fw_state_change_wq()
3978 if (megasas_transition_to_ready(instance, 1)) { in process_fw_state_change_wq()
3979 dev_notice(&instance->pdev->dev, "adapter not ready\n"); in process_fw_state_change_wq()
3981 atomic_set(&instance->fw_reset_no_pci_access, 1); in process_fw_state_change_wq()
3982 megaraid_sas_kill_hba(instance); in process_fw_state_change_wq()
3986 if ((instance->pdev->device == PCI_DEVICE_ID_LSI_SAS1064R) || in process_fw_state_change_wq()
3987 (instance->pdev->device == PCI_DEVICE_ID_DELL_PERC5) || in process_fw_state_change_wq()
3988 (instance->pdev->device == PCI_DEVICE_ID_LSI_VERDE_ZCR) in process_fw_state_change_wq()
3990 *instance->consumer = *instance->producer; in process_fw_state_change_wq()
3992 *instance->consumer = 0; in process_fw_state_change_wq()
3993 *instance->producer = 0; in process_fw_state_change_wq()
3996 megasas_issue_init_mfi(instance); in process_fw_state_change_wq()
3998 spin_lock_irqsave(&instance->hba_lock, flags); in process_fw_state_change_wq()
3999 atomic_set(&instance->adprecovery, MEGASAS_HBA_OPERATIONAL); in process_fw_state_change_wq()
4000 spin_unlock_irqrestore(&instance->hba_lock, flags); in process_fw_state_change_wq()
4001 instance->instancet->enable_intr(instance); in process_fw_state_change_wq()
4003 megasas_issue_pending_cmds_again(instance); in process_fw_state_change_wq()
4004 instance->issuepend_done = 1; in process_fw_state_change_wq()
4017 megasas_deplete_reply_queue(struct megasas_instance *instance, in megasas_deplete_reply_queue() argument
4023 if (instance->instancet->check_reset(instance, instance->reg_set) == 1) in megasas_deplete_reply_queue()
4026 mfiStatus = instance->instancet->clear_intr(instance); in megasas_deplete_reply_queue()
4029 if (!instance->msix_vectors) in megasas_deplete_reply_queue()
4033 instance->mfiStatus = mfiStatus; in megasas_deplete_reply_queue()
4036 fw_state = instance->instancet->read_fw_status_reg( in megasas_deplete_reply_queue()
4037 instance) & MFI_STATE_MASK; in megasas_deplete_reply_queue()
4040 dev_notice(&instance->pdev->dev, "fw state:%x\n", in megasas_deplete_reply_queue()
4045 (instance->disableOnlineCtrlReset == 0)) { in megasas_deplete_reply_queue()
4046 dev_notice(&instance->pdev->dev, "wait adp restart\n"); in megasas_deplete_reply_queue()
4048 if ((instance->pdev->device == in megasas_deplete_reply_queue()
4050 (instance->pdev->device == in megasas_deplete_reply_queue()
4052 (instance->pdev->device == in megasas_deplete_reply_queue()
4055 *instance->consumer = in megasas_deplete_reply_queue()
4060 instance->instancet->disable_intr(instance); in megasas_deplete_reply_queue()
4061 atomic_set(&instance->adprecovery, MEGASAS_ADPRESET_SM_INFAULT); in megasas_deplete_reply_queue()
4062 instance->issuepend_done = 0; in megasas_deplete_reply_queue()
4064 atomic_set(&instance->fw_outstanding, 0); in megasas_deplete_reply_queue()
4065 megasas_internal_reset_defer_cmds(instance); in megasas_deplete_reply_queue()
4067 dev_notice(&instance->pdev->dev, "fwState=%x, stage:%d\n", in megasas_deplete_reply_queue()
4068 fw_state, atomic_read(&instance->adprecovery)); in megasas_deplete_reply_queue()
4070 schedule_work(&instance->work_init); in megasas_deplete_reply_queue()
4074 dev_notice(&instance->pdev->dev, "fwstate:%x, dis_OCR=%x\n", in megasas_deplete_reply_queue()
4075 fw_state, instance->disableOnlineCtrlReset); in megasas_deplete_reply_queue()
4079 tasklet_schedule(&instance->isr_tasklet); in megasas_deplete_reply_queue()
4091 struct megasas_instance *instance = irq_context->instance; in megasas_isr() local
4095 if (atomic_read(&instance->fw_reset_no_pci_access)) in megasas_isr()
4098 spin_lock_irqsave(&instance->hba_lock, flags); in megasas_isr()
4099 rc = megasas_deplete_reply_queue(instance, DID_OK); in megasas_isr()
4100 spin_unlock_irqrestore(&instance->hba_lock, flags); in megasas_isr()
4116 megasas_transition_to_ready(struct megasas_instance *instance, int ocr) in megasas_transition_to_ready() argument
4123 abs_state = instance->instancet->read_fw_status_reg(instance); in megasas_transition_to_ready()
4127 dev_info(&instance->pdev->dev, "Waiting for FW to come to ready" in megasas_transition_to_ready()
4135 dev_printk(KERN_ERR, &instance->pdev->dev, in megasas_transition_to_ready()
4143 dev_printk(KERN_DEBUG, &instance->pdev->dev, "System Register set:\n"); in megasas_transition_to_ready()
4144 megasas_dump_reg_set(instance->reg_set); in megasas_transition_to_ready()
4152 if ((instance->pdev->device == in megasas_transition_to_ready()
4154 (instance->pdev->device == in megasas_transition_to_ready()
4156 (instance->adapter_type != MFI_SERIES)) in megasas_transition_to_ready()
4159 &instance->reg_set->doorbell); in megasas_transition_to_ready()
4163 &instance->reg_set->inbound_doorbell); in megasas_transition_to_ready()
4169 if ((instance->pdev->device == in megasas_transition_to_ready()
4171 (instance->pdev->device == in megasas_transition_to_ready()
4173 (instance->adapter_type != MFI_SERIES)) in megasas_transition_to_ready()
4175 &instance->reg_set->doorbell); in megasas_transition_to_ready()
4178 &instance->reg_set->inbound_doorbell); in megasas_transition_to_ready()
4187 instance->instancet->disable_intr(instance); in megasas_transition_to_ready()
4188 if ((instance->pdev->device == in megasas_transition_to_ready()
4190 (instance->pdev->device == in megasas_transition_to_ready()
4192 (instance->adapter_type != MFI_SERIES)) { in megasas_transition_to_ready()
4194 &instance->reg_set->doorbell); in megasas_transition_to_ready()
4196 if (instance->adapter_type != MFI_SERIES) { in megasas_transition_to_ready()
4199 instance, in megasas_transition_to_ready()
4200 &instance-> in megasas_transition_to_ready()
4210 &instance->reg_set->inbound_doorbell); in megasas_transition_to_ready()
4243 dev_printk(KERN_DEBUG, &instance->pdev->dev, "Unknown state 0x%x\n", in megasas_transition_to_ready()
4245 dev_printk(KERN_DEBUG, &instance->pdev->dev, "System Register set:\n"); in megasas_transition_to_ready()
4246 megasas_dump_reg_set(instance->reg_set); in megasas_transition_to_ready()
4254 curr_abs_state = instance->instancet-> in megasas_transition_to_ready()
4255 read_fw_status_reg(instance); in megasas_transition_to_ready()
4267 dev_printk(KERN_DEBUG, &instance->pdev->dev, "FW state [%d] hasn't changed " in megasas_transition_to_ready()
4269 dev_printk(KERN_DEBUG, &instance->pdev->dev, "System Register set:\n"); in megasas_transition_to_ready()
4270 megasas_dump_reg_set(instance->reg_set); in megasas_transition_to_ready()
4277 dev_info(&instance->pdev->dev, "FW now in Ready state\n"); in megasas_transition_to_ready()
4286 static void megasas_teardown_frame_pool(struct megasas_instance *instance) in megasas_teardown_frame_pool() argument
4289 u16 max_cmd = instance->max_mfi_cmds; in megasas_teardown_frame_pool()
4292 if (!instance->frame_dma_pool) in megasas_teardown_frame_pool()
4300 cmd = instance->cmd_list[i]; in megasas_teardown_frame_pool()
4303 dma_pool_free(instance->frame_dma_pool, cmd->frame, in megasas_teardown_frame_pool()
4307 dma_pool_free(instance->sense_dma_pool, cmd->sense, in megasas_teardown_frame_pool()
4314 dma_pool_destroy(instance->frame_dma_pool); in megasas_teardown_frame_pool()
4315 dma_pool_destroy(instance->sense_dma_pool); in megasas_teardown_frame_pool()
4317 instance->frame_dma_pool = NULL; in megasas_teardown_frame_pool()
4318 instance->sense_dma_pool = NULL; in megasas_teardown_frame_pool()
4330 static int megasas_create_frame_pool(struct megasas_instance *instance) in megasas_create_frame_pool() argument
4337 max_cmd = instance->max_mfi_cmds; in megasas_create_frame_pool()
4350 frame_count = (instance->adapter_type == MFI_SERIES) ? in megasas_create_frame_pool()
4352 instance->mfi_frame_size = MEGAMFI_FRAME_SIZE * frame_count; in megasas_create_frame_pool()
4356 instance->frame_dma_pool = dma_pool_create("megasas frame pool", in megasas_create_frame_pool()
4357 &instance->pdev->dev, in megasas_create_frame_pool()
4358 instance->mfi_frame_size, 256, 0); in megasas_create_frame_pool()
4360 if (!instance->frame_dma_pool) { in megasas_create_frame_pool()
4361 dev_printk(KERN_DEBUG, &instance->pdev->dev, "failed to setup frame pool\n"); in megasas_create_frame_pool()
4365 instance->sense_dma_pool = dma_pool_create("megasas sense pool", in megasas_create_frame_pool()
4366 &instance->pdev->dev, 128, in megasas_create_frame_pool()
4369 if (!instance->sense_dma_pool) { in megasas_create_frame_pool()
4370 dev_printk(KERN_DEBUG, &instance->pdev->dev, "failed to setup sense pool\n"); in megasas_create_frame_pool()
4372 dma_pool_destroy(instance->frame_dma_pool); in megasas_create_frame_pool()
4373 instance->frame_dma_pool = NULL; in megasas_create_frame_pool()
4385 cmd = instance->cmd_list[i]; in megasas_create_frame_pool()
4387 cmd->frame = dma_pool_zalloc(instance->frame_dma_pool, in megasas_create_frame_pool()
4390 cmd->sense = dma_pool_alloc(instance->sense_dma_pool, in megasas_create_frame_pool()
4398 dev_printk(KERN_DEBUG, &instance->pdev->dev, "dma_pool_alloc failed\n"); in megasas_create_frame_pool()
4399 megasas_teardown_frame_pool(instance); in megasas_create_frame_pool()
4405 if ((instance->adapter_type == MFI_SERIES) && reset_devices) in megasas_create_frame_pool()
4416 void megasas_free_cmds(struct megasas_instance *instance) in megasas_free_cmds() argument
4421 megasas_teardown_frame_pool(instance); in megasas_free_cmds()
4424 for (i = 0; i < instance->max_mfi_cmds; i++) in megasas_free_cmds()
4426 kfree(instance->cmd_list[i]); in megasas_free_cmds()
4429 kfree(instance->cmd_list); in megasas_free_cmds()
4430 instance->cmd_list = NULL; in megasas_free_cmds()
4432 INIT_LIST_HEAD(&instance->cmd_pool); in megasas_free_cmds()
4453 int megasas_alloc_cmds(struct megasas_instance *instance) in megasas_alloc_cmds() argument
4460 max_cmd = instance->max_mfi_cmds; in megasas_alloc_cmds()
4467 instance->cmd_list = kcalloc(max_cmd, sizeof(struct megasas_cmd*), GFP_KERNEL); in megasas_alloc_cmds()
4469 if (!instance->cmd_list) { in megasas_alloc_cmds()
4470 dev_printk(KERN_DEBUG, &instance->pdev->dev, "out of memory\n"); in megasas_alloc_cmds()
4475 instance->cmd_list[i] = kmalloc(sizeof(struct megasas_cmd), in megasas_alloc_cmds()
4478 if (!instance->cmd_list[i]) { in megasas_alloc_cmds()
4481 kfree(instance->cmd_list[j]); in megasas_alloc_cmds()
4483 kfree(instance->cmd_list); in megasas_alloc_cmds()
4484 instance->cmd_list = NULL; in megasas_alloc_cmds()
4491 cmd = instance->cmd_list[i]; in megasas_alloc_cmds()
4495 cmd->instance = instance; in megasas_alloc_cmds()
4497 list_add_tail(&cmd->list, &instance->cmd_pool); in megasas_alloc_cmds()
4503 if (megasas_create_frame_pool(instance)) { in megasas_alloc_cmds()
4504 dev_printk(KERN_DEBUG, &instance->pdev->dev, "Error creating frame DMA pool\n"); in megasas_alloc_cmds()
4505 megasas_free_cmds(instance); in megasas_alloc_cmds()
4520 dcmd_timeout_ocr_possible(struct megasas_instance *instance) { in dcmd_timeout_ocr_possible() argument
4522 if (instance->adapter_type == MFI_SERIES) in dcmd_timeout_ocr_possible()
4524 else if (instance->unload || in dcmd_timeout_ocr_possible()
4526 &instance->reset_flags)) in dcmd_timeout_ocr_possible()
4533 megasas_get_pd_info(struct megasas_instance *instance, struct scsi_device *sdev) in megasas_get_pd_info() argument
4543 cmd = megasas_get_cmd(instance); in megasas_get_pd_info()
4546 dev_err(&instance->pdev->dev, "Failed to get cmd %s\n", __func__); in megasas_get_pd_info()
4552 memset(instance->pd_info, 0, sizeof(*instance->pd_info)); in megasas_get_pd_info()
4565 megasas_set_dma_settings(instance, dcmd, instance->pd_info_h, in megasas_get_pd_info()
4568 if ((instance->adapter_type != MFI_SERIES) && in megasas_get_pd_info()
4569 !instance->mask_interrupts) in megasas_get_pd_info()
4570 ret = megasas_issue_blocked_cmd(instance, cmd, MFI_IO_TIMEOUT_SECS); in megasas_get_pd_info()
4572 ret = megasas_issue_polled(instance, cmd); in megasas_get_pd_info()
4577 le16_to_cpus((u16 *)&instance->pd_info->state.ddf.pdType); in megasas_get_pd_info()
4579 instance->pd_info->state.ddf.pdType.intf; in megasas_get_pd_info()
4584 switch (dcmd_timeout_ocr_possible(instance)) { in megasas_get_pd_info()
4587 mutex_unlock(&instance->reset_mutex); in megasas_get_pd_info()
4588 megasas_reset_fusion(instance->host, in megasas_get_pd_info()
4590 mutex_lock(&instance->reset_mutex); in megasas_get_pd_info()
4593 megaraid_sas_kill_hba(instance); in megasas_get_pd_info()
4596 dev_info(&instance->pdev->dev, "Ignore DCMD timeout: %s %d\n", in megasas_get_pd_info()
4605 megasas_return_cmd(instance, cmd); in megasas_get_pd_info()
4619 megasas_get_pd_list(struct megasas_instance *instance) in megasas_get_pd_list() argument
4627 if (instance->pd_list_not_supported) { in megasas_get_pd_list()
4628 dev_info(&instance->pdev->dev, "MR_DCMD_PD_LIST_QUERY " in megasas_get_pd_list()
4633 ci = instance->pd_list_buf; in megasas_get_pd_list()
4635 cmd = megasas_get_cmd(instance); in megasas_get_pd_list()
4638 dev_printk(KERN_DEBUG, &instance->pdev->dev, "(get_pd_list): Failed to get cmd\n"); in megasas_get_pd_list()
4658 megasas_set_dma_settings(instance, dcmd, instance->pd_list_buf_h, in megasas_get_pd_list()
4661 if ((instance->adapter_type != MFI_SERIES) && in megasas_get_pd_list()
4662 !instance->mask_interrupts) in megasas_get_pd_list()
4663 ret = megasas_issue_blocked_cmd(instance, cmd, in megasas_get_pd_list()
4666 ret = megasas_issue_polled(instance, cmd); in megasas_get_pd_list()
4670 dev_info(&instance->pdev->dev, "MR_DCMD_PD_LIST_QUERY " in megasas_get_pd_list()
4673 if (instance->adapter_type != MFI_SERIES) in megasas_get_pd_list()
4674 megaraid_sas_kill_hba(instance); in megasas_get_pd_list()
4676 instance->pd_list_not_supported = 1; in megasas_get_pd_list()
4680 switch (dcmd_timeout_ocr_possible(instance)) { in megasas_get_pd_list()
4688 mutex_unlock(&instance->reset_mutex); in megasas_get_pd_list()
4689 megasas_reset_fusion(instance->host, in megasas_get_pd_list()
4691 mutex_lock(&instance->reset_mutex); in megasas_get_pd_list()
4694 megaraid_sas_kill_hba(instance); in megasas_get_pd_list()
4697 dev_info(&instance->pdev->dev, "Ignore DCMD timeout: %s %d \n", in megasas_get_pd_list()
4707 dev_info(&instance->pdev->dev, "%s, sysPD count: 0x%x\n", in megasas_get_pd_list()
4714 memset(instance->local_pd_list, 0, in megasas_get_pd_list()
4718 instance->local_pd_list[le16_to_cpu(pd_addr->deviceId)].tid = in megasas_get_pd_list()
4720 instance->local_pd_list[le16_to_cpu(pd_addr->deviceId)].driveType = in megasas_get_pd_list()
4722 instance->local_pd_list[le16_to_cpu(pd_addr->deviceId)].driveState = in megasas_get_pd_list()
4725 dev_info(&instance->pdev->dev, in megasas_get_pd_list()
4732 memcpy(instance->pd_list, instance->local_pd_list, in megasas_get_pd_list()
4733 sizeof(instance->pd_list)); in megasas_get_pd_list()
4739 megasas_return_cmd(instance, cmd); in megasas_get_pd_list()
4754 megasas_get_ld_list(struct megasas_instance *instance) in megasas_get_ld_list() argument
4763 ci = instance->ld_list_buf; in megasas_get_ld_list()
4764 ci_h = instance->ld_list_buf_h; in megasas_get_ld_list()
4766 cmd = megasas_get_cmd(instance); in megasas_get_ld_list()
4769 dev_printk(KERN_DEBUG, &instance->pdev->dev, "megasas_get_ld_list: Failed to get cmd\n"); in megasas_get_ld_list()
4778 if (instance->supportmax256vd) in megasas_get_ld_list()
4789 megasas_set_dma_settings(instance, dcmd, ci_h, in megasas_get_ld_list()
4792 if ((instance->adapter_type != MFI_SERIES) && in megasas_get_ld_list()
4793 !instance->mask_interrupts) in megasas_get_ld_list()
4794 ret = megasas_issue_blocked_cmd(instance, cmd, in megasas_get_ld_list()
4797 ret = megasas_issue_polled(instance, cmd); in megasas_get_ld_list()
4803 megaraid_sas_kill_hba(instance); in megasas_get_ld_list()
4807 switch (dcmd_timeout_ocr_possible(instance)) { in megasas_get_ld_list()
4815 mutex_unlock(&instance->reset_mutex); in megasas_get_ld_list()
4816 megasas_reset_fusion(instance->host, in megasas_get_ld_list()
4818 mutex_lock(&instance->reset_mutex); in megasas_get_ld_list()
4821 megaraid_sas_kill_hba(instance); in megasas_get_ld_list()
4824 dev_info(&instance->pdev->dev, "Ignore DCMD timeout: %s %d\n", in megasas_get_ld_list()
4833 dev_info(&instance->pdev->dev, "%s, LD count: 0x%x\n", in megasas_get_ld_list()
4836 if (ld_count > instance->fw_supported_vd_count) in megasas_get_ld_list()
4839 memset(instance->ld_ids, 0xff, MAX_LOGICAL_DRIVES_EXT); in megasas_get_ld_list()
4844 instance->ld_ids[ids] = ci->ldList[ld_index].ref.targetId; in megasas_get_ld_list()
4846 dev_info(&instance->pdev->dev, in megasas_get_ld_list()
4856 megasas_return_cmd(instance, cmd); in megasas_get_ld_list()
4871 megasas_ld_list_query(struct megasas_instance *instance, u8 query_type) in megasas_ld_list_query() argument
4880 ci = instance->ld_targetid_list_buf; in megasas_ld_list_query()
4881 ci_h = instance->ld_targetid_list_buf_h; in megasas_ld_list_query()
4883 cmd = megasas_get_cmd(instance); in megasas_ld_list_query()
4886 dev_warn(&instance->pdev->dev, in megasas_ld_list_query()
4897 if (instance->supportmax256vd) in megasas_ld_list_query()
4909 megasas_set_dma_settings(instance, dcmd, ci_h, in megasas_ld_list_query()
4912 if ((instance->adapter_type != MFI_SERIES) && in megasas_ld_list_query()
4913 !instance->mask_interrupts) in megasas_ld_list_query()
4914 ret = megasas_issue_blocked_cmd(instance, cmd, MFI_IO_TIMEOUT_SECS); in megasas_ld_list_query()
4916 ret = megasas_issue_polled(instance, cmd); in megasas_ld_list_query()
4920 dev_info(&instance->pdev->dev, in megasas_ld_list_query()
4923 ret = megasas_get_ld_list(instance); in megasas_ld_list_query()
4926 switch (dcmd_timeout_ocr_possible(instance)) { in megasas_ld_list_query()
4934 mutex_unlock(&instance->reset_mutex); in megasas_ld_list_query()
4935 megasas_reset_fusion(instance->host, in megasas_ld_list_query()
4937 mutex_lock(&instance->reset_mutex); in megasas_ld_list_query()
4940 megaraid_sas_kill_hba(instance); in megasas_ld_list_query()
4943 dev_info(&instance->pdev->dev, "Ignore DCMD timeout: %s %d\n", in megasas_ld_list_query()
4953 dev_info(&instance->pdev->dev, "%s, LD count: 0x%x\n", in megasas_ld_list_query()
4956 if ((tgtid_count > (instance->fw_supported_vd_count))) in megasas_ld_list_query()
4959 memset(instance->ld_ids, 0xff, MEGASAS_MAX_LD_IDS); in megasas_ld_list_query()
4962 instance->ld_ids[ids] = ci->targetId[ld_index]; in megasas_ld_list_query()
4964 dev_info(&instance->pdev->dev, "LD%d: targetID: 0x%03x\n", in megasas_ld_list_query()
4972 megasas_return_cmd(instance, cmd); in megasas_ld_list_query()
4992 megasas_host_device_list_query(struct megasas_instance *instance, in megasas_host_device_list_query() argument
5002 ci = instance->host_device_list_buf; in megasas_host_device_list_query()
5003 ci_h = instance->host_device_list_buf_h; in megasas_host_device_list_query()
5005 cmd = megasas_get_cmd(instance); in megasas_host_device_list_query()
5008 dev_warn(&instance->pdev->dev, in megasas_host_device_list_query()
5029 megasas_set_dma_settings(instance, dcmd, ci_h, HOST_DEVICE_LIST_SZ); in megasas_host_device_list_query()
5031 if (!instance->mask_interrupts) { in megasas_host_device_list_query()
5032 ret = megasas_issue_blocked_cmd(instance, cmd, in megasas_host_device_list_query()
5035 ret = megasas_issue_polled(instance, cmd); in megasas_host_device_list_query()
5050 dev_info(&instance->pdev->dev, "%s, Device count: 0x%x\n", in megasas_host_device_list_query()
5053 memset(instance->local_pd_list, 0, in megasas_host_device_list_query()
5055 memset(instance->ld_ids, 0xff, MAX_LOGICAL_DRIVES_EXT); in megasas_host_device_list_query()
5059 instance->local_pd_list[target_id].tid = target_id; in megasas_host_device_list_query()
5060 instance->local_pd_list[target_id].driveType = in megasas_host_device_list_query()
5062 instance->local_pd_list[target_id].driveState = in megasas_host_device_list_query()
5065 dev_info(&instance->pdev->dev, in megasas_host_device_list_query()
5069 instance->ld_ids[target_id] = target_id; in megasas_host_device_list_query()
5071 dev_info(&instance->pdev->dev, in megasas_host_device_list_query()
5077 memcpy(instance->pd_list, instance->local_pd_list, in megasas_host_device_list_query()
5078 sizeof(instance->pd_list)); in megasas_host_device_list_query()
5082 switch (dcmd_timeout_ocr_possible(instance)) { in megasas_host_device_list_query()
5085 mutex_unlock(&instance->reset_mutex); in megasas_host_device_list_query()
5086 megasas_reset_fusion(instance->host, in megasas_host_device_list_query()
5088 mutex_lock(&instance->reset_mutex); in megasas_host_device_list_query()
5091 megaraid_sas_kill_hba(instance); in megasas_host_device_list_query()
5094 dev_info(&instance->pdev->dev, "Ignore DCMD timeout: %s %d\n", in megasas_host_device_list_query()
5100 dev_err(&instance->pdev->dev, in megasas_host_device_list_query()
5107 megasas_return_cmd(instance, cmd); in megasas_host_device_list_query()
5116 static void megasas_update_ext_vd_details(struct megasas_instance *instance) in megasas_update_ext_vd_details() argument
5121 fusion = instance->ctrl_context; in megasas_update_ext_vd_details()
5126 instance->supportmax256vd = in megasas_update_ext_vd_details()
5127 instance->ctrl_info_buf->adapterOperations3.supportMaxExtLDs; in megasas_update_ext_vd_details()
5129 if (instance->ctrl_info_buf->max_lds > 64) in megasas_update_ext_vd_details()
5130 instance->supportmax256vd = 1; in megasas_update_ext_vd_details()
5132 instance->drv_supported_vd_count = MEGASAS_MAX_LD_CHANNELS in megasas_update_ext_vd_details()
5134 instance->drv_supported_pd_count = MEGASAS_MAX_PD_CHANNELS in megasas_update_ext_vd_details()
5136 if (instance->supportmax256vd) { in megasas_update_ext_vd_details()
5137 instance->fw_supported_vd_count = MAX_LOGICAL_DRIVES_EXT; in megasas_update_ext_vd_details()
5138 instance->fw_supported_pd_count = MAX_PHYSICAL_DEVICES; in megasas_update_ext_vd_details()
5140 instance->fw_supported_vd_count = MAX_LOGICAL_DRIVES; in megasas_update_ext_vd_details()
5141 instance->fw_supported_pd_count = MAX_PHYSICAL_DEVICES; in megasas_update_ext_vd_details()
5144 dev_info(&instance->pdev->dev, in megasas_update_ext_vd_details()
5146 instance->ctrl_info_buf->adapterOperations3.supportMaxExtLDs ? 1 : 0, in megasas_update_ext_vd_details()
5147 instance->ctrl_info_buf->max_lds); in megasas_update_ext_vd_details()
5149 if (instance->max_raid_mapsize) { in megasas_update_ext_vd_details()
5150 ventura_map_sz = instance->max_raid_mapsize * in megasas_update_ext_vd_details()
5157 instance->fw_supported_vd_count); in megasas_update_ext_vd_details()
5163 if (instance->supportmax256vd) in megasas_update_ext_vd_details()
5179 void megasas_get_snapdump_properties(struct megasas_instance *instance) in megasas_get_snapdump_properties() argument
5187 ci = instance->snapdump_prop; in megasas_get_snapdump_properties()
5188 ci_h = instance->snapdump_prop_h; in megasas_get_snapdump_properties()
5193 cmd = megasas_get_cmd(instance); in megasas_get_snapdump_properties()
5196 dev_dbg(&instance->pdev->dev, "Failed to get a free cmd\n"); in megasas_get_snapdump_properties()
5214 megasas_set_dma_settings(instance, dcmd, ci_h, in megasas_get_snapdump_properties()
5217 if (!instance->mask_interrupts) { in megasas_get_snapdump_properties()
5218 ret = megasas_issue_blocked_cmd(instance, cmd, in megasas_get_snapdump_properties()
5221 ret = megasas_issue_polled(instance, cmd); in megasas_get_snapdump_properties()
5227 instance->snapdump_wait_time = in megasas_get_snapdump_properties()
5233 switch (dcmd_timeout_ocr_possible(instance)) { in megasas_get_snapdump_properties()
5236 mutex_unlock(&instance->reset_mutex); in megasas_get_snapdump_properties()
5237 megasas_reset_fusion(instance->host, in megasas_get_snapdump_properties()
5239 mutex_lock(&instance->reset_mutex); in megasas_get_snapdump_properties()
5242 megaraid_sas_kill_hba(instance); in megasas_get_snapdump_properties()
5245 dev_info(&instance->pdev->dev, "Ignore DCMD timeout: %s %d\n", in megasas_get_snapdump_properties()
5252 megasas_return_cmd(instance, cmd); in megasas_get_snapdump_properties()
5264 megasas_get_ctrl_info(struct megasas_instance *instance) in megasas_get_ctrl_info() argument
5272 ci = instance->ctrl_info_buf; in megasas_get_ctrl_info()
5273 ci_h = instance->ctrl_info_buf_h; in megasas_get_ctrl_info()
5275 cmd = megasas_get_cmd(instance); in megasas_get_ctrl_info()
5278 dev_printk(KERN_DEBUG, &instance->pdev->dev, "Failed to get a free cmd\n"); in megasas_get_ctrl_info()
5297 megasas_set_dma_settings(instance, dcmd, ci_h, in megasas_get_ctrl_info()
5300 if ((instance->adapter_type != MFI_SERIES) && in megasas_get_ctrl_info()
5301 !instance->mask_interrupts) { in megasas_get_ctrl_info()
5302 ret = megasas_issue_blocked_cmd(instance, cmd, MFI_IO_TIMEOUT_SECS); in megasas_get_ctrl_info()
5304 ret = megasas_issue_polled(instance, cmd); in megasas_get_ctrl_info()
5325 megasas_update_ext_vd_details(instance); in megasas_get_ctrl_info()
5326 instance->support_seqnum_jbod_fp = in megasas_get_ctrl_info()
5328 instance->support_morethan256jbod = in megasas_get_ctrl_info()
5330 instance->support_nvme_passthru = in megasas_get_ctrl_info()
5332 instance->support_pci_lane_margining = in megasas_get_ctrl_info()
5334 instance->task_abort_tmo = ci->TaskAbortTO; in megasas_get_ctrl_info()
5335 instance->max_reset_tmo = ci->MaxResetTO; in megasas_get_ctrl_info()
5338 instance->is_imr = (ci->memory_size ? 0 : 1); in megasas_get_ctrl_info()
5340 instance->snapdump_wait_time = in megasas_get_ctrl_info()
5344 instance->enable_fw_dev_list = in megasas_get_ctrl_info()
5347 dev_info(&instance->pdev->dev, in megasas_get_ctrl_info()
5349 instance->is_imr ? "iMR" : "MR", in megasas_get_ctrl_info()
5352 instance->disableOnlineCtrlReset = in megasas_get_ctrl_info()
5354 instance->secure_jbod_support = in megasas_get_ctrl_info()
5356 dev_info(&instance->pdev->dev, "Online Controller Reset(OCR)\t: %s\n", in megasas_get_ctrl_info()
5357 instance->disableOnlineCtrlReset ? "Disabled" : "Enabled"); in megasas_get_ctrl_info()
5358 dev_info(&instance->pdev->dev, "Secure JBOD support\t: %s\n", in megasas_get_ctrl_info()
5359 instance->secure_jbod_support ? "Yes" : "No"); in megasas_get_ctrl_info()
5360 dev_info(&instance->pdev->dev, "NVMe passthru support\t: %s\n", in megasas_get_ctrl_info()
5361 instance->support_nvme_passthru ? "Yes" : "No"); in megasas_get_ctrl_info()
5362 dev_info(&instance->pdev->dev, in megasas_get_ctrl_info()
5364 instance->task_abort_tmo, instance->max_reset_tmo); in megasas_get_ctrl_info()
5365 dev_info(&instance->pdev->dev, "JBOD sequence map support\t: %s\n", in megasas_get_ctrl_info()
5366 instance->support_seqnum_jbod_fp ? "Yes" : "No"); in megasas_get_ctrl_info()
5367 dev_info(&instance->pdev->dev, "PCI Lane Margining support\t: %s\n", in megasas_get_ctrl_info()
5368 instance->support_pci_lane_margining ? "Yes" : "No"); in megasas_get_ctrl_info()
5373 switch (dcmd_timeout_ocr_possible(instance)) { in megasas_get_ctrl_info()
5376 mutex_unlock(&instance->reset_mutex); in megasas_get_ctrl_info()
5377 megasas_reset_fusion(instance->host, in megasas_get_ctrl_info()
5379 mutex_lock(&instance->reset_mutex); in megasas_get_ctrl_info()
5382 megaraid_sas_kill_hba(instance); in megasas_get_ctrl_info()
5385 dev_info(&instance->pdev->dev, "Ignore DCMD timeout: %s %d\n", in megasas_get_ctrl_info()
5391 megaraid_sas_kill_hba(instance); in megasas_get_ctrl_info()
5397 megasas_return_cmd(instance, cmd); in megasas_get_ctrl_info()
5417 int megasas_set_crash_dump_params(struct megasas_instance *instance, in megasas_set_crash_dump_params() argument
5424 cmd = megasas_get_cmd(instance); in megasas_set_crash_dump_params()
5427 dev_err(&instance->pdev->dev, "Failed to get a free cmd\n"); in megasas_set_crash_dump_params()
5445 megasas_set_dma_settings(instance, dcmd, instance->crash_dump_h, in megasas_set_crash_dump_params()
5448 if ((instance->adapter_type != MFI_SERIES) && in megasas_set_crash_dump_params()
5449 !instance->mask_interrupts) in megasas_set_crash_dump_params()
5450 ret = megasas_issue_blocked_cmd(instance, cmd, MFI_IO_TIMEOUT_SECS); in megasas_set_crash_dump_params()
5452 ret = megasas_issue_polled(instance, cmd); in megasas_set_crash_dump_params()
5455 switch (dcmd_timeout_ocr_possible(instance)) { in megasas_set_crash_dump_params()
5458 megasas_reset_fusion(instance->host, in megasas_set_crash_dump_params()
5462 megaraid_sas_kill_hba(instance); in megasas_set_crash_dump_params()
5465 dev_info(&instance->pdev->dev, "Ignore DCMD timeout: %s %d\n", in megasas_set_crash_dump_params()
5470 megasas_return_cmd(instance, cmd); in megasas_set_crash_dump_params()
5482 megasas_issue_init_mfi(struct megasas_instance *instance) in megasas_issue_init_mfi() argument
5499 cmd = megasas_get_cmd(instance); in megasas_issue_init_mfi()
5513 initq_info->reply_queue_entries = cpu_to_le32(instance->max_fw_cmds + 1); in megasas_issue_init_mfi()
5514 initq_info->reply_queue_start_phys_addr_lo = cpu_to_le32(instance->reply_queue_h); in megasas_issue_init_mfi()
5516 initq_info->producer_index_phys_addr_lo = cpu_to_le32(instance->producer_h); in megasas_issue_init_mfi()
5517 initq_info->consumer_index_phys_addr_lo = cpu_to_le32(instance->consumer_h); in megasas_issue_init_mfi()
5531 instance->instancet->disable_intr(instance); in megasas_issue_init_mfi()
5537 if (megasas_issue_polled(instance, cmd)) { in megasas_issue_init_mfi()
5538 dev_err(&instance->pdev->dev, "Failed to init firmware\n"); in megasas_issue_init_mfi()
5539 megasas_return_cmd(instance, cmd); in megasas_issue_init_mfi()
5543 megasas_return_cmd(instance, cmd); in megasas_issue_init_mfi()
5552 megasas_init_adapter_mfi(struct megasas_instance *instance) in megasas_init_adapter_mfi() argument
5560 instance->max_fw_cmds = instance->instancet->read_fw_status_reg(instance) & 0x00FFFF; in megasas_init_adapter_mfi()
5566 instance->max_fw_cmds = instance->max_fw_cmds-1; in megasas_init_adapter_mfi()
5567 instance->max_mfi_cmds = instance->max_fw_cmds; in megasas_init_adapter_mfi()
5568 instance->max_num_sge = (instance->instancet->read_fw_status_reg(instance) & 0xFF0000) >> in megasas_init_adapter_mfi()
5574 if ((instance->pdev->device == PCI_DEVICE_ID_LSI_SAS0073SKINNY) || in megasas_init_adapter_mfi()
5575 (instance->pdev->device == PCI_DEVICE_ID_LSI_SAS0071SKINNY)) { in megasas_init_adapter_mfi()
5576 instance->max_scsi_cmds = (instance->max_fw_cmds - in megasas_init_adapter_mfi()
5578 sema_init(&instance->ioctl_sem, MEGASAS_SKINNY_INT_CMDS); in megasas_init_adapter_mfi()
5580 instance->max_scsi_cmds = (instance->max_fw_cmds - in megasas_init_adapter_mfi()
5582 sema_init(&instance->ioctl_sem, (MEGASAS_MFI_IOCTL_CMDS)); in megasas_init_adapter_mfi()
5585 instance->cur_can_queue = instance->max_scsi_cmds; in megasas_init_adapter_mfi()
5589 if (megasas_alloc_cmds(instance)) in megasas_init_adapter_mfi()
5602 reply_q_sz = context_sz * (instance->max_fw_cmds + 1); in megasas_init_adapter_mfi()
5604 instance->reply_queue = dma_alloc_coherent(&instance->pdev->dev, in megasas_init_adapter_mfi()
5605 reply_q_sz, &instance->reply_queue_h, GFP_KERNEL); in megasas_init_adapter_mfi()
5607 if (!instance->reply_queue) { in megasas_init_adapter_mfi()
5608 dev_printk(KERN_DEBUG, &instance->pdev->dev, "Out of DMA mem for reply queue\n"); in megasas_init_adapter_mfi()
5612 if (megasas_issue_init_mfi(instance)) in megasas_init_adapter_mfi()
5615 if (megasas_get_ctrl_info(instance)) { in megasas_init_adapter_mfi()
5616 dev_err(&instance->pdev->dev, "(%d): Could get controller info " in megasas_init_adapter_mfi()
5617 "Fail from %s %d\n", instance->unique_id, in megasas_init_adapter_mfi()
5622 instance->fw_support_ieee = 0; in megasas_init_adapter_mfi()
5623 instance->fw_support_ieee = in megasas_init_adapter_mfi()
5624 (instance->instancet->read_fw_status_reg(instance) & in megasas_init_adapter_mfi()
5627 dev_notice(&instance->pdev->dev, "megasas_init_mfi: fw_support_ieee=%d", in megasas_init_adapter_mfi()
5628 instance->fw_support_ieee); in megasas_init_adapter_mfi()
5630 if (instance->fw_support_ieee) in megasas_init_adapter_mfi()
5631 instance->flag_ieee = 1; in megasas_init_adapter_mfi()
5637 dma_free_coherent(&instance->pdev->dev, reply_q_sz, in megasas_init_adapter_mfi()
5638 instance->reply_queue, instance->reply_queue_h); in megasas_init_adapter_mfi()
5640 megasas_free_cmds(instance); in megasas_init_adapter_mfi()
5647 void megasas_setup_irq_poll(struct megasas_instance *instance) in megasas_setup_irq_poll() argument
5652 count = instance->msix_vectors > 0 ? instance->msix_vectors : 1; in megasas_setup_irq_poll()
5656 irq_ctx = &instance->irq_context[i]; in megasas_setup_irq_poll()
5657 irq_ctx->os_irq = pci_irq_vector(instance->pdev, i); in megasas_setup_irq_poll()
5660 instance->threshold_reply_count, in megasas_setup_irq_poll()
5674 megasas_setup_irqs_ioapic(struct megasas_instance *instance) in megasas_setup_irqs_ioapic() argument
5678 pdev = instance->pdev; in megasas_setup_irqs_ioapic()
5679 instance->irq_context[0].instance = instance; in megasas_setup_irqs_ioapic()
5680 instance->irq_context[0].MSIxIndex = 0; in megasas_setup_irqs_ioapic()
5681 snprintf(instance->irq_context->name, MEGASAS_MSIX_NAME_LEN, "%s%u", in megasas_setup_irqs_ioapic()
5682 "megasas", instance->host->host_no); in megasas_setup_irqs_ioapic()
5684 instance->instancet->service_isr, IRQF_SHARED, in megasas_setup_irqs_ioapic()
5685 instance->irq_context->name, &instance->irq_context[0])) { in megasas_setup_irqs_ioapic()
5686 dev_err(&instance->pdev->dev, in megasas_setup_irqs_ioapic()
5691 instance->perf_mode = MR_LATENCY_PERF_MODE; in megasas_setup_irqs_ioapic()
5692 instance->low_latency_index_start = 0; in megasas_setup_irqs_ioapic()
5706 megasas_setup_irqs_msix(struct megasas_instance *instance, u8 is_probe) in megasas_setup_irqs_msix() argument
5711 pdev = instance->pdev; in megasas_setup_irqs_msix()
5714 for (i = 0; i < instance->msix_vectors; i++) { in megasas_setup_irqs_msix()
5715 instance->irq_context[i].instance = instance; in megasas_setup_irqs_msix()
5716 instance->irq_context[i].MSIxIndex = i; in megasas_setup_irqs_msix()
5717 snprintf(instance->irq_context[i].name, MEGASAS_MSIX_NAME_LEN, "%s%u-msix%u", in megasas_setup_irqs_msix()
5718 "megasas", instance->host->host_no, i); in megasas_setup_irqs_msix()
5720 instance->instancet->service_isr, 0, instance->irq_context[i].name, in megasas_setup_irqs_msix()
5721 &instance->irq_context[i])) { in megasas_setup_irqs_msix()
5722 dev_err(&instance->pdev->dev, in megasas_setup_irqs_msix()
5725 if (j < instance->low_latency_index_start) in megasas_setup_irqs_msix()
5729 &instance->irq_context[j]); in megasas_setup_irqs_msix()
5732 instance->msix_vectors = 0; in megasas_setup_irqs_msix()
5733 instance->msix_load_balance = false; in megasas_setup_irqs_msix()
5735 pci_free_irq_vectors(instance->pdev); in megasas_setup_irqs_msix()
5736 return megasas_setup_irqs_ioapic(instance); in megasas_setup_irqs_msix()
5752 megasas_destroy_irqs(struct megasas_instance *instance) { in megasas_destroy_irqs() argument
5758 count = instance->msix_vectors > 0 ? instance->msix_vectors : 1; in megasas_destroy_irqs()
5759 if (instance->adapter_type != MFI_SERIES) { in megasas_destroy_irqs()
5761 irq_ctx = &instance->irq_context[i]; in megasas_destroy_irqs()
5766 if (instance->msix_vectors) in megasas_destroy_irqs()
5767 for (i = 0; i < instance->msix_vectors; i++) { in megasas_destroy_irqs()
5768 if (i < instance->low_latency_index_start) in megasas_destroy_irqs()
5770 pci_irq_vector(instance->pdev, i), NULL); in megasas_destroy_irqs()
5771 free_irq(pci_irq_vector(instance->pdev, i), in megasas_destroy_irqs()
5772 &instance->irq_context[i]); in megasas_destroy_irqs()
5775 free_irq(pci_irq_vector(instance->pdev, 0), in megasas_destroy_irqs()
5776 &instance->irq_context[0]); in megasas_destroy_irqs()
5786 megasas_setup_jbod_map(struct megasas_instance *instance) in megasas_setup_jbod_map() argument
5789 struct fusion_context *fusion = instance->ctrl_context; in megasas_setup_jbod_map()
5795 instance->use_seqnum_jbod_fp = in megasas_setup_jbod_map()
5796 instance->support_seqnum_jbod_fp; in megasas_setup_jbod_map()
5798 !instance->support_seqnum_jbod_fp) { in megasas_setup_jbod_map()
5799 dev_info(&instance->pdev->dev, in megasas_setup_jbod_map()
5802 instance->use_seqnum_jbod_fp = false; in megasas_setup_jbod_map()
5811 (&instance->pdev->dev, pd_seq_map_sz, in megasas_setup_jbod_map()
5814 dev_err(&instance->pdev->dev, in megasas_setup_jbod_map()
5818 dma_free_coherent(&instance->pdev->dev, in megasas_setup_jbod_map()
5823 instance->use_seqnum_jbod_fp = false; in megasas_setup_jbod_map()
5829 if (!megasas_sync_pd_seq_num(instance, false) && in megasas_setup_jbod_map()
5830 !megasas_sync_pd_seq_num(instance, true)) in megasas_setup_jbod_map()
5831 instance->use_seqnum_jbod_fp = true; in megasas_setup_jbod_map()
5833 instance->use_seqnum_jbod_fp = false; in megasas_setup_jbod_map()
5836 static void megasas_setup_reply_map(struct megasas_instance *instance) in megasas_setup_reply_map() argument
5841 low_latency_index_start = instance->low_latency_index_start; in megasas_setup_reply_map()
5843 for (queue = low_latency_index_start; queue < instance->msix_vectors; queue++) { in megasas_setup_reply_map()
5844 mask = pci_irq_get_affinity(instance->pdev, queue); in megasas_setup_reply_map()
5849 instance->reply_map[cpu] = queue; in megasas_setup_reply_map()
5856 instance->reply_map[cpu] = queue; in megasas_setup_reply_map()
5857 if (queue == (instance->msix_vectors - 1)) in megasas_setup_reply_map()
5874 int megasas_get_device_list(struct megasas_instance *instance) in megasas_get_device_list() argument
5876 if (instance->enable_fw_dev_list) { in megasas_get_device_list()
5877 if (megasas_host_device_list_query(instance, true)) in megasas_get_device_list()
5880 if (megasas_get_pd_list(instance) < 0) { in megasas_get_device_list()
5881 dev_err(&instance->pdev->dev, "failed to get PD list\n"); in megasas_get_device_list()
5885 if (megasas_ld_list_query(instance, in megasas_get_device_list()
5887 dev_err(&instance->pdev->dev, "failed to get LD list\n"); in megasas_get_device_list()
5902 megasas_set_high_iops_queue_affinity_and_hint(struct megasas_instance *instance) in megasas_set_high_iops_queue_affinity_and_hint() argument
5908 if (instance->perf_mode == MR_BALANCED_PERF_MODE) { in megasas_set_high_iops_queue_affinity_and_hint()
5909 mask = cpumask_of_node(dev_to_node(&instance->pdev->dev)); in megasas_set_high_iops_queue_affinity_and_hint()
5911 for (i = 0; i < instance->low_latency_index_start; i++) { in megasas_set_high_iops_queue_affinity_and_hint()
5912 irq = pci_irq_vector(instance->pdev, i); in megasas_set_high_iops_queue_affinity_and_hint()
5919 __megasas_alloc_irq_vectors(struct megasas_instance *instance) in __megasas_alloc_irq_vectors() argument
5922 struct irq_affinity desc = { .pre_vectors = instance->low_latency_index_start }; in __megasas_alloc_irq_vectors()
5927 if (instance->smp_affinity_enable) in __megasas_alloc_irq_vectors()
5935 i = pci_alloc_irq_vectors_affinity(instance->pdev, in __megasas_alloc_irq_vectors()
5936 instance->low_latency_index_start, in __megasas_alloc_irq_vectors()
5937 instance->msix_vectors - instance->iopoll_q_count, irq_flags, descp); in __megasas_alloc_irq_vectors()
5948 megasas_alloc_irq_vectors(struct megasas_instance *instance) in megasas_alloc_irq_vectors() argument
5953 instance->iopoll_q_count = 0; in megasas_alloc_irq_vectors()
5954 if ((instance->adapter_type != MFI_SERIES) && in megasas_alloc_irq_vectors()
5957 instance->perf_mode = MR_LATENCY_PERF_MODE; in megasas_alloc_irq_vectors()
5958 instance->low_latency_index_start = 1; in megasas_alloc_irq_vectors()
5961 if (instance->msix_vectors > (poll_queues + 2)) in megasas_alloc_irq_vectors()
5962 instance->iopoll_q_count = poll_queues; in megasas_alloc_irq_vectors()
5964 instance->iopoll_q_count = 0; in megasas_alloc_irq_vectors()
5966 num_msix_req = num_online_cpus() + instance->low_latency_index_start; in megasas_alloc_irq_vectors()
5967 instance->msix_vectors = min(num_msix_req, in megasas_alloc_irq_vectors()
5968 instance->msix_vectors); in megasas_alloc_irq_vectors()
5972 i = __megasas_alloc_irq_vectors(instance); in megasas_alloc_irq_vectors()
5974 if (((instance->perf_mode == MR_BALANCED_PERF_MODE) in megasas_alloc_irq_vectors()
5975 || instance->iopoll_q_count) && in megasas_alloc_irq_vectors()
5976 (i != (instance->msix_vectors - instance->iopoll_q_count))) { in megasas_alloc_irq_vectors()
5977 if (instance->msix_vectors) in megasas_alloc_irq_vectors()
5978 pci_free_irq_vectors(instance->pdev); in megasas_alloc_irq_vectors()
5980 instance->perf_mode = MR_LATENCY_PERF_MODE; in megasas_alloc_irq_vectors()
5981 instance->low_latency_index_start = 1; in megasas_alloc_irq_vectors()
5982 num_msix_req = num_online_cpus() + instance->low_latency_index_start; in megasas_alloc_irq_vectors()
5984 instance->msix_vectors = min(num_msix_req, in megasas_alloc_irq_vectors()
5985 instance->msix_vectors); in megasas_alloc_irq_vectors()
5987 instance->iopoll_q_count = 0; in megasas_alloc_irq_vectors()
5988 i = __megasas_alloc_irq_vectors(instance); in megasas_alloc_irq_vectors()
5992 dev_info(&instance->pdev->dev, in megasas_alloc_irq_vectors()
5994 instance->msix_vectors - instance->iopoll_q_count, in megasas_alloc_irq_vectors()
5995 i, instance->iopoll_q_count); in megasas_alloc_irq_vectors()
5998 instance->msix_vectors = i; in megasas_alloc_irq_vectors()
6000 instance->msix_vectors = 0; in megasas_alloc_irq_vectors()
6002 if (instance->smp_affinity_enable) in megasas_alloc_irq_vectors()
6003 megasas_set_high_iops_queue_affinity_and_hint(instance); in megasas_alloc_irq_vectors()
6013 static int megasas_init_fw(struct megasas_instance *instance) in megasas_init_fw() argument
6029 fusion = instance->ctrl_context; in megasas_init_fw()
6032 bar_list = pci_select_bars(instance->pdev, IORESOURCE_MEM); in megasas_init_fw()
6033 instance->bar = find_first_bit(&bar_list, BITS_PER_LONG); in megasas_init_fw()
6034 if (pci_request_selected_regions(instance->pdev, 1<<instance->bar, in megasas_init_fw()
6036 dev_printk(KERN_DEBUG, &instance->pdev->dev, "IO memory region busy!\n"); in megasas_init_fw()
6040 base_addr = pci_resource_start(instance->pdev, instance->bar); in megasas_init_fw()
6041 instance->reg_set = ioremap(base_addr, 8192); in megasas_init_fw()
6043 if (!instance->reg_set) { in megasas_init_fw()
6044 dev_printk(KERN_DEBUG, &instance->pdev->dev, "Failed to map IO mem\n"); in megasas_init_fw()
6049 dev_printk(KERN_DEBUG, &instance->pdev->dev, in megasas_init_fw()
6051 instance->bar, base_addr_phys, instance->reg_set); in megasas_init_fw()
6053 if (instance->adapter_type != MFI_SERIES) in megasas_init_fw()
6054 instance->instancet = &megasas_instance_template_fusion; in megasas_init_fw()
6056 switch (instance->pdev->device) { in megasas_init_fw()
6059 instance->instancet = &megasas_instance_template_ppc; in megasas_init_fw()
6063 instance->instancet = &megasas_instance_template_gen2; in megasas_init_fw()
6067 instance->instancet = &megasas_instance_template_skinny; in megasas_init_fw()
6072 instance->instancet = &megasas_instance_template_xscale; in megasas_init_fw()
6073 instance->pd_list_not_supported = 1; in megasas_init_fw()
6078 if (megasas_transition_to_ready(instance, 0)) { in megasas_init_fw()
6079 dev_info(&instance->pdev->dev, in megasas_init_fw()
6082 if (instance->adapter_type != MFI_SERIES) { in megasas_init_fw()
6083 status_reg = instance->instancet->read_fw_status_reg( in megasas_init_fw()
6084 instance); in megasas_init_fw()
6087 (instance, true, 0) == FAILED) in megasas_init_fw()
6093 atomic_set(&instance->fw_reset_no_pci_access, 1); in megasas_init_fw()
6094 instance->instancet->adp_reset in megasas_init_fw()
6095 (instance, instance->reg_set); in megasas_init_fw()
6096 atomic_set(&instance->fw_reset_no_pci_access, 0); in megasas_init_fw()
6101 if (megasas_transition_to_ready(instance, 0)) in megasas_init_fw()
6105 dev_info(&instance->pdev->dev, in megasas_init_fw()
6110 megasas_init_ctrl_params(instance); in megasas_init_fw()
6112 if (megasas_set_dma_mask(instance)) in megasas_init_fw()
6115 if (megasas_alloc_ctrl_mem(instance)) in megasas_init_fw()
6118 if (megasas_alloc_ctrl_dma_buffers(instance)) in megasas_init_fw()
6121 fusion = instance->ctrl_context; in megasas_init_fw()
6123 if (instance->adapter_type >= VENTURA_SERIES) { in megasas_init_fw()
6125 megasas_readl(instance, in megasas_init_fw()
6126 &instance->reg_set->outbound_scratch_pad_2); in megasas_init_fw()
6127 instance->max_raid_mapsize = ((scratch_pad_2 >> in megasas_init_fw()
6132 instance->enable_sdev_max_qd = enable_sdev_max_qd; in megasas_init_fw()
6134 switch (instance->adapter_type) { in megasas_init_fw()
6146 msix_enable = (instance->instancet->read_fw_status_reg(instance) & in megasas_init_fw()
6151 (instance, &instance->reg_set->outbound_scratch_pad_1); in megasas_init_fw()
6154 if (instance->adapter_type == THUNDERBOLT_SERIES) { in megasas_init_fw()
6156 instance->msix_vectors = (scratch_pad_1 in megasas_init_fw()
6159 instance->msix_vectors = ((scratch_pad_1 in megasas_init_fw()
6171 switch (instance->adapter_type) { in megasas_init_fw()
6173 if (instance->msix_vectors > 8) in megasas_init_fw()
6174 instance->msix_combined = true; in megasas_init_fw()
6178 if (instance->msix_vectors > 16) in megasas_init_fw()
6179 instance->msix_combined = true; in megasas_init_fw()
6184 instance->is_rdpq = (scratch_pad_1 & MR_RDPQ_MODE_OFFSET) ? in megasas_init_fw()
6187 if (instance->adapter_type >= INVADER_SERIES && in megasas_init_fw()
6188 !instance->msix_combined) { in megasas_init_fw()
6189 instance->msix_load_balance = true; in megasas_init_fw()
6190 instance->smp_affinity_enable = false; in megasas_init_fw()
6198 instance->reply_post_host_index_addr[loop] = in megasas_init_fw()
6200 ((u8 __iomem *)instance->reg_set + in megasas_init_fw()
6206 dev_info(&instance->pdev->dev, in megasas_init_fw()
6208 instance->msix_vectors); in megasas_init_fw()
6210 instance->msix_vectors = min(msix_vectors, in megasas_init_fw()
6211 instance->msix_vectors); in megasas_init_fw()
6213 instance->msix_vectors = 1; in megasas_init_fw()
6239 (instance->msix_vectors == MEGASAS_MAX_MSIX_QUEUES)) in megasas_init_fw()
6240 instance->perf_mode = MR_BALANCED_PERF_MODE; in megasas_init_fw()
6242 instance->perf_mode = MR_LATENCY_PERF_MODE; in megasas_init_fw()
6245 if (instance->adapter_type == AERO_SERIES) { in megasas_init_fw()
6246 pcie_capability_read_word(instance->pdev, PCI_EXP_LNKSTA, &lnksta); in megasas_init_fw()
6254 instance->perf_mode = MR_LATENCY_PERF_MODE; in megasas_init_fw()
6266 instance->perf_mode = perf_mode; in megasas_init_fw()
6272 instance->perf_mode = MR_LATENCY_PERF_MODE; in megasas_init_fw()
6276 if (instance->perf_mode == MR_BALANCED_PERF_MODE) in megasas_init_fw()
6277 instance->low_latency_index_start = in megasas_init_fw()
6280 instance->low_latency_index_start = 1; in megasas_init_fw()
6282 num_msix_req = num_online_cpus() + instance->low_latency_index_start; in megasas_init_fw()
6284 instance->msix_vectors = min(num_msix_req, in megasas_init_fw()
6285 instance->msix_vectors); in megasas_init_fw()
6287 megasas_alloc_irq_vectors(instance); in megasas_init_fw()
6288 if (!instance->msix_vectors) in megasas_init_fw()
6289 instance->msix_load_balance = false; in megasas_init_fw()
6295 if (instance->msix_combined) { in megasas_init_fw()
6296 instance->reply_post_host_index_addr[0] = in megasas_init_fw()
6297 (u32 *)((u8 *)instance->reg_set + in megasas_init_fw()
6300 instance->reply_post_host_index_addr[0] = in megasas_init_fw()
6301 (u32 *)((u8 *)instance->reg_set + in megasas_init_fw()
6305 if (!instance->msix_vectors) { in megasas_init_fw()
6306 i = pci_alloc_irq_vectors(instance->pdev, 1, 1, PCI_IRQ_INTX); in megasas_init_fw()
6311 megasas_setup_reply_map(instance); in megasas_init_fw()
6313 dev_info(&instance->pdev->dev, in megasas_init_fw()
6315 instance->msix_vectors, (unsigned int)num_online_cpus()); in megasas_init_fw()
6316 dev_info(&instance->pdev->dev, in megasas_init_fw()
6317 "RDPQ mode\t: (%s)\n", instance->is_rdpq ? "enabled" : "disabled"); in megasas_init_fw()
6319 tasklet_init(&instance->isr_tasklet, instance->instancet->tasklet, in megasas_init_fw()
6320 (unsigned long)instance); in megasas_init_fw()
6326 instance->fw_supported_vd_count = MAX_LOGICAL_DRIVES; in megasas_init_fw()
6327 instance->fw_supported_pd_count = MAX_PHYSICAL_DEVICES; in megasas_init_fw()
6329 if (instance->instancet->init_adapter(instance)) in megasas_init_fw()
6332 if (instance->adapter_type >= VENTURA_SERIES) { in megasas_init_fw()
6334 megasas_readl(instance, in megasas_init_fw()
6335 &instance->reg_set->outbound_scratch_pad_3); in megasas_init_fw()
6338 instance->nvme_page_size = in megasas_init_fw()
6341 dev_info(&instance->pdev->dev, in megasas_init_fw()
6342 "NVME page size\t: (%d)\n", instance->nvme_page_size); in megasas_init_fw()
6345 if (instance->msix_vectors ? in megasas_init_fw()
6346 megasas_setup_irqs_msix(instance, 1) : in megasas_init_fw()
6347 megasas_setup_irqs_ioapic(instance)) in megasas_init_fw()
6350 if (instance->adapter_type != MFI_SERIES) in megasas_init_fw()
6351 megasas_setup_irq_poll(instance); in megasas_init_fw()
6353 instance->instancet->enable_intr(instance); in megasas_init_fw()
6355 dev_info(&instance->pdev->dev, "INIT adapter done\n"); in megasas_init_fw()
6357 megasas_setup_jbod_map(instance); in megasas_init_fw()
6359 if (megasas_get_device_list(instance) != SUCCESS) { in megasas_init_fw()
6360 dev_err(&instance->pdev->dev, in megasas_init_fw()
6367 if (instance->adapter_type >= VENTURA_SERIES) { in megasas_init_fw()
6373 dev_err(&instance->pdev->dev, in megasas_init_fw()
6382 dev_err(&instance->pdev->dev, in megasas_init_fw()
6405 ctrl_info = instance->ctrl_info_buf; in megasas_init_fw()
6413 instance->peerIsPresent = ctrl_info->cluster.peerIsPresent; in megasas_init_fw()
6414 instance->passive = ctrl_info->cluster.passive; in megasas_init_fw()
6415 memcpy(instance->clusterId, ctrl_info->clusterId, sizeof(instance->clusterId)); in megasas_init_fw()
6416 instance->UnevenSpanSupport = in megasas_init_fw()
6418 if (instance->UnevenSpanSupport) { in megasas_init_fw()
6419 struct fusion_context *fusion = instance->ctrl_context; in megasas_init_fw()
6420 if (MR_ValidateMapInfo(instance, instance->map_id)) in megasas_init_fw()
6427 instance->requestorId = ctrl_info->iov.requestorId; in megasas_init_fw()
6428 if (instance->pdev->device == PCI_DEVICE_ID_LSI_PLASMA) { in megasas_init_fw()
6430 instance->PlasmaFW111 = 1; in megasas_init_fw()
6432 dev_info(&instance->pdev->dev, "SR-IOV: firmware type: %s\n", in megasas_init_fw()
6433 instance->PlasmaFW111 ? "1.11" : "new"); in megasas_init_fw()
6435 if (instance->PlasmaFW111) { in megasas_init_fw()
6438 instance->requestorId = iovPtr->requestorId; in megasas_init_fw()
6441 dev_info(&instance->pdev->dev, "SRIOV: VF requestorId %d\n", in megasas_init_fw()
6442 instance->requestorId); in megasas_init_fw()
6445 instance->crash_dump_fw_support = in megasas_init_fw()
6447 instance->crash_dump_drv_support = in megasas_init_fw()
6448 (instance->crash_dump_fw_support && in megasas_init_fw()
6449 instance->crash_dump_buf); in megasas_init_fw()
6450 if (instance->crash_dump_drv_support) in megasas_init_fw()
6451 megasas_set_crash_dump_params(instance, in megasas_init_fw()
6455 if (instance->crash_dump_buf) in megasas_init_fw()
6456 dma_free_coherent(&instance->pdev->dev, in megasas_init_fw()
6458 instance->crash_dump_buf, in megasas_init_fw()
6459 instance->crash_dump_h); in megasas_init_fw()
6460 instance->crash_dump_buf = NULL; in megasas_init_fw()
6463 if (instance->snapdump_wait_time) { in megasas_init_fw()
6464 megasas_get_snapdump_properties(instance); in megasas_init_fw()
6465 dev_info(&instance->pdev->dev, "Snap dump wait time\t: %d\n", in megasas_init_fw()
6466 instance->snapdump_wait_time); in megasas_init_fw()
6469 dev_info(&instance->pdev->dev, in megasas_init_fw()
6475 dev_info(&instance->pdev->dev, "unevenspan support : %s\n", in megasas_init_fw()
6476 instance->UnevenSpanSupport ? "yes" : "no"); in megasas_init_fw()
6477 dev_info(&instance->pdev->dev, "firmware crash dump : %s\n", in megasas_init_fw()
6478 instance->crash_dump_drv_support ? "yes" : "no"); in megasas_init_fw()
6479 dev_info(&instance->pdev->dev, "JBOD sequence map : %s\n", in megasas_init_fw()
6480 instance->use_seqnum_jbod_fp ? "enabled" : "disabled"); in megasas_init_fw()
6482 instance->max_sectors_per_req = instance->max_num_sge * in megasas_init_fw()
6484 if (tmp_sectors && (instance->max_sectors_per_req > tmp_sectors)) in megasas_init_fw()
6485 instance->max_sectors_per_req = tmp_sectors; in megasas_init_fw()
6489 throttlequeuedepth <= instance->max_scsi_cmds) in megasas_init_fw()
6490 instance->throttlequeuedepth = throttlequeuedepth; in megasas_init_fw()
6492 instance->throttlequeuedepth = in megasas_init_fw()
6503 if (instance->requestorId) { in megasas_init_fw()
6504 if (!megasas_sriov_start_heartbeat(instance, 1)) { in megasas_init_fw()
6505 megasas_start_timer(instance); in megasas_init_fw()
6507 instance->skip_heartbeat_timer_del = 1; in megasas_init_fw()
6517 if (instance->adapter_type != MFI_SERIES) in megasas_init_fw()
6518 if (megasas_fusion_start_watchdog(instance) != SUCCESS) in megasas_init_fw()
6524 if (instance->requestorId && !instance->skip_heartbeat_timer_del) in megasas_init_fw()
6525 del_timer_sync(&instance->sriov_heartbeat_timer); in megasas_init_fw()
6527 instance->instancet->disable_intr(instance); in megasas_init_fw()
6528 megasas_destroy_irqs(instance); in megasas_init_fw()
6530 if (instance->msix_vectors) in megasas_init_fw()
6531 pci_free_irq_vectors(instance->pdev); in megasas_init_fw()
6532 instance->msix_vectors = 0; in megasas_init_fw()
6534 megasas_free_ctrl_dma_buffers(instance); in megasas_init_fw()
6535 megasas_free_ctrl_mem(instance); in megasas_init_fw()
6537 iounmap(instance->reg_set); in megasas_init_fw()
6540 pci_release_selected_regions(instance->pdev, 1<<instance->bar); in megasas_init_fw()
6542 dev_err(&instance->pdev->dev, "Failed from %s %d\n", in megasas_init_fw()
6551 static void megasas_release_mfi(struct megasas_instance *instance) in megasas_release_mfi() argument
6553 u32 reply_q_sz = sizeof(u32) *(instance->max_mfi_cmds + 1); in megasas_release_mfi()
6555 if (instance->reply_queue) in megasas_release_mfi()
6556 dma_free_coherent(&instance->pdev->dev, reply_q_sz, in megasas_release_mfi()
6557 instance->reply_queue, instance->reply_queue_h); in megasas_release_mfi()
6559 megasas_free_cmds(instance); in megasas_release_mfi()
6561 iounmap(instance->reg_set); in megasas_release_mfi()
6563 pci_release_selected_regions(instance->pdev, 1<<instance->bar); in megasas_release_mfi()
6579 megasas_get_seq_num(struct megasas_instance *instance, in megasas_get_seq_num() argument
6588 cmd = megasas_get_cmd(instance); in megasas_get_seq_num()
6595 el_info = dma_alloc_coherent(&instance->pdev->dev, in megasas_get_seq_num()
6599 megasas_return_cmd(instance, cmd); in megasas_get_seq_num()
6614 megasas_set_dma_settings(instance, dcmd, el_info_h, in megasas_get_seq_num()
6617 ret = megasas_issue_blocked_cmd(instance, cmd, MFI_IO_TIMEOUT_SECS); in megasas_get_seq_num()
6619 dev_err(&instance->pdev->dev, "Failed from %s %d\n", in megasas_get_seq_num()
6634 dma_free_coherent(&instance->pdev->dev, in megasas_get_seq_num()
6638 megasas_return_cmd(instance, cmd); in megasas_get_seq_num()
6653 megasas_register_aen(struct megasas_instance *instance, u32 seq_num, in megasas_register_aen() argument
6677 if (instance->aen_cmd) { in megasas_register_aen()
6680 le32_to_cpu(instance->aen_cmd->frame->dcmd.mbox.w[1]); in megasas_register_aen()
6684 dev_info(&instance->pdev->dev, in megasas_register_aen()
6714 instance->aen_cmd->abort_aen = 1; in megasas_register_aen()
6715 ret_val = megasas_issue_blocked_abort_cmd(instance, in megasas_register_aen()
6716 instance-> in megasas_register_aen()
6720 dev_printk(KERN_DEBUG, &instance->pdev->dev, "Failed to abort " in megasas_register_aen()
6727 cmd = megasas_get_cmd(instance); in megasas_register_aen()
6734 memset(instance->evt_detail, 0, sizeof(struct megasas_evt_detail)); in megasas_register_aen()
6750 instance->last_seq_num = seq_num; in megasas_register_aen()
6753 megasas_set_dma_settings(instance, dcmd, instance->evt_detail_h, in megasas_register_aen()
6756 if (instance->aen_cmd != NULL) { in megasas_register_aen()
6757 megasas_return_cmd(instance, cmd); in megasas_register_aen()
6766 instance->aen_cmd = cmd; in megasas_register_aen()
6771 instance->instancet->issue_dcmd(instance, cmd); in megasas_register_aen()
6795 megasas_get_target_prop(struct megasas_instance *instance, in megasas_get_target_prop() argument
6804 cmd = megasas_get_cmd(instance); in megasas_get_target_prop()
6807 dev_err(&instance->pdev->dev, in megasas_get_target_prop()
6814 memset(instance->tgt_prop, 0, sizeof(*instance->tgt_prop)); in megasas_get_target_prop()
6829 megasas_set_dma_settings(instance, dcmd, instance->tgt_prop_h, in megasas_get_target_prop()
6832 if ((instance->adapter_type != MFI_SERIES) && in megasas_get_target_prop()
6833 !instance->mask_interrupts) in megasas_get_target_prop()
6834 ret = megasas_issue_blocked_cmd(instance, in megasas_get_target_prop()
6837 ret = megasas_issue_polled(instance, cmd); in megasas_get_target_prop()
6841 switch (dcmd_timeout_ocr_possible(instance)) { in megasas_get_target_prop()
6844 mutex_unlock(&instance->reset_mutex); in megasas_get_target_prop()
6845 megasas_reset_fusion(instance->host, in megasas_get_target_prop()
6847 mutex_lock(&instance->reset_mutex); in megasas_get_target_prop()
6850 megaraid_sas_kill_hba(instance); in megasas_get_target_prop()
6853 dev_info(&instance->pdev->dev, in megasas_get_target_prop()
6861 megasas_return_cmd(instance, cmd); in megasas_get_target_prop()
6864 dev_err(&instance->pdev->dev, in megasas_get_target_prop()
6875 static int megasas_start_aen(struct megasas_instance *instance) in megasas_start_aen() argument
6885 if (megasas_get_seq_num(instance, &eli)) in megasas_start_aen()
6895 return megasas_register_aen(instance, in megasas_start_aen()
6904 static int megasas_io_attach(struct megasas_instance *instance) in megasas_io_attach() argument
6906 struct Scsi_Host *host = instance->host; in megasas_io_attach()
6911 host->unique_id = instance->unique_id; in megasas_io_attach()
6912 host->can_queue = instance->max_scsi_cmds; in megasas_io_attach()
6913 host->this_id = instance->init_id; in megasas_io_attach()
6914 host->sg_tablesize = instance->max_num_sge; in megasas_io_attach()
6916 if (instance->fw_support_ieee) in megasas_io_attach()
6917 instance->max_sectors_per_req = MEGASAS_MAX_SECTORS_IEEE; in megasas_io_attach()
6922 if (max_sectors && max_sectors < instance->max_sectors_per_req) in megasas_io_attach()
6923 instance->max_sectors_per_req = max_sectors; in megasas_io_attach()
6926 if (((instance->pdev->device == in megasas_io_attach()
6928 (instance->pdev->device == in megasas_io_attach()
6931 instance->max_sectors_per_req = max_sectors; in megasas_io_attach()
6933 dev_info(&instance->pdev->dev, "max_sectors should be > 0" in megasas_io_attach()
6935 instance->max_sectors_per_req); in megasas_io_attach()
6940 host->max_sectors = instance->max_sectors_per_req; in megasas_io_attach()
6955 if ((instance->adapter_type != MFI_SERIES) && in megasas_io_attach()
6956 (instance->msix_vectors > instance->low_latency_index_start) && in megasas_io_attach()
6958 instance->smp_affinity_enable) { in megasas_io_attach()
6960 host->nr_hw_queues = instance->msix_vectors - in megasas_io_attach()
6961 instance->low_latency_index_start + instance->iopoll_q_count; in megasas_io_attach()
6962 if (instance->iopoll_q_count) in megasas_io_attach()
6965 instance->iopoll_q_count = 0; in megasas_io_attach()
6968 dev_info(&instance->pdev->dev, in megasas_io_attach()
6970 "hw_queues = %d poll_queues %d\n", instance->max_fw_cmds, in megasas_io_attach()
6971 host->nr_hw_queues - instance->iopoll_q_count, in megasas_io_attach()
6972 instance->iopoll_q_count); in megasas_io_attach()
6976 if (scsi_add_host(host, &instance->pdev->dev)) { in megasas_io_attach()
6977 dev_err(&instance->pdev->dev, in megasas_io_attach()
7004 megasas_set_dma_mask(struct megasas_instance *instance) in megasas_set_dma_mask() argument
7010 pdev = instance->pdev; in megasas_set_dma_mask()
7011 consistent_mask = (instance->adapter_type >= VENTURA_SERIES) ? in megasas_set_dma_mask()
7027 (instance, &instance->reg_set->outbound_scratch_pad_1); in megasas_set_dma_mask()
7039 instance->consistent_mask_64bit = false; in megasas_set_dma_mask()
7041 instance->consistent_mask_64bit = true; in megasas_set_dma_mask()
7045 (instance->consistent_mask_64bit ? "63" : "32")); in megasas_set_dma_mask()
7069 static inline void megasas_set_adapter_type(struct megasas_instance *instance) in megasas_set_adapter_type() argument
7071 if ((instance->pdev->vendor == PCI_VENDOR_ID_DELL) && in megasas_set_adapter_type()
7072 (instance->pdev->device == PCI_DEVICE_ID_DELL_PERC5)) { in megasas_set_adapter_type()
7073 instance->adapter_type = MFI_SERIES; in megasas_set_adapter_type()
7075 switch (instance->pdev->device) { in megasas_set_adapter_type()
7080 instance->adapter_type = AERO_SERIES; in megasas_set_adapter_type()
7088 instance->adapter_type = VENTURA_SERIES; in megasas_set_adapter_type()
7092 instance->adapter_type = THUNDERBOLT_SERIES; in megasas_set_adapter_type()
7100 instance->adapter_type = INVADER_SERIES; in megasas_set_adapter_type()
7103 instance->adapter_type = MFI_SERIES; in megasas_set_adapter_type()
7109 static inline int megasas_alloc_mfi_ctrl_mem(struct megasas_instance *instance) in megasas_alloc_mfi_ctrl_mem() argument
7111 instance->producer = dma_alloc_coherent(&instance->pdev->dev, in megasas_alloc_mfi_ctrl_mem()
7112 sizeof(u32), &instance->producer_h, GFP_KERNEL); in megasas_alloc_mfi_ctrl_mem()
7113 instance->consumer = dma_alloc_coherent(&instance->pdev->dev, in megasas_alloc_mfi_ctrl_mem()
7114 sizeof(u32), &instance->consumer_h, GFP_KERNEL); in megasas_alloc_mfi_ctrl_mem()
7116 if (!instance->producer || !instance->consumer) { in megasas_alloc_mfi_ctrl_mem()
7117 dev_err(&instance->pdev->dev, in megasas_alloc_mfi_ctrl_mem()
7122 *instance->producer = 0; in megasas_alloc_mfi_ctrl_mem()
7123 *instance->consumer = 0; in megasas_alloc_mfi_ctrl_mem()
7137 static int megasas_alloc_ctrl_mem(struct megasas_instance *instance) in megasas_alloc_ctrl_mem() argument
7139 instance->reply_map = kcalloc(nr_cpu_ids, sizeof(unsigned int), in megasas_alloc_ctrl_mem()
7141 if (!instance->reply_map) in megasas_alloc_ctrl_mem()
7144 switch (instance->adapter_type) { in megasas_alloc_ctrl_mem()
7146 if (megasas_alloc_mfi_ctrl_mem(instance)) in megasas_alloc_ctrl_mem()
7153 if (megasas_alloc_fusion_context(instance)) in megasas_alloc_ctrl_mem()
7168 static inline void megasas_free_ctrl_mem(struct megasas_instance *instance) in megasas_free_ctrl_mem() argument
7170 kfree(instance->reply_map); in megasas_free_ctrl_mem()
7171 if (instance->adapter_type == MFI_SERIES) { in megasas_free_ctrl_mem()
7172 if (instance->producer) in megasas_free_ctrl_mem()
7173 dma_free_coherent(&instance->pdev->dev, sizeof(u32), in megasas_free_ctrl_mem()
7174 instance->producer, in megasas_free_ctrl_mem()
7175 instance->producer_h); in megasas_free_ctrl_mem()
7176 if (instance->consumer) in megasas_free_ctrl_mem()
7177 dma_free_coherent(&instance->pdev->dev, sizeof(u32), in megasas_free_ctrl_mem()
7178 instance->consumer, in megasas_free_ctrl_mem()
7179 instance->consumer_h); in megasas_free_ctrl_mem()
7181 megasas_free_fusion_context(instance); in megasas_free_ctrl_mem()
7194 int megasas_alloc_ctrl_dma_buffers(struct megasas_instance *instance) in megasas_alloc_ctrl_dma_buffers() argument
7196 struct pci_dev *pdev = instance->pdev; in megasas_alloc_ctrl_dma_buffers()
7197 struct fusion_context *fusion = instance->ctrl_context; in megasas_alloc_ctrl_dma_buffers()
7199 instance->evt_detail = dma_alloc_coherent(&pdev->dev, in megasas_alloc_ctrl_dma_buffers()
7201 &instance->evt_detail_h, GFP_KERNEL); in megasas_alloc_ctrl_dma_buffers()
7203 if (!instance->evt_detail) { in megasas_alloc_ctrl_dma_buffers()
7204 dev_err(&instance->pdev->dev, in megasas_alloc_ctrl_dma_buffers()
7222 instance->snapdump_prop = dma_alloc_coherent(&pdev->dev, in megasas_alloc_ctrl_dma_buffers()
7224 &instance->snapdump_prop_h, GFP_KERNEL); in megasas_alloc_ctrl_dma_buffers()
7226 if (!instance->snapdump_prop) in megasas_alloc_ctrl_dma_buffers()
7230 instance->host_device_list_buf = dma_alloc_coherent(&pdev->dev, in megasas_alloc_ctrl_dma_buffers()
7232 &instance->host_device_list_buf_h, in megasas_alloc_ctrl_dma_buffers()
7235 if (!instance->host_device_list_buf) { in megasas_alloc_ctrl_dma_buffers()
7243 instance->pd_list_buf = in megasas_alloc_ctrl_dma_buffers()
7246 &instance->pd_list_buf_h, GFP_KERNEL); in megasas_alloc_ctrl_dma_buffers()
7248 if (!instance->pd_list_buf) { in megasas_alloc_ctrl_dma_buffers()
7253 instance->ctrl_info_buf = in megasas_alloc_ctrl_dma_buffers()
7256 &instance->ctrl_info_buf_h, GFP_KERNEL); in megasas_alloc_ctrl_dma_buffers()
7258 if (!instance->ctrl_info_buf) { in megasas_alloc_ctrl_dma_buffers()
7264 instance->ld_list_buf = in megasas_alloc_ctrl_dma_buffers()
7267 &instance->ld_list_buf_h, GFP_KERNEL); in megasas_alloc_ctrl_dma_buffers()
7269 if (!instance->ld_list_buf) { in megasas_alloc_ctrl_dma_buffers()
7274 instance->ld_targetid_list_buf = in megasas_alloc_ctrl_dma_buffers()
7277 &instance->ld_targetid_list_buf_h, GFP_KERNEL); in megasas_alloc_ctrl_dma_buffers()
7279 if (!instance->ld_targetid_list_buf) { in megasas_alloc_ctrl_dma_buffers()
7286 instance->system_info_buf = in megasas_alloc_ctrl_dma_buffers()
7289 &instance->system_info_h, GFP_KERNEL); in megasas_alloc_ctrl_dma_buffers()
7290 instance->pd_info = in megasas_alloc_ctrl_dma_buffers()
7293 &instance->pd_info_h, GFP_KERNEL); in megasas_alloc_ctrl_dma_buffers()
7294 instance->tgt_prop = in megasas_alloc_ctrl_dma_buffers()
7297 &instance->tgt_prop_h, GFP_KERNEL); in megasas_alloc_ctrl_dma_buffers()
7298 instance->crash_dump_buf = in megasas_alloc_ctrl_dma_buffers()
7300 &instance->crash_dump_h, GFP_KERNEL); in megasas_alloc_ctrl_dma_buffers()
7302 if (!instance->system_info_buf) in megasas_alloc_ctrl_dma_buffers()
7303 dev_err(&instance->pdev->dev, in megasas_alloc_ctrl_dma_buffers()
7306 if (!instance->pd_info) in megasas_alloc_ctrl_dma_buffers()
7307 dev_err(&instance->pdev->dev, in megasas_alloc_ctrl_dma_buffers()
7310 if (!instance->tgt_prop) in megasas_alloc_ctrl_dma_buffers()
7311 dev_err(&instance->pdev->dev, in megasas_alloc_ctrl_dma_buffers()
7314 if (!instance->crash_dump_buf) in megasas_alloc_ctrl_dma_buffers()
7315 dev_err(&instance->pdev->dev, in megasas_alloc_ctrl_dma_buffers()
7330 void megasas_free_ctrl_dma_buffers(struct megasas_instance *instance) in megasas_free_ctrl_dma_buffers() argument
7332 struct pci_dev *pdev = instance->pdev; in megasas_free_ctrl_dma_buffers()
7333 struct fusion_context *fusion = instance->ctrl_context; in megasas_free_ctrl_dma_buffers()
7335 if (instance->evt_detail) in megasas_free_ctrl_dma_buffers()
7337 instance->evt_detail, in megasas_free_ctrl_dma_buffers()
7338 instance->evt_detail_h); in megasas_free_ctrl_dma_buffers()
7346 if (instance->pd_list_buf) in megasas_free_ctrl_dma_buffers()
7349 instance->pd_list_buf, in megasas_free_ctrl_dma_buffers()
7350 instance->pd_list_buf_h); in megasas_free_ctrl_dma_buffers()
7352 if (instance->ld_list_buf) in megasas_free_ctrl_dma_buffers()
7354 instance->ld_list_buf, in megasas_free_ctrl_dma_buffers()
7355 instance->ld_list_buf_h); in megasas_free_ctrl_dma_buffers()
7357 if (instance->ld_targetid_list_buf) in megasas_free_ctrl_dma_buffers()
7359 instance->ld_targetid_list_buf, in megasas_free_ctrl_dma_buffers()
7360 instance->ld_targetid_list_buf_h); in megasas_free_ctrl_dma_buffers()
7362 if (instance->ctrl_info_buf) in megasas_free_ctrl_dma_buffers()
7364 instance->ctrl_info_buf, in megasas_free_ctrl_dma_buffers()
7365 instance->ctrl_info_buf_h); in megasas_free_ctrl_dma_buffers()
7367 if (instance->system_info_buf) in megasas_free_ctrl_dma_buffers()
7369 instance->system_info_buf, in megasas_free_ctrl_dma_buffers()
7370 instance->system_info_h); in megasas_free_ctrl_dma_buffers()
7372 if (instance->pd_info) in megasas_free_ctrl_dma_buffers()
7374 instance->pd_info, instance->pd_info_h); in megasas_free_ctrl_dma_buffers()
7376 if (instance->tgt_prop) in megasas_free_ctrl_dma_buffers()
7378 instance->tgt_prop, instance->tgt_prop_h); in megasas_free_ctrl_dma_buffers()
7380 if (instance->crash_dump_buf) in megasas_free_ctrl_dma_buffers()
7382 instance->crash_dump_buf, in megasas_free_ctrl_dma_buffers()
7383 instance->crash_dump_h); in megasas_free_ctrl_dma_buffers()
7385 if (instance->snapdump_prop) in megasas_free_ctrl_dma_buffers()
7388 instance->snapdump_prop, in megasas_free_ctrl_dma_buffers()
7389 instance->snapdump_prop_h); in megasas_free_ctrl_dma_buffers()
7391 if (instance->host_device_list_buf) in megasas_free_ctrl_dma_buffers()
7394 instance->host_device_list_buf, in megasas_free_ctrl_dma_buffers()
7395 instance->host_device_list_buf_h); in megasas_free_ctrl_dma_buffers()
7405 static inline void megasas_init_ctrl_params(struct megasas_instance *instance) in megasas_init_ctrl_params() argument
7407 instance->fw_crash_state = UNAVAILABLE; in megasas_init_ctrl_params()
7410 instance->issuepend_done = 1; in megasas_init_ctrl_params()
7411 atomic_set(&instance->adprecovery, MEGASAS_HBA_OPERATIONAL); in megasas_init_ctrl_params()
7416 INIT_LIST_HEAD(&instance->cmd_pool); in megasas_init_ctrl_params()
7417 INIT_LIST_HEAD(&instance->internal_reset_pending_q); in megasas_init_ctrl_params()
7419 atomic_set(&instance->fw_outstanding, 0); in megasas_init_ctrl_params()
7420 atomic64_set(&instance->total_io_count, 0); in megasas_init_ctrl_params()
7422 init_waitqueue_head(&instance->int_cmd_wait_q); in megasas_init_ctrl_params()
7423 init_waitqueue_head(&instance->abort_cmd_wait_q); in megasas_init_ctrl_params()
7425 mutex_init(&instance->crashdump_lock); in megasas_init_ctrl_params()
7426 spin_lock_init(&instance->mfi_pool_lock); in megasas_init_ctrl_params()
7427 spin_lock_init(&instance->hba_lock); in megasas_init_ctrl_params()
7428 spin_lock_init(&instance->stream_lock); in megasas_init_ctrl_params()
7429 spin_lock_init(&instance->completion_lock); in megasas_init_ctrl_params()
7431 mutex_init(&instance->reset_mutex); in megasas_init_ctrl_params()
7433 if ((instance->pdev->device == PCI_DEVICE_ID_LSI_SAS0073SKINNY) || in megasas_init_ctrl_params()
7434 (instance->pdev->device == PCI_DEVICE_ID_LSI_SAS0071SKINNY)) in megasas_init_ctrl_params()
7435 instance->flag_ieee = 1; in megasas_init_ctrl_params()
7437 instance->flag = 0; in megasas_init_ctrl_params()
7438 instance->unload = 1; in megasas_init_ctrl_params()
7439 instance->last_time = 0; in megasas_init_ctrl_params()
7440 instance->disableOnlineCtrlReset = 1; in megasas_init_ctrl_params()
7441 instance->UnevenSpanSupport = 0; in megasas_init_ctrl_params()
7442 instance->smp_affinity_enable = smp_affinity_enable ? true : false; in megasas_init_ctrl_params()
7443 instance->msix_load_balance = false; in megasas_init_ctrl_params()
7445 if (instance->adapter_type != MFI_SERIES) in megasas_init_ctrl_params()
7446 INIT_WORK(&instance->work_init, megasas_fusion_ocr_wq); in megasas_init_ctrl_params()
7448 INIT_WORK(&instance->work_init, process_fw_state_change_wq); in megasas_init_ctrl_params()
7461 struct megasas_instance *instance; in megasas_probe_one() local
7512 instance = (struct megasas_instance *)host->hostdata; in megasas_probe_one()
7513 memset(instance, 0, sizeof(*instance)); in megasas_probe_one()
7514 atomic_set(&instance->fw_reset_no_pci_access, 0); in megasas_probe_one()
7519 instance->pdev = pdev; in megasas_probe_one()
7520 instance->host = host; in megasas_probe_one()
7521 instance->unique_id = pci_dev_id(pdev); in megasas_probe_one()
7522 instance->init_id = MEGASAS_DEFAULT_INIT_ID; in megasas_probe_one()
7524 megasas_set_adapter_type(instance); in megasas_probe_one()
7529 if (megasas_init_fw(instance)) in megasas_probe_one()
7532 if (instance->requestorId) { in megasas_probe_one()
7533 if (instance->PlasmaFW111) { in megasas_probe_one()
7534 instance->vf_affiliation_111 = in megasas_probe_one()
7537 &instance->vf_affiliation_111_h, in megasas_probe_one()
7539 if (!instance->vf_affiliation_111) in megasas_probe_one()
7543 instance->vf_affiliation = in megasas_probe_one()
7547 &instance->vf_affiliation_h, in megasas_probe_one()
7549 if (!instance->vf_affiliation) in megasas_probe_one()
7558 pci_set_drvdata(pdev, instance); in megasas_probe_one()
7565 megasas_mgmt_info.instance[megasas_mgmt_info.max_index] = instance; in megasas_probe_one()
7571 if (megasas_io_attach(instance)) in megasas_probe_one()
7574 instance->unload = 0; in megasas_probe_one()
7578 if (!instance->enable_fw_dev_list || in megasas_probe_one()
7579 (instance->host_device_list_buf->count > 0)) in megasas_probe_one()
7585 if (megasas_start_aen(instance)) { in megasas_probe_one()
7590 megasas_setup_debugfs(instance); in megasas_probe_one()
7593 if (instance->requestorId) in megasas_probe_one()
7594 megasas_get_ld_vf_affiliation(instance, 1); in megasas_probe_one()
7599 instance->unload = 1; in megasas_probe_one()
7600 scsi_remove_host(instance->host); in megasas_probe_one()
7604 megasas_mgmt_info.instance[megasas_mgmt_info.max_index] = NULL; in megasas_probe_one()
7606 if (instance->requestorId && !instance->skip_heartbeat_timer_del) in megasas_probe_one()
7607 del_timer_sync(&instance->sriov_heartbeat_timer); in megasas_probe_one()
7609 instance->instancet->disable_intr(instance); in megasas_probe_one()
7610 megasas_destroy_irqs(instance); in megasas_probe_one()
7612 if (instance->adapter_type != MFI_SERIES) in megasas_probe_one()
7613 megasas_release_fusion(instance); in megasas_probe_one()
7615 megasas_release_mfi(instance); in megasas_probe_one()
7617 if (instance->msix_vectors) in megasas_probe_one()
7618 pci_free_irq_vectors(instance->pdev); in megasas_probe_one()
7619 instance->msix_vectors = 0; in megasas_probe_one()
7621 if (instance->fw_crash_state != UNAVAILABLE) in megasas_probe_one()
7622 megasas_free_host_crash_buffer(instance); in megasas_probe_one()
7624 if (instance->adapter_type != MFI_SERIES) in megasas_probe_one()
7625 megasas_fusion_stop_watchdog(instance); in megasas_probe_one()
7638 static void megasas_flush_cache(struct megasas_instance *instance) in megasas_flush_cache() argument
7643 if (atomic_read(&instance->adprecovery) == MEGASAS_HW_CRITICAL_ERROR) in megasas_flush_cache()
7646 cmd = megasas_get_cmd(instance); in megasas_flush_cache()
7665 if (megasas_issue_blocked_cmd(instance, cmd, MFI_IO_TIMEOUT_SECS) in megasas_flush_cache()
7667 dev_err(&instance->pdev->dev, in megasas_flush_cache()
7672 megasas_return_cmd(instance, cmd); in megasas_flush_cache()
7680 static void megasas_shutdown_controller(struct megasas_instance *instance, in megasas_shutdown_controller() argument
7686 if (atomic_read(&instance->adprecovery) == MEGASAS_HW_CRITICAL_ERROR) in megasas_shutdown_controller()
7689 cmd = megasas_get_cmd(instance); in megasas_shutdown_controller()
7694 if (instance->aen_cmd) in megasas_shutdown_controller()
7695 megasas_issue_blocked_abort_cmd(instance, in megasas_shutdown_controller()
7696 instance->aen_cmd, MFI_IO_TIMEOUT_SECS); in megasas_shutdown_controller()
7697 if (instance->map_update_cmd) in megasas_shutdown_controller()
7698 megasas_issue_blocked_abort_cmd(instance, in megasas_shutdown_controller()
7699 instance->map_update_cmd, MFI_IO_TIMEOUT_SECS); in megasas_shutdown_controller()
7700 if (instance->jbod_seq_cmd) in megasas_shutdown_controller()
7701 megasas_issue_blocked_abort_cmd(instance, in megasas_shutdown_controller()
7702 instance->jbod_seq_cmd, MFI_IO_TIMEOUT_SECS); in megasas_shutdown_controller()
7717 if (megasas_issue_blocked_cmd(instance, cmd, MFI_IO_TIMEOUT_SECS) in megasas_shutdown_controller()
7719 dev_err(&instance->pdev->dev, in megasas_shutdown_controller()
7724 megasas_return_cmd(instance, cmd); in megasas_shutdown_controller()
7734 struct megasas_instance *instance; in megasas_suspend() local
7736 instance = dev_get_drvdata(dev); in megasas_suspend()
7738 if (!instance) in megasas_suspend()
7741 instance->unload = 1; in megasas_suspend()
7746 if (instance->requestorId && !instance->skip_heartbeat_timer_del) in megasas_suspend()
7747 del_timer_sync(&instance->sriov_heartbeat_timer); in megasas_suspend()
7750 if (instance->adapter_type != MFI_SERIES) in megasas_suspend()
7751 megasas_fusion_stop_watchdog(instance); in megasas_suspend()
7753 megasas_flush_cache(instance); in megasas_suspend()
7754 megasas_shutdown_controller(instance, MR_DCMD_HIBERNATE_SHUTDOWN); in megasas_suspend()
7757 if (instance->ev != NULL) { in megasas_suspend()
7758 struct megasas_aen_event *ev = instance->ev; in megasas_suspend()
7760 instance->ev = NULL; in megasas_suspend()
7763 tasklet_kill(&instance->isr_tasklet); in megasas_suspend()
7765 pci_set_drvdata(instance->pdev, instance); in megasas_suspend()
7766 instance->instancet->disable_intr(instance); in megasas_suspend()
7768 megasas_destroy_irqs(instance); in megasas_suspend()
7770 if (instance->msix_vectors) in megasas_suspend()
7771 pci_free_irq_vectors(instance->pdev); in megasas_suspend()
7785 struct megasas_instance *instance; in megasas_resume() local
7788 instance = dev_get_drvdata(dev); in megasas_resume()
7790 if (!instance) in megasas_resume()
7793 host = instance->host; in megasas_resume()
7801 if (megasas_transition_to_ready(instance, 0)) { in megasas_resume()
7802 dev_info(&instance->pdev->dev, in megasas_resume()
7805 if (instance->adapter_type != MFI_SERIES) { in megasas_resume()
7807 instance->instancet->read_fw_status_reg(instance); in megasas_resume()
7810 (instance, true, 0)) == FAILED)) in megasas_resume()
7813 atomic_set(&instance->fw_reset_no_pci_access, 1); in megasas_resume()
7814 instance->instancet->adp_reset in megasas_resume()
7815 (instance, instance->reg_set); in megasas_resume()
7816 atomic_set(&instance->fw_reset_no_pci_access, 0); in megasas_resume()
7821 if (megasas_transition_to_ready(instance, 0)) in megasas_resume()
7825 dev_info(&instance->pdev->dev, in megasas_resume()
7829 if (megasas_set_dma_mask(instance)) in megasas_resume()
7836 atomic_set(&instance->fw_outstanding, 0); in megasas_resume()
7837 atomic_set(&instance->ldio_outstanding, 0); in megasas_resume()
7840 if (instance->msix_vectors) in megasas_resume()
7841 megasas_alloc_irq_vectors(instance); in megasas_resume()
7843 if (!instance->msix_vectors) { in megasas_resume()
7844 rval = pci_alloc_irq_vectors(instance->pdev, 1, 1, in megasas_resume()
7850 megasas_setup_reply_map(instance); in megasas_resume()
7852 if (instance->adapter_type != MFI_SERIES) { in megasas_resume()
7853 megasas_reset_reply_desc(instance); in megasas_resume()
7854 if (megasas_ioc_init_fusion(instance)) { in megasas_resume()
7855 megasas_free_cmds(instance); in megasas_resume()
7856 megasas_free_cmds_fusion(instance); in megasas_resume()
7859 if (!megasas_get_map_info(instance)) in megasas_resume()
7860 megasas_sync_map_info(instance); in megasas_resume()
7862 *instance->producer = 0; in megasas_resume()
7863 *instance->consumer = 0; in megasas_resume()
7864 if (megasas_issue_init_mfi(instance)) in megasas_resume()
7868 if (megasas_get_ctrl_info(instance) != DCMD_SUCCESS) in megasas_resume()
7871 tasklet_init(&instance->isr_tasklet, instance->instancet->tasklet, in megasas_resume()
7872 (unsigned long)instance); in megasas_resume()
7874 if (instance->msix_vectors ? in megasas_resume()
7875 megasas_setup_irqs_msix(instance, 0) : in megasas_resume()
7876 megasas_setup_irqs_ioapic(instance)) in megasas_resume()
7879 if (instance->adapter_type != MFI_SERIES) in megasas_resume()
7880 megasas_setup_irq_poll(instance); in megasas_resume()
7883 if (instance->requestorId) { in megasas_resume()
7884 if (!megasas_sriov_start_heartbeat(instance, 0)) in megasas_resume()
7885 megasas_start_timer(instance); in megasas_resume()
7887 instance->skip_heartbeat_timer_del = 1; in megasas_resume()
7892 instance->instancet->enable_intr(instance); in megasas_resume()
7893 megasas_setup_jbod_map(instance); in megasas_resume()
7894 instance->unload = 0; in megasas_resume()
7899 if (megasas_start_aen(instance)) in megasas_resume()
7900 dev_err(&instance->pdev->dev, "Start AEN failed\n"); in megasas_resume()
7903 if (instance->adapter_type != MFI_SERIES) in megasas_resume()
7904 if (megasas_fusion_start_watchdog(instance) != SUCCESS) in megasas_resume()
7910 if (instance->requestorId && !instance->skip_heartbeat_timer_del) in megasas_resume()
7911 del_timer_sync(&instance->sriov_heartbeat_timer); in megasas_resume()
7913 megasas_free_ctrl_dma_buffers(instance); in megasas_resume()
7914 megasas_free_ctrl_mem(instance); in megasas_resume()
7925 megasas_wait_for_adapter_operational(struct megasas_instance *instance) in megasas_wait_for_adapter_operational() argument
7932 adp_state = atomic_read(&instance->adprecovery); in megasas_wait_for_adapter_operational()
7938 dev_notice(&instance->pdev->dev, "waiting for controller reset to finish\n"); in megasas_wait_for_adapter_operational()
7944 dev_info(&instance->pdev->dev, in megasas_wait_for_adapter_operational()
7961 struct megasas_instance *instance; in megasas_detach_one() local
7965 instance = pci_get_drvdata(pdev); in megasas_detach_one()
7967 if (!instance) in megasas_detach_one()
7970 host = instance->host; in megasas_detach_one()
7971 fusion = instance->ctrl_context; in megasas_detach_one()
7974 if (instance->requestorId && !instance->skip_heartbeat_timer_del) in megasas_detach_one()
7975 del_timer_sync(&instance->sriov_heartbeat_timer); in megasas_detach_one()
7978 if (instance->adapter_type != MFI_SERIES) in megasas_detach_one()
7979 megasas_fusion_stop_watchdog(instance); in megasas_detach_one()
7981 if (instance->fw_crash_state != UNAVAILABLE) in megasas_detach_one()
7982 megasas_free_host_crash_buffer(instance); in megasas_detach_one()
7983 scsi_remove_host(instance->host); in megasas_detach_one()
7984 instance->unload = 1; in megasas_detach_one()
7986 if (megasas_wait_for_adapter_operational(instance)) in megasas_detach_one()
7989 megasas_flush_cache(instance); in megasas_detach_one()
7990 megasas_shutdown_controller(instance, MR_DCMD_CTRL_SHUTDOWN); in megasas_detach_one()
7994 if (instance->ev != NULL) { in megasas_detach_one()
7995 struct megasas_aen_event *ev = instance->ev; in megasas_detach_one()
7997 instance->ev = NULL; in megasas_detach_one()
8001 wake_up_all(&instance->int_cmd_wait_q); in megasas_detach_one()
8003 tasklet_kill(&instance->isr_tasklet); in megasas_detach_one()
8010 if (megasas_mgmt_info.instance[i] == instance) { in megasas_detach_one()
8012 megasas_mgmt_info.instance[i] = NULL; in megasas_detach_one()
8018 instance->instancet->disable_intr(instance); in megasas_detach_one()
8020 megasas_destroy_irqs(instance); in megasas_detach_one()
8022 if (instance->msix_vectors) in megasas_detach_one()
8023 pci_free_irq_vectors(instance->pdev); in megasas_detach_one()
8025 if (instance->adapter_type >= VENTURA_SERIES) { in megasas_detach_one()
8033 if (instance->adapter_type != MFI_SERIES) { in megasas_detach_one()
8034 megasas_release_fusion(instance); in megasas_detach_one()
8040 dma_free_coherent(&instance->pdev->dev, in megasas_detach_one()
8053 dma_free_coherent(&instance->pdev->dev, in megasas_detach_one()
8059 megasas_release_mfi(instance); in megasas_detach_one()
8062 if (instance->vf_affiliation) in megasas_detach_one()
8065 instance->vf_affiliation, in megasas_detach_one()
8066 instance->vf_affiliation_h); in megasas_detach_one()
8068 if (instance->vf_affiliation_111) in megasas_detach_one()
8071 instance->vf_affiliation_111, in megasas_detach_one()
8072 instance->vf_affiliation_111_h); in megasas_detach_one()
8074 if (instance->hb_host_mem) in megasas_detach_one()
8076 instance->hb_host_mem, in megasas_detach_one()
8077 instance->hb_host_mem_h); in megasas_detach_one()
8079 megasas_free_ctrl_dma_buffers(instance); in megasas_detach_one()
8081 megasas_free_ctrl_mem(instance); in megasas_detach_one()
8083 megasas_destroy_debugfs(instance); in megasas_detach_one()
8096 struct megasas_instance *instance = pci_get_drvdata(pdev); in megasas_shutdown() local
8098 if (!instance) in megasas_shutdown()
8101 instance->unload = 1; in megasas_shutdown()
8103 if (megasas_wait_for_adapter_operational(instance)) in megasas_shutdown()
8106 megasas_flush_cache(instance); in megasas_shutdown()
8107 megasas_shutdown_controller(instance, MR_DCMD_CTRL_SHUTDOWN); in megasas_shutdown()
8110 instance->instancet->disable_intr(instance); in megasas_shutdown()
8111 megasas_destroy_irqs(instance); in megasas_shutdown()
8113 if (instance->msix_vectors) in megasas_shutdown()
8114 pci_free_irq_vectors(instance->pdev); in megasas_shutdown()
8199 local_instance = megasas_mgmt_info.instance[i]; in megasas_set_crash_dump_params_ioctl()
8229 megasas_mgmt_fw_ioctl(struct megasas_instance *instance, in megasas_mgmt_fw_ioctl() argument
8248 dev_printk(KERN_DEBUG, &instance->pdev->dev, "SGE count [%d] > max limit [%d]\n", in megasas_mgmt_fw_ioctl()
8255 !instance->support_nvme_passthru) || in megasas_mgmt_fw_ioctl()
8257 !instance->support_pci_lane_margining)) { in megasas_mgmt_fw_ioctl()
8258 dev_err(&instance->pdev->dev, in megasas_mgmt_fw_ioctl()
8264 cmd = megasas_get_cmd(instance); in megasas_mgmt_fw_ioctl()
8266 dev_printk(KERN_DEBUG, &instance->pdev->dev, "Failed to get a cmd packet\n"); in megasas_mgmt_fw_ioctl()
8282 if (instance->consistent_mask_64bit) in megasas_mgmt_fw_ioctl()
8293 mutex_lock(&instance->reset_mutex); in megasas_mgmt_fw_ioctl()
8294 if (megasas_get_ctrl_info(instance) != DCMD_SUCCESS) { in megasas_mgmt_fw_ioctl()
8295 megasas_return_cmd(instance, cmd); in megasas_mgmt_fw_ioctl()
8296 mutex_unlock(&instance->reset_mutex); in megasas_mgmt_fw_ioctl()
8299 mutex_unlock(&instance->reset_mutex); in megasas_mgmt_fw_ioctl()
8304 megasas_return_cmd(instance, cmd); in megasas_mgmt_fw_ioctl()
8316 if (instance->consistent_mask_64bit) in megasas_mgmt_fw_ioctl()
8330 kbuff_arr[i] = dma_alloc_coherent(&instance->pdev->dev, in megasas_mgmt_fw_ioctl()
8334 dev_printk(KERN_DEBUG, &instance->pdev->dev, "Failed to alloc " in megasas_mgmt_fw_ioctl()
8344 if (instance->consistent_mask_64bit) { in megasas_mgmt_fw_ioctl()
8371 sense = dma_alloc_coherent(&instance->pdev->dev, ioc->sense_len, in megasas_mgmt_fw_ioctl()
8389 ret = megasas_issue_blocked_cmd(instance, cmd, 0); in megasas_mgmt_fw_ioctl()
8394 dev_err(&instance->pdev->dev, in megasas_mgmt_fw_ioctl()
8404 if (instance->unload == 1) { in megasas_mgmt_fw_ioctl()
8405 dev_info(&instance->pdev->dev, "Driver unload is in progress " in megasas_mgmt_fw_ioctl()
8437 dev_err(&instance->pdev->dev, "Failed to copy out to user " in megasas_mgmt_fw_ioctl()
8449 dev_printk(KERN_DEBUG, &instance->pdev->dev, "Error copying out cmd_status\n"); in megasas_mgmt_fw_ioctl()
8455 dma_free_coherent(&instance->pdev->dev, ioc->sense_len, in megasas_mgmt_fw_ioctl()
8461 if (instance->consistent_mask_64bit) in megasas_mgmt_fw_ioctl()
8462 dma_free_coherent(&instance->pdev->dev, in megasas_mgmt_fw_ioctl()
8467 dma_free_coherent(&instance->pdev->dev, in megasas_mgmt_fw_ioctl()
8475 megasas_return_cmd(instance, cmd); in megasas_mgmt_fw_ioctl()
8516 struct megasas_instance *instance; in megasas_mgmt_ioctl_fw() local
8527 instance = megasas_lookup_instance(ioc->host_no); in megasas_mgmt_ioctl_fw()
8528 if (!instance) { in megasas_mgmt_ioctl_fw()
8534 if (instance->requestorId && !allow_vf_ioctls) { in megasas_mgmt_ioctl_fw()
8539 if (atomic_read(&instance->adprecovery) == MEGASAS_HW_CRITICAL_ERROR) { in megasas_mgmt_ioctl_fw()
8540 dev_err(&instance->pdev->dev, "Controller in crit error\n"); in megasas_mgmt_ioctl_fw()
8545 if (instance->unload == 1) { in megasas_mgmt_ioctl_fw()
8550 if (down_interruptible(&instance->ioctl_sem)) { in megasas_mgmt_ioctl_fw()
8555 if (megasas_wait_for_adapter_operational(instance)) { in megasas_mgmt_ioctl_fw()
8560 error = megasas_mgmt_fw_ioctl(instance, user_ioc, ioc); in megasas_mgmt_ioctl_fw()
8562 up(&instance->ioctl_sem); in megasas_mgmt_ioctl_fw()
8571 struct megasas_instance *instance; in megasas_mgmt_ioctl_aen() local
8584 instance = megasas_lookup_instance(aen.host_no); in megasas_mgmt_ioctl_aen()
8586 if (!instance) in megasas_mgmt_ioctl_aen()
8589 if (atomic_read(&instance->adprecovery) == MEGASAS_HW_CRITICAL_ERROR) { in megasas_mgmt_ioctl_aen()
8593 if (instance->unload == 1) { in megasas_mgmt_ioctl_aen()
8597 if (megasas_wait_for_adapter_operational(instance)) in megasas_mgmt_ioctl_aen()
8600 mutex_lock(&instance->reset_mutex); in megasas_mgmt_ioctl_aen()
8601 error = megasas_register_aen(instance, aen.seq_num, in megasas_mgmt_ioctl_aen()
8603 mutex_unlock(&instance->reset_mutex); in megasas_mgmt_ioctl_aen()
8756 int megasas_update_device_list(struct megasas_instance *instance, in megasas_update_device_list() argument
8761 if (instance->enable_fw_dev_list) { in megasas_update_device_list()
8762 return megasas_host_device_list_query(instance, false); in megasas_update_device_list()
8765 dcmd_ret = megasas_get_pd_list(instance); in megasas_update_device_list()
8771 if (!instance->requestorId || in megasas_update_device_list()
8772 megasas_get_ld_vf_affiliation(instance, 0)) { in megasas_update_device_list()
8773 return megasas_ld_list_query(instance, in megasas_update_device_list()
8789 void megasas_add_remove_devices(struct megasas_instance *instance, in megasas_add_remove_devices() argument
8801 host = instance->host; in megasas_add_remove_devices()
8803 if (instance->enable_fw_dev_list) { in megasas_add_remove_devices()
8804 targetid_list = instance->host_device_list_buf; in megasas_add_remove_devices()
8833 if (instance->pd_list[pd_index].driveState == in megasas_add_remove_devices()
8853 if (instance->ld_ids[ld_index] != 0xff) { in megasas_add_remove_devices()
8873 struct megasas_instance *instance = ev->instance; in megasas_aen_polling() local
8882 if (!instance) { in megasas_aen_polling()
8889 mutex_lock(&instance->reset_mutex); in megasas_aen_polling()
8891 instance->ev = NULL; in megasas_aen_polling()
8892 if (instance->evt_detail) { in megasas_aen_polling()
8893 megasas_decode_evt(instance); in megasas_aen_polling()
8895 switch (le32_to_cpu(instance->evt_detail->code)) { in megasas_aen_polling()
8904 ld_target_id = instance->evt_detail->args.ld.target_id; in megasas_aen_polling()
8905 sdev1 = scsi_device_lookup(instance->host, in megasas_aen_polling()
8924 dev_info(&instance->pdev->dev, "scanning for scsi%d...\n", in megasas_aen_polling()
8925 instance->host->host_no); in megasas_aen_polling()
8929 dcmd_ret = megasas_get_ctrl_info(instance); in megasas_aen_polling()
8931 instance->snapdump_wait_time) { in megasas_aen_polling()
8932 megasas_get_snapdump_properties(instance); in megasas_aen_polling()
8933 dev_info(&instance->pdev->dev, in megasas_aen_polling()
8935 instance->snapdump_wait_time); in megasas_aen_polling()
8943 dev_err(&instance->pdev->dev, "invalid evt_detail!\n"); in megasas_aen_polling()
8944 mutex_unlock(&instance->reset_mutex); in megasas_aen_polling()
8950 dcmd_ret = megasas_update_device_list(instance, event_type); in megasas_aen_polling()
8952 mutex_unlock(&instance->reset_mutex); in megasas_aen_polling()
8955 megasas_add_remove_devices(instance, event_type); in megasas_aen_polling()
8958 seq_num = le32_to_cpu(instance->evt_detail->seq_num) + 1; in megasas_aen_polling()
8960 seq_num = instance->last_seq_num; in megasas_aen_polling()
8967 if (instance->aen_cmd != NULL) { in megasas_aen_polling()
8972 mutex_lock(&instance->reset_mutex); in megasas_aen_polling()
8973 error = megasas_register_aen(instance, seq_num, in megasas_aen_polling()
8976 dev_err(&instance->pdev->dev, in megasas_aen_polling()
8979 mutex_unlock(&instance->reset_mutex); in megasas_aen_polling()