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()
1927 } else if (instance->use_seqnum_jbod_fp) { in megasas_set_dynamic_target_properties()
1931 [(instance->pd_seq_map_id - 1) & 1]; in megasas_set_dynamic_target_properties()
1936 if (is_target_prop && instance->tgt_prop->reset_tmo) { in megasas_set_dynamic_target_properties()
1942 min_t(u8, instance->max_reset_tmo, in megasas_set_dynamic_target_properties()
1943 instance->tgt_prop->reset_tmo); in megasas_set_dynamic_target_properties()
1944 mr_device_priv_data->task_abort_tmo = instance->task_abort_tmo; in megasas_set_dynamic_target_properties()
1972 struct megasas_instance *instance; in megasas_set_nvme_device_properties() local
1975 instance = (struct megasas_instance *)sdev->host->hostdata; in megasas_set_nvme_device_properties()
1976 mr_nvme_pg_size = max_t(u32, instance->nvme_page_size, in megasas_set_nvme_device_properties()
1999 struct megasas_instance *instance; in megasas_set_fw_assisted_qd() local
2002 instance = megasas_lookup_instance(sdev->host->host_no); in megasas_set_fw_assisted_qd()
2019 tgt_device_qd = le32_to_cpu(instance->tgt_prop->device_qdepth); in megasas_set_fw_assisted_qd()
2021 device_qd = min(instance->host->can_queue, in megasas_set_fw_assisted_qd()
2025 if (instance->enable_sdev_max_qd && interface_type != UNKNOWN_DRIVE) in megasas_set_fw_assisted_qd()
2026 device_qd = instance->host->can_queue; in megasas_set_fw_assisted_qd()
2047 struct megasas_instance *instance; in megasas_set_static_target_properties() local
2049 instance = megasas_lookup_instance(sdev->host->host_no); in megasas_set_static_target_properties()
2060 max_io_size_kb = le32_to_cpu(instance->tgt_prop->max_io_size_kb); in megasas_set_static_target_properties()
2062 if (instance->nvme_page_size && max_io_size_kb) in megasas_set_static_target_properties()
2072 struct megasas_instance *instance; in megasas_slave_configure() local
2076 instance = megasas_lookup_instance(sdev->host->host_no); in megasas_slave_configure()
2077 if (instance->pd_list_not_supported) { in megasas_slave_configure()
2081 if (instance->pd_list[pd_index].driveState != in megasas_slave_configure()
2087 mutex_lock(&instance->reset_mutex); in megasas_slave_configure()
2089 if ((instance->pd_info) && !MEGASAS_IS_LOGICAL(sdev)) in megasas_slave_configure()
2090 megasas_get_pd_info(instance, sdev); in megasas_slave_configure()
2095 if ((instance->tgt_prop) && (instance->nvme_page_size)) in megasas_slave_configure()
2096 ret_target_prop = megasas_get_target_prop(instance, sdev); in megasas_slave_configure()
2104 mutex_unlock(&instance->reset_mutex); in megasas_slave_configure()
2112 struct megasas_instance *instance ; in megasas_slave_alloc() local
2115 instance = megasas_lookup_instance(sdev->host->host_no); in megasas_slave_alloc()
2123 if ((instance->pd_list_not_supported || in megasas_slave_alloc()
2124 instance->pd_list[pd_index].driveState == in megasas_slave_alloc()
2142 instance->ld_tgtid_status[ld_tgt_id] = LD_TARGET_ID_ACTIVE; in megasas_slave_alloc()
2150 instance->r1_ldio_hint_default); in megasas_slave_alloc()
2157 struct megasas_instance *instance; in megasas_slave_destroy() local
2159 instance = megasas_lookup_instance(sdev->host->host_no); in megasas_slave_destroy()
2167 instance->ld_tgtid_status[ld_tgt_id] = LD_TARGET_ID_DELETED; in megasas_slave_destroy()
2183 static void megasas_complete_outstanding_ioctls(struct megasas_instance *instance) in megasas_complete_outstanding_ioctls() argument
2188 struct fusion_context *fusion = instance->ctrl_context; in megasas_complete_outstanding_ioctls()
2192 for (i = 0; i < instance->max_fw_cmds; i++) { in megasas_complete_outstanding_ioctls()
2195 cmd_mfi = instance->cmd_list[cmd_fusion->sync_cmd_idx]; in megasas_complete_outstanding_ioctls()
2200 megasas_complete_cmd(instance, in megasas_complete_outstanding_ioctls()
2206 for (i = 0; i < instance->max_fw_cmds; i++) { in megasas_complete_outstanding_ioctls()
2207 cmd_mfi = instance->cmd_list[i]; in megasas_complete_outstanding_ioctls()
2210 megasas_complete_cmd(instance, cmd_mfi, DID_OK); in megasas_complete_outstanding_ioctls()
2216 void megaraid_sas_kill_hba(struct megasas_instance *instance) in megaraid_sas_kill_hba() argument
2218 if (atomic_read(&instance->adprecovery) == MEGASAS_HW_CRITICAL_ERROR) { in megaraid_sas_kill_hba()
2219 dev_warn(&instance->pdev->dev, in megaraid_sas_kill_hba()
2225 atomic_set(&instance->adprecovery, MEGASAS_HW_CRITICAL_ERROR); in megaraid_sas_kill_hba()
2228 if ((instance->pdev->device == PCI_DEVICE_ID_LSI_SAS0073SKINNY) || in megaraid_sas_kill_hba()
2229 (instance->pdev->device == PCI_DEVICE_ID_LSI_SAS0071SKINNY) || in megaraid_sas_kill_hba()
2230 (instance->adapter_type != MFI_SERIES)) { in megaraid_sas_kill_hba()
2231 if (!instance->requestorId) { in megaraid_sas_kill_hba()
2232 writel(MFI_STOP_ADP, &instance->reg_set->doorbell); in megaraid_sas_kill_hba()
2234 readl(&instance->reg_set->doorbell); in megaraid_sas_kill_hba()
2236 if (instance->requestorId && instance->peerIsPresent) in megaraid_sas_kill_hba()
2237 memset(instance->ld_ids, 0xff, MEGASAS_MAX_LD_IDS); in megaraid_sas_kill_hba()
2240 &instance->reg_set->inbound_doorbell); in megaraid_sas_kill_hba()
2243 megasas_complete_outstanding_ioctls(instance); in megaraid_sas_kill_hba()
2253 megasas_check_and_restore_queue_depth(struct megasas_instance *instance) in megasas_check_and_restore_queue_depth() argument
2257 if (instance->flag & MEGASAS_FW_BUSY in megasas_check_and_restore_queue_depth()
2258 && time_after(jiffies, instance->last_time + 5 * HZ) in megasas_check_and_restore_queue_depth()
2259 && atomic_read(&instance->fw_outstanding) < in megasas_check_and_restore_queue_depth()
2260 instance->throttlequeuedepth + 1) { in megasas_check_and_restore_queue_depth()
2262 spin_lock_irqsave(instance->host->host_lock, flags); in megasas_check_and_restore_queue_depth()
2263 instance->flag &= ~MEGASAS_FW_BUSY; in megasas_check_and_restore_queue_depth()
2265 instance->host->can_queue = instance->cur_can_queue; in megasas_check_and_restore_queue_depth()
2266 spin_unlock_irqrestore(instance->host->host_lock, flags); in megasas_check_and_restore_queue_depth()
2282 struct megasas_instance *instance = in megasas_complete_cmd_dpc() local
2287 if (atomic_read(&instance->adprecovery) == MEGASAS_HW_CRITICAL_ERROR) in megasas_complete_cmd_dpc()
2290 spin_lock_irqsave(&instance->completion_lock, flags); in megasas_complete_cmd_dpc()
2292 producer = le32_to_cpu(*instance->producer); in megasas_complete_cmd_dpc()
2293 consumer = le32_to_cpu(*instance->consumer); in megasas_complete_cmd_dpc()
2296 context = le32_to_cpu(instance->reply_queue[consumer]); in megasas_complete_cmd_dpc()
2297 if (context >= instance->max_fw_cmds) { in megasas_complete_cmd_dpc()
2298 dev_err(&instance->pdev->dev, "Unexpected context value %x\n", in megasas_complete_cmd_dpc()
2303 cmd = instance->cmd_list[context]; in megasas_complete_cmd_dpc()
2305 megasas_complete_cmd(instance, cmd, DID_OK); in megasas_complete_cmd_dpc()
2308 if (consumer == (instance->max_fw_cmds + 1)) { in megasas_complete_cmd_dpc()
2313 *instance->consumer = cpu_to_le32(producer); in megasas_complete_cmd_dpc()
2315 spin_unlock_irqrestore(&instance->completion_lock, flags); in megasas_complete_cmd_dpc()
2320 megasas_check_and_restore_queue_depth(instance); in megasas_complete_cmd_dpc()
2330 void megasas_start_timer(struct megasas_instance *instance) in megasas_start_timer() argument
2332 struct timer_list *timer = &instance->sriov_heartbeat_timer; in megasas_start_timer()
2340 megasas_internal_reset_defer_cmds(struct megasas_instance *instance);
2345 static void megasas_do_ocr(struct megasas_instance *instance) in megasas_do_ocr() argument
2347 if ((instance->pdev->device == PCI_DEVICE_ID_LSI_SAS1064R) || in megasas_do_ocr()
2348 (instance->pdev->device == PCI_DEVICE_ID_DELL_PERC5) || in megasas_do_ocr()
2349 (instance->pdev->device == PCI_DEVICE_ID_LSI_VERDE_ZCR)) { in megasas_do_ocr()
2350 *instance->consumer = cpu_to_le32(MEGASAS_ADPRESET_INPROG_SIGN); in megasas_do_ocr()
2352 instance->instancet->disable_intr(instance); in megasas_do_ocr()
2353 atomic_set(&instance->adprecovery, MEGASAS_ADPRESET_SM_INFAULT); in megasas_do_ocr()
2354 instance->issuepend_done = 0; in megasas_do_ocr()
2356 atomic_set(&instance->fw_outstanding, 0); in megasas_do_ocr()
2357 megasas_internal_reset_defer_cmds(instance); in megasas_do_ocr()
2358 process_fw_state_change_wq(&instance->work_init); in megasas_do_ocr()
2361 static int megasas_get_ld_vf_affiliation_111(struct megasas_instance *instance, in megasas_get_ld_vf_affiliation_111() argument
2371 cmd = megasas_get_cmd(instance); in megasas_get_ld_vf_affiliation_111()
2374 dev_printk(KERN_DEBUG, &instance->pdev->dev, "megasas_get_ld_vf_affiliation_111:" in megasas_get_ld_vf_affiliation_111()
2376 instance->host->host_no); in megasas_get_ld_vf_affiliation_111()
2382 if (!instance->vf_affiliation_111) { in megasas_get_ld_vf_affiliation_111()
2383 dev_warn(&instance->pdev->dev, "SR-IOV: Couldn't get LD/VF " in megasas_get_ld_vf_affiliation_111()
2384 "affiliation for scsi%d\n", instance->host->host_no); in megasas_get_ld_vf_affiliation_111()
2385 megasas_return_cmd(instance, cmd); in megasas_get_ld_vf_affiliation_111()
2390 memset(instance->vf_affiliation_111, 0, in megasas_get_ld_vf_affiliation_111()
2394 dma_alloc_coherent(&instance->pdev->dev, in megasas_get_ld_vf_affiliation_111()
2398 dev_printk(KERN_DEBUG, &instance->pdev->dev, "SR-IOV: Couldn't allocate " in megasas_get_ld_vf_affiliation_111()
2400 instance->host->host_no); in megasas_get_ld_vf_affiliation_111()
2401 megasas_return_cmd(instance, cmd); in megasas_get_ld_vf_affiliation_111()
2420 cpu_to_le32(instance->vf_affiliation_111_h); in megasas_get_ld_vf_affiliation_111()
2428 dev_warn(&instance->pdev->dev, "SR-IOV: Getting LD/VF affiliation for " in megasas_get_ld_vf_affiliation_111()
2429 "scsi%d\n", instance->host->host_no); in megasas_get_ld_vf_affiliation_111()
2431 if (megasas_issue_blocked_cmd(instance, cmd, 0) != DCMD_SUCCESS) { in megasas_get_ld_vf_affiliation_111()
2432 dev_warn(&instance->pdev->dev, "SR-IOV: LD/VF affiliation DCMD" in megasas_get_ld_vf_affiliation_111()
2434 dcmd->cmd_status, instance->host->host_no); in megasas_get_ld_vf_affiliation_111()
2442 if (instance->vf_affiliation_111->map[ld].policy[thisVf] != in megasas_get_ld_vf_affiliation_111()
2444 dev_warn(&instance->pdev->dev, "SR-IOV: " in megasas_get_ld_vf_affiliation_111()
2446 instance->host->host_no); in megasas_get_ld_vf_affiliation_111()
2447 memcpy(instance->vf_affiliation_111, in megasas_get_ld_vf_affiliation_111()
2456 dma_free_coherent(&instance->pdev->dev, in megasas_get_ld_vf_affiliation_111()
2462 megasas_return_cmd(instance, cmd); in megasas_get_ld_vf_affiliation_111()
2467 static int megasas_get_ld_vf_affiliation_12(struct megasas_instance *instance, in megasas_get_ld_vf_affiliation_12() argument
2478 cmd = megasas_get_cmd(instance); in megasas_get_ld_vf_affiliation_12()
2481 dev_printk(KERN_DEBUG, &instance->pdev->dev, "megasas_get_ld_vf_affiliation12: " in megasas_get_ld_vf_affiliation_12()
2483 instance->host->host_no); in megasas_get_ld_vf_affiliation_12()
2489 if (!instance->vf_affiliation) { in megasas_get_ld_vf_affiliation_12()
2490 dev_warn(&instance->pdev->dev, "SR-IOV: Couldn't get LD/VF " in megasas_get_ld_vf_affiliation_12()
2491 "affiliation for scsi%d\n", instance->host->host_no); in megasas_get_ld_vf_affiliation_12()
2492 megasas_return_cmd(instance, cmd); in megasas_get_ld_vf_affiliation_12()
2497 memset(instance->vf_affiliation, 0, (MAX_LOGICAL_DRIVES + 1) * in megasas_get_ld_vf_affiliation_12()
2501 dma_alloc_coherent(&instance->pdev->dev, in megasas_get_ld_vf_affiliation_12()
2505 dev_printk(KERN_DEBUG, &instance->pdev->dev, "SR-IOV: Couldn't allocate " in megasas_get_ld_vf_affiliation_12()
2507 instance->host->host_no); in megasas_get_ld_vf_affiliation_12()
2508 megasas_return_cmd(instance, cmd); in megasas_get_ld_vf_affiliation_12()
2527 cpu_to_le32(instance->vf_affiliation_h); in megasas_get_ld_vf_affiliation_12()
2535 dev_warn(&instance->pdev->dev, "SR-IOV: Getting LD/VF affiliation for " in megasas_get_ld_vf_affiliation_12()
2536 "scsi%d\n", instance->host->host_no); in megasas_get_ld_vf_affiliation_12()
2539 if (megasas_issue_blocked_cmd(instance, cmd, 0) != DCMD_SUCCESS) { in megasas_get_ld_vf_affiliation_12()
2540 dev_warn(&instance->pdev->dev, "SR-IOV: LD/VF affiliation DCMD" in megasas_get_ld_vf_affiliation_12()
2542 dcmd->cmd_status, instance->host->host_no); in megasas_get_ld_vf_affiliation_12()
2549 dev_warn(&instance->pdev->dev, "SR-IOV: Got new LD/VF " in megasas_get_ld_vf_affiliation_12()
2551 instance->host->host_no); in megasas_get_ld_vf_affiliation_12()
2556 savedmap = instance->vf_affiliation->map; in megasas_get_ld_vf_affiliation_12()
2560 for (j = 0; j < instance->vf_affiliation->ldCount; in megasas_get_ld_vf_affiliation_12()
2585 savedmap = instance->vf_affiliation->map; in megasas_get_ld_vf_affiliation_12()
2587 for (i = 0 ; i < instance->vf_affiliation->ldCount; i++) { in megasas_get_ld_vf_affiliation_12()
2615 dev_warn(&instance->pdev->dev, "SR-IOV: Got new LD/VF " in megasas_get_ld_vf_affiliation_12()
2616 "affiliation for scsi%d\n", instance->host->host_no); in megasas_get_ld_vf_affiliation_12()
2617 memcpy(instance->vf_affiliation, new_affiliation, in megasas_get_ld_vf_affiliation_12()
2623 dma_free_coherent(&instance->pdev->dev, in megasas_get_ld_vf_affiliation_12()
2627 megasas_return_cmd(instance, cmd); in megasas_get_ld_vf_affiliation_12()
2633 static int megasas_get_ld_vf_affiliation(struct megasas_instance *instance, in megasas_get_ld_vf_affiliation() argument
2638 if (instance->PlasmaFW111) in megasas_get_ld_vf_affiliation()
2639 retval = megasas_get_ld_vf_affiliation_111(instance, initial); in megasas_get_ld_vf_affiliation()
2641 retval = megasas_get_ld_vf_affiliation_12(instance, initial); in megasas_get_ld_vf_affiliation()
2646 int megasas_sriov_start_heartbeat(struct megasas_instance *instance, in megasas_sriov_start_heartbeat() argument
2653 cmd = megasas_get_cmd(instance); in megasas_sriov_start_heartbeat()
2656 dev_printk(KERN_DEBUG, &instance->pdev->dev, "megasas_sriov_start_heartbeat: " in megasas_sriov_start_heartbeat()
2658 instance->host->host_no); in megasas_sriov_start_heartbeat()
2665 instance->hb_host_mem = in megasas_sriov_start_heartbeat()
2666 dma_alloc_coherent(&instance->pdev->dev, in megasas_sriov_start_heartbeat()
2668 &instance->hb_host_mem_h, in megasas_sriov_start_heartbeat()
2670 if (!instance->hb_host_mem) { in megasas_sriov_start_heartbeat()
2671 dev_printk(KERN_DEBUG, &instance->pdev->dev, "SR-IOV: Couldn't allocate" in megasas_sriov_start_heartbeat()
2673 instance->host->host_no); in megasas_sriov_start_heartbeat()
2691 megasas_set_dma_settings(instance, dcmd, instance->hb_host_mem_h, in megasas_sriov_start_heartbeat()
2694 dev_warn(&instance->pdev->dev, "SR-IOV: Starting heartbeat for scsi%d\n", in megasas_sriov_start_heartbeat()
2695 instance->host->host_no); in megasas_sriov_start_heartbeat()
2697 if ((instance->adapter_type != MFI_SERIES) && in megasas_sriov_start_heartbeat()
2698 !instance->mask_interrupts) in megasas_sriov_start_heartbeat()
2699 retval = megasas_issue_blocked_cmd(instance, cmd, in megasas_sriov_start_heartbeat()
2702 retval = megasas_issue_polled(instance, cmd); in megasas_sriov_start_heartbeat()
2705 dev_warn(&instance->pdev->dev, "SR-IOV: MR_DCMD_CTRL_SHARED_HOST" in megasas_sriov_start_heartbeat()
2708 "timed out" : "failed", instance->host->host_no); in megasas_sriov_start_heartbeat()
2713 megasas_return_cmd(instance, cmd); in megasas_sriov_start_heartbeat()
2721 struct megasas_instance *instance = in megasas_sriov_heartbeat_handler() local
2722 from_timer(instance, t, sriov_heartbeat_timer); in megasas_sriov_heartbeat_handler()
2724 if (instance->hb_host_mem->HB.fwCounter != in megasas_sriov_heartbeat_handler()
2725 instance->hb_host_mem->HB.driverCounter) { in megasas_sriov_heartbeat_handler()
2726 instance->hb_host_mem->HB.driverCounter = in megasas_sriov_heartbeat_handler()
2727 instance->hb_host_mem->HB.fwCounter; in megasas_sriov_heartbeat_handler()
2728 mod_timer(&instance->sriov_heartbeat_timer, in megasas_sriov_heartbeat_handler()
2731 dev_warn(&instance->pdev->dev, "SR-IOV: Heartbeat never " in megasas_sriov_heartbeat_handler()
2732 "completed for scsi%d\n", instance->host->host_no); in megasas_sriov_heartbeat_handler()
2733 schedule_work(&instance->work_init); in megasas_sriov_heartbeat_handler()
2745 static int megasas_wait_for_outstanding(struct megasas_instance *instance) in megasas_wait_for_outstanding() argument
2755 if (atomic_read(&instance->adprecovery) == MEGASAS_HW_CRITICAL_ERROR) { in megasas_wait_for_outstanding()
2756 dev_info(&instance->pdev->dev, "%s:%d HBA is killed.\n", in megasas_wait_for_outstanding()
2761 if (atomic_read(&instance->adprecovery) != MEGASAS_HBA_OPERATIONAL) { in megasas_wait_for_outstanding()
2764 spin_lock_irqsave(&instance->hba_lock, flags); in megasas_wait_for_outstanding()
2765 list_splice_init(&instance->internal_reset_pending_q, in megasas_wait_for_outstanding()
2767 spin_unlock_irqrestore(&instance->hba_lock, flags); in megasas_wait_for_outstanding()
2769 dev_notice(&instance->pdev->dev, "HBA reset wait ...\n"); in megasas_wait_for_outstanding()
2772 if (atomic_read(&instance->adprecovery) == MEGASAS_HBA_OPERATIONAL) in megasas_wait_for_outstanding()
2776 if (atomic_read(&instance->adprecovery) != MEGASAS_HBA_OPERATIONAL) { in megasas_wait_for_outstanding()
2777 dev_notice(&instance->pdev->dev, "reset: Stopping HBA.\n"); in megasas_wait_for_outstanding()
2778 atomic_set(&instance->adprecovery, MEGASAS_HW_CRITICAL_ERROR); in megasas_wait_for_outstanding()
2789 dev_notice(&instance->pdev->dev, "%d:%p reset [%02x]\n", in megasas_wait_for_outstanding()
2794 megasas_return_cmd(instance, reset_cmd); in megasas_wait_for_outstanding()
2796 dev_notice(&instance->pdev->dev, "%p synch cmds" in megasas_wait_for_outstanding()
2801 instance->instancet->fire_cmd(instance, in megasas_wait_for_outstanding()
2803 0, instance->reg_set); in megasas_wait_for_outstanding()
2805 dev_notice(&instance->pdev->dev, "%p unexpected" in megasas_wait_for_outstanding()
2816 outstanding = atomic_read(&instance->fw_outstanding); in megasas_wait_for_outstanding()
2822 dev_notice(&instance->pdev->dev, "[%2d]waiting for %d " in megasas_wait_for_outstanding()
2828 megasas_complete_cmd_dpc((unsigned long)instance); in megasas_wait_for_outstanding()
2835 outstanding = atomic_read(&instance->fw_outstanding); in megasas_wait_for_outstanding()
2836 fw_state = instance->instancet->read_fw_status_reg(instance) & MFI_STATE_MASK; in megasas_wait_for_outstanding()
2841 if (instance->disableOnlineCtrlReset) in megasas_wait_for_outstanding()
2844 if ((fw_state == MFI_STATE_FAULT) || atomic_read(&instance->fw_outstanding)) { in megasas_wait_for_outstanding()
2845 dev_info(&instance->pdev->dev, in megasas_wait_for_outstanding()
2847 __func__, __LINE__, fw_state, atomic_read(&instance->fw_outstanding)); in megasas_wait_for_outstanding()
2850 megasas_do_ocr(instance); in megasas_wait_for_outstanding()
2852 if (atomic_read(&instance->adprecovery) == MEGASAS_HW_CRITICAL_ERROR) { in megasas_wait_for_outstanding()
2853 dev_info(&instance->pdev->dev, "%s:%d OCR failed and HBA is killed.\n", in megasas_wait_for_outstanding()
2857 dev_info(&instance->pdev->dev, "%s:%d waiting_for_outstanding: after issue OCR.\n", in megasas_wait_for_outstanding()
2863 outstanding = atomic_read(&instance->fw_outstanding); in megasas_wait_for_outstanding()
2865 fw_state = instance->instancet->read_fw_status_reg(instance) & MFI_STATE_MASK; in megasas_wait_for_outstanding()
2874 dev_info(&instance->pdev->dev, "%s:%d no more pending commands remain after reset handling.\n", in megasas_wait_for_outstanding()
2881 dev_info(&instance->pdev->dev, "%s:%d killing adapter scsi%d" in megasas_wait_for_outstanding()
2883 __func__, __LINE__, instance->host->host_no, instance->disableOnlineCtrlReset, in megasas_wait_for_outstanding()
2884 atomic_read(&instance->fw_outstanding)); in megasas_wait_for_outstanding()
2885 megasas_dump_pending_frames(instance); in megasas_wait_for_outstanding()
2886 megaraid_sas_kill_hba(instance); in megasas_wait_for_outstanding()
2902 struct megasas_instance *instance; in megasas_generic_reset() local
2904 instance = (struct megasas_instance *)scmd->device->host->hostdata; in megasas_generic_reset()
2909 if (atomic_read(&instance->adprecovery) == MEGASAS_HW_CRITICAL_ERROR) { in megasas_generic_reset()
2910 dev_err(&instance->pdev->dev, "cannot recover from previous reset failures\n"); in megasas_generic_reset()
2914 ret_val = megasas_wait_for_outstanding(instance); in megasas_generic_reset()
2916 dev_notice(&instance->pdev->dev, "reset successful\n"); in megasas_generic_reset()
2918 dev_err(&instance->pdev->dev, "failed to do reset\n"); in megasas_generic_reset()
2933 struct megasas_instance *instance; in megasas_reset_timer() local
2941 instance = (struct megasas_instance *)scmd->device->host->hostdata; in megasas_reset_timer()
2942 if (!(instance->flag & MEGASAS_FW_BUSY)) { in megasas_reset_timer()
2944 spin_lock_irqsave(instance->host->host_lock, flags); in megasas_reset_timer()
2946 instance->host->can_queue = instance->throttlequeuedepth; in megasas_reset_timer()
2947 instance->last_time = jiffies; in megasas_reset_timer()
2948 instance->flag |= MEGASAS_FW_BUSY; in megasas_reset_timer()
2950 spin_unlock_irqrestore(instance->host->host_lock, flags); in megasas_reset_timer()
3004 struct megasas_instance *instance; in megasas_dump_fusion_io() local
3006 instance = (struct megasas_instance *)scmd->device->host->hostdata; in megasas_dump_fusion_io()
3027 instance->max_chain_frame_sz, 8); in megasas_dump_fusion_io()
3063 struct megasas_instance *instance; in megasas_reset_bus_host() local
3065 instance = (struct megasas_instance *)scmd->device->host->hostdata; in megasas_reset_bus_host()
3074 atomic_read(&instance->fw_outstanding)); in megasas_reset_bus_host()
3078 if (instance->adapter_type == MFI_SERIES) { in megasas_reset_bus_host()
3097 struct megasas_instance *instance; in megasas_task_abort() local
3099 instance = (struct megasas_instance *)scmd->device->host->hostdata; in megasas_task_abort()
3101 if (instance->adapter_type != MFI_SERIES) in megasas_task_abort()
3119 struct megasas_instance *instance; in megasas_reset_target() local
3121 instance = (struct megasas_instance *)scmd->device->host->hostdata; in megasas_reset_target()
3123 if (instance->adapter_type != MFI_SERIES) in megasas_reset_target()
3179 struct megasas_instance *instance; in megasas_map_queues() local
3183 instance = (struct megasas_instance *)shost->hostdata; in megasas_map_queues()
3188 offset = instance->low_latency_index_start; in megasas_map_queues()
3192 map->nr_queues = instance->msix_vectors - offset; in megasas_map_queues()
3194 blk_mq_pci_map_queues(map, instance->pdev, offset); in megasas_map_queues()
3203 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
3282 spin_lock_irqsave(&instance->crashdump_lock, flags); in fw_crash_buffer_store()
3283 instance->fw_crash_buffer_offset = val; in fw_crash_buffer_store()
3284 spin_unlock_irqrestore(&instance->crashdump_lock, flags); in fw_crash_buffer_store()
3293 struct megasas_instance *instance = in fw_crash_buffer_show() local
3302 spin_lock_irqsave(&instance->crashdump_lock, flags); in fw_crash_buffer_show()
3303 buff_offset = instance->fw_crash_buffer_offset; in fw_crash_buffer_show()
3304 if (!instance->crash_dump_buf && in fw_crash_buffer_show()
3305 !((instance->fw_crash_state == AVAILABLE) || in fw_crash_buffer_show()
3306 (instance->fw_crash_state == COPYING))) { in fw_crash_buffer_show()
3307 dev_err(&instance->pdev->dev, in fw_crash_buffer_show()
3309 spin_unlock_irqrestore(&instance->crashdump_lock, flags); in fw_crash_buffer_show()
3313 if (buff_offset > (instance->fw_crash_buffer_size * dmachunk)) { in fw_crash_buffer_show()
3314 dev_err(&instance->pdev->dev, in fw_crash_buffer_show()
3316 spin_unlock_irqrestore(&instance->crashdump_lock, flags); in fw_crash_buffer_show()
3320 size = (instance->fw_crash_buffer_size * dmachunk) - buff_offset; in fw_crash_buffer_show()
3325 src_addr = (unsigned long)instance->crash_buf[buff_offset / dmachunk] + in fw_crash_buffer_show()
3328 spin_unlock_irqrestore(&instance->crashdump_lock, flags); in fw_crash_buffer_show()
3338 struct megasas_instance *instance = in fw_crash_buffer_size_show() local
3342 ((instance->fw_crash_buffer_size) * 1024 * 1024)/PAGE_SIZE); in fw_crash_buffer_size_show()
3350 struct megasas_instance *instance = in fw_crash_state_store() local
3359 dev_err(&instance->pdev->dev, "application updates invalid " in fw_crash_state_store()
3364 instance->fw_crash_state = val; in fw_crash_state_store()
3367 spin_lock_irqsave(&instance->crashdump_lock, flags); in fw_crash_state_store()
3368 megasas_free_host_crash_buffer(instance); in fw_crash_state_store()
3369 spin_unlock_irqrestore(&instance->crashdump_lock, flags); in fw_crash_state_store()
3371 dev_info(&instance->pdev->dev, "application failed to " in fw_crash_state_store()
3374 dev_info(&instance->pdev->dev, "Firmware crash dump " in fw_crash_state_store()
3385 struct megasas_instance *instance = in fw_crash_state_show() local
3388 return snprintf(buf, PAGE_SIZE, "%d\n", instance->fw_crash_state); in fw_crash_state_show()
3403 struct megasas_instance *instance = (struct megasas_instance *)shost->hostdata; in ldio_outstanding_show() local
3405 return snprintf(buf, PAGE_SIZE, "%d\n", atomic_read(&instance->ldio_outstanding)); in ldio_outstanding_show()
3413 struct megasas_instance *instance = (struct megasas_instance *)shost->hostdata; in fw_cmds_outstanding_show() local
3415 return snprintf(buf, PAGE_SIZE, "%d\n", atomic_read(&instance->fw_outstanding)); in fw_cmds_outstanding_show()
3423 struct megasas_instance *instance = (struct megasas_instance *)shost->hostdata; in enable_sdev_max_qd_show() local
3425 return snprintf(buf, PAGE_SIZE, "%d\n", instance->enable_sdev_max_qd); in enable_sdev_max_qd_show()
3433 struct megasas_instance *instance = (struct megasas_instance *)shost->hostdata; in enable_sdev_max_qd_store() local
3444 mutex_lock(&instance->reset_mutex); in enable_sdev_max_qd_store()
3446 instance->enable_sdev_max_qd = true; in enable_sdev_max_qd_store()
3448 instance->enable_sdev_max_qd = false; in enable_sdev_max_qd_store()
3451 ret_target_prop = megasas_get_target_prop(instance, sdev); in enable_sdev_max_qd_store()
3455 mutex_unlock(&instance->reset_mutex); in enable_sdev_max_qd_store()
3465 struct megasas_instance *instance = in dump_system_regs_show() local
3468 return megasas_dump_sys_regs(instance->reg_set, buf); in dump_system_regs_show()
3476 struct megasas_instance *instance = in raid_map_id_show() local
3480 (unsigned long)instance->map_id); in raid_map_id_show()
3543 megasas_complete_int_cmd(struct megasas_instance *instance, in megasas_complete_int_cmd() argument
3551 wake_up(&instance->int_cmd_wait_q); in megasas_complete_int_cmd()
3564 megasas_complete_abort(struct megasas_instance *instance, in megasas_complete_abort() argument
3570 wake_up(&instance->abort_cmd_wait_q); in megasas_complete_abort()
3575 megasas_set_ld_removed_by_fw(struct megasas_instance *instance) in megasas_set_ld_removed_by_fw() argument
3580 if (instance->ld_ids_prev[i] != 0xff && in megasas_set_ld_removed_by_fw()
3581 instance->ld_ids_from_raidmap[i] == 0xff) { in megasas_set_ld_removed_by_fw()
3583 dev_info(&instance->pdev->dev, in megasas_set_ld_removed_by_fw()
3585 instance->ld_tgtid_status[i] = LD_TARGET_ID_DELETED; in megasas_set_ld_removed_by_fw()
3601 megasas_complete_cmd(struct megasas_instance *instance, struct megasas_cmd *cmd, in megasas_complete_cmd() argument
3607 struct fusion_context *fusion = instance->ctrl_context; in megasas_complete_cmd()
3622 dev_warn(&instance->pdev->dev, "MFI_CMD_INVALID command " in megasas_complete_cmd()
3624 dev_warn(&instance->pdev->dev, "If you have a controller " in megasas_complete_cmd()
3637 megasas_complete_int_cmd(instance, cmd); in megasas_complete_cmd()
3652 atomic_dec(&instance->fw_outstanding); in megasas_complete_cmd()
3656 megasas_return_cmd(instance, cmd); in megasas_complete_cmd()
3692 dev_printk(KERN_DEBUG, &instance->pdev->dev, "MFI FW status %#x\n", in megasas_complete_cmd()
3698 atomic_dec(&instance->fw_outstanding); in megasas_complete_cmd()
3702 megasas_return_cmd(instance, cmd); in megasas_complete_cmd()
3710 megasas_complete_int_cmd(instance, cmd); in megasas_complete_cmd()
3719 spin_lock_irqsave(instance->host->host_lock, flags); in megasas_complete_cmd()
3721 instance->map_update_cmd = NULL; in megasas_complete_cmd()
3724 dev_warn(&instance->pdev->dev, "map syncfailed, status = 0x%x\n", in megasas_complete_cmd()
3727 megasas_return_cmd(instance, cmd); in megasas_complete_cmd()
3729 instance->host->host_lock, in megasas_complete_cmd()
3735 megasas_return_cmd(instance, cmd); in megasas_complete_cmd()
3743 (MR_ValidateMapInfo(instance, (instance->map_id + 1)))) { in megasas_complete_cmd()
3744 instance->map_id++; in megasas_complete_cmd()
3750 if (instance->adapter_type >= INVADER_SERIES) in megasas_complete_cmd()
3751 megasas_set_ld_removed_by_fw(instance); in megasas_complete_cmd()
3753 megasas_sync_map_info(instance); in megasas_complete_cmd()
3754 spin_unlock_irqrestore(instance->host->host_lock, in megasas_complete_cmd()
3770 spin_lock_irqsave(instance->host->host_lock, flags); in megasas_complete_cmd()
3772 instance->jbod_seq_cmd = NULL; in megasas_complete_cmd()
3773 megasas_return_cmd(instance, cmd); in megasas_complete_cmd()
3776 instance->pd_seq_map_id++; in megasas_complete_cmd()
3778 if (megasas_sync_pd_seq_num(instance, true)) in megasas_complete_cmd()
3779 instance->use_seqnum_jbod_fp = false; in megasas_complete_cmd()
3781 instance->use_seqnum_jbod_fp = false; in megasas_complete_cmd()
3783 spin_unlock_irqrestore(instance->host->host_lock, flags); in megasas_complete_cmd()
3791 megasas_service_aen(instance, cmd); in megasas_complete_cmd()
3793 megasas_complete_int_cmd(instance, cmd); in megasas_complete_cmd()
3801 megasas_complete_abort(instance, cmd); in megasas_complete_cmd()
3805 dev_info(&instance->pdev->dev, "Unknown command completed! [0x%X]\n", in megasas_complete_cmd()
3807 megasas_complete_int_cmd(instance, cmd); in megasas_complete_cmd()
3818 megasas_issue_pending_cmds_again(struct megasas_instance *instance) in megasas_issue_pending_cmds_again() argument
3827 spin_lock_irqsave(&instance->hba_lock, flags); in megasas_issue_pending_cmds_again()
3828 list_splice_init(&instance->internal_reset_pending_q, &clist_local); in megasas_issue_pending_cmds_again()
3829 spin_unlock_irqrestore(&instance->hba_lock, flags); in megasas_issue_pending_cmds_again()
3837 dev_notice(&instance->pdev->dev, "command %p, %p:%d" in megasas_issue_pending_cmds_again()
3844 dev_notice(&instance->pdev->dev, "cmd %p, %p:%d" in megasas_issue_pending_cmds_again()
3848 instance->instancet->disable_intr(instance); in megasas_issue_pending_cmds_again()
3849 atomic_set(&instance->fw_reset_no_pci_access, 1); in megasas_issue_pending_cmds_again()
3850 megaraid_sas_kill_hba(instance); in megasas_issue_pending_cmds_again()
3857 dev_notice(&instance->pdev->dev, "unexpected" in megasas_issue_pending_cmds_again()
3860 dev_notice(&instance->pdev->dev, "%p synchronous cmd" in megasas_issue_pending_cmds_again()
3864 instance->instancet->fire_cmd(instance, in megasas_issue_pending_cmds_again()
3866 0, instance->reg_set); in megasas_issue_pending_cmds_again()
3868 dev_notice(&instance->pdev->dev, "%p scsi cmd [%02x]" in megasas_issue_pending_cmds_again()
3872 atomic_inc(&instance->fw_outstanding); in megasas_issue_pending_cmds_again()
3873 instance->instancet->fire_cmd(instance, in megasas_issue_pending_cmds_again()
3875 cmd->frame_count-1, instance->reg_set); in megasas_issue_pending_cmds_again()
3877 dev_notice(&instance->pdev->dev, "%p unexpected cmd on the" in megasas_issue_pending_cmds_again()
3883 if (instance->aen_cmd) { in megasas_issue_pending_cmds_again()
3884 dev_notice(&instance->pdev->dev, "aen_cmd in def process\n"); in megasas_issue_pending_cmds_again()
3885 megasas_return_cmd(instance, instance->aen_cmd); in megasas_issue_pending_cmds_again()
3887 instance->aen_cmd = NULL; in megasas_issue_pending_cmds_again()
3893 seq_num = instance->last_seq_num; in megasas_issue_pending_cmds_again()
3898 megasas_register_aen(instance, seq_num, class_locale.word); in megasas_issue_pending_cmds_again()
3911 megasas_internal_reset_defer_cmds(struct megasas_instance *instance) in megasas_internal_reset_defer_cmds() argument
3915 u16 max_cmd = instance->max_fw_cmds; in megasas_internal_reset_defer_cmds()
3920 spin_lock_irqsave(&instance->mfi_pool_lock, flags); in megasas_internal_reset_defer_cmds()
3922 cmd = instance->cmd_list[i]; in megasas_internal_reset_defer_cmds()
3924 dev_notice(&instance->pdev->dev, "moving cmd[%d]:%p:%d:%p" in megasas_internal_reset_defer_cmds()
3929 dev_notice(&instance->pdev->dev, "ERROR while" in megasas_internal_reset_defer_cmds()
3938 &instance->internal_reset_pending_q); in megasas_internal_reset_defer_cmds()
3941 spin_unlock_irqrestore(&instance->mfi_pool_lock, flags); in megasas_internal_reset_defer_cmds()
3948 struct megasas_instance *instance = in process_fw_state_change_wq() local
3953 if (atomic_read(&instance->adprecovery) != MEGASAS_ADPRESET_SM_INFAULT) { in process_fw_state_change_wq()
3954 dev_notice(&instance->pdev->dev, "error, recovery st %x\n", in process_fw_state_change_wq()
3955 atomic_read(&instance->adprecovery)); in process_fw_state_change_wq()
3959 if (atomic_read(&instance->adprecovery) == MEGASAS_ADPRESET_SM_INFAULT) { in process_fw_state_change_wq()
3960 dev_notice(&instance->pdev->dev, "FW detected to be in fault" in process_fw_state_change_wq()
3963 instance->instancet->disable_intr(instance); in process_fw_state_change_wq()
3964 atomic_set(&instance->fw_outstanding, 0); in process_fw_state_change_wq()
3966 atomic_set(&instance->fw_reset_no_pci_access, 1); in process_fw_state_change_wq()
3967 instance->instancet->adp_reset(instance, instance->reg_set); in process_fw_state_change_wq()
3968 atomic_set(&instance->fw_reset_no_pci_access, 0); in process_fw_state_change_wq()
3970 dev_notice(&instance->pdev->dev, "FW restarted successfully," in process_fw_state_change_wq()
3973 dev_notice(&instance->pdev->dev, "HBA recovery state machine," in process_fw_state_change_wq()
3981 if (megasas_transition_to_ready(instance, 1)) { in process_fw_state_change_wq()
3982 dev_notice(&instance->pdev->dev, "adapter not ready\n"); in process_fw_state_change_wq()
3984 atomic_set(&instance->fw_reset_no_pci_access, 1); in process_fw_state_change_wq()
3985 megaraid_sas_kill_hba(instance); in process_fw_state_change_wq()
3989 if ((instance->pdev->device == PCI_DEVICE_ID_LSI_SAS1064R) || in process_fw_state_change_wq()
3990 (instance->pdev->device == PCI_DEVICE_ID_DELL_PERC5) || in process_fw_state_change_wq()
3991 (instance->pdev->device == PCI_DEVICE_ID_LSI_VERDE_ZCR) in process_fw_state_change_wq()
3993 *instance->consumer = *instance->producer; in process_fw_state_change_wq()
3995 *instance->consumer = 0; in process_fw_state_change_wq()
3996 *instance->producer = 0; in process_fw_state_change_wq()
3999 megasas_issue_init_mfi(instance); in process_fw_state_change_wq()
4001 spin_lock_irqsave(&instance->hba_lock, flags); in process_fw_state_change_wq()
4002 atomic_set(&instance->adprecovery, MEGASAS_HBA_OPERATIONAL); in process_fw_state_change_wq()
4003 spin_unlock_irqrestore(&instance->hba_lock, flags); in process_fw_state_change_wq()
4004 instance->instancet->enable_intr(instance); in process_fw_state_change_wq()
4006 megasas_issue_pending_cmds_again(instance); in process_fw_state_change_wq()
4007 instance->issuepend_done = 1; in process_fw_state_change_wq()
4020 megasas_deplete_reply_queue(struct megasas_instance *instance, in megasas_deplete_reply_queue() argument
4026 if ((mfiStatus = instance->instancet->check_reset(instance, in megasas_deplete_reply_queue()
4027 instance->reg_set)) == 1) { in megasas_deplete_reply_queue()
4031 mfiStatus = instance->instancet->clear_intr(instance); in megasas_deplete_reply_queue()
4034 if (!instance->msix_vectors) in megasas_deplete_reply_queue()
4038 instance->mfiStatus = mfiStatus; in megasas_deplete_reply_queue()
4041 fw_state = instance->instancet->read_fw_status_reg( in megasas_deplete_reply_queue()
4042 instance) & MFI_STATE_MASK; in megasas_deplete_reply_queue()
4045 dev_notice(&instance->pdev->dev, "fw state:%x\n", in megasas_deplete_reply_queue()
4050 (instance->disableOnlineCtrlReset == 0)) { in megasas_deplete_reply_queue()
4051 dev_notice(&instance->pdev->dev, "wait adp restart\n"); in megasas_deplete_reply_queue()
4053 if ((instance->pdev->device == in megasas_deplete_reply_queue()
4055 (instance->pdev->device == in megasas_deplete_reply_queue()
4057 (instance->pdev->device == in megasas_deplete_reply_queue()
4060 *instance->consumer = in megasas_deplete_reply_queue()
4065 instance->instancet->disable_intr(instance); in megasas_deplete_reply_queue()
4066 atomic_set(&instance->adprecovery, MEGASAS_ADPRESET_SM_INFAULT); in megasas_deplete_reply_queue()
4067 instance->issuepend_done = 0; in megasas_deplete_reply_queue()
4069 atomic_set(&instance->fw_outstanding, 0); in megasas_deplete_reply_queue()
4070 megasas_internal_reset_defer_cmds(instance); in megasas_deplete_reply_queue()
4072 dev_notice(&instance->pdev->dev, "fwState=%x, stage:%d\n", in megasas_deplete_reply_queue()
4073 fw_state, atomic_read(&instance->adprecovery)); in megasas_deplete_reply_queue()
4075 schedule_work(&instance->work_init); in megasas_deplete_reply_queue()
4079 dev_notice(&instance->pdev->dev, "fwstate:%x, dis_OCR=%x\n", in megasas_deplete_reply_queue()
4080 fw_state, instance->disableOnlineCtrlReset); in megasas_deplete_reply_queue()
4084 tasklet_schedule(&instance->isr_tasklet); in megasas_deplete_reply_queue()
4096 struct megasas_instance *instance = irq_context->instance; in megasas_isr() local
4100 if (atomic_read(&instance->fw_reset_no_pci_access)) in megasas_isr()
4103 spin_lock_irqsave(&instance->hba_lock, flags); in megasas_isr()
4104 rc = megasas_deplete_reply_queue(instance, DID_OK); in megasas_isr()
4105 spin_unlock_irqrestore(&instance->hba_lock, flags); in megasas_isr()
4121 megasas_transition_to_ready(struct megasas_instance *instance, int ocr) in megasas_transition_to_ready() argument
4128 abs_state = instance->instancet->read_fw_status_reg(instance); in megasas_transition_to_ready()
4132 dev_info(&instance->pdev->dev, "Waiting for FW to come to ready" in megasas_transition_to_ready()
4140 dev_printk(KERN_ERR, &instance->pdev->dev, in megasas_transition_to_ready()
4148 dev_printk(KERN_DEBUG, &instance->pdev->dev, "System Register set:\n"); in megasas_transition_to_ready()
4149 megasas_dump_reg_set(instance->reg_set); in megasas_transition_to_ready()
4157 if ((instance->pdev->device == in megasas_transition_to_ready()
4159 (instance->pdev->device == in megasas_transition_to_ready()
4161 (instance->adapter_type != MFI_SERIES)) in megasas_transition_to_ready()
4164 &instance->reg_set->doorbell); in megasas_transition_to_ready()
4168 &instance->reg_set->inbound_doorbell); in megasas_transition_to_ready()
4174 if ((instance->pdev->device == in megasas_transition_to_ready()
4176 (instance->pdev->device == in megasas_transition_to_ready()
4178 (instance->adapter_type != MFI_SERIES)) in megasas_transition_to_ready()
4180 &instance->reg_set->doorbell); in megasas_transition_to_ready()
4183 &instance->reg_set->inbound_doorbell); in megasas_transition_to_ready()
4192 instance->instancet->disable_intr(instance); in megasas_transition_to_ready()
4193 if ((instance->pdev->device == in megasas_transition_to_ready()
4195 (instance->pdev->device == in megasas_transition_to_ready()
4197 (instance->adapter_type != MFI_SERIES)) { in megasas_transition_to_ready()
4199 &instance->reg_set->doorbell); in megasas_transition_to_ready()
4201 if (instance->adapter_type != MFI_SERIES) { in megasas_transition_to_ready()
4204 instance, in megasas_transition_to_ready()
4205 &instance-> in megasas_transition_to_ready()
4215 &instance->reg_set->inbound_doorbell); in megasas_transition_to_ready()
4248 dev_printk(KERN_DEBUG, &instance->pdev->dev, "Unknown state 0x%x\n", in megasas_transition_to_ready()
4250 dev_printk(KERN_DEBUG, &instance->pdev->dev, "System Register set:\n"); in megasas_transition_to_ready()
4251 megasas_dump_reg_set(instance->reg_set); in megasas_transition_to_ready()
4259 curr_abs_state = instance->instancet-> in megasas_transition_to_ready()
4260 read_fw_status_reg(instance); in megasas_transition_to_ready()
4272 dev_printk(KERN_DEBUG, &instance->pdev->dev, "FW state [%d] hasn't changed " in megasas_transition_to_ready()
4274 dev_printk(KERN_DEBUG, &instance->pdev->dev, "System Register set:\n"); in megasas_transition_to_ready()
4275 megasas_dump_reg_set(instance->reg_set); in megasas_transition_to_ready()
4282 dev_info(&instance->pdev->dev, "FW now in Ready state\n"); in megasas_transition_to_ready()
4291 static void megasas_teardown_frame_pool(struct megasas_instance *instance) in megasas_teardown_frame_pool() argument
4294 u16 max_cmd = instance->max_mfi_cmds; in megasas_teardown_frame_pool()
4297 if (!instance->frame_dma_pool) in megasas_teardown_frame_pool()
4305 cmd = instance->cmd_list[i]; in megasas_teardown_frame_pool()
4308 dma_pool_free(instance->frame_dma_pool, cmd->frame, in megasas_teardown_frame_pool()
4312 dma_pool_free(instance->sense_dma_pool, cmd->sense, in megasas_teardown_frame_pool()
4319 dma_pool_destroy(instance->frame_dma_pool); in megasas_teardown_frame_pool()
4320 dma_pool_destroy(instance->sense_dma_pool); in megasas_teardown_frame_pool()
4322 instance->frame_dma_pool = NULL; in megasas_teardown_frame_pool()
4323 instance->sense_dma_pool = NULL; in megasas_teardown_frame_pool()
4335 static int megasas_create_frame_pool(struct megasas_instance *instance) in megasas_create_frame_pool() argument
4342 max_cmd = instance->max_mfi_cmds; in megasas_create_frame_pool()
4355 frame_count = (instance->adapter_type == MFI_SERIES) ? in megasas_create_frame_pool()
4357 instance->mfi_frame_size = MEGAMFI_FRAME_SIZE * frame_count; in megasas_create_frame_pool()
4361 instance->frame_dma_pool = dma_pool_create("megasas frame pool", in megasas_create_frame_pool()
4362 &instance->pdev->dev, in megasas_create_frame_pool()
4363 instance->mfi_frame_size, 256, 0); in megasas_create_frame_pool()
4365 if (!instance->frame_dma_pool) { in megasas_create_frame_pool()
4366 dev_printk(KERN_DEBUG, &instance->pdev->dev, "failed to setup frame pool\n"); in megasas_create_frame_pool()
4370 instance->sense_dma_pool = dma_pool_create("megasas sense pool", in megasas_create_frame_pool()
4371 &instance->pdev->dev, 128, in megasas_create_frame_pool()
4374 if (!instance->sense_dma_pool) { in megasas_create_frame_pool()
4375 dev_printk(KERN_DEBUG, &instance->pdev->dev, "failed to setup sense pool\n"); in megasas_create_frame_pool()
4377 dma_pool_destroy(instance->frame_dma_pool); in megasas_create_frame_pool()
4378 instance->frame_dma_pool = NULL; in megasas_create_frame_pool()
4390 cmd = instance->cmd_list[i]; in megasas_create_frame_pool()
4392 cmd->frame = dma_pool_zalloc(instance->frame_dma_pool, in megasas_create_frame_pool()
4395 cmd->sense = dma_pool_alloc(instance->sense_dma_pool, in megasas_create_frame_pool()
4403 dev_printk(KERN_DEBUG, &instance->pdev->dev, "dma_pool_alloc failed\n"); in megasas_create_frame_pool()
4404 megasas_teardown_frame_pool(instance); in megasas_create_frame_pool()
4410 if ((instance->adapter_type == MFI_SERIES) && reset_devices) in megasas_create_frame_pool()
4421 void megasas_free_cmds(struct megasas_instance *instance) in megasas_free_cmds() argument
4426 megasas_teardown_frame_pool(instance); in megasas_free_cmds()
4429 for (i = 0; i < instance->max_mfi_cmds; i++) in megasas_free_cmds()
4431 kfree(instance->cmd_list[i]); in megasas_free_cmds()
4434 kfree(instance->cmd_list); in megasas_free_cmds()
4435 instance->cmd_list = NULL; in megasas_free_cmds()
4437 INIT_LIST_HEAD(&instance->cmd_pool); in megasas_free_cmds()
4458 int megasas_alloc_cmds(struct megasas_instance *instance) in megasas_alloc_cmds() argument
4465 max_cmd = instance->max_mfi_cmds; in megasas_alloc_cmds()
4472 instance->cmd_list = kcalloc(max_cmd, sizeof(struct megasas_cmd*), GFP_KERNEL); in megasas_alloc_cmds()
4474 if (!instance->cmd_list) { in megasas_alloc_cmds()
4475 dev_printk(KERN_DEBUG, &instance->pdev->dev, "out of memory\n"); in megasas_alloc_cmds()
4480 instance->cmd_list[i] = kmalloc(sizeof(struct megasas_cmd), in megasas_alloc_cmds()
4483 if (!instance->cmd_list[i]) { in megasas_alloc_cmds()
4486 kfree(instance->cmd_list[j]); in megasas_alloc_cmds()
4488 kfree(instance->cmd_list); in megasas_alloc_cmds()
4489 instance->cmd_list = NULL; in megasas_alloc_cmds()
4496 cmd = instance->cmd_list[i]; in megasas_alloc_cmds()
4500 cmd->instance = instance; in megasas_alloc_cmds()
4502 list_add_tail(&cmd->list, &instance->cmd_pool); in megasas_alloc_cmds()
4508 if (megasas_create_frame_pool(instance)) { in megasas_alloc_cmds()
4509 dev_printk(KERN_DEBUG, &instance->pdev->dev, "Error creating frame DMA pool\n"); in megasas_alloc_cmds()
4510 megasas_free_cmds(instance); in megasas_alloc_cmds()
4525 dcmd_timeout_ocr_possible(struct megasas_instance *instance) { in dcmd_timeout_ocr_possible() argument
4527 if (instance->adapter_type == MFI_SERIES) in dcmd_timeout_ocr_possible()
4529 else if (instance->unload || in dcmd_timeout_ocr_possible()
4531 &instance->reset_flags)) in dcmd_timeout_ocr_possible()
4538 megasas_get_pd_info(struct megasas_instance *instance, struct scsi_device *sdev) in megasas_get_pd_info() argument
4548 cmd = megasas_get_cmd(instance); in megasas_get_pd_info()
4551 dev_err(&instance->pdev->dev, "Failed to get cmd %s\n", __func__); in megasas_get_pd_info()
4557 memset(instance->pd_info, 0, sizeof(*instance->pd_info)); in megasas_get_pd_info()
4570 megasas_set_dma_settings(instance, dcmd, instance->pd_info_h, in megasas_get_pd_info()
4573 if ((instance->adapter_type != MFI_SERIES) && in megasas_get_pd_info()
4574 !instance->mask_interrupts) in megasas_get_pd_info()
4575 ret = megasas_issue_blocked_cmd(instance, cmd, MFI_IO_TIMEOUT_SECS); in megasas_get_pd_info()
4577 ret = megasas_issue_polled(instance, cmd); in megasas_get_pd_info()
4582 le16_to_cpus((u16 *)&instance->pd_info->state.ddf.pdType); in megasas_get_pd_info()
4584 instance->pd_info->state.ddf.pdType.intf; in megasas_get_pd_info()
4589 switch (dcmd_timeout_ocr_possible(instance)) { in megasas_get_pd_info()
4592 mutex_unlock(&instance->reset_mutex); in megasas_get_pd_info()
4593 megasas_reset_fusion(instance->host, in megasas_get_pd_info()
4595 mutex_lock(&instance->reset_mutex); in megasas_get_pd_info()
4598 megaraid_sas_kill_hba(instance); in megasas_get_pd_info()
4601 dev_info(&instance->pdev->dev, "Ignore DCMD timeout: %s %d\n", in megasas_get_pd_info()
4610 megasas_return_cmd(instance, cmd); in megasas_get_pd_info()
4624 megasas_get_pd_list(struct megasas_instance *instance) in megasas_get_pd_list() argument
4632 if (instance->pd_list_not_supported) { in megasas_get_pd_list()
4633 dev_info(&instance->pdev->dev, "MR_DCMD_PD_LIST_QUERY " in megasas_get_pd_list()
4638 ci = instance->pd_list_buf; in megasas_get_pd_list()
4640 cmd = megasas_get_cmd(instance); in megasas_get_pd_list()
4643 dev_printk(KERN_DEBUG, &instance->pdev->dev, "(get_pd_list): Failed to get cmd\n"); in megasas_get_pd_list()
4663 megasas_set_dma_settings(instance, dcmd, instance->pd_list_buf_h, in megasas_get_pd_list()
4666 if ((instance->adapter_type != MFI_SERIES) && in megasas_get_pd_list()
4667 !instance->mask_interrupts) in megasas_get_pd_list()
4668 ret = megasas_issue_blocked_cmd(instance, cmd, in megasas_get_pd_list()
4671 ret = megasas_issue_polled(instance, cmd); in megasas_get_pd_list()
4675 dev_info(&instance->pdev->dev, "MR_DCMD_PD_LIST_QUERY " in megasas_get_pd_list()
4678 if (instance->adapter_type != MFI_SERIES) in megasas_get_pd_list()
4679 megaraid_sas_kill_hba(instance); in megasas_get_pd_list()
4681 instance->pd_list_not_supported = 1; in megasas_get_pd_list()
4685 switch (dcmd_timeout_ocr_possible(instance)) { in megasas_get_pd_list()
4693 mutex_unlock(&instance->reset_mutex); in megasas_get_pd_list()
4694 megasas_reset_fusion(instance->host, in megasas_get_pd_list()
4696 mutex_lock(&instance->reset_mutex); in megasas_get_pd_list()
4699 megaraid_sas_kill_hba(instance); in megasas_get_pd_list()
4702 dev_info(&instance->pdev->dev, "Ignore DCMD timeout: %s %d \n", in megasas_get_pd_list()
4712 dev_info(&instance->pdev->dev, "%s, sysPD count: 0x%x\n", in megasas_get_pd_list()
4719 memset(instance->local_pd_list, 0, in megasas_get_pd_list()
4723 instance->local_pd_list[le16_to_cpu(pd_addr->deviceId)].tid = in megasas_get_pd_list()
4725 instance->local_pd_list[le16_to_cpu(pd_addr->deviceId)].driveType = in megasas_get_pd_list()
4727 instance->local_pd_list[le16_to_cpu(pd_addr->deviceId)].driveState = in megasas_get_pd_list()
4730 dev_info(&instance->pdev->dev, in megasas_get_pd_list()
4737 memcpy(instance->pd_list, instance->local_pd_list, in megasas_get_pd_list()
4738 sizeof(instance->pd_list)); in megasas_get_pd_list()
4744 megasas_return_cmd(instance, cmd); in megasas_get_pd_list()
4759 megasas_get_ld_list(struct megasas_instance *instance) in megasas_get_ld_list() argument
4768 ci = instance->ld_list_buf; in megasas_get_ld_list()
4769 ci_h = instance->ld_list_buf_h; in megasas_get_ld_list()
4771 cmd = megasas_get_cmd(instance); in megasas_get_ld_list()
4774 dev_printk(KERN_DEBUG, &instance->pdev->dev, "megasas_get_ld_list: Failed to get cmd\n"); in megasas_get_ld_list()
4783 if (instance->supportmax256vd) in megasas_get_ld_list()
4794 megasas_set_dma_settings(instance, dcmd, ci_h, in megasas_get_ld_list()
4797 if ((instance->adapter_type != MFI_SERIES) && in megasas_get_ld_list()
4798 !instance->mask_interrupts) in megasas_get_ld_list()
4799 ret = megasas_issue_blocked_cmd(instance, cmd, in megasas_get_ld_list()
4802 ret = megasas_issue_polled(instance, cmd); in megasas_get_ld_list()
4808 megaraid_sas_kill_hba(instance); in megasas_get_ld_list()
4812 switch (dcmd_timeout_ocr_possible(instance)) { in megasas_get_ld_list()
4820 mutex_unlock(&instance->reset_mutex); in megasas_get_ld_list()
4821 megasas_reset_fusion(instance->host, in megasas_get_ld_list()
4823 mutex_lock(&instance->reset_mutex); in megasas_get_ld_list()
4826 megaraid_sas_kill_hba(instance); in megasas_get_ld_list()
4829 dev_info(&instance->pdev->dev, "Ignore DCMD timeout: %s %d\n", in megasas_get_ld_list()
4838 dev_info(&instance->pdev->dev, "%s, LD count: 0x%x\n", in megasas_get_ld_list()
4841 if (ld_count > instance->fw_supported_vd_count) in megasas_get_ld_list()
4844 memset(instance->ld_ids, 0xff, MAX_LOGICAL_DRIVES_EXT); in megasas_get_ld_list()
4849 instance->ld_ids[ids] = ci->ldList[ld_index].ref.targetId; in megasas_get_ld_list()
4851 dev_info(&instance->pdev->dev, in megasas_get_ld_list()
4861 megasas_return_cmd(instance, cmd); in megasas_get_ld_list()
4876 megasas_ld_list_query(struct megasas_instance *instance, u8 query_type) in megasas_ld_list_query() argument
4885 ci = instance->ld_targetid_list_buf; in megasas_ld_list_query()
4886 ci_h = instance->ld_targetid_list_buf_h; in megasas_ld_list_query()
4888 cmd = megasas_get_cmd(instance); in megasas_ld_list_query()
4891 dev_warn(&instance->pdev->dev, in megasas_ld_list_query()
4902 if (instance->supportmax256vd) in megasas_ld_list_query()
4914 megasas_set_dma_settings(instance, dcmd, ci_h, in megasas_ld_list_query()
4917 if ((instance->adapter_type != MFI_SERIES) && in megasas_ld_list_query()
4918 !instance->mask_interrupts) in megasas_ld_list_query()
4919 ret = megasas_issue_blocked_cmd(instance, cmd, MFI_IO_TIMEOUT_SECS); in megasas_ld_list_query()
4921 ret = megasas_issue_polled(instance, cmd); in megasas_ld_list_query()
4925 dev_info(&instance->pdev->dev, in megasas_ld_list_query()
4928 ret = megasas_get_ld_list(instance); in megasas_ld_list_query()
4931 switch (dcmd_timeout_ocr_possible(instance)) { in megasas_ld_list_query()
4939 mutex_unlock(&instance->reset_mutex); in megasas_ld_list_query()
4940 megasas_reset_fusion(instance->host, in megasas_ld_list_query()
4942 mutex_lock(&instance->reset_mutex); in megasas_ld_list_query()
4945 megaraid_sas_kill_hba(instance); in megasas_ld_list_query()
4948 dev_info(&instance->pdev->dev, "Ignore DCMD timeout: %s %d\n", in megasas_ld_list_query()
4958 dev_info(&instance->pdev->dev, "%s, LD count: 0x%x\n", in megasas_ld_list_query()
4961 if ((tgtid_count > (instance->fw_supported_vd_count))) in megasas_ld_list_query()
4964 memset(instance->ld_ids, 0xff, MEGASAS_MAX_LD_IDS); in megasas_ld_list_query()
4967 instance->ld_ids[ids] = ci->targetId[ld_index]; in megasas_ld_list_query()
4969 dev_info(&instance->pdev->dev, "LD%d: targetID: 0x%03x\n", in megasas_ld_list_query()
4977 megasas_return_cmd(instance, cmd); in megasas_ld_list_query()
4997 megasas_host_device_list_query(struct megasas_instance *instance, in megasas_host_device_list_query() argument
5007 ci = instance->host_device_list_buf; in megasas_host_device_list_query()
5008 ci_h = instance->host_device_list_buf_h; in megasas_host_device_list_query()
5010 cmd = megasas_get_cmd(instance); in megasas_host_device_list_query()
5013 dev_warn(&instance->pdev->dev, in megasas_host_device_list_query()
5034 megasas_set_dma_settings(instance, dcmd, ci_h, HOST_DEVICE_LIST_SZ); in megasas_host_device_list_query()
5036 if (!instance->mask_interrupts) { in megasas_host_device_list_query()
5037 ret = megasas_issue_blocked_cmd(instance, cmd, in megasas_host_device_list_query()
5040 ret = megasas_issue_polled(instance, cmd); in megasas_host_device_list_query()
5055 dev_info(&instance->pdev->dev, "%s, Device count: 0x%x\n", in megasas_host_device_list_query()
5058 memset(instance->local_pd_list, 0, in megasas_host_device_list_query()
5060 memset(instance->ld_ids, 0xff, MAX_LOGICAL_DRIVES_EXT); in megasas_host_device_list_query()
5064 instance->local_pd_list[target_id].tid = target_id; in megasas_host_device_list_query()
5065 instance->local_pd_list[target_id].driveType = in megasas_host_device_list_query()
5067 instance->local_pd_list[target_id].driveState = in megasas_host_device_list_query()
5070 dev_info(&instance->pdev->dev, in megasas_host_device_list_query()
5074 instance->ld_ids[target_id] = target_id; in megasas_host_device_list_query()
5076 dev_info(&instance->pdev->dev, in megasas_host_device_list_query()
5082 memcpy(instance->pd_list, instance->local_pd_list, in megasas_host_device_list_query()
5083 sizeof(instance->pd_list)); in megasas_host_device_list_query()
5087 switch (dcmd_timeout_ocr_possible(instance)) { in megasas_host_device_list_query()
5090 mutex_unlock(&instance->reset_mutex); in megasas_host_device_list_query()
5091 megasas_reset_fusion(instance->host, in megasas_host_device_list_query()
5093 mutex_lock(&instance->reset_mutex); in megasas_host_device_list_query()
5096 megaraid_sas_kill_hba(instance); in megasas_host_device_list_query()
5099 dev_info(&instance->pdev->dev, "Ignore DCMD timeout: %s %d\n", in megasas_host_device_list_query()
5105 dev_err(&instance->pdev->dev, in megasas_host_device_list_query()
5112 megasas_return_cmd(instance, cmd); in megasas_host_device_list_query()
5121 static void megasas_update_ext_vd_details(struct megasas_instance *instance) in megasas_update_ext_vd_details() argument
5126 fusion = instance->ctrl_context; in megasas_update_ext_vd_details()
5131 instance->supportmax256vd = in megasas_update_ext_vd_details()
5132 instance->ctrl_info_buf->adapterOperations3.supportMaxExtLDs; in megasas_update_ext_vd_details()
5134 if (instance->ctrl_info_buf->max_lds > 64) in megasas_update_ext_vd_details()
5135 instance->supportmax256vd = 1; in megasas_update_ext_vd_details()
5137 instance->drv_supported_vd_count = MEGASAS_MAX_LD_CHANNELS in megasas_update_ext_vd_details()
5139 instance->drv_supported_pd_count = MEGASAS_MAX_PD_CHANNELS in megasas_update_ext_vd_details()
5141 if (instance->supportmax256vd) { in megasas_update_ext_vd_details()
5142 instance->fw_supported_vd_count = MAX_LOGICAL_DRIVES_EXT; in megasas_update_ext_vd_details()
5143 instance->fw_supported_pd_count = MAX_PHYSICAL_DEVICES; in megasas_update_ext_vd_details()
5145 instance->fw_supported_vd_count = MAX_LOGICAL_DRIVES; in megasas_update_ext_vd_details()
5146 instance->fw_supported_pd_count = MAX_PHYSICAL_DEVICES; in megasas_update_ext_vd_details()
5149 dev_info(&instance->pdev->dev, in megasas_update_ext_vd_details()
5151 instance->ctrl_info_buf->adapterOperations3.supportMaxExtLDs ? 1 : 0, in megasas_update_ext_vd_details()
5152 instance->ctrl_info_buf->max_lds); in megasas_update_ext_vd_details()
5154 if (instance->max_raid_mapsize) { in megasas_update_ext_vd_details()
5155 ventura_map_sz = instance->max_raid_mapsize * in megasas_update_ext_vd_details()
5162 (instance->fw_supported_vd_count - 1)); in megasas_update_ext_vd_details()
5168 if (instance->supportmax256vd) in megasas_update_ext_vd_details()
5184 void megasas_get_snapdump_properties(struct megasas_instance *instance) in megasas_get_snapdump_properties() argument
5192 ci = instance->snapdump_prop; in megasas_get_snapdump_properties()
5193 ci_h = instance->snapdump_prop_h; in megasas_get_snapdump_properties()
5198 cmd = megasas_get_cmd(instance); in megasas_get_snapdump_properties()
5201 dev_dbg(&instance->pdev->dev, "Failed to get a free cmd\n"); in megasas_get_snapdump_properties()
5219 megasas_set_dma_settings(instance, dcmd, ci_h, in megasas_get_snapdump_properties()
5222 if (!instance->mask_interrupts) { in megasas_get_snapdump_properties()
5223 ret = megasas_issue_blocked_cmd(instance, cmd, in megasas_get_snapdump_properties()
5226 ret = megasas_issue_polled(instance, cmd); in megasas_get_snapdump_properties()
5232 instance->snapdump_wait_time = in megasas_get_snapdump_properties()
5238 switch (dcmd_timeout_ocr_possible(instance)) { in megasas_get_snapdump_properties()
5241 mutex_unlock(&instance->reset_mutex); in megasas_get_snapdump_properties()
5242 megasas_reset_fusion(instance->host, in megasas_get_snapdump_properties()
5244 mutex_lock(&instance->reset_mutex); in megasas_get_snapdump_properties()
5247 megaraid_sas_kill_hba(instance); in megasas_get_snapdump_properties()
5250 dev_info(&instance->pdev->dev, "Ignore DCMD timeout: %s %d\n", in megasas_get_snapdump_properties()
5257 megasas_return_cmd(instance, cmd); in megasas_get_snapdump_properties()
5269 megasas_get_ctrl_info(struct megasas_instance *instance) in megasas_get_ctrl_info() argument
5277 ci = instance->ctrl_info_buf; in megasas_get_ctrl_info()
5278 ci_h = instance->ctrl_info_buf_h; in megasas_get_ctrl_info()
5280 cmd = megasas_get_cmd(instance); in megasas_get_ctrl_info()
5283 dev_printk(KERN_DEBUG, &instance->pdev->dev, "Failed to get a free cmd\n"); in megasas_get_ctrl_info()
5302 megasas_set_dma_settings(instance, dcmd, ci_h, in megasas_get_ctrl_info()
5305 if ((instance->adapter_type != MFI_SERIES) && in megasas_get_ctrl_info()
5306 !instance->mask_interrupts) { in megasas_get_ctrl_info()
5307 ret = megasas_issue_blocked_cmd(instance, cmd, MFI_IO_TIMEOUT_SECS); in megasas_get_ctrl_info()
5309 ret = megasas_issue_polled(instance, cmd); in megasas_get_ctrl_info()
5330 megasas_update_ext_vd_details(instance); in megasas_get_ctrl_info()
5331 instance->support_seqnum_jbod_fp = in megasas_get_ctrl_info()
5333 instance->support_morethan256jbod = in megasas_get_ctrl_info()
5335 instance->support_nvme_passthru = in megasas_get_ctrl_info()
5337 instance->support_pci_lane_margining = in megasas_get_ctrl_info()
5339 instance->task_abort_tmo = ci->TaskAbortTO; in megasas_get_ctrl_info()
5340 instance->max_reset_tmo = ci->MaxResetTO; in megasas_get_ctrl_info()
5343 instance->is_imr = (ci->memory_size ? 0 : 1); in megasas_get_ctrl_info()
5345 instance->snapdump_wait_time = in megasas_get_ctrl_info()
5349 instance->enable_fw_dev_list = in megasas_get_ctrl_info()
5352 dev_info(&instance->pdev->dev, in megasas_get_ctrl_info()
5354 instance->is_imr ? "iMR" : "MR", in megasas_get_ctrl_info()
5357 instance->disableOnlineCtrlReset = in megasas_get_ctrl_info()
5359 instance->secure_jbod_support = in megasas_get_ctrl_info()
5361 dev_info(&instance->pdev->dev, "Online Controller Reset(OCR)\t: %s\n", in megasas_get_ctrl_info()
5362 instance->disableOnlineCtrlReset ? "Disabled" : "Enabled"); in megasas_get_ctrl_info()
5363 dev_info(&instance->pdev->dev, "Secure JBOD support\t: %s\n", in megasas_get_ctrl_info()
5364 instance->secure_jbod_support ? "Yes" : "No"); in megasas_get_ctrl_info()
5365 dev_info(&instance->pdev->dev, "NVMe passthru support\t: %s\n", in megasas_get_ctrl_info()
5366 instance->support_nvme_passthru ? "Yes" : "No"); in megasas_get_ctrl_info()
5367 dev_info(&instance->pdev->dev, in megasas_get_ctrl_info()
5369 instance->task_abort_tmo, instance->max_reset_tmo); in megasas_get_ctrl_info()
5370 dev_info(&instance->pdev->dev, "JBOD sequence map support\t: %s\n", in megasas_get_ctrl_info()
5371 instance->support_seqnum_jbod_fp ? "Yes" : "No"); in megasas_get_ctrl_info()
5372 dev_info(&instance->pdev->dev, "PCI Lane Margining support\t: %s\n", in megasas_get_ctrl_info()
5373 instance->support_pci_lane_margining ? "Yes" : "No"); in megasas_get_ctrl_info()
5378 switch (dcmd_timeout_ocr_possible(instance)) { in megasas_get_ctrl_info()
5381 mutex_unlock(&instance->reset_mutex); in megasas_get_ctrl_info()
5382 megasas_reset_fusion(instance->host, in megasas_get_ctrl_info()
5384 mutex_lock(&instance->reset_mutex); in megasas_get_ctrl_info()
5387 megaraid_sas_kill_hba(instance); in megasas_get_ctrl_info()
5390 dev_info(&instance->pdev->dev, "Ignore DCMD timeout: %s %d\n", in megasas_get_ctrl_info()
5396 megaraid_sas_kill_hba(instance); in megasas_get_ctrl_info()
5402 megasas_return_cmd(instance, cmd); in megasas_get_ctrl_info()
5422 int megasas_set_crash_dump_params(struct megasas_instance *instance, in megasas_set_crash_dump_params() argument
5429 cmd = megasas_get_cmd(instance); in megasas_set_crash_dump_params()
5432 dev_err(&instance->pdev->dev, "Failed to get a free cmd\n"); in megasas_set_crash_dump_params()
5450 megasas_set_dma_settings(instance, dcmd, instance->crash_dump_h, in megasas_set_crash_dump_params()
5453 if ((instance->adapter_type != MFI_SERIES) && in megasas_set_crash_dump_params()
5454 !instance->mask_interrupts) in megasas_set_crash_dump_params()
5455 ret = megasas_issue_blocked_cmd(instance, cmd, MFI_IO_TIMEOUT_SECS); in megasas_set_crash_dump_params()
5457 ret = megasas_issue_polled(instance, cmd); in megasas_set_crash_dump_params()
5460 switch (dcmd_timeout_ocr_possible(instance)) { in megasas_set_crash_dump_params()
5463 megasas_reset_fusion(instance->host, in megasas_set_crash_dump_params()
5467 megaraid_sas_kill_hba(instance); in megasas_set_crash_dump_params()
5470 dev_info(&instance->pdev->dev, "Ignore DCMD timeout: %s %d\n", in megasas_set_crash_dump_params()
5475 megasas_return_cmd(instance, cmd); in megasas_set_crash_dump_params()
5487 megasas_issue_init_mfi(struct megasas_instance *instance) in megasas_issue_init_mfi() argument
5504 cmd = megasas_get_cmd(instance); in megasas_issue_init_mfi()
5518 initq_info->reply_queue_entries = cpu_to_le32(instance->max_fw_cmds + 1); in megasas_issue_init_mfi()
5519 initq_info->reply_queue_start_phys_addr_lo = cpu_to_le32(instance->reply_queue_h); in megasas_issue_init_mfi()
5521 initq_info->producer_index_phys_addr_lo = cpu_to_le32(instance->producer_h); in megasas_issue_init_mfi()
5522 initq_info->consumer_index_phys_addr_lo = cpu_to_le32(instance->consumer_h); in megasas_issue_init_mfi()
5536 instance->instancet->disable_intr(instance); in megasas_issue_init_mfi()
5542 if (megasas_issue_polled(instance, cmd)) { in megasas_issue_init_mfi()
5543 dev_err(&instance->pdev->dev, "Failed to init firmware\n"); in megasas_issue_init_mfi()
5544 megasas_return_cmd(instance, cmd); in megasas_issue_init_mfi()
5548 megasas_return_cmd(instance, cmd); in megasas_issue_init_mfi()
5557 megasas_init_adapter_mfi(struct megasas_instance *instance) in megasas_init_adapter_mfi() argument
5565 instance->max_fw_cmds = instance->instancet->read_fw_status_reg(instance) & 0x00FFFF; in megasas_init_adapter_mfi()
5571 instance->max_fw_cmds = instance->max_fw_cmds-1; in megasas_init_adapter_mfi()
5572 instance->max_mfi_cmds = instance->max_fw_cmds; in megasas_init_adapter_mfi()
5573 instance->max_num_sge = (instance->instancet->read_fw_status_reg(instance) & 0xFF0000) >> in megasas_init_adapter_mfi()
5579 if ((instance->pdev->device == PCI_DEVICE_ID_LSI_SAS0073SKINNY) || in megasas_init_adapter_mfi()
5580 (instance->pdev->device == PCI_DEVICE_ID_LSI_SAS0071SKINNY)) { in megasas_init_adapter_mfi()
5581 instance->max_scsi_cmds = (instance->max_fw_cmds - in megasas_init_adapter_mfi()
5583 sema_init(&instance->ioctl_sem, MEGASAS_SKINNY_INT_CMDS); in megasas_init_adapter_mfi()
5585 instance->max_scsi_cmds = (instance->max_fw_cmds - in megasas_init_adapter_mfi()
5587 sema_init(&instance->ioctl_sem, (MEGASAS_MFI_IOCTL_CMDS)); in megasas_init_adapter_mfi()
5590 instance->cur_can_queue = instance->max_scsi_cmds; in megasas_init_adapter_mfi()
5594 if (megasas_alloc_cmds(instance)) in megasas_init_adapter_mfi()
5607 reply_q_sz = context_sz * (instance->max_fw_cmds + 1); in megasas_init_adapter_mfi()
5609 instance->reply_queue = dma_alloc_coherent(&instance->pdev->dev, in megasas_init_adapter_mfi()
5610 reply_q_sz, &instance->reply_queue_h, GFP_KERNEL); in megasas_init_adapter_mfi()
5612 if (!instance->reply_queue) { in megasas_init_adapter_mfi()
5613 dev_printk(KERN_DEBUG, &instance->pdev->dev, "Out of DMA mem for reply queue\n"); in megasas_init_adapter_mfi()
5617 if (megasas_issue_init_mfi(instance)) in megasas_init_adapter_mfi()
5620 if (megasas_get_ctrl_info(instance)) { in megasas_init_adapter_mfi()
5621 dev_err(&instance->pdev->dev, "(%d): Could get controller info " in megasas_init_adapter_mfi()
5622 "Fail from %s %d\n", instance->unique_id, in megasas_init_adapter_mfi()
5627 instance->fw_support_ieee = 0; in megasas_init_adapter_mfi()
5628 instance->fw_support_ieee = in megasas_init_adapter_mfi()
5629 (instance->instancet->read_fw_status_reg(instance) & in megasas_init_adapter_mfi()
5632 dev_notice(&instance->pdev->dev, "megasas_init_mfi: fw_support_ieee=%d", in megasas_init_adapter_mfi()
5633 instance->fw_support_ieee); in megasas_init_adapter_mfi()
5635 if (instance->fw_support_ieee) in megasas_init_adapter_mfi()
5636 instance->flag_ieee = 1; in megasas_init_adapter_mfi()
5642 dma_free_coherent(&instance->pdev->dev, reply_q_sz, in megasas_init_adapter_mfi()
5643 instance->reply_queue, instance->reply_queue_h); in megasas_init_adapter_mfi()
5645 megasas_free_cmds(instance); in megasas_init_adapter_mfi()
5652 void megasas_setup_irq_poll(struct megasas_instance *instance) in megasas_setup_irq_poll() argument
5657 count = instance->msix_vectors > 0 ? instance->msix_vectors : 1; in megasas_setup_irq_poll()
5661 irq_ctx = &instance->irq_context[i]; in megasas_setup_irq_poll()
5662 irq_ctx->os_irq = pci_irq_vector(instance->pdev, i); in megasas_setup_irq_poll()
5665 instance->threshold_reply_count, in megasas_setup_irq_poll()
5679 megasas_setup_irqs_ioapic(struct megasas_instance *instance) in megasas_setup_irqs_ioapic() argument
5683 pdev = instance->pdev; in megasas_setup_irqs_ioapic()
5684 instance->irq_context[0].instance = instance; in megasas_setup_irqs_ioapic()
5685 instance->irq_context[0].MSIxIndex = 0; in megasas_setup_irqs_ioapic()
5686 snprintf(instance->irq_context->name, MEGASAS_MSIX_NAME_LEN, "%s%u", in megasas_setup_irqs_ioapic()
5687 "megasas", instance->host->host_no); in megasas_setup_irqs_ioapic()
5689 instance->instancet->service_isr, IRQF_SHARED, in megasas_setup_irqs_ioapic()
5690 instance->irq_context->name, &instance->irq_context[0])) { in megasas_setup_irqs_ioapic()
5691 dev_err(&instance->pdev->dev, in megasas_setup_irqs_ioapic()
5696 instance->perf_mode = MR_LATENCY_PERF_MODE; in megasas_setup_irqs_ioapic()
5697 instance->low_latency_index_start = 0; in megasas_setup_irqs_ioapic()
5711 megasas_setup_irqs_msix(struct megasas_instance *instance, u8 is_probe) in megasas_setup_irqs_msix() argument
5716 pdev = instance->pdev; in megasas_setup_irqs_msix()
5719 for (i = 0; i < instance->msix_vectors; i++) { in megasas_setup_irqs_msix()
5720 instance->irq_context[i].instance = instance; in megasas_setup_irqs_msix()
5721 instance->irq_context[i].MSIxIndex = i; in megasas_setup_irqs_msix()
5722 snprintf(instance->irq_context[i].name, MEGASAS_MSIX_NAME_LEN, "%s%u-msix%u", in megasas_setup_irqs_msix()
5723 "megasas", instance->host->host_no, i); in megasas_setup_irqs_msix()
5725 instance->instancet->service_isr, 0, instance->irq_context[i].name, in megasas_setup_irqs_msix()
5726 &instance->irq_context[i])) { in megasas_setup_irqs_msix()
5727 dev_err(&instance->pdev->dev, in megasas_setup_irqs_msix()
5730 if (j < instance->low_latency_index_start) in megasas_setup_irqs_msix()
5734 &instance->irq_context[j]); in megasas_setup_irqs_msix()
5737 instance->msix_vectors = 0; in megasas_setup_irqs_msix()
5738 instance->msix_load_balance = false; in megasas_setup_irqs_msix()
5740 pci_free_irq_vectors(instance->pdev); in megasas_setup_irqs_msix()
5741 return megasas_setup_irqs_ioapic(instance); in megasas_setup_irqs_msix()
5757 megasas_destroy_irqs(struct megasas_instance *instance) { in megasas_destroy_irqs() argument
5763 count = instance->msix_vectors > 0 ? instance->msix_vectors : 1; in megasas_destroy_irqs()
5764 if (instance->adapter_type != MFI_SERIES) { in megasas_destroy_irqs()
5766 irq_ctx = &instance->irq_context[i]; in megasas_destroy_irqs()
5771 if (instance->msix_vectors) in megasas_destroy_irqs()
5772 for (i = 0; i < instance->msix_vectors; i++) { in megasas_destroy_irqs()
5773 if (i < instance->low_latency_index_start) in megasas_destroy_irqs()
5775 pci_irq_vector(instance->pdev, i), NULL); in megasas_destroy_irqs()
5776 free_irq(pci_irq_vector(instance->pdev, i), in megasas_destroy_irqs()
5777 &instance->irq_context[i]); in megasas_destroy_irqs()
5780 free_irq(pci_irq_vector(instance->pdev, 0), in megasas_destroy_irqs()
5781 &instance->irq_context[0]); in megasas_destroy_irqs()
5791 megasas_setup_jbod_map(struct megasas_instance *instance) in megasas_setup_jbod_map() argument
5794 struct fusion_context *fusion = instance->ctrl_context; in megasas_setup_jbod_map()
5800 instance->use_seqnum_jbod_fp = in megasas_setup_jbod_map()
5801 instance->support_seqnum_jbod_fp; in megasas_setup_jbod_map()
5803 !instance->support_seqnum_jbod_fp) { in megasas_setup_jbod_map()
5804 dev_info(&instance->pdev->dev, in megasas_setup_jbod_map()
5807 instance->use_seqnum_jbod_fp = false; in megasas_setup_jbod_map()
5816 (&instance->pdev->dev, pd_seq_map_sz, in megasas_setup_jbod_map()
5819 dev_err(&instance->pdev->dev, in megasas_setup_jbod_map()
5823 dma_free_coherent(&instance->pdev->dev, in megasas_setup_jbod_map()
5828 instance->use_seqnum_jbod_fp = false; in megasas_setup_jbod_map()
5834 if (!megasas_sync_pd_seq_num(instance, false) && in megasas_setup_jbod_map()
5835 !megasas_sync_pd_seq_num(instance, true)) in megasas_setup_jbod_map()
5836 instance->use_seqnum_jbod_fp = true; in megasas_setup_jbod_map()
5838 instance->use_seqnum_jbod_fp = false; in megasas_setup_jbod_map()
5841 static void megasas_setup_reply_map(struct megasas_instance *instance) in megasas_setup_reply_map() argument
5846 low_latency_index_start = instance->low_latency_index_start; in megasas_setup_reply_map()
5848 for (queue = low_latency_index_start; queue < instance->msix_vectors; queue++) { in megasas_setup_reply_map()
5849 mask = pci_irq_get_affinity(instance->pdev, queue); in megasas_setup_reply_map()
5854 instance->reply_map[cpu] = queue; in megasas_setup_reply_map()
5861 instance->reply_map[cpu] = queue; in megasas_setup_reply_map()
5862 if (queue == (instance->msix_vectors - 1)) in megasas_setup_reply_map()
5879 int megasas_get_device_list(struct megasas_instance *instance) in megasas_get_device_list() argument
5881 memset(instance->pd_list, 0, in megasas_get_device_list()
5883 memset(instance->ld_ids, 0xff, MEGASAS_MAX_LD_IDS); in megasas_get_device_list()
5885 if (instance->enable_fw_dev_list) { in megasas_get_device_list()
5886 if (megasas_host_device_list_query(instance, true)) in megasas_get_device_list()
5889 if (megasas_get_pd_list(instance) < 0) { in megasas_get_device_list()
5890 dev_err(&instance->pdev->dev, "failed to get PD list\n"); in megasas_get_device_list()
5894 if (megasas_ld_list_query(instance, in megasas_get_device_list()
5896 dev_err(&instance->pdev->dev, "failed to get LD list\n"); in megasas_get_device_list()
5911 megasas_set_high_iops_queue_affinity_and_hint(struct megasas_instance *instance) in megasas_set_high_iops_queue_affinity_and_hint() argument
5917 if (instance->perf_mode == MR_BALANCED_PERF_MODE) { in megasas_set_high_iops_queue_affinity_and_hint()
5918 mask = cpumask_of_node(dev_to_node(&instance->pdev->dev)); in megasas_set_high_iops_queue_affinity_and_hint()
5920 for (i = 0; i < instance->low_latency_index_start; i++) { in megasas_set_high_iops_queue_affinity_and_hint()
5921 irq = pci_irq_vector(instance->pdev, i); in megasas_set_high_iops_queue_affinity_and_hint()
5928 __megasas_alloc_irq_vectors(struct megasas_instance *instance) in __megasas_alloc_irq_vectors() argument
5931 struct irq_affinity desc = { .pre_vectors = instance->low_latency_index_start }; in __megasas_alloc_irq_vectors()
5936 if (instance->smp_affinity_enable) in __megasas_alloc_irq_vectors()
5944 i = pci_alloc_irq_vectors_affinity(instance->pdev, in __megasas_alloc_irq_vectors()
5945 instance->low_latency_index_start, in __megasas_alloc_irq_vectors()
5946 instance->msix_vectors - instance->iopoll_q_count, irq_flags, descp); in __megasas_alloc_irq_vectors()
5957 megasas_alloc_irq_vectors(struct megasas_instance *instance) in megasas_alloc_irq_vectors() argument
5962 instance->iopoll_q_count = 0; in megasas_alloc_irq_vectors()
5963 if ((instance->adapter_type != MFI_SERIES) && in megasas_alloc_irq_vectors()
5966 instance->perf_mode = MR_LATENCY_PERF_MODE; in megasas_alloc_irq_vectors()
5967 instance->low_latency_index_start = 1; in megasas_alloc_irq_vectors()
5970 if (instance->msix_vectors > (poll_queues + 2)) in megasas_alloc_irq_vectors()
5971 instance->iopoll_q_count = poll_queues; in megasas_alloc_irq_vectors()
5973 instance->iopoll_q_count = 0; in megasas_alloc_irq_vectors()
5975 num_msix_req = num_online_cpus() + instance->low_latency_index_start; in megasas_alloc_irq_vectors()
5976 instance->msix_vectors = min(num_msix_req, in megasas_alloc_irq_vectors()
5977 instance->msix_vectors); in megasas_alloc_irq_vectors()
5981 i = __megasas_alloc_irq_vectors(instance); in megasas_alloc_irq_vectors()
5983 if (((instance->perf_mode == MR_BALANCED_PERF_MODE) in megasas_alloc_irq_vectors()
5984 || instance->iopoll_q_count) && in megasas_alloc_irq_vectors()
5985 (i != (instance->msix_vectors - instance->iopoll_q_count))) { in megasas_alloc_irq_vectors()
5986 if (instance->msix_vectors) in megasas_alloc_irq_vectors()
5987 pci_free_irq_vectors(instance->pdev); in megasas_alloc_irq_vectors()
5989 instance->perf_mode = MR_LATENCY_PERF_MODE; in megasas_alloc_irq_vectors()
5990 instance->low_latency_index_start = 1; in megasas_alloc_irq_vectors()
5991 num_msix_req = num_online_cpus() + instance->low_latency_index_start; in megasas_alloc_irq_vectors()
5993 instance->msix_vectors = min(num_msix_req, in megasas_alloc_irq_vectors()
5994 instance->msix_vectors); in megasas_alloc_irq_vectors()
5996 instance->iopoll_q_count = 0; in megasas_alloc_irq_vectors()
5997 i = __megasas_alloc_irq_vectors(instance); in megasas_alloc_irq_vectors()
6001 dev_info(&instance->pdev->dev, in megasas_alloc_irq_vectors()
6003 instance->msix_vectors - instance->iopoll_q_count, in megasas_alloc_irq_vectors()
6004 i, instance->iopoll_q_count); in megasas_alloc_irq_vectors()
6007 instance->msix_vectors = i; in megasas_alloc_irq_vectors()
6009 instance->msix_vectors = 0; in megasas_alloc_irq_vectors()
6011 if (instance->smp_affinity_enable) in megasas_alloc_irq_vectors()
6012 megasas_set_high_iops_queue_affinity_and_hint(instance); in megasas_alloc_irq_vectors()
6022 static int megasas_init_fw(struct megasas_instance *instance) in megasas_init_fw() argument
6038 fusion = instance->ctrl_context; in megasas_init_fw()
6041 bar_list = pci_select_bars(instance->pdev, IORESOURCE_MEM); in megasas_init_fw()
6042 instance->bar = find_first_bit(&bar_list, BITS_PER_LONG); in megasas_init_fw()
6043 if (pci_request_selected_regions(instance->pdev, 1<<instance->bar, in megasas_init_fw()
6045 dev_printk(KERN_DEBUG, &instance->pdev->dev, "IO memory region busy!\n"); in megasas_init_fw()
6049 base_addr = pci_resource_start(instance->pdev, instance->bar); in megasas_init_fw()
6050 instance->reg_set = ioremap(base_addr, 8192); in megasas_init_fw()
6052 if (!instance->reg_set) { in megasas_init_fw()
6053 dev_printk(KERN_DEBUG, &instance->pdev->dev, "Failed to map IO mem\n"); in megasas_init_fw()
6058 dev_printk(KERN_DEBUG, &instance->pdev->dev, in megasas_init_fw()
6060 instance->bar, base_addr_phys, instance->reg_set); in megasas_init_fw()
6062 if (instance->adapter_type != MFI_SERIES) in megasas_init_fw()
6063 instance->instancet = &megasas_instance_template_fusion; in megasas_init_fw()
6065 switch (instance->pdev->device) { in megasas_init_fw()
6068 instance->instancet = &megasas_instance_template_ppc; in megasas_init_fw()
6072 instance->instancet = &megasas_instance_template_gen2; in megasas_init_fw()
6076 instance->instancet = &megasas_instance_template_skinny; in megasas_init_fw()
6081 instance->instancet = &megasas_instance_template_xscale; in megasas_init_fw()
6082 instance->pd_list_not_supported = 1; in megasas_init_fw()
6087 if (megasas_transition_to_ready(instance, 0)) { in megasas_init_fw()
6088 dev_info(&instance->pdev->dev, in megasas_init_fw()
6091 if (instance->adapter_type != MFI_SERIES) { in megasas_init_fw()
6092 status_reg = instance->instancet->read_fw_status_reg( in megasas_init_fw()
6093 instance); in megasas_init_fw()
6096 (instance, true, 0) == FAILED) in megasas_init_fw()
6102 atomic_set(&instance->fw_reset_no_pci_access, 1); in megasas_init_fw()
6103 instance->instancet->adp_reset in megasas_init_fw()
6104 (instance, instance->reg_set); in megasas_init_fw()
6105 atomic_set(&instance->fw_reset_no_pci_access, 0); in megasas_init_fw()
6110 if (megasas_transition_to_ready(instance, 0)) in megasas_init_fw()
6114 dev_info(&instance->pdev->dev, in megasas_init_fw()
6119 megasas_init_ctrl_params(instance); in megasas_init_fw()
6121 if (megasas_set_dma_mask(instance)) in megasas_init_fw()
6124 if (megasas_alloc_ctrl_mem(instance)) in megasas_init_fw()
6127 if (megasas_alloc_ctrl_dma_buffers(instance)) in megasas_init_fw()
6130 fusion = instance->ctrl_context; in megasas_init_fw()
6132 if (instance->adapter_type >= VENTURA_SERIES) { in megasas_init_fw()
6134 megasas_readl(instance, in megasas_init_fw()
6135 &instance->reg_set->outbound_scratch_pad_2); in megasas_init_fw()
6136 instance->max_raid_mapsize = ((scratch_pad_2 >> in megasas_init_fw()
6141 instance->enable_sdev_max_qd = enable_sdev_max_qd; in megasas_init_fw()
6143 switch (instance->adapter_type) { in megasas_init_fw()
6155 msix_enable = (instance->instancet->read_fw_status_reg(instance) & in megasas_init_fw()
6160 (instance, &instance->reg_set->outbound_scratch_pad_1); in megasas_init_fw()
6163 if (instance->adapter_type == THUNDERBOLT_SERIES) { in megasas_init_fw()
6165 instance->msix_vectors = (scratch_pad_1 in megasas_init_fw()
6168 instance->msix_vectors = ((scratch_pad_1 in megasas_init_fw()
6180 switch (instance->adapter_type) { in megasas_init_fw()
6182 if (instance->msix_vectors > 8) in megasas_init_fw()
6183 instance->msix_combined = true; in megasas_init_fw()
6187 if (instance->msix_vectors > 16) in megasas_init_fw()
6188 instance->msix_combined = true; in megasas_init_fw()
6193 instance->is_rdpq = (scratch_pad_1 & MR_RDPQ_MODE_OFFSET) ? in megasas_init_fw()
6196 if (instance->adapter_type >= INVADER_SERIES && in megasas_init_fw()
6197 !instance->msix_combined) { in megasas_init_fw()
6198 instance->msix_load_balance = true; in megasas_init_fw()
6199 instance->smp_affinity_enable = false; in megasas_init_fw()
6207 instance->reply_post_host_index_addr[loop] = in megasas_init_fw()
6209 ((u8 __iomem *)instance->reg_set + in megasas_init_fw()
6215 dev_info(&instance->pdev->dev, in megasas_init_fw()
6217 instance->msix_vectors); in megasas_init_fw()
6219 instance->msix_vectors = min(msix_vectors, in megasas_init_fw()
6220 instance->msix_vectors); in megasas_init_fw()
6222 instance->msix_vectors = 1; in megasas_init_fw()
6248 (instance->msix_vectors == MEGASAS_MAX_MSIX_QUEUES)) in megasas_init_fw()
6249 instance->perf_mode = MR_BALANCED_PERF_MODE; in megasas_init_fw()
6251 instance->perf_mode = MR_LATENCY_PERF_MODE; in megasas_init_fw()
6254 if (instance->adapter_type == AERO_SERIES) { in megasas_init_fw()
6255 pcie_capability_read_word(instance->pdev, PCI_EXP_LNKSTA, &lnksta); in megasas_init_fw()
6263 instance->perf_mode = MR_LATENCY_PERF_MODE; in megasas_init_fw()
6275 instance->perf_mode = perf_mode; in megasas_init_fw()
6281 instance->perf_mode = MR_LATENCY_PERF_MODE; in megasas_init_fw()
6285 if (instance->perf_mode == MR_BALANCED_PERF_MODE) in megasas_init_fw()
6286 instance->low_latency_index_start = in megasas_init_fw()
6289 instance->low_latency_index_start = 1; in megasas_init_fw()
6291 num_msix_req = num_online_cpus() + instance->low_latency_index_start; in megasas_init_fw()
6293 instance->msix_vectors = min(num_msix_req, in megasas_init_fw()
6294 instance->msix_vectors); in megasas_init_fw()
6296 megasas_alloc_irq_vectors(instance); in megasas_init_fw()
6297 if (!instance->msix_vectors) in megasas_init_fw()
6298 instance->msix_load_balance = false; in megasas_init_fw()
6304 if (instance->msix_combined) { in megasas_init_fw()
6305 instance->reply_post_host_index_addr[0] = in megasas_init_fw()
6306 (u32 *)((u8 *)instance->reg_set + in megasas_init_fw()
6309 instance->reply_post_host_index_addr[0] = in megasas_init_fw()
6310 (u32 *)((u8 *)instance->reg_set + in megasas_init_fw()
6314 if (!instance->msix_vectors) { in megasas_init_fw()
6315 i = pci_alloc_irq_vectors(instance->pdev, 1, 1, PCI_IRQ_LEGACY); in megasas_init_fw()
6320 megasas_setup_reply_map(instance); in megasas_init_fw()
6322 dev_info(&instance->pdev->dev, in megasas_init_fw()
6324 instance->msix_vectors, (unsigned int)num_online_cpus()); in megasas_init_fw()
6325 dev_info(&instance->pdev->dev, in megasas_init_fw()
6326 "RDPQ mode\t: (%s)\n", instance->is_rdpq ? "enabled" : "disabled"); in megasas_init_fw()
6328 tasklet_init(&instance->isr_tasklet, instance->instancet->tasklet, in megasas_init_fw()
6329 (unsigned long)instance); in megasas_init_fw()
6335 instance->fw_supported_vd_count = MAX_LOGICAL_DRIVES; in megasas_init_fw()
6336 instance->fw_supported_pd_count = MAX_PHYSICAL_DEVICES; in megasas_init_fw()
6338 if (instance->instancet->init_adapter(instance)) in megasas_init_fw()
6341 if (instance->adapter_type >= VENTURA_SERIES) { in megasas_init_fw()
6343 megasas_readl(instance, in megasas_init_fw()
6344 &instance->reg_set->outbound_scratch_pad_3); in megasas_init_fw()
6347 instance->nvme_page_size = in megasas_init_fw()
6350 dev_info(&instance->pdev->dev, in megasas_init_fw()
6351 "NVME page size\t: (%d)\n", instance->nvme_page_size); in megasas_init_fw()
6354 if (instance->msix_vectors ? in megasas_init_fw()
6355 megasas_setup_irqs_msix(instance, 1) : in megasas_init_fw()
6356 megasas_setup_irqs_ioapic(instance)) in megasas_init_fw()
6359 if (instance->adapter_type != MFI_SERIES) in megasas_init_fw()
6360 megasas_setup_irq_poll(instance); in megasas_init_fw()
6362 instance->instancet->enable_intr(instance); in megasas_init_fw()
6364 dev_info(&instance->pdev->dev, "INIT adapter done\n"); in megasas_init_fw()
6366 megasas_setup_jbod_map(instance); in megasas_init_fw()
6368 if (megasas_get_device_list(instance) != SUCCESS) { in megasas_init_fw()
6369 dev_err(&instance->pdev->dev, in megasas_init_fw()
6376 if (instance->adapter_type >= VENTURA_SERIES) { in megasas_init_fw()
6382 dev_err(&instance->pdev->dev, in megasas_init_fw()
6391 dev_err(&instance->pdev->dev, in megasas_init_fw()
6414 ctrl_info = instance->ctrl_info_buf; in megasas_init_fw()
6422 instance->peerIsPresent = ctrl_info->cluster.peerIsPresent; in megasas_init_fw()
6423 instance->passive = ctrl_info->cluster.passive; in megasas_init_fw()
6424 memcpy(instance->clusterId, ctrl_info->clusterId, sizeof(instance->clusterId)); in megasas_init_fw()
6425 instance->UnevenSpanSupport = in megasas_init_fw()
6427 if (instance->UnevenSpanSupport) { in megasas_init_fw()
6428 struct fusion_context *fusion = instance->ctrl_context; in megasas_init_fw()
6429 if (MR_ValidateMapInfo(instance, instance->map_id)) in megasas_init_fw()
6436 instance->requestorId = ctrl_info->iov.requestorId; in megasas_init_fw()
6437 if (instance->pdev->device == PCI_DEVICE_ID_LSI_PLASMA) { in megasas_init_fw()
6439 instance->PlasmaFW111 = 1; in megasas_init_fw()
6441 dev_info(&instance->pdev->dev, "SR-IOV: firmware type: %s\n", in megasas_init_fw()
6442 instance->PlasmaFW111 ? "1.11" : "new"); in megasas_init_fw()
6444 if (instance->PlasmaFW111) { in megasas_init_fw()
6447 instance->requestorId = iovPtr->requestorId; in megasas_init_fw()
6450 dev_info(&instance->pdev->dev, "SRIOV: VF requestorId %d\n", in megasas_init_fw()
6451 instance->requestorId); in megasas_init_fw()
6454 instance->crash_dump_fw_support = in megasas_init_fw()
6456 instance->crash_dump_drv_support = in megasas_init_fw()
6457 (instance->crash_dump_fw_support && in megasas_init_fw()
6458 instance->crash_dump_buf); in megasas_init_fw()
6459 if (instance->crash_dump_drv_support) in megasas_init_fw()
6460 megasas_set_crash_dump_params(instance, in megasas_init_fw()
6464 if (instance->crash_dump_buf) in megasas_init_fw()
6465 dma_free_coherent(&instance->pdev->dev, in megasas_init_fw()
6467 instance->crash_dump_buf, in megasas_init_fw()
6468 instance->crash_dump_h); in megasas_init_fw()
6469 instance->crash_dump_buf = NULL; in megasas_init_fw()
6472 if (instance->snapdump_wait_time) { in megasas_init_fw()
6473 megasas_get_snapdump_properties(instance); in megasas_init_fw()
6474 dev_info(&instance->pdev->dev, "Snap dump wait time\t: %d\n", in megasas_init_fw()
6475 instance->snapdump_wait_time); in megasas_init_fw()
6478 dev_info(&instance->pdev->dev, in megasas_init_fw()
6484 dev_info(&instance->pdev->dev, "unevenspan support : %s\n", in megasas_init_fw()
6485 instance->UnevenSpanSupport ? "yes" : "no"); in megasas_init_fw()
6486 dev_info(&instance->pdev->dev, "firmware crash dump : %s\n", in megasas_init_fw()
6487 instance->crash_dump_drv_support ? "yes" : "no"); in megasas_init_fw()
6488 dev_info(&instance->pdev->dev, "JBOD sequence map : %s\n", in megasas_init_fw()
6489 instance->use_seqnum_jbod_fp ? "enabled" : "disabled"); in megasas_init_fw()
6491 instance->max_sectors_per_req = instance->max_num_sge * in megasas_init_fw()
6493 if (tmp_sectors && (instance->max_sectors_per_req > tmp_sectors)) in megasas_init_fw()
6494 instance->max_sectors_per_req = tmp_sectors; in megasas_init_fw()
6498 throttlequeuedepth <= instance->max_scsi_cmds) in megasas_init_fw()
6499 instance->throttlequeuedepth = throttlequeuedepth; in megasas_init_fw()
6501 instance->throttlequeuedepth = in megasas_init_fw()
6512 if (instance->requestorId) { in megasas_init_fw()
6513 if (!megasas_sriov_start_heartbeat(instance, 1)) { in megasas_init_fw()
6514 megasas_start_timer(instance); in megasas_init_fw()
6516 instance->skip_heartbeat_timer_del = 1; in megasas_init_fw()
6526 if (instance->adapter_type != MFI_SERIES) in megasas_init_fw()
6527 if (megasas_fusion_start_watchdog(instance) != SUCCESS) in megasas_init_fw()
6533 if (instance->requestorId && !instance->skip_heartbeat_timer_del) in megasas_init_fw()
6534 del_timer_sync(&instance->sriov_heartbeat_timer); in megasas_init_fw()
6536 instance->instancet->disable_intr(instance); in megasas_init_fw()
6537 megasas_destroy_irqs(instance); in megasas_init_fw()
6539 if (instance->msix_vectors) in megasas_init_fw()
6540 pci_free_irq_vectors(instance->pdev); in megasas_init_fw()
6541 instance->msix_vectors = 0; in megasas_init_fw()
6543 megasas_free_ctrl_dma_buffers(instance); in megasas_init_fw()
6544 megasas_free_ctrl_mem(instance); in megasas_init_fw()
6546 iounmap(instance->reg_set); in megasas_init_fw()
6549 pci_release_selected_regions(instance->pdev, 1<<instance->bar); in megasas_init_fw()
6551 dev_err(&instance->pdev->dev, "Failed from %s %d\n", in megasas_init_fw()
6560 static void megasas_release_mfi(struct megasas_instance *instance) in megasas_release_mfi() argument
6562 u32 reply_q_sz = sizeof(u32) *(instance->max_mfi_cmds + 1); in megasas_release_mfi()
6564 if (instance->reply_queue) in megasas_release_mfi()
6565 dma_free_coherent(&instance->pdev->dev, reply_q_sz, in megasas_release_mfi()
6566 instance->reply_queue, instance->reply_queue_h); in megasas_release_mfi()
6568 megasas_free_cmds(instance); in megasas_release_mfi()
6570 iounmap(instance->reg_set); in megasas_release_mfi()
6572 pci_release_selected_regions(instance->pdev, 1<<instance->bar); in megasas_release_mfi()
6588 megasas_get_seq_num(struct megasas_instance *instance, in megasas_get_seq_num() argument
6597 cmd = megasas_get_cmd(instance); in megasas_get_seq_num()
6604 el_info = dma_alloc_coherent(&instance->pdev->dev, in megasas_get_seq_num()
6608 megasas_return_cmd(instance, cmd); in megasas_get_seq_num()
6623 megasas_set_dma_settings(instance, dcmd, el_info_h, in megasas_get_seq_num()
6626 ret = megasas_issue_blocked_cmd(instance, cmd, MFI_IO_TIMEOUT_SECS); in megasas_get_seq_num()
6628 dev_err(&instance->pdev->dev, "Failed from %s %d\n", in megasas_get_seq_num()
6643 dma_free_coherent(&instance->pdev->dev, in megasas_get_seq_num()
6647 megasas_return_cmd(instance, cmd); in megasas_get_seq_num()
6662 megasas_register_aen(struct megasas_instance *instance, u32 seq_num, in megasas_register_aen() argument
6686 if (instance->aen_cmd) { in megasas_register_aen()
6689 le32_to_cpu(instance->aen_cmd->frame->dcmd.mbox.w[1]); in megasas_register_aen()
6693 dev_info(&instance->pdev->dev, in megasas_register_aen()
6723 instance->aen_cmd->abort_aen = 1; in megasas_register_aen()
6724 ret_val = megasas_issue_blocked_abort_cmd(instance, in megasas_register_aen()
6725 instance-> in megasas_register_aen()
6729 dev_printk(KERN_DEBUG, &instance->pdev->dev, "Failed to abort " in megasas_register_aen()
6736 cmd = megasas_get_cmd(instance); in megasas_register_aen()
6743 memset(instance->evt_detail, 0, sizeof(struct megasas_evt_detail)); in megasas_register_aen()
6759 instance->last_seq_num = seq_num; in megasas_register_aen()
6762 megasas_set_dma_settings(instance, dcmd, instance->evt_detail_h, in megasas_register_aen()
6765 if (instance->aen_cmd != NULL) { in megasas_register_aen()
6766 megasas_return_cmd(instance, cmd); in megasas_register_aen()
6775 instance->aen_cmd = cmd; in megasas_register_aen()
6780 instance->instancet->issue_dcmd(instance, cmd); in megasas_register_aen()
6804 megasas_get_target_prop(struct megasas_instance *instance, in megasas_get_target_prop() argument
6813 cmd = megasas_get_cmd(instance); in megasas_get_target_prop()
6816 dev_err(&instance->pdev->dev, in megasas_get_target_prop()
6823 memset(instance->tgt_prop, 0, sizeof(*instance->tgt_prop)); in megasas_get_target_prop()
6838 megasas_set_dma_settings(instance, dcmd, instance->tgt_prop_h, in megasas_get_target_prop()
6841 if ((instance->adapter_type != MFI_SERIES) && in megasas_get_target_prop()
6842 !instance->mask_interrupts) in megasas_get_target_prop()
6843 ret = megasas_issue_blocked_cmd(instance, in megasas_get_target_prop()
6846 ret = megasas_issue_polled(instance, cmd); in megasas_get_target_prop()
6850 switch (dcmd_timeout_ocr_possible(instance)) { in megasas_get_target_prop()
6853 mutex_unlock(&instance->reset_mutex); in megasas_get_target_prop()
6854 megasas_reset_fusion(instance->host, in megasas_get_target_prop()
6856 mutex_lock(&instance->reset_mutex); in megasas_get_target_prop()
6859 megaraid_sas_kill_hba(instance); in megasas_get_target_prop()
6862 dev_info(&instance->pdev->dev, in megasas_get_target_prop()
6870 megasas_return_cmd(instance, cmd); in megasas_get_target_prop()
6873 dev_err(&instance->pdev->dev, in megasas_get_target_prop()
6884 static int megasas_start_aen(struct megasas_instance *instance) in megasas_start_aen() argument
6894 if (megasas_get_seq_num(instance, &eli)) in megasas_start_aen()
6904 return megasas_register_aen(instance, in megasas_start_aen()
6913 static int megasas_io_attach(struct megasas_instance *instance) in megasas_io_attach() argument
6915 struct Scsi_Host *host = instance->host; in megasas_io_attach()
6920 host->unique_id = instance->unique_id; in megasas_io_attach()
6921 host->can_queue = instance->max_scsi_cmds; in megasas_io_attach()
6922 host->this_id = instance->init_id; in megasas_io_attach()
6923 host->sg_tablesize = instance->max_num_sge; in megasas_io_attach()
6925 if (instance->fw_support_ieee) in megasas_io_attach()
6926 instance->max_sectors_per_req = MEGASAS_MAX_SECTORS_IEEE; in megasas_io_attach()
6931 if (max_sectors && max_sectors < instance->max_sectors_per_req) in megasas_io_attach()
6932 instance->max_sectors_per_req = max_sectors; in megasas_io_attach()
6935 if (((instance->pdev->device == in megasas_io_attach()
6937 (instance->pdev->device == in megasas_io_attach()
6940 instance->max_sectors_per_req = max_sectors; in megasas_io_attach()
6942 dev_info(&instance->pdev->dev, "max_sectors should be > 0" in megasas_io_attach()
6944 instance->max_sectors_per_req); in megasas_io_attach()
6949 host->max_sectors = instance->max_sectors_per_req; in megasas_io_attach()
6964 if ((instance->adapter_type != MFI_SERIES) && in megasas_io_attach()
6965 (instance->msix_vectors > instance->low_latency_index_start) && in megasas_io_attach()
6967 instance->smp_affinity_enable) { in megasas_io_attach()
6969 host->nr_hw_queues = instance->msix_vectors - in megasas_io_attach()
6970 instance->low_latency_index_start + instance->iopoll_q_count; in megasas_io_attach()
6971 if (instance->iopoll_q_count) in megasas_io_attach()
6974 instance->iopoll_q_count = 0; in megasas_io_attach()
6977 dev_info(&instance->pdev->dev, in megasas_io_attach()
6979 "hw_queues = %d poll_queues %d\n", instance->max_fw_cmds, in megasas_io_attach()
6980 host->nr_hw_queues - instance->iopoll_q_count, in megasas_io_attach()
6981 instance->iopoll_q_count); in megasas_io_attach()
6985 if (scsi_add_host(host, &instance->pdev->dev)) { in megasas_io_attach()
6986 dev_err(&instance->pdev->dev, in megasas_io_attach()
7013 megasas_set_dma_mask(struct megasas_instance *instance) in megasas_set_dma_mask() argument
7019 pdev = instance->pdev; in megasas_set_dma_mask()
7020 consistent_mask = (instance->adapter_type >= VENTURA_SERIES) ? in megasas_set_dma_mask()
7036 (instance, &instance->reg_set->outbound_scratch_pad_1); in megasas_set_dma_mask()
7048 instance->consistent_mask_64bit = false; in megasas_set_dma_mask()
7050 instance->consistent_mask_64bit = true; in megasas_set_dma_mask()
7054 (instance->consistent_mask_64bit ? "63" : "32")); in megasas_set_dma_mask()
7078 static inline void megasas_set_adapter_type(struct megasas_instance *instance) in megasas_set_adapter_type() argument
7080 if ((instance->pdev->vendor == PCI_VENDOR_ID_DELL) && in megasas_set_adapter_type()
7081 (instance->pdev->device == PCI_DEVICE_ID_DELL_PERC5)) { in megasas_set_adapter_type()
7082 instance->adapter_type = MFI_SERIES; in megasas_set_adapter_type()
7084 switch (instance->pdev->device) { in megasas_set_adapter_type()
7089 instance->adapter_type = AERO_SERIES; in megasas_set_adapter_type()
7097 instance->adapter_type = VENTURA_SERIES; in megasas_set_adapter_type()
7101 instance->adapter_type = THUNDERBOLT_SERIES; in megasas_set_adapter_type()
7109 instance->adapter_type = INVADER_SERIES; in megasas_set_adapter_type()
7112 instance->adapter_type = MFI_SERIES; in megasas_set_adapter_type()
7118 static inline int megasas_alloc_mfi_ctrl_mem(struct megasas_instance *instance) in megasas_alloc_mfi_ctrl_mem() argument
7120 instance->producer = dma_alloc_coherent(&instance->pdev->dev, in megasas_alloc_mfi_ctrl_mem()
7121 sizeof(u32), &instance->producer_h, GFP_KERNEL); in megasas_alloc_mfi_ctrl_mem()
7122 instance->consumer = dma_alloc_coherent(&instance->pdev->dev, in megasas_alloc_mfi_ctrl_mem()
7123 sizeof(u32), &instance->consumer_h, GFP_KERNEL); in megasas_alloc_mfi_ctrl_mem()
7125 if (!instance->producer || !instance->consumer) { in megasas_alloc_mfi_ctrl_mem()
7126 dev_err(&instance->pdev->dev, in megasas_alloc_mfi_ctrl_mem()
7131 *instance->producer = 0; in megasas_alloc_mfi_ctrl_mem()
7132 *instance->consumer = 0; in megasas_alloc_mfi_ctrl_mem()
7146 static int megasas_alloc_ctrl_mem(struct megasas_instance *instance) in megasas_alloc_ctrl_mem() argument
7148 instance->reply_map = kcalloc(nr_cpu_ids, sizeof(unsigned int), in megasas_alloc_ctrl_mem()
7150 if (!instance->reply_map) in megasas_alloc_ctrl_mem()
7153 switch (instance->adapter_type) { in megasas_alloc_ctrl_mem()
7155 if (megasas_alloc_mfi_ctrl_mem(instance)) in megasas_alloc_ctrl_mem()
7162 if (megasas_alloc_fusion_context(instance)) in megasas_alloc_ctrl_mem()
7169 kfree(instance->reply_map); in megasas_alloc_ctrl_mem()
7170 instance->reply_map = NULL; in megasas_alloc_ctrl_mem()
7181 static inline void megasas_free_ctrl_mem(struct megasas_instance *instance) in megasas_free_ctrl_mem() argument
7183 kfree(instance->reply_map); in megasas_free_ctrl_mem()
7184 if (instance->adapter_type == MFI_SERIES) { in megasas_free_ctrl_mem()
7185 if (instance->producer) in megasas_free_ctrl_mem()
7186 dma_free_coherent(&instance->pdev->dev, sizeof(u32), in megasas_free_ctrl_mem()
7187 instance->producer, in megasas_free_ctrl_mem()
7188 instance->producer_h); in megasas_free_ctrl_mem()
7189 if (instance->consumer) in megasas_free_ctrl_mem()
7190 dma_free_coherent(&instance->pdev->dev, sizeof(u32), in megasas_free_ctrl_mem()
7191 instance->consumer, in megasas_free_ctrl_mem()
7192 instance->consumer_h); in megasas_free_ctrl_mem()
7194 megasas_free_fusion_context(instance); in megasas_free_ctrl_mem()
7207 int megasas_alloc_ctrl_dma_buffers(struct megasas_instance *instance) in megasas_alloc_ctrl_dma_buffers() argument
7209 struct pci_dev *pdev = instance->pdev; in megasas_alloc_ctrl_dma_buffers()
7210 struct fusion_context *fusion = instance->ctrl_context; in megasas_alloc_ctrl_dma_buffers()
7212 instance->evt_detail = dma_alloc_coherent(&pdev->dev, in megasas_alloc_ctrl_dma_buffers()
7214 &instance->evt_detail_h, GFP_KERNEL); in megasas_alloc_ctrl_dma_buffers()
7216 if (!instance->evt_detail) { in megasas_alloc_ctrl_dma_buffers()
7217 dev_err(&instance->pdev->dev, in megasas_alloc_ctrl_dma_buffers()
7235 instance->snapdump_prop = dma_alloc_coherent(&pdev->dev, in megasas_alloc_ctrl_dma_buffers()
7237 &instance->snapdump_prop_h, GFP_KERNEL); in megasas_alloc_ctrl_dma_buffers()
7239 if (!instance->snapdump_prop) in megasas_alloc_ctrl_dma_buffers()
7243 instance->host_device_list_buf = dma_alloc_coherent(&pdev->dev, in megasas_alloc_ctrl_dma_buffers()
7245 &instance->host_device_list_buf_h, in megasas_alloc_ctrl_dma_buffers()
7248 if (!instance->host_device_list_buf) { in megasas_alloc_ctrl_dma_buffers()
7256 instance->pd_list_buf = in megasas_alloc_ctrl_dma_buffers()
7259 &instance->pd_list_buf_h, GFP_KERNEL); in megasas_alloc_ctrl_dma_buffers()
7261 if (!instance->pd_list_buf) { in megasas_alloc_ctrl_dma_buffers()
7266 instance->ctrl_info_buf = in megasas_alloc_ctrl_dma_buffers()
7269 &instance->ctrl_info_buf_h, GFP_KERNEL); in megasas_alloc_ctrl_dma_buffers()
7271 if (!instance->ctrl_info_buf) { in megasas_alloc_ctrl_dma_buffers()
7277 instance->ld_list_buf = in megasas_alloc_ctrl_dma_buffers()
7280 &instance->ld_list_buf_h, GFP_KERNEL); in megasas_alloc_ctrl_dma_buffers()
7282 if (!instance->ld_list_buf) { in megasas_alloc_ctrl_dma_buffers()
7287 instance->ld_targetid_list_buf = in megasas_alloc_ctrl_dma_buffers()
7290 &instance->ld_targetid_list_buf_h, GFP_KERNEL); in megasas_alloc_ctrl_dma_buffers()
7292 if (!instance->ld_targetid_list_buf) { in megasas_alloc_ctrl_dma_buffers()
7299 instance->system_info_buf = in megasas_alloc_ctrl_dma_buffers()
7302 &instance->system_info_h, GFP_KERNEL); in megasas_alloc_ctrl_dma_buffers()
7303 instance->pd_info = in megasas_alloc_ctrl_dma_buffers()
7306 &instance->pd_info_h, GFP_KERNEL); in megasas_alloc_ctrl_dma_buffers()
7307 instance->tgt_prop = in megasas_alloc_ctrl_dma_buffers()
7310 &instance->tgt_prop_h, GFP_KERNEL); in megasas_alloc_ctrl_dma_buffers()
7311 instance->crash_dump_buf = in megasas_alloc_ctrl_dma_buffers()
7313 &instance->crash_dump_h, GFP_KERNEL); in megasas_alloc_ctrl_dma_buffers()
7315 if (!instance->system_info_buf) in megasas_alloc_ctrl_dma_buffers()
7316 dev_err(&instance->pdev->dev, in megasas_alloc_ctrl_dma_buffers()
7319 if (!instance->pd_info) in megasas_alloc_ctrl_dma_buffers()
7320 dev_err(&instance->pdev->dev, in megasas_alloc_ctrl_dma_buffers()
7323 if (!instance->tgt_prop) in megasas_alloc_ctrl_dma_buffers()
7324 dev_err(&instance->pdev->dev, in megasas_alloc_ctrl_dma_buffers()
7327 if (!instance->crash_dump_buf) in megasas_alloc_ctrl_dma_buffers()
7328 dev_err(&instance->pdev->dev, in megasas_alloc_ctrl_dma_buffers()
7343 void megasas_free_ctrl_dma_buffers(struct megasas_instance *instance) in megasas_free_ctrl_dma_buffers() argument
7345 struct pci_dev *pdev = instance->pdev; in megasas_free_ctrl_dma_buffers()
7346 struct fusion_context *fusion = instance->ctrl_context; in megasas_free_ctrl_dma_buffers()
7348 if (instance->evt_detail) in megasas_free_ctrl_dma_buffers()
7350 instance->evt_detail, in megasas_free_ctrl_dma_buffers()
7351 instance->evt_detail_h); in megasas_free_ctrl_dma_buffers()
7359 if (instance->pd_list_buf) in megasas_free_ctrl_dma_buffers()
7362 instance->pd_list_buf, in megasas_free_ctrl_dma_buffers()
7363 instance->pd_list_buf_h); in megasas_free_ctrl_dma_buffers()
7365 if (instance->ld_list_buf) in megasas_free_ctrl_dma_buffers()
7367 instance->ld_list_buf, in megasas_free_ctrl_dma_buffers()
7368 instance->ld_list_buf_h); in megasas_free_ctrl_dma_buffers()
7370 if (instance->ld_targetid_list_buf) in megasas_free_ctrl_dma_buffers()
7372 instance->ld_targetid_list_buf, in megasas_free_ctrl_dma_buffers()
7373 instance->ld_targetid_list_buf_h); in megasas_free_ctrl_dma_buffers()
7375 if (instance->ctrl_info_buf) in megasas_free_ctrl_dma_buffers()
7377 instance->ctrl_info_buf, in megasas_free_ctrl_dma_buffers()
7378 instance->ctrl_info_buf_h); in megasas_free_ctrl_dma_buffers()
7380 if (instance->system_info_buf) in megasas_free_ctrl_dma_buffers()
7382 instance->system_info_buf, in megasas_free_ctrl_dma_buffers()
7383 instance->system_info_h); in megasas_free_ctrl_dma_buffers()
7385 if (instance->pd_info) in megasas_free_ctrl_dma_buffers()
7387 instance->pd_info, instance->pd_info_h); in megasas_free_ctrl_dma_buffers()
7389 if (instance->tgt_prop) in megasas_free_ctrl_dma_buffers()
7391 instance->tgt_prop, instance->tgt_prop_h); in megasas_free_ctrl_dma_buffers()
7393 if (instance->crash_dump_buf) in megasas_free_ctrl_dma_buffers()
7395 instance->crash_dump_buf, in megasas_free_ctrl_dma_buffers()
7396 instance->crash_dump_h); in megasas_free_ctrl_dma_buffers()
7398 if (instance->snapdump_prop) in megasas_free_ctrl_dma_buffers()
7401 instance->snapdump_prop, in megasas_free_ctrl_dma_buffers()
7402 instance->snapdump_prop_h); in megasas_free_ctrl_dma_buffers()
7404 if (instance->host_device_list_buf) in megasas_free_ctrl_dma_buffers()
7407 instance->host_device_list_buf, in megasas_free_ctrl_dma_buffers()
7408 instance->host_device_list_buf_h); in megasas_free_ctrl_dma_buffers()
7418 static inline void megasas_init_ctrl_params(struct megasas_instance *instance) in megasas_init_ctrl_params() argument
7420 instance->fw_crash_state = UNAVAILABLE; in megasas_init_ctrl_params()
7423 instance->issuepend_done = 1; in megasas_init_ctrl_params()
7424 atomic_set(&instance->adprecovery, MEGASAS_HBA_OPERATIONAL); in megasas_init_ctrl_params()
7429 INIT_LIST_HEAD(&instance->cmd_pool); in megasas_init_ctrl_params()
7430 INIT_LIST_HEAD(&instance->internal_reset_pending_q); in megasas_init_ctrl_params()
7432 atomic_set(&instance->fw_outstanding, 0); in megasas_init_ctrl_params()
7433 atomic64_set(&instance->total_io_count, 0); in megasas_init_ctrl_params()
7435 init_waitqueue_head(&instance->int_cmd_wait_q); in megasas_init_ctrl_params()
7436 init_waitqueue_head(&instance->abort_cmd_wait_q); in megasas_init_ctrl_params()
7438 spin_lock_init(&instance->crashdump_lock); in megasas_init_ctrl_params()
7439 spin_lock_init(&instance->mfi_pool_lock); in megasas_init_ctrl_params()
7440 spin_lock_init(&instance->hba_lock); in megasas_init_ctrl_params()
7441 spin_lock_init(&instance->stream_lock); in megasas_init_ctrl_params()
7442 spin_lock_init(&instance->completion_lock); in megasas_init_ctrl_params()
7444 mutex_init(&instance->reset_mutex); in megasas_init_ctrl_params()
7446 if ((instance->pdev->device == PCI_DEVICE_ID_LSI_SAS0073SKINNY) || in megasas_init_ctrl_params()
7447 (instance->pdev->device == PCI_DEVICE_ID_LSI_SAS0071SKINNY)) in megasas_init_ctrl_params()
7448 instance->flag_ieee = 1; in megasas_init_ctrl_params()
7451 instance->flag = 0; in megasas_init_ctrl_params()
7452 instance->unload = 1; in megasas_init_ctrl_params()
7453 instance->last_time = 0; in megasas_init_ctrl_params()
7454 instance->disableOnlineCtrlReset = 1; in megasas_init_ctrl_params()
7455 instance->UnevenSpanSupport = 0; in megasas_init_ctrl_params()
7456 instance->smp_affinity_enable = smp_affinity_enable ? true : false; in megasas_init_ctrl_params()
7457 instance->msix_load_balance = false; in megasas_init_ctrl_params()
7459 if (instance->adapter_type != MFI_SERIES) in megasas_init_ctrl_params()
7460 INIT_WORK(&instance->work_init, megasas_fusion_ocr_wq); in megasas_init_ctrl_params()
7462 INIT_WORK(&instance->work_init, process_fw_state_change_wq); in megasas_init_ctrl_params()
7475 struct megasas_instance *instance; in megasas_probe_one() local
7526 instance = (struct megasas_instance *)host->hostdata; in megasas_probe_one()
7527 memset(instance, 0, sizeof(*instance)); in megasas_probe_one()
7528 atomic_set(&instance->fw_reset_no_pci_access, 0); in megasas_probe_one()
7533 instance->pdev = pdev; in megasas_probe_one()
7534 instance->host = host; in megasas_probe_one()
7535 instance->unique_id = pdev->bus->number << 8 | pdev->devfn; in megasas_probe_one()
7536 instance->init_id = MEGASAS_DEFAULT_INIT_ID; in megasas_probe_one()
7538 megasas_set_adapter_type(instance); in megasas_probe_one()
7543 if (megasas_init_fw(instance)) in megasas_probe_one()
7546 if (instance->requestorId) { in megasas_probe_one()
7547 if (instance->PlasmaFW111) { in megasas_probe_one()
7548 instance->vf_affiliation_111 = in megasas_probe_one()
7551 &instance->vf_affiliation_111_h, in megasas_probe_one()
7553 if (!instance->vf_affiliation_111) in megasas_probe_one()
7557 instance->vf_affiliation = in megasas_probe_one()
7561 &instance->vf_affiliation_h, in megasas_probe_one()
7563 if (!instance->vf_affiliation) in megasas_probe_one()
7572 pci_set_drvdata(pdev, instance); in megasas_probe_one()
7579 megasas_mgmt_info.instance[megasas_mgmt_info.max_index] = instance; in megasas_probe_one()
7585 if (megasas_io_attach(instance)) in megasas_probe_one()
7588 instance->unload = 0; in megasas_probe_one()
7592 if (!instance->enable_fw_dev_list || in megasas_probe_one()
7593 (instance->host_device_list_buf->count > 0)) in megasas_probe_one()
7599 if (megasas_start_aen(instance)) { in megasas_probe_one()
7604 megasas_setup_debugfs(instance); in megasas_probe_one()
7607 if (instance->requestorId) in megasas_probe_one()
7608 megasas_get_ld_vf_affiliation(instance, 1); in megasas_probe_one()
7613 instance->unload = 1; in megasas_probe_one()
7614 scsi_remove_host(instance->host); in megasas_probe_one()
7618 megasas_mgmt_info.instance[megasas_mgmt_info.max_index] = NULL; in megasas_probe_one()
7620 if (instance->requestorId && !instance->skip_heartbeat_timer_del) in megasas_probe_one()
7621 del_timer_sync(&instance->sriov_heartbeat_timer); in megasas_probe_one()
7623 instance->instancet->disable_intr(instance); in megasas_probe_one()
7624 megasas_destroy_irqs(instance); in megasas_probe_one()
7626 if (instance->adapter_type != MFI_SERIES) in megasas_probe_one()
7627 megasas_release_fusion(instance); in megasas_probe_one()
7629 megasas_release_mfi(instance); in megasas_probe_one()
7631 if (instance->msix_vectors) in megasas_probe_one()
7632 pci_free_irq_vectors(instance->pdev); in megasas_probe_one()
7633 instance->msix_vectors = 0; in megasas_probe_one()
7635 if (instance->fw_crash_state != UNAVAILABLE) in megasas_probe_one()
7636 megasas_free_host_crash_buffer(instance); in megasas_probe_one()
7638 if (instance->adapter_type != MFI_SERIES) in megasas_probe_one()
7639 megasas_fusion_stop_watchdog(instance); in megasas_probe_one()
7652 static void megasas_flush_cache(struct megasas_instance *instance) in megasas_flush_cache() argument
7657 if (atomic_read(&instance->adprecovery) == MEGASAS_HW_CRITICAL_ERROR) in megasas_flush_cache()
7660 cmd = megasas_get_cmd(instance); in megasas_flush_cache()
7679 if (megasas_issue_blocked_cmd(instance, cmd, MFI_IO_TIMEOUT_SECS) in megasas_flush_cache()
7681 dev_err(&instance->pdev->dev, in megasas_flush_cache()
7686 megasas_return_cmd(instance, cmd); in megasas_flush_cache()
7694 static void megasas_shutdown_controller(struct megasas_instance *instance, in megasas_shutdown_controller() argument
7700 if (atomic_read(&instance->adprecovery) == MEGASAS_HW_CRITICAL_ERROR) in megasas_shutdown_controller()
7703 cmd = megasas_get_cmd(instance); in megasas_shutdown_controller()
7708 if (instance->aen_cmd) in megasas_shutdown_controller()
7709 megasas_issue_blocked_abort_cmd(instance, in megasas_shutdown_controller()
7710 instance->aen_cmd, MFI_IO_TIMEOUT_SECS); in megasas_shutdown_controller()
7711 if (instance->map_update_cmd) in megasas_shutdown_controller()
7712 megasas_issue_blocked_abort_cmd(instance, in megasas_shutdown_controller()
7713 instance->map_update_cmd, MFI_IO_TIMEOUT_SECS); in megasas_shutdown_controller()
7714 if (instance->jbod_seq_cmd) in megasas_shutdown_controller()
7715 megasas_issue_blocked_abort_cmd(instance, in megasas_shutdown_controller()
7716 instance->jbod_seq_cmd, MFI_IO_TIMEOUT_SECS); in megasas_shutdown_controller()
7731 if (megasas_issue_blocked_cmd(instance, cmd, MFI_IO_TIMEOUT_SECS) in megasas_shutdown_controller()
7733 dev_err(&instance->pdev->dev, in megasas_shutdown_controller()
7738 megasas_return_cmd(instance, cmd); in megasas_shutdown_controller()
7748 struct megasas_instance *instance; in megasas_suspend() local
7750 instance = dev_get_drvdata(dev); in megasas_suspend()
7752 if (!instance) in megasas_suspend()
7755 instance->unload = 1; in megasas_suspend()
7760 if (instance->requestorId && !instance->skip_heartbeat_timer_del) in megasas_suspend()
7761 del_timer_sync(&instance->sriov_heartbeat_timer); in megasas_suspend()
7764 if (instance->adapter_type != MFI_SERIES) in megasas_suspend()
7765 megasas_fusion_stop_watchdog(instance); in megasas_suspend()
7767 megasas_flush_cache(instance); in megasas_suspend()
7768 megasas_shutdown_controller(instance, MR_DCMD_HIBERNATE_SHUTDOWN); in megasas_suspend()
7771 if (instance->ev != NULL) { in megasas_suspend()
7772 struct megasas_aen_event *ev = instance->ev; in megasas_suspend()
7774 instance->ev = NULL; in megasas_suspend()
7777 tasklet_kill(&instance->isr_tasklet); in megasas_suspend()
7779 pci_set_drvdata(instance->pdev, instance); in megasas_suspend()
7780 instance->instancet->disable_intr(instance); in megasas_suspend()
7782 megasas_destroy_irqs(instance); in megasas_suspend()
7784 if (instance->msix_vectors) in megasas_suspend()
7785 pci_free_irq_vectors(instance->pdev); in megasas_suspend()
7799 struct megasas_instance *instance; in megasas_resume() local
7802 instance = dev_get_drvdata(dev); in megasas_resume()
7804 if (!instance) in megasas_resume()
7807 host = instance->host; in megasas_resume()
7815 if (megasas_transition_to_ready(instance, 0)) { in megasas_resume()
7816 dev_info(&instance->pdev->dev, in megasas_resume()
7819 if (instance->adapter_type != MFI_SERIES) { in megasas_resume()
7821 instance->instancet->read_fw_status_reg(instance); in megasas_resume()
7824 (instance, true, 0)) == FAILED)) in megasas_resume()
7827 atomic_set(&instance->fw_reset_no_pci_access, 1); in megasas_resume()
7828 instance->instancet->adp_reset in megasas_resume()
7829 (instance, instance->reg_set); in megasas_resume()
7830 atomic_set(&instance->fw_reset_no_pci_access, 0); in megasas_resume()
7835 if (megasas_transition_to_ready(instance, 0)) in megasas_resume()
7839 dev_info(&instance->pdev->dev, in megasas_resume()
7843 if (megasas_set_dma_mask(instance)) in megasas_resume()
7850 atomic_set(&instance->fw_outstanding, 0); in megasas_resume()
7851 atomic_set(&instance->ldio_outstanding, 0); in megasas_resume()
7854 if (instance->msix_vectors) in megasas_resume()
7855 megasas_alloc_irq_vectors(instance); in megasas_resume()
7857 if (!instance->msix_vectors) { in megasas_resume()
7858 rval = pci_alloc_irq_vectors(instance->pdev, 1, 1, in megasas_resume()
7864 megasas_setup_reply_map(instance); in megasas_resume()
7866 if (instance->adapter_type != MFI_SERIES) { in megasas_resume()
7867 megasas_reset_reply_desc(instance); in megasas_resume()
7868 if (megasas_ioc_init_fusion(instance)) { in megasas_resume()
7869 megasas_free_cmds(instance); in megasas_resume()
7870 megasas_free_cmds_fusion(instance); in megasas_resume()
7873 if (!megasas_get_map_info(instance)) in megasas_resume()
7874 megasas_sync_map_info(instance); in megasas_resume()
7876 *instance->producer = 0; in megasas_resume()
7877 *instance->consumer = 0; in megasas_resume()
7878 if (megasas_issue_init_mfi(instance)) in megasas_resume()
7882 if (megasas_get_ctrl_info(instance) != DCMD_SUCCESS) in megasas_resume()
7885 tasklet_init(&instance->isr_tasklet, instance->instancet->tasklet, in megasas_resume()
7886 (unsigned long)instance); in megasas_resume()
7888 if (instance->msix_vectors ? in megasas_resume()
7889 megasas_setup_irqs_msix(instance, 0) : in megasas_resume()
7890 megasas_setup_irqs_ioapic(instance)) in megasas_resume()
7893 if (instance->adapter_type != MFI_SERIES) in megasas_resume()
7894 megasas_setup_irq_poll(instance); in megasas_resume()
7897 if (instance->requestorId) { in megasas_resume()
7898 if (!megasas_sriov_start_heartbeat(instance, 0)) in megasas_resume()
7899 megasas_start_timer(instance); in megasas_resume()
7901 instance->skip_heartbeat_timer_del = 1; in megasas_resume()
7906 instance->instancet->enable_intr(instance); in megasas_resume()
7907 megasas_setup_jbod_map(instance); in megasas_resume()
7908 instance->unload = 0; in megasas_resume()
7913 if (megasas_start_aen(instance)) in megasas_resume()
7914 dev_err(&instance->pdev->dev, "Start AEN failed\n"); in megasas_resume()
7917 if (instance->adapter_type != MFI_SERIES) in megasas_resume()
7918 if (megasas_fusion_start_watchdog(instance) != SUCCESS) in megasas_resume()
7924 if (instance->requestorId && !instance->skip_heartbeat_timer_del) in megasas_resume()
7925 del_timer_sync(&instance->sriov_heartbeat_timer); in megasas_resume()
7927 megasas_free_ctrl_dma_buffers(instance); in megasas_resume()
7928 megasas_free_ctrl_mem(instance); in megasas_resume()
7939 megasas_wait_for_adapter_operational(struct megasas_instance *instance) in megasas_wait_for_adapter_operational() argument
7946 adp_state = atomic_read(&instance->adprecovery); in megasas_wait_for_adapter_operational()
7952 dev_notice(&instance->pdev->dev, "waiting for controller reset to finish\n"); in megasas_wait_for_adapter_operational()
7958 dev_info(&instance->pdev->dev, in megasas_wait_for_adapter_operational()
7975 struct megasas_instance *instance; in megasas_detach_one() local
7979 instance = pci_get_drvdata(pdev); in megasas_detach_one()
7981 if (!instance) in megasas_detach_one()
7984 host = instance->host; in megasas_detach_one()
7985 fusion = instance->ctrl_context; in megasas_detach_one()
7988 if (instance->requestorId && !instance->skip_heartbeat_timer_del) in megasas_detach_one()
7989 del_timer_sync(&instance->sriov_heartbeat_timer); in megasas_detach_one()
7992 if (instance->adapter_type != MFI_SERIES) in megasas_detach_one()
7993 megasas_fusion_stop_watchdog(instance); in megasas_detach_one()
7995 if (instance->fw_crash_state != UNAVAILABLE) in megasas_detach_one()
7996 megasas_free_host_crash_buffer(instance); in megasas_detach_one()
7997 scsi_remove_host(instance->host); in megasas_detach_one()
7998 instance->unload = 1; in megasas_detach_one()
8000 if (megasas_wait_for_adapter_operational(instance)) in megasas_detach_one()
8003 megasas_flush_cache(instance); in megasas_detach_one()
8004 megasas_shutdown_controller(instance, MR_DCMD_CTRL_SHUTDOWN); in megasas_detach_one()
8008 if (instance->ev != NULL) { in megasas_detach_one()
8009 struct megasas_aen_event *ev = instance->ev; in megasas_detach_one()
8011 instance->ev = NULL; in megasas_detach_one()
8015 wake_up_all(&instance->int_cmd_wait_q); in megasas_detach_one()
8017 tasklet_kill(&instance->isr_tasklet); in megasas_detach_one()
8024 if (megasas_mgmt_info.instance[i] == instance) { in megasas_detach_one()
8026 megasas_mgmt_info.instance[i] = NULL; in megasas_detach_one()
8032 instance->instancet->disable_intr(instance); in megasas_detach_one()
8034 megasas_destroy_irqs(instance); in megasas_detach_one()
8036 if (instance->msix_vectors) in megasas_detach_one()
8037 pci_free_irq_vectors(instance->pdev); in megasas_detach_one()
8039 if (instance->adapter_type >= VENTURA_SERIES) { in megasas_detach_one()
8047 if (instance->adapter_type != MFI_SERIES) { in megasas_detach_one()
8048 megasas_release_fusion(instance); in megasas_detach_one()
8054 dma_free_coherent(&instance->pdev->dev, in megasas_detach_one()
8067 dma_free_coherent(&instance->pdev->dev, in megasas_detach_one()
8073 megasas_release_mfi(instance); in megasas_detach_one()
8076 if (instance->vf_affiliation) in megasas_detach_one()
8079 instance->vf_affiliation, in megasas_detach_one()
8080 instance->vf_affiliation_h); in megasas_detach_one()
8082 if (instance->vf_affiliation_111) in megasas_detach_one()
8085 instance->vf_affiliation_111, in megasas_detach_one()
8086 instance->vf_affiliation_111_h); in megasas_detach_one()
8088 if (instance->hb_host_mem) in megasas_detach_one()
8090 instance->hb_host_mem, in megasas_detach_one()
8091 instance->hb_host_mem_h); in megasas_detach_one()
8093 megasas_free_ctrl_dma_buffers(instance); in megasas_detach_one()
8095 megasas_free_ctrl_mem(instance); in megasas_detach_one()
8097 megasas_destroy_debugfs(instance); in megasas_detach_one()
8110 struct megasas_instance *instance = pci_get_drvdata(pdev); in megasas_shutdown() local
8112 if (!instance) in megasas_shutdown()
8115 instance->unload = 1; in megasas_shutdown()
8117 if (megasas_wait_for_adapter_operational(instance)) in megasas_shutdown()
8120 megasas_flush_cache(instance); in megasas_shutdown()
8121 megasas_shutdown_controller(instance, MR_DCMD_CTRL_SHUTDOWN); in megasas_shutdown()
8124 instance->instancet->disable_intr(instance); in megasas_shutdown()
8125 megasas_destroy_irqs(instance); in megasas_shutdown()
8127 if (instance->msix_vectors) in megasas_shutdown()
8128 pci_free_irq_vectors(instance->pdev); in megasas_shutdown()
8213 local_instance = megasas_mgmt_info.instance[i]; in megasas_set_crash_dump_params_ioctl()
8243 megasas_mgmt_fw_ioctl(struct megasas_instance *instance, in megasas_mgmt_fw_ioctl() argument
8262 dev_printk(KERN_DEBUG, &instance->pdev->dev, "SGE count [%d] > max limit [%d]\n", in megasas_mgmt_fw_ioctl()
8269 !instance->support_nvme_passthru) || in megasas_mgmt_fw_ioctl()
8271 !instance->support_pci_lane_margining)) { in megasas_mgmt_fw_ioctl()
8272 dev_err(&instance->pdev->dev, in megasas_mgmt_fw_ioctl()
8278 cmd = megasas_get_cmd(instance); in megasas_mgmt_fw_ioctl()
8280 dev_printk(KERN_DEBUG, &instance->pdev->dev, "Failed to get a cmd packet\n"); in megasas_mgmt_fw_ioctl()
8296 if (instance->consistent_mask_64bit) in megasas_mgmt_fw_ioctl()
8307 mutex_lock(&instance->reset_mutex); in megasas_mgmt_fw_ioctl()
8308 if (megasas_get_ctrl_info(instance) != DCMD_SUCCESS) { in megasas_mgmt_fw_ioctl()
8309 megasas_return_cmd(instance, cmd); in megasas_mgmt_fw_ioctl()
8310 mutex_unlock(&instance->reset_mutex); in megasas_mgmt_fw_ioctl()
8313 mutex_unlock(&instance->reset_mutex); in megasas_mgmt_fw_ioctl()
8318 megasas_return_cmd(instance, cmd); in megasas_mgmt_fw_ioctl()
8330 if (instance->consistent_mask_64bit) in megasas_mgmt_fw_ioctl()
8344 kbuff_arr[i] = dma_alloc_coherent(&instance->pdev->dev, in megasas_mgmt_fw_ioctl()
8348 dev_printk(KERN_DEBUG, &instance->pdev->dev, "Failed to alloc " in megasas_mgmt_fw_ioctl()
8358 if (instance->consistent_mask_64bit) { in megasas_mgmt_fw_ioctl()
8385 sense = dma_alloc_coherent(&instance->pdev->dev, ioc->sense_len, in megasas_mgmt_fw_ioctl()
8403 ret = megasas_issue_blocked_cmd(instance, cmd, 0); in megasas_mgmt_fw_ioctl()
8408 dev_err(&instance->pdev->dev, in megasas_mgmt_fw_ioctl()
8418 if (instance->unload == 1) { in megasas_mgmt_fw_ioctl()
8419 dev_info(&instance->pdev->dev, "Driver unload is in progress " in megasas_mgmt_fw_ioctl()
8451 dev_err(&instance->pdev->dev, "Failed to copy out to user " in megasas_mgmt_fw_ioctl()
8463 dev_printk(KERN_DEBUG, &instance->pdev->dev, "Error copying out cmd_status\n"); in megasas_mgmt_fw_ioctl()
8469 dma_free_coherent(&instance->pdev->dev, ioc->sense_len, in megasas_mgmt_fw_ioctl()
8475 if (instance->consistent_mask_64bit) in megasas_mgmt_fw_ioctl()
8476 dma_free_coherent(&instance->pdev->dev, in megasas_mgmt_fw_ioctl()
8481 dma_free_coherent(&instance->pdev->dev, in megasas_mgmt_fw_ioctl()
8489 megasas_return_cmd(instance, cmd); in megasas_mgmt_fw_ioctl()
8530 struct megasas_instance *instance; in megasas_mgmt_ioctl_fw() local
8541 instance = megasas_lookup_instance(ioc->host_no); in megasas_mgmt_ioctl_fw()
8542 if (!instance) { in megasas_mgmt_ioctl_fw()
8548 if (instance->requestorId && !allow_vf_ioctls) { in megasas_mgmt_ioctl_fw()
8553 if (atomic_read(&instance->adprecovery) == MEGASAS_HW_CRITICAL_ERROR) { in megasas_mgmt_ioctl_fw()
8554 dev_err(&instance->pdev->dev, "Controller in crit error\n"); in megasas_mgmt_ioctl_fw()
8559 if (instance->unload == 1) { in megasas_mgmt_ioctl_fw()
8564 if (down_interruptible(&instance->ioctl_sem)) { in megasas_mgmt_ioctl_fw()
8569 if (megasas_wait_for_adapter_operational(instance)) { in megasas_mgmt_ioctl_fw()
8574 error = megasas_mgmt_fw_ioctl(instance, user_ioc, ioc); in megasas_mgmt_ioctl_fw()
8576 up(&instance->ioctl_sem); in megasas_mgmt_ioctl_fw()
8585 struct megasas_instance *instance; in megasas_mgmt_ioctl_aen() local
8598 instance = megasas_lookup_instance(aen.host_no); in megasas_mgmt_ioctl_aen()
8600 if (!instance) in megasas_mgmt_ioctl_aen()
8603 if (atomic_read(&instance->adprecovery) == MEGASAS_HW_CRITICAL_ERROR) { in megasas_mgmt_ioctl_aen()
8607 if (instance->unload == 1) { in megasas_mgmt_ioctl_aen()
8611 if (megasas_wait_for_adapter_operational(instance)) in megasas_mgmt_ioctl_aen()
8614 mutex_lock(&instance->reset_mutex); in megasas_mgmt_ioctl_aen()
8615 error = megasas_register_aen(instance, aen.seq_num, in megasas_mgmt_ioctl_aen()
8617 mutex_unlock(&instance->reset_mutex); in megasas_mgmt_ioctl_aen()
8770 int megasas_update_device_list(struct megasas_instance *instance, in megasas_update_device_list() argument
8775 if (instance->enable_fw_dev_list) { in megasas_update_device_list()
8776 dcmd_ret = megasas_host_device_list_query(instance, false); in megasas_update_device_list()
8781 dcmd_ret = megasas_get_pd_list(instance); in megasas_update_device_list()
8788 if (!instance->requestorId || in megasas_update_device_list()
8789 megasas_get_ld_vf_affiliation(instance, 0)) { in megasas_update_device_list()
8790 dcmd_ret = megasas_ld_list_query(instance, in megasas_update_device_list()
8810 void megasas_add_remove_devices(struct megasas_instance *instance, in megasas_add_remove_devices() argument
8822 host = instance->host; in megasas_add_remove_devices()
8824 if (instance->enable_fw_dev_list) { in megasas_add_remove_devices()
8825 targetid_list = instance->host_device_list_buf; in megasas_add_remove_devices()
8854 if (instance->pd_list[pd_index].driveState == in megasas_add_remove_devices()
8874 if (instance->ld_ids[ld_index] != 0xff) { in megasas_add_remove_devices()
8894 struct megasas_instance *instance = ev->instance; in megasas_aen_polling() local
8903 if (!instance) { in megasas_aen_polling()
8910 mutex_lock(&instance->reset_mutex); in megasas_aen_polling()
8912 instance->ev = NULL; in megasas_aen_polling()
8913 if (instance->evt_detail) { in megasas_aen_polling()
8914 megasas_decode_evt(instance); in megasas_aen_polling()
8916 switch (le32_to_cpu(instance->evt_detail->code)) { in megasas_aen_polling()
8925 ld_target_id = instance->evt_detail->args.ld.target_id; in megasas_aen_polling()
8926 sdev1 = scsi_device_lookup(instance->host, in megasas_aen_polling()
8945 dev_info(&instance->pdev->dev, "scanning for scsi%d...\n", in megasas_aen_polling()
8946 instance->host->host_no); in megasas_aen_polling()
8950 dcmd_ret = megasas_get_ctrl_info(instance); in megasas_aen_polling()
8952 instance->snapdump_wait_time) { in megasas_aen_polling()
8953 megasas_get_snapdump_properties(instance); in megasas_aen_polling()
8954 dev_info(&instance->pdev->dev, in megasas_aen_polling()
8956 instance->snapdump_wait_time); in megasas_aen_polling()
8964 dev_err(&instance->pdev->dev, "invalid evt_detail!\n"); in megasas_aen_polling()
8965 mutex_unlock(&instance->reset_mutex); in megasas_aen_polling()
8971 dcmd_ret = megasas_update_device_list(instance, event_type); in megasas_aen_polling()
8973 mutex_unlock(&instance->reset_mutex); in megasas_aen_polling()
8976 megasas_add_remove_devices(instance, event_type); in megasas_aen_polling()
8979 seq_num = le32_to_cpu(instance->evt_detail->seq_num) + 1; in megasas_aen_polling()
8981 seq_num = instance->last_seq_num; in megasas_aen_polling()
8988 if (instance->aen_cmd != NULL) { in megasas_aen_polling()
8993 mutex_lock(&instance->reset_mutex); in megasas_aen_polling()
8994 error = megasas_register_aen(instance, seq_num, in megasas_aen_polling()
8997 dev_err(&instance->pdev->dev, in megasas_aen_polling()
9000 mutex_unlock(&instance->reset_mutex); in megasas_aen_polling()