Lines Matching refs:ioc

97 _base_get_ioc_facts(struct MPT2SAS_ADAPTER *ioc, int sleep_flag);
100 _base_diag_reset(struct MPT2SAS_ADAPTER *ioc, int sleep_flag);
110 struct MPT2SAS_ADAPTER *ioc; in _scsih_set_fwfault_debug() local
116 list_for_each_entry(ioc, &mpt2sas_ioc_list, list) in _scsih_set_fwfault_debug()
117 ioc->fwfault_debug = mpt2sas_fwfault_debug; in _scsih_set_fwfault_debug()
133 struct MPT2SAS_ADAPTER *ioc = (struct MPT2SAS_ADAPTER *)arg; in mpt2sas_remove_dead_ioc_func() local
136 if ((ioc == NULL)) in mpt2sas_remove_dead_ioc_func()
139 pdev = ioc->pdev; in mpt2sas_remove_dead_ioc_func()
157 struct MPT2SAS_ADAPTER *ioc = in _base_fault_reset_work() local
164 spin_lock_irqsave(&ioc->ioc_reset_in_progress_lock, flags); in _base_fault_reset_work()
165 if (ioc->shost_recovery || ioc->pci_error_recovery) in _base_fault_reset_work()
167 spin_unlock_irqrestore(&ioc->ioc_reset_in_progress_lock, flags); in _base_fault_reset_work()
169 doorbell = mpt2sas_base_get_iocstate(ioc, 0); in _base_fault_reset_work()
172 ioc->name, __func__); in _base_fault_reset_work()
182 if (ioc->non_operational_loop++ < 5) { in _base_fault_reset_work()
183 spin_lock_irqsave(&ioc->ioc_reset_in_progress_lock, in _base_fault_reset_work()
195 ioc->schedule_dead_ioc_flush_running_cmds(ioc); in _base_fault_reset_work()
200 ioc->remove_host = 1; in _base_fault_reset_work()
202 p = kthread_run(mpt2sas_remove_dead_ioc_func, ioc, in _base_fault_reset_work()
203 "mpt2sas_dead_ioc_%d", ioc->id); in _base_fault_reset_work()
207 ioc->name, __func__); in _base_fault_reset_work()
211 ioc->name, __func__); in _base_fault_reset_work()
217 ioc->non_operational_loop = 0; in _base_fault_reset_work()
220 rc = mpt2sas_base_hard_reset_handler(ioc, CAN_SLEEP, in _base_fault_reset_work()
222 printk(MPT2SAS_WARN_FMT "%s: hard reset: %s\n", ioc->name, in _base_fault_reset_work()
224 doorbell = mpt2sas_base_get_iocstate(ioc, 0); in _base_fault_reset_work()
226 mpt2sas_base_fault_info(ioc, doorbell & in _base_fault_reset_work()
230 spin_lock_irqsave(&ioc->ioc_reset_in_progress_lock, flags); in _base_fault_reset_work()
232 if (ioc->fault_reset_work_q) in _base_fault_reset_work()
233 queue_delayed_work(ioc->fault_reset_work_q, in _base_fault_reset_work()
234 &ioc->fault_reset_work, in _base_fault_reset_work()
236 spin_unlock_irqrestore(&ioc->ioc_reset_in_progress_lock, flags); in _base_fault_reset_work()
247 mpt2sas_base_start_watchdog(struct MPT2SAS_ADAPTER *ioc) in mpt2sas_base_start_watchdog() argument
251 if (ioc->fault_reset_work_q) in mpt2sas_base_start_watchdog()
255 INIT_DELAYED_WORK(&ioc->fault_reset_work, _base_fault_reset_work); in mpt2sas_base_start_watchdog()
256 snprintf(ioc->fault_reset_work_q_name, in mpt2sas_base_start_watchdog()
257 sizeof(ioc->fault_reset_work_q_name), "poll_%d_status", ioc->id); in mpt2sas_base_start_watchdog()
258 ioc->fault_reset_work_q = in mpt2sas_base_start_watchdog()
259 create_singlethread_workqueue(ioc->fault_reset_work_q_name); in mpt2sas_base_start_watchdog()
260 if (!ioc->fault_reset_work_q) { in mpt2sas_base_start_watchdog()
262 ioc->name, __func__, __LINE__); in mpt2sas_base_start_watchdog()
265 spin_lock_irqsave(&ioc->ioc_reset_in_progress_lock, flags); in mpt2sas_base_start_watchdog()
266 if (ioc->fault_reset_work_q) in mpt2sas_base_start_watchdog()
267 queue_delayed_work(ioc->fault_reset_work_q, in mpt2sas_base_start_watchdog()
268 &ioc->fault_reset_work, in mpt2sas_base_start_watchdog()
270 spin_unlock_irqrestore(&ioc->ioc_reset_in_progress_lock, flags); in mpt2sas_base_start_watchdog()
281 mpt2sas_base_stop_watchdog(struct MPT2SAS_ADAPTER *ioc) in mpt2sas_base_stop_watchdog() argument
286 spin_lock_irqsave(&ioc->ioc_reset_in_progress_lock, flags); in mpt2sas_base_stop_watchdog()
287 wq = ioc->fault_reset_work_q; in mpt2sas_base_stop_watchdog()
288 ioc->fault_reset_work_q = NULL; in mpt2sas_base_stop_watchdog()
289 spin_unlock_irqrestore(&ioc->ioc_reset_in_progress_lock, flags); in mpt2sas_base_stop_watchdog()
291 if (!cancel_delayed_work_sync(&ioc->fault_reset_work)) in mpt2sas_base_stop_watchdog()
305 mpt2sas_base_fault_info(struct MPT2SAS_ADAPTER *ioc , u16 fault_code) in mpt2sas_base_fault_info() argument
308 ioc->name, fault_code); in mpt2sas_base_fault_info()
321 mpt2sas_halt_firmware(struct MPT2SAS_ADAPTER *ioc) in mpt2sas_halt_firmware() argument
325 if (!ioc->fwfault_debug) in mpt2sas_halt_firmware()
330 doorbell = readl(&ioc->chip->Doorbell); in mpt2sas_halt_firmware()
332 mpt2sas_base_fault_info(ioc , doorbell); in mpt2sas_halt_firmware()
334 writel(0xC0FFEE00, &ioc->chip->Doorbell); in mpt2sas_halt_firmware()
336 "timeout\n", ioc->name); in mpt2sas_halt_firmware()
352 _base_sas_ioc_info(struct MPT2SAS_ADAPTER *ioc, MPI2DefaultReply_t *mpi_reply, in _base_sas_ioc_info() argument
521 frame_sz = sizeof(Mpi2ConfigRequest_t) + ioc->sge_size; in _base_sas_ioc_info()
545 frame_sz = sizeof(Mpi2SmpPassthroughRequest_t) + ioc->sge_size; in _base_sas_ioc_info()
555 " (%s)\n", ioc->name, desc, ioc_status, request_hdr, func_str); in _base_sas_ioc_info()
568 _base_display_event_data(struct MPT2SAS_ADAPTER *ioc, in _base_display_event_data() argument
574 if (!(ioc->logging_level & MPT_DEBUG_EVENTS)) in _base_display_event_data()
596 if (!ioc->hide_ir_msg) in _base_display_event_data()
603 printk(MPT2SAS_INFO_FMT "Discovery: (%s)", ioc->name, in _base_display_event_data()
628 if (!ioc->hide_ir_msg) in _base_display_event_data()
632 if (!ioc->hide_ir_msg) in _base_display_event_data()
636 if (!ioc->hide_ir_msg) in _base_display_event_data()
640 if (!ioc->hide_ir_msg) in _base_display_event_data()
651 printk(MPT2SAS_INFO_FMT "%s\n", ioc->name, desc); in _base_display_event_data()
663 _base_sas_log_info(struct MPT2SAS_ADAPTER *ioc , u32 log_info) in _base_sas_log_info() argument
686 if (ioc->ignore_loginfos && (log_info == 0x30050000 || log_info == in _base_sas_log_info()
698 if (!ioc->hide_ir_msg) in _base_sas_log_info()
706 "code(0x%02x), sub_code(0x%04x)\n", ioc->name, log_info, in _base_sas_log_info()
721 _base_display_reply_info(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 msix_index, in _base_display_reply_info() argument
727 mpi_reply = mpt2sas_base_get_reply_virt_addr(ioc, reply); in _base_display_reply_info()
730 ioc->name, __FILE__, __LINE__, __func__); in _base_display_reply_info()
736 (ioc->logging_level & MPT_DEBUG_REPLY)) { in _base_display_reply_info()
737 _base_sas_ioc_info(ioc , mpi_reply, in _base_display_reply_info()
738 mpt2sas_base_get_msg_frame(ioc, smid)); in _base_display_reply_info()
742 _base_sas_log_info(ioc, le32_to_cpu(mpi_reply->IOCLogInfo)); in _base_display_reply_info()
756 mpt2sas_base_done(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 msix_index, in mpt2sas_base_done() argument
761 mpi_reply = mpt2sas_base_get_reply_virt_addr(ioc, reply); in mpt2sas_base_done()
765 if (ioc->base_cmds.status == MPT2_CMD_NOT_USED) in mpt2sas_base_done()
768 ioc->base_cmds.status |= MPT2_CMD_COMPLETE; in mpt2sas_base_done()
770 ioc->base_cmds.status |= MPT2_CMD_REPLY_VALID; in mpt2sas_base_done()
771 memcpy(ioc->base_cmds.reply, mpi_reply, mpi_reply->MsgLength*4); in mpt2sas_base_done()
773 ioc->base_cmds.status &= ~MPT2_CMD_PENDING; in mpt2sas_base_done()
775 complete(&ioc->base_cmds.done); in mpt2sas_base_done()
788 _base_async_event(struct MPT2SAS_ADAPTER *ioc, u8 msix_index, u32 reply) in _base_async_event() argument
794 mpi_reply = mpt2sas_base_get_reply_virt_addr(ioc, reply); in _base_async_event()
800 _base_display_event_data(ioc, mpi_reply); in _base_async_event()
804 smid = mpt2sas_base_get_smid(ioc, ioc->base_cb_idx); in _base_async_event()
807 ioc->name, __func__); in _base_async_event()
811 ack_request = mpt2sas_base_get_msg_frame(ioc, smid); in _base_async_event()
818 mpt2sas_base_put_smid_default(ioc, smid); in _base_async_event()
823 mpt2sas_scsih_event_callback(ioc, msix_index, reply); in _base_async_event()
826 mpt2sas_ctl_event_callback(ioc, msix_index, reply); in _base_async_event()
839 _base_get_cb_idx(struct MPT2SAS_ADAPTER *ioc, u16 smid) in _base_get_cb_idx() argument
844 if (smid < ioc->hi_priority_smid) { in _base_get_cb_idx()
846 cb_idx = ioc->scsi_lookup[i].cb_idx; in _base_get_cb_idx()
847 } else if (smid < ioc->internal_smid) { in _base_get_cb_idx()
848 i = smid - ioc->hi_priority_smid; in _base_get_cb_idx()
849 cb_idx = ioc->hpr_lookup[i].cb_idx; in _base_get_cb_idx()
850 } else if (smid <= ioc->hba_queue_depth) { in _base_get_cb_idx()
851 i = smid - ioc->internal_smid; in _base_get_cb_idx()
852 cb_idx = ioc->internal_lookup[i].cb_idx; in _base_get_cb_idx()
867 _base_mask_interrupts(struct MPT2SAS_ADAPTER *ioc) in _base_mask_interrupts() argument
871 ioc->mask_interrupts = 1; in _base_mask_interrupts()
872 him_register = readl(&ioc->chip->HostInterruptMask); in _base_mask_interrupts()
874 writel(him_register, &ioc->chip->HostInterruptMask); in _base_mask_interrupts()
875 readl(&ioc->chip->HostInterruptMask); in _base_mask_interrupts()
887 _base_unmask_interrupts(struct MPT2SAS_ADAPTER *ioc) in _base_unmask_interrupts() argument
891 him_register = readl(&ioc->chip->HostInterruptMask); in _base_unmask_interrupts()
893 writel(him_register, &ioc->chip->HostInterruptMask); in _base_unmask_interrupts()
894 ioc->mask_interrupts = 0; in _base_unmask_interrupts()
924 struct MPT2SAS_ADAPTER *ioc = reply_q->ioc; in _base_interrupt() local
928 if (ioc->mask_interrupts) in _base_interrupt()
954 if (reply > ioc->reply_dma_max_address || in _base_interrupt()
955 reply < ioc->reply_dma_min_address) in _base_interrupt()
964 cb_idx = _base_get_cb_idx(ioc, smid); in _base_interrupt()
967 rc = mpt_callbacks[cb_idx](ioc, smid, in _base_interrupt()
970 _base_display_reply_info(ioc, smid, in _base_interrupt()
973 mpt2sas_base_free_smid(ioc, smid); in _base_interrupt()
977 _base_async_event(ioc, msix_index, reply); in _base_interrupt()
981 ioc->reply_free_host_index = in _base_interrupt()
982 (ioc->reply_free_host_index == in _base_interrupt()
983 (ioc->reply_free_queue_depth - 1)) ? in _base_interrupt()
984 0 : ioc->reply_free_host_index + 1; in _base_interrupt()
985 ioc->reply_free[ioc->reply_free_host_index] = in _base_interrupt()
988 writel(ioc->reply_free_host_index, in _base_interrupt()
989 &ioc->chip->ReplyFreeHostIndex); in _base_interrupt()
997 (ioc->reply_post_queue_depth - 1)) ? 0 : in _base_interrupt()
1018 if (ioc->is_warpdrive) { in _base_interrupt()
1020 ioc->reply_post_host_index[msix_index]); in _base_interrupt()
1025 MPI2_RPHI_MSIX_INDEX_SHIFT), &ioc->chip->ReplyPostHostIndex); in _base_interrupt()
1036 _base_is_controller_msix_enabled(struct MPT2SAS_ADAPTER *ioc) in _base_is_controller_msix_enabled() argument
1038 return (ioc->facts.IOCCapabilities & in _base_is_controller_msix_enabled()
1039 MPI2_IOCFACTS_CAPABILITY_MSI_X_INDEX) && ioc->msix_enable; in _base_is_controller_msix_enabled()
1054 mpt2sas_base_flush_reply_queues(struct MPT2SAS_ADAPTER *ioc) in mpt2sas_base_flush_reply_queues() argument
1061 if (!_base_is_controller_msix_enabled(ioc)) in mpt2sas_base_flush_reply_queues()
1064 list_for_each_entry(reply_q, &ioc->reply_queue_list, list) { in mpt2sas_base_flush_reply_queues()
1065 if (ioc->shost_recovery) in mpt2sas_base_flush_reply_queues()
1131 mpt2sas_base_build_zero_len_sge(struct MPT2SAS_ADAPTER *ioc, void *paddr) in mpt2sas_base_build_zero_len_sge() argument
1137 ioc->base_add_sg_single(paddr, flags_length, -1); in mpt2sas_base_build_zero_len_sge()
1189 _base_config_dma_addressing(struct MPT2SAS_ADAPTER *ioc, struct pci_dev *pdev) in _base_config_dma_addressing() argument
1194 if (ioc->dma_mask) in _base_config_dma_addressing()
1205 ioc->base_add_sg_single = &_base_add_sg_single_64; in _base_config_dma_addressing()
1206 ioc->sge_size = sizeof(Mpi2SGESimple64_t); in _base_config_dma_addressing()
1207 ioc->dma_mask = 64; in _base_config_dma_addressing()
1214 ioc->base_add_sg_single = &_base_add_sg_single_32; in _base_config_dma_addressing()
1215 ioc->sge_size = sizeof(Mpi2SGESimple32_t); in _base_config_dma_addressing()
1216 ioc->dma_mask = 32; in _base_config_dma_addressing()
1224 ioc->name, ioc->dma_mask, convert_to_kb(s.totalram)); in _base_config_dma_addressing()
1230 _base_change_consistent_dma_mask(struct MPT2SAS_ADAPTER *ioc, in _base_change_consistent_dma_mask() argument
1247 _base_check_enable_msix(struct MPT2SAS_ADAPTER *ioc) in _base_check_enable_msix() argument
1255 if (ioc->pdev->device == MPI2_MFGPAGE_DEVID_SAS2008 && in _base_check_enable_msix()
1256 ioc->pdev->revision == 0x01) { in _base_check_enable_msix()
1260 base = pci_find_capability(ioc->pdev, PCI_CAP_ID_MSIX); in _base_check_enable_msix()
1262 dfailprintk(ioc, printk(MPT2SAS_INFO_FMT "msix not " in _base_check_enable_msix()
1263 "supported\n", ioc->name)); in _base_check_enable_msix()
1269 if (ioc->pdev->device == MPI2_MFGPAGE_DEVID_SAS2004 || in _base_check_enable_msix()
1270 ioc->pdev->device == MPI2_MFGPAGE_DEVID_SAS2008 || in _base_check_enable_msix()
1271 ioc->pdev->device == MPI2_MFGPAGE_DEVID_SAS2108_1 || in _base_check_enable_msix()
1272 ioc->pdev->device == MPI2_MFGPAGE_DEVID_SAS2108_2 || in _base_check_enable_msix()
1273 ioc->pdev->device == MPI2_MFGPAGE_DEVID_SAS2108_3 || in _base_check_enable_msix()
1274 ioc->pdev->device == MPI2_MFGPAGE_DEVID_SAS2116_1 || in _base_check_enable_msix()
1275 ioc->pdev->device == MPI2_MFGPAGE_DEVID_SAS2116_2) in _base_check_enable_msix()
1276 ioc->msix_vector_count = 1; in _base_check_enable_msix()
1278 pci_read_config_word(ioc->pdev, base + 2, &message_control); in _base_check_enable_msix()
1279 ioc->msix_vector_count = (message_control & 0x3FF) + 1; in _base_check_enable_msix()
1281 dinitprintk(ioc, printk(MPT2SAS_INFO_FMT "msix is supported, " in _base_check_enable_msix()
1282 "vector_count(%d)\n", ioc->name, ioc->msix_vector_count)); in _base_check_enable_msix()
1294 _base_free_irq(struct MPT2SAS_ADAPTER *ioc) in _base_free_irq() argument
1298 if (list_empty(&ioc->reply_queue_list)) in _base_free_irq()
1301 list_for_each_entry_safe(reply_q, next, &ioc->reply_queue_list, list) { in _base_free_irq()
1320 _base_request_irq(struct MPT2SAS_ADAPTER *ioc, u8 index, u32 vector) in _base_request_irq() argument
1328 ioc->name, (int)sizeof(struct adapter_reply_queue)); in _base_request_irq()
1331 reply_q->ioc = ioc; in _base_request_irq()
1340 if (ioc->msix_enable) in _base_request_irq()
1342 MPT2SAS_DRIVER_NAME, ioc->id, index); in _base_request_irq()
1345 MPT2SAS_DRIVER_NAME, ioc->id); in _base_request_irq()
1356 list_add_tail(&reply_q->list, &ioc->reply_queue_list); in _base_request_irq()
1370 _base_assign_reply_queues(struct MPT2SAS_ADAPTER *ioc) in _base_assign_reply_queues() argument
1375 if (!_base_is_controller_msix_enabled(ioc)) in _base_assign_reply_queues()
1378 memset(ioc->cpu_msix_table, 0, ioc->cpu_msix_table_sz); in _base_assign_reply_queues()
1381 nr_msix = ioc->reply_queue_count = min(ioc->reply_queue_count, in _base_assign_reply_queues()
1382 ioc->facts.MaxMSIxVectors); in _base_assign_reply_queues()
1388 list_for_each_entry(reply_q, &ioc->reply_queue_list, list) { in _base_assign_reply_queues()
1399 ioc->cpu_msix_table[cpu] = index; in _base_assign_reply_queues()
1407 dinitprintk(ioc, pr_info(MPT2SAS_FMT in _base_assign_reply_queues()
1409 ioc->name, reply_q->vector)); in _base_assign_reply_queues()
1420 _base_disable_msix(struct MPT2SAS_ADAPTER *ioc) in _base_disable_msix() argument
1422 if (ioc->msix_enable) { in _base_disable_msix()
1423 pci_disable_msix(ioc->pdev); in _base_disable_msix()
1424 ioc->msix_enable = 0; in _base_disable_msix()
1434 _base_enable_msix(struct MPT2SAS_ADAPTER *ioc) in _base_enable_msix() argument
1447 if (_base_check_enable_msix(ioc) != 0) in _base_enable_msix()
1450 ioc->reply_queue_count = min_t(int, ioc->cpu_count, in _base_enable_msix()
1451 ioc->msix_vector_count); in _base_enable_msix()
1453 if (!ioc->rdpq_array_enable && max_msix_vectors == -1) in _base_enable_msix()
1457 ioc->reply_queue_count = min_t(int, max_msix_vectors, in _base_enable_msix()
1458 ioc->reply_queue_count); in _base_enable_msix()
1459 ioc->msix_vector_count = ioc->reply_queue_count; in _base_enable_msix()
1465 ioc->name, ioc->msix_vector_count, ioc->cpu_count, max_msix_vectors); in _base_enable_msix()
1467 entries = kcalloc(ioc->reply_queue_count, sizeof(struct msix_entry), in _base_enable_msix()
1470 dfailprintk(ioc, printk(MPT2SAS_INFO_FMT "kcalloc " in _base_enable_msix()
1471 "failed @ at %s:%d/%s() !!!\n", ioc->name, __FILE__, in _base_enable_msix()
1476 for (i = 0, a = entries; i < ioc->reply_queue_count; i++, a++) in _base_enable_msix()
1479 r = pci_enable_msix_exact(ioc->pdev, entries, ioc->reply_queue_count); in _base_enable_msix()
1481 dfailprintk(ioc, printk(MPT2SAS_INFO_FMT in _base_enable_msix()
1482 "pci_enable_msix_exact failed (r=%d) !!!\n", ioc->name, r)); in _base_enable_msix()
1487 ioc->msix_enable = 1; in _base_enable_msix()
1488 for (i = 0, a = entries; i < ioc->reply_queue_count; i++, a++) { in _base_enable_msix()
1489 r = _base_request_irq(ioc, i, a->vector); in _base_enable_msix()
1491 _base_free_irq(ioc); in _base_enable_msix()
1492 _base_disable_msix(ioc); in _base_enable_msix()
1504 ioc->reply_queue_count = 1; in _base_enable_msix()
1505 r = _base_request_irq(ioc, 0, ioc->pdev->irq); in _base_enable_msix()
1517 mpt2sas_base_map_resources(struct MPT2SAS_ADAPTER *ioc) in mpt2sas_base_map_resources() argument
1519 struct pci_dev *pdev = ioc->pdev; in mpt2sas_base_map_resources()
1527 dinitprintk(ioc, printk(MPT2SAS_INFO_FMT "%s\n", in mpt2sas_base_map_resources()
1528 ioc->name, __func__)); in mpt2sas_base_map_resources()
1530 ioc->bars = pci_select_bars(pdev, IORESOURCE_MEM); in mpt2sas_base_map_resources()
1533 "failed\n", ioc->name); in mpt2sas_base_map_resources()
1534 ioc->bars = 0; in mpt2sas_base_map_resources()
1539 if (pci_request_selected_regions(pdev, ioc->bars, in mpt2sas_base_map_resources()
1542 "failed\n", ioc->name); in mpt2sas_base_map_resources()
1543 ioc->bars = 0; in mpt2sas_base_map_resources()
1553 if (_base_config_dma_addressing(ioc, pdev) != 0) { in mpt2sas_base_map_resources()
1555 ioc->name, pci_name(pdev)); in mpt2sas_base_map_resources()
1571 ioc->chip_phys = pci_resource_start(pdev, i); in mpt2sas_base_map_resources()
1572 chip_phys = (u64)ioc->chip_phys; in mpt2sas_base_map_resources()
1574 ioc->chip = ioremap(ioc->chip_phys, memap_sz); in mpt2sas_base_map_resources()
1575 if (ioc->chip == NULL) { in mpt2sas_base_map_resources()
1577 "adapter memory!\n", ioc->name); in mpt2sas_base_map_resources()
1585 _base_mask_interrupts(ioc); in mpt2sas_base_map_resources()
1587 r = _base_get_ioc_facts(ioc, CAN_SLEEP); in mpt2sas_base_map_resources()
1591 if (!ioc->rdpq_array_enable_assigned) { in mpt2sas_base_map_resources()
1592 ioc->rdpq_array_enable = ioc->rdpq_array_capable; in mpt2sas_base_map_resources()
1593 ioc->rdpq_array_enable_assigned = 1; in mpt2sas_base_map_resources()
1596 r = _base_enable_msix(ioc); in mpt2sas_base_map_resources()
1600 list_for_each_entry(reply_q, &ioc->reply_queue_list, list) in mpt2sas_base_map_resources()
1602 reply_q->name, ((ioc->msix_enable) ? "PCI-MSI-X enabled" : in mpt2sas_base_map_resources()
1606 ioc->name, (unsigned long long)chip_phys, ioc->chip, memap_sz); in mpt2sas_base_map_resources()
1608 ioc->name, (unsigned long long)pio_chip, pio_sz); in mpt2sas_base_map_resources()
1616 if (ioc->chip_phys) in mpt2sas_base_map_resources()
1617 iounmap(ioc->chip); in mpt2sas_base_map_resources()
1618 ioc->chip_phys = 0; in mpt2sas_base_map_resources()
1619 pci_release_selected_regions(ioc->pdev, ioc->bars); in mpt2sas_base_map_resources()
1633 mpt2sas_base_get_msg_frame(struct MPT2SAS_ADAPTER *ioc, u16 smid) in mpt2sas_base_get_msg_frame() argument
1635 return (void *)(ioc->request + (smid * ioc->request_sz)); in mpt2sas_base_get_msg_frame()
1646 mpt2sas_base_get_sense_buffer(struct MPT2SAS_ADAPTER *ioc, u16 smid) in mpt2sas_base_get_sense_buffer() argument
1648 return (void *)(ioc->sense + ((smid - 1) * SCSI_SENSE_BUFFERSIZE)); in mpt2sas_base_get_sense_buffer()
1659 mpt2sas_base_get_sense_buffer_dma(struct MPT2SAS_ADAPTER *ioc, u16 smid) in mpt2sas_base_get_sense_buffer_dma() argument
1661 return cpu_to_le32(ioc->sense_dma + in mpt2sas_base_get_sense_buffer_dma()
1673 mpt2sas_base_get_reply_virt_addr(struct MPT2SAS_ADAPTER *ioc, u32 phys_addr) in mpt2sas_base_get_reply_virt_addr() argument
1677 return ioc->reply + (phys_addr - (u32)ioc->reply_dma); in mpt2sas_base_get_reply_virt_addr()
1688 mpt2sas_base_get_smid(struct MPT2SAS_ADAPTER *ioc, u8 cb_idx) in mpt2sas_base_get_smid() argument
1694 spin_lock_irqsave(&ioc->scsi_lookup_lock, flags); in mpt2sas_base_get_smid()
1695 if (list_empty(&ioc->internal_free_list)) { in mpt2sas_base_get_smid()
1696 spin_unlock_irqrestore(&ioc->scsi_lookup_lock, flags); in mpt2sas_base_get_smid()
1698 ioc->name, __func__); in mpt2sas_base_get_smid()
1702 request = list_entry(ioc->internal_free_list.next, in mpt2sas_base_get_smid()
1707 spin_unlock_irqrestore(&ioc->scsi_lookup_lock, flags); in mpt2sas_base_get_smid()
1720 mpt2sas_base_get_smid_scsiio(struct MPT2SAS_ADAPTER *ioc, u8 cb_idx, in mpt2sas_base_get_smid_scsiio() argument
1727 spin_lock_irqsave(&ioc->scsi_lookup_lock, flags); in mpt2sas_base_get_smid_scsiio()
1728 if (list_empty(&ioc->free_list)) { in mpt2sas_base_get_smid_scsiio()
1729 spin_unlock_irqrestore(&ioc->scsi_lookup_lock, flags); in mpt2sas_base_get_smid_scsiio()
1731 ioc->name, __func__); in mpt2sas_base_get_smid_scsiio()
1735 request = list_entry(ioc->free_list.next, in mpt2sas_base_get_smid_scsiio()
1741 spin_unlock_irqrestore(&ioc->scsi_lookup_lock, flags); in mpt2sas_base_get_smid_scsiio()
1753 mpt2sas_base_get_smid_hpr(struct MPT2SAS_ADAPTER *ioc, u8 cb_idx) in mpt2sas_base_get_smid_hpr() argument
1759 spin_lock_irqsave(&ioc->scsi_lookup_lock, flags); in mpt2sas_base_get_smid_hpr()
1760 if (list_empty(&ioc->hpr_free_list)) { in mpt2sas_base_get_smid_hpr()
1761 spin_unlock_irqrestore(&ioc->scsi_lookup_lock, flags); in mpt2sas_base_get_smid_hpr()
1765 request = list_entry(ioc->hpr_free_list.next, in mpt2sas_base_get_smid_hpr()
1770 spin_unlock_irqrestore(&ioc->scsi_lookup_lock, flags); in mpt2sas_base_get_smid_hpr()
1783 mpt2sas_base_free_smid(struct MPT2SAS_ADAPTER *ioc, u16 smid) in mpt2sas_base_free_smid() argument
1789 spin_lock_irqsave(&ioc->scsi_lookup_lock, flags); in mpt2sas_base_free_smid()
1790 if (smid < ioc->hi_priority_smid) { in mpt2sas_base_free_smid()
1793 if (!list_empty(&ioc->scsi_lookup[i].chain_list)) { in mpt2sas_base_free_smid()
1795 &ioc->scsi_lookup[i].chain_list, tracker_list) { in mpt2sas_base_free_smid()
1798 &ioc->free_chain_list); in mpt2sas_base_free_smid()
1801 ioc->scsi_lookup[i].cb_idx = 0xFF; in mpt2sas_base_free_smid()
1802 ioc->scsi_lookup[i].scmd = NULL; in mpt2sas_base_free_smid()
1803 ioc->scsi_lookup[i].direct_io = 0; in mpt2sas_base_free_smid()
1804 list_add(&ioc->scsi_lookup[i].tracker_list, in mpt2sas_base_free_smid()
1805 &ioc->free_list); in mpt2sas_base_free_smid()
1806 spin_unlock_irqrestore(&ioc->scsi_lookup_lock, flags); in mpt2sas_base_free_smid()
1812 if (ioc->shost_recovery && ioc->pending_io_count) { in mpt2sas_base_free_smid()
1813 if (ioc->pending_io_count == 1) in mpt2sas_base_free_smid()
1814 wake_up(&ioc->reset_wq); in mpt2sas_base_free_smid()
1815 ioc->pending_io_count--; in mpt2sas_base_free_smid()
1818 } else if (smid < ioc->internal_smid) { in mpt2sas_base_free_smid()
1820 i = smid - ioc->hi_priority_smid; in mpt2sas_base_free_smid()
1821 ioc->hpr_lookup[i].cb_idx = 0xFF; in mpt2sas_base_free_smid()
1822 list_add(&ioc->hpr_lookup[i].tracker_list, in mpt2sas_base_free_smid()
1823 &ioc->hpr_free_list); in mpt2sas_base_free_smid()
1824 } else if (smid <= ioc->hba_queue_depth) { in mpt2sas_base_free_smid()
1826 i = smid - ioc->internal_smid; in mpt2sas_base_free_smid()
1827 ioc->internal_lookup[i].cb_idx = 0xFF; in mpt2sas_base_free_smid()
1828 list_add(&ioc->internal_lookup[i].tracker_list, in mpt2sas_base_free_smid()
1829 &ioc->internal_free_list); in mpt2sas_base_free_smid()
1831 spin_unlock_irqrestore(&ioc->scsi_lookup_lock, flags); in mpt2sas_base_free_smid()
1866 _base_get_msix_index(struct MPT2SAS_ADAPTER *ioc) in _base_get_msix_index() argument
1868 return ioc->cpu_msix_table[raw_smp_processor_id()]; in _base_get_msix_index()
1880 mpt2sas_base_put_smid_scsi_io(struct MPT2SAS_ADAPTER *ioc, u16 smid, u16 handle) in mpt2sas_base_put_smid_scsi_io() argument
1887 descriptor.SCSIIO.MSIxIndex = _base_get_msix_index(ioc); in mpt2sas_base_put_smid_scsi_io()
1891 _base_writeq(*request, &ioc->chip->RequestDescriptorPostLow, in mpt2sas_base_put_smid_scsi_io()
1892 &ioc->scsi_lookup_lock); in mpt2sas_base_put_smid_scsi_io()
1904 mpt2sas_base_put_smid_hi_priority(struct MPT2SAS_ADAPTER *ioc, u16 smid) in mpt2sas_base_put_smid_hi_priority() argument
1915 _base_writeq(*request, &ioc->chip->RequestDescriptorPostLow, in mpt2sas_base_put_smid_hi_priority()
1916 &ioc->scsi_lookup_lock); in mpt2sas_base_put_smid_hi_priority()
1927 mpt2sas_base_put_smid_default(struct MPT2SAS_ADAPTER *ioc, u16 smid) in mpt2sas_base_put_smid_default() argument
1933 descriptor.Default.MSIxIndex = _base_get_msix_index(ioc); in mpt2sas_base_put_smid_default()
1937 _base_writeq(*request, &ioc->chip->RequestDescriptorPostLow, in mpt2sas_base_put_smid_default()
1938 &ioc->scsi_lookup_lock); in mpt2sas_base_put_smid_default()
1950 mpt2sas_base_put_smid_target_assist(struct MPT2SAS_ADAPTER *ioc, u16 smid, in mpt2sas_base_put_smid_target_assist() argument
1958 descriptor.SCSITarget.MSIxIndex = _base_get_msix_index(ioc); in mpt2sas_base_put_smid_target_assist()
1962 _base_writeq(*request, &ioc->chip->RequestDescriptorPostLow, in mpt2sas_base_put_smid_target_assist()
1963 &ioc->scsi_lookup_lock); in mpt2sas_base_put_smid_target_assist()
1973 _base_display_dell_branding(struct MPT2SAS_ADAPTER *ioc) in _base_display_dell_branding() argument
1977 if (ioc->pdev->subsystem_vendor != PCI_VENDOR_ID_DELL) in _base_display_dell_branding()
1981 switch (ioc->pdev->subsystem_device) { in _base_display_dell_branding()
2014 sprintf(dell_branding, "0x%4X", ioc->pdev->subsystem_device); in _base_display_dell_branding()
2019 " SSVID(0x%04X), SSDID(0x%04X)\n", ioc->name, dell_branding, in _base_display_dell_branding()
2020 ioc->pdev->vendor, ioc->pdev->device, ioc->pdev->subsystem_vendor, in _base_display_dell_branding()
2021 ioc->pdev->subsystem_device); in _base_display_dell_branding()
2031 _base_display_intel_branding(struct MPT2SAS_ADAPTER *ioc) in _base_display_intel_branding() argument
2033 if (ioc->pdev->subsystem_vendor != PCI_VENDOR_ID_INTEL) in _base_display_intel_branding()
2036 switch (ioc->pdev->device) { in _base_display_intel_branding()
2038 switch (ioc->pdev->subsystem_device) { in _base_display_intel_branding()
2040 printk(MPT2SAS_INFO_FMT "%s\n", ioc->name, in _base_display_intel_branding()
2044 printk(MPT2SAS_INFO_FMT "%s\n", ioc->name, in _base_display_intel_branding()
2048 printk(MPT2SAS_INFO_FMT "%s\n", ioc->name, in _base_display_intel_branding()
2055 switch (ioc->pdev->subsystem_device) { in _base_display_intel_branding()
2057 printk(MPT2SAS_INFO_FMT "%s\n", ioc->name, in _base_display_intel_branding()
2061 printk(MPT2SAS_INFO_FMT "%s\n", ioc->name, in _base_display_intel_branding()
2065 printk(MPT2SAS_INFO_FMT "%s\n", ioc->name, in _base_display_intel_branding()
2069 printk(MPT2SAS_INFO_FMT "%s\n", ioc->name, in _base_display_intel_branding()
2073 printk(MPT2SAS_INFO_FMT "%s\n", ioc->name, in _base_display_intel_branding()
2077 printk(MPT2SAS_INFO_FMT "%s\n", ioc->name, in _base_display_intel_branding()
2081 printk(MPT2SAS_INFO_FMT "%s\n", ioc->name, in _base_display_intel_branding()
2099 _base_display_hp_branding(struct MPT2SAS_ADAPTER *ioc) in _base_display_hp_branding() argument
2101 if (ioc->pdev->subsystem_vendor != MPT2SAS_HP_3PAR_SSVID) in _base_display_hp_branding()
2104 switch (ioc->pdev->device) { in _base_display_hp_branding()
2106 switch (ioc->pdev->subsystem_device) { in _base_display_hp_branding()
2108 printk(MPT2SAS_INFO_FMT "%s\n", ioc->name, in _base_display_hp_branding()
2115 switch (ioc->pdev->subsystem_device) { in _base_display_hp_branding()
2117 printk(MPT2SAS_INFO_FMT "%s\n", ioc->name, in _base_display_hp_branding()
2121 printk(MPT2SAS_INFO_FMT "%s\n", ioc->name, in _base_display_hp_branding()
2125 printk(MPT2SAS_INFO_FMT "%s\n", ioc->name, in _base_display_hp_branding()
2129 printk(MPT2SAS_INFO_FMT "%s\n", ioc->name, in _base_display_hp_branding()
2147 _base_display_ioc_capabilities(struct MPT2SAS_ADAPTER *ioc) in _base_display_ioc_capabilities() argument
2154 bios_version = le32_to_cpu(ioc->bios_pg3.BiosVersion); in _base_display_ioc_capabilities()
2155 strncpy(desc, ioc->manu_pg0.ChipName, 16); in _base_display_ioc_capabilities()
2158 ioc->name, desc, in _base_display_ioc_capabilities()
2159 (ioc->facts.FWVersion.Word & 0xFF000000) >> 24, in _base_display_ioc_capabilities()
2160 (ioc->facts.FWVersion.Word & 0x00FF0000) >> 16, in _base_display_ioc_capabilities()
2161 (ioc->facts.FWVersion.Word & 0x0000FF00) >> 8, in _base_display_ioc_capabilities()
2162 ioc->facts.FWVersion.Word & 0x000000FF, in _base_display_ioc_capabilities()
2163 ioc->pdev->revision, in _base_display_ioc_capabilities()
2169 _base_display_dell_branding(ioc); in _base_display_ioc_capabilities()
2170 _base_display_intel_branding(ioc); in _base_display_ioc_capabilities()
2171 _base_display_hp_branding(ioc); in _base_display_ioc_capabilities()
2173 printk(MPT2SAS_INFO_FMT "Protocol=(", ioc->name); in _base_display_ioc_capabilities()
2175 if (ioc->facts.ProtocolFlags & MPI2_IOCFACTS_PROTOCOL_SCSI_INITIATOR) { in _base_display_ioc_capabilities()
2180 if (ioc->facts.ProtocolFlags & MPI2_IOCFACTS_PROTOCOL_SCSI_TARGET) { in _base_display_ioc_capabilities()
2189 if (!ioc->hide_ir_msg) { in _base_display_ioc_capabilities()
2190 if (ioc->facts.IOCCapabilities & in _base_display_ioc_capabilities()
2197 if (ioc->facts.IOCCapabilities & MPI2_IOCFACTS_CAPABILITY_TLR) { in _base_display_ioc_capabilities()
2202 if (ioc->facts.IOCCapabilities & MPI2_IOCFACTS_CAPABILITY_MULTICAST) { in _base_display_ioc_capabilities()
2207 if (ioc->facts.IOCCapabilities & in _base_display_ioc_capabilities()
2213 if (ioc->facts.IOCCapabilities & MPI2_IOCFACTS_CAPABILITY_EEDP) { in _base_display_ioc_capabilities()
2218 if (ioc->facts.IOCCapabilities & in _base_display_ioc_capabilities()
2224 if (ioc->facts.IOCCapabilities & in _base_display_ioc_capabilities()
2230 if (ioc->facts.IOCCapabilities & in _base_display_ioc_capabilities()
2236 if (ioc->facts.IOCCapabilities & in _base_display_ioc_capabilities()
2242 iounit_pg1_flags = le32_to_cpu(ioc->iounit_pg1.Flags); in _base_display_ioc_capabilities()
2264 mpt2sas_base_update_missing_delay(struct MPT2SAS_ADAPTER *ioc, in mpt2sas_base_update_missing_delay() argument
2275 mpt2sas_config_get_number_hba_phys(ioc, &num_phys); in mpt2sas_base_update_missing_delay()
2284 ioc->name, __FILE__, __LINE__, __func__); in mpt2sas_base_update_missing_delay()
2287 if ((mpt2sas_config_get_sas_iounit_pg1(ioc, &mpi_reply, in mpt2sas_base_update_missing_delay()
2290 ioc->name, __FILE__, __LINE__, __func__); in mpt2sas_base_update_missing_delay()
2297 ioc->name, __FILE__, __LINE__, __func__); in mpt2sas_base_update_missing_delay()
2321 if (!mpt2sas_config_set_sas_iounit_pg1(ioc, &mpi_reply, sas_iounit_pg1, in mpt2sas_base_update_missing_delay()
2330 "new(%d)\n", ioc->name, dmd_orignal, dmd_new); in mpt2sas_base_update_missing_delay()
2332 "new(%d)\n", ioc->name, io_missing_delay_original, in mpt2sas_base_update_missing_delay()
2334 ioc->device_missing_delay = dmd_new; in mpt2sas_base_update_missing_delay()
2335 ioc->io_missing_delay = io_missing_delay; in mpt2sas_base_update_missing_delay()
2349 _base_static_config_pages(struct MPT2SAS_ADAPTER *ioc) in _base_static_config_pages() argument
2354 mpt2sas_config_get_manufacturing_pg0(ioc, &mpi_reply, &ioc->manu_pg0); in _base_static_config_pages()
2355 if (ioc->ir_firmware) in _base_static_config_pages()
2356 mpt2sas_config_get_manufacturing_pg10(ioc, &mpi_reply, in _base_static_config_pages()
2357 &ioc->manu_pg10); in _base_static_config_pages()
2358 mpt2sas_config_get_bios_pg2(ioc, &mpi_reply, &ioc->bios_pg2); in _base_static_config_pages()
2359 mpt2sas_config_get_bios_pg3(ioc, &mpi_reply, &ioc->bios_pg3); in _base_static_config_pages()
2360 mpt2sas_config_get_ioc_pg8(ioc, &mpi_reply, &ioc->ioc_pg8); in _base_static_config_pages()
2361 mpt2sas_config_get_iounit_pg0(ioc, &mpi_reply, &ioc->iounit_pg0); in _base_static_config_pages()
2362 mpt2sas_config_get_iounit_pg1(ioc, &mpi_reply, &ioc->iounit_pg1); in _base_static_config_pages()
2363 mpt2sas_config_get_iounit_pg8(ioc, &mpi_reply, &ioc->iounit_pg8); in _base_static_config_pages()
2364 _base_display_ioc_capabilities(ioc); in _base_static_config_pages()
2370 iounit_pg1_flags = le32_to_cpu(ioc->iounit_pg1.Flags); in _base_static_config_pages()
2371 if ((ioc->facts.IOCCapabilities & in _base_static_config_pages()
2378 ioc->iounit_pg1.Flags = cpu_to_le32(iounit_pg1_flags); in _base_static_config_pages()
2379 mpt2sas_config_set_iounit_pg1(ioc, &mpi_reply, &ioc->iounit_pg1); in _base_static_config_pages()
2381 if (ioc->iounit_pg8.NumSensors) in _base_static_config_pages()
2382 ioc->temp_sensors_count = ioc->iounit_pg8.NumSensors; in _base_static_config_pages()
2394 _base_release_memory_pools(struct MPT2SAS_ADAPTER *ioc) in _base_release_memory_pools() argument
2399 dexitprintk(ioc, printk(MPT2SAS_INFO_FMT "%s\n", ioc->name, in _base_release_memory_pools()
2402 if (ioc->request) { in _base_release_memory_pools()
2403 pci_free_consistent(ioc->pdev, ioc->request_dma_sz, in _base_release_memory_pools()
2404 ioc->request, ioc->request_dma); in _base_release_memory_pools()
2405 dexitprintk(ioc, printk(MPT2SAS_INFO_FMT "request_pool(0x%p)" in _base_release_memory_pools()
2406 ": free\n", ioc->name, ioc->request)); in _base_release_memory_pools()
2407 ioc->request = NULL; in _base_release_memory_pools()
2410 if (ioc->sense) { in _base_release_memory_pools()
2411 pci_pool_free(ioc->sense_dma_pool, ioc->sense, ioc->sense_dma); in _base_release_memory_pools()
2412 if (ioc->sense_dma_pool) in _base_release_memory_pools()
2413 pci_pool_destroy(ioc->sense_dma_pool); in _base_release_memory_pools()
2414 dexitprintk(ioc, printk(MPT2SAS_INFO_FMT "sense_pool(0x%p)" in _base_release_memory_pools()
2415 ": free\n", ioc->name, ioc->sense)); in _base_release_memory_pools()
2416 ioc->sense = NULL; in _base_release_memory_pools()
2419 if (ioc->reply) { in _base_release_memory_pools()
2420 pci_pool_free(ioc->reply_dma_pool, ioc->reply, ioc->reply_dma); in _base_release_memory_pools()
2421 if (ioc->reply_dma_pool) in _base_release_memory_pools()
2422 pci_pool_destroy(ioc->reply_dma_pool); in _base_release_memory_pools()
2423 dexitprintk(ioc, printk(MPT2SAS_INFO_FMT "reply_pool(0x%p)" in _base_release_memory_pools()
2424 ": free\n", ioc->name, ioc->reply)); in _base_release_memory_pools()
2425 ioc->reply = NULL; in _base_release_memory_pools()
2428 if (ioc->reply_free) { in _base_release_memory_pools()
2429 pci_pool_free(ioc->reply_free_dma_pool, ioc->reply_free, in _base_release_memory_pools()
2430 ioc->reply_free_dma); in _base_release_memory_pools()
2431 if (ioc->reply_free_dma_pool) in _base_release_memory_pools()
2432 pci_pool_destroy(ioc->reply_free_dma_pool); in _base_release_memory_pools()
2433 dexitprintk(ioc, printk(MPT2SAS_INFO_FMT "reply_free_pool" in _base_release_memory_pools()
2434 "(0x%p): free\n", ioc->name, ioc->reply_free)); in _base_release_memory_pools()
2435 ioc->reply_free = NULL; in _base_release_memory_pools()
2438 if (ioc->reply_post) { in _base_release_memory_pools()
2440 rps = &ioc->reply_post[i]; in _base_release_memory_pools()
2443 ioc->reply_post_free_dma_pool, in _base_release_memory_pools()
2446 dexitprintk(ioc, printk(MPT2SAS_INFO_FMT in _base_release_memory_pools()
2448 ioc->name, rps->reply_post_free)); in _base_release_memory_pools()
2451 } while (ioc->rdpq_array_enable && in _base_release_memory_pools()
2452 (++i < ioc->reply_queue_count)); in _base_release_memory_pools()
2454 if (ioc->reply_post_free_dma_pool) in _base_release_memory_pools()
2455 pci_pool_destroy(ioc->reply_post_free_dma_pool); in _base_release_memory_pools()
2456 kfree(ioc->reply_post); in _base_release_memory_pools()
2459 if (ioc->config_page) { in _base_release_memory_pools()
2460 dexitprintk(ioc, printk(MPT2SAS_INFO_FMT in _base_release_memory_pools()
2461 "config_page(0x%p): free\n", ioc->name, in _base_release_memory_pools()
2462 ioc->config_page)); in _base_release_memory_pools()
2463 pci_free_consistent(ioc->pdev, ioc->config_page_sz, in _base_release_memory_pools()
2464 ioc->config_page, ioc->config_page_dma); in _base_release_memory_pools()
2467 if (ioc->scsi_lookup) { in _base_release_memory_pools()
2468 free_pages((ulong)ioc->scsi_lookup, ioc->scsi_lookup_pages); in _base_release_memory_pools()
2469 ioc->scsi_lookup = NULL; in _base_release_memory_pools()
2471 kfree(ioc->hpr_lookup); in _base_release_memory_pools()
2472 kfree(ioc->internal_lookup); in _base_release_memory_pools()
2473 if (ioc->chain_lookup) { in _base_release_memory_pools()
2474 for (i = 0; i < ioc->chain_depth; i++) { in _base_release_memory_pools()
2475 if (ioc->chain_lookup[i].chain_buffer) in _base_release_memory_pools()
2476 pci_pool_free(ioc->chain_dma_pool, in _base_release_memory_pools()
2477 ioc->chain_lookup[i].chain_buffer, in _base_release_memory_pools()
2478 ioc->chain_lookup[i].chain_buffer_dma); in _base_release_memory_pools()
2480 if (ioc->chain_dma_pool) in _base_release_memory_pools()
2481 pci_pool_destroy(ioc->chain_dma_pool); in _base_release_memory_pools()
2482 free_pages((ulong)ioc->chain_lookup, ioc->chain_pages); in _base_release_memory_pools()
2483 ioc->chain_lookup = NULL; in _base_release_memory_pools()
2496 _base_allocate_memory_pools(struct MPT2SAS_ADAPTER *ioc, int sleep_flag) in _base_allocate_memory_pools() argument
2506 dinitprintk(ioc, printk(MPT2SAS_INFO_FMT "%s\n", ioc->name, in _base_allocate_memory_pools()
2510 facts = &ioc->facts; in _base_allocate_memory_pools()
2514 ioc->shost->sg_tablesize = min_t(unsigned short, in _base_allocate_memory_pools()
2516 if (ioc->shost->sg_tablesize > MPT2SAS_SG_DEPTH) in _base_allocate_memory_pools()
2519 " SCSI_MAX_SG_SEGMENTS(%u)\n", ioc->name, in _base_allocate_memory_pools()
2520 ioc->shost->sg_tablesize, MPT2SAS_SG_DEPTH); in _base_allocate_memory_pools()
2522 ioc->shost->sg_tablesize = MPT2SAS_SG_DEPTH; in _base_allocate_memory_pools()
2528 ioc->hi_priority_depth + ioc->internal_depth, in _base_allocate_memory_pools()
2536 ioc->hba_queue_depth = max_request_credit; in _base_allocate_memory_pools()
2537 ioc->hi_priority_depth = facts->HighPriorityCredit; in _base_allocate_memory_pools()
2538 ioc->internal_depth = ioc->hi_priority_depth + 5; in _base_allocate_memory_pools()
2541 ioc->request_sz = facts->IOCRequestFrameSize * 4; in _base_allocate_memory_pools()
2544 ioc->reply_sz = facts->ReplyFrameSize * 4; in _base_allocate_memory_pools()
2549 max_sge_elements = ioc->request_sz - ((sizeof(Mpi2SCSIIORequest_t) - in _base_allocate_memory_pools()
2550 sizeof(Mpi2SGEIOUnion_t)) + ioc->sge_size); in _base_allocate_memory_pools()
2551 ioc->max_sges_in_main_message = max_sge_elements/ioc->sge_size; in _base_allocate_memory_pools()
2554 max_sge_elements = ioc->request_sz - ioc->sge_size; in _base_allocate_memory_pools()
2555 ioc->max_sges_in_chain_message = max_sge_elements/ioc->sge_size; in _base_allocate_memory_pools()
2557 ioc->chain_offset_value_for_main_message = in _base_allocate_memory_pools()
2559 (ioc->max_sges_in_chain_message * ioc->sge_size)) / 4; in _base_allocate_memory_pools()
2564 chains_needed_per_io = ((ioc->shost->sg_tablesize - in _base_allocate_memory_pools()
2565 ioc->max_sges_in_main_message)/ioc->max_sges_in_chain_message) in _base_allocate_memory_pools()
2569 ioc->shost->sg_tablesize = min_t(u16, in _base_allocate_memory_pools()
2570 ioc->max_sges_in_main_message + (ioc->max_sges_in_chain_message in _base_allocate_memory_pools()
2571 * chains_needed_per_io), ioc->shost->sg_tablesize); in _base_allocate_memory_pools()
2573 ioc->chains_needed_per_io = chains_needed_per_io; in _base_allocate_memory_pools()
2576 ioc->reply_free_queue_depth = ioc->hba_queue_depth + 64; in _base_allocate_memory_pools()
2579 ioc->reply_post_queue_depth = ioc->hba_queue_depth + in _base_allocate_memory_pools()
2580 ioc->reply_free_queue_depth + 1; in _base_allocate_memory_pools()
2582 if (ioc->reply_post_queue_depth % 16) in _base_allocate_memory_pools()
2583 ioc->reply_post_queue_depth += 16 - in _base_allocate_memory_pools()
2584 (ioc->reply_post_queue_depth % 16); in _base_allocate_memory_pools()
2587 if (ioc->reply_post_queue_depth > in _base_allocate_memory_pools()
2589 ioc->reply_post_queue_depth = in _base_allocate_memory_pools()
2592 ioc->hba_queue_depth = in _base_allocate_memory_pools()
2593 ((ioc->reply_post_queue_depth - 64) / 2) - 1; in _base_allocate_memory_pools()
2594 ioc->reply_free_queue_depth = ioc->hba_queue_depth + 64; in _base_allocate_memory_pools()
2597 dinitprintk(ioc, printk(MPT2SAS_INFO_FMT "scatter gather: " in _base_allocate_memory_pools()
2599 "chains_per_io(%d)\n", ioc->name, ioc->max_sges_in_main_message, in _base_allocate_memory_pools()
2600 ioc->max_sges_in_chain_message, ioc->shost->sg_tablesize, in _base_allocate_memory_pools()
2601 ioc->chains_needed_per_io)); in _base_allocate_memory_pools()
2604 reply_post_free_sz = ioc->reply_post_queue_depth * in _base_allocate_memory_pools()
2608 if (_base_is_controller_msix_enabled(ioc) && !ioc->rdpq_array_enable) in _base_allocate_memory_pools()
2609 sz *= ioc->reply_queue_count; in _base_allocate_memory_pools()
2611 ioc->reply_post = kcalloc((ioc->rdpq_array_enable) ? in _base_allocate_memory_pools()
2612 (ioc->reply_queue_count):1, in _base_allocate_memory_pools()
2615 if (!ioc->reply_post) { in _base_allocate_memory_pools()
2617 ioc->name); in _base_allocate_memory_pools()
2620 ioc->reply_post_free_dma_pool = pci_pool_create("reply_post_free pool", in _base_allocate_memory_pools()
2621 ioc->pdev, sz, 16, 0); in _base_allocate_memory_pools()
2622 if (!ioc->reply_post_free_dma_pool) { in _base_allocate_memory_pools()
2625 ioc->name); in _base_allocate_memory_pools()
2630 ioc->reply_post[i].reply_post_free = in _base_allocate_memory_pools()
2631 pci_pool_alloc(ioc->reply_post_free_dma_pool, in _base_allocate_memory_pools()
2633 &ioc->reply_post[i].reply_post_free_dma); in _base_allocate_memory_pools()
2634 if (!ioc->reply_post[i].reply_post_free) { in _base_allocate_memory_pools()
2637 ioc->name); in _base_allocate_memory_pools()
2640 memset(ioc->reply_post[i].reply_post_free, 0, sz); in _base_allocate_memory_pools()
2641 dinitprintk(ioc, printk(MPT2SAS_INFO_FMT in _base_allocate_memory_pools()
2643 "element_size(%d), pool_size(%d kB)\n", ioc->name, in _base_allocate_memory_pools()
2644 ioc->reply_post[i].reply_post_free, in _base_allocate_memory_pools()
2645 ioc->reply_post_queue_depth, 8, sz/1024)); in _base_allocate_memory_pools()
2646 dinitprintk(ioc, printk(MPT2SAS_INFO_FMT in _base_allocate_memory_pools()
2647 "reply_post_free_dma = (0x%llx)\n", ioc->name, in _base_allocate_memory_pools()
2649 ioc->reply_post[i].reply_post_free_dma)); in _base_allocate_memory_pools()
2651 } while (ioc->rdpq_array_enable && (++i < ioc->reply_queue_count)); in _base_allocate_memory_pools()
2653 if (ioc->dma_mask == 64) { in _base_allocate_memory_pools()
2654 if (_base_change_consistent_dma_mask(ioc, ioc->pdev) != 0) { in _base_allocate_memory_pools()
2657 ioc->name, pci_name(ioc->pdev)); in _base_allocate_memory_pools()
2662 ioc->scsiio_depth = ioc->hba_queue_depth - in _base_allocate_memory_pools()
2663 ioc->hi_priority_depth - ioc->internal_depth; in _base_allocate_memory_pools()
2668 ioc->shost->can_queue = ioc->scsiio_depth; in _base_allocate_memory_pools()
2669 dinitprintk(ioc, printk(MPT2SAS_INFO_FMT "scsi host: " in _base_allocate_memory_pools()
2670 "can_queue depth (%d)\n", ioc->name, ioc->shost->can_queue)); in _base_allocate_memory_pools()
2675 ioc->chain_depth = ioc->chains_needed_per_io * ioc->scsiio_depth; in _base_allocate_memory_pools()
2676 sz = ((ioc->scsiio_depth + 1) * ioc->request_sz); in _base_allocate_memory_pools()
2679 sz += (ioc->hi_priority_depth * ioc->request_sz); in _base_allocate_memory_pools()
2682 sz += (ioc->internal_depth * ioc->request_sz); in _base_allocate_memory_pools()
2684 ioc->request_dma_sz = sz; in _base_allocate_memory_pools()
2685 ioc->request = pci_alloc_consistent(ioc->pdev, sz, &ioc->request_dma); in _base_allocate_memory_pools()
2686 if (!ioc->request) { in _base_allocate_memory_pools()
2689 "total(%d kB)\n", ioc->name, ioc->hba_queue_depth, in _base_allocate_memory_pools()
2690 ioc->chains_needed_per_io, ioc->request_sz, sz/1024); in _base_allocate_memory_pools()
2691 if (ioc->scsiio_depth < MPT2SAS_SAS_QUEUE_DEPTH) in _base_allocate_memory_pools()
2694 ioc->hba_queue_depth = max_request_credit - retry_sz; in _base_allocate_memory_pools()
2701 "total(%d kb)\n", ioc->name, ioc->hba_queue_depth, in _base_allocate_memory_pools()
2702 ioc->chains_needed_per_io, ioc->request_sz, sz/1024); in _base_allocate_memory_pools()
2706 ioc->hi_priority = ioc->request + ((ioc->scsiio_depth + 1) * in _base_allocate_memory_pools()
2707 ioc->request_sz); in _base_allocate_memory_pools()
2708 ioc->hi_priority_dma = ioc->request_dma + ((ioc->scsiio_depth + 1) * in _base_allocate_memory_pools()
2709 ioc->request_sz); in _base_allocate_memory_pools()
2712 ioc->internal = ioc->hi_priority + (ioc->hi_priority_depth * in _base_allocate_memory_pools()
2713 ioc->request_sz); in _base_allocate_memory_pools()
2714 ioc->internal_dma = ioc->hi_priority_dma + (ioc->hi_priority_depth * in _base_allocate_memory_pools()
2715 ioc->request_sz); in _base_allocate_memory_pools()
2718 dinitprintk(ioc, printk(MPT2SAS_INFO_FMT "request pool(0x%p): " in _base_allocate_memory_pools()
2719 "depth(%d), frame_size(%d), pool_size(%d kB)\n", ioc->name, in _base_allocate_memory_pools()
2720 ioc->request, ioc->hba_queue_depth, ioc->request_sz, in _base_allocate_memory_pools()
2721 (ioc->hba_queue_depth * ioc->request_sz)/1024)); in _base_allocate_memory_pools()
2722 dinitprintk(ioc, printk(MPT2SAS_INFO_FMT "request pool: dma(0x%llx)\n", in _base_allocate_memory_pools()
2723 ioc->name, (unsigned long long) ioc->request_dma)); in _base_allocate_memory_pools()
2726 sz = ioc->scsiio_depth * sizeof(struct scsiio_tracker); in _base_allocate_memory_pools()
2727 ioc->scsi_lookup_pages = get_order(sz); in _base_allocate_memory_pools()
2728 ioc->scsi_lookup = (struct scsiio_tracker *)__get_free_pages( in _base_allocate_memory_pools()
2729 GFP_KERNEL, ioc->scsi_lookup_pages); in _base_allocate_memory_pools()
2730 if (!ioc->scsi_lookup) { in _base_allocate_memory_pools()
2732 "sz(%d)\n", ioc->name, (int)sz); in _base_allocate_memory_pools()
2736 dinitprintk(ioc, printk(MPT2SAS_INFO_FMT "scsiio(0x%p): " in _base_allocate_memory_pools()
2737 "depth(%d)\n", ioc->name, ioc->request, in _base_allocate_memory_pools()
2738 ioc->scsiio_depth)); in _base_allocate_memory_pools()
2740 ioc->chain_depth = min_t(u32, ioc->chain_depth, MAX_CHAIN_DEPTH); in _base_allocate_memory_pools()
2741 sz = ioc->chain_depth * sizeof(struct chain_tracker); in _base_allocate_memory_pools()
2742 ioc->chain_pages = get_order(sz); in _base_allocate_memory_pools()
2744 ioc->chain_lookup = (struct chain_tracker *)__get_free_pages( in _base_allocate_memory_pools()
2745 GFP_KERNEL, ioc->chain_pages); in _base_allocate_memory_pools()
2746 if (!ioc->chain_lookup) { in _base_allocate_memory_pools()
2748 "sz(%d)\n", ioc->name, (int)sz); in _base_allocate_memory_pools()
2751 ioc->chain_dma_pool = pci_pool_create("chain pool", ioc->pdev, in _base_allocate_memory_pools()
2752 ioc->request_sz, 16, 0); in _base_allocate_memory_pools()
2753 if (!ioc->chain_dma_pool) { in _base_allocate_memory_pools()
2755 "failed\n", ioc->name); in _base_allocate_memory_pools()
2758 for (i = 0; i < ioc->chain_depth; i++) { in _base_allocate_memory_pools()
2759 ioc->chain_lookup[i].chain_buffer = pci_pool_alloc( in _base_allocate_memory_pools()
2760 ioc->chain_dma_pool , GFP_KERNEL, in _base_allocate_memory_pools()
2761 &ioc->chain_lookup[i].chain_buffer_dma); in _base_allocate_memory_pools()
2762 if (!ioc->chain_lookup[i].chain_buffer) { in _base_allocate_memory_pools()
2763 ioc->chain_depth = i; in _base_allocate_memory_pools()
2766 total_sz += ioc->request_sz; in _base_allocate_memory_pools()
2769 dinitprintk(ioc, printk(MPT2SAS_INFO_FMT "chain pool depth" in _base_allocate_memory_pools()
2770 "(%d), frame_size(%d), pool_size(%d kB)\n", ioc->name, in _base_allocate_memory_pools()
2771 ioc->chain_depth, ioc->request_sz, ((ioc->chain_depth * in _base_allocate_memory_pools()
2772 ioc->request_sz))/1024)); in _base_allocate_memory_pools()
2775 ioc->hpr_lookup = kcalloc(ioc->hi_priority_depth, in _base_allocate_memory_pools()
2777 if (!ioc->hpr_lookup) { in _base_allocate_memory_pools()
2779 ioc->name); in _base_allocate_memory_pools()
2782 ioc->hi_priority_smid = ioc->scsiio_depth + 1; in _base_allocate_memory_pools()
2783 dinitprintk(ioc, printk(MPT2SAS_INFO_FMT "hi_priority(0x%p): " in _base_allocate_memory_pools()
2784 "depth(%d), start smid(%d)\n", ioc->name, ioc->hi_priority, in _base_allocate_memory_pools()
2785 ioc->hi_priority_depth, ioc->hi_priority_smid)); in _base_allocate_memory_pools()
2788 ioc->internal_lookup = kcalloc(ioc->internal_depth, in _base_allocate_memory_pools()
2790 if (!ioc->internal_lookup) { in _base_allocate_memory_pools()
2792 ioc->name); in _base_allocate_memory_pools()
2795 ioc->internal_smid = ioc->hi_priority_smid + ioc->hi_priority_depth; in _base_allocate_memory_pools()
2796 dinitprintk(ioc, printk(MPT2SAS_INFO_FMT "internal(0x%p): " in _base_allocate_memory_pools()
2797 "depth(%d), start smid(%d)\n", ioc->name, ioc->internal, in _base_allocate_memory_pools()
2798 ioc->internal_depth, ioc->internal_smid)); in _base_allocate_memory_pools()
2801 sz = ioc->scsiio_depth * SCSI_SENSE_BUFFERSIZE; in _base_allocate_memory_pools()
2802 ioc->sense_dma_pool = pci_pool_create("sense pool", ioc->pdev, sz, 4, in _base_allocate_memory_pools()
2804 if (!ioc->sense_dma_pool) { in _base_allocate_memory_pools()
2806 ioc->name); in _base_allocate_memory_pools()
2809 ioc->sense = pci_pool_alloc(ioc->sense_dma_pool , GFP_KERNEL, in _base_allocate_memory_pools()
2810 &ioc->sense_dma); in _base_allocate_memory_pools()
2811 if (!ioc->sense) { in _base_allocate_memory_pools()
2813 ioc->name); in _base_allocate_memory_pools()
2816 dinitprintk(ioc, printk(MPT2SAS_INFO_FMT in _base_allocate_memory_pools()
2818 "(%d kB)\n", ioc->name, ioc->sense, ioc->scsiio_depth, in _base_allocate_memory_pools()
2820 dinitprintk(ioc, printk(MPT2SAS_INFO_FMT "sense_dma(0x%llx)\n", in _base_allocate_memory_pools()
2821 ioc->name, (unsigned long long)ioc->sense_dma)); in _base_allocate_memory_pools()
2825 sz = ioc->reply_free_queue_depth * ioc->reply_sz; in _base_allocate_memory_pools()
2826 ioc->reply_dma_pool = pci_pool_create("reply pool", ioc->pdev, sz, 4, in _base_allocate_memory_pools()
2828 if (!ioc->reply_dma_pool) { in _base_allocate_memory_pools()
2830 ioc->name); in _base_allocate_memory_pools()
2833 ioc->reply = pci_pool_alloc(ioc->reply_dma_pool , GFP_KERNEL, in _base_allocate_memory_pools()
2834 &ioc->reply_dma); in _base_allocate_memory_pools()
2835 if (!ioc->reply) { in _base_allocate_memory_pools()
2837 ioc->name); in _base_allocate_memory_pools()
2840 ioc->reply_dma_min_address = (u32)(ioc->reply_dma); in _base_allocate_memory_pools()
2841 ioc->reply_dma_max_address = (u32)(ioc->reply_dma) + sz; in _base_allocate_memory_pools()
2842 dinitprintk(ioc, printk(MPT2SAS_INFO_FMT "reply pool(0x%p): depth" in _base_allocate_memory_pools()
2843 "(%d), frame_size(%d), pool_size(%d kB)\n", ioc->name, ioc->reply, in _base_allocate_memory_pools()
2844 ioc->reply_free_queue_depth, ioc->reply_sz, sz/1024)); in _base_allocate_memory_pools()
2845 dinitprintk(ioc, printk(MPT2SAS_INFO_FMT "reply_dma(0x%llx)\n", in _base_allocate_memory_pools()
2846 ioc->name, (unsigned long long)ioc->reply_dma)); in _base_allocate_memory_pools()
2850 sz = ioc->reply_free_queue_depth * 4; in _base_allocate_memory_pools()
2851 ioc->reply_free_dma_pool = pci_pool_create("reply_free pool", in _base_allocate_memory_pools()
2852 ioc->pdev, sz, 16, 0); in _base_allocate_memory_pools()
2853 if (!ioc->reply_free_dma_pool) { in _base_allocate_memory_pools()
2855 "failed\n", ioc->name); in _base_allocate_memory_pools()
2858 ioc->reply_free = pci_pool_alloc(ioc->reply_free_dma_pool , GFP_KERNEL, in _base_allocate_memory_pools()
2859 &ioc->reply_free_dma); in _base_allocate_memory_pools()
2860 if (!ioc->reply_free) { in _base_allocate_memory_pools()
2862 "failed\n", ioc->name); in _base_allocate_memory_pools()
2865 memset(ioc->reply_free, 0, sz); in _base_allocate_memory_pools()
2866 dinitprintk(ioc, printk(MPT2SAS_INFO_FMT "reply_free pool(0x%p): " in _base_allocate_memory_pools()
2867 "depth(%d), element_size(%d), pool_size(%d kB)\n", ioc->name, in _base_allocate_memory_pools()
2868 ioc->reply_free, ioc->reply_free_queue_depth, 4, sz/1024)); in _base_allocate_memory_pools()
2869 dinitprintk(ioc, printk(MPT2SAS_INFO_FMT "reply_free_dma" in _base_allocate_memory_pools()
2870 "(0x%llx)\n", ioc->name, (unsigned long long)ioc->reply_free_dma)); in _base_allocate_memory_pools()
2873 ioc->config_page_sz = 512; in _base_allocate_memory_pools()
2874 ioc->config_page = pci_alloc_consistent(ioc->pdev, in _base_allocate_memory_pools()
2875 ioc->config_page_sz, &ioc->config_page_dma); in _base_allocate_memory_pools()
2876 if (!ioc->config_page) { in _base_allocate_memory_pools()
2878 "failed\n", ioc->name); in _base_allocate_memory_pools()
2881 dinitprintk(ioc, printk(MPT2SAS_INFO_FMT "config page(0x%p): size" in _base_allocate_memory_pools()
2882 "(%d)\n", ioc->name, ioc->config_page, ioc->config_page_sz)); in _base_allocate_memory_pools()
2883 dinitprintk(ioc, printk(MPT2SAS_INFO_FMT "config_page_dma" in _base_allocate_memory_pools()
2884 "(0x%llx)\n", ioc->name, (unsigned long long)ioc->config_page_dma)); in _base_allocate_memory_pools()
2885 total_sz += ioc->config_page_sz; in _base_allocate_memory_pools()
2888 ioc->name, total_sz/1024); in _base_allocate_memory_pools()
2891 ioc->name, ioc->shost->can_queue, facts->RequestCredit); in _base_allocate_memory_pools()
2893 ioc->name, ioc->shost->sg_tablesize); in _base_allocate_memory_pools()
2910 mpt2sas_base_get_iocstate(struct MPT2SAS_ADAPTER *ioc, int cooked) in mpt2sas_base_get_iocstate() argument
2914 s = readl(&ioc->chip->Doorbell); in mpt2sas_base_get_iocstate()
2928 _base_wait_on_iocstate(struct MPT2SAS_ADAPTER *ioc, u32 ioc_state, int timeout, in _base_wait_on_iocstate() argument
2937 current_state = mpt2sas_base_get_iocstate(ioc, 1); in _base_wait_on_iocstate()
2964 _base_wait_for_doorbell_int(struct MPT2SAS_ADAPTER *ioc, int timeout, in _base_wait_for_doorbell_int() argument
2973 int_status = readl(&ioc->chip->HostInterruptStatus); in _base_wait_for_doorbell_int()
2975 dhsprintk(ioc, printk(MPT2SAS_INFO_FMT "%s: " in _base_wait_for_doorbell_int()
2976 "successful count(%d), timeout(%d)\n", ioc->name, in _base_wait_for_doorbell_int()
2988 "int_status(%x)!\n", ioc->name, __func__, count, int_status); in _base_wait_for_doorbell_int()
3004 _base_wait_for_doorbell_ack(struct MPT2SAS_ADAPTER *ioc, int timeout, in _base_wait_for_doorbell_ack() argument
3014 int_status = readl(&ioc->chip->HostInterruptStatus); in _base_wait_for_doorbell_ack()
3016 dhsprintk(ioc, printk(MPT2SAS_INFO_FMT "%s: " in _base_wait_for_doorbell_ack()
3017 "successful count(%d), timeout(%d)\n", ioc->name, in _base_wait_for_doorbell_ack()
3021 doorbell = readl(&ioc->chip->Doorbell); in _base_wait_for_doorbell_ack()
3024 mpt2sas_base_fault_info(ioc , doorbell); in _base_wait_for_doorbell_ack()
3039 "int_status(%x)!\n", ioc->name, __func__, count, int_status); in _base_wait_for_doorbell_ack()
3053 _base_wait_for_doorbell_not_used(struct MPT2SAS_ADAPTER *ioc, int timeout, in _base_wait_for_doorbell_not_used() argument
3062 doorbell_reg = readl(&ioc->chip->Doorbell); in _base_wait_for_doorbell_not_used()
3064 dhsprintk(ioc, printk(MPT2SAS_INFO_FMT "%s: " in _base_wait_for_doorbell_not_used()
3065 "successful count(%d), timeout(%d)\n", ioc->name, in _base_wait_for_doorbell_not_used()
3077 "doorbell_reg(%x)!\n", ioc->name, __func__, count, doorbell_reg); in _base_wait_for_doorbell_not_used()
3091 _base_send_ioc_reset(struct MPT2SAS_ADAPTER *ioc, u8 reset_type, int timeout, in _base_send_ioc_reset() argument
3099 ioc->name, __func__); in _base_send_ioc_reset()
3103 if (!(ioc->facts.IOCCapabilities & in _base_send_ioc_reset()
3107 printk(MPT2SAS_INFO_FMT "sending message unit reset !!\n", ioc->name); in _base_send_ioc_reset()
3110 &ioc->chip->Doorbell); in _base_send_ioc_reset()
3111 if ((_base_wait_for_doorbell_ack(ioc, 15, sleep_flag))) { in _base_send_ioc_reset()
3115 ioc_state = _base_wait_on_iocstate(ioc, MPI2_IOC_STATE_READY, in _base_send_ioc_reset()
3119 " (ioc_state=0x%x)\n", ioc->name, __func__, ioc_state); in _base_send_ioc_reset()
3125 ioc->name, ((r == 0) ? "SUCCESS" : "FAILED")); in _base_send_ioc_reset()
3142 _base_handshake_req_reply_wait(struct MPT2SAS_ADAPTER *ioc, int request_bytes, in _base_handshake_req_reply_wait() argument
3152 if ((readl(&ioc->chip->Doorbell) & MPI2_DOORBELL_USED)) { in _base_handshake_req_reply_wait()
3154 " (line=%d)\n", ioc->name, __LINE__); in _base_handshake_req_reply_wait()
3159 if (readl(&ioc->chip->HostInterruptStatus) & in _base_handshake_req_reply_wait()
3161 writel(0, &ioc->chip->HostInterruptStatus); in _base_handshake_req_reply_wait()
3166 &ioc->chip->Doorbell); in _base_handshake_req_reply_wait()
3168 if ((_base_wait_for_doorbell_int(ioc, 5, NO_SLEEP))) { in _base_handshake_req_reply_wait()
3170 "int failed (line=%d)\n", ioc->name, __LINE__); in _base_handshake_req_reply_wait()
3173 writel(0, &ioc->chip->HostInterruptStatus); in _base_handshake_req_reply_wait()
3175 if ((_base_wait_for_doorbell_ack(ioc, 5, sleep_flag))) { in _base_handshake_req_reply_wait()
3177 "ack failed (line=%d)\n", ioc->name, __LINE__); in _base_handshake_req_reply_wait()
3183 writel(cpu_to_le32(request[i]), &ioc->chip->Doorbell); in _base_handshake_req_reply_wait()
3184 if ((_base_wait_for_doorbell_ack(ioc, 5, sleep_flag))) in _base_handshake_req_reply_wait()
3190 "sending request failed (line=%d)\n", ioc->name, __LINE__); in _base_handshake_req_reply_wait()
3195 if ((_base_wait_for_doorbell_int(ioc, timeout, sleep_flag))) { in _base_handshake_req_reply_wait()
3197 "int failed (line=%d)\n", ioc->name, __LINE__); in _base_handshake_req_reply_wait()
3202 reply[0] = le16_to_cpu(readl(&ioc->chip->Doorbell) in _base_handshake_req_reply_wait()
3204 writel(0, &ioc->chip->HostInterruptStatus); in _base_handshake_req_reply_wait()
3205 if ((_base_wait_for_doorbell_int(ioc, 5, sleep_flag))) { in _base_handshake_req_reply_wait()
3207 "int failed (line=%d)\n", ioc->name, __LINE__); in _base_handshake_req_reply_wait()
3210 reply[1] = le16_to_cpu(readl(&ioc->chip->Doorbell) in _base_handshake_req_reply_wait()
3212 writel(0, &ioc->chip->HostInterruptStatus); in _base_handshake_req_reply_wait()
3215 if ((_base_wait_for_doorbell_int(ioc, 5, sleep_flag))) { in _base_handshake_req_reply_wait()
3217 "handshake int failed (line=%d)\n", ioc->name, in _base_handshake_req_reply_wait()
3222 dummy = readl(&ioc->chip->Doorbell); in _base_handshake_req_reply_wait()
3224 reply[i] = le16_to_cpu(readl(&ioc->chip->Doorbell) in _base_handshake_req_reply_wait()
3226 writel(0, &ioc->chip->HostInterruptStatus); in _base_handshake_req_reply_wait()
3229 _base_wait_for_doorbell_int(ioc, 5, sleep_flag); in _base_handshake_req_reply_wait()
3230 if (_base_wait_for_doorbell_not_used(ioc, 5, sleep_flag) != 0) { in _base_handshake_req_reply_wait()
3231 dhsprintk(ioc, printk(MPT2SAS_INFO_FMT "doorbell is in use " in _base_handshake_req_reply_wait()
3232 " (line=%d)\n", ioc->name, __LINE__)); in _base_handshake_req_reply_wait()
3234 writel(0, &ioc->chip->HostInterruptStatus); in _base_handshake_req_reply_wait()
3236 if (ioc->logging_level & MPT_DEBUG_INIT) { in _base_handshake_req_reply_wait()
3261 mpt2sas_base_sas_iounit_control(struct MPT2SAS_ADAPTER *ioc, in mpt2sas_base_sas_iounit_control() argument
3273 dinitprintk(ioc, printk(MPT2SAS_INFO_FMT "%s\n", ioc->name, in mpt2sas_base_sas_iounit_control()
3276 mutex_lock(&ioc->base_cmds.mutex); in mpt2sas_base_sas_iounit_control()
3278 if (ioc->base_cmds.status != MPT2_CMD_NOT_USED) { in mpt2sas_base_sas_iounit_control()
3280 ioc->name, __func__); in mpt2sas_base_sas_iounit_control()
3286 ioc_state = mpt2sas_base_get_iocstate(ioc, 1); in mpt2sas_base_sas_iounit_control()
3291 ioc->name, __func__); in mpt2sas_base_sas_iounit_control()
3296 ioc_state = mpt2sas_base_get_iocstate(ioc, 1); in mpt2sas_base_sas_iounit_control()
3298 "operational state(count=%d)\n", ioc->name, in mpt2sas_base_sas_iounit_control()
3302 smid = mpt2sas_base_get_smid(ioc, ioc->base_cb_idx); in mpt2sas_base_sas_iounit_control()
3305 ioc->name, __func__); in mpt2sas_base_sas_iounit_control()
3311 ioc->base_cmds.status = MPT2_CMD_PENDING; in mpt2sas_base_sas_iounit_control()
3312 request = mpt2sas_base_get_msg_frame(ioc, smid); in mpt2sas_base_sas_iounit_control()
3313 ioc->base_cmds.smid = smid; in mpt2sas_base_sas_iounit_control()
3317 ioc->ioc_link_reset_in_progress = 1; in mpt2sas_base_sas_iounit_control()
3318 init_completion(&ioc->base_cmds.done); in mpt2sas_base_sas_iounit_control()
3319 mpt2sas_base_put_smid_default(ioc, smid); in mpt2sas_base_sas_iounit_control()
3320 timeleft = wait_for_completion_timeout(&ioc->base_cmds.done, in mpt2sas_base_sas_iounit_control()
3324 ioc->ioc_link_reset_in_progress) in mpt2sas_base_sas_iounit_control()
3325 ioc->ioc_link_reset_in_progress = 0; in mpt2sas_base_sas_iounit_control()
3326 if (!(ioc->base_cmds.status & MPT2_CMD_COMPLETE)) { in mpt2sas_base_sas_iounit_control()
3328 ioc->name, __func__); in mpt2sas_base_sas_iounit_control()
3331 if (!(ioc->base_cmds.status & MPT2_CMD_RESET)) in mpt2sas_base_sas_iounit_control()
3335 if (ioc->base_cmds.status & MPT2_CMD_REPLY_VALID) in mpt2sas_base_sas_iounit_control()
3336 memcpy(mpi_reply, ioc->base_cmds.reply, in mpt2sas_base_sas_iounit_control()
3340 ioc->base_cmds.status = MPT2_CMD_NOT_USED; in mpt2sas_base_sas_iounit_control()
3345 mpt2sas_base_hard_reset_handler(ioc, CAN_SLEEP, in mpt2sas_base_sas_iounit_control()
3347 ioc->base_cmds.status = MPT2_CMD_NOT_USED; in mpt2sas_base_sas_iounit_control()
3350 mutex_unlock(&ioc->base_cmds.mutex); in mpt2sas_base_sas_iounit_control()
3367 mpt2sas_base_scsi_enclosure_processor(struct MPT2SAS_ADAPTER *ioc, in mpt2sas_base_scsi_enclosure_processor() argument
3378 dinitprintk(ioc, printk(MPT2SAS_INFO_FMT "%s\n", ioc->name, in mpt2sas_base_scsi_enclosure_processor()
3381 mutex_lock(&ioc->base_cmds.mutex); in mpt2sas_base_scsi_enclosure_processor()
3383 if (ioc->base_cmds.status != MPT2_CMD_NOT_USED) { in mpt2sas_base_scsi_enclosure_processor()
3385 ioc->name, __func__); in mpt2sas_base_scsi_enclosure_processor()
3391 ioc_state = mpt2sas_base_get_iocstate(ioc, 1); in mpt2sas_base_scsi_enclosure_processor()
3396 ioc->name, __func__); in mpt2sas_base_scsi_enclosure_processor()
3401 ioc_state = mpt2sas_base_get_iocstate(ioc, 1); in mpt2sas_base_scsi_enclosure_processor()
3403 "operational state(count=%d)\n", ioc->name, in mpt2sas_base_scsi_enclosure_processor()
3407 smid = mpt2sas_base_get_smid(ioc, ioc->base_cb_idx); in mpt2sas_base_scsi_enclosure_processor()
3410 ioc->name, __func__); in mpt2sas_base_scsi_enclosure_processor()
3416 ioc->base_cmds.status = MPT2_CMD_PENDING; in mpt2sas_base_scsi_enclosure_processor()
3417 request = mpt2sas_base_get_msg_frame(ioc, smid); in mpt2sas_base_scsi_enclosure_processor()
3418 ioc->base_cmds.smid = smid; in mpt2sas_base_scsi_enclosure_processor()
3420 init_completion(&ioc->base_cmds.done); in mpt2sas_base_scsi_enclosure_processor()
3421 mpt2sas_base_put_smid_default(ioc, smid); in mpt2sas_base_scsi_enclosure_processor()
3422 timeleft = wait_for_completion_timeout(&ioc->base_cmds.done, in mpt2sas_base_scsi_enclosure_processor()
3424 if (!(ioc->base_cmds.status & MPT2_CMD_COMPLETE)) { in mpt2sas_base_scsi_enclosure_processor()
3426 ioc->name, __func__); in mpt2sas_base_scsi_enclosure_processor()
3429 if (!(ioc->base_cmds.status & MPT2_CMD_RESET)) in mpt2sas_base_scsi_enclosure_processor()
3433 if (ioc->base_cmds.status & MPT2_CMD_REPLY_VALID) in mpt2sas_base_scsi_enclosure_processor()
3434 memcpy(mpi_reply, ioc->base_cmds.reply, in mpt2sas_base_scsi_enclosure_processor()
3438 ioc->base_cmds.status = MPT2_CMD_NOT_USED; in mpt2sas_base_scsi_enclosure_processor()
3443 mpt2sas_base_hard_reset_handler(ioc, CAN_SLEEP, in mpt2sas_base_scsi_enclosure_processor()
3445 ioc->base_cmds.status = MPT2_CMD_NOT_USED; in mpt2sas_base_scsi_enclosure_processor()
3448 mutex_unlock(&ioc->base_cmds.mutex); in mpt2sas_base_scsi_enclosure_processor()
3460 _base_get_port_facts(struct MPT2SAS_ADAPTER *ioc, int port, int sleep_flag) in _base_get_port_facts() argument
3467 dinitprintk(ioc, printk(MPT2SAS_INFO_FMT "%s\n", ioc->name, in _base_get_port_facts()
3475 r = _base_handshake_req_reply_wait(ioc, mpi_request_sz, in _base_get_port_facts()
3480 ioc->name, __func__, r); in _base_get_port_facts()
3484 pfacts = &ioc->pfacts[port]; in _base_get_port_facts()
3504 _base_wait_for_iocstate(struct MPT2SAS_ADAPTER *ioc, int timeout, in _base_wait_for_iocstate() argument
3510 dinitprintk(ioc, printk(MPT2SAS_INFO_FMT "%s\n", ioc->name, in _base_wait_for_iocstate()
3513 if (ioc->pci_error_recovery) in _base_wait_for_iocstate()
3516 doorbell = mpt2sas_base_get_iocstate(ioc, 0); in _base_wait_for_iocstate()
3518 dhsprintk(ioc, printk(MPT2SAS_INFO_FMT "%s: ioc_state(0x%08x)\n", in _base_wait_for_iocstate()
3519 ioc->name, __func__, ioc_state)); in _base_wait_for_iocstate()
3528 dhsprintk(ioc, printk(MPT2SAS_INFO_FMT in _base_wait_for_iocstate()
3529 "unexpected doorbell activ!e\n", ioc->name)); in _base_wait_for_iocstate()
3534 mpt2sas_base_fault_info(ioc, doorbell & in _base_wait_for_iocstate()
3539 ioc_state = _base_wait_on_iocstate(ioc, MPI2_IOC_STATE_READY, in _base_wait_for_iocstate()
3544 ioc->name, __func__, ioc_state); in _base_wait_for_iocstate()
3549 rc = _base_diag_reset(ioc, sleep_flag); in _base_wait_for_iocstate()
3561 _base_get_ioc_facts(struct MPT2SAS_ADAPTER *ioc, int sleep_flag) in _base_get_ioc_facts() argument
3568 dinitprintk(ioc, printk(MPT2SAS_INFO_FMT "%s\n", ioc->name, in _base_get_ioc_facts()
3571 r = _base_wait_for_iocstate(ioc, 10, sleep_flag); in _base_get_ioc_facts()
3574 ioc->name, __func__); in _base_get_ioc_facts()
3582 r = _base_handshake_req_reply_wait(ioc, mpi_request_sz, in _base_get_ioc_facts()
3587 ioc->name, __func__, r); in _base_get_ioc_facts()
3591 facts = &ioc->facts; in _base_get_ioc_facts()
3608 ioc->ir_firmware = 1; in _base_get_ioc_facts()
3611 ioc->rdpq_array_capable = 1; in _base_get_ioc_facts()
3617 ioc->shost->max_id = -1; in _base_get_ioc_facts()
3626 dinitprintk(ioc, printk(MPT2SAS_INFO_FMT "hba queue depth(%d), " in _base_get_ioc_facts()
3627 "max chains per io(%d)\n", ioc->name, facts->RequestCredit, in _base_get_ioc_facts()
3629 dinitprintk(ioc, printk(MPT2SAS_INFO_FMT "request frame size(%d), " in _base_get_ioc_facts()
3630 "reply frame size(%d)\n", ioc->name, in _base_get_ioc_facts()
3643 _base_send_ioc_init(struct MPT2SAS_ADAPTER *ioc, int sleep_flag) in _base_send_ioc_init() argument
3654 dinitprintk(ioc, printk(MPT2SAS_INFO_FMT "%s\n", ioc->name, in _base_send_ioc_init()
3665 if (_base_is_controller_msix_enabled(ioc)) in _base_send_ioc_init()
3666 mpi_request.HostMSIxVectors = ioc->reply_queue_count; in _base_send_ioc_init()
3667 mpi_request.SystemRequestFrameSize = cpu_to_le16(ioc->request_sz/4); in _base_send_ioc_init()
3669 cpu_to_le16(ioc->reply_post_queue_depth); in _base_send_ioc_init()
3671 cpu_to_le16(ioc->reply_free_queue_depth); in _base_send_ioc_init()
3674 cpu_to_le32((u64)ioc->sense_dma >> 32); in _base_send_ioc_init()
3676 cpu_to_le32((u64)ioc->reply_dma >> 32); in _base_send_ioc_init()
3678 cpu_to_le64((u64)ioc->request_dma); in _base_send_ioc_init()
3680 cpu_to_le64((u64)ioc->reply_free_dma); in _base_send_ioc_init()
3682 if (ioc->rdpq_array_enable) { in _base_send_ioc_init()
3683 reply_post_free_array_sz = ioc->reply_queue_count * in _base_send_ioc_init()
3685 reply_post_free_array = pci_alloc_consistent(ioc->pdev, in _base_send_ioc_init()
3690 ioc->name); in _base_send_ioc_init()
3695 for (i = 0; i < ioc->reply_queue_count; i++) in _base_send_ioc_init()
3698 (u64)ioc->reply_post[i].reply_post_free_dma); in _base_send_ioc_init()
3704 cpu_to_le64((u64)ioc->reply_post[0].reply_post_free_dma); in _base_send_ioc_init()
3714 if (ioc->logging_level & MPT_DEBUG_INIT) { in _base_send_ioc_init()
3725 r = _base_handshake_req_reply_wait(ioc, in _base_send_ioc_init()
3732 ioc->name, __func__, r); in _base_send_ioc_init()
3739 printk(MPT2SAS_ERR_FMT "%s: failed\n", ioc->name, __func__); in _base_send_ioc_init()
3745 pci_free_consistent(ioc->pdev, reply_post_free_array_sz, in _base_send_ioc_init()
3762 mpt2sas_port_enable_done(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 msix_index, in mpt2sas_port_enable_done() argument
3768 mpi_reply = mpt2sas_base_get_reply_virt_addr(ioc, reply); in mpt2sas_port_enable_done()
3772 if (ioc->port_enable_cmds.status == MPT2_CMD_NOT_USED) in mpt2sas_port_enable_done()
3775 ioc->port_enable_cmds.status |= MPT2_CMD_COMPLETE; in mpt2sas_port_enable_done()
3777 ioc->port_enable_cmds.status |= MPT2_CMD_REPLY_VALID; in mpt2sas_port_enable_done()
3778 memcpy(ioc->port_enable_cmds.reply, mpi_reply, in mpt2sas_port_enable_done()
3781 ioc->port_enable_cmds.status &= ~MPT2_CMD_PENDING; in mpt2sas_port_enable_done()
3786 ioc->port_enable_failed = 1; in mpt2sas_port_enable_done()
3788 if (ioc->is_driver_loading) { in mpt2sas_port_enable_done()
3790 mpt2sas_port_enable_complete(ioc); in mpt2sas_port_enable_done()
3793 ioc->start_scan_failed = ioc_status; in mpt2sas_port_enable_done()
3794 ioc->start_scan = 0; in mpt2sas_port_enable_done()
3798 complete(&ioc->port_enable_cmds.done); in mpt2sas_port_enable_done()
3811 _base_send_port_enable(struct MPT2SAS_ADAPTER *ioc, int sleep_flag) in _base_send_port_enable() argument
3820 printk(MPT2SAS_INFO_FMT "sending port enable !!\n", ioc->name); in _base_send_port_enable()
3822 if (ioc->port_enable_cmds.status & MPT2_CMD_PENDING) { in _base_send_port_enable()
3824 ioc->name, __func__); in _base_send_port_enable()
3828 smid = mpt2sas_base_get_smid(ioc, ioc->port_enable_cb_idx); in _base_send_port_enable()
3831 ioc->name, __func__); in _base_send_port_enable()
3835 ioc->port_enable_cmds.status = MPT2_CMD_PENDING; in _base_send_port_enable()
3836 mpi_request = mpt2sas_base_get_msg_frame(ioc, smid); in _base_send_port_enable()
3837 ioc->port_enable_cmds.smid = smid; in _base_send_port_enable()
3841 init_completion(&ioc->port_enable_cmds.done); in _base_send_port_enable()
3842 mpt2sas_base_put_smid_default(ioc, smid); in _base_send_port_enable()
3843 timeleft = wait_for_completion_timeout(&ioc->port_enable_cmds.done, in _base_send_port_enable()
3845 if (!(ioc->port_enable_cmds.status & MPT2_CMD_COMPLETE)) { in _base_send_port_enable()
3847 ioc->name, __func__); in _base_send_port_enable()
3850 if (ioc->port_enable_cmds.status & MPT2_CMD_RESET) in _base_send_port_enable()
3856 mpi_reply = ioc->port_enable_cmds.reply; in _base_send_port_enable()
3861 ioc->name, __func__, ioc_status); in _base_send_port_enable()
3866 ioc->port_enable_cmds.status = MPT2_CMD_NOT_USED; in _base_send_port_enable()
3867 printk(MPT2SAS_INFO_FMT "port enable: %s\n", ioc->name, ((r == 0) ? in _base_send_port_enable()
3879 mpt2sas_port_enable(struct MPT2SAS_ADAPTER *ioc) in mpt2sas_port_enable() argument
3884 printk(MPT2SAS_INFO_FMT "sending port enable !!\n", ioc->name); in mpt2sas_port_enable()
3886 if (ioc->port_enable_cmds.status & MPT2_CMD_PENDING) { in mpt2sas_port_enable()
3888 ioc->name, __func__); in mpt2sas_port_enable()
3892 smid = mpt2sas_base_get_smid(ioc, ioc->port_enable_cb_idx); in mpt2sas_port_enable()
3895 ioc->name, __func__); in mpt2sas_port_enable()
3899 ioc->port_enable_cmds.status = MPT2_CMD_PENDING; in mpt2sas_port_enable()
3900 mpi_request = mpt2sas_base_get_msg_frame(ioc, smid); in mpt2sas_port_enable()
3901 ioc->port_enable_cmds.smid = smid; in mpt2sas_port_enable()
3905 mpt2sas_base_put_smid_default(ioc, smid); in mpt2sas_port_enable()
3919 _base_determine_wait_on_discovery(struct MPT2SAS_ADAPTER *ioc) in _base_determine_wait_on_discovery() argument
3927 if (ioc->ir_firmware) in _base_determine_wait_on_discovery()
3931 if (!ioc->bios_pg3.BiosVersion) in _base_determine_wait_on_discovery()
3941 if ((ioc->bios_pg2.CurrentBootDeviceForm & in _base_determine_wait_on_discovery()
3945 (ioc->bios_pg2.ReqBootDeviceForm & in _base_determine_wait_on_discovery()
3949 (ioc->bios_pg2.ReqAltBootDeviceForm & in _base_determine_wait_on_discovery()
3966 _base_unmask_events(struct MPT2SAS_ADAPTER *ioc, u16 event) in _base_unmask_events() argument
3976 ioc->event_masks[0] &= ~desired_event; in _base_unmask_events()
3978 ioc->event_masks[1] &= ~desired_event; in _base_unmask_events()
3980 ioc->event_masks[2] &= ~desired_event; in _base_unmask_events()
3982 ioc->event_masks[3] &= ~desired_event; in _base_unmask_events()
3993 _base_event_notification(struct MPT2SAS_ADAPTER *ioc, int sleep_flag) in _base_event_notification() argument
4001 dinitprintk(ioc, printk(MPT2SAS_INFO_FMT "%s\n", ioc->name, in _base_event_notification()
4004 if (ioc->base_cmds.status & MPT2_CMD_PENDING) { in _base_event_notification()
4006 ioc->name, __func__); in _base_event_notification()
4010 smid = mpt2sas_base_get_smid(ioc, ioc->base_cb_idx); in _base_event_notification()
4013 ioc->name, __func__); in _base_event_notification()
4016 ioc->base_cmds.status = MPT2_CMD_PENDING; in _base_event_notification()
4017 mpi_request = mpt2sas_base_get_msg_frame(ioc, smid); in _base_event_notification()
4018 ioc->base_cmds.smid = smid; in _base_event_notification()
4025 cpu_to_le32(ioc->event_masks[i]); in _base_event_notification()
4026 init_completion(&ioc->base_cmds.done); in _base_event_notification()
4027 mpt2sas_base_put_smid_default(ioc, smid); in _base_event_notification()
4028 timeleft = wait_for_completion_timeout(&ioc->base_cmds.done, 30*HZ); in _base_event_notification()
4029 if (!(ioc->base_cmds.status & MPT2_CMD_COMPLETE)) { in _base_event_notification()
4031 ioc->name, __func__); in _base_event_notification()
4034 if (ioc->base_cmds.status & MPT2_CMD_RESET) in _base_event_notification()
4039 dinitprintk(ioc, printk(MPT2SAS_INFO_FMT "%s: complete\n", in _base_event_notification()
4040 ioc->name, __func__)); in _base_event_notification()
4041 ioc->base_cmds.status = MPT2_CMD_NOT_USED; in _base_event_notification()
4054 mpt2sas_base_validate_event_type(struct MPT2SAS_ADAPTER *ioc, u32 *event_type) in mpt2sas_base_validate_event_type() argument
4066 (ioc->event_masks[i] & desired_event)) { in mpt2sas_base_validate_event_type()
4067 ioc->event_masks[i] &= ~desired_event; in mpt2sas_base_validate_event_type()
4077 mutex_lock(&ioc->base_cmds.mutex); in mpt2sas_base_validate_event_type()
4078 _base_event_notification(ioc, CAN_SLEEP); in mpt2sas_base_validate_event_type()
4079 mutex_unlock(&ioc->base_cmds.mutex); in mpt2sas_base_validate_event_type()
4090 _base_diag_reset(struct MPT2SAS_ADAPTER *ioc, int sleep_flag) in _base_diag_reset() argument
4097 printk(MPT2SAS_INFO_FMT "sending diag reset !!\n", ioc->name); in _base_diag_reset()
4098 drsprintk(ioc, printk(MPT2SAS_INFO_FMT "clear interrupts\n", in _base_diag_reset()
4099 ioc->name)); in _base_diag_reset()
4106 drsprintk(ioc, printk(MPT2SAS_INFO_FMT "write magic " in _base_diag_reset()
4107 "sequence\n", ioc->name)); in _base_diag_reset()
4108 writel(MPI2_WRSEQ_FLUSH_KEY_VALUE, &ioc->chip->WriteSequence); in _base_diag_reset()
4109 writel(MPI2_WRSEQ_1ST_KEY_VALUE, &ioc->chip->WriteSequence); in _base_diag_reset()
4110 writel(MPI2_WRSEQ_2ND_KEY_VALUE, &ioc->chip->WriteSequence); in _base_diag_reset()
4111 writel(MPI2_WRSEQ_3RD_KEY_VALUE, &ioc->chip->WriteSequence); in _base_diag_reset()
4112 writel(MPI2_WRSEQ_4TH_KEY_VALUE, &ioc->chip->WriteSequence); in _base_diag_reset()
4113 writel(MPI2_WRSEQ_5TH_KEY_VALUE, &ioc->chip->WriteSequence); in _base_diag_reset()
4114 writel(MPI2_WRSEQ_6TH_KEY_VALUE, &ioc->chip->WriteSequence); in _base_diag_reset()
4125 host_diagnostic = readl(&ioc->chip->HostDiagnostic); in _base_diag_reset()
4126 drsprintk(ioc, printk(MPT2SAS_INFO_FMT "wrote magic " in _base_diag_reset()
4128 ioc->name, count, host_diagnostic)); in _base_diag_reset()
4132 hcb_size = readl(&ioc->chip->HCBSize); in _base_diag_reset()
4134 drsprintk(ioc, printk(MPT2SAS_INFO_FMT "diag reset: issued\n", in _base_diag_reset()
4135 ioc->name)); in _base_diag_reset()
4137 &ioc->chip->HostDiagnostic); in _base_diag_reset()
4149 host_diagnostic = readl(&ioc->chip->HostDiagnostic); in _base_diag_reset()
4167 drsprintk(ioc, printk(MPT2SAS_INFO_FMT "restart the adapter " in _base_diag_reset()
4169 ioc->name)); in _base_diag_reset()
4172 writel(host_diagnostic, &ioc->chip->HostDiagnostic); in _base_diag_reset()
4174 drsprintk(ioc, printk(MPT2SAS_INFO_FMT in _base_diag_reset()
4175 "re-enable the HCDW\n", ioc->name)); in _base_diag_reset()
4177 &ioc->chip->HCBSize); in _base_diag_reset()
4180 drsprintk(ioc, printk(MPT2SAS_INFO_FMT "restart the adapter\n", in _base_diag_reset()
4181 ioc->name)); in _base_diag_reset()
4183 &ioc->chip->HostDiagnostic); in _base_diag_reset()
4185 drsprintk(ioc, printk(MPT2SAS_INFO_FMT "disable writes to the " in _base_diag_reset()
4186 "diagnostic register\n", ioc->name)); in _base_diag_reset()
4187 writel(MPI2_WRSEQ_FLUSH_KEY_VALUE, &ioc->chip->WriteSequence); in _base_diag_reset()
4189 drsprintk(ioc, printk(MPT2SAS_INFO_FMT "Wait for FW to go to the " in _base_diag_reset()
4190 "READY state\n", ioc->name)); in _base_diag_reset()
4191 ioc_state = _base_wait_on_iocstate(ioc, MPI2_IOC_STATE_READY, 20, in _base_diag_reset()
4195 " (ioc_state=0x%x)\n", ioc->name, __func__, ioc_state); in _base_diag_reset()
4199 printk(MPT2SAS_INFO_FMT "diag reset: SUCCESS\n", ioc->name); in _base_diag_reset()
4203 printk(MPT2SAS_ERR_FMT "diag reset: FAILED\n", ioc->name); in _base_diag_reset()
4216 _base_make_ioc_ready(struct MPT2SAS_ADAPTER *ioc, int sleep_flag, in _base_make_ioc_ready() argument
4222 dinitprintk(ioc, printk(MPT2SAS_INFO_FMT "%s\n", ioc->name, in _base_make_ioc_ready()
4225 if (ioc->pci_error_recovery) in _base_make_ioc_ready()
4228 ioc_state = mpt2sas_base_get_iocstate(ioc, 0); in _base_make_ioc_ready()
4229 dhsprintk(ioc, printk(MPT2SAS_INFO_FMT "%s: ioc_state(0x%08x)\n", in _base_make_ioc_ready()
4230 ioc->name, __func__, ioc_state)); in _base_make_ioc_ready()
4236 dhsprintk(ioc, printk(MPT2SAS_INFO_FMT "unexpected doorbell " in _base_make_ioc_ready()
4237 "active!\n", ioc->name)); in _base_make_ioc_ready()
4242 mpt2sas_base_fault_info(ioc, ioc_state & in _base_make_ioc_ready()
4251 if (!(_base_send_ioc_reset(ioc, in _base_make_ioc_ready()
4253 ioc->ioc_reset_count++; in _base_make_ioc_ready()
4258 rc = _base_diag_reset(ioc, CAN_SLEEP); in _base_make_ioc_ready()
4259 ioc->ioc_reset_count++; in _base_make_ioc_ready()
4271 _base_make_ioc_operational(struct MPT2SAS_ADAPTER *ioc, int sleep_flag) in _base_make_ioc_operational() argument
4283 dinitprintk(ioc, printk(MPT2SAS_INFO_FMT "%s\n", ioc->name, in _base_make_ioc_operational()
4288 &ioc->delayed_tr_list, list) { in _base_make_ioc_operational()
4294 &ioc->delayed_tr_volume_list, list) { in _base_make_ioc_operational()
4300 spin_lock_irqsave(&ioc->scsi_lookup_lock, flags); in _base_make_ioc_operational()
4301 INIT_LIST_HEAD(&ioc->free_list); in _base_make_ioc_operational()
4303 for (i = 0; i < ioc->scsiio_depth; i++, smid++) { in _base_make_ioc_operational()
4304 INIT_LIST_HEAD(&ioc->scsi_lookup[i].chain_list); in _base_make_ioc_operational()
4305 ioc->scsi_lookup[i].cb_idx = 0xFF; in _base_make_ioc_operational()
4306 ioc->scsi_lookup[i].smid = smid; in _base_make_ioc_operational()
4307 ioc->scsi_lookup[i].scmd = NULL; in _base_make_ioc_operational()
4308 ioc->scsi_lookup[i].direct_io = 0; in _base_make_ioc_operational()
4309 list_add_tail(&ioc->scsi_lookup[i].tracker_list, in _base_make_ioc_operational()
4310 &ioc->free_list); in _base_make_ioc_operational()
4314 INIT_LIST_HEAD(&ioc->hpr_free_list); in _base_make_ioc_operational()
4315 smid = ioc->hi_priority_smid; in _base_make_ioc_operational()
4316 for (i = 0; i < ioc->hi_priority_depth; i++, smid++) { in _base_make_ioc_operational()
4317 ioc->hpr_lookup[i].cb_idx = 0xFF; in _base_make_ioc_operational()
4318 ioc->hpr_lookup[i].smid = smid; in _base_make_ioc_operational()
4319 list_add_tail(&ioc->hpr_lookup[i].tracker_list, in _base_make_ioc_operational()
4320 &ioc->hpr_free_list); in _base_make_ioc_operational()
4324 INIT_LIST_HEAD(&ioc->internal_free_list); in _base_make_ioc_operational()
4325 smid = ioc->internal_smid; in _base_make_ioc_operational()
4326 for (i = 0; i < ioc->internal_depth; i++, smid++) { in _base_make_ioc_operational()
4327 ioc->internal_lookup[i].cb_idx = 0xFF; in _base_make_ioc_operational()
4328 ioc->internal_lookup[i].smid = smid; in _base_make_ioc_operational()
4329 list_add_tail(&ioc->internal_lookup[i].tracker_list, in _base_make_ioc_operational()
4330 &ioc->internal_free_list); in _base_make_ioc_operational()
4334 INIT_LIST_HEAD(&ioc->free_chain_list); in _base_make_ioc_operational()
4335 for (i = 0; i < ioc->chain_depth; i++) in _base_make_ioc_operational()
4336 list_add_tail(&ioc->chain_lookup[i].tracker_list, in _base_make_ioc_operational()
4337 &ioc->free_chain_list); in _base_make_ioc_operational()
4339 spin_unlock_irqrestore(&ioc->scsi_lookup_lock, flags); in _base_make_ioc_operational()
4342 for (i = 0, reply_address = (u32)ioc->reply_dma ; in _base_make_ioc_operational()
4343 i < ioc->reply_free_queue_depth ; i++, reply_address += in _base_make_ioc_operational()
4344 ioc->reply_sz) in _base_make_ioc_operational()
4345 ioc->reply_free[i] = cpu_to_le32(reply_address); in _base_make_ioc_operational()
4348 if (ioc->is_driver_loading) in _base_make_ioc_operational()
4349 _base_assign_reply_queues(ioc); in _base_make_ioc_operational()
4352 reply_post_free_sz = ioc->reply_post_queue_depth * in _base_make_ioc_operational()
4354 reply_post_free = (long)ioc->reply_post[index].reply_post_free; in _base_make_ioc_operational()
4355 list_for_each_entry(reply_q, &ioc->reply_queue_list, list) { in _base_make_ioc_operational()
4359 for (i = 0; i < ioc->reply_post_queue_depth; i++) in _base_make_ioc_operational()
4362 if (!_base_is_controller_msix_enabled(ioc)) in _base_make_ioc_operational()
4368 if (ioc->rdpq_array_enable) in _base_make_ioc_operational()
4370 ioc->reply_post[++index].reply_post_free; in _base_make_ioc_operational()
4376 r = _base_send_ioc_init(ioc, sleep_flag); in _base_make_ioc_operational()
4381 ioc->reply_free_host_index = ioc->reply_free_queue_depth - 1; in _base_make_ioc_operational()
4382 writel(ioc->reply_free_host_index, &ioc->chip->ReplyFreeHostIndex); in _base_make_ioc_operational()
4385 list_for_each_entry(reply_q, &ioc->reply_queue_list, list) { in _base_make_ioc_operational()
4387 &ioc->chip->ReplyPostHostIndex); in _base_make_ioc_operational()
4388 if (!_base_is_controller_msix_enabled(ioc)) in _base_make_ioc_operational()
4394 _base_unmask_interrupts(ioc); in _base_make_ioc_operational()
4396 r = _base_event_notification(ioc, sleep_flag); in _base_make_ioc_operational()
4401 _base_static_config_pages(ioc); in _base_make_ioc_operational()
4404 if (ioc->is_driver_loading) { in _base_make_ioc_operational()
4405 if (ioc->is_warpdrive && ioc->manu_pg10.OEMIdentifier in _base_make_ioc_operational()
4408 le32_to_cpu(ioc->manu_pg10.OEMSpecificFlags0) & in _base_make_ioc_operational()
4411 ioc->mfg_pg10_hide_flag = hide_flag; in _base_make_ioc_operational()
4413 ioc->wait_for_discovery_to_complete = in _base_make_ioc_operational()
4414 _base_determine_wait_on_discovery(ioc); in _base_make_ioc_operational()
4417 r = _base_send_port_enable(ioc, sleep_flag); in _base_make_ioc_operational()
4431 mpt2sas_base_free_resources(struct MPT2SAS_ADAPTER *ioc) in mpt2sas_base_free_resources() argument
4433 struct pci_dev *pdev = ioc->pdev; in mpt2sas_base_free_resources()
4435 dexitprintk(ioc, printk(MPT2SAS_INFO_FMT "%s\n", ioc->name, in mpt2sas_base_free_resources()
4438 if (ioc->chip_phys && ioc->chip) { in mpt2sas_base_free_resources()
4439 _base_mask_interrupts(ioc); in mpt2sas_base_free_resources()
4440 ioc->shost_recovery = 1; in mpt2sas_base_free_resources()
4441 _base_make_ioc_ready(ioc, CAN_SLEEP, SOFT_RESET); in mpt2sas_base_free_resources()
4442 ioc->shost_recovery = 0; in mpt2sas_base_free_resources()
4445 _base_free_irq(ioc); in mpt2sas_base_free_resources()
4446 _base_disable_msix(ioc); in mpt2sas_base_free_resources()
4448 if (ioc->chip_phys && ioc->chip) in mpt2sas_base_free_resources()
4449 iounmap(ioc->chip); in mpt2sas_base_free_resources()
4450 ioc->chip_phys = 0; in mpt2sas_base_free_resources()
4453 pci_release_selected_regions(ioc->pdev, ioc->bars); in mpt2sas_base_free_resources()
4467 mpt2sas_base_attach(struct MPT2SAS_ADAPTER *ioc) in mpt2sas_base_attach() argument
4472 dinitprintk(ioc, printk(MPT2SAS_INFO_FMT "%s\n", ioc->name, in mpt2sas_base_attach()
4476 ioc->cpu_count = num_online_cpus(); in mpt2sas_base_attach()
4479 ioc->cpu_msix_table_sz = last_cpu_id + 1; in mpt2sas_base_attach()
4480 ioc->cpu_msix_table = kzalloc(ioc->cpu_msix_table_sz, GFP_KERNEL); in mpt2sas_base_attach()
4481 ioc->reply_queue_count = 1; in mpt2sas_base_attach()
4482 if (!ioc->cpu_msix_table) { in mpt2sas_base_attach()
4483 dfailprintk(ioc, printk(MPT2SAS_INFO_FMT "allocation for " in mpt2sas_base_attach()
4484 "cpu_msix_table failed!!!\n", ioc->name)); in mpt2sas_base_attach()
4489 if (ioc->is_warpdrive) { in mpt2sas_base_attach()
4490 ioc->reply_post_host_index = kcalloc(ioc->cpu_msix_table_sz, in mpt2sas_base_attach()
4492 if (!ioc->reply_post_host_index) { in mpt2sas_base_attach()
4493 dfailprintk(ioc, printk(MPT2SAS_INFO_FMT "allocation " in mpt2sas_base_attach()
4494 "for cpu_msix_table failed!!!\n", ioc->name)); in mpt2sas_base_attach()
4500 ioc->rdpq_array_enable_assigned = 0; in mpt2sas_base_attach()
4501 ioc->dma_mask = 0; in mpt2sas_base_attach()
4502 r = mpt2sas_base_map_resources(ioc); in mpt2sas_base_attach()
4506 if (ioc->is_warpdrive) { in mpt2sas_base_attach()
4507 ioc->reply_post_host_index[0] = (resource_size_t __iomem *) in mpt2sas_base_attach()
4508 &ioc->chip->ReplyPostHostIndex; in mpt2sas_base_attach()
4510 for (i = 1; i < ioc->cpu_msix_table_sz; i++) in mpt2sas_base_attach()
4511 ioc->reply_post_host_index[i] = in mpt2sas_base_attach()
4513 ((u8 __iomem *)&ioc->chip->Doorbell + (0x4000 + ((i - 1) in mpt2sas_base_attach()
4517 pci_set_drvdata(ioc->pdev, ioc->shost); in mpt2sas_base_attach()
4518 r = _base_get_ioc_facts(ioc, CAN_SLEEP); in mpt2sas_base_attach()
4522 r = _base_make_ioc_ready(ioc, CAN_SLEEP, SOFT_RESET); in mpt2sas_base_attach()
4526 ioc->pfacts = kcalloc(ioc->facts.NumberOfPorts, in mpt2sas_base_attach()
4528 if (!ioc->pfacts) { in mpt2sas_base_attach()
4533 for (i = 0 ; i < ioc->facts.NumberOfPorts; i++) { in mpt2sas_base_attach()
4534 r = _base_get_port_facts(ioc, i, CAN_SLEEP); in mpt2sas_base_attach()
4539 r = _base_allocate_memory_pools(ioc, CAN_SLEEP); in mpt2sas_base_attach()
4543 init_waitqueue_head(&ioc->reset_wq); in mpt2sas_base_attach()
4545 ioc->pd_handles_sz = (ioc->facts.MaxDevHandle / 8); in mpt2sas_base_attach()
4546 if (ioc->facts.MaxDevHandle % 8) in mpt2sas_base_attach()
4547 ioc->pd_handles_sz++; in mpt2sas_base_attach()
4548 ioc->pd_handles = kzalloc(ioc->pd_handles_sz, in mpt2sas_base_attach()
4550 if (!ioc->pd_handles) { in mpt2sas_base_attach()
4554 ioc->blocking_handles = kzalloc(ioc->pd_handles_sz, in mpt2sas_base_attach()
4556 if (!ioc->blocking_handles) { in mpt2sas_base_attach()
4560 ioc->fwfault_debug = mpt2sas_fwfault_debug; in mpt2sas_base_attach()
4563 mutex_init(&ioc->base_cmds.mutex); in mpt2sas_base_attach()
4564 ioc->base_cmds.reply = kzalloc(ioc->reply_sz, GFP_KERNEL); in mpt2sas_base_attach()
4565 ioc->base_cmds.status = MPT2_CMD_NOT_USED; in mpt2sas_base_attach()
4568 ioc->port_enable_cmds.reply = kzalloc(ioc->reply_sz, GFP_KERNEL); in mpt2sas_base_attach()
4569 ioc->port_enable_cmds.status = MPT2_CMD_NOT_USED; in mpt2sas_base_attach()
4572 ioc->transport_cmds.reply = kzalloc(ioc->reply_sz, GFP_KERNEL); in mpt2sas_base_attach()
4573 ioc->transport_cmds.status = MPT2_CMD_NOT_USED; in mpt2sas_base_attach()
4574 mutex_init(&ioc->transport_cmds.mutex); in mpt2sas_base_attach()
4577 ioc->scsih_cmds.reply = kzalloc(ioc->reply_sz, GFP_KERNEL); in mpt2sas_base_attach()
4578 ioc->scsih_cmds.status = MPT2_CMD_NOT_USED; in mpt2sas_base_attach()
4579 mutex_init(&ioc->scsih_cmds.mutex); in mpt2sas_base_attach()
4582 ioc->tm_cmds.reply = kzalloc(ioc->reply_sz, GFP_KERNEL); in mpt2sas_base_attach()
4583 ioc->tm_cmds.status = MPT2_CMD_NOT_USED; in mpt2sas_base_attach()
4584 mutex_init(&ioc->tm_cmds.mutex); in mpt2sas_base_attach()
4587 ioc->config_cmds.reply = kzalloc(ioc->reply_sz, GFP_KERNEL); in mpt2sas_base_attach()
4588 ioc->config_cmds.status = MPT2_CMD_NOT_USED; in mpt2sas_base_attach()
4589 mutex_init(&ioc->config_cmds.mutex); in mpt2sas_base_attach()
4592 ioc->ctl_cmds.reply = kzalloc(ioc->reply_sz, GFP_KERNEL); in mpt2sas_base_attach()
4593 ioc->ctl_cmds.sense = kzalloc(SCSI_SENSE_BUFFERSIZE, GFP_KERNEL); in mpt2sas_base_attach()
4594 ioc->ctl_cmds.status = MPT2_CMD_NOT_USED; in mpt2sas_base_attach()
4595 mutex_init(&ioc->ctl_cmds.mutex); in mpt2sas_base_attach()
4597 if (!ioc->base_cmds.reply || !ioc->transport_cmds.reply || in mpt2sas_base_attach()
4598 !ioc->scsih_cmds.reply || !ioc->tm_cmds.reply || in mpt2sas_base_attach()
4599 !ioc->config_cmds.reply || !ioc->ctl_cmds.reply || in mpt2sas_base_attach()
4600 !ioc->ctl_cmds.sense) { in mpt2sas_base_attach()
4605 if (!ioc->base_cmds.reply || !ioc->transport_cmds.reply || in mpt2sas_base_attach()
4606 !ioc->scsih_cmds.reply || !ioc->tm_cmds.reply || in mpt2sas_base_attach()
4607 !ioc->config_cmds.reply || !ioc->ctl_cmds.reply) { in mpt2sas_base_attach()
4613 ioc->event_masks[i] = -1; in mpt2sas_base_attach()
4616 _base_unmask_events(ioc, MPI2_EVENT_SAS_DISCOVERY); in mpt2sas_base_attach()
4617 _base_unmask_events(ioc, MPI2_EVENT_SAS_BROADCAST_PRIMITIVE); in mpt2sas_base_attach()
4618 _base_unmask_events(ioc, MPI2_EVENT_SAS_TOPOLOGY_CHANGE_LIST); in mpt2sas_base_attach()
4619 _base_unmask_events(ioc, MPI2_EVENT_SAS_DEVICE_STATUS_CHANGE); in mpt2sas_base_attach()
4620 _base_unmask_events(ioc, MPI2_EVENT_SAS_ENCL_DEVICE_STATUS_CHANGE); in mpt2sas_base_attach()
4621 _base_unmask_events(ioc, MPI2_EVENT_IR_CONFIGURATION_CHANGE_LIST); in mpt2sas_base_attach()
4622 _base_unmask_events(ioc, MPI2_EVENT_IR_VOLUME); in mpt2sas_base_attach()
4623 _base_unmask_events(ioc, MPI2_EVENT_IR_PHYSICAL_DISK); in mpt2sas_base_attach()
4624 _base_unmask_events(ioc, MPI2_EVENT_IR_OPERATION_STATUS); in mpt2sas_base_attach()
4625 _base_unmask_events(ioc, MPI2_EVENT_LOG_ENTRY_ADDED); in mpt2sas_base_attach()
4626 _base_unmask_events(ioc, MPI2_EVENT_TEMP_THRESHOLD); in mpt2sas_base_attach()
4627 r = _base_make_ioc_operational(ioc, CAN_SLEEP); in mpt2sas_base_attach()
4631 ioc->non_operational_loop = 0; in mpt2sas_base_attach()
4637 ioc->remove_host = 1; in mpt2sas_base_attach()
4638 mpt2sas_base_free_resources(ioc); in mpt2sas_base_attach()
4639 _base_release_memory_pools(ioc); in mpt2sas_base_attach()
4640 pci_set_drvdata(ioc->pdev, NULL); in mpt2sas_base_attach()
4641 kfree(ioc->cpu_msix_table); in mpt2sas_base_attach()
4642 if (ioc->is_warpdrive) in mpt2sas_base_attach()
4643 kfree(ioc->reply_post_host_index); in mpt2sas_base_attach()
4644 kfree(ioc->pd_handles); in mpt2sas_base_attach()
4645 kfree(ioc->blocking_handles); in mpt2sas_base_attach()
4646 kfree(ioc->tm_cmds.reply); in mpt2sas_base_attach()
4647 kfree(ioc->transport_cmds.reply); in mpt2sas_base_attach()
4648 kfree(ioc->scsih_cmds.reply); in mpt2sas_base_attach()
4649 kfree(ioc->config_cmds.reply); in mpt2sas_base_attach()
4650 kfree(ioc->base_cmds.reply); in mpt2sas_base_attach()
4651 kfree(ioc->port_enable_cmds.reply); in mpt2sas_base_attach()
4652 kfree(ioc->ctl_cmds.reply); in mpt2sas_base_attach()
4653 kfree(ioc->ctl_cmds.sense); in mpt2sas_base_attach()
4654 kfree(ioc->pfacts); in mpt2sas_base_attach()
4655 ioc->ctl_cmds.reply = NULL; in mpt2sas_base_attach()
4656 ioc->base_cmds.reply = NULL; in mpt2sas_base_attach()
4657 ioc->tm_cmds.reply = NULL; in mpt2sas_base_attach()
4658 ioc->scsih_cmds.reply = NULL; in mpt2sas_base_attach()
4659 ioc->transport_cmds.reply = NULL; in mpt2sas_base_attach()
4660 ioc->config_cmds.reply = NULL; in mpt2sas_base_attach()
4661 ioc->pfacts = NULL; in mpt2sas_base_attach()
4673 mpt2sas_base_detach(struct MPT2SAS_ADAPTER *ioc) in mpt2sas_base_detach() argument
4676 dexitprintk(ioc, printk(MPT2SAS_INFO_FMT "%s\n", ioc->name, in mpt2sas_base_detach()
4679 mpt2sas_base_stop_watchdog(ioc); in mpt2sas_base_detach()
4680 mpt2sas_base_free_resources(ioc); in mpt2sas_base_detach()
4681 _base_release_memory_pools(ioc); in mpt2sas_base_detach()
4682 pci_set_drvdata(ioc->pdev, NULL); in mpt2sas_base_detach()
4683 kfree(ioc->cpu_msix_table); in mpt2sas_base_detach()
4684 if (ioc->is_warpdrive) in mpt2sas_base_detach()
4685 kfree(ioc->reply_post_host_index); in mpt2sas_base_detach()
4686 kfree(ioc->pd_handles); in mpt2sas_base_detach()
4687 kfree(ioc->blocking_handles); in mpt2sas_base_detach()
4688 kfree(ioc->pfacts); in mpt2sas_base_detach()
4689 kfree(ioc->ctl_cmds.reply); in mpt2sas_base_detach()
4690 kfree(ioc->ctl_cmds.sense); in mpt2sas_base_detach()
4691 kfree(ioc->base_cmds.reply); in mpt2sas_base_detach()
4692 kfree(ioc->port_enable_cmds.reply); in mpt2sas_base_detach()
4693 kfree(ioc->tm_cmds.reply); in mpt2sas_base_detach()
4694 kfree(ioc->transport_cmds.reply); in mpt2sas_base_detach()
4695 kfree(ioc->scsih_cmds.reply); in mpt2sas_base_detach()
4696 kfree(ioc->config_cmds.reply); in mpt2sas_base_detach()
4712 _base_reset_handler(struct MPT2SAS_ADAPTER *ioc, int reset_phase) in _base_reset_handler() argument
4714 mpt2sas_scsih_reset_handler(ioc, reset_phase); in _base_reset_handler()
4715 mpt2sas_ctl_reset_handler(ioc, reset_phase); in _base_reset_handler()
4718 dtmprintk(ioc, printk(MPT2SAS_INFO_FMT "%s: " in _base_reset_handler()
4719 "MPT2_IOC_PRE_RESET\n", ioc->name, __func__)); in _base_reset_handler()
4722 dtmprintk(ioc, printk(MPT2SAS_INFO_FMT "%s: " in _base_reset_handler()
4723 "MPT2_IOC_AFTER_RESET\n", ioc->name, __func__)); in _base_reset_handler()
4724 if (ioc->transport_cmds.status & MPT2_CMD_PENDING) { in _base_reset_handler()
4725 ioc->transport_cmds.status |= MPT2_CMD_RESET; in _base_reset_handler()
4726 mpt2sas_base_free_smid(ioc, ioc->transport_cmds.smid); in _base_reset_handler()
4727 complete(&ioc->transport_cmds.done); in _base_reset_handler()
4729 if (ioc->base_cmds.status & MPT2_CMD_PENDING) { in _base_reset_handler()
4730 ioc->base_cmds.status |= MPT2_CMD_RESET; in _base_reset_handler()
4731 mpt2sas_base_free_smid(ioc, ioc->base_cmds.smid); in _base_reset_handler()
4732 complete(&ioc->base_cmds.done); in _base_reset_handler()
4734 if (ioc->port_enable_cmds.status & MPT2_CMD_PENDING) { in _base_reset_handler()
4735 ioc->port_enable_failed = 1; in _base_reset_handler()
4736 ioc->port_enable_cmds.status |= MPT2_CMD_RESET; in _base_reset_handler()
4737 mpt2sas_base_free_smid(ioc, ioc->port_enable_cmds.smid); in _base_reset_handler()
4738 if (ioc->is_driver_loading) { in _base_reset_handler()
4739 ioc->start_scan_failed = in _base_reset_handler()
4741 ioc->start_scan = 0; in _base_reset_handler()
4742 ioc->port_enable_cmds.status = in _base_reset_handler()
4745 complete(&ioc->port_enable_cmds.done); in _base_reset_handler()
4748 if (ioc->config_cmds.status & MPT2_CMD_PENDING) { in _base_reset_handler()
4749 ioc->config_cmds.status |= MPT2_CMD_RESET; in _base_reset_handler()
4750 mpt2sas_base_free_smid(ioc, ioc->config_cmds.smid); in _base_reset_handler()
4751 ioc->config_cmds.smid = USHRT_MAX; in _base_reset_handler()
4752 complete(&ioc->config_cmds.done); in _base_reset_handler()
4756 dtmprintk(ioc, printk(MPT2SAS_INFO_FMT "%s: " in _base_reset_handler()
4757 "MPT2_IOC_DONE_RESET\n", ioc->name, __func__)); in _base_reset_handler()
4771 _wait_for_commands_to_complete(struct MPT2SAS_ADAPTER *ioc, int sleep_flag) in _wait_for_commands_to_complete() argument
4777 ioc->pending_io_count = 0; in _wait_for_commands_to_complete()
4781 ioc_state = mpt2sas_base_get_iocstate(ioc, 0); in _wait_for_commands_to_complete()
4786 spin_lock_irqsave(&ioc->scsi_lookup_lock, flags); in _wait_for_commands_to_complete()
4787 for (i = 0; i < ioc->scsiio_depth; i++) in _wait_for_commands_to_complete()
4788 if (ioc->scsi_lookup[i].cb_idx != 0xFF) in _wait_for_commands_to_complete()
4789 ioc->pending_io_count++; in _wait_for_commands_to_complete()
4790 spin_unlock_irqrestore(&ioc->scsi_lookup_lock, flags); in _wait_for_commands_to_complete()
4792 if (!ioc->pending_io_count) in _wait_for_commands_to_complete()
4796 wait_event_timeout(ioc->reset_wq, ioc->pending_io_count == 0, 10 * HZ); in _wait_for_commands_to_complete()
4808 mpt2sas_base_hard_reset_handler(struct MPT2SAS_ADAPTER *ioc, int sleep_flag, in mpt2sas_base_hard_reset_handler() argument
4814 dtmprintk(ioc, printk(MPT2SAS_INFO_FMT "%s: enter\n", ioc->name, in mpt2sas_base_hard_reset_handler()
4817 if (ioc->pci_error_recovery) { in mpt2sas_base_hard_reset_handler()
4819 ioc->name, __func__); in mpt2sas_base_hard_reset_handler()
4825 mpt2sas_halt_firmware(ioc); in mpt2sas_base_hard_reset_handler()
4835 if (!mutex_trylock(&ioc->reset_in_progress_mutex)) { in mpt2sas_base_hard_reset_handler()
4838 } while (ioc->shost_recovery == 1); in mpt2sas_base_hard_reset_handler()
4839 dtmprintk(ioc, printk(MPT2SAS_INFO_FMT "%s: exit\n", ioc->name, in mpt2sas_base_hard_reset_handler()
4841 return ioc->ioc_reset_in_progress_status; in mpt2sas_base_hard_reset_handler()
4844 spin_lock_irqsave(&ioc->ioc_reset_in_progress_lock, flags); in mpt2sas_base_hard_reset_handler()
4845 ioc->shost_recovery = 1; in mpt2sas_base_hard_reset_handler()
4846 spin_unlock_irqrestore(&ioc->ioc_reset_in_progress_lock, flags); in mpt2sas_base_hard_reset_handler()
4848 _base_reset_handler(ioc, MPT2_IOC_PRE_RESET); in mpt2sas_base_hard_reset_handler()
4849 _wait_for_commands_to_complete(ioc, sleep_flag); in mpt2sas_base_hard_reset_handler()
4850 _base_mask_interrupts(ioc); in mpt2sas_base_hard_reset_handler()
4851 r = _base_make_ioc_ready(ioc, sleep_flag, type); in mpt2sas_base_hard_reset_handler()
4854 _base_reset_handler(ioc, MPT2_IOC_AFTER_RESET); in mpt2sas_base_hard_reset_handler()
4859 if (ioc->is_driver_loading && ioc->port_enable_failed) { in mpt2sas_base_hard_reset_handler()
4860 ioc->remove_host = 1; in mpt2sas_base_hard_reset_handler()
4865 r = _base_get_ioc_facts(ioc, CAN_SLEEP); in mpt2sas_base_hard_reset_handler()
4869 if (ioc->rdpq_array_enable && !ioc->rdpq_array_capable) in mpt2sas_base_hard_reset_handler()
4872 " firmware version is running\n", ioc->name); in mpt2sas_base_hard_reset_handler()
4874 r = _base_make_ioc_operational(ioc, sleep_flag); in mpt2sas_base_hard_reset_handler()
4876 _base_reset_handler(ioc, MPT2_IOC_DONE_RESET); in mpt2sas_base_hard_reset_handler()
4878 dtmprintk(ioc, printk(MPT2SAS_INFO_FMT "%s: %s\n", in mpt2sas_base_hard_reset_handler()
4879 ioc->name, __func__, ((r == 0) ? "SUCCESS" : "FAILED"))); in mpt2sas_base_hard_reset_handler()
4881 spin_lock_irqsave(&ioc->ioc_reset_in_progress_lock, flags); in mpt2sas_base_hard_reset_handler()
4882 ioc->ioc_reset_in_progress_status = r; in mpt2sas_base_hard_reset_handler()
4883 ioc->shost_recovery = 0; in mpt2sas_base_hard_reset_handler()
4884 spin_unlock_irqrestore(&ioc->ioc_reset_in_progress_lock, flags); in mpt2sas_base_hard_reset_handler()
4885 mutex_unlock(&ioc->reset_in_progress_mutex); in mpt2sas_base_hard_reset_handler()
4888 dtmprintk(ioc, printk(MPT2SAS_INFO_FMT "%s: exit\n", ioc->name, in mpt2sas_base_hard_reset_handler()