• Home
  • Raw
  • Download

Lines Matching full:instance

52 megasas_complete_cmd(struct megasas_instance *instance,
55 wait_and_poll(struct megasas_instance *instance, struct megasas_cmd *cmd,
59 megasas_clear_intr_fusion(struct megasas_instance *instance);
61 int megasas_transition_to_ready(struct megasas_instance *instance, int ocr);
64 int megasas_sriov_start_heartbeat(struct megasas_instance *instance,
69 static void megasas_free_rdpq_fusion(struct megasas_instance *instance);
70 static void megasas_free_reply_fusion(struct megasas_instance *instance);
72 void megasas_configure_queue_sizes(struct megasas_instance *instance);
73 static void megasas_fusion_crash_dump(struct megasas_instance *instance);
78 * @instance: adapter's soft state
88 megasas_adp_reset_wait_for_ready(struct megasas_instance *instance, in megasas_adp_reset_wait_for_ready() argument
99 dev_info(&instance->pdev->dev, in megasas_adp_reset_wait_for_ready()
103 pci_cfg_access_lock(instance->pdev); in megasas_adp_reset_wait_for_ready()
106 if (instance->instancet->adp_reset in megasas_adp_reset_wait_for_ready()
107 (instance, instance->reg_set)) in megasas_adp_reset_wait_for_ready()
112 if (megasas_transition_to_ready(instance, ocr_context)) { in megasas_adp_reset_wait_for_ready()
113 dev_warn(&instance->pdev->dev, in megasas_adp_reset_wait_for_ready()
115 instance->host->host_no); in megasas_adp_reset_wait_for_ready()
122 dev_info(&instance->pdev->dev, in megasas_adp_reset_wait_for_ready()
126 pci_cfg_access_unlock(instance->pdev); in megasas_adp_reset_wait_for_ready()
134 * @instance: adapter's soft instance
143 (struct megasas_instance *instance, dma_addr_t start_addr, size_t size) in megasas_check_same_4gb_region() argument
150 dev_err(&instance->pdev->dev, in megasas_check_same_4gb_region()
162 * @instance: adapter's soft instance
165 megasas_enable_intr_fusion(struct megasas_instance *instance) in megasas_enable_intr_fusion() argument
168 regs = instance->reg_set; in megasas_enable_intr_fusion()
170 instance->mask_interrupts = 0; in megasas_enable_intr_fusion()
178 dev_info(&instance->pdev->dev, "%s is called outbound_intr_mask:0x%08x\n", in megasas_enable_intr_fusion()
184 * @instance: adapter's soft instance
187 megasas_disable_intr_fusion(struct megasas_instance *instance) in megasas_disable_intr_fusion() argument
191 regs = instance->reg_set; in megasas_disable_intr_fusion()
192 instance->mask_interrupts = 1; in megasas_disable_intr_fusion()
196 dev_info(&instance->pdev->dev, "%s is called outbound_intr_mask:0x%08x\n", in megasas_disable_intr_fusion()
201 megasas_clear_intr_fusion(struct megasas_instance *instance) in megasas_clear_intr_fusion() argument
205 regs = instance->reg_set; in megasas_clear_intr_fusion()
209 status = megasas_readl(instance, in megasas_clear_intr_fusion()
225 * @instance: Adapter soft state
231 *instance, u32 blk_tag) in megasas_get_cmd_fusion()
235 fusion = instance->ctrl_context; in megasas_get_cmd_fusion()
241 * @instance: Adapter soft state
244 inline void megasas_return_cmd_fusion(struct megasas_instance *instance, in megasas_return_cmd_fusion() argument
255 * @instance: Adapter soft state
259 megasas_write_64bit_req_desc(struct megasas_instance *instance, in megasas_write_64bit_req_desc() argument
265 writeq(req_data, &instance->reg_set->inbound_low_queue_port); in megasas_write_64bit_req_desc()
268 spin_lock_irqsave(&instance->hba_lock, flags); in megasas_write_64bit_req_desc()
270 &instance->reg_set->inbound_low_queue_port); in megasas_write_64bit_req_desc()
272 &instance->reg_set->inbound_high_queue_port); in megasas_write_64bit_req_desc()
273 spin_unlock_irqrestore(&instance->hba_lock, flags); in megasas_write_64bit_req_desc()
279 * @instance: Adapter soft state
286 megasas_fire_cmd_fusion(struct megasas_instance *instance, in megasas_fire_cmd_fusion() argument
289 if (instance->atomic_desc_support) in megasas_fire_cmd_fusion()
291 &instance->reg_set->inbound_single_queue_port); in megasas_fire_cmd_fusion()
293 megasas_write_64bit_req_desc(instance, req_desc); in megasas_fire_cmd_fusion()
298 * @instance: Adapter soft state
308 megasas_fusion_update_can_queue(struct megasas_instance *instance, int fw_boot_context) in megasas_fusion_update_can_queue() argument
314 if (instance->adapter_type < VENTURA_SERIES) in megasas_fusion_update_can_queue()
316 megasas_readl(instance, in megasas_fusion_update_can_queue()
317 &instance->reg_set->outbound_scratch_pad_2) & 0x00FFFF; in megasas_fusion_update_can_queue()
320 cur_max_fw_cmds = instance->instancet->read_fw_status_reg(instance) & 0x00FFFF; in megasas_fusion_update_can_queue()
323 (instance->instancet->read_fw_status_reg(instance) & 0x00FFFF) - MEGASAS_FUSION_IOCTL_CMDS; in megasas_fusion_update_can_queue()
325 dev_info(&instance->pdev->dev, in megasas_fusion_update_can_queue()
331 if (cur_max_fw_cmds < instance->max_fw_cmds) { in megasas_fusion_update_can_queue()
332 instance->cur_can_queue = in megasas_fusion_update_can_queue()
335 instance->host->can_queue = instance->cur_can_queue; in megasas_fusion_update_can_queue()
336 instance->ldio_threshold = ldio_threshold; in megasas_fusion_update_can_queue()
339 instance->max_fw_cmds = cur_max_fw_cmds; in megasas_fusion_update_can_queue()
340 instance->ldio_threshold = ldio_threshold; in megasas_fusion_update_can_queue()
343 instance->max_fw_cmds = min(instance->max_fw_cmds, in megasas_fusion_update_can_queue()
350 instance->max_fw_cmds = instance->max_fw_cmds-1; in megasas_fusion_update_can_queue()
355 megasas_get_msix_index(struct megasas_instance *instance, in megasas_get_msix_index() argument
367 if (instance->perf_mode == MR_BALANCED_PERF_MODE && in megasas_get_msix_index()
370 mega_mod64((atomic64_add_return(1, &instance->high_iops_outstanding) / in megasas_get_msix_index()
371 MR_HIGH_IOPS_BATCH_COUNT), instance->low_latency_index_start); in megasas_get_msix_index()
372 } else if (instance->msix_load_balance) { in megasas_get_msix_index()
374 (mega_mod64(atomic64_add_return(1, &instance->total_io_count), in megasas_get_msix_index()
375 instance->msix_vectors)); in megasas_get_msix_index()
376 } else if (instance->host->nr_hw_queues > 1) { in megasas_get_msix_index()
380 instance->low_latency_index_start; in megasas_get_msix_index()
383 instance->reply_map[raw_smp_processor_id()]; in megasas_get_msix_index()
389 * @instance: Adapter soft state
392 megasas_free_cmds_fusion(struct megasas_instance *instance) in megasas_free_cmds_fusion() argument
395 struct fusion_context *fusion = instance->ctrl_context; in megasas_free_cmds_fusion()
404 for (i = 0; i < instance->max_mpt_cmds; i++) { in megasas_free_cmds_fusion()
428 if (instance->is_rdpq) in megasas_free_cmds_fusion()
429 megasas_free_rdpq_fusion(instance); in megasas_free_cmds_fusion()
431 megasas_free_reply_fusion(instance); in megasas_free_cmds_fusion()
435 dma_free_coherent(&instance->pdev->dev, in megasas_free_cmds_fusion()
450 * @instance: Adapter soft state
453 static int megasas_create_sg_sense_fusion(struct megasas_instance *instance) in megasas_create_sg_sense_fusion() argument
462 fusion = instance->ctrl_context; in megasas_create_sg_sense_fusion()
463 max_cmd = instance->max_fw_cmds; in megasas_create_sg_sense_fusion()
464 sense_sz = instance->max_mpt_cmds * SCSI_SENSE_BUFFERSIZE; in megasas_create_sg_sense_fusion()
467 dma_pool_create("mr_sg", &instance->pdev->dev, in megasas_create_sg_sense_fusion()
468 instance->max_chain_frame_sz, in megasas_create_sg_sense_fusion()
472 dma_pool_create("mr_sense", &instance->pdev->dev, in megasas_create_sg_sense_fusion()
476 dev_err(&instance->pdev->dev, in megasas_create_sg_sense_fusion()
484 dev_err(&instance->pdev->dev, in megasas_create_sg_sense_fusion()
500 if (!megasas_check_same_4gb_region(instance, fusion->sense_phys_addr, in megasas_create_sg_sense_fusion()
508 dma_pool_create("mr_sense_align", &instance->pdev->dev, in megasas_create_sg_sense_fusion()
512 dev_err(&instance->pdev->dev, in megasas_create_sg_sense_fusion()
520 dev_err(&instance->pdev->dev, in megasas_create_sg_sense_fusion()
539 dev_err(&instance->pdev->dev, in megasas_create_sg_sense_fusion()
546 for (i = max_cmd; i < instance->max_mpt_cmds; i++) { in megasas_create_sg_sense_fusion()
558 megasas_alloc_cmdlist_fusion(struct megasas_instance *instance) in megasas_alloc_cmdlist_fusion() argument
563 fusion = instance->ctrl_context; in megasas_alloc_cmdlist_fusion()
565 max_mpt_cmd = instance->max_mpt_cmds; in megasas_alloc_cmdlist_fusion()
576 dev_err(&instance->pdev->dev, in megasas_alloc_cmdlist_fusion()
588 dev_err(&instance->pdev->dev, in megasas_alloc_cmdlist_fusion()
598 megasas_alloc_request_fusion(struct megasas_instance *instance) in megasas_alloc_request_fusion() argument
602 fusion = instance->ctrl_context; in megasas_alloc_request_fusion()
606 dma_pool_create("mr_ioreq", &instance->pdev->dev, in megasas_alloc_request_fusion()
610 dev_err(&instance->pdev->dev, in megasas_alloc_request_fusion()
620 if (instance->max_fw_cmds >= (MEGASAS_REDUCE_QD_COUNT * 2)) { in megasas_alloc_request_fusion()
621 instance->max_fw_cmds -= MEGASAS_REDUCE_QD_COUNT; in megasas_alloc_request_fusion()
623 megasas_configure_queue_sizes(instance); in megasas_alloc_request_fusion()
626 dev_err(&instance->pdev->dev, in megasas_alloc_request_fusion()
632 if (!megasas_check_same_4gb_region(instance, in megasas_alloc_request_fusion()
643 &instance->pdev->dev, in megasas_alloc_request_fusion()
649 dev_err(&instance->pdev->dev, in megasas_alloc_request_fusion()
660 dev_err(&instance->pdev->dev, in megasas_alloc_request_fusion()
667 dma_alloc_coherent(&instance->pdev->dev, in megasas_alloc_request_fusion()
671 dev_err(&instance->pdev->dev, in megasas_alloc_request_fusion()
680 megasas_alloc_reply_fusion(struct megasas_instance *instance) in megasas_alloc_reply_fusion() argument
685 fusion = instance->ctrl_context; in megasas_alloc_reply_fusion()
687 count = instance->msix_vectors > 0 ? instance->msix_vectors : 1; in megasas_alloc_reply_fusion()
689 dma_pool_create("mr_reply", &instance->pdev->dev, in megasas_alloc_reply_fusion()
693 dev_err(&instance->pdev->dev, in megasas_alloc_reply_fusion()
702 dev_err(&instance->pdev->dev, in megasas_alloc_reply_fusion()
707 if (!megasas_check_same_4gb_region(instance, in megasas_alloc_reply_fusion()
718 &instance->pdev->dev, in megasas_alloc_reply_fusion()
724 dev_err(&instance->pdev->dev, in megasas_alloc_reply_fusion()
735 dev_err(&instance->pdev->dev, in megasas_alloc_reply_fusion()
757 megasas_alloc_rdpq_fusion(struct megasas_instance *instance) in megasas_alloc_rdpq_fusion() argument
767 fusion = instance->ctrl_context; in megasas_alloc_rdpq_fusion()
772 fusion->rdpq_virt = dma_alloc_coherent(&instance->pdev->dev, in megasas_alloc_rdpq_fusion()
776 dev_err(&instance->pdev->dev, in megasas_alloc_rdpq_fusion()
781 msix_count = instance->msix_vectors > 0 ? instance->msix_vectors : 1; in megasas_alloc_rdpq_fusion()
784 &instance->pdev->dev, in megasas_alloc_rdpq_fusion()
788 &instance->pdev->dev, in megasas_alloc_rdpq_fusion()
795 dev_err(&instance->pdev->dev, in megasas_alloc_rdpq_fusion()
815 dev_err(&instance->pdev->dev, in megasas_alloc_rdpq_fusion()
831 if (!megasas_check_same_4gb_region(instance, rdpq_chunk_phys[i], in megasas_alloc_rdpq_fusion()
841 dev_err(&instance->pdev->dev, in megasas_alloc_rdpq_fusion()
881 megasas_free_rdpq_fusion(struct megasas_instance *instance) { in megasas_free_rdpq_fusion() argument
886 fusion = instance->ctrl_context; in megasas_free_rdpq_fusion()
900 dma_free_coherent(&instance->pdev->dev, in megasas_free_rdpq_fusion()
906 megasas_free_reply_fusion(struct megasas_instance *instance) { in megasas_free_reply_fusion() argument
910 fusion = instance->ctrl_context; in megasas_free_reply_fusion()
924 * @instance: Adapter soft state
939 megasas_alloc_cmds_fusion(struct megasas_instance *instance) in megasas_alloc_cmds_fusion() argument
949 fusion = instance->ctrl_context; in megasas_alloc_cmds_fusion()
951 if (megasas_alloc_request_fusion(instance)) in megasas_alloc_cmds_fusion()
954 if (instance->is_rdpq) { in megasas_alloc_cmds_fusion()
955 if (megasas_alloc_rdpq_fusion(instance)) in megasas_alloc_cmds_fusion()
958 if (megasas_alloc_reply_fusion(instance)) in megasas_alloc_cmds_fusion()
961 if (megasas_alloc_cmdlist_fusion(instance)) in megasas_alloc_cmds_fusion()
973 for (i = 0; i < instance->max_mpt_cmds; i++) { in megasas_alloc_cmds_fusion()
980 (i >= instance->max_scsi_cmds && i < instance->max_fw_cmds) ? in megasas_alloc_cmds_fusion()
981 (i - instance->max_scsi_cmds) : in megasas_alloc_cmds_fusion()
983 cmd->instance = instance; in megasas_alloc_cmds_fusion()
993 if (megasas_create_sg_sense_fusion(instance)) in megasas_alloc_cmds_fusion()
999 megasas_free_cmds_fusion(instance); in megasas_alloc_cmds_fusion()
1005 * @instance: Adapter soft state
1012 wait_and_poll(struct megasas_instance *instance, struct megasas_cmd *cmd, in wait_and_poll() argument
1028 status_reg = instance->instancet->read_fw_status_reg(instance) in wait_and_poll()
1045 * @instance: Adapter soft state
1050 megasas_ioc_init_fusion(struct megasas_instance *instance) in megasas_ioc_init_fusion() argument
1068 fusion = instance->ctrl_context; in megasas_ioc_init_fusion()
1076 (instance, &instance->reg_set->outbound_scratch_pad_1); in megasas_ioc_init_fusion()
1080 if (instance->adapter_type == INVADER_SERIES) { in megasas_ioc_init_fusion()
1084 if (instance->consistent_mask_64bit && !cur_fw_64bit_dma_capable) { in megasas_ioc_init_fusion()
1085 dev_err(&instance->pdev->dev, "Driver was operating on 64bit " in megasas_ioc_init_fusion()
1087 megaraid_sas_kill_hba(instance); in megasas_ioc_init_fusion()
1093 if (instance->is_rdpq && !cur_rdpq_mode) { in megasas_ioc_init_fusion()
1094 dev_err(&instance->pdev->dev, "Firmware downgrade *NOT SUPPORTED*" in megasas_ioc_init_fusion()
1103 if ((instance->low_latency_index_start == in megasas_ioc_init_fusion()
1105 instance->perf_mode = MR_BALANCED_PERF_MODE; in megasas_ioc_init_fusion()
1107 dev_info(&instance->pdev->dev, "Performance mode :%s (latency index = %d)\n", in megasas_ioc_init_fusion()
1108 MEGASAS_PERF_MODE_2STR(instance->perf_mode), in megasas_ioc_init_fusion()
1109 instance->low_latency_index_start); in megasas_ioc_init_fusion()
1111 instance->fw_sync_cache_support = (scratch_pad_1 & in megasas_ioc_init_fusion()
1113 dev_info(&instance->pdev->dev, "FW supports sync cache\t: %s\n", in megasas_ioc_init_fusion()
1114 instance->fw_sync_cache_support ? "Yes" : "No"); in megasas_ioc_init_fusion()
1125 IOCInitMessage->ReplyDescriptorPostQueueAddress = instance->is_rdpq ? in megasas_ioc_init_fusion()
1128 IOCInitMessage->MsgFlags = instance->is_rdpq ? in megasas_ioc_init_fusion()
1132 IOCInitMessage->HostMSIxVectors = instance->msix_vectors; in megasas_ioc_init_fusion()
1152 if (instance->adapter_type >= INVADER_SERIES) in megasas_ioc_init_fusion()
1161 if (instance->max_chain_frame_sz > MEGASAS_CHAIN_FRAME_SZ_MIN) in megasas_ioc_init_fusion()
1173 if (instance->consistent_mask_64bit) in megasas_ioc_init_fusion()
1180 if (instance->system_info_buf && sys_info) { in megasas_ioc_init_fusion()
1181 memcpy(instance->system_info_buf->systemId, sys_info, in megasas_ioc_init_fusion()
1183 instance->system_info_buf->systemIdLength = in megasas_ioc_init_fusion()
1185 init_frame->system_info_lo = cpu_to_le32(lower_32_bits(instance->system_info_h)); in megasas_ioc_init_fusion()
1186 init_frame->system_info_hi = cpu_to_le32(upper_32_bits(instance->system_info_h)); in megasas_ioc_init_fusion()
1199 switch (instance->perf_mode) { in megasas_ioc_init_fusion()
1202 cpu_to_le16(~(~0 << instance->low_latency_index_start/8)); in megasas_ioc_init_fusion()
1206 cpu_to_le16(~(~0 << instance->msix_vectors/8)); in megasas_ioc_init_fusion()
1220 instance->instancet->disable_intr(instance); in megasas_ioc_init_fusion()
1223 if (megasas_readl(instance, &instance->reg_set->doorbell) & 1) in megasas_ioc_init_fusion()
1230 megasas_write_64bit_req_desc(instance, &req_desc); in megasas_ioc_init_fusion()
1232 wait_and_poll(instance, cmd, MFI_IO_TIMEOUT_SECS); in megasas_ioc_init_fusion()
1240 if (instance->adapter_type >= AERO_SERIES) { in megasas_ioc_init_fusion()
1242 (instance, &instance->reg_set->outbound_scratch_pad_1); in megasas_ioc_init_fusion()
1244 instance->atomic_desc_support = in megasas_ioc_init_fusion()
1247 dev_info(&instance->pdev->dev, "FW supports atomic descriptor\t: %s\n", in megasas_ioc_init_fusion()
1248 instance->atomic_desc_support ? "Yes" : "No"); in megasas_ioc_init_fusion()
1254 dev_err(&instance->pdev->dev, in megasas_ioc_init_fusion()
1256 instance->host->host_no); in megasas_ioc_init_fusion()
1263 * @instance: Adapter soft state
1267 * issue command and return. If it is first instance of jbod map
1271 megasas_sync_pd_seq_num(struct megasas_instance *instance, bool pend) { in megasas_sync_pd_seq_num() argument
1276 struct fusion_context *fusion = instance->ctrl_context; in megasas_sync_pd_seq_num()
1280 pd_sync = (void *)fusion->pd_seq_sync[(instance->pd_seq_map_id & 1)]; in megasas_sync_pd_seq_num()
1281 pd_seq_h = fusion->pd_seq_phys[(instance->pd_seq_map_id & 1)]; in megasas_sync_pd_seq_num()
1284 cmd = megasas_get_cmd(instance); in megasas_sync_pd_seq_num()
1286 dev_err(&instance->pdev->dev, in megasas_sync_pd_seq_num()
1300 instance->jbod_seq_cmd = cmd; in megasas_sync_pd_seq_num()
1313 megasas_set_dma_settings(instance, dcmd, pd_seq_h, pd_seq_map_sz); in megasas_sync_pd_seq_num()
1316 instance->instancet->issue_dcmd(instance, cmd); in megasas_sync_pd_seq_num()
1321 if (!instance->mask_interrupts) in megasas_sync_pd_seq_num()
1322 ret = megasas_issue_blocked_cmd(instance, cmd, in megasas_sync_pd_seq_num()
1325 ret = megasas_issue_polled(instance, cmd); in megasas_sync_pd_seq_num()
1328 dev_warn(&instance->pdev->dev, in megasas_sync_pd_seq_num()
1335 dev_warn(&instance->pdev->dev, in megasas_sync_pd_seq_num()
1340 instance->pd_seq_map_id++; in megasas_sync_pd_seq_num()
1342 megasas_return_cmd(instance, cmd); in megasas_sync_pd_seq_num()
1348 * @instance: Adapter soft state
1362 megasas_get_ld_map_info(struct megasas_instance *instance) in megasas_get_ld_map_info() argument
1372 cmd = megasas_get_cmd(instance); in megasas_get_ld_map_info()
1375 dev_printk(KERN_DEBUG, &instance->pdev->dev, "Failed to get cmd for map info\n"); in megasas_get_ld_map_info()
1379 fusion = instance->ctrl_context; in megasas_get_ld_map_info()
1382 megasas_return_cmd(instance, cmd); in megasas_get_ld_map_info()
1390 ci = (void *) fusion->ld_map[(instance->map_id & 1)]; in megasas_get_ld_map_info()
1391 ci_h = fusion->ld_map_phys[(instance->map_id & 1)]; in megasas_get_ld_map_info()
1394 dev_printk(KERN_DEBUG, &instance->pdev->dev, "Failed to alloc mem for ld_map_info\n"); in megasas_get_ld_map_info()
1395 megasas_return_cmd(instance, cmd); in megasas_get_ld_map_info()
1410 megasas_set_dma_settings(instance, dcmd, ci_h, size_map_info); in megasas_get_ld_map_info()
1412 if (!instance->mask_interrupts) in megasas_get_ld_map_info()
1413 ret = megasas_issue_blocked_cmd(instance, cmd, in megasas_get_ld_map_info()
1416 ret = megasas_issue_polled(instance, cmd); in megasas_get_ld_map_info()
1419 dev_warn(&instance->pdev->dev, in megasas_get_ld_map_info()
1423 megasas_return_cmd(instance, cmd); in megasas_get_ld_map_info()
1429 megasas_get_map_info(struct megasas_instance *instance) in megasas_get_map_info() argument
1431 struct fusion_context *fusion = instance->ctrl_context; in megasas_get_map_info()
1434 if (!megasas_get_ld_map_info(instance)) { in megasas_get_map_info()
1435 if (MR_ValidateMapInfo(instance, instance->map_id)) { in megasas_get_map_info()
1445 * @instance: Adapter soft state
1452 megasas_sync_map_info(struct megasas_instance *instance) in megasas_sync_map_info() argument
1466 cmd = megasas_get_cmd(instance); in megasas_sync_map_info()
1469 dev_printk(KERN_DEBUG, &instance->pdev->dev, "Failed to get cmd for sync info\n"); in megasas_sync_map_info()
1473 fusion = instance->ctrl_context; in megasas_sync_map_info()
1476 megasas_return_cmd(instance, cmd); in megasas_sync_map_info()
1480 map = fusion->ld_drv_map[instance->map_id & 1]; in megasas_sync_map_info()
1489 fusion->ld_map[(instance->map_id - 1) & 1]; in megasas_sync_map_info()
1492 ci_h = fusion->ld_map_phys[(instance->map_id - 1) & 1]; in megasas_sync_map_info()
1515 megasas_set_dma_settings(instance, dcmd, ci_h, size_map_info); in megasas_sync_map_info()
1517 instance->map_update_cmd = cmd; in megasas_sync_map_info()
1519 instance->instancet->issue_dcmd(instance, cmd); in megasas_sync_map_info()
1526 * @instance: per adapter object
1531 megasas_display_intel_branding(struct megasas_instance *instance) in megasas_display_intel_branding() argument
1533 if (instance->pdev->subsystem_vendor != PCI_VENDOR_ID_INTEL) in megasas_display_intel_branding()
1536 switch (instance->pdev->device) { in megasas_display_intel_branding()
1538 switch (instance->pdev->subsystem_device) { in megasas_display_intel_branding()
1540 dev_info(&instance->pdev->dev, "scsi host %d: %s\n", in megasas_display_intel_branding()
1541 instance->host->host_no, in megasas_display_intel_branding()
1545 dev_info(&instance->pdev->dev, "scsi host %d: %s\n", in megasas_display_intel_branding()
1546 instance->host->host_no, in megasas_display_intel_branding()
1550 dev_info(&instance->pdev->dev, "scsi host %d: %s\n", in megasas_display_intel_branding()
1551 instance->host->host_no, in megasas_display_intel_branding()
1555 dev_info(&instance->pdev->dev, "scsi host %d: %s\n", in megasas_display_intel_branding()
1556 instance->host->host_no, in megasas_display_intel_branding()
1564 switch (instance->pdev->subsystem_device) { in megasas_display_intel_branding()
1566 dev_info(&instance->pdev->dev, "scsi host %d: %s\n", in megasas_display_intel_branding()
1567 instance->host->host_no, in megasas_display_intel_branding()
1571 dev_info(&instance->pdev->dev, "scsi host %d: %s\n", in megasas_display_intel_branding()
1572 instance->host->host_no, in megasas_display_intel_branding()
1581 switch (instance->pdev->subsystem_device) { in megasas_display_intel_branding()
1583 dev_info(&instance->pdev->dev, "scsi host %d: %s\n", in megasas_display_intel_branding()
1584 instance->host->host_no, in megasas_display_intel_branding()
1598 * @instance: Adapter soft state
1603 static inline int megasas_allocate_raid_maps(struct megasas_instance *instance) in megasas_allocate_raid_maps() argument
1608 fusion = instance->ctrl_context; in megasas_allocate_raid_maps()
1623 dev_err(&instance->pdev->dev, in megasas_allocate_raid_maps()
1633 fusion->ld_map[i] = dma_alloc_coherent(&instance->pdev->dev, in megasas_allocate_raid_maps()
1638 dev_err(&instance->pdev->dev, in megasas_allocate_raid_maps()
1650 dma_free_coherent(&instance->pdev->dev, in megasas_allocate_raid_maps()
1674 * @instance: Adapter soft state
1678 void megasas_configure_queue_sizes(struct megasas_instance *instance) in megasas_configure_queue_sizes() argument
1683 fusion = instance->ctrl_context; in megasas_configure_queue_sizes()
1684 max_cmd = instance->max_fw_cmds; in megasas_configure_queue_sizes()
1686 if (instance->adapter_type >= VENTURA_SERIES) in megasas_configure_queue_sizes()
1687 instance->max_mpt_cmds = instance->max_fw_cmds * RAID_1_PEER_CMDS; in megasas_configure_queue_sizes()
1689 instance->max_mpt_cmds = instance->max_fw_cmds; in megasas_configure_queue_sizes()
1691 instance->max_scsi_cmds = instance->max_fw_cmds - instance->max_mfi_cmds; in megasas_configure_queue_sizes()
1692 instance->cur_can_queue = instance->max_scsi_cmds; in megasas_configure_queue_sizes()
1693 instance->host->can_queue = instance->cur_can_queue; in megasas_configure_queue_sizes()
1698 instance->max_mpt_cmds; in megasas_configure_queue_sizes()
1703 * (instance->max_mpt_cmds + 1)); /* Extra 1 for SMID 0 */ in megasas_configure_queue_sizes()
1706 static int megasas_alloc_ioc_init_frame(struct megasas_instance *instance) in megasas_alloc_ioc_init_frame() argument
1711 fusion = instance->ctrl_context; in megasas_alloc_ioc_init_frame()
1716 dev_err(&instance->pdev->dev, "Failed from func: %s line: %d\n", in megasas_alloc_ioc_init_frame()
1721 cmd->frame = dma_alloc_coherent(&instance->pdev->dev, in megasas_alloc_ioc_init_frame()
1726 dev_err(&instance->pdev->dev, "Failed from func: %s line: %d\n", in megasas_alloc_ioc_init_frame()
1738 * @instance: Adapter soft state
1740 static inline void megasas_free_ioc_init_cmd(struct megasas_instance *instance) in megasas_free_ioc_init_cmd() argument
1744 fusion = instance->ctrl_context; in megasas_free_ioc_init_cmd()
1747 dma_free_coherent(&instance->pdev->dev, in megasas_free_ioc_init_cmd()
1757 * @instance: Adapter soft state
1762 megasas_init_adapter_fusion(struct megasas_instance *instance) in megasas_init_adapter_fusion() argument
1769 fusion = instance->ctrl_context; in megasas_init_adapter_fusion()
1771 megasas_fusion_update_can_queue(instance, PROBE_CONTEXT); in megasas_init_adapter_fusion()
1776 instance->max_mfi_cmds = in megasas_init_adapter_fusion()
1779 megasas_configure_queue_sizes(instance); in megasas_init_adapter_fusion()
1781 scratch_pad_1 = megasas_readl(instance, in megasas_init_adapter_fusion()
1782 &instance->reg_set->outbound_scratch_pad_1); in megasas_init_adapter_fusion()
1790 instance->max_chain_frame_sz = in megasas_init_adapter_fusion()
1794 instance->max_chain_frame_sz = in megasas_init_adapter_fusion()
1798 if (instance->max_chain_frame_sz < MEGASAS_CHAIN_FRAME_SZ_MIN) { in megasas_init_adapter_fusion()
1799 dev_warn(&instance->pdev->dev, "frame size %d invalid, fall back to legacy max frame size %d\n", in megasas_init_adapter_fusion()
1800 instance->max_chain_frame_sz, in megasas_init_adapter_fusion()
1802 instance->max_chain_frame_sz = MEGASAS_CHAIN_FRAME_SZ_MIN; in megasas_init_adapter_fusion()
1810 instance->max_chain_frame_sz in megasas_init_adapter_fusion()
1813 instance->max_num_sge = in megasas_init_adapter_fusion()
1825 count = instance->msix_vectors > 0 ? instance->msix_vectors : 1; in megasas_init_adapter_fusion()
1833 instance->max_scsi_cmds = instance->max_fw_cmds - in megasas_init_adapter_fusion()
1836 sema_init(&instance->ioctl_sem, MEGASAS_FUSION_IOCTL_CMDS); in megasas_init_adapter_fusion()
1838 if (megasas_alloc_ioc_init_frame(instance)) in megasas_init_adapter_fusion()
1845 if (megasas_alloc_cmds(instance)) in megasas_init_adapter_fusion()
1847 if (megasas_alloc_cmds_fusion(instance)) in megasas_init_adapter_fusion()
1850 if (megasas_ioc_init_fusion(instance)) { in megasas_init_adapter_fusion()
1851 status_reg = instance->instancet->read_fw_status_reg(instance); in megasas_init_adapter_fusion()
1856 (instance, true, 0) == FAILED) in megasas_init_adapter_fusion()
1859 if (megasas_ioc_init_fusion(instance)) in megasas_init_adapter_fusion()
1866 megasas_display_intel_branding(instance); in megasas_init_adapter_fusion()
1867 if (megasas_get_ctrl_info(instance)) { in megasas_init_adapter_fusion()
1868 dev_err(&instance->pdev->dev, in megasas_init_adapter_fusion()
1874 instance->flag_ieee = 1; in megasas_init_adapter_fusion()
1875 instance->r1_ldio_hint_default = MR_R1_LDIO_PIGGYBACK_DEFAULT; in megasas_init_adapter_fusion()
1876 instance->threshold_reply_count = instance->max_fw_cmds / 4; in megasas_init_adapter_fusion()
1879 if (megasas_allocate_raid_maps(instance)) in megasas_init_adapter_fusion()
1882 if (!megasas_get_map_info(instance)) in megasas_init_adapter_fusion()
1883 megasas_sync_map_info(instance); in megasas_init_adapter_fusion()
1888 megasas_free_cmds_fusion(instance); in megasas_init_adapter_fusion()
1890 megasas_free_cmds(instance); in megasas_init_adapter_fusion()
1892 megasas_free_ioc_init_cmd(instance); in megasas_init_adapter_fusion()
1904 struct megasas_instance *instance = in megasas_fault_detect_work() local
1910 fw_state = instance->instancet->read_fw_status_reg(instance) & in megasas_fault_detect_work()
1914 dma_state = instance->instancet->read_fw_status_reg(instance) & in megasas_fault_detect_work()
1917 if (instance->crash_dump_drv_support && in megasas_fault_detect_work()
1918 instance->crash_dump_app_support && dma_state) { in megasas_fault_detect_work()
1919 megasas_fusion_crash_dump(instance); in megasas_fault_detect_work()
1921 if (instance->unload == 0) { in megasas_fault_detect_work()
1922 status = megasas_reset_fusion(instance->host, 0); in megasas_fault_detect_work()
1924 dev_err(&instance->pdev->dev, in megasas_fault_detect_work()
1933 if (instance->fw_fault_work_q) in megasas_fault_detect_work()
1934 queue_delayed_work(instance->fw_fault_work_q, in megasas_fault_detect_work()
1935 &instance->fw_fault_work, in megasas_fault_detect_work()
1940 megasas_fusion_start_watchdog(struct megasas_instance *instance) in megasas_fusion_start_watchdog() argument
1943 if (instance->fw_fault_work_q) in megasas_fusion_start_watchdog()
1946 INIT_DELAYED_WORK(&instance->fw_fault_work, megasas_fault_detect_work); in megasas_fusion_start_watchdog()
1948 snprintf(instance->fault_handler_work_q_name, in megasas_fusion_start_watchdog()
1949 sizeof(instance->fault_handler_work_q_name), in megasas_fusion_start_watchdog()
1950 "poll_megasas%d_status", instance->host->host_no); in megasas_fusion_start_watchdog()
1952 instance->fw_fault_work_q = in megasas_fusion_start_watchdog()
1953 create_singlethread_workqueue(instance->fault_handler_work_q_name); in megasas_fusion_start_watchdog()
1954 if (!instance->fw_fault_work_q) { in megasas_fusion_start_watchdog()
1955 dev_err(&instance->pdev->dev, "Failed from %s %d\n", in megasas_fusion_start_watchdog()
1960 queue_delayed_work(instance->fw_fault_work_q, in megasas_fusion_start_watchdog()
1961 &instance->fw_fault_work, in megasas_fusion_start_watchdog()
1968 megasas_fusion_stop_watchdog(struct megasas_instance *instance) in megasas_fusion_stop_watchdog() argument
1972 if (instance->fw_fault_work_q) { in megasas_fusion_stop_watchdog()
1973 wq = instance->fw_fault_work_q; in megasas_fusion_stop_watchdog()
1974 instance->fw_fault_work_q = NULL; in megasas_fusion_stop_watchdog()
1975 if (!cancel_delayed_work_sync(&instance->fw_fault_work)) in megasas_fusion_stop_watchdog()
2055 * @instance: Adapter soft state
2063 megasas_is_prp_possible(struct megasas_instance *instance, in megasas_is_prp_possible() argument
2071 mr_nvme_pg_size = max_t(u32, instance->nvme_page_size, in megasas_is_prp_possible()
2101 * @instance: Adapter soft state
2111 megasas_make_prp_nvme(struct megasas_instance *instance, struct scsi_cmnd *scmd, in megasas_make_prp_nvme() argument
2125 u32 mr_nvme_pg_size = max_t(u32, instance->nvme_page_size, in megasas_make_prp_nvme()
2128 build_prp = megasas_is_prp_possible(instance, scmd, sge_count); in megasas_make_prp_nvme()
2148 memset(ptr_sgl, 0, instance->max_chain_frame_sz); in megasas_make_prp_nvme()
2226 * @instance: Adapter soft state
2234 megasas_make_sgl_fusion(struct megasas_instance *instance, in megasas_make_sgl_fusion() argument
2243 fusion = instance->ctrl_context; in megasas_make_sgl_fusion()
2245 if (instance->adapter_type >= INVADER_SERIES) { in megasas_make_sgl_fusion()
2255 if (instance->adapter_type >= INVADER_SERIES) in megasas_make_sgl_fusion()
2265 if (instance->adapter_type >= INVADER_SERIES) { in megasas_make_sgl_fusion()
2281 if (instance->adapter_type >= INVADER_SERIES) in megasas_make_sgl_fusion()
2292 memset(sgl_ptr, 0, instance->max_chain_frame_sz); in megasas_make_sgl_fusion()
2300 * @instance: Soft instance of controller
2311 int megasas_make_sgl(struct megasas_instance *instance, struct scsi_cmnd *scp, in megasas_make_sgl() argument
2320 if ((sge_count > instance->max_num_sge) || (sge_count <= 0)) in megasas_make_sgl()
2327 build_prp = megasas_make_prp_nvme(instance, scp, sgl_chain64, in megasas_make_sgl()
2331 megasas_make_sgl_fusion(instance, scp, sgl_chain64, in megasas_make_sgl()
2519 * @instance: Adapter soft state
2526 static void megasas_stream_detect(struct megasas_instance *instance, in megasas_stream_detect() argument
2530 struct fusion_context *fusion = instance->ctrl_context; in megasas_stream_detect()
2682 * @instance: Adapter soft state
2690 megasas_build_ldio_fusion(struct megasas_instance *instance, in megasas_build_ldio_fusion() argument
2711 fusion = instance->ctrl_context; in megasas_build_ldio_fusion()
2787 local_map_ptr = fusion->ld_drv_map[(instance->map_id & 1)]; in megasas_build_ldio_fusion()
2790 if (ld < instance->fw_supported_vd_count) in megasas_build_ldio_fusion()
2797 if (MR_BuildRaidContext(instance, &io_info, rctx, in megasas_build_ldio_fusion()
2802 megasas_get_msix_index(instance, scp, cmd, io_info.data_arms); in megasas_build_ldio_fusion()
2804 if (instance->adapter_type >= VENTURA_SERIES) { in megasas_build_ldio_fusion()
2816 if (atomic_inc_return(&instance->fw_outstanding) > in megasas_build_ldio_fusion()
2817 (instance->host->can_queue)) { in megasas_build_ldio_fusion()
2819 atomic_dec(&instance->fw_outstanding); in megasas_build_ldio_fusion()
2824 atomic_dec(&instance->fw_outstanding); in megasas_build_ldio_fusion()
2827 instance->r1_ldio_hint_default); in megasas_build_ldio_fusion()
2833 spin_lock_irqsave(&instance->stream_lock, in megasas_build_ldio_fusion()
2835 megasas_stream_detect(instance, cmd, &io_info); in megasas_build_ldio_fusion()
2836 spin_unlock_irqrestore(&instance->stream_lock, in megasas_build_ldio_fusion()
2862 if (instance->adapter_type == INVADER_SERIES) { in megasas_build_ldio_fusion()
2869 } else if (instance->adapter_type >= VENTURA_SERIES) { in megasas_build_ldio_fusion()
2880 get_updated_dev_handle(instance, in megasas_build_ldio_fusion()
2885 if (instance->adapter_type >= VENTURA_SERIES) in megasas_build_ldio_fusion()
2893 if (instance->adapter_type >= VENTURA_SERIES) in megasas_build_ldio_fusion()
2900 instance->dev_handle = !(instance->dev_handle); in megasas_build_ldio_fusion()
2902 local_map_ptr->raidMap.devHndlInfo[io_info.pd_after_lb].devHandle[instance->dev_handle]; in megasas_build_ldio_fusion()
2916 if (instance->adapter_type == INVADER_SERIES) { in megasas_build_ldio_fusion()
2927 } else if (instance->adapter_type >= VENTURA_SERIES) { in megasas_build_ldio_fusion()
2940 * @instance: Adapter soft state
2946 static void megasas_build_ld_nonrw_fusion(struct megasas_instance *instance, in megasas_build_ld_nonrw_fusion() argument
2953 struct fusion_context *fusion = instance->ctrl_context; in megasas_build_ld_nonrw_fusion()
2963 local_map_ptr = fusion->ld_drv_map[(instance->map_id & 1)]; in megasas_build_ld_nonrw_fusion()
2973 device_id < instance->fw_supported_vd_count)) { in megasas_build_ld_nonrw_fusion()
2976 if (ld >= instance->fw_supported_vd_count - 1) in megasas_build_ld_nonrw_fusion()
2999 if (instance->adapter_type < VENTURA_SERIES) in megasas_build_ld_nonrw_fusion()
3028 * @instance: Adapter soft state
3036 megasas_build_syspd_fusion(struct megasas_instance *instance, in megasas_build_syspd_fusion() argument
3049 struct fusion_context *fusion = instance->ctrl_context; in megasas_build_syspd_fusion()
3050 pd_sync = (void *)fusion->pd_seq_sync[(instance->pd_seq_map_id - 1) & 1]; in megasas_build_syspd_fusion()
3070 if (instance->support_seqnum_jbod_fp) { in megasas_build_syspd_fusion()
3071 if (instance->use_seqnum_jbod_fp && in megasas_build_syspd_fusion()
3072 instance->pd_list[pd_index].driveType == TYPE_DISK) { in megasas_build_syspd_fusion()
3075 if (instance->support_morethan256jbod) in megasas_build_syspd_fusion()
3086 if (instance->adapter_type >= VENTURA_SERIES) { in megasas_build_syspd_fusion()
3113 fusion->ld_drv_map[(instance->map_id & 1)]; in megasas_build_syspd_fusion()
3123 megasas_get_msix_index(instance, scmd, cmd, 1); in megasas_build_syspd_fusion()
3144 if (instance->adapter_type >= INVADER_SERIES) in megasas_build_syspd_fusion()
3156 * @instance: Adapter soft state
3164 megasas_build_io_fusion(struct megasas_instance *instance, in megasas_build_io_fusion() argument
3195 megasas_build_ldio_fusion(instance, scp, cmd); in megasas_build_io_fusion()
3198 megasas_build_ld_nonrw_fusion(instance, scp, cmd); in megasas_build_io_fusion()
3201 megasas_build_syspd_fusion(instance, scp, cmd, true); in megasas_build_io_fusion()
3204 if (instance->secure_jbod_support || in megasas_build_io_fusion()
3206 megasas_build_syspd_fusion(instance, scp, cmd, false); in megasas_build_io_fusion()
3208 megasas_build_syspd_fusion(instance, scp, cmd, true); in megasas_build_io_fusion()
3218 sge_count = megasas_make_sgl(instance, scp, cmd); in megasas_build_io_fusion()
3220 if (sge_count > instance->max_num_sge || (sge_count < 0)) { in megasas_build_io_fusion()
3221 dev_err(&instance->pdev->dev, in megasas_build_io_fusion()
3223 __func__, __LINE__, sge_count, instance->max_num_sge); in megasas_build_io_fusion()
3227 if (instance->adapter_type >= VENTURA_SERIES) { in megasas_build_io_fusion()
3261 megasas_get_request_descriptor(struct megasas_instance *instance, u16 index) in megasas_get_request_descriptor() argument
3266 fusion = instance->ctrl_context; in megasas_get_request_descriptor()
3277 static void megasas_prepare_secondRaid1_IO(struct megasas_instance *instance, in megasas_prepare_secondRaid1_IO() argument
3283 fusion = instance->ctrl_context; in megasas_prepare_secondRaid1_IO()
3294 req_desc2 = megasas_get_request_descriptor(instance, in megasas_prepare_secondRaid1_IO()
3318 * @instance: Adapter soft state
3322 megasas_build_and_issue_cmd_fusion(struct megasas_instance *instance, in megasas_build_and_issue_cmd_fusion() argument
3330 instance->ldio_threshold && in megasas_build_and_issue_cmd_fusion()
3331 (atomic_inc_return(&instance->ldio_outstanding) > in megasas_build_and_issue_cmd_fusion()
3332 instance->ldio_threshold)) { in megasas_build_and_issue_cmd_fusion()
3333 atomic_dec(&instance->ldio_outstanding); in megasas_build_and_issue_cmd_fusion()
3337 if (atomic_inc_return(&instance->fw_outstanding) > in megasas_build_and_issue_cmd_fusion()
3338 instance->host->can_queue) { in megasas_build_and_issue_cmd_fusion()
3339 atomic_dec(&instance->fw_outstanding); in megasas_build_and_issue_cmd_fusion()
3343 cmd = megasas_get_cmd_fusion(instance, scmd->request->tag); in megasas_build_and_issue_cmd_fusion()
3346 atomic_dec(&instance->fw_outstanding); in megasas_build_and_issue_cmd_fusion()
3352 req_desc = megasas_get_request_descriptor(instance, index-1); in megasas_build_and_issue_cmd_fusion()
3357 if (megasas_build_io_fusion(instance, scmd, cmd)) { in megasas_build_and_issue_cmd_fusion()
3358 megasas_return_cmd_fusion(instance, cmd); in megasas_build_and_issue_cmd_fusion()
3359 dev_err(&instance->pdev->dev, "Error building command\n"); in megasas_build_and_issue_cmd_fusion()
3361 atomic_dec(&instance->fw_outstanding); in megasas_build_and_issue_cmd_fusion()
3370 dev_err(&instance->pdev->dev, "The chain offset value is not " in megasas_build_and_issue_cmd_fusion()
3383 r1_cmd = megasas_get_cmd_fusion(instance, in megasas_build_and_issue_cmd_fusion()
3384 (scmd->request->tag + instance->max_fw_cmds)); in megasas_build_and_issue_cmd_fusion()
3385 megasas_prepare_secondRaid1_IO(instance, cmd, r1_cmd); in megasas_build_and_issue_cmd_fusion()
3393 megasas_fire_cmd_fusion(instance, req_desc); in megasas_build_and_issue_cmd_fusion()
3396 megasas_fire_cmd_fusion(instance, r1_cmd->request_desc); in megasas_build_and_issue_cmd_fusion()
3405 * @instance: Adapter soft state
3410 megasas_complete_r1_command(struct megasas_instance *instance, in megasas_complete_r1_command() argument
3422 fusion = instance->ctrl_context; in megasas_complete_r1_command()
3444 megasas_return_cmd_fusion(instance, r1_cmd); in megasas_complete_r1_command()
3447 if (instance->ldio_threshold && in megasas_complete_r1_command()
3449 atomic_dec(&instance->ldio_outstanding); in megasas_complete_r1_command()
3451 megasas_return_cmd_fusion(instance, cmd); in megasas_complete_r1_command()
3459 * @instance: Adapter soft state
3466 complete_cmd_fusion(struct megasas_instance *instance, u32 MSIxIndex, in complete_cmd_fusion() argument
3485 fusion = instance->ctrl_context; in complete_cmd_fusion()
3487 if (atomic_read(&instance->adprecovery) == MEGASAS_HW_CRITICAL_ERROR) in complete_cmd_fusion()
3525 dev_dbg(&instance->pdev->dev, "TM completion:" in complete_cmd_fusion()
3542 atomic_dec(&instance->fw_outstanding); in complete_cmd_fusion()
3547 if (instance->ldio_threshold && in complete_cmd_fusion()
3549 atomic_dec(&instance->ldio_outstanding); in complete_cmd_fusion()
3551 megasas_return_cmd_fusion(instance, cmd_fusion); in complete_cmd_fusion()
3555 megasas_complete_r1_command(instance, cmd_fusion); in complete_cmd_fusion()
3558 cmd_mfi = instance->cmd_list[cmd_fusion->sync_cmd_idx]; in complete_cmd_fusion()
3564 megasas_return_cmd(instance, cmd_mfi); in complete_cmd_fusion()
3566 megasas_complete_cmd(instance, cmd_mfi, DID_OK); in complete_cmd_fusion()
3600 if (threshold_reply_count >= instance->threshold_reply_count) { in complete_cmd_fusion()
3601 if (instance->msix_combined) in complete_cmd_fusion()
3604 instance->reply_post_host_index_addr[MSIxIndex/8]); in complete_cmd_fusion()
3608 instance->reply_post_host_index_addr[0]); in complete_cmd_fusion()
3623 if (instance->msix_combined) in complete_cmd_fusion()
3626 instance->reply_post_host_index_addr[MSIxIndex/8]); in complete_cmd_fusion()
3630 instance->reply_post_host_index_addr[0]); in complete_cmd_fusion()
3631 megasas_check_and_restore_queue_depth(instance); in complete_cmd_fusion()
3638 * @instance: Adapter soft state
3640 static void megasas_enable_irq_poll(struct megasas_instance *instance) in megasas_enable_irq_poll() argument
3645 count = instance->msix_vectors > 0 ? instance->msix_vectors : 1; in megasas_enable_irq_poll()
3648 irq_ctx = &instance->irq_context[i]; in megasas_enable_irq_poll()
3660 struct megasas_instance *instance = in megasas_sync_irqs() local
3664 count = instance->msix_vectors > 0 ? instance->msix_vectors : 1; in megasas_sync_irqs()
3667 synchronize_irq(pci_irq_vector(instance->pdev, i)); in megasas_sync_irqs()
3668 irq_ctx = &instance->irq_context[i]; in megasas_sync_irqs()
3673 complete_cmd_fusion(instance, irq_ctx->MSIxIndex, irq_ctx); in megasas_sync_irqs()
3689 struct megasas_instance *instance; in megasas_irqpoll() local
3693 instance = irq_ctx->instance; in megasas_irqpoll()
3700 num_entries = complete_cmd_fusion(instance, irq_ctx->MSIxIndex, irq_ctx); in megasas_irqpoll()
3705 complete_cmd_fusion(instance, irq_ctx->MSIxIndex, irq_ctx); in megasas_irqpoll()
3720 struct megasas_instance *instance = in megasas_complete_cmd_dpc_fusion() local
3725 count = instance->msix_vectors > 0 ? instance->msix_vectors : 1; in megasas_complete_cmd_dpc_fusion()
3728 if (atomic_read(&instance->adprecovery) == MEGASAS_HW_CRITICAL_ERROR) in megasas_complete_cmd_dpc_fusion()
3732 irq_ctx = &instance->irq_context[MSIxIndex]; in megasas_complete_cmd_dpc_fusion()
3733 complete_cmd_fusion(instance, MSIxIndex, irq_ctx); in megasas_complete_cmd_dpc_fusion()
3745 struct megasas_instance *instance = irq_context->instance; in megasas_isr_fusion() local
3748 if (instance->mask_interrupts) in megasas_isr_fusion()
3754 if (!instance->msix_vectors) { in megasas_isr_fusion()
3755 mfiStatus = instance->instancet->clear_intr(instance); in megasas_isr_fusion()
3761 if (test_bit(MEGASAS_FUSION_IN_RESET, &instance->reset_flags)) { in megasas_isr_fusion()
3762 instance->instancet->clear_intr(instance); in megasas_isr_fusion()
3766 return complete_cmd_fusion(instance, irq_context->MSIxIndex, irq_context) in megasas_isr_fusion()
3772 * @instance: Adapter soft state
3777 build_mpt_mfi_pass_thru(struct megasas_instance *instance, in build_mpt_mfi_pass_thru() argument
3786 fusion = instance->ctrl_context; in build_mpt_mfi_pass_thru()
3788 cmd = megasas_get_cmd_fusion(instance, in build_mpt_mfi_pass_thru()
3789 instance->max_scsi_cmds + mfi_cmd->index); in build_mpt_mfi_pass_thru()
3805 if (instance->adapter_type >= INVADER_SERIES) { in build_mpt_mfi_pass_thru()
3825 mpi25_ieee_chain->Length = cpu_to_le32(instance->mfi_frame_size); in build_mpt_mfi_pass_thru()
3830 * @instance: Adapter soft state
3835 build_mpt_cmd(struct megasas_instance *instance, struct megasas_cmd *cmd) in build_mpt_cmd() argument
3840 build_mpt_mfi_pass_thru(instance, cmd); in build_mpt_cmd()
3843 req_desc = megasas_get_request_descriptor(instance, index - 1); in build_mpt_cmd()
3856 * @instance: Adapter soft state
3861 megasas_issue_dcmd_fusion(struct megasas_instance *instance, in megasas_issue_dcmd_fusion() argument
3866 req_desc = build_mpt_cmd(instance, cmd); in megasas_issue_dcmd_fusion()
3868 megasas_fire_cmd_fusion(instance, req_desc); in megasas_issue_dcmd_fusion()
3874 * @instance: Adapter soft state
3877 megasas_release_fusion(struct megasas_instance *instance) in megasas_release_fusion() argument
3879 megasas_free_ioc_init_cmd(instance); in megasas_release_fusion()
3880 megasas_free_cmds(instance); in megasas_release_fusion()
3881 megasas_free_cmds_fusion(instance); in megasas_release_fusion()
3883 iounmap(instance->reg_set); in megasas_release_fusion()
3885 pci_release_selected_regions(instance->pdev, 1<<instance->bar); in megasas_release_fusion()
3890 * @instance: Adapter soft state
3893 megasas_read_fw_status_reg_fusion(struct megasas_instance *instance) in megasas_read_fw_status_reg_fusion() argument
3895 return megasas_readl(instance, &instance->reg_set->outbound_scratch_pad_0); in megasas_read_fw_status_reg_fusion()
3900 * @instance: Controller's soft instance
3904 megasas_alloc_host_crash_buffer(struct megasas_instance *instance) in megasas_alloc_host_crash_buffer() argument
3909 instance->crash_buf[i] = vzalloc(CRASH_DMA_BUF_SIZE); in megasas_alloc_host_crash_buffer()
3910 if (!instance->crash_buf[i]) { in megasas_alloc_host_crash_buffer()
3911 dev_info(&instance->pdev->dev, "Firmware crash dump " in megasas_alloc_host_crash_buffer()
3916 instance->drv_buf_alloc = i; in megasas_alloc_host_crash_buffer()
3921 * @instance: Controller's soft instance
3924 megasas_free_host_crash_buffer(struct megasas_instance *instance) in megasas_free_host_crash_buffer() argument
3927 for (i = 0; i < instance->drv_buf_alloc; i++) { in megasas_free_host_crash_buffer()
3928 if (instance->crash_buf[i]) in megasas_free_host_crash_buffer()
3929 vfree(instance->crash_buf[i]); in megasas_free_host_crash_buffer()
3931 instance->drv_buf_index = 0; in megasas_free_host_crash_buffer()
3932 instance->drv_buf_alloc = 0; in megasas_free_host_crash_buffer()
3933 instance->fw_crash_state = UNAVAILABLE; in megasas_free_host_crash_buffer()
3934 instance->fw_crash_buffer_size = 0; in megasas_free_host_crash_buffer()
3939 * @instance: Controller's soft instance
3943 megasas_adp_reset_fusion(struct megasas_instance *instance, in megasas_adp_reset_fusion() argument
3949 writel(MPI2_WRSEQ_FLUSH_KEY_VALUE, &instance->reg_set->fusion_seq_offset); in megasas_adp_reset_fusion()
3950 writel(MPI2_WRSEQ_1ST_KEY_VALUE, &instance->reg_set->fusion_seq_offset); in megasas_adp_reset_fusion()
3951 writel(MPI2_WRSEQ_2ND_KEY_VALUE, &instance->reg_set->fusion_seq_offset); in megasas_adp_reset_fusion()
3952 writel(MPI2_WRSEQ_3RD_KEY_VALUE, &instance->reg_set->fusion_seq_offset); in megasas_adp_reset_fusion()
3953 writel(MPI2_WRSEQ_4TH_KEY_VALUE, &instance->reg_set->fusion_seq_offset); in megasas_adp_reset_fusion()
3954 writel(MPI2_WRSEQ_5TH_KEY_VALUE, &instance->reg_set->fusion_seq_offset); in megasas_adp_reset_fusion()
3955 writel(MPI2_WRSEQ_6TH_KEY_VALUE, &instance->reg_set->fusion_seq_offset); in megasas_adp_reset_fusion()
3958 host_diag = megasas_readl(instance, &instance->reg_set->fusion_host_diag); in megasas_adp_reset_fusion()
3962 host_diag = megasas_readl(instance, in megasas_adp_reset_fusion()
3963 &instance->reg_set->fusion_host_diag); in megasas_adp_reset_fusion()
3965 dev_warn(&instance->pdev->dev, in megasas_adp_reset_fusion()
3976 &instance->reg_set->fusion_host_diag); in megasas_adp_reset_fusion()
3980 host_diag = megasas_readl(instance, &instance->reg_set->fusion_host_diag); in megasas_adp_reset_fusion()
3984 host_diag = megasas_readl(instance, in megasas_adp_reset_fusion()
3985 &instance->reg_set->fusion_host_diag); in megasas_adp_reset_fusion()
3987 dev_warn(&instance->pdev->dev, in megasas_adp_reset_fusion()
3996 abs_state = instance->instancet->read_fw_status_reg(instance) in megasas_adp_reset_fusion()
4002 abs_state = instance->instancet-> in megasas_adp_reset_fusion()
4003 read_fw_status_reg(instance) & MFI_STATE_MASK; in megasas_adp_reset_fusion()
4006 dev_warn(&instance->pdev->dev, in megasas_adp_reset_fusion()
4017 * @instance: Controller's soft instance
4021 megasas_check_reset_fusion(struct megasas_instance *instance, in megasas_check_reset_fusion() argument
4029 * @instance: Soft instance of adapter
4031 static inline void megasas_trigger_snap_dump(struct megasas_instance *instance) in megasas_trigger_snap_dump() argument
4036 if (!instance->disableOnlineCtrlReset) { in megasas_trigger_snap_dump()
4037 dev_info(&instance->pdev->dev, "Trigger snap dump\n"); in megasas_trigger_snap_dump()
4039 &instance->reg_set->doorbell); in megasas_trigger_snap_dump()
4040 readl(&instance->reg_set->doorbell); in megasas_trigger_snap_dump()
4043 for (j = 0; j < instance->snapdump_wait_time; j++) { in megasas_trigger_snap_dump()
4044 abs_state = instance->instancet->read_fw_status_reg(instance); in megasas_trigger_snap_dump()
4047 dev_printk(KERN_ERR, &instance->pdev->dev, in megasas_trigger_snap_dump()
4059 megasas_wait_for_outstanding_fusion(struct megasas_instance *instance, in megasas_wait_for_outstanding_fusion() argument
4068 (resetwaittime - instance->snapdump_wait_time)); in megasas_wait_for_outstanding_fusion()
4071 dev_info(&instance->pdev->dev, in megasas_wait_for_outstanding_fusion()
4073 megasas_complete_cmd_dpc_fusion((unsigned long)instance); in megasas_wait_for_outstanding_fusion()
4074 if (instance->snapdump_wait_time) in megasas_wait_for_outstanding_fusion()
4075 megasas_trigger_snap_dump(instance); in megasas_wait_for_outstanding_fusion()
4082 abs_state = instance->instancet->read_fw_status_reg(instance); in megasas_wait_for_outstanding_fusion()
4085 dev_printk(KERN_ERR, &instance->pdev->dev, in megasas_wait_for_outstanding_fusion()
4089 megasas_complete_cmd_dpc_fusion((unsigned long)instance); in megasas_wait_for_outstanding_fusion()
4090 if (instance->requestorId && reason) { in megasas_wait_for_outstanding_fusion()
4091 dev_warn(&instance->pdev->dev, "SR-IOV Found FW in FAULT" in megasas_wait_for_outstanding_fusion()
4094 instance->host->host_no); in megasas_wait_for_outstanding_fusion()
4104 if (instance->requestorId && !reason) { in megasas_wait_for_outstanding_fusion()
4110 if (instance->requestorId && (reason == SCSIIO_TIMEOUT_OCR)) { in megasas_wait_for_outstanding_fusion()
4111 if (instance->hb_host_mem->HB.fwCounter != in megasas_wait_for_outstanding_fusion()
4112 instance->hb_host_mem->HB.driverCounter) { in megasas_wait_for_outstanding_fusion()
4113 instance->hb_host_mem->HB.driverCounter = in megasas_wait_for_outstanding_fusion()
4114 instance->hb_host_mem->HB.fwCounter; in megasas_wait_for_outstanding_fusion()
4120 dev_warn(&instance->pdev->dev, "SR-IOV:" in megasas_wait_for_outstanding_fusion()
4125 instance->host->host_no); in megasas_wait_for_outstanding_fusion()
4133 megasas_complete_cmd_dpc_fusion((unsigned long)instance); in megasas_wait_for_outstanding_fusion()
4134 outstanding = atomic_read(&instance->fw_outstanding); in megasas_wait_for_outstanding_fusion()
4139 dev_notice(&instance->pdev->dev, "[%2d]waiting for %d " in megasas_wait_for_outstanding_fusion()
4141 outstanding, instance->host->host_no); in megasas_wait_for_outstanding_fusion()
4146 if (instance->snapdump_wait_time) { in megasas_wait_for_outstanding_fusion()
4147 megasas_trigger_snap_dump(instance); in megasas_wait_for_outstanding_fusion()
4152 if (atomic_read(&instance->fw_outstanding)) { in megasas_wait_for_outstanding_fusion()
4153 dev_err(&instance->pdev->dev, "pending commands remain after waiting, " in megasas_wait_for_outstanding_fusion()
4155 instance->host->host_no); in megasas_wait_for_outstanding_fusion()
4164 void megasas_reset_reply_desc(struct megasas_instance *instance) in megasas_reset_reply_desc() argument
4170 fusion = instance->ctrl_context; in megasas_reset_reply_desc()
4171 count = instance->msix_vectors > 0 ? instance->msix_vectors : 1; in megasas_reset_reply_desc()
4182 * @instance: Controller's soft instance
4184 static void megasas_refire_mgmt_cmd(struct megasas_instance *instance, in megasas_refire_mgmt_cmd() argument
4198 fusion = instance->ctrl_context; in megasas_refire_mgmt_cmd()
4203 for (j = instance->max_scsi_cmds ; j < instance->max_fw_cmds; j++) { in megasas_refire_mgmt_cmd()
4205 cmd_mfi = instance->cmd_list[cmd_fusion->sync_cmd_idx]; in megasas_refire_mgmt_cmd()
4212 req_desc = megasas_get_request_descriptor(instance, smid - 1); in megasas_refire_mgmt_cmd()
4233 if (!instance->support_nvme_passthru) { in megasas_refire_mgmt_cmd()
4240 if (!instance->support_pci_lane_margining) { in megasas_refire_mgmt_cmd()
4252 dev_err(&instance->pdev->dev, in megasas_refire_mgmt_cmd()
4267 megasas_fire_cmd_fusion(instance, req_desc); in megasas_refire_mgmt_cmd()
4270 megasas_return_cmd(instance, cmd_mfi); in megasas_refire_mgmt_cmd()
4273 megasas_complete_cmd(instance, cmd_mfi, DID_OK); in megasas_refire_mgmt_cmd()
4282 * @instance: Controller's soft instance
4285 megasas_return_polled_cmds(struct megasas_instance *instance) in megasas_return_polled_cmds() argument
4292 fusion = instance->ctrl_context; in megasas_return_polled_cmds()
4294 for (i = instance->max_scsi_cmds; i < instance->max_fw_cmds; i++) { in megasas_return_polled_cmds()
4296 cmd_mfi = instance->cmd_list[cmd_fusion->sync_cmd_idx]; in megasas_return_polled_cmds()
4300 dev_info(&instance->pdev->dev, in megasas_return_polled_cmds()
4305 megasas_return_cmd(instance, cmd_mfi); in megasas_return_polled_cmds()
4312 * @instance: per adapter struct
4319 static int megasas_track_scsiio(struct megasas_instance *instance, in megasas_track_scsiio() argument
4325 fusion = instance->ctrl_context; in megasas_track_scsiio()
4327 for (i = 0 ; i < instance->max_scsi_cmds; i++) { in megasas_track_scsiio()
4332 dev_info(&instance->pdev->dev, in megasas_track_scsiio()
4347 * @instance: Controller's soft instance
4353 megasas_tm_response_code(struct megasas_instance *instance, in megasas_tm_response_code() argument
4387 dev_dbg(&instance->pdev->dev, "response_code(%01x): %s\n", in megasas_tm_response_code()
4389 dev_dbg(&instance->pdev->dev, in megasas_tm_response_code()
4399 * @instance: per adapter struct
4414 megasas_issue_tm(struct megasas_instance *instance, u16 device_handle, in megasas_issue_tm() argument
4430 fusion = instance->ctrl_context; in megasas_issue_tm()
4432 cmd_mfi = megasas_get_cmd(instance); in megasas_issue_tm()
4435 dev_err(&instance->pdev->dev, "Failed from %s %d\n", in megasas_issue_tm()
4440 cmd_fusion = megasas_get_cmd_fusion(instance, in megasas_issue_tm()
4441 instance->max_scsi_cmds + cmd_mfi->index); in megasas_issue_tm()
4446 req_desc = megasas_get_request_descriptor(instance, in megasas_issue_tm()
4477 megasas_fire_cmd_fusion(instance, req_desc); in megasas_issue_tm()
4491 dev_err(&instance->pdev->dev, in megasas_issue_tm()
4493 mutex_unlock(&instance->reset_mutex); in megasas_issue_tm()
4494 rc = megasas_reset_fusion(instance->host, MFI_IO_TIMEOUT_OCR); in megasas_issue_tm()
4495 mutex_lock(&instance->reset_mutex); in megasas_issue_tm()
4500 megasas_tm_response_code(instance, mpi_reply); in megasas_issue_tm()
4502 megasas_return_cmd(instance, cmd_mfi); in megasas_issue_tm()
4511 instance->instancet->disable_intr(instance); in megasas_issue_tm()
4512 megasas_sync_irqs((unsigned long)instance); in megasas_issue_tm()
4513 instance->instancet->enable_intr(instance); in megasas_issue_tm()
4514 megasas_enable_irq_poll(instance); in megasas_issue_tm()
4524 instance->instancet->disable_intr(instance); in megasas_issue_tm()
4525 megasas_sync_irqs((unsigned long)instance); in megasas_issue_tm()
4526 rc = megasas_track_scsiio(instance, id, channel); in megasas_issue_tm()
4527 instance->instancet->enable_intr(instance); in megasas_issue_tm()
4528 megasas_enable_irq_poll(instance); in megasas_issue_tm()
4545 * @instance: per adapter struct
4552 struct megasas_instance *instance; in megasas_fusion_smid_lookup() local
4556 instance = (struct megasas_instance *)scmd->device->host->hostdata; in megasas_fusion_smid_lookup()
4558 fusion = instance->ctrl_context; in megasas_fusion_smid_lookup()
4560 for (i = 0; i < instance->max_scsi_cmds; i++) { in megasas_fusion_smid_lookup()
4583 struct megasas_instance *instance; in megasas_get_tm_devhandle() local
4588 instance = (struct megasas_instance *)sdev->host->hostdata; in megasas_get_tm_devhandle()
4589 fusion = instance->ctrl_context; in megasas_get_tm_devhandle()
4592 if (instance->use_seqnum_jbod_fp) { in megasas_get_tm_devhandle()
4596 [(instance->pd_seq_map_id - 1) & 1]; in megasas_get_tm_devhandle()
4619 struct megasas_instance *instance; in megasas_task_abort_fusion() local
4625 instance = (struct megasas_instance *)scmd->device->host->hostdata; in megasas_task_abort_fusion()
4627 if (atomic_read(&instance->adprecovery) != MEGASAS_HBA_OPERATIONAL) { in megasas_task_abort_fusion()
4628 dev_err(&instance->pdev->dev, "Controller is not OPERATIONAL," in megasas_task_abort_fusion()
4629 "SCSI host:%d\n", instance->host->host_no); in megasas_task_abort_fusion()
4647 mutex_lock(&instance->reset_mutex); in megasas_task_abort_fusion()
4655 mutex_unlock(&instance->reset_mutex); in megasas_task_abort_fusion()
4665 mutex_unlock(&instance->reset_mutex); in megasas_task_abort_fusion()
4673 ret = megasas_issue_tm(instance, devhandle, in megasas_task_abort_fusion()
4679 mutex_unlock(&instance->reset_mutex); in megasas_task_abort_fusion()
4700 struct megasas_instance *instance; in megasas_reset_target_fusion() local
4706 instance = (struct megasas_instance *)scmd->device->host->hostdata; in megasas_reset_target_fusion()
4708 if (atomic_read(&instance->adprecovery) != MEGASAS_HBA_OPERATIONAL) { in megasas_reset_target_fusion()
4709 dev_err(&instance->pdev->dev, "Controller is not OPERATIONAL," in megasas_reset_target_fusion()
4710 "SCSI host:%d\n", instance->host->host_no); in megasas_reset_target_fusion()
4728 mutex_lock(&instance->reset_mutex); in megasas_reset_target_fusion()
4735 mutex_unlock(&instance->reset_mutex); in megasas_reset_target_fusion()
4743 ret = megasas_issue_tm(instance, devhandle, in megasas_reset_target_fusion()
4748 mutex_unlock(&instance->reset_mutex); in megasas_reset_target_fusion()
4756 /*SRIOV get other instance in cluster if any*/
4758 megasas_instance *megasas_get_peer_instance(struct megasas_instance *instance) in megasas_get_peer_instance() argument
4763 if (megasas_mgmt_info.instance[i] && in megasas_get_peer_instance()
4764 (megasas_mgmt_info.instance[i] != instance) && in megasas_get_peer_instance()
4765 megasas_mgmt_info.instance[i]->requestorId && in megasas_get_peer_instance()
4766 megasas_mgmt_info.instance[i]->peerIsPresent && in megasas_get_peer_instance()
4767 (memcmp((megasas_mgmt_info.instance[i]->clusterId), in megasas_get_peer_instance()
4768 instance->clusterId, MEGASAS_CLUSTER_ID_SIZE) == 0)) in megasas_get_peer_instance()
4769 return megasas_mgmt_info.instance[i]; in megasas_get_peer_instance()
4775 int megasas_check_mpio_paths(struct megasas_instance *instance, in megasas_check_mpio_paths() argument
4781 if (instance->peerIsPresent) { in megasas_check_mpio_paths()
4782 peer_instance = megasas_get_peer_instance(instance); in megasas_check_mpio_paths()
4795 struct megasas_instance *instance; in megasas_reset_fusion() local
4807 instance = (struct megasas_instance *)shost->hostdata; in megasas_reset_fusion()
4808 fusion = instance->ctrl_context; in megasas_reset_fusion()
4810 mutex_lock(&instance->reset_mutex); in megasas_reset_fusion()
4812 if (atomic_read(&instance->adprecovery) == MEGASAS_HW_CRITICAL_ERROR) { in megasas_reset_fusion()
4813 dev_warn(&instance->pdev->dev, "Hardware critical error, " in megasas_reset_fusion()
4815 instance->host->host_no); in megasas_reset_fusion()
4816 mutex_unlock(&instance->reset_mutex); in megasas_reset_fusion()
4819 status_reg = instance->instancet->read_fw_status_reg(instance); in megasas_reset_fusion()
4823 if (abs_state != MFI_STATE_FAULT && instance->crash_dump_buf && in megasas_reset_fusion()
4824 instance->crash_dump_app_support && reason) { in megasas_reset_fusion()
4825 dev_info(&instance->pdev->dev, "IO/DCMD timeout is detected, " in megasas_reset_fusion()
4827 atomic_set(&instance->adprecovery, MEGASAS_ADPRESET_SM_INFAULT); in megasas_reset_fusion()
4828 status_reg = megasas_readl(instance, &instance->reg_set->doorbell); in megasas_reset_fusion()
4830 &instance->reg_set->doorbell); in megasas_reset_fusion()
4831 readl(&instance->reg_set->doorbell); in megasas_reset_fusion()
4832 mutex_unlock(&instance->reset_mutex); in megasas_reset_fusion()
4836 dev_dbg(&instance->pdev->dev, "waiting for [%d] " in megasas_reset_fusion()
4839 } while ((atomic_read(&instance->adprecovery) != MEGASAS_HBA_OPERATIONAL) && in megasas_reset_fusion()
4842 if (atomic_read(&instance->adprecovery) == MEGASAS_HBA_OPERATIONAL) { in megasas_reset_fusion()
4843 dev_info(&instance->pdev->dev, "OCR done for IO " in megasas_reset_fusion()
4847 dev_info(&instance->pdev->dev, "Controller is not " in megasas_reset_fusion()
4856 if (instance->requestorId && !instance->skip_heartbeat_timer_del) in megasas_reset_fusion()
4857 del_timer_sync(&instance->sriov_heartbeat_timer); in megasas_reset_fusion()
4858 set_bit(MEGASAS_FUSION_IN_RESET, &instance->reset_flags); in megasas_reset_fusion()
4859 set_bit(MEGASAS_FUSION_OCR_NOT_POSSIBLE, &instance->reset_flags); in megasas_reset_fusion()
4860 atomic_set(&instance->adprecovery, MEGASAS_ADPRESET_SM_POLLING); in megasas_reset_fusion()
4861 instance->instancet->disable_intr(instance); in megasas_reset_fusion()
4862 megasas_sync_irqs((unsigned long)instance); in megasas_reset_fusion()
4865 if (megasas_wait_for_outstanding_fusion(instance, reason, in megasas_reset_fusion()
4867 atomic_set(&instance->adprecovery, MEGASAS_ADPRESET_SM_INFAULT); in megasas_reset_fusion()
4868 dev_warn(&instance->pdev->dev, "resetting fusion " in megasas_reset_fusion()
4869 "adapter scsi%d.\n", instance->host->host_no); in megasas_reset_fusion()
4874 dev_info(&instance->pdev->dev, "\nPending SCSI commands:\n"); in megasas_reset_fusion()
4877 for (i = 0 ; i < instance->max_scsi_cmds; i++) { in megasas_reset_fusion()
4880 if (instance->adapter_type >= VENTURA_SERIES) { in megasas_reset_fusion()
4881 r1_cmd = fusion->cmd_list[i + instance->max_fw_cmds]; in megasas_reset_fusion()
4882 megasas_return_cmd_fusion(instance, r1_cmd); in megasas_reset_fusion()
4898 megasas_check_mpio_paths(instance, in megasas_reset_fusion()
4900 if (instance->ldio_threshold && in megasas_reset_fusion()
4902 atomic_dec(&instance->ldio_outstanding); in megasas_reset_fusion()
4903 megasas_return_cmd_fusion(instance, cmd_fusion); in megasas_reset_fusion()
4909 dev_info(&instance->pdev->dev, "Outstanding fastpath IOs: %d\n", in megasas_reset_fusion()
4912 atomic_set(&instance->fw_outstanding, 0); in megasas_reset_fusion()
4914 status_reg = instance->instancet->read_fw_status_reg(instance); in megasas_reset_fusion()
4917 if (instance->disableOnlineCtrlReset || in megasas_reset_fusion()
4920 dev_warn(&instance->pdev->dev, "Reset not supported" in megasas_reset_fusion()
4922 instance->host->host_no); in megasas_reset_fusion()
4927 if (instance->requestorId && !reason) { in megasas_reset_fusion()
4939 if (megasas_adp_reset_wait_for_ready(instance, in megasas_reset_fusion()
4944 if (megasas_transition_to_ready(instance, 1)) { in megasas_reset_fusion()
4945 dev_warn(&instance->pdev->dev, in megasas_reset_fusion()
4947 "scsi%d.\n", instance->host->host_no); in megasas_reset_fusion()
4950 megasas_reset_reply_desc(instance); in megasas_reset_fusion()
4951 megasas_fusion_update_can_queue(instance, OCR_CONTEXT); in megasas_reset_fusion()
4953 if (megasas_ioc_init_fusion(instance)) { in megasas_reset_fusion()
4957 if (megasas_get_ctrl_info(instance)) { in megasas_reset_fusion()
4958 dev_info(&instance->pdev->dev, in megasas_reset_fusion()
4964 megasas_refire_mgmt_cmd(instance, in megasas_reset_fusion()
4974 if (!megasas_get_map_info(instance)) { in megasas_reset_fusion()
4975 megasas_sync_map_info(instance); in megasas_reset_fusion()
4981 megasas_return_polled_cmds(instance); in megasas_reset_fusion()
4985 megasas_setup_jbod_map(instance); in megasas_reset_fusion()
4988 if (instance->adapter_type >= VENTURA_SERIES) { in megasas_reset_fusion()
4998 &instance->reset_flags); in megasas_reset_fusion()
4999 instance->instancet->enable_intr(instance); in megasas_reset_fusion()
5000 megasas_enable_irq_poll(instance); in megasas_reset_fusion()
5002 if ((instance->tgt_prop) && in megasas_reset_fusion()
5003 (instance->nvme_page_size)) in megasas_reset_fusion()
5004 ret_target_prop = megasas_get_target_prop(instance, sdev); in megasas_reset_fusion()
5010 status_reg = instance->instancet->read_fw_status_reg in megasas_reset_fusion()
5011 (instance); in megasas_reset_fusion()
5014 dev_info(&instance->pdev->dev, in megasas_reset_fusion()
5016 abs_state, instance->host->host_no); in megasas_reset_fusion()
5019 atomic_set(&instance->adprecovery, MEGASAS_HBA_OPERATIONAL); in megasas_reset_fusion()
5021 dev_info(&instance->pdev->dev, in megasas_reset_fusion()
5023 instance->host->host_no); in megasas_reset_fusion()
5026 if (instance->requestorId) { in megasas_reset_fusion()
5027 if (!megasas_sriov_start_heartbeat(instance, 0)) in megasas_reset_fusion()
5028 megasas_start_timer(instance); in megasas_reset_fusion()
5030 instance->skip_heartbeat_timer_del = 1; in megasas_reset_fusion()
5033 if (instance->crash_dump_drv_support && in megasas_reset_fusion()
5034 instance->crash_dump_app_support) in megasas_reset_fusion()
5035 megasas_set_crash_dump_params(instance, in megasas_reset_fusion()
5038 megasas_set_crash_dump_params(instance, in megasas_reset_fusion()
5041 if (instance->snapdump_wait_time) { in megasas_reset_fusion()
5042 megasas_get_snapdump_properties(instance); in megasas_reset_fusion()
5043 dev_info(&instance->pdev->dev, in megasas_reset_fusion()
5045 instance->snapdump_wait_time); in megasas_reset_fusion()
5051 dev_warn(&instance->pdev->dev, in megasas_reset_fusion()
5053 instance->host->host_no); in megasas_reset_fusion()
5058 dev_warn(&instance->pdev->dev, "Reset failed, killing " in megasas_reset_fusion()
5059 "adapter scsi%d.\n", instance->host->host_no); in megasas_reset_fusion()
5063 if (instance->requestorId) { in megasas_reset_fusion()
5064 megasas_start_timer(instance); in megasas_reset_fusion()
5066 clear_bit(MEGASAS_FUSION_IN_RESET, &instance->reset_flags); in megasas_reset_fusion()
5067 instance->instancet->enable_intr(instance); in megasas_reset_fusion()
5068 megasas_enable_irq_poll(instance); in megasas_reset_fusion()
5069 atomic_set(&instance->adprecovery, MEGASAS_HBA_OPERATIONAL); in megasas_reset_fusion()
5073 megaraid_sas_kill_hba(instance); in megasas_reset_fusion()
5074 megasas_enable_irq_poll(instance); in megasas_reset_fusion()
5075 instance->skip_heartbeat_timer_del = 1; in megasas_reset_fusion()
5078 clear_bit(MEGASAS_FUSION_OCR_NOT_POSSIBLE, &instance->reset_flags); in megasas_reset_fusion()
5079 mutex_unlock(&instance->reset_mutex); in megasas_reset_fusion()
5084 static void megasas_fusion_crash_dump(struct megasas_instance *instance) in megasas_fusion_crash_dump() argument
5091 status_reg = instance->instancet->read_fw_status_reg(instance); in megasas_fusion_crash_dump()
5097 if (instance->drv_buf_index == 0) { in megasas_fusion_crash_dump()
5101 if (instance->drv_buf_alloc) { in megasas_fusion_crash_dump()
5102 dev_info(&instance->pdev->dev, "earlier crash dump is " in megasas_fusion_crash_dump()
5107 &instance->reg_set->outbound_scratch_pad_0); in megasas_fusion_crash_dump()
5108 readl(&instance->reg_set->outbound_scratch_pad_0); in megasas_fusion_crash_dump()
5111 megasas_alloc_host_crash_buffer(instance); in megasas_fusion_crash_dump()
5112 dev_info(&instance->pdev->dev, "Number of host crash buffers " in megasas_fusion_crash_dump()
5113 "allocated: %d\n", instance->drv_buf_alloc); in megasas_fusion_crash_dump()
5126 status_reg = instance->instancet->read_fw_status_reg( in megasas_fusion_crash_dump()
5127 instance); in megasas_fusion_crash_dump()
5132 if (instance->drv_buf_index >= instance->drv_buf_alloc) { in megasas_fusion_crash_dump()
5133 dev_info(&instance->pdev->dev, in megasas_fusion_crash_dump()
5135 instance->drv_buf_alloc); in megasas_fusion_crash_dump()
5140 memcpy(instance->crash_buf[instance->drv_buf_index], in megasas_fusion_crash_dump()
5141 instance->crash_dump_buf, CRASH_DMA_BUF_SIZE); in megasas_fusion_crash_dump()
5142 instance->drv_buf_index++; in megasas_fusion_crash_dump()
5146 writel(status_reg, &instance->reg_set->outbound_scratch_pad_0); in megasas_fusion_crash_dump()
5147 readl(&instance->reg_set->outbound_scratch_pad_0); in megasas_fusion_crash_dump()
5150 status_reg = instance->instancet->read_fw_status_reg(instance); in megasas_fusion_crash_dump()
5154 dev_info(&instance->pdev->dev, "Crash Dump is available,number " in megasas_fusion_crash_dump()
5155 "of copied buffers: %d\n", instance->drv_buf_index); in megasas_fusion_crash_dump()
5156 instance->fw_crash_buffer_size = instance->drv_buf_index; in megasas_fusion_crash_dump()
5157 instance->fw_crash_state = AVAILABLE; in megasas_fusion_crash_dump()
5158 instance->drv_buf_index = 0; in megasas_fusion_crash_dump()
5159 writel(status_reg, &instance->reg_set->outbound_scratch_pad_0); in megasas_fusion_crash_dump()
5160 readl(&instance->reg_set->outbound_scratch_pad_0); in megasas_fusion_crash_dump()
5162 megasas_reset_fusion(instance->host, 0); in megasas_fusion_crash_dump()
5170 struct megasas_instance *instance = in megasas_fusion_ocr_wq() local
5173 megasas_reset_fusion(instance->host, 0); in megasas_fusion_ocr_wq()
5178 megasas_alloc_fusion_context(struct megasas_instance *instance) in megasas_alloc_fusion_context() argument
5182 instance->ctrl_context = kzalloc(sizeof(struct fusion_context), in megasas_alloc_fusion_context()
5184 if (!instance->ctrl_context) { in megasas_alloc_fusion_context()
5185 dev_err(&instance->pdev->dev, "Failed from %s %d\n", in megasas_alloc_fusion_context()
5190 fusion = instance->ctrl_context; in megasas_alloc_fusion_context()
5202 dev_err(&instance->pdev->dev, "Failed from %s %d\n", in megasas_alloc_fusion_context()
5218 dev_err(&instance->pdev->dev, "Failed to allocate load_balance_info, " in megasas_alloc_fusion_context()
5226 megasas_free_fusion_context(struct megasas_instance *instance) in megasas_free_fusion_context() argument
5228 struct fusion_context *fusion = instance->ctrl_context; in megasas_free_fusion_context()