Lines Matching refs:ioc
96 _base_get_ioc_facts(struct MPT3SAS_ADAPTER *ioc, int sleep_flag);
106 struct MPT3SAS_ADAPTER *ioc; in _scsih_set_fwfault_debug() local
112 list_for_each_entry(ioc, &mpt3sas_ioc_list, list) in _scsih_set_fwfault_debug()
113 ioc->fwfault_debug = mpt3sas_fwfault_debug; in _scsih_set_fwfault_debug()
128 struct MPT3SAS_ADAPTER *ioc = (struct MPT3SAS_ADAPTER *)arg; in mpt3sas_remove_dead_ioc_func() local
131 if ((ioc == NULL)) in mpt3sas_remove_dead_ioc_func()
134 pdev = ioc->pdev; in mpt3sas_remove_dead_ioc_func()
151 struct MPT3SAS_ADAPTER *ioc = in _base_fault_reset_work() local
159 spin_lock_irqsave(&ioc->ioc_reset_in_progress_lock, flags); in _base_fault_reset_work()
160 if (ioc->shost_recovery) in _base_fault_reset_work()
162 spin_unlock_irqrestore(&ioc->ioc_reset_in_progress_lock, flags); in _base_fault_reset_work()
164 doorbell = mpt3sas_base_get_iocstate(ioc, 0); in _base_fault_reset_work()
167 ioc->name); in _base_fault_reset_work()
176 ioc->schedule_dead_ioc_flush_running_cmds(ioc); in _base_fault_reset_work()
181 ioc->remove_host = 1; in _base_fault_reset_work()
183 p = kthread_run(mpt3sas_remove_dead_ioc_func, ioc, in _base_fault_reset_work()
184 "mpt3sas_dead_ioc_%d", ioc->id); in _base_fault_reset_work()
188 ioc->name, __func__); in _base_fault_reset_work()
192 ioc->name, __func__); in _base_fault_reset_work()
197 rc = mpt3sas_base_hard_reset_handler(ioc, CAN_SLEEP, in _base_fault_reset_work()
199 pr_warn(MPT3SAS_FMT "%s: hard reset: %s\n", ioc->name, in _base_fault_reset_work()
201 doorbell = mpt3sas_base_get_iocstate(ioc, 0); in _base_fault_reset_work()
203 mpt3sas_base_fault_info(ioc, doorbell & in _base_fault_reset_work()
210 spin_lock_irqsave(&ioc->ioc_reset_in_progress_lock, flags); in _base_fault_reset_work()
212 if (ioc->fault_reset_work_q) in _base_fault_reset_work()
213 queue_delayed_work(ioc->fault_reset_work_q, in _base_fault_reset_work()
214 &ioc->fault_reset_work, in _base_fault_reset_work()
216 spin_unlock_irqrestore(&ioc->ioc_reset_in_progress_lock, flags); in _base_fault_reset_work()
227 mpt3sas_base_start_watchdog(struct MPT3SAS_ADAPTER *ioc) in mpt3sas_base_start_watchdog() argument
231 if (ioc->fault_reset_work_q) in mpt3sas_base_start_watchdog()
236 INIT_DELAYED_WORK(&ioc->fault_reset_work, _base_fault_reset_work); in mpt3sas_base_start_watchdog()
237 snprintf(ioc->fault_reset_work_q_name, in mpt3sas_base_start_watchdog()
238 sizeof(ioc->fault_reset_work_q_name), "poll_%d_status", ioc->id); in mpt3sas_base_start_watchdog()
239 ioc->fault_reset_work_q = in mpt3sas_base_start_watchdog()
240 create_singlethread_workqueue(ioc->fault_reset_work_q_name); in mpt3sas_base_start_watchdog()
241 if (!ioc->fault_reset_work_q) { in mpt3sas_base_start_watchdog()
243 ioc->name, __func__, __LINE__); in mpt3sas_base_start_watchdog()
246 spin_lock_irqsave(&ioc->ioc_reset_in_progress_lock, flags); in mpt3sas_base_start_watchdog()
247 if (ioc->fault_reset_work_q) in mpt3sas_base_start_watchdog()
248 queue_delayed_work(ioc->fault_reset_work_q, in mpt3sas_base_start_watchdog()
249 &ioc->fault_reset_work, in mpt3sas_base_start_watchdog()
251 spin_unlock_irqrestore(&ioc->ioc_reset_in_progress_lock, flags); in mpt3sas_base_start_watchdog()
262 mpt3sas_base_stop_watchdog(struct MPT3SAS_ADAPTER *ioc) in mpt3sas_base_stop_watchdog() argument
267 spin_lock_irqsave(&ioc->ioc_reset_in_progress_lock, flags); in mpt3sas_base_stop_watchdog()
268 wq = ioc->fault_reset_work_q; in mpt3sas_base_stop_watchdog()
269 ioc->fault_reset_work_q = NULL; in mpt3sas_base_stop_watchdog()
270 spin_unlock_irqrestore(&ioc->ioc_reset_in_progress_lock, flags); in mpt3sas_base_stop_watchdog()
272 if (!cancel_delayed_work_sync(&ioc->fault_reset_work)) in mpt3sas_base_stop_watchdog()
286 mpt3sas_base_fault_info(struct MPT3SAS_ADAPTER *ioc , u16 fault_code) in mpt3sas_base_fault_info() argument
289 ioc->name, fault_code); in mpt3sas_base_fault_info()
302 mpt3sas_halt_firmware(struct MPT3SAS_ADAPTER *ioc) in mpt3sas_halt_firmware() argument
306 if (!ioc->fwfault_debug) in mpt3sas_halt_firmware()
311 doorbell = readl(&ioc->chip->Doorbell); in mpt3sas_halt_firmware()
313 mpt3sas_base_fault_info(ioc , doorbell); in mpt3sas_halt_firmware()
315 writel(0xC0FFEE00, &ioc->chip->Doorbell); in mpt3sas_halt_firmware()
317 ioc->name); in mpt3sas_halt_firmware()
320 if (ioc->fwfault_debug == 2) in mpt3sas_halt_firmware()
337 _base_sas_ioc_info(struct MPT3SAS_ADAPTER *ioc, MPI2DefaultReply_t *mpi_reply, in _base_sas_ioc_info() argument
506 frame_sz = sizeof(Mpi2ConfigRequest_t) + ioc->sge_size; in _base_sas_ioc_info()
530 frame_sz = sizeof(Mpi2SmpPassthroughRequest_t) + ioc->sge_size; in _base_sas_ioc_info()
540 ioc->name, desc, ioc_status, request_hdr, func_str); in _base_sas_ioc_info()
553 _base_display_event_data(struct MPT3SAS_ADAPTER *ioc, in _base_display_event_data() argument
559 if (!(ioc->logging_level & MPT_DEBUG_EVENTS)) in _base_display_event_data()
587 pr_info(MPT3SAS_FMT "Discovery: (%s)", ioc->name, in _base_display_event_data()
631 pr_info(MPT3SAS_FMT "%s\n", ioc->name, desc); in _base_display_event_data()
643 _base_sas_log_info(struct MPT3SAS_ADAPTER *ioc , u32 log_info) in _base_sas_log_info() argument
666 if (ioc->ignore_loginfos && (log_info == 0x30050000 || log_info == in _base_sas_log_info()
684 ioc->name, log_info, in _base_sas_log_info()
699 _base_display_reply_info(struct MPT3SAS_ADAPTER *ioc, u16 smid, u8 msix_index, in _base_display_reply_info() argument
706 mpi_reply = mpt3sas_base_get_reply_virt_addr(ioc, reply); in _base_display_reply_info()
709 ioc->name, __FILE__, __LINE__, __func__); in _base_display_reply_info()
715 (ioc->logging_level & MPT_DEBUG_REPLY)) { in _base_display_reply_info()
716 _base_sas_ioc_info(ioc , mpi_reply, in _base_display_reply_info()
717 mpt3sas_base_get_msg_frame(ioc, smid)); in _base_display_reply_info()
722 _base_sas_log_info(ioc, loginfo); in _base_display_reply_info()
727 mpt3sas_trigger_mpi(ioc, ioc_status, loginfo); in _base_display_reply_info()
742 mpt3sas_base_done(struct MPT3SAS_ADAPTER *ioc, u16 smid, u8 msix_index, in mpt3sas_base_done() argument
747 mpi_reply = mpt3sas_base_get_reply_virt_addr(ioc, reply); in mpt3sas_base_done()
751 if (ioc->base_cmds.status == MPT3_CMD_NOT_USED) in mpt3sas_base_done()
754 ioc->base_cmds.status |= MPT3_CMD_COMPLETE; in mpt3sas_base_done()
756 ioc->base_cmds.status |= MPT3_CMD_REPLY_VALID; in mpt3sas_base_done()
757 memcpy(ioc->base_cmds.reply, mpi_reply, mpi_reply->MsgLength*4); in mpt3sas_base_done()
759 ioc->base_cmds.status &= ~MPT3_CMD_PENDING; in mpt3sas_base_done()
761 complete(&ioc->base_cmds.done); in mpt3sas_base_done()
775 _base_async_event(struct MPT3SAS_ADAPTER *ioc, u8 msix_index, u32 reply) in _base_async_event() argument
781 mpi_reply = mpt3sas_base_get_reply_virt_addr(ioc, reply); in _base_async_event()
787 _base_display_event_data(ioc, mpi_reply); in _base_async_event()
791 smid = mpt3sas_base_get_smid(ioc, ioc->base_cb_idx); in _base_async_event()
794 ioc->name, __func__); in _base_async_event()
798 ack_request = mpt3sas_base_get_msg_frame(ioc, smid); in _base_async_event()
805 mpt3sas_base_put_smid_default(ioc, smid); in _base_async_event()
810 mpt3sas_scsih_event_callback(ioc, msix_index, reply); in _base_async_event()
813 mpt3sas_ctl_event_callback(ioc, msix_index, reply); in _base_async_event()
826 _base_get_cb_idx(struct MPT3SAS_ADAPTER *ioc, u16 smid) in _base_get_cb_idx() argument
831 if (smid < ioc->hi_priority_smid) { in _base_get_cb_idx()
833 cb_idx = ioc->scsi_lookup[i].cb_idx; in _base_get_cb_idx()
834 } else if (smid < ioc->internal_smid) { in _base_get_cb_idx()
835 i = smid - ioc->hi_priority_smid; in _base_get_cb_idx()
836 cb_idx = ioc->hpr_lookup[i].cb_idx; in _base_get_cb_idx()
837 } else if (smid <= ioc->hba_queue_depth) { in _base_get_cb_idx()
838 i = smid - ioc->internal_smid; in _base_get_cb_idx()
839 cb_idx = ioc->internal_lookup[i].cb_idx; in _base_get_cb_idx()
854 _base_mask_interrupts(struct MPT3SAS_ADAPTER *ioc) in _base_mask_interrupts() argument
858 ioc->mask_interrupts = 1; in _base_mask_interrupts()
859 him_register = readl(&ioc->chip->HostInterruptMask); in _base_mask_interrupts()
861 writel(him_register, &ioc->chip->HostInterruptMask); in _base_mask_interrupts()
862 readl(&ioc->chip->HostInterruptMask); in _base_mask_interrupts()
874 _base_unmask_interrupts(struct MPT3SAS_ADAPTER *ioc) in _base_unmask_interrupts() argument
878 him_register = readl(&ioc->chip->HostInterruptMask); in _base_unmask_interrupts()
880 writel(him_register, &ioc->chip->HostInterruptMask); in _base_unmask_interrupts()
881 ioc->mask_interrupts = 0; in _base_unmask_interrupts()
911 struct MPT3SAS_ADAPTER *ioc = reply_q->ioc; in _base_interrupt() local
915 if (ioc->mask_interrupts) in _base_interrupt()
941 cb_idx = _base_get_cb_idx(ioc, smid); in _base_interrupt()
944 rc = mpt_callbacks[cb_idx](ioc, smid, in _base_interrupt()
947 mpt3sas_base_free_smid(ioc, smid); in _base_interrupt()
953 if (reply > ioc->reply_dma_max_address || in _base_interrupt()
954 reply < ioc->reply_dma_min_address) in _base_interrupt()
957 cb_idx = _base_get_cb_idx(ioc, smid); in _base_interrupt()
960 rc = mpt_callbacks[cb_idx](ioc, smid, in _base_interrupt()
963 _base_display_reply_info(ioc, in _base_interrupt()
966 mpt3sas_base_free_smid(ioc, in _base_interrupt()
970 _base_async_event(ioc, msix_index, reply); in _base_interrupt()
975 ioc->reply_free_host_index = in _base_interrupt()
976 (ioc->reply_free_host_index == in _base_interrupt()
977 (ioc->reply_free_queue_depth - 1)) ? in _base_interrupt()
978 0 : ioc->reply_free_host_index + 1; in _base_interrupt()
979 ioc->reply_free[ioc->reply_free_host_index] = in _base_interrupt()
982 writel(ioc->reply_free_host_index, in _base_interrupt()
983 &ioc->chip->ReplyFreeHostIndex); in _base_interrupt()
990 (ioc->reply_post_queue_depth - 1)) ? 0 : in _base_interrupt()
1013 MPI2_RPHI_MSIX_INDEX_SHIFT), &ioc->chip->ReplyPostHostIndex); in _base_interrupt()
1024 _base_is_controller_msix_enabled(struct MPT3SAS_ADAPTER *ioc) in _base_is_controller_msix_enabled() argument
1026 return (ioc->facts.IOCCapabilities & in _base_is_controller_msix_enabled()
1027 MPI2_IOCFACTS_CAPABILITY_MSI_X_INDEX) && ioc->msix_enable; in _base_is_controller_msix_enabled()
1042 mpt3sas_base_flush_reply_queues(struct MPT3SAS_ADAPTER *ioc) in mpt3sas_base_flush_reply_queues() argument
1049 if (!_base_is_controller_msix_enabled(ioc)) in mpt3sas_base_flush_reply_queues()
1052 list_for_each_entry(reply_q, &ioc->reply_queue_list, list) { in mpt3sas_base_flush_reply_queues()
1053 if (ioc->shost_recovery) in mpt3sas_base_flush_reply_queues()
1120 _base_build_zero_len_sge(struct MPT3SAS_ADAPTER *ioc, void *paddr) in _base_build_zero_len_sge() argument
1126 ioc->base_add_sg_single(paddr, flags_length, -1); in _base_build_zero_len_sge()
1176 _base_get_chain_buffer_tracker(struct MPT3SAS_ADAPTER *ioc, u16 smid) in _base_get_chain_buffer_tracker() argument
1181 spin_lock_irqsave(&ioc->scsi_lookup_lock, flags); in _base_get_chain_buffer_tracker()
1182 if (list_empty(&ioc->free_chain_list)) { in _base_get_chain_buffer_tracker()
1183 spin_unlock_irqrestore(&ioc->scsi_lookup_lock, flags); in _base_get_chain_buffer_tracker()
1184 dfailprintk(ioc, pr_warn(MPT3SAS_FMT in _base_get_chain_buffer_tracker()
1185 "chain buffers not available\n", ioc->name)); in _base_get_chain_buffer_tracker()
1188 chain_req = list_entry(ioc->free_chain_list.next, in _base_get_chain_buffer_tracker()
1192 &ioc->scsi_lookup[smid - 1].chain_list); in _base_get_chain_buffer_tracker()
1193 spin_unlock_irqrestore(&ioc->scsi_lookup_lock, flags); in _base_get_chain_buffer_tracker()
1210 _base_build_sg(struct MPT3SAS_ADAPTER *ioc, void *psge, in _base_build_sg() argument
1217 _base_build_zero_len_sge(ioc, psge); in _base_build_sg()
1226 ioc->base_add_sg_single(psge, sgl_flags | in _base_build_sg()
1230 psge += ioc->sge_size; in _base_build_sg()
1237 ioc->base_add_sg_single(psge, sgl_flags | in _base_build_sg()
1244 ioc->base_add_sg_single(psge, sgl_flags | in _base_build_sg()
1251 ioc->base_add_sg_single(psge, sgl_flags | in _base_build_sg()
1292 _base_build_zero_len_sge_ieee(struct MPT3SAS_ADAPTER *ioc, void *paddr) in _base_build_zero_len_sge_ieee() argument
1313 _base_build_sg_scmd_ieee(struct MPT3SAS_ADAPTER *ioc, in _base_build_sg_scmd_ieee() argument
1329 mpi_request = mpt3sas_base_get_msg_frame(ioc, smid); in _base_build_sg_scmd_ieee()
1349 sges_in_segment = (ioc->request_sz - in _base_build_sg_scmd_ieee()
1350 offsetof(Mpi2SCSIIORequest_t, SGL))/ioc->sge_size_ieee; in _base_build_sg_scmd_ieee()
1355 (offsetof(Mpi2SCSIIORequest_t, SGL)/ioc->sge_size_ieee); in _base_build_sg_scmd_ieee()
1362 sg_local += ioc->sge_size_ieee; in _base_build_sg_scmd_ieee()
1368 chain_req = _base_get_chain_buffer_tracker(ioc, smid); in _base_build_sg_scmd_ieee()
1375 ioc->max_sges_in_chain_message) ? sges_left : in _base_build_sg_scmd_ieee()
1376 ioc->max_sges_in_chain_message; in _base_build_sg_scmd_ieee()
1379 chain_length = sges_in_segment * ioc->sge_size_ieee; in _base_build_sg_scmd_ieee()
1381 chain_length += ioc->sge_size_ieee; in _base_build_sg_scmd_ieee()
1394 sg_local += ioc->sge_size_ieee; in _base_build_sg_scmd_ieee()
1399 chain_req = _base_get_chain_buffer_tracker(ioc, smid); in _base_build_sg_scmd_ieee()
1419 sg_local += ioc->sge_size_ieee; in _base_build_sg_scmd_ieee()
1438 _base_build_sg_ieee(struct MPT3SAS_ADAPTER *ioc, void *psge, in _base_build_sg_ieee() argument
1445 _base_build_zero_len_sge_ieee(ioc, psge); in _base_build_sg_ieee()
1457 psge += ioc->sge_size_ieee; in _base_build_sg_ieee()
1488 _base_config_dma_addressing(struct MPT3SAS_ADAPTER *ioc, struct pci_dev *pdev) in _base_config_dma_addressing() argument
1493 if (ioc->dma_mask) in _base_config_dma_addressing()
1504 ioc->base_add_sg_single = &_base_add_sg_single_64; in _base_config_dma_addressing()
1505 ioc->sge_size = sizeof(Mpi2SGESimple64_t); in _base_config_dma_addressing()
1506 ioc->dma_mask = 64; in _base_config_dma_addressing()
1513 ioc->base_add_sg_single = &_base_add_sg_single_32; in _base_config_dma_addressing()
1514 ioc->sge_size = sizeof(Mpi2SGESimple32_t); in _base_config_dma_addressing()
1515 ioc->dma_mask = 32; in _base_config_dma_addressing()
1523 ioc->name, ioc->dma_mask, convert_to_kb(s.totalram)); in _base_config_dma_addressing()
1529 _base_change_consistent_dma_mask(struct MPT3SAS_ADAPTER *ioc, in _base_change_consistent_dma_mask() argument
1547 _base_check_enable_msix(struct MPT3SAS_ADAPTER *ioc) in _base_check_enable_msix() argument
1552 base = pci_find_capability(ioc->pdev, PCI_CAP_ID_MSIX); in _base_check_enable_msix()
1554 dfailprintk(ioc, pr_info(MPT3SAS_FMT "msix not supported\n", in _base_check_enable_msix()
1555 ioc->name)); in _base_check_enable_msix()
1561 pci_read_config_word(ioc->pdev, base + 2, &message_control); in _base_check_enable_msix()
1562 ioc->msix_vector_count = (message_control & 0x3FF) + 1; in _base_check_enable_msix()
1563 if (ioc->msix_vector_count > 8) in _base_check_enable_msix()
1564 ioc->msix_vector_count = 8; in _base_check_enable_msix()
1565 dinitprintk(ioc, pr_info(MPT3SAS_FMT in _base_check_enable_msix()
1567 ioc->name, ioc->msix_vector_count)); in _base_check_enable_msix()
1578 _base_free_irq(struct MPT3SAS_ADAPTER *ioc) in _base_free_irq() argument
1582 if (list_empty(&ioc->reply_queue_list)) in _base_free_irq()
1585 list_for_each_entry_safe(reply_q, next, &ioc->reply_queue_list, list) { in _base_free_irq()
1604 _base_request_irq(struct MPT3SAS_ADAPTER *ioc, u8 index, u32 vector) in _base_request_irq() argument
1612 ioc->name, (int)sizeof(struct adapter_reply_queue)); in _base_request_irq()
1615 reply_q->ioc = ioc; in _base_request_irq()
1624 if (ioc->msix_enable) in _base_request_irq()
1626 MPT3SAS_DRIVER_NAME, ioc->id, index); in _base_request_irq()
1629 MPT3SAS_DRIVER_NAME, ioc->id); in _base_request_irq()
1640 list_add_tail(&reply_q->list, &ioc->reply_queue_list); in _base_request_irq()
1654 _base_assign_reply_queues(struct MPT3SAS_ADAPTER *ioc) in _base_assign_reply_queues() argument
1659 if (!_base_is_controller_msix_enabled(ioc)) in _base_assign_reply_queues()
1662 memset(ioc->cpu_msix_table, 0, ioc->cpu_msix_table_sz); in _base_assign_reply_queues()
1665 nr_msix = ioc->reply_queue_count = min(ioc->reply_queue_count, in _base_assign_reply_queues()
1666 ioc->facts.MaxMSIxVectors); in _base_assign_reply_queues()
1672 list_for_each_entry(reply_q, &ioc->reply_queue_list, list) { in _base_assign_reply_queues()
1683 ioc->cpu_msix_table[cpu] = index; in _base_assign_reply_queues()
1691 dinitprintk(ioc, pr_info(MPT3SAS_FMT in _base_assign_reply_queues()
1693 ioc->name, reply_q->vector)); in _base_assign_reply_queues()
1704 _base_disable_msix(struct MPT3SAS_ADAPTER *ioc) in _base_disable_msix() argument
1706 if (!ioc->msix_enable) in _base_disable_msix()
1708 pci_disable_msix(ioc->pdev); in _base_disable_msix()
1709 ioc->msix_enable = 0; in _base_disable_msix()
1718 _base_enable_msix(struct MPT3SAS_ADAPTER *ioc) in _base_enable_msix() argument
1731 if (_base_check_enable_msix(ioc) != 0) in _base_enable_msix()
1734 ioc->reply_queue_count = min_t(int, ioc->cpu_count, in _base_enable_msix()
1735 ioc->msix_vector_count); in _base_enable_msix()
1738 ": %d, max_msix_vectors: %d\n", ioc->name, ioc->msix_vector_count, in _base_enable_msix()
1739 ioc->cpu_count, max_msix_vectors); in _base_enable_msix()
1741 if (!ioc->rdpq_array_enable && max_msix_vectors == -1) in _base_enable_msix()
1745 ioc->reply_queue_count = min_t(int, max_msix_vectors, in _base_enable_msix()
1746 ioc->reply_queue_count); in _base_enable_msix()
1747 ioc->msix_vector_count = ioc->reply_queue_count; in _base_enable_msix()
1751 entries = kcalloc(ioc->reply_queue_count, sizeof(struct msix_entry), in _base_enable_msix()
1754 dfailprintk(ioc, pr_info(MPT3SAS_FMT in _base_enable_msix()
1756 ioc->name, __FILE__, __LINE__, __func__)); in _base_enable_msix()
1760 for (i = 0, a = entries; i < ioc->reply_queue_count; i++, a++) in _base_enable_msix()
1763 r = pci_enable_msix_exact(ioc->pdev, entries, ioc->reply_queue_count); in _base_enable_msix()
1765 dfailprintk(ioc, pr_info(MPT3SAS_FMT in _base_enable_msix()
1767 ioc->name, r)); in _base_enable_msix()
1772 ioc->msix_enable = 1; in _base_enable_msix()
1773 for (i = 0, a = entries; i < ioc->reply_queue_count; i++, a++) { in _base_enable_msix()
1774 r = _base_request_irq(ioc, i, a->vector); in _base_enable_msix()
1776 _base_free_irq(ioc); in _base_enable_msix()
1777 _base_disable_msix(ioc); in _base_enable_msix()
1789 ioc->reply_queue_count = 1; in _base_enable_msix()
1790 r = _base_request_irq(ioc, 0, ioc->pdev->irq); in _base_enable_msix()
1802 mpt3sas_base_map_resources(struct MPT3SAS_ADAPTER *ioc) in mpt3sas_base_map_resources() argument
1804 struct pci_dev *pdev = ioc->pdev; in mpt3sas_base_map_resources()
1812 dinitprintk(ioc, pr_info(MPT3SAS_FMT "%s\n", in mpt3sas_base_map_resources()
1813 ioc->name, __func__)); in mpt3sas_base_map_resources()
1815 ioc->bars = pci_select_bars(pdev, IORESOURCE_MEM); in mpt3sas_base_map_resources()
1818 ioc->name); in mpt3sas_base_map_resources()
1819 ioc->bars = 0; in mpt3sas_base_map_resources()
1824 if (pci_request_selected_regions(pdev, ioc->bars, in mpt3sas_base_map_resources()
1827 ioc->name); in mpt3sas_base_map_resources()
1828 ioc->bars = 0; in mpt3sas_base_map_resources()
1839 if (_base_config_dma_addressing(ioc, pdev) != 0) { in mpt3sas_base_map_resources()
1841 ioc->name, pci_name(pdev)); in mpt3sas_base_map_resources()
1855 ioc->chip_phys = pci_resource_start(pdev, i); in mpt3sas_base_map_resources()
1856 chip_phys = (u64)ioc->chip_phys; in mpt3sas_base_map_resources()
1858 ioc->chip = ioremap(ioc->chip_phys, memap_sz); in mpt3sas_base_map_resources()
1859 if (ioc->chip == NULL) { in mpt3sas_base_map_resources()
1861 ioc->name); in mpt3sas_base_map_resources()
1868 _base_mask_interrupts(ioc); in mpt3sas_base_map_resources()
1870 r = _base_get_ioc_facts(ioc, CAN_SLEEP); in mpt3sas_base_map_resources()
1874 if (!ioc->rdpq_array_enable_assigned) { in mpt3sas_base_map_resources()
1875 ioc->rdpq_array_enable = ioc->rdpq_array_capable; in mpt3sas_base_map_resources()
1876 ioc->rdpq_array_enable_assigned = 1; in mpt3sas_base_map_resources()
1879 r = _base_enable_msix(ioc); in mpt3sas_base_map_resources()
1883 list_for_each_entry(reply_q, &ioc->reply_queue_list, list) in mpt3sas_base_map_resources()
1885 reply_q->name, ((ioc->msix_enable) ? "PCI-MSI-X enabled" : in mpt3sas_base_map_resources()
1889 ioc->name, (unsigned long long)chip_phys, ioc->chip, memap_sz); in mpt3sas_base_map_resources()
1891 ioc->name, (unsigned long long)pio_chip, pio_sz); in mpt3sas_base_map_resources()
1898 if (ioc->chip_phys) in mpt3sas_base_map_resources()
1899 iounmap(ioc->chip); in mpt3sas_base_map_resources()
1900 ioc->chip_phys = 0; in mpt3sas_base_map_resources()
1901 pci_release_selected_regions(ioc->pdev, ioc->bars); in mpt3sas_base_map_resources()
1915 mpt3sas_base_get_msg_frame(struct MPT3SAS_ADAPTER *ioc, u16 smid) in mpt3sas_base_get_msg_frame() argument
1917 return (void *)(ioc->request + (smid * ioc->request_sz)); in mpt3sas_base_get_msg_frame()
1928 mpt3sas_base_get_sense_buffer(struct MPT3SAS_ADAPTER *ioc, u16 smid) in mpt3sas_base_get_sense_buffer() argument
1930 return (void *)(ioc->sense + ((smid - 1) * SCSI_SENSE_BUFFERSIZE)); in mpt3sas_base_get_sense_buffer()
1941 mpt3sas_base_get_sense_buffer_dma(struct MPT3SAS_ADAPTER *ioc, u16 smid) in mpt3sas_base_get_sense_buffer_dma() argument
1943 return cpu_to_le32(ioc->sense_dma + ((smid - 1) * in mpt3sas_base_get_sense_buffer_dma()
1955 mpt3sas_base_get_reply_virt_addr(struct MPT3SAS_ADAPTER *ioc, u32 phys_addr) in mpt3sas_base_get_reply_virt_addr() argument
1959 return ioc->reply + (phys_addr - (u32)ioc->reply_dma); in mpt3sas_base_get_reply_virt_addr()
1970 mpt3sas_base_get_smid(struct MPT3SAS_ADAPTER *ioc, u8 cb_idx) in mpt3sas_base_get_smid() argument
1976 spin_lock_irqsave(&ioc->scsi_lookup_lock, flags); in mpt3sas_base_get_smid()
1977 if (list_empty(&ioc->internal_free_list)) { in mpt3sas_base_get_smid()
1978 spin_unlock_irqrestore(&ioc->scsi_lookup_lock, flags); in mpt3sas_base_get_smid()
1980 ioc->name, __func__); in mpt3sas_base_get_smid()
1984 request = list_entry(ioc->internal_free_list.next, in mpt3sas_base_get_smid()
1989 spin_unlock_irqrestore(&ioc->scsi_lookup_lock, flags); in mpt3sas_base_get_smid()
2002 mpt3sas_base_get_smid_scsiio(struct MPT3SAS_ADAPTER *ioc, u8 cb_idx, in mpt3sas_base_get_smid_scsiio() argument
2009 spin_lock_irqsave(&ioc->scsi_lookup_lock, flags); in mpt3sas_base_get_smid_scsiio()
2010 if (list_empty(&ioc->free_list)) { in mpt3sas_base_get_smid_scsiio()
2011 spin_unlock_irqrestore(&ioc->scsi_lookup_lock, flags); in mpt3sas_base_get_smid_scsiio()
2013 ioc->name, __func__); in mpt3sas_base_get_smid_scsiio()
2017 request = list_entry(ioc->free_list.next, in mpt3sas_base_get_smid_scsiio()
2023 spin_unlock_irqrestore(&ioc->scsi_lookup_lock, flags); in mpt3sas_base_get_smid_scsiio()
2035 mpt3sas_base_get_smid_hpr(struct MPT3SAS_ADAPTER *ioc, u8 cb_idx) in mpt3sas_base_get_smid_hpr() argument
2041 spin_lock_irqsave(&ioc->scsi_lookup_lock, flags); in mpt3sas_base_get_smid_hpr()
2042 if (list_empty(&ioc->hpr_free_list)) { in mpt3sas_base_get_smid_hpr()
2043 spin_unlock_irqrestore(&ioc->scsi_lookup_lock, flags); in mpt3sas_base_get_smid_hpr()
2047 request = list_entry(ioc->hpr_free_list.next, in mpt3sas_base_get_smid_hpr()
2052 spin_unlock_irqrestore(&ioc->scsi_lookup_lock, flags); in mpt3sas_base_get_smid_hpr()
2064 mpt3sas_base_free_smid(struct MPT3SAS_ADAPTER *ioc, u16 smid) in mpt3sas_base_free_smid() argument
2070 spin_lock_irqsave(&ioc->scsi_lookup_lock, flags); in mpt3sas_base_free_smid()
2071 if (smid < ioc->hi_priority_smid) { in mpt3sas_base_free_smid()
2074 if (!list_empty(&ioc->scsi_lookup[i].chain_list)) { in mpt3sas_base_free_smid()
2076 &ioc->scsi_lookup[i].chain_list, tracker_list) { in mpt3sas_base_free_smid()
2079 &ioc->free_chain_list); in mpt3sas_base_free_smid()
2082 ioc->scsi_lookup[i].cb_idx = 0xFF; in mpt3sas_base_free_smid()
2083 ioc->scsi_lookup[i].scmd = NULL; in mpt3sas_base_free_smid()
2084 list_add(&ioc->scsi_lookup[i].tracker_list, &ioc->free_list); in mpt3sas_base_free_smid()
2085 spin_unlock_irqrestore(&ioc->scsi_lookup_lock, flags); in mpt3sas_base_free_smid()
2091 if (ioc->shost_recovery && ioc->pending_io_count) { in mpt3sas_base_free_smid()
2092 if (ioc->pending_io_count == 1) in mpt3sas_base_free_smid()
2093 wake_up(&ioc->reset_wq); in mpt3sas_base_free_smid()
2094 ioc->pending_io_count--; in mpt3sas_base_free_smid()
2097 } else if (smid < ioc->internal_smid) { in mpt3sas_base_free_smid()
2099 i = smid - ioc->hi_priority_smid; in mpt3sas_base_free_smid()
2100 ioc->hpr_lookup[i].cb_idx = 0xFF; in mpt3sas_base_free_smid()
2101 list_add(&ioc->hpr_lookup[i].tracker_list, &ioc->hpr_free_list); in mpt3sas_base_free_smid()
2102 } else if (smid <= ioc->hba_queue_depth) { in mpt3sas_base_free_smid()
2104 i = smid - ioc->internal_smid; in mpt3sas_base_free_smid()
2105 ioc->internal_lookup[i].cb_idx = 0xFF; in mpt3sas_base_free_smid()
2106 list_add(&ioc->internal_lookup[i].tracker_list, in mpt3sas_base_free_smid()
2107 &ioc->internal_free_list); in mpt3sas_base_free_smid()
2109 spin_unlock_irqrestore(&ioc->scsi_lookup_lock, flags); in mpt3sas_base_free_smid()
2144 _base_get_msix_index(struct MPT3SAS_ADAPTER *ioc) in _base_get_msix_index() argument
2146 return ioc->cpu_msix_table[raw_smp_processor_id()]; in _base_get_msix_index()
2158 mpt3sas_base_put_smid_scsi_io(struct MPT3SAS_ADAPTER *ioc, u16 smid, u16 handle) in mpt3sas_base_put_smid_scsi_io() argument
2165 descriptor.SCSIIO.MSIxIndex = _base_get_msix_index(ioc); in mpt3sas_base_put_smid_scsi_io()
2169 _base_writeq(*request, &ioc->chip->RequestDescriptorPostLow, in mpt3sas_base_put_smid_scsi_io()
2170 &ioc->scsi_lookup_lock); in mpt3sas_base_put_smid_scsi_io()
2182 mpt3sas_base_put_smid_fast_path(struct MPT3SAS_ADAPTER *ioc, u16 smid, in mpt3sas_base_put_smid_fast_path() argument
2190 descriptor.SCSIIO.MSIxIndex = _base_get_msix_index(ioc); in mpt3sas_base_put_smid_fast_path()
2194 _base_writeq(*request, &ioc->chip->RequestDescriptorPostLow, in mpt3sas_base_put_smid_fast_path()
2195 &ioc->scsi_lookup_lock); in mpt3sas_base_put_smid_fast_path()
2206 mpt3sas_base_put_smid_hi_priority(struct MPT3SAS_ADAPTER *ioc, u16 smid) in mpt3sas_base_put_smid_hi_priority() argument
2217 _base_writeq(*request, &ioc->chip->RequestDescriptorPostLow, in mpt3sas_base_put_smid_hi_priority()
2218 &ioc->scsi_lookup_lock); in mpt3sas_base_put_smid_hi_priority()
2229 mpt3sas_base_put_smid_default(struct MPT3SAS_ADAPTER *ioc, u16 smid) in mpt3sas_base_put_smid_default() argument
2235 descriptor.Default.MSIxIndex = _base_get_msix_index(ioc); in mpt3sas_base_put_smid_default()
2239 _base_writeq(*request, &ioc->chip->RequestDescriptorPostLow, in mpt3sas_base_put_smid_default()
2240 &ioc->scsi_lookup_lock); in mpt3sas_base_put_smid_default()
2250 _base_display_intel_branding(struct MPT3SAS_ADAPTER *ioc) in _base_display_intel_branding() argument
2252 if (ioc->pdev->subsystem_vendor != PCI_VENDOR_ID_INTEL) in _base_display_intel_branding()
2255 switch (ioc->pdev->device) { in _base_display_intel_branding()
2257 switch (ioc->pdev->subsystem_device) { in _base_display_intel_branding()
2259 pr_info(MPT3SAS_FMT "%s\n", ioc->name, in _base_display_intel_branding()
2264 pr_info(MPT3SAS_FMT "%s\n", ioc->name, in _base_display_intel_branding()
2268 pr_info(MPT3SAS_FMT "%s\n", ioc->name, in _base_display_intel_branding()
2272 pr_info(MPT3SAS_FMT "%s\n", ioc->name, in _base_display_intel_branding()
2278 ioc->name, ioc->pdev->subsystem_device); in _base_display_intel_branding()
2285 ioc->name, ioc->pdev->subsystem_device); in _base_display_intel_branding()
2299 _base_display_ioc_capabilities(struct MPT3SAS_ADAPTER *ioc) in _base_display_ioc_capabilities() argument
2306 bios_version = le32_to_cpu(ioc->bios_pg3.BiosVersion); in _base_display_ioc_capabilities()
2307 strncpy(desc, ioc->manu_pg0.ChipName, 16); in _base_display_ioc_capabilities()
2310 ioc->name, desc, in _base_display_ioc_capabilities()
2311 (ioc->facts.FWVersion.Word & 0xFF000000) >> 24, in _base_display_ioc_capabilities()
2312 (ioc->facts.FWVersion.Word & 0x00FF0000) >> 16, in _base_display_ioc_capabilities()
2313 (ioc->facts.FWVersion.Word & 0x0000FF00) >> 8, in _base_display_ioc_capabilities()
2314 ioc->facts.FWVersion.Word & 0x000000FF, in _base_display_ioc_capabilities()
2315 ioc->pdev->revision, in _base_display_ioc_capabilities()
2321 _base_display_intel_branding(ioc); in _base_display_ioc_capabilities()
2323 pr_info(MPT3SAS_FMT "Protocol=(", ioc->name); in _base_display_ioc_capabilities()
2325 if (ioc->facts.ProtocolFlags & MPI2_IOCFACTS_PROTOCOL_SCSI_INITIATOR) { in _base_display_ioc_capabilities()
2330 if (ioc->facts.ProtocolFlags & MPI2_IOCFACTS_PROTOCOL_SCSI_TARGET) { in _base_display_ioc_capabilities()
2339 if (ioc->facts.IOCCapabilities & in _base_display_ioc_capabilities()
2345 if (ioc->facts.IOCCapabilities & MPI2_IOCFACTS_CAPABILITY_TLR) { in _base_display_ioc_capabilities()
2350 if (ioc->facts.IOCCapabilities & MPI2_IOCFACTS_CAPABILITY_MULTICAST) { in _base_display_ioc_capabilities()
2355 if (ioc->facts.IOCCapabilities & in _base_display_ioc_capabilities()
2361 if (ioc->facts.IOCCapabilities & MPI2_IOCFACTS_CAPABILITY_EEDP) { in _base_display_ioc_capabilities()
2366 if (ioc->facts.IOCCapabilities & in _base_display_ioc_capabilities()
2372 if (ioc->facts.IOCCapabilities & in _base_display_ioc_capabilities()
2378 if (ioc->facts.IOCCapabilities & in _base_display_ioc_capabilities()
2384 if (ioc->facts.IOCCapabilities & in _base_display_ioc_capabilities()
2390 iounit_pg1_flags = le32_to_cpu(ioc->iounit_pg1.Flags); in _base_display_ioc_capabilities()
2412 mpt3sas_base_update_missing_delay(struct MPT3SAS_ADAPTER *ioc, in mpt3sas_base_update_missing_delay() argument
2423 mpt3sas_config_get_number_hba_phys(ioc, &num_phys); in mpt3sas_base_update_missing_delay()
2432 ioc->name, __FILE__, __LINE__, __func__); in mpt3sas_base_update_missing_delay()
2435 if ((mpt3sas_config_get_sas_iounit_pg1(ioc, &mpi_reply, in mpt3sas_base_update_missing_delay()
2438 ioc->name, __FILE__, __LINE__, __func__); in mpt3sas_base_update_missing_delay()
2445 ioc->name, __FILE__, __LINE__, __func__); in mpt3sas_base_update_missing_delay()
2469 if (!mpt3sas_config_set_sas_iounit_pg1(ioc, &mpi_reply, sas_iounit_pg1, in mpt3sas_base_update_missing_delay()
2478 ioc->name, dmd_orignal, dmd_new); in mpt3sas_base_update_missing_delay()
2480 ioc->name, io_missing_delay_original, in mpt3sas_base_update_missing_delay()
2482 ioc->device_missing_delay = dmd_new; in mpt3sas_base_update_missing_delay()
2483 ioc->io_missing_delay = io_missing_delay; in mpt3sas_base_update_missing_delay()
2496 _base_static_config_pages(struct MPT3SAS_ADAPTER *ioc) in _base_static_config_pages() argument
2501 mpt3sas_config_get_manufacturing_pg0(ioc, &mpi_reply, &ioc->manu_pg0); in _base_static_config_pages()
2502 if (ioc->ir_firmware) in _base_static_config_pages()
2503 mpt3sas_config_get_manufacturing_pg10(ioc, &mpi_reply, in _base_static_config_pages()
2504 &ioc->manu_pg10); in _base_static_config_pages()
2510 mpt3sas_config_get_manufacturing_pg11(ioc, &mpi_reply, &ioc->manu_pg11); in _base_static_config_pages()
2511 if (ioc->manu_pg11.EEDPTagMode == 0) { in _base_static_config_pages()
2513 ioc->name); in _base_static_config_pages()
2514 ioc->manu_pg11.EEDPTagMode &= ~0x3; in _base_static_config_pages()
2515 ioc->manu_pg11.EEDPTagMode |= 0x1; in _base_static_config_pages()
2516 mpt3sas_config_set_manufacturing_pg11(ioc, &mpi_reply, in _base_static_config_pages()
2517 &ioc->manu_pg11); in _base_static_config_pages()
2520 mpt3sas_config_get_bios_pg2(ioc, &mpi_reply, &ioc->bios_pg2); in _base_static_config_pages()
2521 mpt3sas_config_get_bios_pg3(ioc, &mpi_reply, &ioc->bios_pg3); in _base_static_config_pages()
2522 mpt3sas_config_get_ioc_pg8(ioc, &mpi_reply, &ioc->ioc_pg8); in _base_static_config_pages()
2523 mpt3sas_config_get_iounit_pg0(ioc, &mpi_reply, &ioc->iounit_pg0); in _base_static_config_pages()
2524 mpt3sas_config_get_iounit_pg1(ioc, &mpi_reply, &ioc->iounit_pg1); in _base_static_config_pages()
2525 mpt3sas_config_get_iounit_pg8(ioc, &mpi_reply, &ioc->iounit_pg8); in _base_static_config_pages()
2526 _base_display_ioc_capabilities(ioc); in _base_static_config_pages()
2532 iounit_pg1_flags = le32_to_cpu(ioc->iounit_pg1.Flags); in _base_static_config_pages()
2533 if ((ioc->facts.IOCCapabilities & in _base_static_config_pages()
2540 ioc->iounit_pg1.Flags = cpu_to_le32(iounit_pg1_flags); in _base_static_config_pages()
2541 mpt3sas_config_set_iounit_pg1(ioc, &mpi_reply, &ioc->iounit_pg1); in _base_static_config_pages()
2543 if (ioc->iounit_pg8.NumSensors) in _base_static_config_pages()
2544 ioc->temp_sensors_count = ioc->iounit_pg8.NumSensors; in _base_static_config_pages()
2556 _base_release_memory_pools(struct MPT3SAS_ADAPTER *ioc) in _base_release_memory_pools() argument
2561 dexitprintk(ioc, pr_info(MPT3SAS_FMT "%s\n", ioc->name, in _base_release_memory_pools()
2564 if (ioc->request) { in _base_release_memory_pools()
2565 pci_free_consistent(ioc->pdev, ioc->request_dma_sz, in _base_release_memory_pools()
2566 ioc->request, ioc->request_dma); in _base_release_memory_pools()
2567 dexitprintk(ioc, pr_info(MPT3SAS_FMT in _base_release_memory_pools()
2569 ioc->name, ioc->request)); in _base_release_memory_pools()
2570 ioc->request = NULL; in _base_release_memory_pools()
2573 if (ioc->sense) { in _base_release_memory_pools()
2574 pci_pool_free(ioc->sense_dma_pool, ioc->sense, ioc->sense_dma); in _base_release_memory_pools()
2575 if (ioc->sense_dma_pool) in _base_release_memory_pools()
2576 pci_pool_destroy(ioc->sense_dma_pool); in _base_release_memory_pools()
2577 dexitprintk(ioc, pr_info(MPT3SAS_FMT in _base_release_memory_pools()
2579 ioc->name, ioc->sense)); in _base_release_memory_pools()
2580 ioc->sense = NULL; in _base_release_memory_pools()
2583 if (ioc->reply) { in _base_release_memory_pools()
2584 pci_pool_free(ioc->reply_dma_pool, ioc->reply, ioc->reply_dma); in _base_release_memory_pools()
2585 if (ioc->reply_dma_pool) in _base_release_memory_pools()
2586 pci_pool_destroy(ioc->reply_dma_pool); in _base_release_memory_pools()
2587 dexitprintk(ioc, pr_info(MPT3SAS_FMT in _base_release_memory_pools()
2589 ioc->name, ioc->reply)); in _base_release_memory_pools()
2590 ioc->reply = NULL; in _base_release_memory_pools()
2593 if (ioc->reply_free) { in _base_release_memory_pools()
2594 pci_pool_free(ioc->reply_free_dma_pool, ioc->reply_free, in _base_release_memory_pools()
2595 ioc->reply_free_dma); in _base_release_memory_pools()
2596 if (ioc->reply_free_dma_pool) in _base_release_memory_pools()
2597 pci_pool_destroy(ioc->reply_free_dma_pool); in _base_release_memory_pools()
2598 dexitprintk(ioc, pr_info(MPT3SAS_FMT in _base_release_memory_pools()
2600 ioc->name, ioc->reply_free)); in _base_release_memory_pools()
2601 ioc->reply_free = NULL; in _base_release_memory_pools()
2604 if (ioc->reply_post) { in _base_release_memory_pools()
2606 rps = &ioc->reply_post[i]; in _base_release_memory_pools()
2609 ioc->reply_post_free_dma_pool, in _base_release_memory_pools()
2612 dexitprintk(ioc, pr_info(MPT3SAS_FMT in _base_release_memory_pools()
2614 ioc->name, rps->reply_post_free)); in _base_release_memory_pools()
2617 } while (ioc->rdpq_array_enable && in _base_release_memory_pools()
2618 (++i < ioc->reply_queue_count)); in _base_release_memory_pools()
2620 if (ioc->reply_post_free_dma_pool) in _base_release_memory_pools()
2621 pci_pool_destroy(ioc->reply_post_free_dma_pool); in _base_release_memory_pools()
2622 kfree(ioc->reply_post); in _base_release_memory_pools()
2625 if (ioc->config_page) { in _base_release_memory_pools()
2626 dexitprintk(ioc, pr_info(MPT3SAS_FMT in _base_release_memory_pools()
2627 "config_page(0x%p): free\n", ioc->name, in _base_release_memory_pools()
2628 ioc->config_page)); in _base_release_memory_pools()
2629 pci_free_consistent(ioc->pdev, ioc->config_page_sz, in _base_release_memory_pools()
2630 ioc->config_page, ioc->config_page_dma); in _base_release_memory_pools()
2633 if (ioc->scsi_lookup) { in _base_release_memory_pools()
2634 free_pages((ulong)ioc->scsi_lookup, ioc->scsi_lookup_pages); in _base_release_memory_pools()
2635 ioc->scsi_lookup = NULL; in _base_release_memory_pools()
2637 kfree(ioc->hpr_lookup); in _base_release_memory_pools()
2638 kfree(ioc->internal_lookup); in _base_release_memory_pools()
2639 if (ioc->chain_lookup) { in _base_release_memory_pools()
2640 for (i = 0; i < ioc->chain_depth; i++) { in _base_release_memory_pools()
2641 if (ioc->chain_lookup[i].chain_buffer) in _base_release_memory_pools()
2642 pci_pool_free(ioc->chain_dma_pool, in _base_release_memory_pools()
2643 ioc->chain_lookup[i].chain_buffer, in _base_release_memory_pools()
2644 ioc->chain_lookup[i].chain_buffer_dma); in _base_release_memory_pools()
2646 if (ioc->chain_dma_pool) in _base_release_memory_pools()
2647 pci_pool_destroy(ioc->chain_dma_pool); in _base_release_memory_pools()
2648 free_pages((ulong)ioc->chain_lookup, ioc->chain_pages); in _base_release_memory_pools()
2649 ioc->chain_lookup = NULL; in _base_release_memory_pools()
2661 _base_allocate_memory_pools(struct MPT3SAS_ADAPTER *ioc, int sleep_flag) in _base_allocate_memory_pools() argument
2673 dinitprintk(ioc, pr_info(MPT3SAS_FMT "%s\n", ioc->name, in _base_allocate_memory_pools()
2678 facts = &ioc->facts; in _base_allocate_memory_pools()
2693 " defined SCSI_MAX_SG_SEGMENTS(%u)\n", ioc->name, in _base_allocate_memory_pools()
2696 ioc->shost->sg_tablesize = sg_tablesize; in _base_allocate_memory_pools()
2698 ioc->hi_priority_depth = facts->HighPriorityCredit; in _base_allocate_memory_pools()
2699 ioc->internal_depth = ioc->hi_priority_depth + (5); in _base_allocate_memory_pools()
2703 ioc->hi_priority_depth + ioc->internal_depth, in _base_allocate_memory_pools()
2711 ioc->hba_queue_depth = max_request_credit; in _base_allocate_memory_pools()
2714 ioc->request_sz = facts->IOCRequestFrameSize * 4; in _base_allocate_memory_pools()
2717 ioc->reply_sz = facts->ReplyFrameSize * 4; in _base_allocate_memory_pools()
2720 sge_size = max_t(u16, ioc->sge_size, ioc->sge_size_ieee); in _base_allocate_memory_pools()
2725 max_sge_elements = ioc->request_sz - ((sizeof(Mpi2SCSIIORequest_t) - in _base_allocate_memory_pools()
2727 ioc->max_sges_in_main_message = max_sge_elements/sge_size; in _base_allocate_memory_pools()
2730 max_sge_elements = ioc->request_sz - sge_size; in _base_allocate_memory_pools()
2731 ioc->max_sges_in_chain_message = max_sge_elements/sge_size; in _base_allocate_memory_pools()
2736 chains_needed_per_io = ((ioc->shost->sg_tablesize - in _base_allocate_memory_pools()
2737 ioc->max_sges_in_main_message)/ioc->max_sges_in_chain_message) in _base_allocate_memory_pools()
2741 ioc->shost->sg_tablesize = min_t(u16, in _base_allocate_memory_pools()
2742 ioc->max_sges_in_main_message + (ioc->max_sges_in_chain_message in _base_allocate_memory_pools()
2743 * chains_needed_per_io), ioc->shost->sg_tablesize); in _base_allocate_memory_pools()
2745 ioc->chains_needed_per_io = chains_needed_per_io; in _base_allocate_memory_pools()
2748 ioc->reply_free_queue_depth = ioc->hba_queue_depth + 64; in _base_allocate_memory_pools()
2751 ioc->reply_post_queue_depth = ioc->hba_queue_depth + in _base_allocate_memory_pools()
2752 ioc->reply_free_queue_depth + 1 ; in _base_allocate_memory_pools()
2754 if (ioc->reply_post_queue_depth % 16) in _base_allocate_memory_pools()
2755 ioc->reply_post_queue_depth += 16 - in _base_allocate_memory_pools()
2756 (ioc->reply_post_queue_depth % 16); in _base_allocate_memory_pools()
2759 if (ioc->reply_post_queue_depth > in _base_allocate_memory_pools()
2761 ioc->reply_post_queue_depth = in _base_allocate_memory_pools()
2764 ioc->hba_queue_depth = in _base_allocate_memory_pools()
2765 ((ioc->reply_post_queue_depth - 64) / 2) - 1; in _base_allocate_memory_pools()
2766 ioc->reply_free_queue_depth = ioc->hba_queue_depth + 64; in _base_allocate_memory_pools()
2769 dinitprintk(ioc, pr_info(MPT3SAS_FMT "scatter gather: " \ in _base_allocate_memory_pools()
2771 "chains_per_io(%d)\n", ioc->name, ioc->max_sges_in_main_message, in _base_allocate_memory_pools()
2772 ioc->max_sges_in_chain_message, ioc->shost->sg_tablesize, in _base_allocate_memory_pools()
2773 ioc->chains_needed_per_io)); in _base_allocate_memory_pools()
2776 reply_post_free_sz = ioc->reply_post_queue_depth * in _base_allocate_memory_pools()
2780 if (_base_is_controller_msix_enabled(ioc) && !ioc->rdpq_array_enable) in _base_allocate_memory_pools()
2781 sz *= ioc->reply_queue_count; in _base_allocate_memory_pools()
2783 ioc->reply_post = kcalloc((ioc->rdpq_array_enable) ? in _base_allocate_memory_pools()
2784 (ioc->reply_queue_count):1, in _base_allocate_memory_pools()
2787 if (!ioc->reply_post) { in _base_allocate_memory_pools()
2789 ioc->name); in _base_allocate_memory_pools()
2792 ioc->reply_post_free_dma_pool = pci_pool_create("reply_post_free pool", in _base_allocate_memory_pools()
2793 ioc->pdev, sz, 16, 0); in _base_allocate_memory_pools()
2794 if (!ioc->reply_post_free_dma_pool) { in _base_allocate_memory_pools()
2797 ioc->name); in _base_allocate_memory_pools()
2802 ioc->reply_post[i].reply_post_free = in _base_allocate_memory_pools()
2803 pci_pool_alloc(ioc->reply_post_free_dma_pool, in _base_allocate_memory_pools()
2805 &ioc->reply_post[i].reply_post_free_dma); in _base_allocate_memory_pools()
2806 if (!ioc->reply_post[i].reply_post_free) { in _base_allocate_memory_pools()
2809 ioc->name); in _base_allocate_memory_pools()
2812 memset(ioc->reply_post[i].reply_post_free, 0, sz); in _base_allocate_memory_pools()
2813 dinitprintk(ioc, pr_info(MPT3SAS_FMT in _base_allocate_memory_pools()
2815 "element_size(%d), pool_size(%d kB)\n", ioc->name, in _base_allocate_memory_pools()
2816 ioc->reply_post[i].reply_post_free, in _base_allocate_memory_pools()
2817 ioc->reply_post_queue_depth, 8, sz/1024)); in _base_allocate_memory_pools()
2818 dinitprintk(ioc, pr_info(MPT3SAS_FMT in _base_allocate_memory_pools()
2819 "reply_post_free_dma = (0x%llx)\n", ioc->name, in _base_allocate_memory_pools()
2821 ioc->reply_post[i].reply_post_free_dma)); in _base_allocate_memory_pools()
2823 } while (ioc->rdpq_array_enable && (++i < ioc->reply_queue_count)); in _base_allocate_memory_pools()
2825 if (ioc->dma_mask == 64) { in _base_allocate_memory_pools()
2826 if (_base_change_consistent_dma_mask(ioc, ioc->pdev) != 0) { in _base_allocate_memory_pools()
2829 ioc->name, pci_name(ioc->pdev)); in _base_allocate_memory_pools()
2834 ioc->scsiio_depth = ioc->hba_queue_depth - in _base_allocate_memory_pools()
2835 ioc->hi_priority_depth - ioc->internal_depth; in _base_allocate_memory_pools()
2840 ioc->shost->can_queue = ioc->scsiio_depth; in _base_allocate_memory_pools()
2841 dinitprintk(ioc, pr_info(MPT3SAS_FMT in _base_allocate_memory_pools()
2843 ioc->name, ioc->shost->can_queue)); in _base_allocate_memory_pools()
2849 ioc->chain_depth = ioc->chains_needed_per_io * ioc->scsiio_depth; in _base_allocate_memory_pools()
2850 sz = ((ioc->scsiio_depth + 1) * ioc->request_sz); in _base_allocate_memory_pools()
2853 sz += (ioc->hi_priority_depth * ioc->request_sz); in _base_allocate_memory_pools()
2856 sz += (ioc->internal_depth * ioc->request_sz); in _base_allocate_memory_pools()
2858 ioc->request_dma_sz = sz; in _base_allocate_memory_pools()
2859 ioc->request = pci_alloc_consistent(ioc->pdev, sz, &ioc->request_dma); in _base_allocate_memory_pools()
2860 if (!ioc->request) { in _base_allocate_memory_pools()
2863 "total(%d kB)\n", ioc->name, ioc->hba_queue_depth, in _base_allocate_memory_pools()
2864 ioc->chains_needed_per_io, ioc->request_sz, sz/1024); in _base_allocate_memory_pools()
2865 if (ioc->scsiio_depth < MPT3SAS_SAS_QUEUE_DEPTH) in _base_allocate_memory_pools()
2868 ioc->hba_queue_depth = max_request_credit - retry_sz; in _base_allocate_memory_pools()
2875 "total(%d kb)\n", ioc->name, ioc->hba_queue_depth, in _base_allocate_memory_pools()
2876 ioc->chains_needed_per_io, ioc->request_sz, sz/1024); in _base_allocate_memory_pools()
2879 ioc->hi_priority = ioc->request + ((ioc->scsiio_depth + 1) * in _base_allocate_memory_pools()
2880 ioc->request_sz); in _base_allocate_memory_pools()
2881 ioc->hi_priority_dma = ioc->request_dma + ((ioc->scsiio_depth + 1) * in _base_allocate_memory_pools()
2882 ioc->request_sz); in _base_allocate_memory_pools()
2885 ioc->internal = ioc->hi_priority + (ioc->hi_priority_depth * in _base_allocate_memory_pools()
2886 ioc->request_sz); in _base_allocate_memory_pools()
2887 ioc->internal_dma = ioc->hi_priority_dma + (ioc->hi_priority_depth * in _base_allocate_memory_pools()
2888 ioc->request_sz); in _base_allocate_memory_pools()
2890 dinitprintk(ioc, pr_info(MPT3SAS_FMT in _base_allocate_memory_pools()
2892 ioc->name, ioc->request, ioc->hba_queue_depth, ioc->request_sz, in _base_allocate_memory_pools()
2893 (ioc->hba_queue_depth * ioc->request_sz)/1024)); in _base_allocate_memory_pools()
2895 dinitprintk(ioc, pr_info(MPT3SAS_FMT "request pool: dma(0x%llx)\n", in _base_allocate_memory_pools()
2896 ioc->name, (unsigned long long) ioc->request_dma)); in _base_allocate_memory_pools()
2899 sz = ioc->scsiio_depth * sizeof(struct scsiio_tracker); in _base_allocate_memory_pools()
2900 ioc->scsi_lookup_pages = get_order(sz); in _base_allocate_memory_pools()
2901 ioc->scsi_lookup = (struct scsiio_tracker *)__get_free_pages( in _base_allocate_memory_pools()
2902 GFP_KERNEL, ioc->scsi_lookup_pages); in _base_allocate_memory_pools()
2903 if (!ioc->scsi_lookup) { in _base_allocate_memory_pools()
2905 ioc->name, (int)sz); in _base_allocate_memory_pools()
2909 dinitprintk(ioc, pr_info(MPT3SAS_FMT "scsiio(0x%p): depth(%d)\n", in _base_allocate_memory_pools()
2910 ioc->name, ioc->request, ioc->scsiio_depth)); in _base_allocate_memory_pools()
2912 ioc->chain_depth = min_t(u32, ioc->chain_depth, MAX_CHAIN_DEPTH); in _base_allocate_memory_pools()
2913 sz = ioc->chain_depth * sizeof(struct chain_tracker); in _base_allocate_memory_pools()
2914 ioc->chain_pages = get_order(sz); in _base_allocate_memory_pools()
2915 ioc->chain_lookup = (struct chain_tracker *)__get_free_pages( in _base_allocate_memory_pools()
2916 GFP_KERNEL, ioc->chain_pages); in _base_allocate_memory_pools()
2917 if (!ioc->chain_lookup) { in _base_allocate_memory_pools()
2919 ioc->name); in _base_allocate_memory_pools()
2922 ioc->chain_dma_pool = pci_pool_create("chain pool", ioc->pdev, in _base_allocate_memory_pools()
2923 ioc->request_sz, 16, 0); in _base_allocate_memory_pools()
2924 if (!ioc->chain_dma_pool) { in _base_allocate_memory_pools()
2926 ioc->name); in _base_allocate_memory_pools()
2929 for (i = 0; i < ioc->chain_depth; i++) { in _base_allocate_memory_pools()
2930 ioc->chain_lookup[i].chain_buffer = pci_pool_alloc( in _base_allocate_memory_pools()
2931 ioc->chain_dma_pool , GFP_KERNEL, in _base_allocate_memory_pools()
2932 &ioc->chain_lookup[i].chain_buffer_dma); in _base_allocate_memory_pools()
2933 if (!ioc->chain_lookup[i].chain_buffer) { in _base_allocate_memory_pools()
2934 ioc->chain_depth = i; in _base_allocate_memory_pools()
2937 total_sz += ioc->request_sz; in _base_allocate_memory_pools()
2940 dinitprintk(ioc, pr_info(MPT3SAS_FMT in _base_allocate_memory_pools()
2942 ioc->name, ioc->chain_depth, ioc->request_sz, in _base_allocate_memory_pools()
2943 ((ioc->chain_depth * ioc->request_sz))/1024)); in _base_allocate_memory_pools()
2946 ioc->hpr_lookup = kcalloc(ioc->hi_priority_depth, in _base_allocate_memory_pools()
2948 if (!ioc->hpr_lookup) { in _base_allocate_memory_pools()
2950 ioc->name); in _base_allocate_memory_pools()
2953 ioc->hi_priority_smid = ioc->scsiio_depth + 1; in _base_allocate_memory_pools()
2954 dinitprintk(ioc, pr_info(MPT3SAS_FMT in _base_allocate_memory_pools()
2956 ioc->name, ioc->hi_priority, in _base_allocate_memory_pools()
2957 ioc->hi_priority_depth, ioc->hi_priority_smid)); in _base_allocate_memory_pools()
2960 ioc->internal_lookup = kcalloc(ioc->internal_depth, in _base_allocate_memory_pools()
2962 if (!ioc->internal_lookup) { in _base_allocate_memory_pools()
2964 ioc->name); in _base_allocate_memory_pools()
2967 ioc->internal_smid = ioc->hi_priority_smid + ioc->hi_priority_depth; in _base_allocate_memory_pools()
2968 dinitprintk(ioc, pr_info(MPT3SAS_FMT in _base_allocate_memory_pools()
2970 ioc->name, ioc->internal, in _base_allocate_memory_pools()
2971 ioc->internal_depth, ioc->internal_smid)); in _base_allocate_memory_pools()
2974 sz = ioc->scsiio_depth * SCSI_SENSE_BUFFERSIZE; in _base_allocate_memory_pools()
2975 ioc->sense_dma_pool = pci_pool_create("sense pool", ioc->pdev, sz, 4, in _base_allocate_memory_pools()
2977 if (!ioc->sense_dma_pool) { in _base_allocate_memory_pools()
2979 ioc->name); in _base_allocate_memory_pools()
2982 ioc->sense = pci_pool_alloc(ioc->sense_dma_pool , GFP_KERNEL, in _base_allocate_memory_pools()
2983 &ioc->sense_dma); in _base_allocate_memory_pools()
2984 if (!ioc->sense) { in _base_allocate_memory_pools()
2986 ioc->name); in _base_allocate_memory_pools()
2989 dinitprintk(ioc, pr_info(MPT3SAS_FMT in _base_allocate_memory_pools()
2991 "(%d kB)\n", ioc->name, ioc->sense, ioc->scsiio_depth, in _base_allocate_memory_pools()
2993 dinitprintk(ioc, pr_info(MPT3SAS_FMT "sense_dma(0x%llx)\n", in _base_allocate_memory_pools()
2994 ioc->name, (unsigned long long)ioc->sense_dma)); in _base_allocate_memory_pools()
2998 sz = ioc->reply_free_queue_depth * ioc->reply_sz; in _base_allocate_memory_pools()
2999 ioc->reply_dma_pool = pci_pool_create("reply pool", ioc->pdev, sz, 4, in _base_allocate_memory_pools()
3001 if (!ioc->reply_dma_pool) { in _base_allocate_memory_pools()
3003 ioc->name); in _base_allocate_memory_pools()
3006 ioc->reply = pci_pool_alloc(ioc->reply_dma_pool , GFP_KERNEL, in _base_allocate_memory_pools()
3007 &ioc->reply_dma); in _base_allocate_memory_pools()
3008 if (!ioc->reply) { in _base_allocate_memory_pools()
3010 ioc->name); in _base_allocate_memory_pools()
3013 ioc->reply_dma_min_address = (u32)(ioc->reply_dma); in _base_allocate_memory_pools()
3014 ioc->reply_dma_max_address = (u32)(ioc->reply_dma) + sz; in _base_allocate_memory_pools()
3015 dinitprintk(ioc, pr_info(MPT3SAS_FMT in _base_allocate_memory_pools()
3017 ioc->name, ioc->reply, in _base_allocate_memory_pools()
3018 ioc->reply_free_queue_depth, ioc->reply_sz, sz/1024)); in _base_allocate_memory_pools()
3019 dinitprintk(ioc, pr_info(MPT3SAS_FMT "reply_dma(0x%llx)\n", in _base_allocate_memory_pools()
3020 ioc->name, (unsigned long long)ioc->reply_dma)); in _base_allocate_memory_pools()
3024 sz = ioc->reply_free_queue_depth * 4; in _base_allocate_memory_pools()
3025 ioc->reply_free_dma_pool = pci_pool_create("reply_free pool", in _base_allocate_memory_pools()
3026 ioc->pdev, sz, 16, 0); in _base_allocate_memory_pools()
3027 if (!ioc->reply_free_dma_pool) { in _base_allocate_memory_pools()
3029 ioc->name); in _base_allocate_memory_pools()
3032 ioc->reply_free = pci_pool_alloc(ioc->reply_free_dma_pool , GFP_KERNEL, in _base_allocate_memory_pools()
3033 &ioc->reply_free_dma); in _base_allocate_memory_pools()
3034 if (!ioc->reply_free) { in _base_allocate_memory_pools()
3036 ioc->name); in _base_allocate_memory_pools()
3039 memset(ioc->reply_free, 0, sz); in _base_allocate_memory_pools()
3040 dinitprintk(ioc, pr_info(MPT3SAS_FMT "reply_free pool(0x%p): " \ in _base_allocate_memory_pools()
3041 "depth(%d), element_size(%d), pool_size(%d kB)\n", ioc->name, in _base_allocate_memory_pools()
3042 ioc->reply_free, ioc->reply_free_queue_depth, 4, sz/1024)); in _base_allocate_memory_pools()
3043 dinitprintk(ioc, pr_info(MPT3SAS_FMT in _base_allocate_memory_pools()
3045 ioc->name, (unsigned long long)ioc->reply_free_dma)); in _base_allocate_memory_pools()
3048 ioc->config_page_sz = 512; in _base_allocate_memory_pools()
3049 ioc->config_page = pci_alloc_consistent(ioc->pdev, in _base_allocate_memory_pools()
3050 ioc->config_page_sz, &ioc->config_page_dma); in _base_allocate_memory_pools()
3051 if (!ioc->config_page) { in _base_allocate_memory_pools()
3054 ioc->name); in _base_allocate_memory_pools()
3057 dinitprintk(ioc, pr_info(MPT3SAS_FMT in _base_allocate_memory_pools()
3059 ioc->name, ioc->config_page, ioc->config_page_sz)); in _base_allocate_memory_pools()
3060 dinitprintk(ioc, pr_info(MPT3SAS_FMT "config_page_dma(0x%llx)\n", in _base_allocate_memory_pools()
3061 ioc->name, (unsigned long long)ioc->config_page_dma)); in _base_allocate_memory_pools()
3062 total_sz += ioc->config_page_sz; in _base_allocate_memory_pools()
3065 ioc->name, total_sz/1024); in _base_allocate_memory_pools()
3068 ioc->name, ioc->shost->can_queue, facts->RequestCredit); in _base_allocate_memory_pools()
3070 ioc->name, ioc->shost->sg_tablesize); in _base_allocate_memory_pools()
3086 mpt3sas_base_get_iocstate(struct MPT3SAS_ADAPTER *ioc, int cooked) in mpt3sas_base_get_iocstate() argument
3090 s = readl(&ioc->chip->Doorbell); in mpt3sas_base_get_iocstate()
3104 _base_wait_on_iocstate(struct MPT3SAS_ADAPTER *ioc, u32 ioc_state, int timeout, in _base_wait_on_iocstate() argument
3113 current_state = mpt3sas_base_get_iocstate(ioc, 1); in _base_wait_on_iocstate()
3140 _base_wait_for_doorbell_int(struct MPT3SAS_ADAPTER *ioc, int timeout, in _base_wait_for_doorbell_int() argument
3149 int_status = readl(&ioc->chip->HostInterruptStatus); in _base_wait_for_doorbell_int()
3151 dhsprintk(ioc, pr_info(MPT3SAS_FMT in _base_wait_for_doorbell_int()
3153 ioc->name, __func__, count, timeout)); in _base_wait_for_doorbell_int()
3165 ioc->name, __func__, count, int_status); in _base_wait_for_doorbell_int()
3181 _base_wait_for_doorbell_ack(struct MPT3SAS_ADAPTER *ioc, int timeout, in _base_wait_for_doorbell_ack() argument
3191 int_status = readl(&ioc->chip->HostInterruptStatus); in _base_wait_for_doorbell_ack()
3193 dhsprintk(ioc, pr_info(MPT3SAS_FMT in _base_wait_for_doorbell_ack()
3195 ioc->name, __func__, count, timeout)); in _base_wait_for_doorbell_ack()
3198 doorbell = readl(&ioc->chip->Doorbell); in _base_wait_for_doorbell_ack()
3201 mpt3sas_base_fault_info(ioc , doorbell); in _base_wait_for_doorbell_ack()
3217 ioc->name, __func__, count, int_status); in _base_wait_for_doorbell_ack()
3231 _base_wait_for_doorbell_not_used(struct MPT3SAS_ADAPTER *ioc, int timeout, in _base_wait_for_doorbell_not_used() argument
3240 doorbell_reg = readl(&ioc->chip->Doorbell); in _base_wait_for_doorbell_not_used()
3242 dhsprintk(ioc, pr_info(MPT3SAS_FMT in _base_wait_for_doorbell_not_used()
3244 ioc->name, __func__, count, timeout)); in _base_wait_for_doorbell_not_used()
3256 ioc->name, __func__, count, doorbell_reg); in _base_wait_for_doorbell_not_used()
3270 _base_send_ioc_reset(struct MPT3SAS_ADAPTER *ioc, u8 reset_type, int timeout, in _base_send_ioc_reset() argument
3278 ioc->name, __func__); in _base_send_ioc_reset()
3282 if (!(ioc->facts.IOCCapabilities & in _base_send_ioc_reset()
3286 pr_info(MPT3SAS_FMT "sending message unit reset !!\n", ioc->name); in _base_send_ioc_reset()
3289 &ioc->chip->Doorbell); in _base_send_ioc_reset()
3290 if ((_base_wait_for_doorbell_ack(ioc, 15, sleep_flag))) { in _base_send_ioc_reset()
3294 ioc_state = _base_wait_on_iocstate(ioc, MPI2_IOC_STATE_READY, in _base_send_ioc_reset()
3299 ioc->name, __func__, ioc_state); in _base_send_ioc_reset()
3305 ioc->name, ((r == 0) ? "SUCCESS" : "FAILED")); in _base_send_ioc_reset()
3322 _base_handshake_req_reply_wait(struct MPT3SAS_ADAPTER *ioc, int request_bytes, in _base_handshake_req_reply_wait() argument
3332 if ((readl(&ioc->chip->Doorbell) & MPI2_DOORBELL_USED)) { in _base_handshake_req_reply_wait()
3335 ioc->name, __LINE__); in _base_handshake_req_reply_wait()
3340 if (readl(&ioc->chip->HostInterruptStatus) & in _base_handshake_req_reply_wait()
3342 writel(0, &ioc->chip->HostInterruptStatus); in _base_handshake_req_reply_wait()
3347 &ioc->chip->Doorbell); in _base_handshake_req_reply_wait()
3349 if ((_base_wait_for_doorbell_int(ioc, 5, NO_SLEEP))) { in _base_handshake_req_reply_wait()
3352 ioc->name, __LINE__); in _base_handshake_req_reply_wait()
3355 writel(0, &ioc->chip->HostInterruptStatus); in _base_handshake_req_reply_wait()
3357 if ((_base_wait_for_doorbell_ack(ioc, 5, sleep_flag))) { in _base_handshake_req_reply_wait()
3360 ioc->name, __LINE__); in _base_handshake_req_reply_wait()
3366 writel(cpu_to_le32(request[i]), &ioc->chip->Doorbell); in _base_handshake_req_reply_wait()
3367 if ((_base_wait_for_doorbell_ack(ioc, 5, sleep_flag))) in _base_handshake_req_reply_wait()
3374 ioc->name, __LINE__); in _base_handshake_req_reply_wait()
3379 if ((_base_wait_for_doorbell_int(ioc, timeout, sleep_flag))) { in _base_handshake_req_reply_wait()
3382 ioc->name, __LINE__); in _base_handshake_req_reply_wait()
3387 reply[0] = le16_to_cpu(readl(&ioc->chip->Doorbell) in _base_handshake_req_reply_wait()
3389 writel(0, &ioc->chip->HostInterruptStatus); in _base_handshake_req_reply_wait()
3390 if ((_base_wait_for_doorbell_int(ioc, 5, sleep_flag))) { in _base_handshake_req_reply_wait()
3393 ioc->name, __LINE__); in _base_handshake_req_reply_wait()
3396 reply[1] = le16_to_cpu(readl(&ioc->chip->Doorbell) in _base_handshake_req_reply_wait()
3398 writel(0, &ioc->chip->HostInterruptStatus); in _base_handshake_req_reply_wait()
3401 if ((_base_wait_for_doorbell_int(ioc, 5, sleep_flag))) { in _base_handshake_req_reply_wait()
3404 ioc->name, __LINE__); in _base_handshake_req_reply_wait()
3408 dummy = readl(&ioc->chip->Doorbell); in _base_handshake_req_reply_wait()
3410 reply[i] = le16_to_cpu(readl(&ioc->chip->Doorbell) in _base_handshake_req_reply_wait()
3412 writel(0, &ioc->chip->HostInterruptStatus); in _base_handshake_req_reply_wait()
3415 _base_wait_for_doorbell_int(ioc, 5, sleep_flag); in _base_handshake_req_reply_wait()
3416 if (_base_wait_for_doorbell_not_used(ioc, 5, sleep_flag) != 0) { in _base_handshake_req_reply_wait()
3417 dhsprintk(ioc, pr_info(MPT3SAS_FMT in _base_handshake_req_reply_wait()
3418 "doorbell is in use (line=%d)\n", ioc->name, __LINE__)); in _base_handshake_req_reply_wait()
3420 writel(0, &ioc->chip->HostInterruptStatus); in _base_handshake_req_reply_wait()
3422 if (ioc->logging_level & MPT_DEBUG_INIT) { in _base_handshake_req_reply_wait()
3447 mpt3sas_base_sas_iounit_control(struct MPT3SAS_ADAPTER *ioc, in mpt3sas_base_sas_iounit_control() argument
3459 dinitprintk(ioc, pr_info(MPT3SAS_FMT "%s\n", ioc->name, in mpt3sas_base_sas_iounit_control()
3462 mutex_lock(&ioc->base_cmds.mutex); in mpt3sas_base_sas_iounit_control()
3464 if (ioc->base_cmds.status != MPT3_CMD_NOT_USED) { in mpt3sas_base_sas_iounit_control()
3466 ioc->name, __func__); in mpt3sas_base_sas_iounit_control()
3472 ioc_state = mpt3sas_base_get_iocstate(ioc, 1); in mpt3sas_base_sas_iounit_control()
3477 ioc->name, __func__); in mpt3sas_base_sas_iounit_control()
3482 ioc_state = mpt3sas_base_get_iocstate(ioc, 1); in mpt3sas_base_sas_iounit_control()
3485 ioc->name, __func__, wait_state_count); in mpt3sas_base_sas_iounit_control()
3488 smid = mpt3sas_base_get_smid(ioc, ioc->base_cb_idx); in mpt3sas_base_sas_iounit_control()
3491 ioc->name, __func__); in mpt3sas_base_sas_iounit_control()
3497 ioc->base_cmds.status = MPT3_CMD_PENDING; in mpt3sas_base_sas_iounit_control()
3498 request = mpt3sas_base_get_msg_frame(ioc, smid); in mpt3sas_base_sas_iounit_control()
3499 ioc->base_cmds.smid = smid; in mpt3sas_base_sas_iounit_control()
3503 ioc->ioc_link_reset_in_progress = 1; in mpt3sas_base_sas_iounit_control()
3504 init_completion(&ioc->base_cmds.done); in mpt3sas_base_sas_iounit_control()
3505 mpt3sas_base_put_smid_default(ioc, smid); in mpt3sas_base_sas_iounit_control()
3506 timeleft = wait_for_completion_timeout(&ioc->base_cmds.done, in mpt3sas_base_sas_iounit_control()
3510 ioc->ioc_link_reset_in_progress) in mpt3sas_base_sas_iounit_control()
3511 ioc->ioc_link_reset_in_progress = 0; in mpt3sas_base_sas_iounit_control()
3512 if (!(ioc->base_cmds.status & MPT3_CMD_COMPLETE)) { in mpt3sas_base_sas_iounit_control()
3514 ioc->name, __func__); in mpt3sas_base_sas_iounit_control()
3517 if (!(ioc->base_cmds.status & MPT3_CMD_RESET)) in mpt3sas_base_sas_iounit_control()
3521 if (ioc->base_cmds.status & MPT3_CMD_REPLY_VALID) in mpt3sas_base_sas_iounit_control()
3522 memcpy(mpi_reply, ioc->base_cmds.reply, in mpt3sas_base_sas_iounit_control()
3526 ioc->base_cmds.status = MPT3_CMD_NOT_USED; in mpt3sas_base_sas_iounit_control()
3531 mpt3sas_base_hard_reset_handler(ioc, CAN_SLEEP, in mpt3sas_base_sas_iounit_control()
3533 ioc->base_cmds.status = MPT3_CMD_NOT_USED; in mpt3sas_base_sas_iounit_control()
3536 mutex_unlock(&ioc->base_cmds.mutex); in mpt3sas_base_sas_iounit_control()
3552 mpt3sas_base_scsi_enclosure_processor(struct MPT3SAS_ADAPTER *ioc, in mpt3sas_base_scsi_enclosure_processor() argument
3563 dinitprintk(ioc, pr_info(MPT3SAS_FMT "%s\n", ioc->name, in mpt3sas_base_scsi_enclosure_processor()
3566 mutex_lock(&ioc->base_cmds.mutex); in mpt3sas_base_scsi_enclosure_processor()
3568 if (ioc->base_cmds.status != MPT3_CMD_NOT_USED) { in mpt3sas_base_scsi_enclosure_processor()
3570 ioc->name, __func__); in mpt3sas_base_scsi_enclosure_processor()
3576 ioc_state = mpt3sas_base_get_iocstate(ioc, 1); in mpt3sas_base_scsi_enclosure_processor()
3581 ioc->name, __func__); in mpt3sas_base_scsi_enclosure_processor()
3586 ioc_state = mpt3sas_base_get_iocstate(ioc, 1); in mpt3sas_base_scsi_enclosure_processor()
3589 ioc->name, in mpt3sas_base_scsi_enclosure_processor()
3593 smid = mpt3sas_base_get_smid(ioc, ioc->base_cb_idx); in mpt3sas_base_scsi_enclosure_processor()
3596 ioc->name, __func__); in mpt3sas_base_scsi_enclosure_processor()
3602 ioc->base_cmds.status = MPT3_CMD_PENDING; in mpt3sas_base_scsi_enclosure_processor()
3603 request = mpt3sas_base_get_msg_frame(ioc, smid); in mpt3sas_base_scsi_enclosure_processor()
3604 ioc->base_cmds.smid = smid; in mpt3sas_base_scsi_enclosure_processor()
3606 init_completion(&ioc->base_cmds.done); in mpt3sas_base_scsi_enclosure_processor()
3607 mpt3sas_base_put_smid_default(ioc, smid); in mpt3sas_base_scsi_enclosure_processor()
3608 timeleft = wait_for_completion_timeout(&ioc->base_cmds.done, in mpt3sas_base_scsi_enclosure_processor()
3610 if (!(ioc->base_cmds.status & MPT3_CMD_COMPLETE)) { in mpt3sas_base_scsi_enclosure_processor()
3612 ioc->name, __func__); in mpt3sas_base_scsi_enclosure_processor()
3615 if (!(ioc->base_cmds.status & MPT3_CMD_RESET)) in mpt3sas_base_scsi_enclosure_processor()
3619 if (ioc->base_cmds.status & MPT3_CMD_REPLY_VALID) in mpt3sas_base_scsi_enclosure_processor()
3620 memcpy(mpi_reply, ioc->base_cmds.reply, in mpt3sas_base_scsi_enclosure_processor()
3624 ioc->base_cmds.status = MPT3_CMD_NOT_USED; in mpt3sas_base_scsi_enclosure_processor()
3629 mpt3sas_base_hard_reset_handler(ioc, CAN_SLEEP, in mpt3sas_base_scsi_enclosure_processor()
3631 ioc->base_cmds.status = MPT3_CMD_NOT_USED; in mpt3sas_base_scsi_enclosure_processor()
3634 mutex_unlock(&ioc->base_cmds.mutex); in mpt3sas_base_scsi_enclosure_processor()
3646 _base_get_port_facts(struct MPT3SAS_ADAPTER *ioc, int port, int sleep_flag) in _base_get_port_facts() argument
3653 dinitprintk(ioc, pr_info(MPT3SAS_FMT "%s\n", ioc->name, in _base_get_port_facts()
3661 r = _base_handshake_req_reply_wait(ioc, mpi_request_sz, in _base_get_port_facts()
3666 ioc->name, __func__, r); in _base_get_port_facts()
3670 pfacts = &ioc->pfacts[port]; in _base_get_port_facts()
3689 _base_get_ioc_facts(struct MPT3SAS_ADAPTER *ioc, int sleep_flag) in _base_get_ioc_facts() argument
3696 dinitprintk(ioc, pr_info(MPT3SAS_FMT "%s\n", ioc->name, in _base_get_ioc_facts()
3703 r = _base_handshake_req_reply_wait(ioc, mpi_request_sz, in _base_get_ioc_facts()
3708 ioc->name, __func__, r); in _base_get_ioc_facts()
3712 facts = &ioc->facts; in _base_get_ioc_facts()
3729 ioc->ir_firmware = 1; in _base_get_ioc_facts()
3732 ioc->rdpq_array_capable = 1; in _base_get_ioc_facts()
3738 ioc->shost->max_id = -1; in _base_get_ioc_facts()
3747 dinitprintk(ioc, pr_info(MPT3SAS_FMT in _base_get_ioc_facts()
3749 ioc->name, facts->RequestCredit, in _base_get_ioc_facts()
3751 dinitprintk(ioc, pr_info(MPT3SAS_FMT in _base_get_ioc_facts()
3752 "request frame size(%d), reply frame size(%d)\n", ioc->name, in _base_get_ioc_facts()
3765 _base_send_ioc_init(struct MPT3SAS_ADAPTER *ioc, int sleep_flag) in _base_send_ioc_init() argument
3776 dinitprintk(ioc, pr_info(MPT3SAS_FMT "%s\n", ioc->name, in _base_send_ioc_init()
3787 if (_base_is_controller_msix_enabled(ioc)) in _base_send_ioc_init()
3788 mpi_request.HostMSIxVectors = ioc->reply_queue_count; in _base_send_ioc_init()
3789 mpi_request.SystemRequestFrameSize = cpu_to_le16(ioc->request_sz/4); in _base_send_ioc_init()
3791 cpu_to_le16(ioc->reply_post_queue_depth); in _base_send_ioc_init()
3793 cpu_to_le16(ioc->reply_free_queue_depth); in _base_send_ioc_init()
3796 cpu_to_le32((u64)ioc->sense_dma >> 32); in _base_send_ioc_init()
3798 cpu_to_le32((u64)ioc->reply_dma >> 32); in _base_send_ioc_init()
3800 cpu_to_le64((u64)ioc->request_dma); in _base_send_ioc_init()
3802 cpu_to_le64((u64)ioc->reply_free_dma); in _base_send_ioc_init()
3804 if (ioc->rdpq_array_enable) { in _base_send_ioc_init()
3805 reply_post_free_array_sz = ioc->reply_queue_count * in _base_send_ioc_init()
3807 reply_post_free_array = pci_alloc_consistent(ioc->pdev, in _base_send_ioc_init()
3812 ioc->name); in _base_send_ioc_init()
3817 for (i = 0; i < ioc->reply_queue_count; i++) in _base_send_ioc_init()
3820 (u64)ioc->reply_post[i].reply_post_free_dma); in _base_send_ioc_init()
3826 cpu_to_le64((u64)ioc->reply_post[0].reply_post_free_dma); in _base_send_ioc_init()
3836 if (ioc->logging_level & MPT_DEBUG_INIT) { in _base_send_ioc_init()
3847 r = _base_handshake_req_reply_wait(ioc, in _base_send_ioc_init()
3854 ioc->name, __func__, r); in _base_send_ioc_init()
3861 pr_err(MPT3SAS_FMT "%s: failed\n", ioc->name, __func__); in _base_send_ioc_init()
3867 pci_free_consistent(ioc->pdev, reply_post_free_array_sz, in _base_send_ioc_init()
3884 mpt3sas_port_enable_done(struct MPT3SAS_ADAPTER *ioc, u16 smid, u8 msix_index, in mpt3sas_port_enable_done() argument
3890 if (ioc->port_enable_cmds.status == MPT3_CMD_NOT_USED) in mpt3sas_port_enable_done()
3893 mpi_reply = mpt3sas_base_get_reply_virt_addr(ioc, reply); in mpt3sas_port_enable_done()
3900 ioc->port_enable_cmds.status &= ~MPT3_CMD_PENDING; in mpt3sas_port_enable_done()
3901 ioc->port_enable_cmds.status |= MPT3_CMD_COMPLETE; in mpt3sas_port_enable_done()
3902 ioc->port_enable_cmds.status |= MPT3_CMD_REPLY_VALID; in mpt3sas_port_enable_done()
3903 memcpy(ioc->port_enable_cmds.reply, mpi_reply, mpi_reply->MsgLength*4); in mpt3sas_port_enable_done()
3906 ioc->port_enable_failed = 1; in mpt3sas_port_enable_done()
3908 if (ioc->is_driver_loading) { in mpt3sas_port_enable_done()
3910 mpt3sas_port_enable_complete(ioc); in mpt3sas_port_enable_done()
3913 ioc->start_scan_failed = ioc_status; in mpt3sas_port_enable_done()
3914 ioc->start_scan = 0; in mpt3sas_port_enable_done()
3918 complete(&ioc->port_enable_cmds.done); in mpt3sas_port_enable_done()
3930 _base_send_port_enable(struct MPT3SAS_ADAPTER *ioc, int sleep_flag) in _base_send_port_enable() argument
3939 pr_info(MPT3SAS_FMT "sending port enable !!\n", ioc->name); in _base_send_port_enable()
3941 if (ioc->port_enable_cmds.status & MPT3_CMD_PENDING) { in _base_send_port_enable()
3943 ioc->name, __func__); in _base_send_port_enable()
3947 smid = mpt3sas_base_get_smid(ioc, ioc->port_enable_cb_idx); in _base_send_port_enable()
3950 ioc->name, __func__); in _base_send_port_enable()
3954 ioc->port_enable_cmds.status = MPT3_CMD_PENDING; in _base_send_port_enable()
3955 mpi_request = mpt3sas_base_get_msg_frame(ioc, smid); in _base_send_port_enable()
3956 ioc->port_enable_cmds.smid = smid; in _base_send_port_enable()
3960 init_completion(&ioc->port_enable_cmds.done); in _base_send_port_enable()
3961 mpt3sas_base_put_smid_default(ioc, smid); in _base_send_port_enable()
3962 timeleft = wait_for_completion_timeout(&ioc->port_enable_cmds.done, in _base_send_port_enable()
3964 if (!(ioc->port_enable_cmds.status & MPT3_CMD_COMPLETE)) { in _base_send_port_enable()
3966 ioc->name, __func__); in _base_send_port_enable()
3969 if (ioc->port_enable_cmds.status & MPT3_CMD_RESET) in _base_send_port_enable()
3976 mpi_reply = ioc->port_enable_cmds.reply; in _base_send_port_enable()
3980 ioc->name, __func__, ioc_status); in _base_send_port_enable()
3986 ioc->port_enable_cmds.status = MPT3_CMD_NOT_USED; in _base_send_port_enable()
3987 pr_info(MPT3SAS_FMT "port enable: %s\n", ioc->name, ((r == 0) ? in _base_send_port_enable()
3999 mpt3sas_port_enable(struct MPT3SAS_ADAPTER *ioc) in mpt3sas_port_enable() argument
4004 pr_info(MPT3SAS_FMT "sending port enable !!\n", ioc->name); in mpt3sas_port_enable()
4006 if (ioc->port_enable_cmds.status & MPT3_CMD_PENDING) { in mpt3sas_port_enable()
4008 ioc->name, __func__); in mpt3sas_port_enable()
4012 smid = mpt3sas_base_get_smid(ioc, ioc->port_enable_cb_idx); in mpt3sas_port_enable()
4015 ioc->name, __func__); in mpt3sas_port_enable()
4019 ioc->port_enable_cmds.status = MPT3_CMD_PENDING; in mpt3sas_port_enable()
4020 mpi_request = mpt3sas_base_get_msg_frame(ioc, smid); in mpt3sas_port_enable()
4021 ioc->port_enable_cmds.smid = smid; in mpt3sas_port_enable()
4025 mpt3sas_base_put_smid_default(ioc, smid); in mpt3sas_port_enable()
4039 _base_determine_wait_on_discovery(struct MPT3SAS_ADAPTER *ioc) in _base_determine_wait_on_discovery() argument
4047 if (ioc->ir_firmware) in _base_determine_wait_on_discovery()
4051 if (!ioc->bios_pg3.BiosVersion) in _base_determine_wait_on_discovery()
4061 if ((ioc->bios_pg2.CurrentBootDeviceForm & in _base_determine_wait_on_discovery()
4065 (ioc->bios_pg2.ReqBootDeviceForm & in _base_determine_wait_on_discovery()
4069 (ioc->bios_pg2.ReqAltBootDeviceForm & in _base_determine_wait_on_discovery()
4085 _base_unmask_events(struct MPT3SAS_ADAPTER *ioc, u16 event) in _base_unmask_events() argument
4095 ioc->event_masks[0] &= ~desired_event; in _base_unmask_events()
4097 ioc->event_masks[1] &= ~desired_event; in _base_unmask_events()
4099 ioc->event_masks[2] &= ~desired_event; in _base_unmask_events()
4101 ioc->event_masks[3] &= ~desired_event; in _base_unmask_events()
4112 _base_event_notification(struct MPT3SAS_ADAPTER *ioc, int sleep_flag) in _base_event_notification() argument
4120 dinitprintk(ioc, pr_info(MPT3SAS_FMT "%s\n", ioc->name, in _base_event_notification()
4123 if (ioc->base_cmds.status & MPT3_CMD_PENDING) { in _base_event_notification()
4125 ioc->name, __func__); in _base_event_notification()
4129 smid = mpt3sas_base_get_smid(ioc, ioc->base_cb_idx); in _base_event_notification()
4132 ioc->name, __func__); in _base_event_notification()
4135 ioc->base_cmds.status = MPT3_CMD_PENDING; in _base_event_notification()
4136 mpi_request = mpt3sas_base_get_msg_frame(ioc, smid); in _base_event_notification()
4137 ioc->base_cmds.smid = smid; in _base_event_notification()
4144 cpu_to_le32(ioc->event_masks[i]); in _base_event_notification()
4145 init_completion(&ioc->base_cmds.done); in _base_event_notification()
4146 mpt3sas_base_put_smid_default(ioc, smid); in _base_event_notification()
4147 timeleft = wait_for_completion_timeout(&ioc->base_cmds.done, 30*HZ); in _base_event_notification()
4148 if (!(ioc->base_cmds.status & MPT3_CMD_COMPLETE)) { in _base_event_notification()
4150 ioc->name, __func__); in _base_event_notification()
4153 if (ioc->base_cmds.status & MPT3_CMD_RESET) in _base_event_notification()
4158 dinitprintk(ioc, pr_info(MPT3SAS_FMT "%s: complete\n", in _base_event_notification()
4159 ioc->name, __func__)); in _base_event_notification()
4160 ioc->base_cmds.status = MPT3_CMD_NOT_USED; in _base_event_notification()
4173 mpt3sas_base_validate_event_type(struct MPT3SAS_ADAPTER *ioc, u32 *event_type) in mpt3sas_base_validate_event_type() argument
4185 (ioc->event_masks[i] & desired_event)) { in mpt3sas_base_validate_event_type()
4186 ioc->event_masks[i] &= ~desired_event; in mpt3sas_base_validate_event_type()
4196 mutex_lock(&ioc->base_cmds.mutex); in mpt3sas_base_validate_event_type()
4197 _base_event_notification(ioc, CAN_SLEEP); in mpt3sas_base_validate_event_type()
4198 mutex_unlock(&ioc->base_cmds.mutex); in mpt3sas_base_validate_event_type()
4209 _base_diag_reset(struct MPT3SAS_ADAPTER *ioc, int sleep_flag) in _base_diag_reset() argument
4216 pr_info(MPT3SAS_FMT "sending diag reset !!\n", ioc->name); in _base_diag_reset()
4218 drsprintk(ioc, pr_info(MPT3SAS_FMT "clear interrupts\n", in _base_diag_reset()
4219 ioc->name)); in _base_diag_reset()
4226 drsprintk(ioc, pr_info(MPT3SAS_FMT in _base_diag_reset()
4227 "write magic sequence\n", ioc->name)); in _base_diag_reset()
4228 writel(MPI2_WRSEQ_FLUSH_KEY_VALUE, &ioc->chip->WriteSequence); in _base_diag_reset()
4229 writel(MPI2_WRSEQ_1ST_KEY_VALUE, &ioc->chip->WriteSequence); in _base_diag_reset()
4230 writel(MPI2_WRSEQ_2ND_KEY_VALUE, &ioc->chip->WriteSequence); in _base_diag_reset()
4231 writel(MPI2_WRSEQ_3RD_KEY_VALUE, &ioc->chip->WriteSequence); in _base_diag_reset()
4232 writel(MPI2_WRSEQ_4TH_KEY_VALUE, &ioc->chip->WriteSequence); in _base_diag_reset()
4233 writel(MPI2_WRSEQ_5TH_KEY_VALUE, &ioc->chip->WriteSequence); in _base_diag_reset()
4234 writel(MPI2_WRSEQ_6TH_KEY_VALUE, &ioc->chip->WriteSequence); in _base_diag_reset()
4245 host_diagnostic = readl(&ioc->chip->HostDiagnostic); in _base_diag_reset()
4246 drsprintk(ioc, pr_info(MPT3SAS_FMT in _base_diag_reset()
4248 ioc->name, count, host_diagnostic)); in _base_diag_reset()
4252 hcb_size = readl(&ioc->chip->HCBSize); in _base_diag_reset()
4254 drsprintk(ioc, pr_info(MPT3SAS_FMT "diag reset: issued\n", in _base_diag_reset()
4255 ioc->name)); in _base_diag_reset()
4257 &ioc->chip->HostDiagnostic); in _base_diag_reset()
4269 host_diagnostic = readl(&ioc->chip->HostDiagnostic); in _base_diag_reset()
4287 drsprintk(ioc, pr_info(MPT3SAS_FMT in _base_diag_reset()
4289 ioc->name)); in _base_diag_reset()
4292 writel(host_diagnostic, &ioc->chip->HostDiagnostic); in _base_diag_reset()
4294 drsprintk(ioc, pr_info(MPT3SAS_FMT in _base_diag_reset()
4295 "re-enable the HCDW\n", ioc->name)); in _base_diag_reset()
4297 &ioc->chip->HCBSize); in _base_diag_reset()
4300 drsprintk(ioc, pr_info(MPT3SAS_FMT "restart the adapter\n", in _base_diag_reset()
4301 ioc->name)); in _base_diag_reset()
4303 &ioc->chip->HostDiagnostic); in _base_diag_reset()
4305 drsprintk(ioc, pr_info(MPT3SAS_FMT in _base_diag_reset()
4306 "disable writes to the diagnostic register\n", ioc->name)); in _base_diag_reset()
4307 writel(MPI2_WRSEQ_FLUSH_KEY_VALUE, &ioc->chip->WriteSequence); in _base_diag_reset()
4309 drsprintk(ioc, pr_info(MPT3SAS_FMT in _base_diag_reset()
4310 "Wait for FW to go to the READY state\n", ioc->name)); in _base_diag_reset()
4311 ioc_state = _base_wait_on_iocstate(ioc, MPI2_IOC_STATE_READY, 20, in _base_diag_reset()
4316 ioc->name, __func__, ioc_state); in _base_diag_reset()
4320 pr_info(MPT3SAS_FMT "diag reset: SUCCESS\n", ioc->name); in _base_diag_reset()
4324 pr_err(MPT3SAS_FMT "diag reset: FAILED\n", ioc->name); in _base_diag_reset()
4337 _base_make_ioc_ready(struct MPT3SAS_ADAPTER *ioc, int sleep_flag, in _base_make_ioc_ready() argument
4344 dinitprintk(ioc, pr_info(MPT3SAS_FMT "%s\n", ioc->name, in _base_make_ioc_ready()
4347 if (ioc->pci_error_recovery) in _base_make_ioc_ready()
4350 ioc_state = mpt3sas_base_get_iocstate(ioc, 0); in _base_make_ioc_ready()
4351 dhsprintk(ioc, pr_info(MPT3SAS_FMT "%s: ioc_state(0x%08x)\n", in _base_make_ioc_ready()
4352 ioc->name, __func__, ioc_state)); in _base_make_ioc_ready()
4362 ioc->name, __func__, ioc_state); in _base_make_ioc_ready()
4369 ioc_state = mpt3sas_base_get_iocstate(ioc, 0); in _base_make_ioc_ready()
4377 dhsprintk(ioc, pr_info(MPT3SAS_FMT in _base_make_ioc_ready()
4379 ioc->name)); in _base_make_ioc_ready()
4384 mpt3sas_base_fault_info(ioc, ioc_state & in _base_make_ioc_ready()
4393 if (!(_base_send_ioc_reset(ioc, in _base_make_ioc_ready()
4399 rc = _base_diag_reset(ioc, CAN_SLEEP); in _base_make_ioc_ready()
4411 _base_make_ioc_operational(struct MPT3SAS_ADAPTER *ioc, int sleep_flag) in _base_make_ioc_operational() argument
4422 dinitprintk(ioc, pr_info(MPT3SAS_FMT "%s\n", ioc->name, in _base_make_ioc_operational()
4427 &ioc->delayed_tr_list, list) { in _base_make_ioc_operational()
4434 &ioc->delayed_tr_volume_list, list) { in _base_make_ioc_operational()
4440 spin_lock_irqsave(&ioc->scsi_lookup_lock, flags); in _base_make_ioc_operational()
4441 INIT_LIST_HEAD(&ioc->free_list); in _base_make_ioc_operational()
4443 for (i = 0; i < ioc->scsiio_depth; i++, smid++) { in _base_make_ioc_operational()
4444 INIT_LIST_HEAD(&ioc->scsi_lookup[i].chain_list); in _base_make_ioc_operational()
4445 ioc->scsi_lookup[i].cb_idx = 0xFF; in _base_make_ioc_operational()
4446 ioc->scsi_lookup[i].smid = smid; in _base_make_ioc_operational()
4447 ioc->scsi_lookup[i].scmd = NULL; in _base_make_ioc_operational()
4448 list_add_tail(&ioc->scsi_lookup[i].tracker_list, in _base_make_ioc_operational()
4449 &ioc->free_list); in _base_make_ioc_operational()
4453 INIT_LIST_HEAD(&ioc->hpr_free_list); in _base_make_ioc_operational()
4454 smid = ioc->hi_priority_smid; in _base_make_ioc_operational()
4455 for (i = 0; i < ioc->hi_priority_depth; i++, smid++) { in _base_make_ioc_operational()
4456 ioc->hpr_lookup[i].cb_idx = 0xFF; in _base_make_ioc_operational()
4457 ioc->hpr_lookup[i].smid = smid; in _base_make_ioc_operational()
4458 list_add_tail(&ioc->hpr_lookup[i].tracker_list, in _base_make_ioc_operational()
4459 &ioc->hpr_free_list); in _base_make_ioc_operational()
4463 INIT_LIST_HEAD(&ioc->internal_free_list); in _base_make_ioc_operational()
4464 smid = ioc->internal_smid; in _base_make_ioc_operational()
4465 for (i = 0; i < ioc->internal_depth; i++, smid++) { in _base_make_ioc_operational()
4466 ioc->internal_lookup[i].cb_idx = 0xFF; in _base_make_ioc_operational()
4467 ioc->internal_lookup[i].smid = smid; in _base_make_ioc_operational()
4468 list_add_tail(&ioc->internal_lookup[i].tracker_list, in _base_make_ioc_operational()
4469 &ioc->internal_free_list); in _base_make_ioc_operational()
4473 INIT_LIST_HEAD(&ioc->free_chain_list); in _base_make_ioc_operational()
4474 for (i = 0; i < ioc->chain_depth; i++) in _base_make_ioc_operational()
4475 list_add_tail(&ioc->chain_lookup[i].tracker_list, in _base_make_ioc_operational()
4476 &ioc->free_chain_list); in _base_make_ioc_operational()
4478 spin_unlock_irqrestore(&ioc->scsi_lookup_lock, flags); in _base_make_ioc_operational()
4481 for (i = 0, reply_address = (u32)ioc->reply_dma ; in _base_make_ioc_operational()
4482 i < ioc->reply_free_queue_depth ; i++, reply_address += in _base_make_ioc_operational()
4483 ioc->reply_sz) in _base_make_ioc_operational()
4484 ioc->reply_free[i] = cpu_to_le32(reply_address); in _base_make_ioc_operational()
4487 if (ioc->is_driver_loading) in _base_make_ioc_operational()
4488 _base_assign_reply_queues(ioc); in _base_make_ioc_operational()
4491 reply_post_free_sz = ioc->reply_post_queue_depth * in _base_make_ioc_operational()
4493 reply_post_free = (long)ioc->reply_post[index].reply_post_free; in _base_make_ioc_operational()
4494 list_for_each_entry(reply_q, &ioc->reply_queue_list, list) { in _base_make_ioc_operational()
4498 for (i = 0; i < ioc->reply_post_queue_depth; i++) in _base_make_ioc_operational()
4501 if (!_base_is_controller_msix_enabled(ioc)) in _base_make_ioc_operational()
4507 if (ioc->rdpq_array_enable) in _base_make_ioc_operational()
4509 ioc->reply_post[++index].reply_post_free; in _base_make_ioc_operational()
4515 r = _base_send_ioc_init(ioc, sleep_flag); in _base_make_ioc_operational()
4520 ioc->reply_free_host_index = ioc->reply_free_queue_depth - 1; in _base_make_ioc_operational()
4521 writel(ioc->reply_free_host_index, &ioc->chip->ReplyFreeHostIndex); in _base_make_ioc_operational()
4524 list_for_each_entry(reply_q, &ioc->reply_queue_list, list) { in _base_make_ioc_operational()
4526 &ioc->chip->ReplyPostHostIndex); in _base_make_ioc_operational()
4527 if (!_base_is_controller_msix_enabled(ioc)) in _base_make_ioc_operational()
4533 _base_unmask_interrupts(ioc); in _base_make_ioc_operational()
4534 r = _base_event_notification(ioc, sleep_flag); in _base_make_ioc_operational()
4539 _base_static_config_pages(ioc); in _base_make_ioc_operational()
4542 if (ioc->is_driver_loading) { in _base_make_ioc_operational()
4543 ioc->wait_for_discovery_to_complete = in _base_make_ioc_operational()
4544 _base_determine_wait_on_discovery(ioc); in _base_make_ioc_operational()
4549 r = _base_send_port_enable(ioc, sleep_flag); in _base_make_ioc_operational()
4563 mpt3sas_base_free_resources(struct MPT3SAS_ADAPTER *ioc) in mpt3sas_base_free_resources() argument
4565 struct pci_dev *pdev = ioc->pdev; in mpt3sas_base_free_resources()
4567 dexitprintk(ioc, pr_info(MPT3SAS_FMT "%s\n", ioc->name, in mpt3sas_base_free_resources()
4570 if (ioc->chip_phys && ioc->chip) { in mpt3sas_base_free_resources()
4571 _base_mask_interrupts(ioc); in mpt3sas_base_free_resources()
4572 ioc->shost_recovery = 1; in mpt3sas_base_free_resources()
4573 _base_make_ioc_ready(ioc, CAN_SLEEP, SOFT_RESET); in mpt3sas_base_free_resources()
4574 ioc->shost_recovery = 0; in mpt3sas_base_free_resources()
4577 _base_free_irq(ioc); in mpt3sas_base_free_resources()
4578 _base_disable_msix(ioc); in mpt3sas_base_free_resources()
4580 if (ioc->chip_phys && ioc->chip) in mpt3sas_base_free_resources()
4581 iounmap(ioc->chip); in mpt3sas_base_free_resources()
4582 ioc->chip_phys = 0; in mpt3sas_base_free_resources()
4585 pci_release_selected_regions(ioc->pdev, ioc->bars); in mpt3sas_base_free_resources()
4599 mpt3sas_base_attach(struct MPT3SAS_ADAPTER *ioc) in mpt3sas_base_attach() argument
4604 dinitprintk(ioc, pr_info(MPT3SAS_FMT "%s\n", ioc->name, in mpt3sas_base_attach()
4608 ioc->cpu_count = num_online_cpus(); in mpt3sas_base_attach()
4611 ioc->cpu_msix_table_sz = last_cpu_id + 1; in mpt3sas_base_attach()
4612 ioc->cpu_msix_table = kzalloc(ioc->cpu_msix_table_sz, GFP_KERNEL); in mpt3sas_base_attach()
4613 ioc->reply_queue_count = 1; in mpt3sas_base_attach()
4614 if (!ioc->cpu_msix_table) { in mpt3sas_base_attach()
4615 dfailprintk(ioc, pr_info(MPT3SAS_FMT in mpt3sas_base_attach()
4617 ioc->name)); in mpt3sas_base_attach()
4622 ioc->rdpq_array_enable_assigned = 0; in mpt3sas_base_attach()
4623 ioc->dma_mask = 0; in mpt3sas_base_attach()
4624 r = mpt3sas_base_map_resources(ioc); in mpt3sas_base_attach()
4629 pci_set_drvdata(ioc->pdev, ioc->shost); in mpt3sas_base_attach()
4630 r = _base_get_ioc_facts(ioc, CAN_SLEEP); in mpt3sas_base_attach()
4641 ioc->build_sg_scmd = &_base_build_sg_scmd_ieee; in mpt3sas_base_attach()
4642 ioc->build_sg = &_base_build_sg_ieee; in mpt3sas_base_attach()
4643 ioc->build_zero_len_sge = &_base_build_zero_len_sge_ieee; in mpt3sas_base_attach()
4644 ioc->mpi25 = 1; in mpt3sas_base_attach()
4645 ioc->sge_size_ieee = sizeof(Mpi2IeeeSgeSimple64_t); in mpt3sas_base_attach()
4653 ioc->build_sg_mpi = &_base_build_sg; in mpt3sas_base_attach()
4654 ioc->build_zero_len_sge_mpi = &_base_build_zero_len_sge; in mpt3sas_base_attach()
4656 r = _base_make_ioc_ready(ioc, CAN_SLEEP, SOFT_RESET); in mpt3sas_base_attach()
4660 ioc->pfacts = kcalloc(ioc->facts.NumberOfPorts, in mpt3sas_base_attach()
4662 if (!ioc->pfacts) { in mpt3sas_base_attach()
4667 for (i = 0 ; i < ioc->facts.NumberOfPorts; i++) { in mpt3sas_base_attach()
4668 r = _base_get_port_facts(ioc, i, CAN_SLEEP); in mpt3sas_base_attach()
4673 r = _base_allocate_memory_pools(ioc, CAN_SLEEP); in mpt3sas_base_attach()
4677 init_waitqueue_head(&ioc->reset_wq); in mpt3sas_base_attach()
4680 ioc->pd_handles_sz = (ioc->facts.MaxDevHandle / 8); in mpt3sas_base_attach()
4681 if (ioc->facts.MaxDevHandle % 8) in mpt3sas_base_attach()
4682 ioc->pd_handles_sz++; in mpt3sas_base_attach()
4683 ioc->pd_handles = kzalloc(ioc->pd_handles_sz, in mpt3sas_base_attach()
4685 if (!ioc->pd_handles) { in mpt3sas_base_attach()
4689 ioc->blocking_handles = kzalloc(ioc->pd_handles_sz, in mpt3sas_base_attach()
4691 if (!ioc->blocking_handles) { in mpt3sas_base_attach()
4696 ioc->fwfault_debug = mpt3sas_fwfault_debug; in mpt3sas_base_attach()
4699 mutex_init(&ioc->base_cmds.mutex); in mpt3sas_base_attach()
4700 ioc->base_cmds.reply = kzalloc(ioc->reply_sz, GFP_KERNEL); in mpt3sas_base_attach()
4701 ioc->base_cmds.status = MPT3_CMD_NOT_USED; in mpt3sas_base_attach()
4704 ioc->port_enable_cmds.reply = kzalloc(ioc->reply_sz, GFP_KERNEL); in mpt3sas_base_attach()
4705 ioc->port_enable_cmds.status = MPT3_CMD_NOT_USED; in mpt3sas_base_attach()
4708 ioc->transport_cmds.reply = kzalloc(ioc->reply_sz, GFP_KERNEL); in mpt3sas_base_attach()
4709 ioc->transport_cmds.status = MPT3_CMD_NOT_USED; in mpt3sas_base_attach()
4710 mutex_init(&ioc->transport_cmds.mutex); in mpt3sas_base_attach()
4713 ioc->scsih_cmds.reply = kzalloc(ioc->reply_sz, GFP_KERNEL); in mpt3sas_base_attach()
4714 ioc->scsih_cmds.status = MPT3_CMD_NOT_USED; in mpt3sas_base_attach()
4715 mutex_init(&ioc->scsih_cmds.mutex); in mpt3sas_base_attach()
4718 ioc->tm_cmds.reply = kzalloc(ioc->reply_sz, GFP_KERNEL); in mpt3sas_base_attach()
4719 ioc->tm_cmds.status = MPT3_CMD_NOT_USED; in mpt3sas_base_attach()
4720 mutex_init(&ioc->tm_cmds.mutex); in mpt3sas_base_attach()
4723 ioc->config_cmds.reply = kzalloc(ioc->reply_sz, GFP_KERNEL); in mpt3sas_base_attach()
4724 ioc->config_cmds.status = MPT3_CMD_NOT_USED; in mpt3sas_base_attach()
4725 mutex_init(&ioc->config_cmds.mutex); in mpt3sas_base_attach()
4728 ioc->ctl_cmds.reply = kzalloc(ioc->reply_sz, GFP_KERNEL); in mpt3sas_base_attach()
4729 ioc->ctl_cmds.sense = kzalloc(SCSI_SENSE_BUFFERSIZE, GFP_KERNEL); in mpt3sas_base_attach()
4730 ioc->ctl_cmds.status = MPT3_CMD_NOT_USED; in mpt3sas_base_attach()
4731 mutex_init(&ioc->ctl_cmds.mutex); in mpt3sas_base_attach()
4733 if (!ioc->base_cmds.reply || !ioc->transport_cmds.reply || in mpt3sas_base_attach()
4734 !ioc->scsih_cmds.reply || !ioc->tm_cmds.reply || in mpt3sas_base_attach()
4735 !ioc->config_cmds.reply || !ioc->ctl_cmds.reply || in mpt3sas_base_attach()
4736 !ioc->ctl_cmds.sense) { in mpt3sas_base_attach()
4742 ioc->event_masks[i] = -1; in mpt3sas_base_attach()
4745 _base_unmask_events(ioc, MPI2_EVENT_SAS_DISCOVERY); in mpt3sas_base_attach()
4746 _base_unmask_events(ioc, MPI2_EVENT_SAS_BROADCAST_PRIMITIVE); in mpt3sas_base_attach()
4747 _base_unmask_events(ioc, MPI2_EVENT_SAS_TOPOLOGY_CHANGE_LIST); in mpt3sas_base_attach()
4748 _base_unmask_events(ioc, MPI2_EVENT_SAS_DEVICE_STATUS_CHANGE); in mpt3sas_base_attach()
4749 _base_unmask_events(ioc, MPI2_EVENT_SAS_ENCL_DEVICE_STATUS_CHANGE); in mpt3sas_base_attach()
4750 _base_unmask_events(ioc, MPI2_EVENT_IR_CONFIGURATION_CHANGE_LIST); in mpt3sas_base_attach()
4751 _base_unmask_events(ioc, MPI2_EVENT_IR_VOLUME); in mpt3sas_base_attach()
4752 _base_unmask_events(ioc, MPI2_EVENT_IR_PHYSICAL_DISK); in mpt3sas_base_attach()
4753 _base_unmask_events(ioc, MPI2_EVENT_IR_OPERATION_STATUS); in mpt3sas_base_attach()
4754 _base_unmask_events(ioc, MPI2_EVENT_LOG_ENTRY_ADDED); in mpt3sas_base_attach()
4755 _base_unmask_events(ioc, MPI2_EVENT_TEMP_THRESHOLD); in mpt3sas_base_attach()
4757 r = _base_make_ioc_operational(ioc, CAN_SLEEP); in mpt3sas_base_attach()
4765 ioc->remove_host = 1; in mpt3sas_base_attach()
4767 mpt3sas_base_free_resources(ioc); in mpt3sas_base_attach()
4768 _base_release_memory_pools(ioc); in mpt3sas_base_attach()
4769 pci_set_drvdata(ioc->pdev, NULL); in mpt3sas_base_attach()
4770 kfree(ioc->cpu_msix_table); in mpt3sas_base_attach()
4771 kfree(ioc->pd_handles); in mpt3sas_base_attach()
4772 kfree(ioc->blocking_handles); in mpt3sas_base_attach()
4773 kfree(ioc->tm_cmds.reply); in mpt3sas_base_attach()
4774 kfree(ioc->transport_cmds.reply); in mpt3sas_base_attach()
4775 kfree(ioc->scsih_cmds.reply); in mpt3sas_base_attach()
4776 kfree(ioc->config_cmds.reply); in mpt3sas_base_attach()
4777 kfree(ioc->base_cmds.reply); in mpt3sas_base_attach()
4778 kfree(ioc->port_enable_cmds.reply); in mpt3sas_base_attach()
4779 kfree(ioc->ctl_cmds.reply); in mpt3sas_base_attach()
4780 kfree(ioc->ctl_cmds.sense); in mpt3sas_base_attach()
4781 kfree(ioc->pfacts); in mpt3sas_base_attach()
4782 ioc->ctl_cmds.reply = NULL; in mpt3sas_base_attach()
4783 ioc->base_cmds.reply = NULL; in mpt3sas_base_attach()
4784 ioc->tm_cmds.reply = NULL; in mpt3sas_base_attach()
4785 ioc->scsih_cmds.reply = NULL; in mpt3sas_base_attach()
4786 ioc->transport_cmds.reply = NULL; in mpt3sas_base_attach()
4787 ioc->config_cmds.reply = NULL; in mpt3sas_base_attach()
4788 ioc->pfacts = NULL; in mpt3sas_base_attach()
4800 mpt3sas_base_detach(struct MPT3SAS_ADAPTER *ioc) in mpt3sas_base_detach() argument
4802 dexitprintk(ioc, pr_info(MPT3SAS_FMT "%s\n", ioc->name, in mpt3sas_base_detach()
4805 mpt3sas_base_stop_watchdog(ioc); in mpt3sas_base_detach()
4806 mpt3sas_base_free_resources(ioc); in mpt3sas_base_detach()
4807 _base_release_memory_pools(ioc); in mpt3sas_base_detach()
4808 pci_set_drvdata(ioc->pdev, NULL); in mpt3sas_base_detach()
4809 kfree(ioc->cpu_msix_table); in mpt3sas_base_detach()
4810 kfree(ioc->pd_handles); in mpt3sas_base_detach()
4811 kfree(ioc->blocking_handles); in mpt3sas_base_detach()
4812 kfree(ioc->pfacts); in mpt3sas_base_detach()
4813 kfree(ioc->ctl_cmds.reply); in mpt3sas_base_detach()
4814 kfree(ioc->ctl_cmds.sense); in mpt3sas_base_detach()
4815 kfree(ioc->base_cmds.reply); in mpt3sas_base_detach()
4816 kfree(ioc->port_enable_cmds.reply); in mpt3sas_base_detach()
4817 kfree(ioc->tm_cmds.reply); in mpt3sas_base_detach()
4818 kfree(ioc->transport_cmds.reply); in mpt3sas_base_detach()
4819 kfree(ioc->scsih_cmds.reply); in mpt3sas_base_detach()
4820 kfree(ioc->config_cmds.reply); in mpt3sas_base_detach()
4836 _base_reset_handler(struct MPT3SAS_ADAPTER *ioc, int reset_phase) in _base_reset_handler() argument
4838 mpt3sas_scsih_reset_handler(ioc, reset_phase); in _base_reset_handler()
4839 mpt3sas_ctl_reset_handler(ioc, reset_phase); in _base_reset_handler()
4842 dtmprintk(ioc, pr_info(MPT3SAS_FMT in _base_reset_handler()
4843 "%s: MPT3_IOC_PRE_RESET\n", ioc->name, __func__)); in _base_reset_handler()
4846 dtmprintk(ioc, pr_info(MPT3SAS_FMT in _base_reset_handler()
4847 "%s: MPT3_IOC_AFTER_RESET\n", ioc->name, __func__)); in _base_reset_handler()
4848 if (ioc->transport_cmds.status & MPT3_CMD_PENDING) { in _base_reset_handler()
4849 ioc->transport_cmds.status |= MPT3_CMD_RESET; in _base_reset_handler()
4850 mpt3sas_base_free_smid(ioc, ioc->transport_cmds.smid); in _base_reset_handler()
4851 complete(&ioc->transport_cmds.done); in _base_reset_handler()
4853 if (ioc->base_cmds.status & MPT3_CMD_PENDING) { in _base_reset_handler()
4854 ioc->base_cmds.status |= MPT3_CMD_RESET; in _base_reset_handler()
4855 mpt3sas_base_free_smid(ioc, ioc->base_cmds.smid); in _base_reset_handler()
4856 complete(&ioc->base_cmds.done); in _base_reset_handler()
4858 if (ioc->port_enable_cmds.status & MPT3_CMD_PENDING) { in _base_reset_handler()
4859 ioc->port_enable_failed = 1; in _base_reset_handler()
4860 ioc->port_enable_cmds.status |= MPT3_CMD_RESET; in _base_reset_handler()
4861 mpt3sas_base_free_smid(ioc, ioc->port_enable_cmds.smid); in _base_reset_handler()
4862 if (ioc->is_driver_loading) { in _base_reset_handler()
4863 ioc->start_scan_failed = in _base_reset_handler()
4865 ioc->start_scan = 0; in _base_reset_handler()
4866 ioc->port_enable_cmds.status = in _base_reset_handler()
4869 complete(&ioc->port_enable_cmds.done); in _base_reset_handler()
4871 if (ioc->config_cmds.status & MPT3_CMD_PENDING) { in _base_reset_handler()
4872 ioc->config_cmds.status |= MPT3_CMD_RESET; in _base_reset_handler()
4873 mpt3sas_base_free_smid(ioc, ioc->config_cmds.smid); in _base_reset_handler()
4874 ioc->config_cmds.smid = USHRT_MAX; in _base_reset_handler()
4875 complete(&ioc->config_cmds.done); in _base_reset_handler()
4879 dtmprintk(ioc, pr_info(MPT3SAS_FMT in _base_reset_handler()
4880 "%s: MPT3_IOC_DONE_RESET\n", ioc->name, __func__)); in _base_reset_handler()
4894 _wait_for_commands_to_complete(struct MPT3SAS_ADAPTER *ioc, int sleep_flag) in _wait_for_commands_to_complete() argument
4900 ioc->pending_io_count = 0; in _wait_for_commands_to_complete()
4904 ioc_state = mpt3sas_base_get_iocstate(ioc, 0); in _wait_for_commands_to_complete()
4909 spin_lock_irqsave(&ioc->scsi_lookup_lock, flags); in _wait_for_commands_to_complete()
4910 for (i = 0; i < ioc->scsiio_depth; i++) in _wait_for_commands_to_complete()
4911 if (ioc->scsi_lookup[i].cb_idx != 0xFF) in _wait_for_commands_to_complete()
4912 ioc->pending_io_count++; in _wait_for_commands_to_complete()
4913 spin_unlock_irqrestore(&ioc->scsi_lookup_lock, flags); in _wait_for_commands_to_complete()
4915 if (!ioc->pending_io_count) in _wait_for_commands_to_complete()
4919 wait_event_timeout(ioc->reset_wq, ioc->pending_io_count == 0, 10 * HZ); in _wait_for_commands_to_complete()
4931 mpt3sas_base_hard_reset_handler(struct MPT3SAS_ADAPTER *ioc, int sleep_flag, in mpt3sas_base_hard_reset_handler() argument
4939 dtmprintk(ioc, pr_info(MPT3SAS_FMT "%s: enter\n", ioc->name, in mpt3sas_base_hard_reset_handler()
4942 if (ioc->pci_error_recovery) { in mpt3sas_base_hard_reset_handler()
4944 ioc->name, __func__); in mpt3sas_base_hard_reset_handler()
4950 mpt3sas_halt_firmware(ioc); in mpt3sas_base_hard_reset_handler()
4960 if (!mutex_trylock(&ioc->reset_in_progress_mutex)) { in mpt3sas_base_hard_reset_handler()
4963 } while (ioc->shost_recovery == 1); in mpt3sas_base_hard_reset_handler()
4964 dtmprintk(ioc, pr_info(MPT3SAS_FMT "%s: exit\n", ioc->name, in mpt3sas_base_hard_reset_handler()
4966 return ioc->ioc_reset_in_progress_status; in mpt3sas_base_hard_reset_handler()
4969 spin_lock_irqsave(&ioc->ioc_reset_in_progress_lock, flags); in mpt3sas_base_hard_reset_handler()
4970 ioc->shost_recovery = 1; in mpt3sas_base_hard_reset_handler()
4971 spin_unlock_irqrestore(&ioc->ioc_reset_in_progress_lock, flags); in mpt3sas_base_hard_reset_handler()
4973 if ((ioc->diag_buffer_status[MPI2_DIAG_BUF_TYPE_TRACE] & in mpt3sas_base_hard_reset_handler()
4975 (!(ioc->diag_buffer_status[MPI2_DIAG_BUF_TYPE_TRACE] & in mpt3sas_base_hard_reset_handler()
4978 ioc_state = mpt3sas_base_get_iocstate(ioc, 0); in mpt3sas_base_hard_reset_handler()
4982 _base_reset_handler(ioc, MPT3_IOC_PRE_RESET); in mpt3sas_base_hard_reset_handler()
4983 _wait_for_commands_to_complete(ioc, sleep_flag); in mpt3sas_base_hard_reset_handler()
4984 _base_mask_interrupts(ioc); in mpt3sas_base_hard_reset_handler()
4985 r = _base_make_ioc_ready(ioc, sleep_flag, type); in mpt3sas_base_hard_reset_handler()
4988 _base_reset_handler(ioc, MPT3_IOC_AFTER_RESET); in mpt3sas_base_hard_reset_handler()
4993 if (ioc->is_driver_loading && ioc->port_enable_failed) { in mpt3sas_base_hard_reset_handler()
4994 ioc->remove_host = 1; in mpt3sas_base_hard_reset_handler()
4998 r = _base_get_ioc_facts(ioc, CAN_SLEEP); in mpt3sas_base_hard_reset_handler()
5002 if (ioc->rdpq_array_enable && !ioc->rdpq_array_capable) in mpt3sas_base_hard_reset_handler()
5005 " firmware version is running\n", ioc->name); in mpt3sas_base_hard_reset_handler()
5007 r = _base_make_ioc_operational(ioc, sleep_flag); in mpt3sas_base_hard_reset_handler()
5009 _base_reset_handler(ioc, MPT3_IOC_DONE_RESET); in mpt3sas_base_hard_reset_handler()
5012 dtmprintk(ioc, pr_info(MPT3SAS_FMT "%s: %s\n", in mpt3sas_base_hard_reset_handler()
5013 ioc->name, __func__, ((r == 0) ? "SUCCESS" : "FAILED"))); in mpt3sas_base_hard_reset_handler()
5015 spin_lock_irqsave(&ioc->ioc_reset_in_progress_lock, flags); in mpt3sas_base_hard_reset_handler()
5016 ioc->ioc_reset_in_progress_status = r; in mpt3sas_base_hard_reset_handler()
5017 ioc->shost_recovery = 0; in mpt3sas_base_hard_reset_handler()
5018 spin_unlock_irqrestore(&ioc->ioc_reset_in_progress_lock, flags); in mpt3sas_base_hard_reset_handler()
5019 ioc->ioc_reset_count++; in mpt3sas_base_hard_reset_handler()
5020 mutex_unlock(&ioc->reset_in_progress_mutex); in mpt3sas_base_hard_reset_handler()
5025 mpt3sas_trigger_master(ioc, MASTER_TRIGGER_FW_FAULT); in mpt3sas_base_hard_reset_handler()
5027 mpt3sas_trigger_master(ioc, in mpt3sas_base_hard_reset_handler()
5030 dtmprintk(ioc, pr_info(MPT3SAS_FMT "%s: exit\n", ioc->name, in mpt3sas_base_hard_reset_handler()