Lines Matching refs: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);
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()
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()
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()
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()
224 megasas_sdev_busy_inc(struct megasas_instance *instance, in megasas_sdev_busy_inc() argument
227 if (instance->perf_mode == MR_BALANCED_PERF_MODE) { in megasas_sdev_busy_inc()
235 megasas_sdev_busy_dec(struct megasas_instance *instance, in megasas_sdev_busy_dec() argument
238 if (instance->perf_mode == MR_BALANCED_PERF_MODE) { in megasas_sdev_busy_dec()
246 megasas_sdev_busy_read(struct megasas_instance *instance, in megasas_sdev_busy_read() argument
249 if (instance->perf_mode == MR_BALANCED_PERF_MODE) { in megasas_sdev_busy_read()
265 *instance, u32 blk_tag) in megasas_get_cmd_fusion()
269 fusion = instance->ctrl_context; in megasas_get_cmd_fusion()
278 inline void megasas_return_cmd_fusion(struct megasas_instance *instance, in megasas_return_cmd_fusion() argument
293 megasas_write_64bit_req_desc(struct megasas_instance *instance, in megasas_write_64bit_req_desc() argument
299 writeq(req_data, &instance->reg_set->inbound_low_queue_port); in megasas_write_64bit_req_desc()
302 spin_lock_irqsave(&instance->hba_lock, flags); in megasas_write_64bit_req_desc()
304 &instance->reg_set->inbound_low_queue_port); in megasas_write_64bit_req_desc()
306 &instance->reg_set->inbound_high_queue_port); in megasas_write_64bit_req_desc()
307 spin_unlock_irqrestore(&instance->hba_lock, flags); in megasas_write_64bit_req_desc()
320 megasas_fire_cmd_fusion(struct megasas_instance *instance, in megasas_fire_cmd_fusion() argument
323 if (instance->atomic_desc_support) in megasas_fire_cmd_fusion()
325 &instance->reg_set->inbound_single_queue_port); in megasas_fire_cmd_fusion()
327 megasas_write_64bit_req_desc(instance, req_desc); in megasas_fire_cmd_fusion()
342 megasas_fusion_update_can_queue(struct megasas_instance *instance, int fw_boot_context) in megasas_fusion_update_can_queue() argument
348 if (instance->adapter_type < VENTURA_SERIES) in megasas_fusion_update_can_queue()
350 megasas_readl(instance, in megasas_fusion_update_can_queue()
351 &instance->reg_set->outbound_scratch_pad_2) & 0x00FFFF; in megasas_fusion_update_can_queue()
354 cur_max_fw_cmds = instance->instancet->read_fw_status_reg(instance) & 0x00FFFF; in megasas_fusion_update_can_queue()
357 (instance->instancet->read_fw_status_reg(instance) & 0x00FFFF) - MEGASAS_FUSION_IOCTL_CMDS; in megasas_fusion_update_can_queue()
359 dev_info(&instance->pdev->dev, in megasas_fusion_update_can_queue()
365 if (cur_max_fw_cmds < instance->max_fw_cmds) { in megasas_fusion_update_can_queue()
366 instance->cur_can_queue = in megasas_fusion_update_can_queue()
369 instance->host->can_queue = instance->cur_can_queue; in megasas_fusion_update_can_queue()
370 instance->ldio_threshold = ldio_threshold; in megasas_fusion_update_can_queue()
373 instance->max_fw_cmds = cur_max_fw_cmds; in megasas_fusion_update_can_queue()
374 instance->ldio_threshold = ldio_threshold; in megasas_fusion_update_can_queue()
377 instance->max_fw_cmds = min(instance->max_fw_cmds, in megasas_fusion_update_can_queue()
384 instance->max_fw_cmds = instance->max_fw_cmds-1; in megasas_fusion_update_can_queue()
389 megasas_get_msix_index(struct megasas_instance *instance, in megasas_get_msix_index() argument
394 if (instance->perf_mode == MR_BALANCED_PERF_MODE && in megasas_get_msix_index()
395 (megasas_sdev_busy_read(instance, scmd) > in megasas_get_msix_index()
398 mega_mod64((atomic64_add_return(1, &instance->high_iops_outstanding) / in megasas_get_msix_index()
399 MR_HIGH_IOPS_BATCH_COUNT), instance->low_latency_index_start); in megasas_get_msix_index()
400 } else if (instance->msix_load_balance) { in megasas_get_msix_index()
402 (mega_mod64(atomic64_add_return(1, &instance->total_io_count), in megasas_get_msix_index()
403 instance->msix_vectors)); in megasas_get_msix_index()
404 } else if (instance->host->nr_hw_queues > 1) { in megasas_get_msix_index()
408 instance->low_latency_index_start; in megasas_get_msix_index()
411 instance->reply_map[raw_smp_processor_id()]; in megasas_get_msix_index()
420 megasas_free_cmds_fusion(struct megasas_instance *instance) in megasas_free_cmds_fusion() argument
423 struct fusion_context *fusion = instance->ctrl_context; in megasas_free_cmds_fusion()
432 for (i = 0; i < instance->max_mpt_cmds; i++) { in megasas_free_cmds_fusion()
456 if (instance->is_rdpq) in megasas_free_cmds_fusion()
457 megasas_free_rdpq_fusion(instance); in megasas_free_cmds_fusion()
459 megasas_free_reply_fusion(instance); in megasas_free_cmds_fusion()
463 dma_free_coherent(&instance->pdev->dev, in megasas_free_cmds_fusion()
481 static int megasas_create_sg_sense_fusion(struct megasas_instance *instance) in megasas_create_sg_sense_fusion() argument
490 fusion = instance->ctrl_context; in megasas_create_sg_sense_fusion()
491 max_cmd = instance->max_fw_cmds; in megasas_create_sg_sense_fusion()
492 sense_sz = instance->max_mpt_cmds * SCSI_SENSE_BUFFERSIZE; in megasas_create_sg_sense_fusion()
495 dma_pool_create("mr_sg", &instance->pdev->dev, in megasas_create_sg_sense_fusion()
496 instance->max_chain_frame_sz, in megasas_create_sg_sense_fusion()
500 dma_pool_create("mr_sense", &instance->pdev->dev, in megasas_create_sg_sense_fusion()
504 dev_err(&instance->pdev->dev, in megasas_create_sg_sense_fusion()
512 dev_err(&instance->pdev->dev, in megasas_create_sg_sense_fusion()
528 if (!megasas_check_same_4gb_region(instance, fusion->sense_phys_addr, in megasas_create_sg_sense_fusion()
536 dma_pool_create("mr_sense_align", &instance->pdev->dev, in megasas_create_sg_sense_fusion()
540 dev_err(&instance->pdev->dev, in megasas_create_sg_sense_fusion()
548 dev_err(&instance->pdev->dev, in megasas_create_sg_sense_fusion()
567 dev_err(&instance->pdev->dev, in megasas_create_sg_sense_fusion()
574 for (i = max_cmd; i < instance->max_mpt_cmds; i++) { in megasas_create_sg_sense_fusion()
586 megasas_alloc_cmdlist_fusion(struct megasas_instance *instance) in megasas_alloc_cmdlist_fusion() argument
591 fusion = instance->ctrl_context; in megasas_alloc_cmdlist_fusion()
593 max_mpt_cmd = instance->max_mpt_cmds; in megasas_alloc_cmdlist_fusion()
604 dev_err(&instance->pdev->dev, in megasas_alloc_cmdlist_fusion()
616 dev_err(&instance->pdev->dev, in megasas_alloc_cmdlist_fusion()
626 megasas_alloc_request_fusion(struct megasas_instance *instance) in megasas_alloc_request_fusion() argument
630 fusion = instance->ctrl_context; in megasas_alloc_request_fusion()
634 dma_pool_create("mr_ioreq", &instance->pdev->dev, in megasas_alloc_request_fusion()
638 dev_err(&instance->pdev->dev, in megasas_alloc_request_fusion()
648 if (instance->max_fw_cmds >= (MEGASAS_REDUCE_QD_COUNT * 2)) { in megasas_alloc_request_fusion()
649 instance->max_fw_cmds -= MEGASAS_REDUCE_QD_COUNT; in megasas_alloc_request_fusion()
651 megasas_configure_queue_sizes(instance); in megasas_alloc_request_fusion()
654 dev_err(&instance->pdev->dev, in megasas_alloc_request_fusion()
660 if (!megasas_check_same_4gb_region(instance, in megasas_alloc_request_fusion()
671 &instance->pdev->dev, in megasas_alloc_request_fusion()
677 dev_err(&instance->pdev->dev, in megasas_alloc_request_fusion()
688 dev_err(&instance->pdev->dev, in megasas_alloc_request_fusion()
695 dma_alloc_coherent(&instance->pdev->dev, in megasas_alloc_request_fusion()
699 dev_err(&instance->pdev->dev, in megasas_alloc_request_fusion()
708 megasas_alloc_reply_fusion(struct megasas_instance *instance) in megasas_alloc_reply_fusion() argument
713 fusion = instance->ctrl_context; in megasas_alloc_reply_fusion()
715 count = instance->msix_vectors > 0 ? instance->msix_vectors : 1; in megasas_alloc_reply_fusion()
716 count += instance->iopoll_q_count; in megasas_alloc_reply_fusion()
719 dma_pool_create("mr_reply", &instance->pdev->dev, in megasas_alloc_reply_fusion()
723 dev_err(&instance->pdev->dev, in megasas_alloc_reply_fusion()
732 dev_err(&instance->pdev->dev, in megasas_alloc_reply_fusion()
737 if (!megasas_check_same_4gb_region(instance, in megasas_alloc_reply_fusion()
748 &instance->pdev->dev, in megasas_alloc_reply_fusion()
754 dev_err(&instance->pdev->dev, in megasas_alloc_reply_fusion()
765 dev_err(&instance->pdev->dev, in megasas_alloc_reply_fusion()
787 megasas_alloc_rdpq_fusion(struct megasas_instance *instance) in megasas_alloc_rdpq_fusion() argument
797 fusion = instance->ctrl_context; in megasas_alloc_rdpq_fusion()
802 fusion->rdpq_virt = dma_alloc_coherent(&instance->pdev->dev, in megasas_alloc_rdpq_fusion()
806 dev_err(&instance->pdev->dev, in megasas_alloc_rdpq_fusion()
811 msix_count = instance->msix_vectors > 0 ? instance->msix_vectors : 1; in megasas_alloc_rdpq_fusion()
812 msix_count += instance->iopoll_q_count; in megasas_alloc_rdpq_fusion()
815 &instance->pdev->dev, in megasas_alloc_rdpq_fusion()
819 &instance->pdev->dev, in megasas_alloc_rdpq_fusion()
826 dev_err(&instance->pdev->dev, in megasas_alloc_rdpq_fusion()
846 dev_err(&instance->pdev->dev, in megasas_alloc_rdpq_fusion()
862 if (!megasas_check_same_4gb_region(instance, rdpq_chunk_phys[i], in megasas_alloc_rdpq_fusion()
872 dev_err(&instance->pdev->dev, in megasas_alloc_rdpq_fusion()
912 megasas_free_rdpq_fusion(struct megasas_instance *instance) { in megasas_free_rdpq_fusion() argument
917 fusion = instance->ctrl_context; in megasas_free_rdpq_fusion()
931 dma_free_coherent(&instance->pdev->dev, in megasas_free_rdpq_fusion()
937 megasas_free_reply_fusion(struct megasas_instance *instance) { in megasas_free_reply_fusion() argument
941 fusion = instance->ctrl_context; in megasas_free_reply_fusion()
970 megasas_alloc_cmds_fusion(struct megasas_instance *instance) in megasas_alloc_cmds_fusion() argument
980 fusion = instance->ctrl_context; in megasas_alloc_cmds_fusion()
982 if (megasas_alloc_request_fusion(instance)) in megasas_alloc_cmds_fusion()
985 if (instance->is_rdpq) { in megasas_alloc_cmds_fusion()
986 if (megasas_alloc_rdpq_fusion(instance)) in megasas_alloc_cmds_fusion()
989 if (megasas_alloc_reply_fusion(instance)) in megasas_alloc_cmds_fusion()
992 if (megasas_alloc_cmdlist_fusion(instance)) in megasas_alloc_cmds_fusion()
1004 for (i = 0; i < instance->max_mpt_cmds; i++) { in megasas_alloc_cmds_fusion()
1011 (i >= instance->max_scsi_cmds && i < instance->max_fw_cmds) ? in megasas_alloc_cmds_fusion()
1012 (i - instance->max_scsi_cmds) : in megasas_alloc_cmds_fusion()
1014 cmd->instance = instance; in megasas_alloc_cmds_fusion()
1024 if (megasas_create_sg_sense_fusion(instance)) in megasas_alloc_cmds_fusion()
1030 megasas_free_cmds_fusion(instance); in megasas_alloc_cmds_fusion()
1043 wait_and_poll(struct megasas_instance *instance, struct megasas_cmd *cmd, in wait_and_poll() argument
1059 status_reg = instance->instancet->read_fw_status_reg(instance) in wait_and_poll()
1081 megasas_ioc_init_fusion(struct megasas_instance *instance) in megasas_ioc_init_fusion() argument
1099 fusion = instance->ctrl_context; in megasas_ioc_init_fusion()
1107 (instance, &instance->reg_set->outbound_scratch_pad_1); in megasas_ioc_init_fusion()
1111 if (instance->adapter_type == INVADER_SERIES) { in megasas_ioc_init_fusion()
1115 if (instance->consistent_mask_64bit && !cur_fw_64bit_dma_capable) { in megasas_ioc_init_fusion()
1116 dev_err(&instance->pdev->dev, "Driver was operating on 64bit " in megasas_ioc_init_fusion()
1118 megaraid_sas_kill_hba(instance); in megasas_ioc_init_fusion()
1124 if (instance->is_rdpq && !cur_rdpq_mode) { in megasas_ioc_init_fusion()
1125 dev_err(&instance->pdev->dev, "Firmware downgrade *NOT SUPPORTED*" in megasas_ioc_init_fusion()
1134 if ((instance->low_latency_index_start == in megasas_ioc_init_fusion()
1136 instance->perf_mode = MR_BALANCED_PERF_MODE; in megasas_ioc_init_fusion()
1138 dev_info(&instance->pdev->dev, "Performance mode :%s (latency index = %d)\n", in megasas_ioc_init_fusion()
1139 MEGASAS_PERF_MODE_2STR(instance->perf_mode), in megasas_ioc_init_fusion()
1140 instance->low_latency_index_start); in megasas_ioc_init_fusion()
1142 instance->fw_sync_cache_support = (scratch_pad_1 & in megasas_ioc_init_fusion()
1144 dev_info(&instance->pdev->dev, "FW supports sync cache\t: %s\n", in megasas_ioc_init_fusion()
1145 instance->fw_sync_cache_support ? "Yes" : "No"); in megasas_ioc_init_fusion()
1156 IOCInitMessage->ReplyDescriptorPostQueueAddress = instance->is_rdpq ? in megasas_ioc_init_fusion()
1159 IOCInitMessage->MsgFlags = instance->is_rdpq ? in megasas_ioc_init_fusion()
1163 IOCInitMessage->HostMSIxVectors = instance->msix_vectors + instance->iopoll_q_count; in megasas_ioc_init_fusion()
1183 if (instance->adapter_type >= INVADER_SERIES) in megasas_ioc_init_fusion()
1192 if (instance->max_chain_frame_sz > MEGASAS_CHAIN_FRAME_SZ_MIN) in megasas_ioc_init_fusion()
1204 if (instance->consistent_mask_64bit) in megasas_ioc_init_fusion()
1211 if (instance->system_info_buf && sys_info) { in megasas_ioc_init_fusion()
1212 memcpy(instance->system_info_buf->systemId, sys_info, in megasas_ioc_init_fusion()
1214 instance->system_info_buf->systemIdLength = in megasas_ioc_init_fusion()
1216 init_frame->system_info_lo = cpu_to_le32(lower_32_bits(instance->system_info_h)); in megasas_ioc_init_fusion()
1217 init_frame->system_info_hi = cpu_to_le32(upper_32_bits(instance->system_info_h)); in megasas_ioc_init_fusion()
1230 switch (instance->perf_mode) { in megasas_ioc_init_fusion()
1233 cpu_to_le16(~(~0 << instance->low_latency_index_start/8)); in megasas_ioc_init_fusion()
1237 cpu_to_le16(~(~0 << instance->msix_vectors/8)); in megasas_ioc_init_fusion()
1251 instance->instancet->disable_intr(instance); in megasas_ioc_init_fusion()
1254 if (megasas_readl(instance, &instance->reg_set->doorbell) & 1) in megasas_ioc_init_fusion()
1261 megasas_write_64bit_req_desc(instance, &req_desc); in megasas_ioc_init_fusion()
1263 wait_and_poll(instance, cmd, MFI_IO_TIMEOUT_SECS); in megasas_ioc_init_fusion()
1271 if (instance->adapter_type >= AERO_SERIES) { in megasas_ioc_init_fusion()
1273 (instance, &instance->reg_set->outbound_scratch_pad_1); in megasas_ioc_init_fusion()
1275 instance->atomic_desc_support = in megasas_ioc_init_fusion()
1278 dev_info(&instance->pdev->dev, "FW supports atomic descriptor\t: %s\n", in megasas_ioc_init_fusion()
1279 instance->atomic_desc_support ? "Yes" : "No"); in megasas_ioc_init_fusion()
1285 dev_err(&instance->pdev->dev, in megasas_ioc_init_fusion()
1287 instance->host->host_no); in megasas_ioc_init_fusion()
1302 megasas_sync_pd_seq_num(struct megasas_instance *instance, bool pend) { in megasas_sync_pd_seq_num() argument
1307 struct fusion_context *fusion = instance->ctrl_context; in megasas_sync_pd_seq_num()
1311 pd_sync = (void *)fusion->pd_seq_sync[(instance->pd_seq_map_id & 1)]; in megasas_sync_pd_seq_num()
1312 pd_seq_h = fusion->pd_seq_phys[(instance->pd_seq_map_id & 1)]; in megasas_sync_pd_seq_num()
1315 cmd = megasas_get_cmd(instance); in megasas_sync_pd_seq_num()
1317 dev_err(&instance->pdev->dev, in megasas_sync_pd_seq_num()
1331 instance->jbod_seq_cmd = cmd; in megasas_sync_pd_seq_num()
1344 megasas_set_dma_settings(instance, dcmd, pd_seq_h, pd_seq_map_sz); in megasas_sync_pd_seq_num()
1347 instance->instancet->issue_dcmd(instance, cmd); in megasas_sync_pd_seq_num()
1352 if (!instance->mask_interrupts) in megasas_sync_pd_seq_num()
1353 ret = megasas_issue_blocked_cmd(instance, cmd, in megasas_sync_pd_seq_num()
1356 ret = megasas_issue_polled(instance, cmd); in megasas_sync_pd_seq_num()
1359 dev_warn(&instance->pdev->dev, in megasas_sync_pd_seq_num()
1366 dev_warn(&instance->pdev->dev, in megasas_sync_pd_seq_num()
1371 instance->pd_seq_map_id++; in megasas_sync_pd_seq_num()
1373 megasas_return_cmd(instance, cmd); in megasas_sync_pd_seq_num()
1393 megasas_get_ld_map_info(struct megasas_instance *instance) in megasas_get_ld_map_info() argument
1403 cmd = megasas_get_cmd(instance); in megasas_get_ld_map_info()
1406 dev_printk(KERN_DEBUG, &instance->pdev->dev, "Failed to get cmd for map info\n"); in megasas_get_ld_map_info()
1410 fusion = instance->ctrl_context; in megasas_get_ld_map_info()
1413 megasas_return_cmd(instance, cmd); in megasas_get_ld_map_info()
1421 ci = (void *) fusion->ld_map[(instance->map_id & 1)]; in megasas_get_ld_map_info()
1422 ci_h = fusion->ld_map_phys[(instance->map_id & 1)]; in megasas_get_ld_map_info()
1425 dev_printk(KERN_DEBUG, &instance->pdev->dev, "Failed to alloc mem for ld_map_info\n"); in megasas_get_ld_map_info()
1426 megasas_return_cmd(instance, cmd); in megasas_get_ld_map_info()
1441 megasas_set_dma_settings(instance, dcmd, ci_h, size_map_info); in megasas_get_ld_map_info()
1443 if (!instance->mask_interrupts) in megasas_get_ld_map_info()
1444 ret = megasas_issue_blocked_cmd(instance, cmd, in megasas_get_ld_map_info()
1447 ret = megasas_issue_polled(instance, cmd); in megasas_get_ld_map_info()
1450 dev_warn(&instance->pdev->dev, in megasas_get_ld_map_info()
1454 megasas_return_cmd(instance, cmd); in megasas_get_ld_map_info()
1460 megasas_get_map_info(struct megasas_instance *instance) in megasas_get_map_info() argument
1462 struct fusion_context *fusion = instance->ctrl_context; in megasas_get_map_info()
1465 if (!megasas_get_ld_map_info(instance)) { in megasas_get_map_info()
1466 if (MR_ValidateMapInfo(instance, instance->map_id)) { in megasas_get_map_info()
1483 megasas_sync_map_info(struct megasas_instance *instance) in megasas_sync_map_info() argument
1497 cmd = megasas_get_cmd(instance); in megasas_sync_map_info()
1500 dev_printk(KERN_DEBUG, &instance->pdev->dev, "Failed to get cmd for sync info\n"); in megasas_sync_map_info()
1504 fusion = instance->ctrl_context; in megasas_sync_map_info()
1507 megasas_return_cmd(instance, cmd); in megasas_sync_map_info()
1511 map = fusion->ld_drv_map[instance->map_id & 1]; in megasas_sync_map_info()
1520 fusion->ld_map[(instance->map_id - 1) & 1]; in megasas_sync_map_info()
1523 ci_h = fusion->ld_map_phys[(instance->map_id - 1) & 1]; in megasas_sync_map_info()
1546 megasas_set_dma_settings(instance, dcmd, ci_h, size_map_info); in megasas_sync_map_info()
1548 instance->map_update_cmd = cmd; in megasas_sync_map_info()
1550 instance->instancet->issue_dcmd(instance, cmd); in megasas_sync_map_info()
1562 megasas_display_intel_branding(struct megasas_instance *instance) in megasas_display_intel_branding() argument
1564 if (instance->pdev->subsystem_vendor != PCI_VENDOR_ID_INTEL) in megasas_display_intel_branding()
1567 switch (instance->pdev->device) { in megasas_display_intel_branding()
1569 switch (instance->pdev->subsystem_device) { 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()
1576 dev_info(&instance->pdev->dev, "scsi host %d: %s\n", in megasas_display_intel_branding()
1577 instance->host->host_no, in megasas_display_intel_branding()
1581 dev_info(&instance->pdev->dev, "scsi host %d: %s\n", in megasas_display_intel_branding()
1582 instance->host->host_no, in megasas_display_intel_branding()
1586 dev_info(&instance->pdev->dev, "scsi host %d: %s\n", in megasas_display_intel_branding()
1587 instance->host->host_no, in megasas_display_intel_branding()
1595 switch (instance->pdev->subsystem_device) { in megasas_display_intel_branding()
1597 dev_info(&instance->pdev->dev, "scsi host %d: %s\n", in megasas_display_intel_branding()
1598 instance->host->host_no, in megasas_display_intel_branding()
1602 dev_info(&instance->pdev->dev, "scsi host %d: %s\n", in megasas_display_intel_branding()
1603 instance->host->host_no, in megasas_display_intel_branding()
1612 switch (instance->pdev->subsystem_device) { in megasas_display_intel_branding()
1614 dev_info(&instance->pdev->dev, "scsi host %d: %s\n", in megasas_display_intel_branding()
1615 instance->host->host_no, in megasas_display_intel_branding()
1634 static inline int megasas_allocate_raid_maps(struct megasas_instance *instance) in megasas_allocate_raid_maps() argument
1639 fusion = instance->ctrl_context; in megasas_allocate_raid_maps()
1654 dev_err(&instance->pdev->dev, in megasas_allocate_raid_maps()
1664 fusion->ld_map[i] = dma_alloc_coherent(&instance->pdev->dev, in megasas_allocate_raid_maps()
1669 dev_err(&instance->pdev->dev, in megasas_allocate_raid_maps()
1681 dma_free_coherent(&instance->pdev->dev, in megasas_allocate_raid_maps()
1709 void megasas_configure_queue_sizes(struct megasas_instance *instance) in megasas_configure_queue_sizes() argument
1714 fusion = instance->ctrl_context; in megasas_configure_queue_sizes()
1715 max_cmd = instance->max_fw_cmds; in megasas_configure_queue_sizes()
1717 if (instance->adapter_type >= VENTURA_SERIES) in megasas_configure_queue_sizes()
1718 instance->max_mpt_cmds = instance->max_fw_cmds * RAID_1_PEER_CMDS; in megasas_configure_queue_sizes()
1720 instance->max_mpt_cmds = instance->max_fw_cmds; in megasas_configure_queue_sizes()
1722 instance->max_scsi_cmds = instance->max_fw_cmds - instance->max_mfi_cmds; in megasas_configure_queue_sizes()
1723 instance->cur_can_queue = instance->max_scsi_cmds; in megasas_configure_queue_sizes()
1724 instance->host->can_queue = instance->cur_can_queue; in megasas_configure_queue_sizes()
1729 instance->max_mpt_cmds; in megasas_configure_queue_sizes()
1734 * (instance->max_mpt_cmds + 1)); /* Extra 1 for SMID 0 */ in megasas_configure_queue_sizes()
1737 static int megasas_alloc_ioc_init_frame(struct megasas_instance *instance) in megasas_alloc_ioc_init_frame() argument
1742 fusion = instance->ctrl_context; in megasas_alloc_ioc_init_frame()
1747 dev_err(&instance->pdev->dev, "Failed from func: %s line: %d\n", in megasas_alloc_ioc_init_frame()
1752 cmd->frame = dma_alloc_coherent(&instance->pdev->dev, in megasas_alloc_ioc_init_frame()
1757 dev_err(&instance->pdev->dev, "Failed from func: %s line: %d\n", in megasas_alloc_ioc_init_frame()
1771 static inline void megasas_free_ioc_init_cmd(struct megasas_instance *instance) in megasas_free_ioc_init_cmd() argument
1775 fusion = instance->ctrl_context; in megasas_free_ioc_init_cmd()
1778 dma_free_coherent(&instance->pdev->dev, in megasas_free_ioc_init_cmd()
1793 megasas_init_adapter_fusion(struct megasas_instance *instance) in megasas_init_adapter_fusion() argument
1800 fusion = instance->ctrl_context; in megasas_init_adapter_fusion()
1802 megasas_fusion_update_can_queue(instance, PROBE_CONTEXT); in megasas_init_adapter_fusion()
1807 instance->max_mfi_cmds = in megasas_init_adapter_fusion()
1810 megasas_configure_queue_sizes(instance); in megasas_init_adapter_fusion()
1812 scratch_pad_1 = megasas_readl(instance, in megasas_init_adapter_fusion()
1813 &instance->reg_set->outbound_scratch_pad_1); in megasas_init_adapter_fusion()
1821 instance->max_chain_frame_sz = in megasas_init_adapter_fusion()
1825 instance->max_chain_frame_sz = in megasas_init_adapter_fusion()
1829 if (instance->max_chain_frame_sz < MEGASAS_CHAIN_FRAME_SZ_MIN) { in megasas_init_adapter_fusion()
1830 dev_warn(&instance->pdev->dev, "frame size %d invalid, fall back to legacy max frame size %d\n", in megasas_init_adapter_fusion()
1831 instance->max_chain_frame_sz, in megasas_init_adapter_fusion()
1833 instance->max_chain_frame_sz = MEGASAS_CHAIN_FRAME_SZ_MIN; in megasas_init_adapter_fusion()
1841 instance->max_chain_frame_sz in megasas_init_adapter_fusion()
1844 instance->max_num_sge = in megasas_init_adapter_fusion()
1856 count = instance->msix_vectors > 0 ? instance->msix_vectors : 1; in megasas_init_adapter_fusion()
1857 count += instance->iopoll_q_count; in megasas_init_adapter_fusion()
1866 instance->max_scsi_cmds = instance->max_fw_cmds - in megasas_init_adapter_fusion()
1869 sema_init(&instance->ioctl_sem, MEGASAS_FUSION_IOCTL_CMDS); in megasas_init_adapter_fusion()
1874 if (megasas_alloc_ioc_init_frame(instance)) in megasas_init_adapter_fusion()
1881 if (megasas_alloc_cmds(instance)) in megasas_init_adapter_fusion()
1883 if (megasas_alloc_cmds_fusion(instance)) in megasas_init_adapter_fusion()
1886 if (megasas_ioc_init_fusion(instance)) { in megasas_init_adapter_fusion()
1887 status_reg = instance->instancet->read_fw_status_reg(instance); in megasas_init_adapter_fusion()
1892 (instance, true, 0) == FAILED) in megasas_init_adapter_fusion()
1895 if (megasas_ioc_init_fusion(instance)) in megasas_init_adapter_fusion()
1902 megasas_display_intel_branding(instance); in megasas_init_adapter_fusion()
1903 if (megasas_get_ctrl_info(instance)) { in megasas_init_adapter_fusion()
1904 dev_err(&instance->pdev->dev, in megasas_init_adapter_fusion()
1910 instance->flag_ieee = 1; in megasas_init_adapter_fusion()
1911 instance->r1_ldio_hint_default = MR_R1_LDIO_PIGGYBACK_DEFAULT; in megasas_init_adapter_fusion()
1912 instance->threshold_reply_count = instance->max_fw_cmds / 4; in megasas_init_adapter_fusion()
1915 if (megasas_allocate_raid_maps(instance)) in megasas_init_adapter_fusion()
1918 if (!megasas_get_map_info(instance)) in megasas_init_adapter_fusion()
1919 megasas_sync_map_info(instance); in megasas_init_adapter_fusion()
1924 megasas_free_cmds_fusion(instance); in megasas_init_adapter_fusion()
1926 megasas_free_cmds(instance); in megasas_init_adapter_fusion()
1928 megasas_free_ioc_init_cmd(instance); in megasas_init_adapter_fusion()
1940 struct megasas_instance *instance = in megasas_fault_detect_work() local
1946 fw_state = instance->instancet->read_fw_status_reg(instance) & in megasas_fault_detect_work()
1950 dma_state = instance->instancet->read_fw_status_reg(instance) & in megasas_fault_detect_work()
1953 if (instance->crash_dump_drv_support && in megasas_fault_detect_work()
1954 instance->crash_dump_app_support && dma_state) { in megasas_fault_detect_work()
1955 megasas_fusion_crash_dump(instance); in megasas_fault_detect_work()
1957 if (instance->unload == 0) { in megasas_fault_detect_work()
1958 status = megasas_reset_fusion(instance->host, 0); in megasas_fault_detect_work()
1960 dev_err(&instance->pdev->dev, in megasas_fault_detect_work()
1969 if (instance->fw_fault_work_q) in megasas_fault_detect_work()
1970 queue_delayed_work(instance->fw_fault_work_q, in megasas_fault_detect_work()
1971 &instance->fw_fault_work, in megasas_fault_detect_work()
1976 megasas_fusion_start_watchdog(struct megasas_instance *instance) in megasas_fusion_start_watchdog() argument
1979 if (instance->fw_fault_work_q) in megasas_fusion_start_watchdog()
1982 INIT_DELAYED_WORK(&instance->fw_fault_work, megasas_fault_detect_work); in megasas_fusion_start_watchdog()
1984 snprintf(instance->fault_handler_work_q_name, in megasas_fusion_start_watchdog()
1985 sizeof(instance->fault_handler_work_q_name), in megasas_fusion_start_watchdog()
1986 "poll_megasas%d_status", instance->host->host_no); in megasas_fusion_start_watchdog()
1988 instance->fw_fault_work_q = in megasas_fusion_start_watchdog()
1989 create_singlethread_workqueue(instance->fault_handler_work_q_name); in megasas_fusion_start_watchdog()
1990 if (!instance->fw_fault_work_q) { in megasas_fusion_start_watchdog()
1991 dev_err(&instance->pdev->dev, "Failed from %s %d\n", in megasas_fusion_start_watchdog()
1996 queue_delayed_work(instance->fw_fault_work_q, in megasas_fusion_start_watchdog()
1997 &instance->fw_fault_work, in megasas_fusion_start_watchdog()
2004 megasas_fusion_stop_watchdog(struct megasas_instance *instance) in megasas_fusion_stop_watchdog() argument
2008 if (instance->fw_fault_work_q) { in megasas_fusion_stop_watchdog()
2009 wq = instance->fw_fault_work_q; in megasas_fusion_stop_watchdog()
2010 instance->fw_fault_work_q = NULL; in megasas_fusion_stop_watchdog()
2011 if (!cancel_delayed_work_sync(&instance->fw_fault_work)) in megasas_fusion_stop_watchdog()
2096 megasas_is_prp_possible(struct megasas_instance *instance, in megasas_is_prp_possible() argument
2104 mr_nvme_pg_size = max_t(u32, instance->nvme_page_size, in megasas_is_prp_possible()
2144 megasas_make_prp_nvme(struct megasas_instance *instance, struct scsi_cmnd *scmd, in megasas_make_prp_nvme() argument
2158 u32 mr_nvme_pg_size = max_t(u32, instance->nvme_page_size, in megasas_make_prp_nvme()
2161 build_prp = megasas_is_prp_possible(instance, scmd, sge_count); in megasas_make_prp_nvme()
2181 memset(ptr_sgl, 0, instance->max_chain_frame_sz); in megasas_make_prp_nvme()
2267 megasas_make_sgl_fusion(struct megasas_instance *instance, in megasas_make_sgl_fusion() argument
2276 fusion = instance->ctrl_context; in megasas_make_sgl_fusion()
2278 if (instance->adapter_type >= INVADER_SERIES) { in megasas_make_sgl_fusion()
2288 if (instance->adapter_type >= INVADER_SERIES) in megasas_make_sgl_fusion()
2298 if (instance->adapter_type >= INVADER_SERIES) { in megasas_make_sgl_fusion()
2314 if (instance->adapter_type >= INVADER_SERIES) in megasas_make_sgl_fusion()
2325 memset(sgl_ptr, 0, instance->max_chain_frame_sz); in megasas_make_sgl_fusion()
2344 int megasas_make_sgl(struct megasas_instance *instance, struct scsi_cmnd *scp, in megasas_make_sgl() argument
2353 if ((sge_count > instance->max_num_sge) || (sge_count <= 0)) in megasas_make_sgl()
2360 build_prp = megasas_make_prp_nvme(instance, scp, sgl_chain64, in megasas_make_sgl()
2364 megasas_make_sgl_fusion(instance, scp, sgl_chain64, in megasas_make_sgl()
2559 static void megasas_stream_detect(struct megasas_instance *instance, in megasas_stream_detect() argument
2563 struct fusion_context *fusion = instance->ctrl_context; in megasas_stream_detect()
2723 megasas_build_ldio_fusion(struct megasas_instance *instance, in megasas_build_ldio_fusion() argument
2744 fusion = instance->ctrl_context; in megasas_build_ldio_fusion()
2820 local_map_ptr = fusion->ld_drv_map[(instance->map_id & 1)]; in megasas_build_ldio_fusion()
2823 if (ld < instance->fw_supported_vd_count) in megasas_build_ldio_fusion()
2830 if (MR_BuildRaidContext(instance, &io_info, rctx, in megasas_build_ldio_fusion()
2835 megasas_get_msix_index(instance, scp, cmd, io_info.data_arms); in megasas_build_ldio_fusion()
2837 if (instance->adapter_type >= VENTURA_SERIES) { in megasas_build_ldio_fusion()
2849 if (atomic_inc_return(&instance->fw_outstanding) > in megasas_build_ldio_fusion()
2850 (instance->host->can_queue)) { in megasas_build_ldio_fusion()
2852 atomic_dec(&instance->fw_outstanding); in megasas_build_ldio_fusion()
2857 atomic_dec(&instance->fw_outstanding); in megasas_build_ldio_fusion()
2860 instance->r1_ldio_hint_default); in megasas_build_ldio_fusion()
2866 spin_lock_irqsave(&instance->stream_lock, in megasas_build_ldio_fusion()
2868 megasas_stream_detect(instance, cmd, &io_info); in megasas_build_ldio_fusion()
2869 spin_unlock_irqrestore(&instance->stream_lock, in megasas_build_ldio_fusion()
2895 if (instance->adapter_type == INVADER_SERIES) { in megasas_build_ldio_fusion()
2902 } else if (instance->adapter_type >= VENTURA_SERIES) { in megasas_build_ldio_fusion()
2913 get_updated_dev_handle(instance, in megasas_build_ldio_fusion()
2918 if (instance->adapter_type >= VENTURA_SERIES) in megasas_build_ldio_fusion()
2926 if (instance->adapter_type >= VENTURA_SERIES) in megasas_build_ldio_fusion()
2933 instance->dev_handle = !(instance->dev_handle); in megasas_build_ldio_fusion()
2935 local_map_ptr->raidMap.devHndlInfo[io_info.pd_after_lb].devHandle[instance->dev_handle]; in megasas_build_ldio_fusion()
2949 if (instance->adapter_type == INVADER_SERIES) { in megasas_build_ldio_fusion()
2960 } else if (instance->adapter_type >= VENTURA_SERIES) { in megasas_build_ldio_fusion()
2979 static void megasas_build_ld_nonrw_fusion(struct megasas_instance *instance, in megasas_build_ld_nonrw_fusion() argument
2986 struct fusion_context *fusion = instance->ctrl_context; in megasas_build_ld_nonrw_fusion()
2996 local_map_ptr = fusion->ld_drv_map[(instance->map_id & 1)]; in megasas_build_ld_nonrw_fusion()
3006 device_id < instance->fw_supported_vd_count)) { in megasas_build_ld_nonrw_fusion()
3009 if (ld >= instance->fw_supported_vd_count - 1) in megasas_build_ld_nonrw_fusion()
3032 if (instance->adapter_type < VENTURA_SERIES) in megasas_build_ld_nonrw_fusion()
3069 megasas_build_syspd_fusion(struct megasas_instance *instance, in megasas_build_syspd_fusion() argument
3082 struct fusion_context *fusion = instance->ctrl_context; in megasas_build_syspd_fusion()
3083 pd_sync = (void *)fusion->pd_seq_sync[(instance->pd_seq_map_id - 1) & 1]; in megasas_build_syspd_fusion()
3103 if (instance->support_seqnum_jbod_fp) { in megasas_build_syspd_fusion()
3104 if (instance->use_seqnum_jbod_fp && in megasas_build_syspd_fusion()
3105 instance->pd_list[pd_index].driveType == TYPE_DISK) { in megasas_build_syspd_fusion()
3108 if (instance->support_morethan256jbod) in megasas_build_syspd_fusion()
3119 if (instance->adapter_type >= VENTURA_SERIES) { in megasas_build_syspd_fusion()
3146 fusion->ld_drv_map[(instance->map_id & 1)]; in megasas_build_syspd_fusion()
3156 megasas_get_msix_index(instance, scmd, cmd, 1); in megasas_build_syspd_fusion()
3177 if (instance->adapter_type >= INVADER_SERIES) in megasas_build_syspd_fusion()
3197 megasas_build_io_fusion(struct megasas_instance *instance, in megasas_build_io_fusion() argument
3230 megasas_build_ldio_fusion(instance, scp, cmd); in megasas_build_io_fusion()
3233 megasas_build_ld_nonrw_fusion(instance, scp, cmd); in megasas_build_io_fusion()
3236 megasas_build_syspd_fusion(instance, scp, cmd, true); in megasas_build_io_fusion()
3240 drive_type = instance->pd_list[pd_index].driveType; in megasas_build_io_fusion()
3241 if ((instance->secure_jbod_support || in megasas_build_io_fusion()
3243 (instance->adapter_type >= VENTURA_SERIES && in megasas_build_io_fusion()
3245 megasas_build_syspd_fusion(instance, scp, cmd, false); in megasas_build_io_fusion()
3247 megasas_build_syspd_fusion(instance, scp, cmd, true); in megasas_build_io_fusion()
3257 sge_count = megasas_make_sgl(instance, scp, cmd); in megasas_build_io_fusion()
3259 if (sge_count > instance->max_num_sge || (sge_count < 0)) { in megasas_build_io_fusion()
3260 dev_err(&instance->pdev->dev, in megasas_build_io_fusion()
3262 __func__, __LINE__, sge_count, instance->max_num_sge); in megasas_build_io_fusion()
3266 if (instance->adapter_type >= VENTURA_SERIES) { in megasas_build_io_fusion()
3300 megasas_get_request_descriptor(struct megasas_instance *instance, u16 index) in megasas_get_request_descriptor() argument
3305 fusion = instance->ctrl_context; in megasas_get_request_descriptor()
3316 static void megasas_prepare_secondRaid1_IO(struct megasas_instance *instance, in megasas_prepare_secondRaid1_IO() argument
3322 fusion = instance->ctrl_context; in megasas_prepare_secondRaid1_IO()
3333 req_desc2 = megasas_get_request_descriptor(instance, in megasas_prepare_secondRaid1_IO()
3361 megasas_build_and_issue_cmd_fusion(struct megasas_instance *instance, in megasas_build_and_issue_cmd_fusion() argument
3369 instance->ldio_threshold && in megasas_build_and_issue_cmd_fusion()
3370 (atomic_inc_return(&instance->ldio_outstanding) > in megasas_build_and_issue_cmd_fusion()
3371 instance->ldio_threshold)) { in megasas_build_and_issue_cmd_fusion()
3372 atomic_dec(&instance->ldio_outstanding); in megasas_build_and_issue_cmd_fusion()
3376 if (atomic_inc_return(&instance->fw_outstanding) > in megasas_build_and_issue_cmd_fusion()
3377 instance->host->can_queue) { in megasas_build_and_issue_cmd_fusion()
3378 atomic_dec(&instance->fw_outstanding); in megasas_build_and_issue_cmd_fusion()
3382 cmd = megasas_get_cmd_fusion(instance, scsi_cmd_to_rq(scmd)->tag); in megasas_build_and_issue_cmd_fusion()
3385 atomic_dec(&instance->fw_outstanding); in megasas_build_and_issue_cmd_fusion()
3391 req_desc = megasas_get_request_descriptor(instance, index-1); in megasas_build_and_issue_cmd_fusion()
3396 if (megasas_build_io_fusion(instance, scmd, cmd)) { in megasas_build_and_issue_cmd_fusion()
3397 megasas_return_cmd_fusion(instance, cmd); in megasas_build_and_issue_cmd_fusion()
3398 dev_err(&instance->pdev->dev, "Error building command\n"); in megasas_build_and_issue_cmd_fusion()
3400 atomic_dec(&instance->fw_outstanding); in megasas_build_and_issue_cmd_fusion()
3409 dev_err(&instance->pdev->dev, "The chain offset value is not " in megasas_build_and_issue_cmd_fusion()
3422 r1_cmd = megasas_get_cmd_fusion(instance, in megasas_build_and_issue_cmd_fusion()
3423 scsi_cmd_to_rq(scmd)->tag + instance->max_fw_cmds); in megasas_build_and_issue_cmd_fusion()
3424 megasas_prepare_secondRaid1_IO(instance, cmd, r1_cmd); in megasas_build_and_issue_cmd_fusion()
3432 megasas_sdev_busy_inc(instance, scmd); in megasas_build_and_issue_cmd_fusion()
3433 megasas_fire_cmd_fusion(instance, req_desc); in megasas_build_and_issue_cmd_fusion()
3436 megasas_fire_cmd_fusion(instance, r1_cmd->request_desc); in megasas_build_and_issue_cmd_fusion()
3450 megasas_complete_r1_command(struct megasas_instance *instance, in megasas_complete_r1_command() argument
3462 fusion = instance->ctrl_context; in megasas_complete_r1_command()
3484 megasas_return_cmd_fusion(instance, r1_cmd); in megasas_complete_r1_command()
3487 if (instance->ldio_threshold && in megasas_complete_r1_command()
3489 atomic_dec(&instance->ldio_outstanding); in megasas_complete_r1_command()
3491 megasas_return_cmd_fusion(instance, cmd); in megasas_complete_r1_command()
3493 megasas_sdev_busy_dec(instance, scmd_local); in megasas_complete_r1_command()
3542 complete_cmd_fusion(struct megasas_instance *instance, u32 MSIxIndex, in complete_cmd_fusion() argument
3561 fusion = instance->ctrl_context; in complete_cmd_fusion()
3563 if (atomic_read(&instance->adprecovery) == MEGASAS_HW_CRITICAL_ERROR) in complete_cmd_fusion()
3606 dev_dbg(&instance->pdev->dev, "TM completion:" in complete_cmd_fusion()
3624 atomic_dec(&instance->fw_outstanding); in complete_cmd_fusion()
3629 if (instance->ldio_threshold && in complete_cmd_fusion()
3631 atomic_dec(&instance->ldio_outstanding); in complete_cmd_fusion()
3633 megasas_return_cmd_fusion(instance, cmd_fusion); in complete_cmd_fusion()
3635 megasas_sdev_busy_dec(instance, scmd_local); in complete_cmd_fusion()
3638 megasas_complete_r1_command(instance, cmd_fusion); in complete_cmd_fusion()
3641 cmd_mfi = instance->cmd_list[cmd_fusion->sync_cmd_idx]; in complete_cmd_fusion()
3647 megasas_return_cmd(instance, cmd_mfi); in complete_cmd_fusion()
3649 megasas_complete_cmd(instance, cmd_mfi, DID_OK); in complete_cmd_fusion()
3683 if (threshold_reply_count >= instance->threshold_reply_count) { in complete_cmd_fusion()
3684 if (instance->msix_combined) in complete_cmd_fusion()
3687 instance->reply_post_host_index_addr[MSIxIndex/8]); in complete_cmd_fusion()
3691 instance->reply_post_host_index_addr[0]); in complete_cmd_fusion()
3707 if (instance->msix_combined) in complete_cmd_fusion()
3710 instance->reply_post_host_index_addr[MSIxIndex/8]); in complete_cmd_fusion()
3714 instance->reply_post_host_index_addr[0]); in complete_cmd_fusion()
3715 megasas_check_and_restore_queue_depth(instance); in complete_cmd_fusion()
3726 struct megasas_instance *instance; in megasas_blk_mq_poll() local
3730 instance = (struct megasas_instance *)shost->hostdata; in megasas_blk_mq_poll()
3732 fusion = instance->ctrl_context; in megasas_blk_mq_poll()
3734 queue_num = queue_num + instance->low_latency_index_start; in megasas_blk_mq_poll()
3739 num_entries = complete_cmd_fusion(instance, queue_num, NULL); in megasas_blk_mq_poll()
3749 static void megasas_enable_irq_poll(struct megasas_instance *instance) in megasas_enable_irq_poll() argument
3754 count = instance->msix_vectors > 0 ? instance->msix_vectors : 1; in megasas_enable_irq_poll()
3757 irq_ctx = &instance->irq_context[i]; in megasas_enable_irq_poll()
3769 struct megasas_instance *instance = in megasas_sync_irqs() local
3773 count = instance->msix_vectors > 0 ? instance->msix_vectors : 1; in megasas_sync_irqs()
3776 synchronize_irq(pci_irq_vector(instance->pdev, i)); in megasas_sync_irqs()
3777 irq_ctx = &instance->irq_context[i]; in megasas_sync_irqs()
3782 complete_cmd_fusion(instance, irq_ctx->MSIxIndex, irq_ctx); in megasas_sync_irqs()
3798 struct megasas_instance *instance; in megasas_irqpoll() local
3802 instance = irq_ctx->instance; in megasas_irqpoll()
3809 num_entries = complete_cmd_fusion(instance, irq_ctx->MSIxIndex, irq_ctx); in megasas_irqpoll()
3814 complete_cmd_fusion(instance, irq_ctx->MSIxIndex, irq_ctx); in megasas_irqpoll()
3829 struct megasas_instance *instance = in megasas_complete_cmd_dpc_fusion() local
3834 count = instance->msix_vectors > 0 ? instance->msix_vectors : 1; in megasas_complete_cmd_dpc_fusion()
3837 if (atomic_read(&instance->adprecovery) == MEGASAS_HW_CRITICAL_ERROR) in megasas_complete_cmd_dpc_fusion()
3841 irq_ctx = &instance->irq_context[MSIxIndex]; in megasas_complete_cmd_dpc_fusion()
3842 complete_cmd_fusion(instance, MSIxIndex, irq_ctx); in megasas_complete_cmd_dpc_fusion()
3854 struct megasas_instance *instance = irq_context->instance; in megasas_isr_fusion() local
3857 if (instance->mask_interrupts) in megasas_isr_fusion()
3863 if (!instance->msix_vectors) { in megasas_isr_fusion()
3864 mfiStatus = instance->instancet->clear_intr(instance); in megasas_isr_fusion()
3870 if (test_bit(MEGASAS_FUSION_IN_RESET, &instance->reset_flags)) { in megasas_isr_fusion()
3871 instance->instancet->clear_intr(instance); in megasas_isr_fusion()
3875 return complete_cmd_fusion(instance, irq_context->MSIxIndex, irq_context) in megasas_isr_fusion()
3886 build_mpt_mfi_pass_thru(struct megasas_instance *instance, in build_mpt_mfi_pass_thru() argument
3895 fusion = instance->ctrl_context; in build_mpt_mfi_pass_thru()
3897 cmd = megasas_get_cmd_fusion(instance, in build_mpt_mfi_pass_thru()
3898 instance->max_scsi_cmds + mfi_cmd->index); in build_mpt_mfi_pass_thru()
3914 if (instance->adapter_type >= INVADER_SERIES) { in build_mpt_mfi_pass_thru()
3934 mpi25_ieee_chain->Length = cpu_to_le32(instance->mfi_frame_size); in build_mpt_mfi_pass_thru()
3944 build_mpt_cmd(struct megasas_instance *instance, struct megasas_cmd *cmd) in build_mpt_cmd() argument
3949 build_mpt_mfi_pass_thru(instance, cmd); in build_mpt_cmd()
3952 req_desc = megasas_get_request_descriptor(instance, index - 1); in build_mpt_cmd()
3970 megasas_issue_dcmd_fusion(struct megasas_instance *instance, in megasas_issue_dcmd_fusion() argument
3975 req_desc = build_mpt_cmd(instance, cmd); in megasas_issue_dcmd_fusion()
3977 megasas_fire_cmd_fusion(instance, req_desc); in megasas_issue_dcmd_fusion()
3986 megasas_release_fusion(struct megasas_instance *instance) in megasas_release_fusion() argument
3988 megasas_free_ioc_init_cmd(instance); in megasas_release_fusion()
3989 megasas_free_cmds(instance); in megasas_release_fusion()
3990 megasas_free_cmds_fusion(instance); in megasas_release_fusion()
3992 iounmap(instance->reg_set); in megasas_release_fusion()
3994 pci_release_selected_regions(instance->pdev, 1<<instance->bar); in megasas_release_fusion()
4002 megasas_read_fw_status_reg_fusion(struct megasas_instance *instance) in megasas_read_fw_status_reg_fusion() argument
4004 return megasas_readl(instance, &instance->reg_set->outbound_scratch_pad_0); in megasas_read_fw_status_reg_fusion()
4013 megasas_alloc_host_crash_buffer(struct megasas_instance *instance) in megasas_alloc_host_crash_buffer() argument
4018 instance->crash_buf[i] = vzalloc(CRASH_DMA_BUF_SIZE); in megasas_alloc_host_crash_buffer()
4019 if (!instance->crash_buf[i]) { in megasas_alloc_host_crash_buffer()
4020 dev_info(&instance->pdev->dev, "Firmware crash dump " in megasas_alloc_host_crash_buffer()
4025 instance->drv_buf_alloc = i; in megasas_alloc_host_crash_buffer()
4033 megasas_free_host_crash_buffer(struct megasas_instance *instance) in megasas_free_host_crash_buffer() argument
4036 for (i = 0; i < instance->drv_buf_alloc; i++) { in megasas_free_host_crash_buffer()
4037 vfree(instance->crash_buf[i]); in megasas_free_host_crash_buffer()
4039 instance->drv_buf_index = 0; in megasas_free_host_crash_buffer()
4040 instance->drv_buf_alloc = 0; in megasas_free_host_crash_buffer()
4041 instance->fw_crash_state = UNAVAILABLE; in megasas_free_host_crash_buffer()
4042 instance->fw_crash_buffer_size = 0; in megasas_free_host_crash_buffer()
4051 megasas_adp_reset_fusion(struct megasas_instance *instance, in megasas_adp_reset_fusion() argument
4057 writel(MPI2_WRSEQ_FLUSH_KEY_VALUE, &instance->reg_set->fusion_seq_offset); in megasas_adp_reset_fusion()
4058 writel(MPI2_WRSEQ_1ST_KEY_VALUE, &instance->reg_set->fusion_seq_offset); in megasas_adp_reset_fusion()
4059 writel(MPI2_WRSEQ_2ND_KEY_VALUE, &instance->reg_set->fusion_seq_offset); in megasas_adp_reset_fusion()
4060 writel(MPI2_WRSEQ_3RD_KEY_VALUE, &instance->reg_set->fusion_seq_offset); in megasas_adp_reset_fusion()
4061 writel(MPI2_WRSEQ_4TH_KEY_VALUE, &instance->reg_set->fusion_seq_offset); in megasas_adp_reset_fusion()
4062 writel(MPI2_WRSEQ_5TH_KEY_VALUE, &instance->reg_set->fusion_seq_offset); in megasas_adp_reset_fusion()
4063 writel(MPI2_WRSEQ_6TH_KEY_VALUE, &instance->reg_set->fusion_seq_offset); in megasas_adp_reset_fusion()
4066 host_diag = megasas_readl(instance, &instance->reg_set->fusion_host_diag); in megasas_adp_reset_fusion()
4070 host_diag = megasas_readl(instance, in megasas_adp_reset_fusion()
4071 &instance->reg_set->fusion_host_diag); in megasas_adp_reset_fusion()
4073 dev_warn(&instance->pdev->dev, in megasas_adp_reset_fusion()
4084 &instance->reg_set->fusion_host_diag); in megasas_adp_reset_fusion()
4088 host_diag = megasas_readl(instance, &instance->reg_set->fusion_host_diag); in megasas_adp_reset_fusion()
4092 host_diag = megasas_readl(instance, in megasas_adp_reset_fusion()
4093 &instance->reg_set->fusion_host_diag); in megasas_adp_reset_fusion()
4095 dev_warn(&instance->pdev->dev, in megasas_adp_reset_fusion()
4104 abs_state = instance->instancet->read_fw_status_reg(instance) in megasas_adp_reset_fusion()
4110 abs_state = instance->instancet-> in megasas_adp_reset_fusion()
4111 read_fw_status_reg(instance) & MFI_STATE_MASK; in megasas_adp_reset_fusion()
4114 dev_warn(&instance->pdev->dev, in megasas_adp_reset_fusion()
4129 megasas_check_reset_fusion(struct megasas_instance *instance, in megasas_check_reset_fusion() argument
4139 static inline void megasas_trigger_snap_dump(struct megasas_instance *instance) in megasas_trigger_snap_dump() argument
4144 if (!instance->disableOnlineCtrlReset) { in megasas_trigger_snap_dump()
4145 dev_info(&instance->pdev->dev, "Trigger snap dump\n"); in megasas_trigger_snap_dump()
4147 &instance->reg_set->doorbell); in megasas_trigger_snap_dump()
4148 readl(&instance->reg_set->doorbell); in megasas_trigger_snap_dump()
4151 for (j = 0; j < instance->snapdump_wait_time; j++) { in megasas_trigger_snap_dump()
4152 abs_state = instance->instancet->read_fw_status_reg(instance); in megasas_trigger_snap_dump()
4155 dev_printk(KERN_ERR, &instance->pdev->dev, in megasas_trigger_snap_dump()
4167 megasas_wait_for_outstanding_fusion(struct megasas_instance *instance, in megasas_wait_for_outstanding_fusion() argument
4176 (resetwaittime - instance->snapdump_wait_time)); in megasas_wait_for_outstanding_fusion()
4179 dev_info(&instance->pdev->dev, in megasas_wait_for_outstanding_fusion()
4181 megasas_complete_cmd_dpc_fusion((unsigned long)instance); in megasas_wait_for_outstanding_fusion()
4182 if (instance->snapdump_wait_time) in megasas_wait_for_outstanding_fusion()
4183 megasas_trigger_snap_dump(instance); in megasas_wait_for_outstanding_fusion()
4190 abs_state = instance->instancet->read_fw_status_reg(instance); in megasas_wait_for_outstanding_fusion()
4193 dev_printk(KERN_ERR, &instance->pdev->dev, in megasas_wait_for_outstanding_fusion()
4197 megasas_complete_cmd_dpc_fusion((unsigned long)instance); in megasas_wait_for_outstanding_fusion()
4198 if (instance->requestorId && reason) { in megasas_wait_for_outstanding_fusion()
4199 dev_warn(&instance->pdev->dev, "SR-IOV Found FW in FAULT" in megasas_wait_for_outstanding_fusion()
4202 instance->host->host_no); in megasas_wait_for_outstanding_fusion()
4212 if (instance->requestorId && !reason) { in megasas_wait_for_outstanding_fusion()
4218 if (instance->requestorId && (reason == SCSIIO_TIMEOUT_OCR)) { in megasas_wait_for_outstanding_fusion()
4219 if (instance->hb_host_mem->HB.fwCounter != in megasas_wait_for_outstanding_fusion()
4220 instance->hb_host_mem->HB.driverCounter) { in megasas_wait_for_outstanding_fusion()
4221 instance->hb_host_mem->HB.driverCounter = in megasas_wait_for_outstanding_fusion()
4222 instance->hb_host_mem->HB.fwCounter; in megasas_wait_for_outstanding_fusion()
4228 dev_warn(&instance->pdev->dev, "SR-IOV:" in megasas_wait_for_outstanding_fusion()
4233 instance->host->host_no); in megasas_wait_for_outstanding_fusion()
4241 megasas_complete_cmd_dpc_fusion((unsigned long)instance); in megasas_wait_for_outstanding_fusion()
4242 outstanding = atomic_read(&instance->fw_outstanding); in megasas_wait_for_outstanding_fusion()
4247 dev_notice(&instance->pdev->dev, "[%2d]waiting for %d " in megasas_wait_for_outstanding_fusion()
4249 outstanding, instance->host->host_no); in megasas_wait_for_outstanding_fusion()
4254 if (instance->snapdump_wait_time) { in megasas_wait_for_outstanding_fusion()
4255 megasas_trigger_snap_dump(instance); in megasas_wait_for_outstanding_fusion()
4260 if (atomic_read(&instance->fw_outstanding)) { in megasas_wait_for_outstanding_fusion()
4261 dev_err(&instance->pdev->dev, "pending commands remain after waiting, " in megasas_wait_for_outstanding_fusion()
4263 instance->host->host_no); in megasas_wait_for_outstanding_fusion()
4272 void megasas_reset_reply_desc(struct megasas_instance *instance) in megasas_reset_reply_desc() argument
4278 fusion = instance->ctrl_context; in megasas_reset_reply_desc()
4279 count = instance->msix_vectors > 0 ? instance->msix_vectors : 1; in megasas_reset_reply_desc()
4280 count += instance->iopoll_q_count; in megasas_reset_reply_desc()
4294 static void megasas_refire_mgmt_cmd(struct megasas_instance *instance, in megasas_refire_mgmt_cmd() argument
4308 fusion = instance->ctrl_context; in megasas_refire_mgmt_cmd()
4313 for (j = instance->max_scsi_cmds ; j < instance->max_fw_cmds; j++) { in megasas_refire_mgmt_cmd()
4315 cmd_mfi = instance->cmd_list[cmd_fusion->sync_cmd_idx]; in megasas_refire_mgmt_cmd()
4322 req_desc = megasas_get_request_descriptor(instance, smid - 1); in megasas_refire_mgmt_cmd()
4343 if (!instance->support_nvme_passthru) { in megasas_refire_mgmt_cmd()
4350 if (!instance->support_pci_lane_margining) { in megasas_refire_mgmt_cmd()
4362 dev_err(&instance->pdev->dev, in megasas_refire_mgmt_cmd()
4377 megasas_fire_cmd_fusion(instance, req_desc); in megasas_refire_mgmt_cmd()
4380 megasas_return_cmd(instance, cmd_mfi); in megasas_refire_mgmt_cmd()
4383 megasas_complete_cmd(instance, cmd_mfi, DID_OK); in megasas_refire_mgmt_cmd()
4395 megasas_return_polled_cmds(struct megasas_instance *instance) in megasas_return_polled_cmds() argument
4402 fusion = instance->ctrl_context; in megasas_return_polled_cmds()
4404 for (i = instance->max_scsi_cmds; i < instance->max_fw_cmds; i++) { in megasas_return_polled_cmds()
4406 cmd_mfi = instance->cmd_list[cmd_fusion->sync_cmd_idx]; in megasas_return_polled_cmds()
4410 dev_info(&instance->pdev->dev, in megasas_return_polled_cmds()
4415 megasas_return_cmd(instance, cmd_mfi); in megasas_return_polled_cmds()
4429 static int megasas_track_scsiio(struct megasas_instance *instance, in megasas_track_scsiio() argument
4435 fusion = instance->ctrl_context; in megasas_track_scsiio()
4437 for (i = 0 ; i < instance->max_scsi_cmds; i++) { in megasas_track_scsiio()
4442 dev_info(&instance->pdev->dev, in megasas_track_scsiio()
4463 megasas_tm_response_code(struct megasas_instance *instance, in megasas_tm_response_code() argument
4497 dev_dbg(&instance->pdev->dev, "response_code(%01x): %s\n", in megasas_tm_response_code()
4499 dev_dbg(&instance->pdev->dev, in megasas_tm_response_code()
4524 megasas_issue_tm(struct megasas_instance *instance, u16 device_handle, in megasas_issue_tm() argument
4540 fusion = instance->ctrl_context; in megasas_issue_tm()
4542 cmd_mfi = megasas_get_cmd(instance); in megasas_issue_tm()
4545 dev_err(&instance->pdev->dev, "Failed from %s %d\n", in megasas_issue_tm()
4550 cmd_fusion = megasas_get_cmd_fusion(instance, in megasas_issue_tm()
4551 instance->max_scsi_cmds + cmd_mfi->index); in megasas_issue_tm()
4556 req_desc = megasas_get_request_descriptor(instance, in megasas_issue_tm()
4587 megasas_fire_cmd_fusion(instance, req_desc); in megasas_issue_tm()
4601 dev_err(&instance->pdev->dev, in megasas_issue_tm()
4603 mutex_unlock(&instance->reset_mutex); in megasas_issue_tm()
4604 rc = megasas_reset_fusion(instance->host, MFI_IO_TIMEOUT_OCR); in megasas_issue_tm()
4605 mutex_lock(&instance->reset_mutex); in megasas_issue_tm()
4610 megasas_tm_response_code(instance, mpi_reply); in megasas_issue_tm()
4612 megasas_return_cmd(instance, cmd_mfi); in megasas_issue_tm()
4621 instance->instancet->disable_intr(instance); in megasas_issue_tm()
4622 megasas_sync_irqs((unsigned long)instance); in megasas_issue_tm()
4623 instance->instancet->enable_intr(instance); in megasas_issue_tm()
4624 megasas_enable_irq_poll(instance); in megasas_issue_tm()
4634 instance->instancet->disable_intr(instance); in megasas_issue_tm()
4635 megasas_sync_irqs((unsigned long)instance); in megasas_issue_tm()
4636 rc = megasas_track_scsiio(instance, id, channel); in megasas_issue_tm()
4637 instance->instancet->enable_intr(instance); in megasas_issue_tm()
4638 megasas_enable_irq_poll(instance); in megasas_issue_tm()
4662 struct megasas_instance *instance; in megasas_fusion_smid_lookup() local
4666 instance = (struct megasas_instance *)scmd->device->host->hostdata; in megasas_fusion_smid_lookup()
4668 fusion = instance->ctrl_context; in megasas_fusion_smid_lookup()
4670 for (i = 0; i < instance->max_scsi_cmds; i++) { in megasas_fusion_smid_lookup()
4693 struct megasas_instance *instance; in megasas_get_tm_devhandle() local
4698 instance = (struct megasas_instance *)sdev->host->hostdata; in megasas_get_tm_devhandle()
4699 fusion = instance->ctrl_context; in megasas_get_tm_devhandle()
4702 if (instance->use_seqnum_jbod_fp) { in megasas_get_tm_devhandle()
4706 [(instance->pd_seq_map_id - 1) & 1]; in megasas_get_tm_devhandle()
4729 struct megasas_instance *instance; in megasas_task_abort_fusion() local
4735 instance = (struct megasas_instance *)scmd->device->host->hostdata; in megasas_task_abort_fusion()
4737 if (atomic_read(&instance->adprecovery) != MEGASAS_HBA_OPERATIONAL) { in megasas_task_abort_fusion()
4738 dev_err(&instance->pdev->dev, "Controller is not OPERATIONAL," in megasas_task_abort_fusion()
4739 "SCSI host:%d\n", instance->host->host_no); in megasas_task_abort_fusion()
4757 mutex_lock(&instance->reset_mutex); in megasas_task_abort_fusion()
4765 mutex_unlock(&instance->reset_mutex); in megasas_task_abort_fusion()
4775 mutex_unlock(&instance->reset_mutex); in megasas_task_abort_fusion()
4783 ret = megasas_issue_tm(instance, devhandle, in megasas_task_abort_fusion()
4789 mutex_unlock(&instance->reset_mutex); in megasas_task_abort_fusion()
4810 struct megasas_instance *instance; in megasas_reset_target_fusion() local
4816 instance = (struct megasas_instance *)scmd->device->host->hostdata; in megasas_reset_target_fusion()
4818 if (atomic_read(&instance->adprecovery) != MEGASAS_HBA_OPERATIONAL) { in megasas_reset_target_fusion()
4819 dev_err(&instance->pdev->dev, "Controller is not OPERATIONAL," in megasas_reset_target_fusion()
4820 "SCSI host:%d\n", instance->host->host_no); in megasas_reset_target_fusion()
4838 mutex_lock(&instance->reset_mutex); in megasas_reset_target_fusion()
4845 mutex_unlock(&instance->reset_mutex); in megasas_reset_target_fusion()
4853 ret = megasas_issue_tm(instance, devhandle, in megasas_reset_target_fusion()
4858 mutex_unlock(&instance->reset_mutex); in megasas_reset_target_fusion()
4868 megasas_instance *megasas_get_peer_instance(struct megasas_instance *instance) in megasas_get_peer_instance() argument
4873 if (megasas_mgmt_info.instance[i] && in megasas_get_peer_instance()
4874 (megasas_mgmt_info.instance[i] != instance) && in megasas_get_peer_instance()
4875 megasas_mgmt_info.instance[i]->requestorId && in megasas_get_peer_instance()
4876 megasas_mgmt_info.instance[i]->peerIsPresent && in megasas_get_peer_instance()
4877 (memcmp((megasas_mgmt_info.instance[i]->clusterId), in megasas_get_peer_instance()
4878 instance->clusterId, MEGASAS_CLUSTER_ID_SIZE) == 0)) in megasas_get_peer_instance()
4879 return megasas_mgmt_info.instance[i]; in megasas_get_peer_instance()
4885 int megasas_check_mpio_paths(struct megasas_instance *instance, in megasas_check_mpio_paths() argument
4891 if (instance->peerIsPresent) { in megasas_check_mpio_paths()
4892 peer_instance = megasas_get_peer_instance(instance); in megasas_check_mpio_paths()
4905 struct megasas_instance *instance; in megasas_reset_fusion() local
4917 instance = (struct megasas_instance *)shost->hostdata; in megasas_reset_fusion()
4918 fusion = instance->ctrl_context; in megasas_reset_fusion()
4920 mutex_lock(&instance->reset_mutex); in megasas_reset_fusion()
4922 if (atomic_read(&instance->adprecovery) == MEGASAS_HW_CRITICAL_ERROR) { in megasas_reset_fusion()
4923 dev_warn(&instance->pdev->dev, "Hardware critical error, " in megasas_reset_fusion()
4925 instance->host->host_no); in megasas_reset_fusion()
4926 mutex_unlock(&instance->reset_mutex); in megasas_reset_fusion()
4929 status_reg = instance->instancet->read_fw_status_reg(instance); in megasas_reset_fusion()
4933 if (abs_state != MFI_STATE_FAULT && instance->crash_dump_buf && in megasas_reset_fusion()
4934 instance->crash_dump_app_support && reason) { in megasas_reset_fusion()
4935 dev_info(&instance->pdev->dev, "IO/DCMD timeout is detected, " in megasas_reset_fusion()
4937 atomic_set(&instance->adprecovery, MEGASAS_ADPRESET_SM_INFAULT); in megasas_reset_fusion()
4938 status_reg = megasas_readl(instance, &instance->reg_set->doorbell); in megasas_reset_fusion()
4940 &instance->reg_set->doorbell); in megasas_reset_fusion()
4941 readl(&instance->reg_set->doorbell); in megasas_reset_fusion()
4942 mutex_unlock(&instance->reset_mutex); in megasas_reset_fusion()
4946 dev_dbg(&instance->pdev->dev, "waiting for [%d] " in megasas_reset_fusion()
4949 } while ((atomic_read(&instance->adprecovery) != MEGASAS_HBA_OPERATIONAL) && in megasas_reset_fusion()
4952 if (atomic_read(&instance->adprecovery) == MEGASAS_HBA_OPERATIONAL) { in megasas_reset_fusion()
4953 dev_info(&instance->pdev->dev, "OCR done for IO " in megasas_reset_fusion()
4957 dev_info(&instance->pdev->dev, "Controller is not " in megasas_reset_fusion()
4966 if (instance->requestorId && !instance->skip_heartbeat_timer_del) in megasas_reset_fusion()
4967 del_timer_sync(&instance->sriov_heartbeat_timer); in megasas_reset_fusion()
4968 set_bit(MEGASAS_FUSION_IN_RESET, &instance->reset_flags); in megasas_reset_fusion()
4969 set_bit(MEGASAS_FUSION_OCR_NOT_POSSIBLE, &instance->reset_flags); in megasas_reset_fusion()
4970 atomic_set(&instance->adprecovery, MEGASAS_ADPRESET_SM_POLLING); in megasas_reset_fusion()
4971 instance->instancet->disable_intr(instance); in megasas_reset_fusion()
4972 megasas_sync_irqs((unsigned long)instance); in megasas_reset_fusion()
4975 if (megasas_wait_for_outstanding_fusion(instance, reason, in megasas_reset_fusion()
4977 atomic_set(&instance->adprecovery, MEGASAS_ADPRESET_SM_INFAULT); in megasas_reset_fusion()
4978 dev_warn(&instance->pdev->dev, "resetting fusion " in megasas_reset_fusion()
4979 "adapter scsi%d.\n", instance->host->host_no); in megasas_reset_fusion()
4984 dev_info(&instance->pdev->dev, "\nPending SCSI commands:\n"); in megasas_reset_fusion()
4987 for (i = 0 ; i < instance->max_scsi_cmds; i++) { in megasas_reset_fusion()
4990 if (instance->adapter_type >= VENTURA_SERIES) { in megasas_reset_fusion()
4991 r1_cmd = fusion->cmd_list[i + instance->max_fw_cmds]; in megasas_reset_fusion()
4992 megasas_return_cmd_fusion(instance, r1_cmd); in megasas_reset_fusion()
5008 megasas_check_mpio_paths(instance, in megasas_reset_fusion()
5010 if (instance->ldio_threshold && in megasas_reset_fusion()
5012 atomic_dec(&instance->ldio_outstanding); in megasas_reset_fusion()
5013 megasas_return_cmd_fusion(instance, cmd_fusion); in megasas_reset_fusion()
5019 dev_info(&instance->pdev->dev, "Outstanding fastpath IOs: %d\n", in megasas_reset_fusion()
5022 atomic_set(&instance->fw_outstanding, 0); in megasas_reset_fusion()
5024 status_reg = instance->instancet->read_fw_status_reg(instance); in megasas_reset_fusion()
5027 if (instance->disableOnlineCtrlReset || in megasas_reset_fusion()
5030 dev_warn(&instance->pdev->dev, "Reset not supported" in megasas_reset_fusion()
5032 instance->host->host_no); in megasas_reset_fusion()
5037 if (instance->requestorId && !reason) { in megasas_reset_fusion()
5049 if (megasas_adp_reset_wait_for_ready(instance, in megasas_reset_fusion()
5054 if (megasas_transition_to_ready(instance, 1)) { in megasas_reset_fusion()
5055 dev_warn(&instance->pdev->dev, in megasas_reset_fusion()
5057 "scsi%d.\n", instance->host->host_no); in megasas_reset_fusion()
5060 megasas_reset_reply_desc(instance); in megasas_reset_fusion()
5061 megasas_fusion_update_can_queue(instance, OCR_CONTEXT); in megasas_reset_fusion()
5063 if (megasas_ioc_init_fusion(instance)) { in megasas_reset_fusion()
5067 if (megasas_get_ctrl_info(instance)) { in megasas_reset_fusion()
5068 dev_info(&instance->pdev->dev, in megasas_reset_fusion()
5074 megasas_refire_mgmt_cmd(instance, in megasas_reset_fusion()
5084 if (!megasas_get_map_info(instance)) { in megasas_reset_fusion()
5085 megasas_sync_map_info(instance); in megasas_reset_fusion()
5091 megasas_return_polled_cmds(instance); in megasas_reset_fusion()
5095 megasas_setup_jbod_map(instance); in megasas_reset_fusion()
5098 if (instance->adapter_type >= VENTURA_SERIES) { in megasas_reset_fusion()
5108 &instance->reset_flags); in megasas_reset_fusion()
5109 instance->instancet->enable_intr(instance); in megasas_reset_fusion()
5110 megasas_enable_irq_poll(instance); in megasas_reset_fusion()
5112 if ((instance->tgt_prop) && in megasas_reset_fusion()
5113 (instance->nvme_page_size)) in megasas_reset_fusion()
5114 ret_target_prop = megasas_get_target_prop(instance, sdev); in megasas_reset_fusion()
5120 status_reg = instance->instancet->read_fw_status_reg in megasas_reset_fusion()
5121 (instance); in megasas_reset_fusion()
5124 dev_info(&instance->pdev->dev, in megasas_reset_fusion()
5126 abs_state, instance->host->host_no); in megasas_reset_fusion()
5129 atomic_set(&instance->adprecovery, MEGASAS_HBA_OPERATIONAL); in megasas_reset_fusion()
5131 dev_info(&instance->pdev->dev, in megasas_reset_fusion()
5133 instance->host->host_no); in megasas_reset_fusion()
5136 if (instance->requestorId) { in megasas_reset_fusion()
5137 if (!megasas_sriov_start_heartbeat(instance, 0)) in megasas_reset_fusion()
5138 megasas_start_timer(instance); in megasas_reset_fusion()
5140 instance->skip_heartbeat_timer_del = 1; in megasas_reset_fusion()
5143 if (instance->crash_dump_drv_support && in megasas_reset_fusion()
5144 instance->crash_dump_app_support) in megasas_reset_fusion()
5145 megasas_set_crash_dump_params(instance, in megasas_reset_fusion()
5148 megasas_set_crash_dump_params(instance, in megasas_reset_fusion()
5151 if (instance->snapdump_wait_time) { in megasas_reset_fusion()
5152 megasas_get_snapdump_properties(instance); in megasas_reset_fusion()
5153 dev_info(&instance->pdev->dev, in megasas_reset_fusion()
5155 instance->snapdump_wait_time); in megasas_reset_fusion()
5161 dev_warn(&instance->pdev->dev, in megasas_reset_fusion()
5163 instance->host->host_no); in megasas_reset_fusion()
5168 dev_warn(&instance->pdev->dev, "Reset failed, killing " in megasas_reset_fusion()
5169 "adapter scsi%d.\n", instance->host->host_no); in megasas_reset_fusion()
5173 if (instance->requestorId) { in megasas_reset_fusion()
5174 megasas_start_timer(instance); in megasas_reset_fusion()
5176 clear_bit(MEGASAS_FUSION_IN_RESET, &instance->reset_flags); in megasas_reset_fusion()
5177 instance->instancet->enable_intr(instance); in megasas_reset_fusion()
5178 megasas_enable_irq_poll(instance); in megasas_reset_fusion()
5179 atomic_set(&instance->adprecovery, MEGASAS_HBA_OPERATIONAL); in megasas_reset_fusion()
5183 megaraid_sas_kill_hba(instance); in megasas_reset_fusion()
5184 megasas_enable_irq_poll(instance); in megasas_reset_fusion()
5185 instance->skip_heartbeat_timer_del = 1; in megasas_reset_fusion()
5188 clear_bit(MEGASAS_FUSION_OCR_NOT_POSSIBLE, &instance->reset_flags); in megasas_reset_fusion()
5189 mutex_unlock(&instance->reset_mutex); in megasas_reset_fusion()
5194 static void megasas_fusion_crash_dump(struct megasas_instance *instance) in megasas_fusion_crash_dump() argument
5201 status_reg = instance->instancet->read_fw_status_reg(instance); in megasas_fusion_crash_dump()
5207 if (instance->drv_buf_index == 0) { in megasas_fusion_crash_dump()
5211 if (instance->drv_buf_alloc) { in megasas_fusion_crash_dump()
5212 dev_info(&instance->pdev->dev, "earlier crash dump is " in megasas_fusion_crash_dump()
5217 &instance->reg_set->outbound_scratch_pad_0); in megasas_fusion_crash_dump()
5218 readl(&instance->reg_set->outbound_scratch_pad_0); in megasas_fusion_crash_dump()
5221 megasas_alloc_host_crash_buffer(instance); in megasas_fusion_crash_dump()
5222 dev_info(&instance->pdev->dev, "Number of host crash buffers " in megasas_fusion_crash_dump()
5223 "allocated: %d\n", instance->drv_buf_alloc); in megasas_fusion_crash_dump()
5236 status_reg = instance->instancet->read_fw_status_reg( in megasas_fusion_crash_dump()
5237 instance); in megasas_fusion_crash_dump()
5242 if (instance->drv_buf_index >= instance->drv_buf_alloc) { in megasas_fusion_crash_dump()
5243 dev_info(&instance->pdev->dev, in megasas_fusion_crash_dump()
5245 instance->drv_buf_alloc); in megasas_fusion_crash_dump()
5250 memcpy(instance->crash_buf[instance->drv_buf_index], in megasas_fusion_crash_dump()
5251 instance->crash_dump_buf, CRASH_DMA_BUF_SIZE); in megasas_fusion_crash_dump()
5252 instance->drv_buf_index++; in megasas_fusion_crash_dump()
5256 writel(status_reg, &instance->reg_set->outbound_scratch_pad_0); in megasas_fusion_crash_dump()
5257 readl(&instance->reg_set->outbound_scratch_pad_0); in megasas_fusion_crash_dump()
5260 status_reg = instance->instancet->read_fw_status_reg(instance); in megasas_fusion_crash_dump()
5264 dev_info(&instance->pdev->dev, "Crash Dump is available,number " in megasas_fusion_crash_dump()
5265 "of copied buffers: %d\n", instance->drv_buf_index); in megasas_fusion_crash_dump()
5266 instance->fw_crash_buffer_size = instance->drv_buf_index; in megasas_fusion_crash_dump()
5267 instance->fw_crash_state = AVAILABLE; in megasas_fusion_crash_dump()
5268 instance->drv_buf_index = 0; in megasas_fusion_crash_dump()
5269 writel(status_reg, &instance->reg_set->outbound_scratch_pad_0); in megasas_fusion_crash_dump()
5270 readl(&instance->reg_set->outbound_scratch_pad_0); in megasas_fusion_crash_dump()
5272 megasas_reset_fusion(instance->host, 0); in megasas_fusion_crash_dump()
5280 struct megasas_instance *instance = in megasas_fusion_ocr_wq() local
5283 megasas_reset_fusion(instance->host, 0); in megasas_fusion_ocr_wq()
5288 megasas_alloc_fusion_context(struct megasas_instance *instance) in megasas_alloc_fusion_context() argument
5292 instance->ctrl_context = kzalloc(sizeof(struct fusion_context), in megasas_alloc_fusion_context()
5294 if (!instance->ctrl_context) { in megasas_alloc_fusion_context()
5295 dev_err(&instance->pdev->dev, "Failed from %s %d\n", in megasas_alloc_fusion_context()
5300 fusion = instance->ctrl_context; in megasas_alloc_fusion_context()
5312 dev_err(&instance->pdev->dev, "Failed from %s %d\n", in megasas_alloc_fusion_context()
5328 dev_err(&instance->pdev->dev, "Failed to allocate load_balance_info, " in megasas_alloc_fusion_context()
5336 megasas_free_fusion_context(struct megasas_instance *instance) in megasas_free_fusion_context() argument
5338 struct fusion_context *fusion = instance->ctrl_context; in megasas_free_fusion_context()