• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /asuswrt-rt-n18u-9.0.0.4.380.2695/release/src-rt-6.x.4708/linux/linux-2.6/drivers/scsi/mpt2sas/

Lines Matching defs:ioc

103  * _scsih_set_fwfault_debug - global setting of ioc->fwfault_debug.
110 struct MPT2SAS_ADAPTER *ioc;
116 list_for_each_entry(ioc, &mpt2sas_ioc_list, list)
117 ioc->fwfault_debug = mpt2sas_fwfault_debug;
124 * _base_fault_reset_work - workq handling ioc fault conditions
125 * @work: input argument, used to derive ioc
133 struct MPT2SAS_ADAPTER *ioc =
139 spin_lock_irqsave(&ioc->ioc_reset_in_progress_lock, flags);
140 if (ioc->shost_recovery)
142 spin_unlock_irqrestore(&ioc->ioc_reset_in_progress_lock, flags);
144 doorbell = mpt2sas_base_get_iocstate(ioc, 0);
146 rc = mpt2sas_base_hard_reset_handler(ioc, CAN_SLEEP,
148 printk(MPT2SAS_WARN_FMT "%s: hard reset: %s\n", ioc->name,
150 doorbell = mpt2sas_base_get_iocstate(ioc, 0);
152 mpt2sas_base_fault_info(ioc, doorbell &
156 spin_lock_irqsave(&ioc->ioc_reset_in_progress_lock, flags);
158 if (ioc->fault_reset_work_q)
159 queue_delayed_work(ioc->fault_reset_work_q,
160 &ioc->fault_reset_work,
162 spin_unlock_irqrestore(&ioc->ioc_reset_in_progress_lock, flags);
167 * @ioc: per adapter object
173 mpt2sas_base_start_watchdog(struct MPT2SAS_ADAPTER *ioc)
177 if (ioc->fault_reset_work_q)
181 INIT_DELAYED_WORK(&ioc->fault_reset_work, _base_fault_reset_work);
182 snprintf(ioc->fault_reset_work_q_name,
183 sizeof(ioc->fault_reset_work_q_name), "poll_%d_status", ioc->id);
184 ioc->fault_reset_work_q =
185 create_singlethread_workqueue(ioc->fault_reset_work_q_name);
186 if (!ioc->fault_reset_work_q) {
188 ioc->name, __func__, __LINE__);
191 spin_lock_irqsave(&ioc->ioc_reset_in_progress_lock, flags);
192 if (ioc->fault_reset_work_q)
193 queue_delayed_work(ioc->fault_reset_work_q,
194 &ioc->fault_reset_work,
196 spin_unlock_irqrestore(&ioc->ioc_reset_in_progress_lock, flags);
201 * @ioc: per adapter object
207 mpt2sas_base_stop_watchdog(struct MPT2SAS_ADAPTER *ioc)
212 spin_lock_irqsave(&ioc->ioc_reset_in_progress_lock, flags);
213 wq = ioc->fault_reset_work_q;
214 ioc->fault_reset_work_q = NULL;
215 spin_unlock_irqrestore(&ioc->ioc_reset_in_progress_lock, flags);
217 if (!cancel_delayed_work(&ioc->fault_reset_work))
225 * @ioc: per adapter object
231 mpt2sas_base_fault_info(struct MPT2SAS_ADAPTER *ioc , u16 fault_code)
234 ioc->name, fault_code);
239 * @ioc: per adapter object
247 mpt2sas_halt_firmware(struct MPT2SAS_ADAPTER *ioc)
251 if (!ioc->fwfault_debug)
256 doorbell = readl(&ioc->chip->Doorbell);
258 mpt2sas_base_fault_info(ioc , doorbell);
260 writel(0xC0FFEE00, &ioc->chip->Doorbell);
262 "timeout\n", ioc->name);
270 * _base_sas_ioc_info - verbose translation of the ioc status
271 * @ioc: per adapter object
278 _base_sas_ioc_info(struct MPT2SAS_ADAPTER *ioc, MPI2DefaultReply_t *mpi_reply,
447 frame_sz = sizeof(Mpi2ConfigRequest_t) + ioc->sge_size;
471 frame_sz = sizeof(Mpi2SmpPassthroughRequest_t) + ioc->sge_size;
481 " (%s)\n", ioc->name, desc, ioc_status, request_hdr, func_str);
488 * @ioc: per adapter object
494 _base_display_event_data(struct MPT2SAS_ADAPTER *ioc,
500 if (!(ioc->logging_level & MPT_DEBUG_EVENTS))
531 printk(MPT2SAS_INFO_FMT "Discovery: (%s)", ioc->name,
572 printk(MPT2SAS_INFO_FMT "%s\n", ioc->name, desc);
578 * @ioc: per adapter object
584 _base_sas_log_info(struct MPT2SAS_ADAPTER *ioc , u32 log_info)
607 if (ioc->ignore_loginfos && (log_info == 30050000 || log_info ==
624 "code(0x%02x), sub_code(0x%04x)\n", ioc->name, log_info,
631 * @ioc: per adapter object
639 _base_display_reply_info(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 msix_index,
645 mpi_reply = mpt2sas_base_get_reply_virt_addr(ioc, reply);
649 (ioc->logging_level & MPT_DEBUG_REPLY)) {
650 _base_sas_ioc_info(ioc , mpi_reply,
651 mpt2sas_base_get_msg_frame(ioc, smid));
655 _base_sas_log_info(ioc, le32_to_cpu(mpi_reply->IOCLogInfo));
660 * @ioc: per adapter object
669 mpt2sas_base_done(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 msix_index,
674 mpi_reply = mpt2sas_base_get_reply_virt_addr(ioc, reply);
678 if (ioc->base_cmds.status == MPT2_CMD_NOT_USED)
681 ioc->base_cmds.status |= MPT2_CMD_COMPLETE;
683 ioc->base_cmds.status |= MPT2_CMD_REPLY_VALID;
684 memcpy(ioc->base_cmds.reply, mpi_reply, mpi_reply->MsgLength*4);
686 ioc->base_cmds.status &= ~MPT2_CMD_PENDING;
687 complete(&ioc->base_cmds.done);
693 * @ioc: per adapter object
701 _base_async_event(struct MPT2SAS_ADAPTER *ioc, u8 msix_index, u32 reply)
707 mpi_reply = mpt2sas_base_get_reply_virt_addr(ioc, reply);
713 _base_display_event_data(ioc, mpi_reply);
717 smid = mpt2sas_base_get_smid(ioc, ioc->base_cb_idx);
720 ioc->name, __func__);
724 ack_request = mpt2sas_base_get_msg_frame(ioc, smid);
731 mpt2sas_base_put_smid_default(ioc, smid);
736 mpt2sas_scsih_event_callback(ioc, msix_index, reply);
739 mpt2sas_ctl_event_callback(ioc, msix_index, reply);
746 * @ioc: per adapter object
752 _base_get_cb_idx(struct MPT2SAS_ADAPTER *ioc, u16 smid)
757 if (smid >= ioc->hi_priority_smid) {
758 if (smid < ioc->internal_smid) {
759 i = smid - ioc->hi_priority_smid;
760 cb_idx = ioc->hpr_lookup[i].cb_idx;
762 i = smid - ioc->internal_smid;
763 cb_idx = ioc->internal_lookup[i].cb_idx;
767 cb_idx = ioc->scsi_lookup[i].cb_idx;
774 * @ioc: per adapter object
781 _base_mask_interrupts(struct MPT2SAS_ADAPTER *ioc)
785 ioc->mask_interrupts = 1;
786 him_register = readl(&ioc->chip->HostInterruptMask);
788 writel(him_register, &ioc->chip->HostInterruptMask);
789 readl(&ioc->chip->HostInterruptMask);
794 * @ioc: per adapter object
801 _base_unmask_interrupts(struct MPT2SAS_ADAPTER *ioc)
805 him_register = readl(&ioc->chip->HostInterruptMask);
807 writel(him_register, &ioc->chip->HostInterruptMask);
808 ioc->mask_interrupts = 0;
837 struct MPT2SAS_ADAPTER *ioc = bus_id;
841 if (ioc->mask_interrupts)
844 rpf = &ioc->reply_post_free[ioc->reply_post_host_index];
870 cb_idx = _base_get_cb_idx(ioc, smid);
872 rc = mpt_callbacks[cb_idx](ioc, smid, msix_index,
875 _base_display_reply_info(ioc, smid, msix_index,
878 mpt2sas_base_free_smid(ioc, smid);
881 _base_async_event(ioc, msix_index, reply);
885 ioc->reply_free_host_index =
886 (ioc->reply_free_host_index ==
887 (ioc->reply_free_queue_depth - 1)) ?
888 0 : ioc->reply_free_host_index + 1;
889 ioc->reply_free[ioc->reply_free_host_index] =
892 writel(ioc->reply_free_host_index,
893 &ioc->chip->ReplyFreeHostIndex);
899 ioc->reply_post_host_index = (ioc->reply_post_host_index ==
900 (ioc->reply_post_queue_depth - 1)) ? 0 :
901 ioc->reply_post_host_index + 1;
903 ioc->reply_post_free[ioc->reply_post_host_index].Default.
908 if (!ioc->reply_post_host_index)
909 rpf = ioc->reply_post_free;
920 writel(ioc->reply_post_host_index, &ioc->chip->ReplyPostHostIndex);
971 * @ioc: per adapter object
981 mpt2sas_base_build_zero_len_sge(struct MPT2SAS_ADAPTER *ioc, void *paddr)
987 ioc->base_add_sg_single(paddr, flags_length, -1);
1033 * @ioc: per adapter object
1039 _base_config_dma_addressing(struct MPT2SAS_ADAPTER *ioc, struct pci_dev *pdev)
1050 ioc->base_add_sg_single = &_base_add_sg_single_64;
1051 ioc->sge_size = sizeof(Mpi2SGESimple64_t);
1059 ioc->base_add_sg_single = &_base_add_sg_single_32;
1060 ioc->sge_size = sizeof(Mpi2SGESimple32_t);
1068 "total mem (%ld kB)\n", ioc->name, desc, convert_to_kb(s.totalram));
1075 * @ioc: per adapter object
1080 _base_save_msix_table(struct MPT2SAS_ADAPTER *ioc)
1084 if (!ioc->msix_enable || ioc->msix_table_backup == NULL)
1087 for (i = 0; i < ioc->msix_vector_count; i++)
1088 ioc->msix_table_backup[i] = ioc->msix_table[i];
1093 * @ioc: per adapter object
1097 _base_restore_msix_table(struct MPT2SAS_ADAPTER *ioc)
1101 if (!ioc->msix_enable || ioc->msix_table_backup == NULL)
1104 for (i = 0; i < ioc->msix_vector_count; i++)
1105 ioc->msix_table[i] = ioc->msix_table_backup[i];
1110 * @ioc: per adapter object
1116 _base_check_enable_msix(struct MPT2SAS_ADAPTER *ioc)
1122 base = pci_find_capability(ioc->pdev, PCI_CAP_ID_MSIX);
1124 dfailprintk(ioc, printk(MPT2SAS_INFO_FMT "msix not "
1125 "supported\n", ioc->name));
1130 pci_read_config_word(ioc->pdev, base + 2, &message_control);
1131 ioc->msix_vector_count = (message_control & 0x3FF) + 1;
1134 pci_read_config_dword(ioc->pdev, base + 4, &msix_table_offset);
1136 ioc->msix_table = (u32 *)((void *)ioc->chip + msix_table_offset);
1138 dinitprintk(ioc, printk(MPT2SAS_INFO_FMT "msix is supported, "
1139 "vector_count(%d), table_offset(0x%08x), table(%p)\n", ioc->name,
1140 ioc->msix_vector_count, msix_table_offset, ioc->msix_table));
1146 * @ioc: per adapter object
1150 _base_disable_msix(struct MPT2SAS_ADAPTER *ioc)
1152 if (ioc->msix_enable) {
1153 pci_disable_msix(ioc->pdev);
1154 kfree(ioc->msix_table_backup);
1155 ioc->msix_table_backup = NULL;
1156 ioc->msix_enable = 0;
1162 * @ioc: per adapter object
1166 _base_enable_msix(struct MPT2SAS_ADAPTER *ioc)
1178 if (_base_check_enable_msix(ioc) != 0)
1181 ioc->msix_table_backup = kcalloc(ioc->msix_vector_count,
1183 if (!ioc->msix_table_backup) {
1184 dfailprintk(ioc, printk(MPT2SAS_INFO_FMT "allocation for "
1185 "msix_table_backup failed!!!\n", ioc->name));
1190 r = pci_enable_msix(ioc->pdev, &entries, 1);
1192 dfailprintk(ioc, printk(MPT2SAS_INFO_FMT "pci_enable_msix "
1193 "failed (r=%d) !!!\n", ioc->name, r));
1198 ioc->name, ioc);
1200 dfailprintk(ioc, printk(MPT2SAS_INFO_FMT "unable to allocate "
1201 "interrupt %d !!!\n", ioc->name, entries.vector));
1202 pci_disable_msix(ioc->pdev);
1206 ioc->pci_irq = entries.vector;
1207 ioc->msix_enable = 1;
1213 r = request_irq(ioc->pdev->irq, _base_interrupt, IRQF_SHARED,
1214 ioc->name, ioc);
1217 ioc->name, ioc->pdev->irq);
1222 ioc->pci_irq = ioc->pdev->irq;
1231 * @ioc: per adapter object
1236 mpt2sas_base_map_resources(struct MPT2SAS_ADAPTER *ioc)
1238 struct pci_dev *pdev = ioc->pdev;
1245 dinitprintk(ioc, printk(MPT2SAS_INFO_FMT "%s\n",
1246 ioc->name, __func__));
1248 ioc->bars = pci_select_bars(pdev, IORESOURCE_MEM);
1251 "failed\n", ioc->name);
1256 if (pci_request_selected_regions(pdev, ioc->bars,
1259 "failed\n", ioc->name);
1269 if (_base_config_dma_addressing(ioc, pdev) != 0) {
1271 ioc->name, pci_name(pdev));
1287 ioc->chip_phys = pci_resource_start(pdev, i);
1288 chip_phys = (u64)ioc->chip_phys;
1290 ioc->chip = ioremap(ioc->chip_phys, memap_sz);
1291 if (ioc->chip == NULL) {
1293 "adapter memory!\n", ioc->name);
1301 _base_mask_interrupts(ioc);
1302 r = _base_enable_msix(ioc);
1307 ioc->name, ((ioc->msix_enable) ? "PCI-MSI-X enabled" :
1308 "IO-APIC enabled"), ioc->pci_irq);
1310 ioc->name, (unsigned long long)chip_phys, ioc->chip, memap_sz);
1312 ioc->name, (unsigned long long)pio_chip, pio_sz);
1320 if (ioc->chip_phys)
1321 iounmap(ioc->chip);
1322 ioc->chip_phys = 0;
1323 ioc->pci_irq = -1;
1324 pci_release_selected_regions(ioc->pdev, ioc->bars);
1332 * @ioc: per adapter object
1338 mpt2sas_base_get_msg_frame(struct MPT2SAS_ADAPTER *ioc, u16 smid)
1340 return (void *)(ioc->request + (smid * ioc->request_sz));
1345 * @ioc: per adapter object
1351 mpt2sas_base_get_sense_buffer(struct MPT2SAS_ADAPTER *ioc, u16 smid)
1353 return (void *)(ioc->sense + ((smid - 1) * SCSI_SENSE_BUFFERSIZE));
1358 * @ioc: per adapter object
1364 mpt2sas_base_get_sense_buffer_dma(struct MPT2SAS_ADAPTER *ioc, u16 smid)
1366 return cpu_to_le32(ioc->sense_dma +
1372 * @ioc: per adapter object
1378 mpt2sas_base_get_reply_virt_addr(struct MPT2SAS_ADAPTER *ioc, u32 phys_addr)
1382 return ioc->reply + (phys_addr - (u32)ioc->reply_dma);
1387 * @ioc: per adapter object
1393 mpt2sas_base_get_smid(struct MPT2SAS_ADAPTER *ioc, u8 cb_idx)
1399 spin_lock_irqsave(&ioc->scsi_lookup_lock, flags);
1400 if (list_empty(&ioc->internal_free_list)) {
1401 spin_unlock_irqrestore(&ioc->scsi_lookup_lock, flags);
1403 ioc->name, __func__);
1407 request = list_entry(ioc->internal_free_list.next,
1412 spin_unlock_irqrestore(&ioc->scsi_lookup_lock, flags);
1418 * @ioc: per adapter object
1425 mpt2sas_base_get_smid_scsiio(struct MPT2SAS_ADAPTER *ioc, u8 cb_idx,
1432 spin_lock_irqsave(&ioc->scsi_lookup_lock, flags);
1433 if (list_empty(&ioc->free_list)) {
1434 spin_unlock_irqrestore(&ioc->scsi_lookup_lock, flags);
1436 ioc->name, __func__);
1440 request = list_entry(ioc->free_list.next,
1446 spin_unlock_irqrestore(&ioc->scsi_lookup_lock, flags);
1452 * @ioc: per adapter object
1458 mpt2sas_base_get_smid_hpr(struct MPT2SAS_ADAPTER *ioc, u8 cb_idx)
1464 spin_lock_irqsave(&ioc->scsi_lookup_lock, flags);
1465 if (list_empty(&ioc->hpr_free_list)) {
1466 spin_unlock_irqrestore(&ioc->scsi_lookup_lock, flags);
1470 request = list_entry(ioc->hpr_free_list.next,
1475 spin_unlock_irqrestore(&ioc->scsi_lookup_lock, flags);
1482 * @ioc: per adapter object
1488 mpt2sas_base_free_smid(struct MPT2SAS_ADAPTER *ioc, u16 smid)
1493 spin_lock_irqsave(&ioc->scsi_lookup_lock, flags);
1494 if (smid >= ioc->hi_priority_smid) {
1495 if (smid < ioc->internal_smid) {
1497 i = smid - ioc->hi_priority_smid;
1498 ioc->hpr_lookup[i].cb_idx = 0xFF;
1499 list_add_tail(&ioc->hpr_lookup[i].tracker_list,
1500 &ioc->hpr_free_list);
1503 i = smid - ioc->internal_smid;
1504 ioc->internal_lookup[i].cb_idx = 0xFF;
1505 list_add_tail(&ioc->internal_lookup[i].tracker_list,
1506 &ioc->internal_free_list);
1508 spin_unlock_irqrestore(&ioc->scsi_lookup_lock, flags);
1514 ioc->scsi_lookup[i].cb_idx = 0xFF;
1515 ioc->scsi_lookup[i].scmd = NULL;
1516 list_add_tail(&ioc->scsi_lookup[i].tracker_list,
1517 &ioc->free_list);
1518 spin_unlock_irqrestore(&ioc->scsi_lookup_lock, flags);
1523 if (ioc->shost_recovery && ioc->pending_io_count) {
1524 if (ioc->pending_io_count == 1)
1525 wake_up(&ioc->reset_wq);
1526 ioc->pending_io_count--;
1532 * @ioc: per adapter object
1563 * @ioc: per adapter object
1570 mpt2sas_base_put_smid_scsi_io(struct MPT2SAS_ADAPTER *ioc, u16 smid, u16 handle)
1581 _base_writeq(*request, &ioc->chip->RequestDescriptorPostLow,
1582 &ioc->scsi_lookup_lock);
1588 * @ioc: per adapter object
1594 mpt2sas_base_put_smid_hi_priority(struct MPT2SAS_ADAPTER *ioc, u16 smid)
1605 _base_writeq(*request, &ioc->chip->RequestDescriptorPostLow,
1606 &ioc->scsi_lookup_lock);
1611 * @ioc: per adapter object
1617 mpt2sas_base_put_smid_default(struct MPT2SAS_ADAPTER *ioc, u16 smid)
1627 _base_writeq(*request, &ioc->chip->RequestDescriptorPostLow,
1628 &ioc->scsi_lookup_lock);
1633 * @ioc: per adapter object
1640 mpt2sas_base_put_smid_target_assist(struct MPT2SAS_ADAPTER *ioc, u16 smid,
1652 _base_writeq(*request, &ioc->chip->RequestDescriptorPostLow,
1653 &ioc->scsi_lookup_lock);
1658 * @ioc: per adapter object
1663 _base_display_dell_branding(struct MPT2SAS_ADAPTER *ioc)
1667 if (ioc->pdev->subsystem_vendor != PCI_VENDOR_ID_DELL)
1671 switch (ioc->pdev->subsystem_device) {
1704 sprintf(dell_branding, "0x%4X", ioc->pdev->subsystem_device);
1709 " SSVID(0x%04X), SSDID(0x%04X)\n", ioc->name, dell_branding,
1710 ioc->pdev->vendor, ioc->pdev->device, ioc->pdev->subsystem_vendor,
1711 ioc->pdev->subsystem_device);
1716 * @ioc: per adapter object
1721 _base_display_ioc_capabilities(struct MPT2SAS_ADAPTER *ioc)
1728 pci_read_config_byte(ioc->pdev, PCI_CLASS_REVISION, &revision);
1729 strncpy(desc, ioc->manu_pg0.ChipName, 16);
1732 ioc->name, desc,
1733 (ioc->facts.FWVersion.Word & 0xFF000000) >> 24,
1734 (ioc->facts.FWVersion.Word & 0x00FF0000) >> 16,
1735 (ioc->facts.FWVersion.Word & 0x0000FF00) >> 8,
1736 ioc->facts.FWVersion.Word & 0x000000FF,
1738 (ioc->bios_pg3.BiosVersion & 0xFF000000) >> 24,
1739 (ioc->bios_pg3.BiosVersion & 0x00FF0000) >> 16,
1740 (ioc->bios_pg3.BiosVersion & 0x0000FF00) >> 8,
1741 ioc->bios_pg3.BiosVersion & 0x000000FF);
1743 _base_display_dell_branding(ioc);
1745 printk(MPT2SAS_INFO_FMT "Protocol=(", ioc->name);
1747 if (ioc->facts.ProtocolFlags & MPI2_IOCFACTS_PROTOCOL_SCSI_INITIATOR) {
1752 if (ioc->facts.ProtocolFlags & MPI2_IOCFACTS_PROTOCOL_SCSI_TARGET) {
1761 if (ioc->facts.IOCCapabilities &
1767 if (ioc->facts.IOCCapabilities & MPI2_IOCFACTS_CAPABILITY_TLR) {
1772 if (ioc->facts.IOCCapabilities & MPI2_IOCFACTS_CAPABILITY_MULTICAST) {
1777 if (ioc->facts.IOCCapabilities &
1783 if (ioc->facts.IOCCapabilities & MPI2_IOCFACTS_CAPABILITY_EEDP) {
1788 if (ioc->facts.IOCCapabilities &
1794 if (ioc->facts.IOCCapabilities &
1800 if (ioc->facts.IOCCapabilities &
1806 if (ioc->facts.IOCCapabilities &
1812 iounit_pg1_flags = le32_to_cpu(ioc->iounit_pg1.Flags);
1823 * @ioc: per adapter object
1828 _base_static_config_pages(struct MPT2SAS_ADAPTER *ioc)
1833 mpt2sas_config_get_manufacturing_pg0(ioc, &mpi_reply, &ioc->manu_pg0);
1834 if (ioc->ir_firmware)
1835 mpt2sas_config_get_manufacturing_pg10(ioc, &mpi_reply,
1836 &ioc->manu_pg10);
1837 mpt2sas_config_get_bios_pg2(ioc, &mpi_reply, &ioc->bios_pg2);
1838 mpt2sas_config_get_bios_pg3(ioc, &mpi_reply, &ioc->bios_pg3);
1839 mpt2sas_config_get_ioc_pg8(ioc, &mpi_reply, &ioc->ioc_pg8);
1840 mpt2sas_config_get_iounit_pg0(ioc, &mpi_reply, &ioc->iounit_pg0);
1841 mpt2sas_config_get_iounit_pg1(ioc, &mpi_reply, &ioc->iounit_pg1);
1842 _base_display_ioc_capabilities(ioc);
1848 iounit_pg1_flags = le32_to_cpu(ioc->iounit_pg1.Flags);
1849 if ((ioc->facts.IOCCapabilities &
1856 ioc->iounit_pg1.Flags = cpu_to_le32(iounit_pg1_flags);
1857 mpt2sas_config_set_iounit_pg1(ioc, &mpi_reply, &ioc->iounit_pg1);
1862 * @ioc: per adapter object
1869 _base_release_memory_pools(struct MPT2SAS_ADAPTER *ioc)
1871 dexitprintk(ioc, printk(MPT2SAS_INFO_FMT "%s\n", ioc->name,
1874 if (ioc->request) {
1875 pci_free_consistent(ioc->pdev, ioc->request_dma_sz,
1876 ioc->request, ioc->request_dma);
1877 dexitprintk(ioc, printk(MPT2SAS_INFO_FMT "request_pool(0x%p)"
1878 ": free\n", ioc->name, ioc->request));
1879 ioc->request = NULL;
1882 if (ioc->sense) {
1883 pci_pool_free(ioc->sense_dma_pool, ioc->sense, ioc->sense_dma);
1884 if (ioc->sense_dma_pool)
1885 pci_pool_destroy(ioc->sense_dma_pool);
1886 dexitprintk(ioc, printk(MPT2SAS_INFO_FMT "sense_pool(0x%p)"
1887 ": free\n", ioc->name, ioc->sense));
1888 ioc->sense = NULL;
1891 if (ioc->reply) {
1892 pci_pool_free(ioc->reply_dma_pool, ioc->reply, ioc->reply_dma);
1893 if (ioc->reply_dma_pool)
1894 pci_pool_destroy(ioc->reply_dma_pool);
1895 dexitprintk(ioc, printk(MPT2SAS_INFO_FMT "reply_pool(0x%p)"
1896 ": free\n", ioc->name, ioc->reply));
1897 ioc->reply = NULL;
1900 if (ioc->reply_free) {
1901 pci_pool_free(ioc->reply_free_dma_pool, ioc->reply_free,
1902 ioc->reply_free_dma);
1903 if (ioc->reply_free_dma_pool)
1904 pci_pool_destroy(ioc->reply_free_dma_pool);
1905 dexitprintk(ioc, printk(MPT2SAS_INFO_FMT "reply_free_pool"
1906 "(0x%p): free\n", ioc->name, ioc->reply_free));
1907 ioc->reply_free = NULL;
1910 if (ioc->reply_post_free) {
1911 pci_pool_free(ioc->reply_post_free_dma_pool,
1912 ioc->reply_post_free, ioc->reply_post_free_dma);
1913 if (ioc->reply_post_free_dma_pool)
1914 pci_pool_destroy(ioc->reply_post_free_dma_pool);
1915 dexitprintk(ioc, printk(MPT2SAS_INFO_FMT
1916 "reply_post_free_pool(0x%p): free\n", ioc->name,
1917 ioc->reply_post_free));
1918 ioc->reply_post_free = NULL;
1921 if (ioc->config_page) {
1922 dexitprintk(ioc, printk(MPT2SAS_INFO_FMT
1923 "config_page(0x%p): free\n", ioc->name,
1924 ioc->config_page));
1925 pci_free_consistent(ioc->pdev, ioc->config_page_sz,
1926 ioc->config_page, ioc->config_page_dma);
1929 if (ioc->scsi_lookup) {
1930 free_pages((ulong)ioc->scsi_lookup, ioc->scsi_lookup_pages);
1931 ioc->scsi_lookup = NULL;
1933 kfree(ioc->hpr_lookup);
1934 kfree(ioc->internal_lookup);
1940 * @ioc: per adapter object
1946 _base_allocate_memory_pools(struct MPT2SAS_ADAPTER *ioc, int sleep_flag)
1957 dinitprintk(ioc, printk(MPT2SAS_INFO_FMT "%s\n", ioc->name,
1961 facts = &ioc->facts;
1965 ioc->shost->sg_tablesize = (max_sgl_entries <
1969 ioc->shost->sg_tablesize = MPT2SAS_SG_DEPTH;
1982 ioc->hba_queue_depth = max_request_credit;
1983 ioc->hi_priority_depth = facts->HighPriorityCredit;
1984 ioc->internal_depth = ioc->hi_priority_depth + 5;
1987 ioc->request_sz = facts->IOCRequestFrameSize * 4;
1990 ioc->reply_sz = facts->ReplyFrameSize * 4;
1995 max_sge_elements = ioc->request_sz - ((sizeof(Mpi2SCSIIORequest_t) -
1996 sizeof(Mpi2SGEIOUnion_t)) + ioc->sge_size);
1997 ioc->max_sges_in_main_message = max_sge_elements/ioc->sge_size;
2000 max_sge_elements = ioc->request_sz - ioc->sge_size;
2001 ioc->max_sges_in_chain_message = max_sge_elements/ioc->sge_size;
2003 ioc->chain_offset_value_for_main_message =
2005 (ioc->max_sges_in_chain_message * ioc->sge_size)) / 4;
2010 chains_needed_per_io = ((ioc->shost->sg_tablesize -
2011 ioc->max_sges_in_main_message)/ioc->max_sges_in_chain_message)
2015 ioc->shost->sg_tablesize = min_t(u16,
2016 ioc->max_sges_in_main_message + (ioc->max_sges_in_chain_message
2017 * chains_needed_per_io), ioc->shost->sg_tablesize);
2019 ioc->chains_needed_per_io = chains_needed_per_io;
2022 num_of_reply_frames = ioc->hba_queue_depth + 32;
2036 ioc->reply_free_queue_depth = queue_size;
2043 queue_size = ioc->hba_queue_depth + num_of_reply_frames + 1;
2060 ioc->hba_queue_depth -= (queue_diff / 2);
2061 ioc->reply_free_queue_depth -= (queue_diff / 2);
2064 ioc->reply_post_queue_depth = queue_size;
2066 dinitprintk(ioc, printk(MPT2SAS_INFO_FMT "scatter gather: "
2068 "chains_per_io(%d)\n", ioc->name, ioc->max_sges_in_main_message,
2069 ioc->max_sges_in_chain_message, ioc->shost->sg_tablesize,
2070 ioc->chains_needed_per_io));
2072 ioc->scsiio_depth = ioc->hba_queue_depth -
2073 ioc->hi_priority_depth - ioc->internal_depth;
2078 ioc->shost->can_queue = ioc->scsiio_depth - (2);
2079 dinitprintk(ioc, printk(MPT2SAS_INFO_FMT "scsi host: "
2080 "can_queue depth (%d)\n", ioc->name, ioc->shost->can_queue));
2085 ioc->chain_depth = ioc->chains_needed_per_io * ioc->scsiio_depth;
2086 sz = ((ioc->scsiio_depth + 1 + ioc->chain_depth) * ioc->request_sz);
2089 sz += (ioc->hi_priority_depth * ioc->request_sz);
2092 sz += (ioc->internal_depth * ioc->request_sz);
2094 ioc->request_dma_sz = sz;
2095 ioc->request = pci_alloc_consistent(ioc->pdev, sz, &ioc->request_dma);
2096 if (!ioc->request) {
2099 "total(%d kB)\n", ioc->name, ioc->hba_queue_depth,
2100 ioc->chains_needed_per_io, ioc->request_sz, sz/1024);
2101 if (ioc->scsiio_depth < MPT2SAS_SAS_QUEUE_DEPTH)
2104 ioc->hba_queue_depth = max_request_credit - retry_sz;
2111 "total(%d kb)\n", ioc->name, ioc->hba_queue_depth,
2112 ioc->chains_needed_per_io, ioc->request_sz, sz/1024);
2116 ioc->hi_priority = ioc->request + ((ioc->scsiio_depth + 1) *
2117 ioc->request_sz);
2118 ioc->hi_priority_dma = ioc->request_dma + ((ioc->scsiio_depth + 1) *
2119 ioc->request_sz);
2122 ioc->internal = ioc->hi_priority + (ioc->hi_priority_depth *
2123 ioc->request_sz);
2124 ioc->internal_dma = ioc->hi_priority_dma + (ioc->hi_priority_depth *
2125 ioc->request_sz);
2127 ioc->chain = ioc->internal + (ioc->internal_depth *
2128 ioc->request_sz);
2129 ioc->chain_dma = ioc->internal_dma + (ioc->internal_depth *
2130 ioc->request_sz);
2132 dinitprintk(ioc, printk(MPT2SAS_INFO_FMT "request pool(0x%p): "
2133 "depth(%d), frame_size(%d), pool_size(%d kB)\n", ioc->name,
2134 ioc->request, ioc->hba_queue_depth, ioc->request_sz,
2135 (ioc->hba_queue_depth * ioc->request_sz)/1024));
2136 dinitprintk(ioc, printk(MPT2SAS_INFO_FMT "chain pool(0x%p): depth"
2137 "(%d), frame_size(%d), pool_size(%d kB)\n", ioc->name, ioc->chain,
2138 ioc->chain_depth, ioc->request_sz, ((ioc->chain_depth *
2139 ioc->request_sz))/1024));
2140 dinitprintk(ioc, printk(MPT2SAS_INFO_FMT "request pool: dma(0x%llx)\n",
2141 ioc->name, (unsigned long long) ioc->request_dma));
2144 sz = ioc->scsiio_depth * sizeof(struct request_tracker);
2145 ioc->scsi_lookup_pages = get_order(sz);
2146 ioc->scsi_lookup = (struct request_tracker *)__get_free_pages(
2147 GFP_KERNEL, ioc->scsi_lookup_pages);
2148 if (!ioc->scsi_lookup) {
2150 "sz(%d)\n", ioc->name, (int)sz);
2154 dinitprintk(ioc, printk(MPT2SAS_INFO_FMT "scsiio(0x%p): "
2155 "depth(%d)\n", ioc->name, ioc->request,
2156 ioc->scsiio_depth));
2159 ioc->hpr_lookup = kcalloc(ioc->hi_priority_depth,
2161 if (!ioc->hpr_lookup) {
2163 ioc->name);
2166 ioc->hi_priority_smid = ioc->scsiio_depth + 1;
2167 dinitprintk(ioc, printk(MPT2SAS_INFO_FMT "hi_priority(0x%p): "
2168 "depth(%d), start smid(%d)\n", ioc->name, ioc->hi_priority,
2169 ioc->hi_priority_depth, ioc->hi_priority_smid));
2172 ioc->internal_lookup = kcalloc(ioc->internal_depth,
2174 if (!ioc->internal_lookup) {
2176 ioc->name);
2179 ioc->internal_smid = ioc->hi_priority_smid + ioc->hi_priority_depth;
2180 dinitprintk(ioc, printk(MPT2SAS_INFO_FMT "internal(0x%p): "
2181 "depth(%d), start smid(%d)\n", ioc->name, ioc->internal,
2182 ioc->internal_depth, ioc->internal_smid));
2185 sz = ioc->scsiio_depth * SCSI_SENSE_BUFFERSIZE;
2186 ioc->sense_dma_pool = pci_pool_create("sense pool", ioc->pdev, sz, 4,
2188 if (!ioc->sense_dma_pool) {
2190 ioc->name);
2193 ioc->sense = pci_pool_alloc(ioc->sense_dma_pool , GFP_KERNEL,
2194 &ioc->sense_dma);
2195 if (!ioc->sense) {
2197 ioc->name);
2200 dinitprintk(ioc, printk(MPT2SAS_INFO_FMT
2202 "(%d kB)\n", ioc->name, ioc->sense, ioc->scsiio_depth,
2204 dinitprintk(ioc, printk(MPT2SAS_INFO_FMT "sense_dma(0x%llx)\n",
2205 ioc->name, (unsigned long long)ioc->sense_dma));
2209 sz = ioc->reply_free_queue_depth * ioc->reply_sz;
2210 ioc->reply_dma_pool = pci_pool_create("reply pool", ioc->pdev, sz, 4,
2212 if (!ioc->reply_dma_pool) {
2214 ioc->name);
2217 ioc->reply = pci_pool_alloc(ioc->reply_dma_pool , GFP_KERNEL,
2218 &ioc->reply_dma);
2219 if (!ioc->reply) {
2221 ioc->name);
2224 dinitprintk(ioc, printk(MPT2SAS_INFO_FMT "reply pool(0x%p): depth"
2225 "(%d), frame_size(%d), pool_size(%d kB)\n", ioc->name, ioc->reply,
2226 ioc->reply_free_queue_depth, ioc->reply_sz, sz/1024));
2227 dinitprintk(ioc, printk(MPT2SAS_INFO_FMT "reply_dma(0x%llx)\n",
2228 ioc->name, (unsigned long long)ioc->reply_dma));
2232 sz = ioc->reply_free_queue_depth * 4;
2233 ioc->reply_free_dma_pool = pci_pool_create("reply_free pool",
2234 ioc->pdev, sz, 16, 0);
2235 if (!ioc->reply_free_dma_pool) {
2237 "failed\n", ioc->name);
2240 ioc->reply_free = pci_pool_alloc(ioc->reply_free_dma_pool , GFP_KERNEL,
2241 &ioc->reply_free_dma);
2242 if (!ioc->reply_free) {
2244 "failed\n", ioc->name);
2247 memset(ioc->reply_free, 0, sz);
2248 dinitprintk(ioc, printk(MPT2SAS_INFO_FMT "reply_free pool(0x%p): "
2249 "depth(%d), element_size(%d), pool_size(%d kB)\n", ioc->name,
2250 ioc->reply_free, ioc->reply_free_queue_depth, 4, sz/1024));
2251 dinitprintk(ioc, printk(MPT2SAS_INFO_FMT "reply_free_dma"
2252 "(0x%llx)\n", ioc->name, (unsigned long long)ioc->reply_free_dma));
2256 sz = ioc->reply_post_queue_depth * sizeof(Mpi2DefaultReplyDescriptor_t);
2257 ioc->reply_post_free_dma_pool = pci_pool_create("reply_post_free pool",
2258 ioc->pdev, sz, 16, 0);
2259 if (!ioc->reply_post_free_dma_pool) {
2261 "failed\n", ioc->name);
2264 ioc->reply_post_free = pci_pool_alloc(ioc->reply_post_free_dma_pool ,
2265 GFP_KERNEL, &ioc->reply_post_free_dma);
2266 if (!ioc->reply_post_free) {
2268 "failed\n", ioc->name);
2271 memset(ioc->reply_post_free, 0, sz);
2272 dinitprintk(ioc, printk(MPT2SAS_INFO_FMT "reply post free pool"
2274 ioc->name, ioc->reply_post_free, ioc->reply_post_queue_depth, 8,
2276 dinitprintk(ioc, printk(MPT2SAS_INFO_FMT "reply_post_free_dma = "
2277 "(0x%llx)\n", ioc->name, (unsigned long long)
2278 ioc->reply_post_free_dma));
2281 ioc->config_page_sz = 512;
2282 ioc->config_page = pci_alloc_consistent(ioc->pdev,
2283 ioc->config_page_sz, &ioc->config_page_dma);
2284 if (!ioc->config_page) {
2286 "failed\n", ioc->name);
2289 dinitprintk(ioc, printk(MPT2SAS_INFO_FMT "config page(0x%p): size"
2290 "(%d)\n", ioc->name, ioc->config_page, ioc->config_page_sz));
2291 dinitprintk(ioc, printk(MPT2SAS_INFO_FMT "config_page_dma"
2292 "(0x%llx)\n", ioc->name, (unsigned long long)ioc->config_page_dma));
2293 total_sz += ioc->config_page_sz;
2296 ioc->name, total_sz/1024);
2299 ioc->name, ioc->shost->can_queue, facts->RequestCredit);
2301 ioc->name, ioc->shost->sg_tablesize);
2305 _base_release_memory_pools(ioc);
2312 * @ioc: Pointer to MPT_ADAPTER structure
2319 mpt2sas_base_get_iocstate(struct MPT2SAS_ADAPTER *ioc, int cooked)
2323 s = readl(&ioc->chip->Doorbell);
2329 * _base_wait_on_iocstate - waiting on a particular ioc state
2337 _base_wait_on_iocstate(struct MPT2SAS_ADAPTER *ioc, u32 ioc_state, int timeout,
2346 current_state = mpt2sas_base_get_iocstate(ioc, 1);
2364 * @ioc: per adapter object
2373 _base_wait_for_doorbell_int(struct MPT2SAS_ADAPTER *ioc, int timeout,
2382 int_status = readl(&ioc->chip->HostInterruptStatus);
2384 dhsprintk(ioc, printk(MPT2SAS_INFO_FMT "%s: "
2385 "successfull count(%d), timeout(%d)\n", ioc->name,
2397 "int_status(%x)!\n", ioc->name, __func__, count, int_status);
2403 * @ioc: per adapter object
2413 _base_wait_for_doorbell_ack(struct MPT2SAS_ADAPTER *ioc, int timeout,
2423 int_status = readl(&ioc->chip->HostInterruptStatus);
2425 dhsprintk(ioc, printk(MPT2SAS_INFO_FMT "%s: "
2426 "successfull count(%d), timeout(%d)\n", ioc->name,
2430 doorbell = readl(&ioc->chip->Doorbell);
2433 mpt2sas_base_fault_info(ioc , doorbell);
2448 "int_status(%x)!\n", ioc->name, __func__, count, int_status);
2454 * @ioc: per adapter object
2462 _base_wait_for_doorbell_not_used(struct MPT2SAS_ADAPTER *ioc, int timeout,
2471 doorbell_reg = readl(&ioc->chip->Doorbell);
2473 dhsprintk(ioc, printk(MPT2SAS_INFO_FMT "%s: "
2474 "successfull count(%d), timeout(%d)\n", ioc->name,
2486 "doorbell_reg(%x)!\n", ioc->name, __func__, count, doorbell_reg);
2492 * @ioc: per adapter object
2500 _base_send_ioc_reset(struct MPT2SAS_ADAPTER *ioc, u8 reset_type, int timeout,
2508 ioc->name, __func__);
2512 if (!(ioc->facts.IOCCapabilities &
2516 printk(MPT2SAS_INFO_FMT "sending message unit reset !!\n", ioc->name);
2519 &ioc->chip->Doorbell);
2520 if ((_base_wait_for_doorbell_ack(ioc, 15, sleep_flag))) {
2524 ioc_state = _base_wait_on_iocstate(ioc, MPI2_IOC_STATE_READY,
2528 " (ioc_state=0x%x)\n", ioc->name, __func__, ioc_state);
2534 ioc->name, ((r == 0) ? "SUCCESS" : "FAILED"));
2540 * @ioc: per adapter object
2551 _base_handshake_req_reply_wait(struct MPT2SAS_ADAPTER *ioc, int request_bytes,
2561 if ((readl(&ioc->chip->Doorbell) & MPI2_DOORBELL_USED)) {
2563 " (line=%d)\n", ioc->name, __LINE__);
2568 if (readl(&ioc->chip->HostInterruptStatus) &
2570 writel(0, &ioc->chip->HostInterruptStatus);
2572 /* send message to ioc */
2575 &ioc->chip->Doorbell);
2577 if ((_base_wait_for_doorbell_int(ioc, 5, NO_SLEEP))) {
2579 "int failed (line=%d)\n", ioc->name, __LINE__);
2582 writel(0, &ioc->chip->HostInterruptStatus);
2584 if ((_base_wait_for_doorbell_ack(ioc, 5, sleep_flag))) {
2586 "ack failed (line=%d)\n", ioc->name, __LINE__);
2592 writel(cpu_to_le32(request[i]), &ioc->chip->Doorbell);
2593 if ((_base_wait_for_doorbell_ack(ioc, 5, sleep_flag)))
2599 "sending request failed (line=%d)\n", ioc->name, __LINE__);
2604 if ((_base_wait_for_doorbell_int(ioc, timeout, sleep_flag))) {
2606 "int failed (line=%d)\n", ioc->name, __LINE__);
2611 reply[0] = le16_to_cpu(readl(&ioc->chip->Doorbell)
2613 writel(0, &ioc->chip->HostInterruptStatus);
2614 if ((_base_wait_for_doorbell_int(ioc, 5, sleep_flag))) {
2616 "int failed (line=%d)\n", ioc->name, __LINE__);
2619 reply[1] = le16_to_cpu(readl(&ioc->chip->Doorbell)
2621 writel(0, &ioc->chip->HostInterruptStatus);
2624 if ((_base_wait_for_doorbell_int(ioc, 5, sleep_flag))) {
2626 "handshake int failed (line=%d)\n", ioc->name,
2631 dummy = readl(&ioc->chip->Doorbell);
2633 reply[i] = le16_to_cpu(readl(&ioc->chip->Doorbell)
2635 writel(0, &ioc->chip->HostInterruptStatus);
2638 _base_wait_for_doorbell_int(ioc, 5, sleep_flag);
2639 if (_base_wait_for_doorbell_not_used(ioc, 5, sleep_flag) != 0) {
2640 dhsprintk(ioc, printk(MPT2SAS_INFO_FMT "doorbell is in use "
2641 " (line=%d)\n", ioc->name, __LINE__));
2643 writel(0, &ioc->chip->HostInterruptStatus);
2645 if (ioc->logging_level & MPT_DEBUG_INIT) {
2657 * @ioc: per adapter object
2670 mpt2sas_base_sas_iounit_control(struct MPT2SAS_ADAPTER *ioc,
2682 dinitprintk(ioc, printk(MPT2SAS_INFO_FMT "%s\n", ioc->name,
2685 mutex_lock(&ioc->base_cmds.mutex);
2687 if (ioc->base_cmds.status != MPT2_CMD_NOT_USED) {
2689 ioc->name, __func__);
2695 ioc_state = mpt2sas_base_get_iocstate(ioc, 1);
2699 "%s: failed due to ioc not operational\n",
2700 ioc->name, __func__);
2705 ioc_state = mpt2sas_base_get_iocstate(ioc, 1);
2707 "operational state(count=%d)\n", ioc->name,
2711 smid = mpt2sas_base_get_smid(ioc, ioc->base_cb_idx);
2714 ioc->name, __func__);
2720 ioc->base_cmds.status = MPT2_CMD_PENDING;
2721 request = mpt2sas_base_get_msg_frame(ioc, smid);
2722 ioc->base_cmds.smid = smid;
2726 ioc->ioc_link_reset_in_progress = 1;
2727 mpt2sas_base_put_smid_default(ioc, smid);
2728 init_completion(&ioc->base_cmds.done);
2729 timeleft = wait_for_completion_timeout(&ioc->base_cmds.done,
2733 ioc->ioc_link_reset_in_progress)
2734 ioc->ioc_link_reset_in_progress = 0;
2735 if (!(ioc->base_cmds.status & MPT2_CMD_COMPLETE)) {
2737 ioc->name, __func__);
2740 if (!(ioc->base_cmds.status & MPT2_CMD_RESET))
2744 if (ioc->base_cmds.status & MPT2_CMD_REPLY_VALID)
2745 memcpy(mpi_reply, ioc->base_cmds.reply,
2749 ioc->base_cmds.status = MPT2_CMD_NOT_USED;
2754 mpt2sas_base_hard_reset_handler(ioc, CAN_SLEEP,
2756 ioc->base_cmds.status = MPT2_CMD_NOT_USED;
2759 mutex_unlock(&ioc->base_cmds.mutex);
2766 * @ioc: per adapter object
2776 mpt2sas_base_scsi_enclosure_processor(struct MPT2SAS_ADAPTER *ioc,
2787 dinitprintk(ioc, printk(MPT2SAS_INFO_FMT "%s\n", ioc->name,
2790 mutex_lock(&ioc->base_cmds.mutex);
2792 if (ioc->base_cmds.status != MPT2_CMD_NOT_USED) {
2794 ioc->name, __func__);
2800 ioc_state = mpt2sas_base_get_iocstate(ioc, 1);
2804 "%s: failed due to ioc not operational\n",
2805 ioc->name, __func__);
2810 ioc_state = mpt2sas_base_get_iocstate(ioc, 1);
2812 "operational state(count=%d)\n", ioc->name,
2816 smid = mpt2sas_base_get_smid(ioc, ioc->base_cb_idx);
2819 ioc->name, __func__);
2825 ioc->base_cmds.status = MPT2_CMD_PENDING;
2826 request = mpt2sas_base_get_msg_frame(ioc, smid);
2827 ioc->base_cmds.smid = smid;
2829 mpt2sas_base_put_smid_default(ioc, smid);
2830 init_completion(&ioc->base_cmds.done);
2831 timeleft = wait_for_completion_timeout(&ioc->base_cmds.done,
2833 if (!(ioc->base_cmds.status & MPT2_CMD_COMPLETE)) {
2835 ioc->name, __func__);
2838 if (!(ioc->base_cmds.status & MPT2_CMD_RESET))
2842 if (ioc->base_cmds.status & MPT2_CMD_REPLY_VALID)
2843 memcpy(mpi_reply, ioc->base_cmds.reply,
2847 ioc->base_cmds.status = MPT2_CMD_NOT_USED;
2852 mpt2sas_base_hard_reset_handler(ioc, CAN_SLEEP,
2854 ioc->base_cmds.status = MPT2_CMD_NOT_USED;
2857 mutex_unlock(&ioc->base_cmds.mutex);
2862 * _base_get_port_facts - obtain port facts reply and save in ioc
2863 * @ioc: per adapter object
2869 _base_get_port_facts(struct MPT2SAS_ADAPTER *ioc, int port, int sleep_flag)
2875 dinitprintk(ioc, printk(MPT2SAS_INFO_FMT "%s\n", ioc->name,
2883 r = _base_handshake_req_reply_wait(ioc, mpi_request_sz,
2888 ioc->name, __func__, r);
2892 pfacts = &ioc->pfacts[port];
2904 * _base_get_ioc_facts - obtain ioc facts reply and save in ioc
2905 * @ioc: per adapter object
2911 _base_get_ioc_facts(struct MPT2SAS_ADAPTER *ioc, int sleep_flag)
2917 dinitprintk(ioc, printk(MPT2SAS_INFO_FMT "%s\n", ioc->name,
2924 r = _base_handshake_req_reply_wait(ioc, mpi_request_sz,
2929 ioc->name, __func__, r);
2933 facts = &ioc->facts;
2949 ioc->ir_firmware = 1;
2955 ioc->shost->max_id = -1;
2964 dinitprintk(ioc, printk(MPT2SAS_INFO_FMT "hba queue depth(%d), "
2965 "max chains per io(%d)\n", ioc->name, facts->RequestCredit,
2967 dinitprintk(ioc, printk(MPT2SAS_INFO_FMT "request frame size(%d), "
2968 "reply frame size(%d)\n", ioc->name,
2975 * @ioc: per adapter object
2981 _base_send_ioc_init(struct MPT2SAS_ADAPTER *ioc, int sleep_flag)
2989 dinitprintk(ioc, printk(MPT2SAS_INFO_FMT "%s\n", ioc->name,
3005 if ((ioc->facts.HeaderVersion >> 8) < 0xA) {
3006 mpi_request.Reserved7 = cpu_to_le16(ioc->reply_sz);
3008 * cpu_to_le16(ioc->reply_sz);
3012 mpi_request.SystemRequestFrameSize = cpu_to_le16(ioc->request_sz/4);
3014 cpu_to_le16(ioc->reply_post_queue_depth);
3016 cpu_to_le16(ioc->reply_free_queue_depth);
3020 cpu_to_le32(ioc->sense_dma >> 32);
3022 cpu_to_le32(ioc->reply_dma >> 32);
3024 cpu_to_le64(ioc->request_dma);
3026 cpu_to_le64(ioc->reply_free_dma);
3028 cpu_to_le64(ioc->reply_post_free_dma);
3031 cpu_to_le32(ioc->request_dma);
3033 cpu_to_le32(ioc->reply_free_dma);
3035 cpu_to_le32(ioc->reply_post_free_dma);
3045 if (ioc->logging_level & MPT_DEBUG_INIT) {
3056 r = _base_handshake_req_reply_wait(ioc,
3063 ioc->name, __func__, r);
3070 printk(MPT2SAS_ERR_FMT "%s: failed\n", ioc->name, __func__);
3079 * @ioc: per adapter object
3085 _base_send_port_enable(struct MPT2SAS_ADAPTER *ioc, int sleep_flag)
3093 printk(MPT2SAS_INFO_FMT "sending port enable !!\n", ioc->name);
3095 if (ioc->base_cmds.status & MPT2_CMD_PENDING) {
3097 ioc->name, __func__);
3101 smid = mpt2sas_base_get_smid(ioc, ioc->base_cb_idx);
3104 ioc->name, __func__);
3108 ioc->base_cmds.status = MPT2_CMD_PENDING;
3109 mpi_request = mpt2sas_base_get_msg_frame(ioc, smid);
3110 ioc->base_cmds.smid = smid;
3116 mpt2sas_base_put_smid_default(ioc, smid);
3117 init_completion(&ioc->base_cmds.done);
3118 timeleft = wait_for_completion_timeout(&ioc->base_cmds.done,
3120 if (!(ioc->base_cmds.status & MPT2_CMD_COMPLETE)) {
3122 ioc->name, __func__);
3125 if (ioc->base_cmds.status & MPT2_CMD_RESET)
3131 dinitprintk(ioc, printk(MPT2SAS_INFO_FMT "%s: complete\n",
3132 ioc->name, __func__));
3134 ioc_state = _base_wait_on_iocstate(ioc, MPI2_IOC_STATE_OPERATIONAL,
3138 " (ioc_state=0x%x)\n", ioc->name, __func__, ioc_state);
3142 ioc->base_cmds.status = MPT2_CMD_NOT_USED;
3144 ioc->name, ((r == 0) ? "SUCCESS" : "FAILED"));
3150 * @ioc: per adapter object
3153 * The mask is stored in ioc->event_masks.
3156 _base_unmask_events(struct MPT2SAS_ADAPTER *ioc, u16 event)
3166 ioc->event_masks[0] &= ~desired_event;
3168 ioc->event_masks[1] &= ~desired_event;
3170 ioc->event_masks[2] &= ~desired_event;
3172 ioc->event_masks[3] &= ~desired_event;
3177 * @ioc: per adapter object
3183 _base_event_notification(struct MPT2SAS_ADAPTER *ioc, int sleep_flag)
3191 dinitprintk(ioc, printk(MPT2SAS_INFO_FMT "%s\n", ioc->name,
3194 if (ioc->base_cmds.status & MPT2_CMD_PENDING) {
3196 ioc->name, __func__);
3200 smid = mpt2sas_base_get_smid(ioc, ioc->base_cb_idx);
3203 ioc->name, __func__);
3206 ioc->base_cmds.status = MPT2_CMD_PENDING;
3207 mpi_request = mpt2sas_base_get_msg_frame(ioc, smid);
3208 ioc->base_cmds.smid = smid;
3215 cpu_to_le32(ioc->event_masks[i]);
3216 mpt2sas_base_put_smid_default(ioc, smid);
3217 init_completion(&ioc->base_cmds.done);
3218 timeleft = wait_for_completion_timeout(&ioc->base_cmds.done, 30*HZ);
3219 if (!(ioc->base_cmds.status & MPT2_CMD_COMPLETE)) {
3221 ioc->name, __func__);
3224 if (ioc->base_cmds.status & MPT2_CMD_RESET)
3229 dinitprintk(ioc, printk(MPT2SAS_INFO_FMT "%s: complete\n",
3230 ioc->name, __func__));
3231 ioc->base_cmds.status = MPT2_CMD_NOT_USED;
3237 * @ioc: per adapter object
3244 mpt2sas_base_validate_event_type(struct MPT2SAS_ADAPTER *ioc, u32 *event_type)
3256 (ioc->event_masks[i] & desired_event)) {
3257 ioc->event_masks[i] &= ~desired_event;
3267 mutex_lock(&ioc->base_cmds.mutex);
3268 _base_event_notification(ioc, CAN_SLEEP);
3269 mutex_unlock(&ioc->base_cmds.mutex);
3274 * @ioc: per adapter object
3280 _base_diag_reset(struct MPT2SAS_ADAPTER *ioc, int sleep_flag)
3287 printk(MPT2SAS_INFO_FMT "sending diag reset !!\n", ioc->name);
3289 _base_save_msix_table(ioc);
3291 drsprintk(ioc, printk(MPT2SAS_INFO_FMT "clear interrupts\n",
3292 ioc->name));
3299 drsprintk(ioc, printk(MPT2SAS_INFO_FMT "write magic "
3300 "sequence\n", ioc->name));
3301 writel(MPI2_WRSEQ_FLUSH_KEY_VALUE, &ioc->chip->WriteSequence);
3302 writel(MPI2_WRSEQ_1ST_KEY_VALUE, &ioc->chip->WriteSequence);
3303 writel(MPI2_WRSEQ_2ND_KEY_VALUE, &ioc->chip->WriteSequence);
3304 writel(MPI2_WRSEQ_3RD_KEY_VALUE, &ioc->chip->WriteSequence);
3305 writel(MPI2_WRSEQ_4TH_KEY_VALUE, &ioc->chip->WriteSequence);
3306 writel(MPI2_WRSEQ_5TH_KEY_VALUE, &ioc->chip->WriteSequence);
3307 writel(MPI2_WRSEQ_6TH_KEY_VALUE, &ioc->chip->WriteSequence);
3318 host_diagnostic = readl(&ioc->chip->HostDiagnostic);
3319 drsprintk(ioc, printk(MPT2SAS_INFO_FMT "wrote magic "
3321 ioc->name, count, host_diagnostic));
3325 hcb_size = readl(&ioc->chip->HCBSize);
3327 drsprintk(ioc, printk(MPT2SAS_INFO_FMT "diag reset: issued\n",
3328 ioc->name));
3330 &ioc->chip->HostDiagnostic);
3338 host_diagnostic = readl(&ioc->chip->HostDiagnostic);
3354 drsprintk(ioc, printk(MPT2SAS_INFO_FMT "restart the adapter "
3356 ioc->name));
3359 writel(host_diagnostic, &ioc->chip->HostDiagnostic);
3361 drsprintk(ioc, printk(MPT2SAS_INFO_FMT
3362 "re-enable the HCDW\n", ioc->name));
3364 &ioc->chip->HCBSize);
3367 drsprintk(ioc, printk(MPT2SAS_INFO_FMT "restart the adapter\n",
3368 ioc->name));
3370 &ioc->chip->HostDiagnostic);
3372 drsprintk(ioc, printk(MPT2SAS_INFO_FMT "disable writes to the "
3373 "diagnostic register\n", ioc->name));
3374 writel(MPI2_WRSEQ_FLUSH_KEY_VALUE, &ioc->chip->WriteSequence);
3376 drsprintk(ioc, printk(MPT2SAS_INFO_FMT "Wait for FW to go to the "
3377 "READY state\n", ioc->name));
3378 ioc_state = _base_wait_on_iocstate(ioc, MPI2_IOC_STATE_READY, 20,
3382 " (ioc_state=0x%x)\n", ioc->name, __func__, ioc_state);
3386 _base_restore_msix_table(ioc);
3387 printk(MPT2SAS_INFO_FMT "diag reset: SUCCESS\n", ioc->name);
3391 printk(MPT2SAS_ERR_FMT "diag reset: FAILED\n", ioc->name);
3397 * @ioc: per adapter object
3404 _base_make_ioc_ready(struct MPT2SAS_ADAPTER *ioc, int sleep_flag,
3410 dinitprintk(ioc, printk(MPT2SAS_INFO_FMT "%s\n", ioc->name,
3413 if (ioc->pci_error_recovery)
3416 ioc_state = mpt2sas_base_get_iocstate(ioc, 0);
3417 dhsprintk(ioc, printk(MPT2SAS_INFO_FMT "%s: ioc_state(0x%08x)\n",
3418 ioc->name, __func__, ioc_state));
3424 dhsprintk(ioc, printk(MPT2SAS_INFO_FMT "unexpected doorbell "
3425 "active!\n", ioc->name));
3430 mpt2sas_base_fault_info(ioc, ioc_state &
3439 if (!(_base_send_ioc_reset(ioc,
3441 ioc->ioc_reset_count++;
3446 rc = _base_diag_reset(ioc, CAN_SLEEP);
3447 ioc->ioc_reset_count++;
3453 * @ioc: per adapter object
3459 _base_make_ioc_operational(struct MPT2SAS_ADAPTER *ioc, int sleep_flag)
3467 dinitprintk(ioc, printk(MPT2SAS_INFO_FMT "%s\n", ioc->name,
3472 &ioc->delayed_tr_list, list) {
3478 &ioc->delayed_tr_volume_list, list) {
3484 spin_lock_irqsave(&ioc->scsi_lookup_lock, flags);
3485 INIT_LIST_HEAD(&ioc->free_list);
3487 for (i = 0; i < ioc->scsiio_depth; i++, smid++) {
3488 ioc->scsi_lookup[i].cb_idx = 0xFF;
3489 ioc->scsi_lookup[i].smid = smid;
3490 ioc->scsi_lookup[i].scmd = NULL;
3491 list_add_tail(&ioc->scsi_lookup[i].tracker_list,
3492 &ioc->free_list);
3496 INIT_LIST_HEAD(&ioc->hpr_free_list);
3497 smid = ioc->hi_priority_smid;
3498 for (i = 0; i < ioc->hi_priority_depth; i++, smid++) {
3499 ioc->hpr_lookup[i].cb_idx = 0xFF;
3500 ioc->hpr_lookup[i].smid = smid;
3501 list_add_tail(&ioc->hpr_lookup[i].tracker_list,
3502 &ioc->hpr_free_list);
3506 INIT_LIST_HEAD(&ioc->internal_free_list);
3507 smid = ioc->internal_smid;
3508 for (i = 0; i < ioc->internal_depth; i++, smid++) {
3509 ioc->internal_lookup[i].cb_idx = 0xFF;
3510 ioc->internal_lookup[i].smid = smid;
3511 list_add_tail(&ioc->internal_lookup[i].tracker_list,
3512 &ioc->internal_free_list);
3514 spin_unlock_irqrestore(&ioc->scsi_lookup_lock, flags);
3517 for (i = 0, reply_address = (u32)ioc->reply_dma ;
3518 i < ioc->reply_free_queue_depth ; i++, reply_address +=
3519 ioc->reply_sz)
3520 ioc->reply_free[i] = cpu_to_le32(reply_address);
3523 for (i = 0; i < ioc->reply_post_queue_depth; i++)
3524 ioc->reply_post_free[i].Words = ULLONG_MAX;
3526 r = _base_send_ioc_init(ioc, sleep_flag);
3531 ioc->reply_free_host_index = ioc->reply_free_queue_depth - 1;
3532 ioc->reply_post_host_index = 0;
3533 writel(ioc->reply_free_host_index, &ioc->chip->ReplyFreeHostIndex);
3534 writel(0, &ioc->chip->ReplyPostHostIndex);
3536 _base_unmask_interrupts(ioc);
3537 r = _base_event_notification(ioc, sleep_flag);
3542 _base_static_config_pages(ioc);
3544 if (ioc->wait_for_port_enable_to_complete) {
3546 mpt2sas_enable_diag_buffer(ioc, diag_buffer_enable);
3551 r = _base_send_port_enable(ioc, sleep_flag);
3560 * @ioc: per adapter object
3565 mpt2sas_base_free_resources(struct MPT2SAS_ADAPTER *ioc)
3567 struct pci_dev *pdev = ioc->pdev;
3569 dexitprintk(ioc, printk(MPT2SAS_INFO_FMT "%s\n", ioc->name,
3572 _base_mask_interrupts(ioc);
3573 ioc->shost_recovery = 1;
3574 _base_make_ioc_ready(ioc, CAN_SLEEP, SOFT_RESET);
3575 ioc->shost_recovery = 0;
3576 if (ioc->pci_irq) {
3578 free_irq(ioc->pci_irq, ioc);
3580 _base_disable_msix(ioc);
3581 if (ioc->chip_phys)
3582 iounmap(ioc->chip);
3583 ioc->pci_irq = -1;
3584 ioc->chip_phys = 0;
3585 pci_release_selected_regions(ioc->pdev, ioc->bars);
3593 * @ioc: per adapter object
3598 mpt2sas_base_attach(struct MPT2SAS_ADAPTER *ioc)
3602 dinitprintk(ioc, printk(MPT2SAS_INFO_FMT "%s\n", ioc->name,
3605 r = mpt2sas_base_map_resources(ioc);
3609 pci_set_drvdata(ioc->pdev, ioc->shost);
3610 r = _base_get_ioc_facts(ioc, CAN_SLEEP);
3614 r = _base_make_ioc_ready(ioc, CAN_SLEEP, SOFT_RESET);
3618 ioc->pfacts = kcalloc(ioc->facts.NumberOfPorts,
3620 if (!ioc->pfacts) {
3625 for (i = 0 ; i < ioc->facts.NumberOfPorts; i++) {
3626 r = _base_get_port_facts(ioc, i, CAN_SLEEP);
3631 r = _base_allocate_memory_pools(ioc, CAN_SLEEP);
3635 init_waitqueue_head(&ioc->reset_wq);
3638 ioc->pd_handles_sz = (ioc->facts.MaxDevHandle / 8);
3639 if (ioc->facts.MaxDevHandle % 8)
3640 ioc->pd_handles_sz++;
3641 ioc->pd_handles = kzalloc(ioc->pd_handles_sz,
3643 if (!ioc->pd_handles) {
3648 ioc->fwfault_debug = mpt2sas_fwfault_debug;
3651 mutex_init(&ioc->base_cmds.mutex);
3652 ioc->base_cmds.reply = kzalloc(ioc->reply_sz, GFP_KERNEL);
3653 ioc->base_cmds.status = MPT2_CMD_NOT_USED;
3656 ioc->transport_cmds.reply = kzalloc(ioc->reply_sz, GFP_KERNEL);
3657 ioc->transport_cmds.status = MPT2_CMD_NOT_USED;
3658 mutex_init(&ioc->transport_cmds.mutex);
3661 ioc->scsih_cmds.reply = kzalloc(ioc->reply_sz, GFP_KERNEL);
3662 ioc->scsih_cmds.status = MPT2_CMD_NOT_USED;
3663 mutex_init(&ioc->scsih_cmds.mutex);
3666 ioc->scsih_cmds.reply = kzalloc(ioc->reply_sz, GFP_KERNEL);
3667 ioc->scsih_cmds.status = MPT2_CMD_NOT_USED;
3668 mutex_init(&ioc->scsih_cmds.mutex);
3671 ioc->tm_cmds.reply = kzalloc(ioc->reply_sz, GFP_KERNEL);
3672 ioc->tm_cmds.status = MPT2_CMD_NOT_USED;
3673 mutex_init(&ioc->tm_cmds.mutex);
3676 ioc->config_cmds.reply = kzalloc(ioc->reply_sz, GFP_KERNEL);
3677 ioc->config_cmds.status = MPT2_CMD_NOT_USED;
3678 mutex_init(&ioc->config_cmds.mutex);
3681 ioc->ctl_cmds.reply = kzalloc(ioc->reply_sz, GFP_KERNEL);
3682 ioc->ctl_cmds.sense = kzalloc(SCSI_SENSE_BUFFERSIZE, GFP_KERNEL);
3683 ioc->ctl_cmds.status = MPT2_CMD_NOT_USED;
3684 mutex_init(&ioc->ctl_cmds.mutex);
3686 if (!ioc->base_cmds.reply || !ioc->transport_cmds.reply ||
3687 !ioc->scsih_cmds.reply || !ioc->tm_cmds.reply ||
3688 !ioc->config_cmds.reply || !ioc->ctl_cmds.reply ||
3689 !ioc->ctl_cmds.sense) {
3694 if (!ioc->base_cmds.reply || !ioc->transport_cmds.reply ||
3695 !ioc->scsih_cmds.reply || !ioc->tm_cmds.reply ||
3696 !ioc->config_cmds.reply || !ioc->ctl_cmds.reply) {
3701 init_completion(&ioc->shost_recovery_done);
3704 ioc->event_masks[i] = -1;
3707 _base_unmask_events(ioc, MPI2_EVENT_SAS_DISCOVERY);
3708 _base_unmask_events(ioc, MPI2_EVENT_SAS_BROADCAST_PRIMITIVE);
3709 _base_unmask_events(ioc, MPI2_EVENT_SAS_TOPOLOGY_CHANGE_LIST);
3710 _base_unmask_events(ioc, MPI2_EVENT_SAS_DEVICE_STATUS_CHANGE);
3711 _base_unmask_events(ioc, MPI2_EVENT_SAS_ENCL_DEVICE_STATUS_CHANGE);
3712 _base_unmask_events(ioc, MPI2_EVENT_IR_CONFIGURATION_CHANGE_LIST);
3713 _base_unmask_events(ioc, MPI2_EVENT_IR_VOLUME);
3714 _base_unmask_events(ioc, MPI2_EVENT_IR_PHYSICAL_DISK);
3715 _base_unmask_events(ioc, MPI2_EVENT_IR_OPERATION_STATUS);
3716 _base_unmask_events(ioc, MPI2_EVENT_TASK_SET_FULL);
3717 _base_unmask_events(ioc, MPI2_EVENT_LOG_ENTRY_ADDED);
3718 r = _base_make_ioc_operational(ioc, CAN_SLEEP);
3722 mpt2sas_base_start_watchdog(ioc);
3727 ioc->remove_host = 1;
3728 mpt2sas_base_free_resources(ioc);
3729 _base_release_memory_pools(ioc);
3730 pci_set_drvdata(ioc->pdev, NULL);
3731 kfree(ioc->pd_handles);
3732 kfree(ioc->tm_cmds.reply);
3733 kfree(ioc->transport_cmds.reply);
3734 kfree(ioc->scsih_cmds.reply);
3735 kfree(ioc->config_cmds.reply);
3736 kfree(ioc->base_cmds.reply);
3737 kfree(ioc->ctl_cmds.reply);
3738 kfree(ioc->ctl_cmds.sense);
3739 kfree(ioc->pfacts);
3740 ioc->ctl_cmds.reply = NULL;
3741 ioc->base_cmds.reply = NULL;
3742 ioc->tm_cmds.reply = NULL;
3743 ioc->scsih_cmds.reply = NULL;
3744 ioc->transport_cmds.reply = NULL;
3745 ioc->config_cmds.reply = NULL;
3746 ioc->pfacts = NULL;
3753 * @ioc: per adapter object
3758 mpt2sas_base_detach(struct MPT2SAS_ADAPTER *ioc)
3761 dexitprintk(ioc, printk(MPT2SAS_INFO_FMT "%s\n", ioc->name,
3764 mpt2sas_base_stop_watchdog(ioc);
3765 mpt2sas_base_free_resources(ioc);
3766 _base_release_memory_pools(ioc);
3767 pci_set_drvdata(ioc->pdev, NULL);
3768 kfree(ioc->pd_handles);
3769 kfree(ioc->pfacts);
3770 kfree(ioc->ctl_cmds.reply);
3771 kfree(ioc->ctl_cmds.sense);
3772 kfree(ioc->base_cmds.reply);
3773 kfree(ioc->tm_cmds.reply);
3774 kfree(ioc->transport_cmds.reply);
3775 kfree(ioc->scsih_cmds.reply);
3776 kfree(ioc->config_cmds.reply);
3781 * @ioc: per adapter object
3792 _base_reset_handler(struct MPT2SAS_ADAPTER *ioc, int reset_phase)
3794 mpt2sas_scsih_reset_handler(ioc, reset_phase);
3795 mpt2sas_ctl_reset_handler(ioc, reset_phase);
3798 dtmprintk(ioc, printk(MPT2SAS_INFO_FMT "%s: "
3799 "MPT2_IOC_PRE_RESET\n", ioc->name, __func__));
3802 dtmprintk(ioc, printk(MPT2SAS_INFO_FMT "%s: "
3803 "MPT2_IOC_AFTER_RESET\n", ioc->name, __func__));
3804 if (ioc->transport_cmds.status & MPT2_CMD_PENDING) {
3805 ioc->transport_cmds.status |= MPT2_CMD_RESET;
3806 mpt2sas_base_free_smid(ioc, ioc->transport_cmds.smid);
3807 complete(&ioc->transport_cmds.done);
3809 if (ioc->base_cmds.status & MPT2_CMD_PENDING) {
3810 ioc->base_cmds.status |= MPT2_CMD_RESET;
3811 mpt2sas_base_free_smid(ioc, ioc->base_cmds.smid);
3812 complete(&ioc->base_cmds.done);
3814 if (ioc->config_cmds.status & MPT2_CMD_PENDING) {
3815 ioc->config_cmds.status |= MPT2_CMD_RESET;
3816 mpt2sas_base_free_smid(ioc, ioc->config_cmds.smid);
3817 ioc->config_cmds.smid = USHRT_MAX;
3818 complete(&ioc->config_cmds.done);
3822 dtmprintk(ioc, printk(MPT2SAS_INFO_FMT "%s: "
3823 "MPT2_IOC_DONE_RESET\n", ioc->name, __func__));
3830 * @ioc: Pointer to MPT_ADAPTER structure
3837 _wait_for_commands_to_complete(struct MPT2SAS_ADAPTER *ioc, int sleep_flag)
3843 ioc->pending_io_count = 0;
3847 ioc_state = mpt2sas_base_get_iocstate(ioc, 0);
3852 spin_lock_irqsave(&ioc->scsi_lookup_lock, flags);
3853 for (i = 0; i < ioc->scsiio_depth; i++)
3854 if (ioc->scsi_lookup[i].cb_idx != 0xFF)
3855 ioc->pending_io_count++;
3856 spin_unlock_irqrestore(&ioc->scsi_lookup_lock, flags);
3858 if (!ioc->pending_io_count)
3862 wait_event_timeout(ioc->reset_wq, ioc->pending_io_count == 0, 10 * HZ);
3867 * @ioc: Pointer to MPT_ADAPTER structure
3874 mpt2sas_base_hard_reset_handler(struct MPT2SAS_ADAPTER *ioc, int sleep_flag,
3879 u8 pe_complete = ioc->wait_for_port_enable_to_complete;
3881 dtmprintk(ioc, printk(MPT2SAS_INFO_FMT "%s: enter\n", ioc->name,
3884 if (ioc->pci_error_recovery) {
3886 ioc->name, __func__);
3892 mpt2sas_halt_firmware(ioc);
3902 if (!mutex_trylock(&ioc->reset_in_progress_mutex)) {
3905 } while (ioc->shost_recovery == 1);
3906 dtmprintk(ioc, printk(MPT2SAS_INFO_FMT "%s: exit\n", ioc->name,
3908 return ioc->ioc_reset_in_progress_status;
3911 spin_lock_irqsave(&ioc->ioc_reset_in_progress_lock, flags);
3912 ioc->shost_recovery = 1;
3913 spin_unlock_irqrestore(&ioc->ioc_reset_in_progress_lock, flags);
3915 _base_reset_handler(ioc, MPT2_IOC_PRE_RESET);
3916 _wait_for_commands_to_complete(ioc, sleep_flag);
3917 _base_mask_interrupts(ioc);
3918 r = _base_make_ioc_ready(ioc, sleep_flag, type);
3921 _base_reset_handler(ioc, MPT2_IOC_AFTER_RESET);
3930 r = _base_make_ioc_operational(ioc, sleep_flag);
3932 _base_reset_handler(ioc, MPT2_IOC_DONE_RESET);
3934 dtmprintk(ioc, printk(MPT2SAS_INFO_FMT "%s: %s\n",
3935 ioc->name, __func__, ((r == 0) ? "SUCCESS" : "FAILED")));
3937 spin_lock_irqsave(&ioc->ioc_reset_in_progress_lock, flags);
3938 ioc->ioc_reset_in_progress_status = r;
3939 ioc->shost_recovery = 0;
3940 complete(&ioc->shost_recovery_done);
3941 spin_unlock_irqrestore(&ioc->ioc_reset_in_progress_lock, flags);
3942 mutex_unlock(&ioc->reset_in_progress_mutex);
3944 dtmprintk(ioc, printk(MPT2SAS_INFO_FMT "%s: exit\n", ioc->name,