Lines Matching +full:max +full:- +full:outbound +full:- +full:regions
8 * Copyright (c) 1999-2008 LSI Corporation
9 * (mailto:DL-MPTFusionLinux@lsi.com)
12 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
26 LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
45 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
47 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
61 #include <linux/dma-mapping.h>
68 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
106 " debug level - refer to mptdebug.h - (default=0)");
112 "Enable detection of Firmware fault and halt Firmware on fault - (default=0)");
122 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
129 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
155 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
254 ioc->debug_level = mpt_debug_level; in mpt_set_debug_level()
259 * mpt_get_cb_idx - obtain cb_idx for registered driver
269 for (cb_idx = MPT_MAX_PROTOCOL_DRIVERS-1; cb_idx; cb_idx--) in mpt_get_cb_idx()
276 * mpt_is_discovery_complete - determine if discovery has completed
303 buffer = dma_alloc_coherent(&ioc->pcidev->dev, hdr.ExtPageLength * 4, in mpt_is_discovery_complete()
314 if (!(buffer->PhyData[0].PortFlags & in mpt_is_discovery_complete()
319 dma_free_coherent(&ioc->pcidev->dev, hdr.ExtPageLength * 4, buffer, in mpt_is_discovery_complete()
327 * mpt_remove_dead_ioc_func - kthread context to remove dead ioc
331 * Return -1 for other case.
339 return -1; in mpt_remove_dead_ioc_func()
341 pdev = ioc->pcidev; in mpt_remove_dead_ioc_func()
343 return -1; in mpt_remove_dead_ioc_func()
352 * mpt_fault_reset_work - work performed on workq after ioc fault
367 if (ioc->ioc_reset_in_progress || !ioc->active) in mpt_fault_reset_work()
373 printk(MYIOC_s_INFO_FMT "%s: IOC is non-operational !!!!\n", in mpt_fault_reset_work()
374 ioc->name, __func__); in mpt_fault_reset_work()
383 hd = shost_priv(ioc->sh); in mpt_fault_reset_work()
384 ioc->schedule_dead_ioc_flush_running_cmds(hd); in mpt_fault_reset_work()
388 "mpt_dead_ioc_%d", ioc->id); in mpt_fault_reset_work()
392 ioc->name, __func__); in mpt_fault_reset_work()
396 ioc->name, __func__); in mpt_fault_reset_work()
404 ioc->name, ioc_raw_state & MPI_DOORBELL_DATA_MASK); in mpt_fault_reset_work()
406 ioc->name, __func__); in mpt_fault_reset_work()
408 printk(MYIOC_s_WARN_FMT "%s: HardReset: %s\n", ioc->name, in mpt_fault_reset_work()
413 "reset (%04xh)\n", ioc->name, ioc_raw_state & in mpt_fault_reset_work()
415 } else if (ioc->bus_type == SAS && ioc->sas_discovery_quiesce_io) { in mpt_fault_reset_work()
418 "discovery_quiesce_io flag\n", ioc->name)); in mpt_fault_reset_work()
419 ioc->sas_discovery_quiesce_io = 0; in mpt_fault_reset_work()
427 if (ioc->alt_ioc) in mpt_fault_reset_work()
428 ioc = ioc->alt_ioc; in mpt_fault_reset_work()
431 spin_lock_irqsave(&ioc->taskmgmt_lock, flags); in mpt_fault_reset_work()
432 if (ioc->reset_work_q) in mpt_fault_reset_work()
433 queue_delayed_work(ioc->reset_work_q, &ioc->fault_reset_work, in mpt_fault_reset_work()
435 spin_unlock_irqrestore(&ioc->taskmgmt_lock, flags); in mpt_fault_reset_work()
451 ioc->name, pa)); in mpt_turbo_reply()
468 * proper mf value first here:-) in mpt_turbo_reply()
492 __func__, ioc->name, cb_idx); in mpt_turbo_reply()
514 /* non-TURBO reply! Hmmm, something may be up... in mpt_reply()
520 * pa is 32 bits - but the dma address may be 32 or 64 bits in mpt_reply()
525 mr = (MPT_FRAME_HDR *)((u8 *)ioc->reply_frames + in mpt_reply()
526 (reply_dma_low - ioc->reply_frames_low_dma)); in mpt_reply()
528 req_idx = le16_to_cpu(mr->u.frame.hwhdr.msgctxu.fld.req_idx); in mpt_reply()
529 cb_idx = mr->u.frame.hwhdr.msgctxu.fld.cb_idx; in mpt_reply()
532 …dmfprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Got non-TURBO reply=%p req_idx=%x cb_idx=%x Function=%x\n… in mpt_reply()
533 ioc->name, mr, req_idx, cb_idx, mr->u.hdr.Function)); in mpt_reply()
538 ioc_stat = le16_to_cpu(mr->u.reply.IOCStatus); in mpt_reply()
540 u32 log_info = le32_to_cpu(mr->u.reply.IOCLogInfo); in mpt_reply()
541 if (ioc->bus_type == FC) in mpt_reply()
543 else if (ioc->bus_type == SPI) in mpt_reply()
545 else if (ioc->bus_type == SAS) in mpt_reply()
556 __func__, ioc->name, cb_idx); in mpt_reply()
564 /* Flush (non-TURBO) reply with a WRITE! */ in mpt_reply()
565 CHIPREG_WRITE32(&ioc->chip->ReplyFifo, pa); in mpt_reply()
572 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
574 * mpt_interrupt - MPT adapter (IOC) specific interrupt handler.
585 * This routine handles register-level access of the adapter but
586 * dispatches (calls) a protocol-specific callback routine to handle
587 * the protocol-specific details of the MPT request completion.
593 u32 pa = CHIPREG_READ32_dmasync(&ioc->chip->ReplyFifo); in mpt_interrupt()
606 pa = CHIPREG_READ32_dmasync(&ioc->chip->ReplyFifo); in mpt_interrupt()
612 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
614 * mptbase_reply - MPT base driver's callback routine
634 switch (reply->u.hdr.Function) { in mptbase_reply()
639 event = le32_to_cpu(pEventReply->Event) & 0xFF; in mptbase_reply()
640 if (pEventReply->MsgFlags & MPI_MSGFLAGS_CONTINUATION_REPLY) in mptbase_reply()
647 ioc->mptbase_cmds.status |= MPT_MGMT_STATUS_COMMAND_GOOD; in mptbase_reply()
648 ioc->mptbase_cmds.status |= MPT_MGMT_STATUS_RF_VALID; in mptbase_reply()
649 memcpy(ioc->mptbase_cmds.reply, reply, in mptbase_reply()
651 4 * reply->u.reply.MsgLength)); in mptbase_reply()
652 if (ioc->mptbase_cmds.status & MPT_MGMT_STATUS_PENDING) { in mptbase_reply()
653 ioc->mptbase_cmds.status &= ~MPT_MGMT_STATUS_PENDING; in mptbase_reply()
654 complete(&ioc->mptbase_cmds.done); in mptbase_reply()
657 if (ioc->mptbase_cmds.status & MPT_MGMT_STATUS_FREE_MF) in mptbase_reply()
662 "EventAck reply received\n", ioc->name)); in mptbase_reply()
667 ioc->name, reply->u.hdr.Function); in mptbase_reply()
678 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
680 * mpt_register - Register protocol-specific main callback handler.
685 * This routine is called by a protocol-specific driver (SCSI host,
687 * protocol-specific driver must do this before it will be able to
709 for (cb_idx = MPT_MAX_PROTOCOL_DRIVERS-1; cb_idx; cb_idx--) { in mpt_register()
724 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
726 * mpt_deregister - Deregister a protocol drivers resources.
729 * Each protocol-specific driver should call this routine when its
744 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
746 * mpt_event_register - Register protocol-specific event callback handler.
750 * This routine can be called by one or more protocol-specific drivers
759 return -1; in mpt_event_register()
765 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
767 * mpt_event_deregister - Deregister protocol-specific event callback handler
770 * Each protocol-specific driver should call this routine
783 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
785 * mpt_reset_register - Register protocol-specific IOC reset handler.
789 * This routine can be called by one or more protocol-specific drivers
798 return -1; in mpt_reset_register()
804 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
806 * mpt_reset_deregister - Deregister protocol-specific IOC reset handler.
809 * Each protocol-specific driver should call this routine
822 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
824 * mpt_device_driver_register - Register device driver hooks
834 return -EINVAL; in mpt_device_driver_register()
840 if (dd_cbfunc->probe) in mpt_device_driver_register()
841 dd_cbfunc->probe(ioc->pcidev); in mpt_device_driver_register()
847 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
849 * mpt_device_driver_deregister - DeRegister device driver hooks
864 if (dd_cbfunc->remove) in mpt_device_driver_deregister()
865 dd_cbfunc->remove(ioc->pcidev); in mpt_device_driver_deregister()
872 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
874 * mpt_get_msg_frame - Obtain an MPT request frame from the pool
894 if (!ioc->active) in mpt_get_msg_frame()
896 "returning NULL!\n", ioc->name); in mpt_get_msg_frame()
900 if (!ioc->active) in mpt_get_msg_frame()
903 spin_lock_irqsave(&ioc->FreeQlock, flags); in mpt_get_msg_frame()
904 if (!list_empty(&ioc->FreeQ)) { in mpt_get_msg_frame()
907 mf = list_entry(ioc->FreeQ.next, MPT_FRAME_HDR, in mpt_get_msg_frame()
909 list_del(&mf->u.frame.linkage.list); in mpt_get_msg_frame()
910 mf->u.frame.linkage.arg1 = 0; in mpt_get_msg_frame()
911 mf->u.frame.hwhdr.msgctxu.fld.cb_idx = cb_idx; /* byte */ in mpt_get_msg_frame()
912 req_offset = (u8 *)mf - (u8 *)ioc->req_frames; in mpt_get_msg_frame()
914 req_idx = req_offset / ioc->req_sz; in mpt_get_msg_frame()
915 mf->u.frame.hwhdr.msgctxu.fld.req_idx = cpu_to_le16(req_idx); in mpt_get_msg_frame()
916 mf->u.frame.hwhdr.msgctxu.fld.rsvd = 0; in mpt_get_msg_frame()
918 ioc->RequestNB[req_idx] = ioc->NB_for_64_byte_frame; in mpt_get_msg_frame()
920 ioc->mfcnt++; in mpt_get_msg_frame()
925 spin_unlock_irqrestore(&ioc->FreeQlock, flags); in mpt_get_msg_frame()
930 "Count 0x%x Max 0x%x\n", ioc->name, ioc->mfcnt, in mpt_get_msg_frame()
931 ioc->req_depth); in mpt_get_msg_frame()
934 printk(MYIOC_s_INFO_FMT "MF Count 0x%x Max 0x%x \n", ioc->name, in mpt_get_msg_frame()
935 ioc->mfcnt, ioc->req_depth); in mpt_get_msg_frame()
939 ioc->name, cb_idx, ioc->id, mf)); in mpt_get_msg_frame()
943 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
945 * mpt_put_msg_frame - Send a protocol-specific MPT request frame to an IOC
961 mf->u.frame.hwhdr.msgctxu.fld.cb_idx = cb_idx; /* byte */ in mpt_put_msg_frame()
962 req_offset = (u8 *)mf - (u8 *)ioc->req_frames; in mpt_put_msg_frame()
964 req_idx = req_offset / ioc->req_sz; in mpt_put_msg_frame()
965 mf->u.frame.hwhdr.msgctxu.fld.req_idx = cpu_to_le16(req_idx); in mpt_put_msg_frame()
966 mf->u.frame.hwhdr.msgctxu.fld.rsvd = 0; in mpt_put_msg_frame()
970 mf_dma_addr = (ioc->req_frames_low_dma + req_offset) | ioc->RequestNB[req_idx]; in mpt_put_msg_frame()
972 "RequestNB=%x\n", ioc->name, mf_dma_addr, req_idx, in mpt_put_msg_frame()
973 ioc->RequestNB[req_idx])); in mpt_put_msg_frame()
974 CHIPREG_WRITE32(&ioc->chip->RequestFifo, mf_dma_addr); in mpt_put_msg_frame()
978 * mpt_put_msg_frame_hi_pri - Send a hi-pri protocol-specific MPT request frame
983 * Send a protocol-specific MPT request frame to an IOC using
984 * hi-priority request queue.
997 mf->u.frame.hwhdr.msgctxu.fld.cb_idx = cb_idx; in mpt_put_msg_frame_hi_pri()
998 req_offset = (u8 *)mf - (u8 *)ioc->req_frames; in mpt_put_msg_frame_hi_pri()
999 req_idx = req_offset / ioc->req_sz; in mpt_put_msg_frame_hi_pri()
1000 mf->u.frame.hwhdr.msgctxu.fld.req_idx = cpu_to_le16(req_idx); in mpt_put_msg_frame_hi_pri()
1001 mf->u.frame.hwhdr.msgctxu.fld.rsvd = 0; in mpt_put_msg_frame_hi_pri()
1005 mf_dma_addr = (ioc->req_frames_low_dma + req_offset); in mpt_put_msg_frame_hi_pri()
1007 ioc->name, mf_dma_addr, req_idx)); in mpt_put_msg_frame_hi_pri()
1008 CHIPREG_WRITE32(&ioc->chip->RequestHiPriFifo, mf_dma_addr); in mpt_put_msg_frame_hi_pri()
1011 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
1013 * mpt_free_msg_frame - Place MPT request frame back on FreeQ.
1026 spin_lock_irqsave(&ioc->FreeQlock, flags); in mpt_free_msg_frame()
1027 if (cpu_to_le32(mf->u.frame.linkage.arg1) == 0xdeadbeaf) in mpt_free_msg_frame()
1030 mf->u.frame.linkage.arg1 = cpu_to_le32(0xdeadbeaf); in mpt_free_msg_frame()
1031 list_add(&mf->u.frame.linkage.list, &ioc->FreeQ); in mpt_free_msg_frame()
1033 ioc->mfcnt--; in mpt_free_msg_frame()
1036 spin_unlock_irqrestore(&ioc->FreeQlock, flags); in mpt_free_msg_frame()
1039 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
1041 * mpt_add_sge - Place a simple 32 bit SGE at address pAddr.
1053 pSge->FlagsLength = cpu_to_le32(flagslength); in mpt_add_sge()
1054 pSge->Address = cpu_to_le32(dma_addr); in mpt_add_sge()
1058 * mpt_add_sge_64bit - Place a simple 64 bit SGE at address pAddr.
1070 pSge->Address.Low = cpu_to_le32 in mpt_add_sge_64bit()
1072 pSge->Address.High = cpu_to_le32 in mpt_add_sge_64bit()
1074 pSge->FlagsLength = cpu_to_le32 in mpt_add_sge_64bit()
1079 * mpt_add_sge_64bit_1078 - Place a simple 64 bit SGE at address pAddr (1078 workaround).
1093 pSge->Address.Low = cpu_to_le32 in mpt_add_sge_64bit_1078()
1111 pSge->Address.High = cpu_to_le32(tmp); in mpt_add_sge_64bit_1078()
1112 pSge->FlagsLength = cpu_to_le32( in mpt_add_sge_64bit_1078()
1116 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
1118 * mpt_add_chain - Place a 32 bit chain SGE at address pAddr.
1130 pChain->Length = cpu_to_le16(length); in mpt_add_chain()
1131 pChain->Flags = MPI_SGE_FLAGS_CHAIN_ELEMENT; in mpt_add_chain()
1132 pChain->NextChainOffset = next; in mpt_add_chain()
1133 pChain->Address = cpu_to_le32(dma_addr); in mpt_add_chain()
1136 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
1138 * mpt_add_chain_64bit - Place a 64 bit chain SGE at address pAddr.
1151 pChain->Length = cpu_to_le16(length); in mpt_add_chain_64bit()
1152 pChain->Flags = (MPI_SGE_FLAGS_CHAIN_ELEMENT | in mpt_add_chain_64bit()
1155 pChain->NextChainOffset = next; in mpt_add_chain_64bit()
1157 pChain->Address.Low = cpu_to_le32(tmp); in mpt_add_chain_64bit()
1159 pChain->Address.High = cpu_to_le32(tmp); in mpt_add_chain_64bit()
1162 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
1164 * mpt_send_handshake_request - Send MPT request via doorbell handshake method.
1174 * NOTE: It is the callers responsibility to byte-swap fields in the
1177 * Returns 0 for success, non-zero for failure.
1194 * is in proper (pre-alloc'd) request buffer range... in mpt_send_handshake_request()
1197 if (reqBytes >= 12 && ii >= 0 && ii < ioc->req_depth) { in mpt_send_handshake_request()
1199 mf->u.frame.hwhdr.msgctxu.fld.req_idx = cpu_to_le16(ii); in mpt_send_handshake_request()
1200 mf->u.frame.hwhdr.msgctxu.fld.cb_idx = cb_idx; in mpt_send_handshake_request()
1204 CHIPREG_WRITE32(&ioc->chip->IntStatus, 0); in mpt_send_handshake_request()
1206 CHIPREG_WRITE32(&ioc->chip->Doorbell, in mpt_send_handshake_request()
1216 if (!(CHIPREG_READ32(&ioc->chip->Doorbell) & MPI_DOORBELL_ACTIVE)) in mpt_send_handshake_request()
1217 return -5; in mpt_send_handshake_request()
1220 ioc->name, ii)); in mpt_send_handshake_request()
1222 CHIPREG_WRITE32(&ioc->chip->IntStatus, 0); in mpt_send_handshake_request()
1225 return -2; in mpt_send_handshake_request()
1237 CHIPREG_WRITE32(&ioc->chip->Doorbell, word); in mpt_send_handshake_request()
1239 r = -3; in mpt_send_handshake_request()
1247 r = -4; in mpt_send_handshake_request()
1250 CHIPREG_WRITE32(&ioc->chip->IntStatus, 0); in mpt_send_handshake_request()
1255 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
1257 * mpt_host_page_access_control - control the IOC's Host Page Buffer access
1265 * Access Control Value - bits[15:12]
1271 * Returns 0 for success, non-zero for failure.
1278 if (CHIPREG_READ32(&ioc->chip->Doorbell) in mpt_host_page_access_control()
1280 return -1; in mpt_host_page_access_control()
1282 CHIPREG_WRITE32(&ioc->chip->IntStatus, 0); in mpt_host_page_access_control()
1284 CHIPREG_WRITE32(&ioc->chip->Doorbell, in mpt_host_page_access_control()
1291 return -2; in mpt_host_page_access_control()
1296 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
1298 * mpt_host_page_alloc - allocate system memory for the fw
1303 * Returns 0 for success, non-zero for failure.
1312 if(!ioc->HostPageBuffer) { in mpt_host_page_alloc()
1315 le32_to_cpu(ioc->facts.HostPageBufferSGE.FlagsLength) & 0xFFFFFF; in mpt_host_page_alloc()
1322 ioc->HostPageBuffer = in mpt_host_page_alloc()
1323 dma_alloc_coherent(&ioc->pcidev->dev, in mpt_host_page_alloc()
1325 &ioc->HostPageBuffer_dma, in mpt_host_page_alloc()
1327 if (ioc->HostPageBuffer) { in mpt_host_page_alloc()
1330 ioc->name, ioc->HostPageBuffer, in mpt_host_page_alloc()
1331 (u32)ioc->HostPageBuffer_dma, in mpt_host_page_alloc()
1333 ioc->alloc_total += host_page_buffer_sz; in mpt_host_page_alloc()
1334 ioc->HostPageBuffer_sz = host_page_buffer_sz; in mpt_host_page_alloc()
1338 host_page_buffer_sz -= (4*1024); in mpt_host_page_alloc()
1342 if(!ioc->HostPageBuffer) { in mpt_host_page_alloc()
1345 ioc->name); in mpt_host_page_alloc()
1346 return -999; in mpt_host_page_alloc()
1349 psge = (char *)&ioc_init->HostPageBufferSGE; in mpt_host_page_alloc()
1355 flags_length |= ioc->HostPageBuffer_sz; in mpt_host_page_alloc()
1356 ioc->add_sge(psge, flags_length, ioc->HostPageBuffer_dma); in mpt_host_page_alloc()
1357 ioc->facts.HostPageBufferSGE = ioc_init->HostPageBufferSGE; in mpt_host_page_alloc()
1362 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
1364 * mpt_verify_adapter - Given IOC identifier, set pointer to its adapter structure.
1372 * Returns -1 if iocid is not found.
1380 if (ioc->id == iocid) { in mpt_verify_adapter()
1387 return -1; in mpt_verify_adapter()
1391 * mpt_get_product_name - returns product string
1631 * mpt_mapresources - map in memory mapped io
1644 int r = -ENODEV; in mpt_mapresources()
1647 pdev = ioc->pcidev; in mpt_mapresources()
1648 ioc->bars = pci_select_bars(pdev, IORESOURCE_MEM); in mpt_mapresources()
1651 "failed\n", ioc->name); in mpt_mapresources()
1654 if (pci_request_selected_regions(pdev, ioc->bars, "mpt")) { in mpt_mapresources()
1656 "MEM failed\n", ioc->name); in mpt_mapresources()
1662 (&pdev->dev); in mpt_mapresources()
1664 && !dma_set_mask(&pdev->dev, DMA_BIT_MASK(64)) in mpt_mapresources()
1665 && !dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(64))) { in mpt_mapresources()
1666 ioc->dma_mask = DMA_BIT_MASK(64); in mpt_mapresources()
1669 ioc->name)); in mpt_mapresources()
1670 } else if (!dma_set_mask(&pdev->dev, DMA_BIT_MASK(32)) in mpt_mapresources()
1671 && !dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(32))) { in mpt_mapresources()
1672 ioc->dma_mask = DMA_BIT_MASK(32); in mpt_mapresources()
1675 ioc->name)); in mpt_mapresources()
1678 ioc->name, pci_name(pdev)); in mpt_mapresources()
1682 if (!dma_set_mask(&pdev->dev, DMA_BIT_MASK(32)) in mpt_mapresources()
1683 && !dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(32))) { in mpt_mapresources()
1684 ioc->dma_mask = DMA_BIT_MASK(32); in mpt_mapresources()
1687 ioc->name)); in mpt_mapresources()
1690 ioc->name, pci_name(pdev)); in mpt_mapresources()
1712 ioc->mem_size = msize; in mpt_mapresources()
1719 printk(MYIOC_s_ERR_FMT ": ERROR - Unable to map adapter" in mpt_mapresources()
1720 " memory!\n", ioc->name); in mpt_mapresources()
1721 r = -EINVAL; in mpt_mapresources()
1724 ioc->memmap = mem; in mpt_mapresources()
1726 ioc->name, mem, (unsigned long long)mem_phys)); in mpt_mapresources()
1728 ioc->mem_phys = mem_phys; in mpt_mapresources()
1729 ioc->chip = (SYSIF_REGS __iomem *)mem; in mpt_mapresources()
1732 ioc->pio_mem_phys = port; in mpt_mapresources()
1733 ioc->pio_chip = (SYSIF_REGS __iomem *)port; in mpt_mapresources()
1738 pci_release_selected_regions(pdev, ioc->bars); in mpt_mapresources()
1744 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
1746 * mpt_attach - Install a PCI intelligent MPT adapter.
1752 * memory regions, registering the interrupt, and allocating request
1755 * This routine also pre-fetches the LAN MAC address of a Fibre Channel
1758 * Returns 0 for success, non-zero for failure.
1767 int r = -ENODEV; in mpt_attach()
1776 printk(KERN_ERR MYNAM ": ERROR - Insufficient memory to add adapter!\n"); in mpt_attach()
1777 return -ENOMEM; in mpt_attach()
1780 ioc->id = mpt_ids++; in mpt_attach()
1781 sprintf(ioc->name, "ioc%d", ioc->id); in mpt_attach()
1789 ioc->debug_level = mpt_debug_level; in mpt_attach()
1793 dinitprintk(ioc, printk(MYIOC_s_INFO_FMT ": mpt_adapter_install\n", ioc->name)); in mpt_attach()
1795 ioc->pcidev = pdev; in mpt_attach()
1803 if (ioc->dma_mask == DMA_BIT_MASK(64)) { in mpt_attach()
1804 if (pdev->device == MPI_MANUFACTPAGE_DEVID_SAS1078) in mpt_attach()
1805 ioc->add_sge = &mpt_add_sge_64bit_1078; in mpt_attach()
1807 ioc->add_sge = &mpt_add_sge_64bit; in mpt_attach()
1808 ioc->add_chain = &mpt_add_chain_64bit; in mpt_attach()
1809 ioc->sg_addr_size = 8; in mpt_attach()
1811 ioc->add_sge = &mpt_add_sge; in mpt_attach()
1812 ioc->add_chain = &mpt_add_chain; in mpt_attach()
1813 ioc->sg_addr_size = 4; in mpt_attach()
1815 ioc->SGE_size = sizeof(u32) + ioc->sg_addr_size; in mpt_attach()
1817 ioc->alloc_total = sizeof(MPT_ADAPTER); in mpt_attach()
1818 ioc->req_sz = MPT_DEFAULT_FRAME_SIZE; /* avoid div by zero! */ in mpt_attach()
1819 ioc->reply_sz = MPT_REPLY_FRAME_SIZE; in mpt_attach()
1822 spin_lock_init(&ioc->taskmgmt_lock); in mpt_attach()
1823 mutex_init(&ioc->internal_cmds.mutex); in mpt_attach()
1824 init_completion(&ioc->internal_cmds.done); in mpt_attach()
1825 mutex_init(&ioc->mptbase_cmds.mutex); in mpt_attach()
1826 init_completion(&ioc->mptbase_cmds.done); in mpt_attach()
1827 mutex_init(&ioc->taskmgmt_cmds.mutex); in mpt_attach()
1828 init_completion(&ioc->taskmgmt_cmds.done); in mpt_attach()
1832 ioc->eventTypes = 0; /* None */ in mpt_attach()
1833 ioc->eventContext = 0; in mpt_attach()
1834 ioc->eventLogSize = 0; in mpt_attach()
1835 ioc->events = NULL; in mpt_attach()
1838 ioc->mfcnt = 0; in mpt_attach()
1841 ioc->sh = NULL; in mpt_attach()
1842 ioc->cached_fw = NULL; in mpt_attach()
1846 memset(&ioc->spi_data, 0, sizeof(SpiCfgData)); in mpt_attach()
1850 INIT_LIST_HEAD(&ioc->fc_rports); in mpt_attach()
1853 INIT_LIST_HEAD(&ioc->list); in mpt_attach()
1857 INIT_DELAYED_WORK(&ioc->fault_reset_work, mpt_fault_reset_work); in mpt_attach()
1859 snprintf(ioc->reset_work_q_name, MPT_KOBJ_NAME_LEN, in mpt_attach()
1860 "mpt_poll_%d", ioc->id); in mpt_attach()
1861 ioc->reset_work_q = alloc_workqueue(ioc->reset_work_q_name, in mpt_attach()
1863 if (!ioc->reset_work_q) { in mpt_attach()
1865 ioc->name); in mpt_attach()
1866 r = -ENOMEM; in mpt_attach()
1871 ioc->name, &ioc->facts, &ioc->pfacts[0])); in mpt_attach()
1873 ioc->prod_name = mpt_get_product_name(pdev->vendor, pdev->device, in mpt_attach()
1874 pdev->revision); in mpt_attach()
1876 switch (pdev->device) in mpt_attach()
1880 ioc->errata_flag_1064 = 1; in mpt_attach()
1886 ioc->bus_type = FC; in mpt_attach()
1890 if (pdev->revision < XL_929) { in mpt_attach()
1904 ioc->bus_type = FC; in mpt_attach()
1914 ioc->bus_type = FC; in mpt_attach()
1921 if (pdev->revision < C0_1030) { in mpt_attach()
1929 ioc->bus_type = SPI; in mpt_attach()
1934 ioc->errata_flag_1064 = 1; in mpt_attach()
1935 ioc->bus_type = SAS; in mpt_attach()
1941 ioc->bus_type = SAS; in mpt_attach()
1946 switch (ioc->bus_type) { in mpt_attach()
1949 ioc->msi_enable = mpt_msi_enable_sas; in mpt_attach()
1953 ioc->msi_enable = mpt_msi_enable_spi; in mpt_attach()
1957 ioc->msi_enable = mpt_msi_enable_fc; in mpt_attach()
1961 ioc->msi_enable = 0; in mpt_attach()
1965 ioc->fw_events_off = 1; in mpt_attach()
1967 if (ioc->errata_flag_1064) in mpt_attach()
1970 spin_lock_init(&ioc->FreeQlock); in mpt_attach()
1973 CHIPREG_WRITE32(&ioc->chip->IntMask, 0xFFFFFFFF); in mpt_attach()
1974 ioc->active = 0; in mpt_attach()
1975 CHIPREG_WRITE32(&ioc->chip->IntStatus, 0); in mpt_attach()
1978 pci_set_drvdata(ioc->pcidev, ioc); in mpt_attach()
1981 list_add_tail(&ioc->list, &ioc_list); in mpt_attach()
1987 INIT_LIST_HEAD(&ioc->fw_event_list); in mpt_attach()
1988 spin_lock_init(&ioc->fw_event_lock); in mpt_attach()
1989 snprintf(ioc->fw_event_q_name, MPT_KOBJ_NAME_LEN, "mpt/%d", ioc->id); in mpt_attach()
1990 ioc->fw_event_q = alloc_workqueue(ioc->fw_event_q_name, in mpt_attach()
1992 if (!ioc->fw_event_q) { in mpt_attach()
1994 ioc->name); in mpt_attach()
1995 r = -ENOMEM; in mpt_attach()
2002 ioc->name, r); in mpt_attach()
2004 destroy_workqueue(ioc->fw_event_q); in mpt_attach()
2005 ioc->fw_event_q = NULL; in mpt_attach()
2007 list_del(&ioc->list); in mpt_attach()
2008 if (ioc->alt_ioc) in mpt_attach()
2009 ioc->alt_ioc->alt_ioc = NULL; in mpt_attach()
2010 iounmap(ioc->memmap); in mpt_attach()
2013 if (r != -5) in mpt_attach()
2014 pci_release_selected_regions(pdev, ioc->bars); in mpt_attach()
2016 destroy_workqueue(ioc->reset_work_q); in mpt_attach()
2017 ioc->reset_work_q = NULL; in mpt_attach()
2026 MptDeviceDriverHandlers[cb_idx]->probe) { in mpt_attach()
2027 MptDeviceDriverHandlers[cb_idx]->probe(pdev); in mpt_attach()
2035 dent = proc_mkdir(ioc->name, mpt_proc_root_dir); in mpt_attach()
2044 if (!ioc->alt_ioc) in mpt_attach()
2045 queue_delayed_work(ioc->reset_work_q, &ioc->fault_reset_work, in mpt_attach()
2051 list_del(&ioc->list); in mpt_attach()
2052 if (ioc->alt_ioc) in mpt_attach()
2053 ioc->alt_ioc->alt_ioc = NULL; in mpt_attach()
2055 destroy_workqueue(ioc->reset_work_q); in mpt_attach()
2056 ioc->reset_work_q = NULL; in mpt_attach()
2059 iounmap(ioc->memmap); in mpt_attach()
2061 pci_release_selected_regions(pdev, ioc->bars); in mpt_attach()
2069 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
2071 * mpt_detach - Remove a PCI intelligent MPT adapter.
2087 spin_lock_irqsave(&ioc->taskmgmt_lock, flags); in mpt_detach()
2088 wq = ioc->reset_work_q; in mpt_detach()
2089 ioc->reset_work_q = NULL; in mpt_detach()
2090 spin_unlock_irqrestore(&ioc->taskmgmt_lock, flags); in mpt_detach()
2091 cancel_delayed_work(&ioc->fault_reset_work); in mpt_detach()
2094 spin_lock_irqsave(&ioc->fw_event_lock, flags); in mpt_detach()
2095 wq = ioc->fw_event_q; in mpt_detach()
2096 ioc->fw_event_q = NULL; in mpt_detach()
2097 spin_unlock_irqrestore(&ioc->fw_event_lock, flags); in mpt_detach()
2100 snprintf(pname, sizeof(pname), MPT_PROCFS_MPTBASEDIR "/%s/summary", ioc->name); in mpt_detach()
2102 snprintf(pname, sizeof(pname), MPT_PROCFS_MPTBASEDIR "/%s/info", ioc->name); in mpt_detach()
2104 snprintf(pname, sizeof(pname), MPT_PROCFS_MPTBASEDIR "/%s", ioc->name); in mpt_detach()
2110 MptDeviceDriverHandlers[cb_idx]->remove) { in mpt_detach()
2111 MptDeviceDriverHandlers[cb_idx]->remove(pdev); in mpt_detach()
2116 CHIPREG_WRITE32(&ioc->chip->IntMask, 0xFFFFFFFF); in mpt_detach()
2118 ioc->active = 0; in mpt_detach()
2119 synchronize_irq(pdev->irq); in mpt_detach()
2122 CHIPREG_WRITE32(&ioc->chip->IntStatus, 0); in mpt_detach()
2124 CHIPREG_READ32(&ioc->chip->IntStatus); in mpt_detach()
2134 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
2136 * mpt_suspend - Fusion MPT base driver suspend routine.
2147 printk(MYIOC_s_INFO_FMT "pci-suspend: pdev=0x%p, slot=%s, Entering " in mpt_suspend()
2148 "operating state [D%d]\n", ioc->name, pdev, pci_name(pdev), in mpt_suspend()
2154 "pci-suspend: IOC msg unit reset failed!\n", ioc->name); in mpt_suspend()
2158 CHIPREG_WRITE32(&ioc->chip->IntMask, 0xFFFFFFFF); in mpt_suspend()
2159 ioc->active = 0; in mpt_suspend()
2162 CHIPREG_WRITE32(&ioc->chip->IntStatus, 0); in mpt_suspend()
2164 free_irq(ioc->pci_irq, ioc); in mpt_suspend()
2165 if (ioc->msi_enable) in mpt_suspend()
2166 pci_disable_msi(ioc->pcidev); in mpt_suspend()
2167 ioc->pci_irq = -1; in mpt_suspend()
2170 pci_release_selected_regions(pdev, ioc->bars); in mpt_suspend()
2175 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
2177 * mpt_resume - Fusion MPT base driver resume routine.
2184 u32 device_state = pdev->current_state; in mpt_resume()
2188 printk(MYIOC_s_INFO_FMT "pci-resume: pdev=0x%p, slot=%s, Previous " in mpt_resume()
2189 "operating state [D%d]\n", ioc->name, pdev, pci_name(pdev), in mpt_resume()
2195 ioc->pcidev = pdev; in mpt_resume()
2200 if (ioc->dma_mask == DMA_BIT_MASK(64)) { in mpt_resume()
2201 if (pdev->device == MPI_MANUFACTPAGE_DEVID_SAS1078) in mpt_resume()
2202 ioc->add_sge = &mpt_add_sge_64bit_1078; in mpt_resume()
2204 ioc->add_sge = &mpt_add_sge_64bit; in mpt_resume()
2205 ioc->add_chain = &mpt_add_chain_64bit; in mpt_resume()
2206 ioc->sg_addr_size = 8; in mpt_resume()
2209 ioc->add_sge = &mpt_add_sge; in mpt_resume()
2210 ioc->add_chain = &mpt_add_chain; in mpt_resume()
2211 ioc->sg_addr_size = 4; in mpt_resume()
2213 ioc->SGE_size = sizeof(u32) + ioc->sg_addr_size; in mpt_resume()
2215 printk(MYIOC_s_INFO_FMT "pci-resume: ioc-state=0x%x,doorbell=0x%x\n", in mpt_resume()
2216 ioc->name, (mpt_GetIocState(ioc, 1) >> MPI_IOC_STATE_SHIFT), in mpt_resume()
2217 CHIPREG_READ32(&ioc->chip->Doorbell)); in mpt_resume()
2226 if (ioc->bus_type == SAS && (pdev->device == in mpt_resume()
2227 MPI_MANUFACTPAGE_DEVID_SAS1068E || pdev->device == in mpt_resume()
2230 printk(MYIOC_s_WARN_FMT "pci-resume: Cannot recover\n", in mpt_resume()
2231 ioc->name); in mpt_resume()
2237 printk(MYIOC_s_INFO_FMT "Sending mpt_do_ioc_recovery\n", ioc->name); in mpt_resume()
2241 printk(MYIOC_s_WARN_FMT "pci-resume: Cannot recover, " in mpt_resume()
2242 "error:[%x]\n", ioc->name, recovery_state); in mpt_resume()
2245 "pci-resume: success\n", ioc->name); in mpt_resume()
2256 ioc->bus_type != SPI) || in mpt_signal_reset()
2258 ioc->bus_type != FC) || in mpt_signal_reset()
2260 ioc->bus_type != SAS)) in mpt_signal_reset()
2267 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
2269 * mpt_do_ioc_recovery - Initialize or recover MPT adapter.
2277 * This routine also pre-fetches the LAN MAC address of a Fibre Channel
2282 * -1 if failed to get board READY
2283 * -2 if READY but IOCFacts Failed
2284 * -3 if READY but PrimeIOCFifos Failed
2285 * -4 if READY but IOCInit Failed
2286 * -5 if failed to enable_device and/or request_selected_regions
2287 * -6 if failed to upload firmware
2302 printk(MYIOC_s_INFO_FMT "Initiating %s\n", ioc->name, in mpt_do_ioc_recovery()
2306 CHIPREG_WRITE32(&ioc->chip->IntMask, 0xFFFFFFFF); in mpt_do_ioc_recovery()
2307 ioc->active = 0; in mpt_do_ioc_recovery()
2309 if (ioc->alt_ioc) { in mpt_do_ioc_recovery()
2310 if (ioc->alt_ioc->active || in mpt_do_ioc_recovery()
2313 /* Disable alt-IOC's reply interrupts in mpt_do_ioc_recovery()
2316 CHIPREG_WRITE32(&ioc->alt_ioc->chip->IntMask, in mpt_do_ioc_recovery()
2318 ioc->alt_ioc->active = 0; in mpt_do_ioc_recovery()
2327 if (hard_reset_done == -4) { in mpt_do_ioc_recovery()
2329 ioc->name); in mpt_do_ioc_recovery()
2331 if (reset_alt_ioc_active && ioc->alt_ioc) { in mpt_do_ioc_recovery()
2332 /* (re)Enable alt-IOC! (reply interrupt, FreeQ) */ in mpt_do_ioc_recovery()
2334 "alt_ioc reply irq re-enabled\n", ioc->alt_ioc->name)); in mpt_do_ioc_recovery()
2335 CHIPREG_WRITE32(&ioc->alt_ioc->chip->IntMask, MPI_HIM_DIM); in mpt_do_ioc_recovery()
2336 ioc->alt_ioc->active = 1; in mpt_do_ioc_recovery()
2341 "NOT READY WARNING!\n", ioc->name); in mpt_do_ioc_recovery()
2343 ret = -1; in mpt_do_ioc_recovery()
2350 if (hard_reset_done && reset_alt_ioc_active && ioc->alt_ioc) { in mpt_do_ioc_recovery()
2351 if ((rc = MakeIocReady(ioc->alt_ioc, 0, sleepFlag)) == 0) in mpt_do_ioc_recovery()
2355 ": alt-ioc Not ready WARNING!\n", in mpt_do_ioc_recovery()
2356 ioc->alt_ioc->name); in mpt_do_ioc_recovery()
2368 "Retry IocFacts failed rc=%x\n", ioc->name, rc)); in mpt_do_ioc_recovery()
2369 ret = -2; in mpt_do_ioc_recovery()
2375 if ((rc = GetIocFacts(ioc->alt_ioc, sleepFlag, reason)) != 0) { in mpt_do_ioc_recovery()
2378 ioc->name, rc)); in mpt_do_ioc_recovery()
2379 /* Retry - alt IOC was initialized once in mpt_do_ioc_recovery()
2381 rc = GetIocFacts(ioc->alt_ioc, sleepFlag, reason); in mpt_do_ioc_recovery()
2385 "Retry Alt IocFacts failed rc=%x\n", ioc->name, rc)); in mpt_do_ioc_recovery()
2389 MptDisplayIocCapabilities(ioc->alt_ioc); in mpt_do_ioc_recovery()
2394 (ioc->facts.Flags & MPI_IOCFACTS_FLAGS_FW_DOWNLOAD_BOOT)) { in mpt_do_ioc_recovery()
2395 pci_release_selected_regions(ioc->pcidev, ioc->bars); in mpt_do_ioc_recovery()
2396 ioc->bars = pci_select_bars(ioc->pcidev, IORESOURCE_MEM | in mpt_do_ioc_recovery()
2398 if (pci_enable_device(ioc->pcidev)) in mpt_do_ioc_recovery()
2399 return -5; in mpt_do_ioc_recovery()
2400 if (pci_request_selected_regions(ioc->pcidev, ioc->bars, in mpt_do_ioc_recovery()
2402 return -5; in mpt_do_ioc_recovery()
2406 * Device is reset now. It must have de-asserted the interrupt line in mpt_do_ioc_recovery()
2411 ioc->pci_irq = -1; in mpt_do_ioc_recovery()
2412 if (ioc->pcidev->irq) { in mpt_do_ioc_recovery()
2413 if (ioc->msi_enable && !pci_enable_msi(ioc->pcidev)) in mpt_do_ioc_recovery()
2414 printk(MYIOC_s_INFO_FMT "PCI-MSI enabled\n", in mpt_do_ioc_recovery()
2415 ioc->name); in mpt_do_ioc_recovery()
2417 ioc->msi_enable = 0; in mpt_do_ioc_recovery()
2418 rc = request_irq(ioc->pcidev->irq, mpt_interrupt, in mpt_do_ioc_recovery()
2419 IRQF_SHARED, ioc->name, ioc); in mpt_do_ioc_recovery()
2423 ioc->name, ioc->pcidev->irq); in mpt_do_ioc_recovery()
2424 if (ioc->msi_enable) in mpt_do_ioc_recovery()
2425 pci_disable_msi(ioc->pcidev); in mpt_do_ioc_recovery()
2426 ret = -EBUSY; in mpt_do_ioc_recovery()
2430 ioc->pci_irq = ioc->pcidev->irq; in mpt_do_ioc_recovery()
2431 pci_set_master(ioc->pcidev); /* ?? */ in mpt_do_ioc_recovery()
2432 pci_set_drvdata(ioc->pcidev, ioc); in mpt_do_ioc_recovery()
2434 "installed at interrupt %d\n", ioc->name, in mpt_do_ioc_recovery()
2435 ioc->pcidev->irq)); in mpt_do_ioc_recovery()
2442 * If fails, continue with alt-ioc processing in mpt_do_ioc_recovery()
2445 ioc->name)); in mpt_do_ioc_recovery()
2447 ret = -3; in mpt_do_ioc_recovery()
2450 * If fails, continue with alt-ioc processing in mpt_do_ioc_recovery()
2453 ioc->name)); in mpt_do_ioc_recovery()
2455 ret = -4; in mpt_do_ioc_recovery()
2457 if (alt_ioc_ready && ((rc = PrimeIocFifos(ioc->alt_ioc)) != 0)) { in mpt_do_ioc_recovery()
2459 ": alt-ioc (%d) FIFO mgmt alloc WARNING!\n", in mpt_do_ioc_recovery()
2460 ioc->alt_ioc->name, rc); in mpt_do_ioc_recovery()
2466 if ((rc = SendIocInit(ioc->alt_ioc, sleepFlag)) != 0) { in mpt_do_ioc_recovery()
2470 ": alt-ioc: (%d) init failure WARNING!\n", in mpt_do_ioc_recovery()
2471 ioc->alt_ioc->name, rc); in mpt_do_ioc_recovery()
2476 if (ioc->upload_fw) { in mpt_do_ioc_recovery()
2478 "firmware upload required!\n", ioc->name)); in mpt_do_ioc_recovery()
2485 if (ioc->alt_ioc && ioc->alt_ioc->cached_fw) { in mpt_do_ioc_recovery()
2495 ioc->name, ioc->alt_ioc->name, ioc->alt_ioc->cached_fw)); in mpt_do_ioc_recovery()
2496 ioc->cached_fw = NULL; in mpt_do_ioc_recovery()
2500 "firmware upload failure!\n", ioc->name); in mpt_do_ioc_recovery()
2501 ret = -6; in mpt_do_ioc_recovery()
2510 if ((ret == 0) && (!ioc->facts.EventState)) { in mpt_do_ioc_recovery()
2513 ioc->name)); in mpt_do_ioc_recovery()
2517 if (ioc->alt_ioc && alt_ioc_ready && !ioc->alt_ioc->facts.EventState) in mpt_do_ioc_recovery()
2518 rc = SendEventNotification(ioc->alt_ioc, 1, sleepFlag); in mpt_do_ioc_recovery()
2522 CHIPREG_WRITE32(&ioc->chip->IntMask, MPI_HIM_DIM); in mpt_do_ioc_recovery()
2523 ioc->active = 1; in mpt_do_ioc_recovery()
2526 if (reset_alt_ioc_active && ioc->alt_ioc) { in mpt_do_ioc_recovery()
2527 /* (re)Enable alt-IOC! (reply interrupt) */ in mpt_do_ioc_recovery()
2528 dinitprintk(ioc, printk(MYIOC_s_DEBUG_FMT "alt-ioc" in mpt_do_ioc_recovery()
2529 "reply irq re-enabled\n", in mpt_do_ioc_recovery()
2530 ioc->alt_ioc->name)); in mpt_do_ioc_recovery()
2531 CHIPREG_WRITE32(&ioc->alt_ioc->chip->IntMask, in mpt_do_ioc_recovery()
2533 ioc->alt_ioc->active = 1; in mpt_do_ioc_recovery()
2549 mutex_init(&ioc->raid_data.inactive_list_mutex); in mpt_do_ioc_recovery()
2550 INIT_LIST_HEAD(&ioc->raid_data.inactive_list); in mpt_do_ioc_recovery()
2552 switch (ioc->bus_type) { in mpt_do_ioc_recovery()
2556 if(ioc->facts.IOCExceptions & in mpt_do_ioc_recovery()
2575 if ((ioc->pfacts[0].ProtocolFlags & in mpt_do_ioc_recovery()
2577 (ioc->lan_cnfg_page0.Header.PageLength == 0)) { in mpt_do_ioc_recovery()
2579 * Pre-fetch the ports LAN MAC address! in mpt_do_ioc_recovery()
2583 a = (u8*)&ioc->lan_cnfg_page1.HardwareAddressLow; in mpt_do_ioc_recovery()
2585 "LanAddr = %pMR\n", ioc->name, a)); in mpt_do_ioc_recovery()
2600 if (ioc->facts.MsgVersion >= MPI_VERSION_01_02) in mpt_do_ioc_recovery()
2618 free_irq(ioc->pci_irq, ioc); in mpt_do_ioc_recovery()
2619 if (ioc->msi_enable) in mpt_do_ioc_recovery()
2620 pci_disable_msi(ioc->pcidev); in mpt_do_ioc_recovery()
2625 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
2627 * mpt_detect_bound_ports - Search for matching PCI bus/dev_function
2632 * PCI bus/dev_function (+/-1) for newly discovered 929,
2635 * If match on PCI dev_function +/-1 is found, bind the two MPT adapters
2642 unsigned int slot = PCI_SLOT(pdev->devfn); in mpt_detect_bound_ports()
2643 unsigned int func = PCI_FUNC(pdev->devfn); in mpt_detect_bound_ports()
2648 ioc->name, pci_name(pdev), pdev->bus->number, in mpt_detect_bound_ports()
2649 pdev->devfn, func-1, func+1)); in mpt_detect_bound_ports()
2651 peer = pci_get_slot(pdev->bus, PCI_DEVFN(slot,func-1)); in mpt_detect_bound_ports()
2653 peer = pci_get_slot(pdev->bus, PCI_DEVFN(slot,func+1)); in mpt_detect_bound_ports()
2659 struct pci_dev *_pcidev = ioc_srch->pcidev; in mpt_detect_bound_ports()
2662 if (ioc->alt_ioc != NULL) { in mpt_detect_bound_ports()
2665 ioc->name, ioc->name, ioc->alt_ioc->name); in mpt_detect_bound_ports()
2667 } else if (ioc_srch->alt_ioc != NULL) { in mpt_detect_bound_ports()
2670 ioc_srch->name, ioc_srch->name, in mpt_detect_bound_ports()
2671 ioc_srch->alt_ioc->name); in mpt_detect_bound_ports()
2676 ioc->name, ioc->name, ioc_srch->name)); in mpt_detect_bound_ports()
2677 ioc_srch->alt_ioc = ioc; in mpt_detect_bound_ports()
2678 ioc->alt_ioc = ioc_srch; in mpt_detect_bound_ports()
2684 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
2686 * mpt_adapter_disable - Disable misbehaving MPT adapter.
2695 if (ioc->cached_fw != NULL) { in mpt_adapter_disable()
2697 "%s: Pushing FW onto adapter\n", __func__, ioc->name)); in mpt_adapter_disable()
2699 ioc->cached_fw, CAN_SLEEP)) < 0) { in mpt_adapter_disable()
2702 ioc->name, ret); in mpt_adapter_disable()
2715 ioc->name, __func__); in mpt_adapter_disable()
2718 "failed!\n", ioc->name, __func__); in mpt_adapter_disable()
2723 synchronize_irq(ioc->pcidev->irq); in mpt_adapter_disable()
2724 CHIPREG_WRITE32(&ioc->chip->IntMask, 0xFFFFFFFF); in mpt_adapter_disable()
2725 ioc->active = 0; in mpt_adapter_disable()
2728 CHIPREG_WRITE32(&ioc->chip->IntStatus, 0); in mpt_adapter_disable()
2729 CHIPREG_READ32(&ioc->chip->IntStatus); in mpt_adapter_disable()
2731 if (ioc->alloc != NULL) { in mpt_adapter_disable()
2732 sz = ioc->alloc_sz; in mpt_adapter_disable()
2734 ioc->name, ioc->alloc, ioc->alloc_sz)); in mpt_adapter_disable()
2735 dma_free_coherent(&ioc->pcidev->dev, sz, ioc->alloc, in mpt_adapter_disable()
2736 ioc->alloc_dma); in mpt_adapter_disable()
2737 ioc->reply_frames = NULL; in mpt_adapter_disable()
2738 ioc->req_frames = NULL; in mpt_adapter_disable()
2739 ioc->alloc = NULL; in mpt_adapter_disable()
2740 ioc->alloc_total -= sz; in mpt_adapter_disable()
2743 if (ioc->sense_buf_pool != NULL) { in mpt_adapter_disable()
2744 sz = (ioc->req_depth * MPT_SENSE_BUFFER_ALLOC); in mpt_adapter_disable()
2745 dma_free_coherent(&ioc->pcidev->dev, sz, ioc->sense_buf_pool, in mpt_adapter_disable()
2746 ioc->sense_buf_pool_dma); in mpt_adapter_disable()
2747 ioc->sense_buf_pool = NULL; in mpt_adapter_disable()
2748 ioc->alloc_total -= sz; in mpt_adapter_disable()
2751 if (ioc->events != NULL){ in mpt_adapter_disable()
2753 kfree(ioc->events); in mpt_adapter_disable()
2754 ioc->events = NULL; in mpt_adapter_disable()
2755 ioc->alloc_total -= sz; in mpt_adapter_disable()
2760 kfree(ioc->spi_data.nvram); in mpt_adapter_disable()
2762 kfree(ioc->raid_data.pIocPg2); in mpt_adapter_disable()
2763 kfree(ioc->raid_data.pIocPg3); in mpt_adapter_disable()
2764 ioc->spi_data.nvram = NULL; in mpt_adapter_disable()
2765 ioc->raid_data.pIocPg3 = NULL; in mpt_adapter_disable()
2767 if (ioc->spi_data.pIocPg4 != NULL) { in mpt_adapter_disable()
2768 sz = ioc->spi_data.IocPg4Sz; in mpt_adapter_disable()
2769 dma_free_coherent(&ioc->pcidev->dev, sz, in mpt_adapter_disable()
2770 ioc->spi_data.pIocPg4, in mpt_adapter_disable()
2771 ioc->spi_data.IocPg4_dma); in mpt_adapter_disable()
2772 ioc->spi_data.pIocPg4 = NULL; in mpt_adapter_disable()
2773 ioc->alloc_total -= sz; in mpt_adapter_disable()
2776 if (ioc->ReqToChain != NULL) { in mpt_adapter_disable()
2777 kfree(ioc->ReqToChain); in mpt_adapter_disable()
2778 kfree(ioc->RequestNB); in mpt_adapter_disable()
2779 ioc->ReqToChain = NULL; in mpt_adapter_disable()
2782 kfree(ioc->ChainToChain); in mpt_adapter_disable()
2783 ioc->ChainToChain = NULL; in mpt_adapter_disable()
2785 if (ioc->HostPageBuffer != NULL) { in mpt_adapter_disable()
2790 ioc->name, __func__, ret); in mpt_adapter_disable()
2794 ioc->name, ioc->HostPageBuffer, in mpt_adapter_disable()
2795 ioc->HostPageBuffer_sz)); in mpt_adapter_disable()
2796 dma_free_coherent(&ioc->pcidev->dev, ioc->HostPageBuffer_sz, in mpt_adapter_disable()
2797 ioc->HostPageBuffer, ioc->HostPageBuffer_dma); in mpt_adapter_disable()
2798 ioc->HostPageBuffer = NULL; in mpt_adapter_disable()
2799 ioc->HostPageBuffer_sz = 0; in mpt_adapter_disable()
2800 ioc->alloc_total -= ioc->HostPageBuffer_sz; in mpt_adapter_disable()
2803 pci_set_drvdata(ioc->pcidev, NULL); in mpt_adapter_disable()
2805 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
2807 * mpt_adapter_dispose - Free all resources associated with an MPT adapter
2821 sz_first = ioc->alloc_total; in mpt_adapter_dispose()
2825 if (ioc->pci_irq != -1) { in mpt_adapter_dispose()
2826 free_irq(ioc->pci_irq, ioc); in mpt_adapter_dispose()
2827 if (ioc->msi_enable) in mpt_adapter_dispose()
2828 pci_disable_msi(ioc->pcidev); in mpt_adapter_dispose()
2829 ioc->pci_irq = -1; in mpt_adapter_dispose()
2832 if (ioc->memmap != NULL) { in mpt_adapter_dispose()
2833 iounmap(ioc->memmap); in mpt_adapter_dispose()
2834 ioc->memmap = NULL; in mpt_adapter_dispose()
2837 pci_disable_device(ioc->pcidev); in mpt_adapter_dispose()
2838 pci_release_selected_regions(ioc->pcidev, ioc->bars); in mpt_adapter_dispose()
2841 list_del(&ioc->list); in mpt_adapter_dispose()
2843 sz_last = ioc->alloc_total; in mpt_adapter_dispose()
2845 ioc->name, sz_first-sz_last+(int)sizeof(*ioc), sz_first)); in mpt_adapter_dispose()
2847 if (ioc->alt_ioc) in mpt_adapter_dispose()
2848 ioc->alt_ioc->alt_ioc = NULL; in mpt_adapter_dispose()
2853 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
2855 * MptDisplayIocCapabilities - Disply IOC's capabilities.
2863 printk(KERN_INFO "%s: ", ioc->name); in MptDisplayIocCapabilities()
2864 if (ioc->prod_name) in MptDisplayIocCapabilities()
2865 pr_cont("%s: ", ioc->prod_name); in MptDisplayIocCapabilities()
2868 if (ioc->pfacts[0].ProtocolFlags & MPI_PORTFACTS_PROTOCOL_INITIATOR) { in MptDisplayIocCapabilities()
2873 if (ioc->pfacts[0].ProtocolFlags & MPI_PORTFACTS_PROTOCOL_TARGET) { in MptDisplayIocCapabilities()
2878 if (ioc->pfacts[0].ProtocolFlags & MPI_PORTFACTS_PROTOCOL_LAN) { in MptDisplayIocCapabilities()
2887 if (ioc->pfacts[0].ProtocolFlags & MPI_PORTFACTS_PROTOCOL_TARGET) { in MptDisplayIocCapabilities()
2896 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
2898 * MakeIocReady - Get IOC to a READY state, using KickStart if needed.
2904 * 1 - DIAG reset and READY
2905 * 0 - READY initially OR soft reset and READY
2906 * -1 - Any failure on KickStart
2907 * -2 - Msg Unit Reset Failed
2908 * -3 - IO Unit Reset Failed
2909 * -4 - IOC owned by a PEER
2924 dhsprintk(ioc, printk(MYIOC_s_INFO_FMT "MakeIocReady [raw] state=%08x\n", ioc->name, ioc_state)); in MakeIocReady()
2933 ioc->name); in MakeIocReady()
2940 "IOC is in READY state\n", ioc->name)); in MakeIocReady()
2950 ioc->name); in MakeIocReady()
2952 ioc->name, ioc_state & MPI_DOORBELL_DATA_MASK); in MakeIocReady()
2960 ioc->name)); in MakeIocReady()
2970 ioc->name, whoinit, statefault, force)); in MakeIocReady()
2972 return -4; in MakeIocReady()
2984 return -1; in MakeIocReady()
2999 printk(MYIOC_s_ERR_FMT "IOC msg unit reset failed!\n", ioc->name); in MakeIocReady()
3000 return -2; in MakeIocReady()
3008 printk(MYIOC_s_ERR_FMT "IO unit reset failed!\n", ioc->name); in MakeIocReady()
3009 return -3; in MakeIocReady()
3013 ii++; cntdn--; in MakeIocReady()
3017 ioc->name, ioc_state, (int)((ii+5)/HZ)); in MakeIocReady()
3018 return -ETIME; in MakeIocReady()
3030 printk(MYIOC_s_INFO_FMT "Recovered from %s\n", ioc->name, in MakeIocReady()
3037 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
3039 * mpt_GetIocState - Get the current state of a MPT adapter.
3052 s = CHIPREG_READ32(&ioc->chip->Doorbell); in mpt_GetIocState()
3056 ioc->last_state = sc; in mpt_GetIocState()
3061 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
3063 * GetIocFacts - Send IOCFacts request to MPT adapter.
3068 * Returns 0 for success, non-zero for failure.
3083 if (ioc->last_state == MPI_IOC_STATE_RESET) { in GetIocFacts()
3085 ": ERROR - Can't get IOCFacts, %s NOT READY! (%08x)\n", in GetIocFacts()
3086 ioc->name, ioc->last_state); in GetIocFacts()
3087 return -44; in GetIocFacts()
3090 facts = &ioc->facts; in GetIocFacts()
3105 ioc->name, req_sz, reply_sz)); in GetIocFacts()
3107 /* No non-zero fields in the get_facts request are greater than in GetIocFacts()
3123 if (facts->MsgLength > offsetof(IOCFactsReply_t, RequestFrameSize)/sizeof(u32)) { in GetIocFacts()
3128 if (ioc->FirstWhoInit == WHOINIT_UNKNOWN) in GetIocFacts()
3129 ioc->FirstWhoInit = facts->WhoInit; in GetIocFacts()
3132 facts->MsgVersion = le16_to_cpu(facts->MsgVersion); in GetIocFacts()
3133 facts->MsgContext = le32_to_cpu(facts->MsgContext); in GetIocFacts()
3134 facts->IOCExceptions = le16_to_cpu(facts->IOCExceptions); in GetIocFacts()
3135 facts->IOCStatus = le16_to_cpu(facts->IOCStatus); in GetIocFacts()
3136 facts->IOCLogInfo = le32_to_cpu(facts->IOCLogInfo); in GetIocFacts()
3139 facts->ReplyQueueDepth = le16_to_cpu(facts->ReplyQueueDepth); in GetIocFacts()
3140 facts->RequestFrameSize = le16_to_cpu(facts->RequestFrameSize); in GetIocFacts()
3147 if (facts->MsgVersion < MPI_VERSION_01_02) { in GetIocFacts()
3151 u16 oldv = le16_to_cpu(facts->Reserved_0101_FWVersion); in GetIocFacts()
3152 facts->FWVersion.Word = in GetIocFacts()
3156 facts->FWVersion.Word = le32_to_cpu(facts->FWVersion.Word); in GetIocFacts()
3158 facts->ProductID = le16_to_cpu(facts->ProductID); in GetIocFacts()
3160 if ((ioc->facts.ProductID & MPI_FW_HEADER_PID_PROD_MASK) in GetIocFacts()
3162 ioc->ir_firmware = 1; in GetIocFacts()
3164 facts->CurrentHostMfaHighAddr = in GetIocFacts()
3165 le32_to_cpu(facts->CurrentHostMfaHighAddr); in GetIocFacts()
3166 facts->GlobalCredits = le16_to_cpu(facts->GlobalCredits); in GetIocFacts()
3167 facts->CurrentSenseBufferHighAddr = in GetIocFacts()
3168 le32_to_cpu(facts->CurrentSenseBufferHighAddr); in GetIocFacts()
3169 facts->CurReplyFrameSize = in GetIocFacts()
3170 le16_to_cpu(facts->CurReplyFrameSize); in GetIocFacts()
3171 facts->IOCCapabilities = le32_to_cpu(facts->IOCCapabilities); in GetIocFacts()
3174 * Handle NEW (!) IOCFactsReply fields in MPI-1.01.xx in GetIocFacts()
3175 * Older MPI-1.00.xx struct had 13 dwords, and enlarged in GetIocFacts()
3176 * to 14 in MPI-1.01.0x. in GetIocFacts()
3178 if (facts->MsgLength >= (offsetof(IOCFactsReply_t,FWImageSize) + 7)/4 && in GetIocFacts()
3179 facts->MsgVersion > MPI_VERSION_01_00) { in GetIocFacts()
3180 facts->FWImageSize = le32_to_cpu(facts->FWImageSize); in GetIocFacts()
3183 facts->FWImageSize = ALIGN(facts->FWImageSize, 4); in GetIocFacts()
3185 if (!facts->RequestFrameSize) { in GetIocFacts()
3188 ioc->name); in GetIocFacts()
3189 return -55; in GetIocFacts()
3192 r = sz = facts->BlockSize; in GetIocFacts()
3194 ioc->NB_for_64_byte_frame = vv; in GetIocFacts()
3200 ioc->NBShiftFactor = shiftFactor; in GetIocFacts()
3203 ioc->name, vv, shiftFactor, r)); in GetIocFacts()
3210 ioc->req_sz = min(MPT_DEFAULT_FRAME_SIZE, facts->RequestFrameSize * 4); in GetIocFacts()
3211 ioc->req_depth = min_t(int, MPT_MAX_REQ_DEPTH, facts->GlobalCredits); in GetIocFacts()
3212 ioc->reply_sz = MPT_REPLY_FRAME_SIZE; in GetIocFacts()
3213 ioc->reply_depth = min_t(int, MPT_DEFAULT_REPLY_DEPTH, facts->ReplyQueueDepth); in GetIocFacts()
3216 ioc->name, ioc->reply_sz, ioc->reply_depth)); in GetIocFacts()
3218 ioc->name, ioc->req_sz, ioc->req_depth)); in GetIocFacts()
3227 ioc->name, facts->MsgLength, (offsetof(IOCFactsReply_t, in GetIocFacts()
3229 return -66; in GetIocFacts()
3235 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
3237 * GetPortFacts - Send PortFacts request to MPT adapter.
3242 * Returns 0 for success, non-zero for failure.
3255 if (ioc->last_state == MPI_IOC_STATE_RESET) { in GetPortFacts()
3257 ioc->name, ioc->last_state ); in GetPortFacts()
3258 return -4; in GetPortFacts()
3261 pfacts = &ioc->pfacts[portnum]; in GetPortFacts()
3276 ioc->name, portnum)); in GetPortFacts()
3278 /* No non-zero fields in the get_pfacts request are greater than in GetPortFacts()
3289 pfacts->MsgContext = le32_to_cpu(pfacts->MsgContext); in GetPortFacts()
3290 pfacts->IOCStatus = le16_to_cpu(pfacts->IOCStatus); in GetPortFacts()
3291 pfacts->IOCLogInfo = le32_to_cpu(pfacts->IOCLogInfo); in GetPortFacts()
3292 pfacts->MaxDevices = le16_to_cpu(pfacts->MaxDevices); in GetPortFacts()
3293 pfacts->PortSCSIID = le16_to_cpu(pfacts->PortSCSIID); in GetPortFacts()
3294 pfacts->ProtocolFlags = le16_to_cpu(pfacts->ProtocolFlags); in GetPortFacts()
3295 pfacts->MaxPostedCmdBuffers = le16_to_cpu(pfacts->MaxPostedCmdBuffers); in GetPortFacts()
3296 pfacts->MaxPersistentIDs = le16_to_cpu(pfacts->MaxPersistentIDs); in GetPortFacts()
3297 pfacts->MaxLanBuckets = le16_to_cpu(pfacts->MaxLanBuckets); in GetPortFacts()
3299 max_id = (ioc->bus_type == SAS) ? pfacts->PortSCSIID : in GetPortFacts()
3300 pfacts->MaxDevices; in GetPortFacts()
3301 ioc->devices_per_bus = (max_id > 255) ? 256 : max_id; in GetPortFacts()
3302 ioc->number_of_buses = (ioc->devices_per_bus < 256) ? 1 : max_id/256; in GetPortFacts()
3310 ioc->devices_per_bus = 1; in GetPortFacts()
3311 ioc->number_of_buses = (max_id > 255) ? 255 : max_id; in GetPortFacts()
3317 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
3319 * SendIocInit - Send IOCInit request to MPT adapter.
3325 * Returns 0 for success, non-zero for failure.
3347 if (ioc->facts.Flags & MPI_IOCFACTS_FLAGS_FW_DOWNLOAD_BOOT) in SendIocInit()
3348 ioc->upload_fw = 1; in SendIocInit()
3350 ioc->upload_fw = 0; in SendIocInit()
3352 ioc->name, ioc->upload_fw, ioc->facts.Flags)); in SendIocInit()
3354 ioc_init.MaxDevices = (U8)ioc->devices_per_bus; in SendIocInit()
3355 ioc_init.MaxBuses = (U8)ioc->number_of_buses; in SendIocInit()
3358 ioc->name, ioc->facts.MsgVersion)); in SendIocInit()
3359 if (ioc->facts.MsgVersion >= MPI_VERSION_01_05) { in SendIocInit()
3364 if (ioc->facts.Flags & MPI_IOCFACTS_FLAGS_HOST_PAGE_BUFFER_PERSISTENT) { in SendIocInit()
3365 ioc_init.HostPageBufferSGE = ioc->facts.HostPageBufferSGE; in SendIocInit()
3367 return -99; in SendIocInit()
3369 ioc_init.ReplyFrameSize = cpu_to_le16(ioc->reply_sz); /* in BYTES */ in SendIocInit()
3371 if (ioc->sg_addr_size == sizeof(u64)) { in SendIocInit()
3372 /* Save the upper 32-bits of the request in SendIocInit()
3375 ioc_init.HostMfaHighAddr = cpu_to_le32((u32)((u64)ioc->alloc_dma >> 32)); in SendIocInit()
3376 ioc_init.SenseBufferHighAddr = cpu_to_le32((u32)((u64)ioc->sense_buf_pool_dma >> 32)); in SendIocInit()
3378 /* Force 32-bit addressing */ in SendIocInit()
3383 ioc->facts.CurrentHostMfaHighAddr = ioc_init.HostMfaHighAddr; in SendIocInit()
3384 ioc->facts.CurrentSenseBufferHighAddr = ioc_init.SenseBufferHighAddr; in SendIocInit()
3385 ioc->facts.MaxDevices = ioc_init.MaxDevices; in SendIocInit()
3386 ioc->facts.MaxBuses = ioc_init.MaxBuses; in SendIocInit()
3389 ioc->name, &ioc_init)); in SendIocInit()
3394 printk(MYIOC_s_ERR_FMT "Sending IOCInit failed(%d)!\n",ioc->name, r); in SendIocInit()
3403 ioc->name, &ioc_init)); in SendIocInit()
3406 printk(MYIOC_s_ERR_FMT "Sending PortEnable failed(%d)!\n",ioc->name, r); in SendIocInit()
3417 while (state != MPI_IOC_STATE_OPERATIONAL && --cntdn) { in SendIocInit()
3426 ioc->name, (int)((count+5)/HZ)); in SendIocInit()
3427 return -9; in SendIocInit()
3434 ioc->name, count)); in SendIocInit()
3436 ioc->aen_event_read_flag=0; in SendIocInit()
3440 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
3442 * SendPortEnable - Send PortEnable request to MPT adapter port.
3449 * Returns 0 for success, non-zero for failure.
3474 ioc->name, portnum, &port_enable)); in SendPortEnable()
3478 if (ioc->ir_firmware || ioc->bus_type == SAS) { in SendPortEnable()
3491 * mpt_alloc_fw_memory - allocate firmware memory
3498 * Return 0 if successful, or non-zero for failure
3505 if (ioc->cached_fw) { in mpt_alloc_fw_memory()
3509 else if (ioc->alt_ioc && ioc->alt_ioc->cached_fw) { in mpt_alloc_fw_memory()
3510 ioc->cached_fw = ioc->alt_ioc->cached_fw; /* use alt_ioc's memory */ in mpt_alloc_fw_memory()
3511 ioc->cached_fw_dma = ioc->alt_ioc->cached_fw_dma; in mpt_alloc_fw_memory()
3515 ioc->cached_fw = dma_alloc_coherent(&ioc->pcidev->dev, size, in mpt_alloc_fw_memory()
3516 &ioc->cached_fw_dma, GFP_ATOMIC); in mpt_alloc_fw_memory()
3517 if (!ioc->cached_fw) { in mpt_alloc_fw_memory()
3519 ioc->name); in mpt_alloc_fw_memory()
3520 rc = -1; in mpt_alloc_fw_memory()
3523 ioc->name, ioc->cached_fw, (void *)(ulong)ioc->cached_fw_dma, size, size)); in mpt_alloc_fw_memory()
3524 ioc->alloc_total += size; in mpt_alloc_fw_memory()
3532 * mpt_free_fw_memory - free firmware memory
3543 if (!ioc->cached_fw) in mpt_free_fw_memory()
3546 sz = ioc->facts.FWImageSize; in mpt_free_fw_memory()
3548 ioc->name, ioc->cached_fw, (void *)(ulong)ioc->cached_fw_dma, sz, sz)); in mpt_free_fw_memory()
3549 dma_free_coherent(&ioc->pcidev->dev, sz, ioc->cached_fw, in mpt_free_fw_memory()
3550 ioc->cached_fw_dma); in mpt_free_fw_memory()
3551 ioc->alloc_total -= sz; in mpt_free_fw_memory()
3552 ioc->cached_fw = NULL; in mpt_free_fw_memory()
3555 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
3557 * mpt_do_upload - Construct and Send FWUpload request to MPT adapter port.
3582 if ((sz = ioc->facts.FWImageSize) == 0) in mpt_do_upload()
3585 if (mpt_alloc_fw_memory(ioc, ioc->facts.FWImageSize) != 0) in mpt_do_upload()
3586 return -ENOMEM; in mpt_do_upload()
3589 ioc->name, ioc->cached_fw, (void *)(ulong)ioc->cached_fw_dma, sz, sz)); in mpt_do_upload()
3591 prequest = (sleepFlag == NO_SLEEP) ? kzalloc(ioc->req_sz, GFP_ATOMIC) : in mpt_do_upload()
3592 kzalloc(ioc->req_sz, GFP_KERNEL); in mpt_do_upload()
3595 "while allocating memory \n", ioc->name)); in mpt_do_upload()
3597 return -ENOMEM; in mpt_do_upload()
3605 prequest->ImageType = MPI_FW_UPLOAD_ITYPE_FW_IOC_MEM; in mpt_do_upload()
3606 prequest->Function = MPI_FUNCTION_FW_UPLOAD; in mpt_do_upload()
3608 ptcsge = (FWUploadTCSGE_t *) &prequest->SGL; in mpt_do_upload()
3609 ptcsge->DetailsLength = 12; in mpt_do_upload()
3610 ptcsge->Flags = MPI_SGE_FLAGS_TRANSACTION_ELEMENT; in mpt_do_upload()
3611 ptcsge->ImageSize = cpu_to_le32(sz); in mpt_do_upload()
3615 ioc->add_sge((char *)ptcsge, flagsLength, ioc->cached_fw_dma); in mpt_do_upload()
3617 ioc->SGE_size; in mpt_do_upload()
3619 " (req @ %p) fw_size=%d mf_request_size=%d\n", ioc->name, prequest, in mpt_do_upload()
3620 ioc->facts.FWImageSize, request_size)); in mpt_do_upload()
3627 "rc=%x \n", ioc->name, ii)); in mpt_do_upload()
3629 cmdStatus = -EFAULT; in mpt_do_upload()
3635 status = le16_to_cpu(preply->IOCStatus) & in mpt_do_upload()
3638 ioc->facts.FWImageSize == in mpt_do_upload()
3639 le32_to_cpu(preply->ActualImageSize)) in mpt_do_upload()
3643 ioc->name, cmdStatus)); in mpt_do_upload()
3648 "freeing image \n", ioc->name)); in mpt_do_upload()
3656 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
3658 * mpt_downloadboot - DownloadBoot code
3666 * -1 FW Image size is 0
3667 * -2 No valid cached_fw Pointer
3684 ioc->name, pFwHeader->ImageSize, pFwHeader->ImageSize, pFwHeader)); in mpt_downloadboot()
3686 CHIPREG_WRITE32(&ioc->chip->WriteSequence, 0xFF); in mpt_downloadboot()
3687 CHIPREG_WRITE32(&ioc->chip->WriteSequence, MPI_WRSEQ_1ST_KEY_VALUE); in mpt_downloadboot()
3688 CHIPREG_WRITE32(&ioc->chip->WriteSequence, MPI_WRSEQ_2ND_KEY_VALUE); in mpt_downloadboot()
3689 CHIPREG_WRITE32(&ioc->chip->WriteSequence, MPI_WRSEQ_3RD_KEY_VALUE); in mpt_downloadboot()
3690 CHIPREG_WRITE32(&ioc->chip->WriteSequence, MPI_WRSEQ_4TH_KEY_VALUE); in mpt_downloadboot()
3691 CHIPREG_WRITE32(&ioc->chip->WriteSequence, MPI_WRSEQ_5TH_KEY_VALUE); in mpt_downloadboot()
3693 CHIPREG_WRITE32(&ioc->chip->Diagnostic, (MPI_DIAG_PREVENT_IOC_BOOT | MPI_DIAG_DISABLE_ARM)); in mpt_downloadboot()
3702 diag0val = CHIPREG_READ32(&ioc->chip->Diagnostic); in mpt_downloadboot()
3703 CHIPREG_WRITE32(&ioc->chip->Diagnostic, diag0val | MPI_DIAG_RESET_ADAPTER); in mpt_downloadboot()
3706 diag0val = CHIPREG_READ32(&ioc->chip->Diagnostic); in mpt_downloadboot()
3709 ioc->name, count)); in mpt_downloadboot()
3723 ioc->name, diag0val)); in mpt_downloadboot()
3724 return -3; in mpt_downloadboot()
3727 CHIPREG_WRITE32(&ioc->chip->WriteSequence, 0xFF); in mpt_downloadboot()
3728 CHIPREG_WRITE32(&ioc->chip->WriteSequence, MPI_WRSEQ_1ST_KEY_VALUE); in mpt_downloadboot()
3729 CHIPREG_WRITE32(&ioc->chip->WriteSequence, MPI_WRSEQ_2ND_KEY_VALUE); in mpt_downloadboot()
3730 CHIPREG_WRITE32(&ioc->chip->WriteSequence, MPI_WRSEQ_3RD_KEY_VALUE); in mpt_downloadboot()
3731 CHIPREG_WRITE32(&ioc->chip->WriteSequence, MPI_WRSEQ_4TH_KEY_VALUE); in mpt_downloadboot()
3732 CHIPREG_WRITE32(&ioc->chip->WriteSequence, MPI_WRSEQ_5TH_KEY_VALUE); in mpt_downloadboot()
3735 CHIPREG_WRITE32(&ioc->chip->Diagnostic, (MPI_DIAG_RW_ENABLE | MPI_DIAG_DISABLE_ARM)); in mpt_downloadboot()
3737 fwSize = (pFwHeader->ImageSize + 3)/4; in mpt_downloadboot()
3743 if (ioc->errata_flag_1064) in mpt_downloadboot()
3744 pci_enable_io_access(ioc->pcidev); in mpt_downloadboot()
3746 CHIPREG_PIO_WRITE32(&ioc->pio_chip->DiagRwAddress, pFwHeader->LoadStartAddress); in mpt_downloadboot()
3748 ioc->name, pFwHeader->LoadStartAddress)); in mpt_downloadboot()
3751 ioc->name, fwSize*4, ptrFw)); in mpt_downloadboot()
3752 while (fwSize--) { in mpt_downloadboot()
3753 CHIPREG_PIO_WRITE32(&ioc->pio_chip->DiagRwData, *ptrFw++); in mpt_downloadboot()
3756 nextImage = pFwHeader->NextImageHeaderOffset; in mpt_downloadboot()
3760 load_addr = pExtImage->LoadStartAddress; in mpt_downloadboot()
3762 fwSize = (pExtImage->ImageSize + 3) >> 2; in mpt_downloadboot()
3766 ioc->name, fwSize*4, fwSize*4, ptrFw, load_addr)); in mpt_downloadboot()
3767 CHIPREG_PIO_WRITE32(&ioc->pio_chip->DiagRwAddress, load_addr); in mpt_downloadboot()
3769 while (fwSize--) { in mpt_downloadboot()
3770 CHIPREG_PIO_WRITE32(&ioc->pio_chip->DiagRwData, *ptrFw++); in mpt_downloadboot()
3772 nextImage = pExtImage->NextImageHeaderOffset; in mpt_downloadboot()
3776 …ddlprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Write IopResetVector Addr=%x! \n", ioc->name, pFwHeader-… in mpt_downloadboot()
3777 CHIPREG_PIO_WRITE32(&ioc->pio_chip->DiagRwAddress, pFwHeader->IopResetRegAddr); in mpt_downloadboot()
3780 …ddlprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Write IopResetVector Value=%x! \n", ioc->name, pFwHeader-… in mpt_downloadboot()
3781 CHIPREG_PIO_WRITE32(&ioc->pio_chip->DiagRwData, pFwHeader->IopResetVectorValue); in mpt_downloadboot()
3783 /* Clear the internal flash bad bit - autoincrementing register, in mpt_downloadboot()
3786 if (ioc->bus_type == SPI) { in mpt_downloadboot()
3791 CHIPREG_PIO_WRITE32(&ioc->pio_chip->DiagRwAddress, 0x3F000000); in mpt_downloadboot()
3792 diagRwData = CHIPREG_PIO_READ32(&ioc->pio_chip->DiagRwData); in mpt_downloadboot()
3794 CHIPREG_PIO_WRITE32(&ioc->pio_chip->DiagRwAddress, 0x3F000000); in mpt_downloadboot()
3795 CHIPREG_PIO_WRITE32(&ioc->pio_chip->DiagRwData, diagRwData); in mpt_downloadboot()
3797 } else /* if((ioc->bus_type == SAS) || (ioc->bus_type == FC)) */ { in mpt_downloadboot()
3798 diag0val = CHIPREG_READ32(&ioc->chip->Diagnostic); in mpt_downloadboot()
3799 CHIPREG_WRITE32(&ioc->chip->Diagnostic, diag0val | in mpt_downloadboot()
3810 if (ioc->errata_flag_1064) in mpt_downloadboot()
3811 pci_disable_io_access(ioc->pcidev); in mpt_downloadboot()
3813 diag0val = CHIPREG_READ32(&ioc->chip->Diagnostic); in mpt_downloadboot()
3816 ioc->name, diag0val)); in mpt_downloadboot()
3819 ioc->name, diag0val)); in mpt_downloadboot()
3820 CHIPREG_WRITE32(&ioc->chip->Diagnostic, diag0val); in mpt_downloadboot()
3823 CHIPREG_WRITE32(&ioc->chip->WriteSequence, 0xFF); in mpt_downloadboot()
3825 if (ioc->bus_type == SAS) { in mpt_downloadboot()
3830 ioc->name, ioc_state)); in mpt_downloadboot()
3831 return -EFAULT; in mpt_downloadboot()
3839 ioc->name, count, ioc_state)); in mpt_downloadboot()
3840 if (ioc->bus_type == SAS) { in mpt_downloadboot()
3846 ioc->name)); in mpt_downloadboot()
3847 return -EFAULT; in mpt_downloadboot()
3851 ioc->name)); in mpt_downloadboot()
3861 "downloadboot failed! IocState=%x\n",ioc->name, ioc_state)); in mpt_downloadboot()
3862 return -EFAULT; in mpt_downloadboot()
3865 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
3867 * KickStart - Perform hard reset of MPT adapter.
3876 * Inputs: sleepflag - CAN_SLEEP (non-interrupt thread)
3878 * force - 1 if doorbell active, board fault state
3884 * 1 - hard reset, READY
3885 * 0 - no reset due to History bit, READY
3886 * -1 - no reset due to History bit but not READY
3888 * -2 - no reset, could not enter DIAG mode
3889 * -3 - reset but bad FW bit
3898 dinitprintk(ioc, printk(MYIOC_s_DEBUG_FMT "KickStarting!\n", ioc->name)); in KickStart()
3899 if (ioc->bus_type == SPI) { in KickStart()
3917 ioc->name)); in KickStart()
3924 ioc->name, cnt)); in KickStart()
3935 ioc->name, mpt_GetIocState(ioc, 0))); in KickStart()
3936 return -1; in KickStart()
3939 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
3941 * mpt_diag_reset - Perform hard reset of the adapter.
3945 * @sleepFlag: CAN_SLEEP if called in a non-interrupt thread,
3955 * -2 enabling diagnostic mode failed
3956 * -3 diagnostic reset failed
3970 CHIPREG_WRITE32(&ioc->chip->IntStatus, 0); in mpt_diag_reset()
3972 if (ioc->pcidev->device == MPI_MANUFACTPAGE_DEVID_SAS1078) { in mpt_diag_reset()
3978 "address=%p\n", ioc->name, __func__, in mpt_diag_reset()
3979 &ioc->chip->Doorbell, &ioc->chip->Reset_1078)); in mpt_diag_reset()
3980 CHIPREG_WRITE32(&ioc->chip->Reset_1078, 0x07); in mpt_diag_reset()
3988 * with pre-reset indication. in mpt_diag_reset()
3992 for (cb_idx = MPT_MAX_PROTOCOL_DRIVERS-1; cb_idx; cb_idx--) { in mpt_diag_reset()
3999 doorbell = CHIPREG_READ32(&ioc->chip->Doorbell); in mpt_diag_reset()
4005 ioc->name, doorbell, count)); in mpt_diag_reset()
4017 return -1; in mpt_diag_reset()
4021 diag0val = CHIPREG_READ32(&ioc->chip->Diagnostic); in mpt_diag_reset()
4023 if (ioc->debug_level & MPT_DEBUG) { in mpt_diag_reset()
4024 if (ioc->alt_ioc) in mpt_diag_reset()
4025 diag1val = CHIPREG_READ32(&ioc->alt_ioc->chip->Diagnostic); in mpt_diag_reset()
4027 ioc->name, diag0val, diag1val)); in mpt_diag_reset()
4038 CHIPREG_WRITE32(&ioc->chip->WriteSequence, 0xFF); in mpt_diag_reset()
4039 CHIPREG_WRITE32(&ioc->chip->WriteSequence, MPI_WRSEQ_1ST_KEY_VALUE); in mpt_diag_reset()
4040 CHIPREG_WRITE32(&ioc->chip->WriteSequence, MPI_WRSEQ_2ND_KEY_VALUE); in mpt_diag_reset()
4041 CHIPREG_WRITE32(&ioc->chip->WriteSequence, MPI_WRSEQ_3RD_KEY_VALUE); in mpt_diag_reset()
4042 CHIPREG_WRITE32(&ioc->chip->WriteSequence, MPI_WRSEQ_4TH_KEY_VALUE); in mpt_diag_reset()
4043 CHIPREG_WRITE32(&ioc->chip->WriteSequence, MPI_WRSEQ_5TH_KEY_VALUE); in mpt_diag_reset()
4055 ioc->name, diag0val); in mpt_diag_reset()
4056 return -2; in mpt_diag_reset()
4060 diag0val = CHIPREG_READ32(&ioc->chip->Diagnostic); in mpt_diag_reset()
4063 ioc->name, diag0val)); in mpt_diag_reset()
4066 if (ioc->debug_level & MPT_DEBUG) { in mpt_diag_reset()
4067 if (ioc->alt_ioc) in mpt_diag_reset()
4068 diag1val = CHIPREG_READ32(&ioc->alt_ioc->chip->Diagnostic); in mpt_diag_reset()
4070 ioc->name, diag0val, diag1val)); in mpt_diag_reset()
4076 CHIPREG_WRITE32(&ioc->chip->Diagnostic, diag0val | MPI_DIAG_DISABLE_ARM); in mpt_diag_reset()
4083 CHIPREG_WRITE32(&ioc->chip->Diagnostic, diag0val | MPI_DIAG_RESET_ADAPTER); in mpt_diag_reset()
4086 ioc->name)); in mpt_diag_reset()
4090 * with pre-reset indication. in mpt_diag_reset()
4094 for (cb_idx = MPT_MAX_PROTOCOL_DRIVERS-1; cb_idx; cb_idx--) { in mpt_diag_reset()
4098 if (ioc->alt_ioc) { in mpt_diag_reset()
4100 ioc->alt_ioc, MPT_IOC_PRE_RESET); in mpt_diag_reset()
4105 if (ioc->cached_fw) in mpt_diag_reset()
4106 cached_fw = (MpiFwHeader_t *)ioc->cached_fw; in mpt_diag_reset()
4107 else if (ioc->alt_ioc && ioc->alt_ioc->cached_fw) in mpt_diag_reset()
4108 cached_fw = (MpiFwHeader_t *)ioc->alt_ioc->cached_fw; in mpt_diag_reset()
4117 diag0val = CHIPREG_READ32(&ioc->chip->Diagnostic); in mpt_diag_reset()
4123 ioc->name, diag0val, count)); in mpt_diag_reset()
4133 "firmware downloadboot failure (%d)!\n", ioc->name, count); in mpt_diag_reset()
4144 doorbell = CHIPREG_READ32(&ioc->chip->Doorbell); in mpt_diag_reset()
4149 " count=%d\n", ioc->name, doorbell, count)); in mpt_diag_reset()
4165 "after reset! IocState=%x", ioc->name, in mpt_diag_reset()
4170 diag0val = CHIPREG_READ32(&ioc->chip->Diagnostic); in mpt_diag_reset()
4171 if (ioc->debug_level & MPT_DEBUG) { in mpt_diag_reset()
4172 if (ioc->alt_ioc) in mpt_diag_reset()
4173 diag1val = CHIPREG_READ32(&ioc->alt_ioc->chip->Diagnostic); in mpt_diag_reset()
4175 ioc->name, diag0val, diag1val)); in mpt_diag_reset()
4181 diag0val = CHIPREG_READ32(&ioc->chip->Diagnostic); in mpt_diag_reset()
4187 CHIPREG_WRITE32(&ioc->chip->WriteSequence, 0xFF); in mpt_diag_reset()
4188 CHIPREG_WRITE32(&ioc->chip->WriteSequence, MPI_WRSEQ_1ST_KEY_VALUE); in mpt_diag_reset()
4189 CHIPREG_WRITE32(&ioc->chip->WriteSequence, MPI_WRSEQ_2ND_KEY_VALUE); in mpt_diag_reset()
4190 CHIPREG_WRITE32(&ioc->chip->WriteSequence, MPI_WRSEQ_3RD_KEY_VALUE); in mpt_diag_reset()
4191 CHIPREG_WRITE32(&ioc->chip->WriteSequence, MPI_WRSEQ_4TH_KEY_VALUE); in mpt_diag_reset()
4192 CHIPREG_WRITE32(&ioc->chip->WriteSequence, MPI_WRSEQ_5TH_KEY_VALUE); in mpt_diag_reset()
4204 ioc->name, diag0val); in mpt_diag_reset()
4207 diag0val = CHIPREG_READ32(&ioc->chip->Diagnostic); in mpt_diag_reset()
4210 CHIPREG_WRITE32(&ioc->chip->Diagnostic, diag0val); in mpt_diag_reset()
4211 diag0val = CHIPREG_READ32(&ioc->chip->Diagnostic); in mpt_diag_reset()
4214 ioc->name); in mpt_diag_reset()
4219 CHIPREG_WRITE32(&ioc->chip->WriteSequence, 0xFFFFFFFF); in mpt_diag_reset()
4223 diag0val = CHIPREG_READ32(&ioc->chip->Diagnostic); in mpt_diag_reset()
4226 ioc->name, diag0val); in mpt_diag_reset()
4227 return -3; in mpt_diag_reset()
4230 if (ioc->debug_level & MPT_DEBUG) { in mpt_diag_reset()
4231 if (ioc->alt_ioc) in mpt_diag_reset()
4232 diag1val = CHIPREG_READ32(&ioc->alt_ioc->chip->Diagnostic); in mpt_diag_reset()
4234 ioc->name, diag0val, diag1val)); in mpt_diag_reset()
4240 ioc->facts.EventState = 0; in mpt_diag_reset()
4242 if (ioc->alt_ioc) in mpt_diag_reset()
4243 ioc->alt_ioc->facts.EventState = 0; in mpt_diag_reset()
4248 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
4250 * SendIocReset - Send IOCReset request to MPT adapter.
4258 * Returns 0 for success, non-zero for failure.
4268 ioc->name, reset_type)); in SendIocReset()
4269 CHIPREG_WRITE32(&ioc->chip->Doorbell, reset_type<<MPI_DOORBELL_FUNCTION_SHIFT); in SendIocReset()
4279 cntdn--; in SendIocReset()
4287 ioc->name, state, (int)((count+5)/HZ)); in SendIocReset()
4288 return -ETIME; in SendIocReset()
4299 * Cleanup all event stuff for this IOC; re-issue EventNotification in SendIocReset()
4302 if (ioc->facts.Function) in SendIocReset()
4303 ioc->facts.EventState = 0; in SendIocReset()
4308 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
4310 * initChainBuffers - Allocate memory for and initialize chain buffers
4326 if (ioc->ReqToChain == NULL) { in initChainBuffers()
4327 sz = ioc->req_depth * sizeof(int); in initChainBuffers()
4330 return -1; in initChainBuffers()
4332 ioc->ReqToChain = (int *) mem; in initChainBuffers()
4334 ioc->name, mem, sz)); in initChainBuffers()
4337 return -1; in initChainBuffers()
4339 ioc->RequestNB = (int *) mem; in initChainBuffers()
4341 ioc->name, mem, sz)); in initChainBuffers()
4343 for (ii = 0; ii < ioc->req_depth; ii++) { in initChainBuffers()
4344 ioc->ReqToChain[ii] = MPT_HOST_NO_CHAIN; in initChainBuffers()
4357 scale = ioc->req_sz / ioc->SGE_size; in initChainBuffers()
4358 if (ioc->sg_addr_size == sizeof(u64)) in initChainBuffers()
4359 num_sge = scale + (ioc->req_sz - 60) / ioc->SGE_size; in initChainBuffers()
4361 num_sge = 1 + scale + (ioc->req_sz - 64) / ioc->SGE_size; in initChainBuffers()
4363 if (ioc->sg_addr_size == sizeof(u64)) { in initChainBuffers()
4364 numSGE = (scale - 1) * (ioc->facts.MaxChainDepth-1) + scale + in initChainBuffers()
4365 (ioc->req_sz - 60) / ioc->SGE_size; in initChainBuffers()
4367 numSGE = 1 + (scale - 1) * (ioc->facts.MaxChainDepth-1) + in initChainBuffers()
4368 scale + (ioc->req_sz - 64) / ioc->SGE_size; in initChainBuffers()
4371 ioc->name, num_sge, numSGE)); in initChainBuffers()
4373 if (ioc->bus_type == FC) { in initChainBuffers()
4382 while (numSGE - num_sge > 0) { in initChainBuffers()
4384 num_sge += (scale - 1); in initChainBuffers()
4389 ioc->name, numSGE, num_sge, num_chain)); in initChainBuffers()
4391 if (ioc->bus_type == SPI) in initChainBuffers()
4393 else if (ioc->bus_type == SAS) in initChainBuffers()
4398 ioc->num_chain = num_chain; in initChainBuffers()
4401 if (ioc->ChainToChain == NULL) { in initChainBuffers()
4404 return -1; in initChainBuffers()
4406 ioc->ChainToChain = (int *) mem; in initChainBuffers()
4408 ioc->name, mem, sz)); in initChainBuffers()
4410 mem = (u8 *) ioc->ChainToChain; in initChainBuffers()
4416 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
4418 * PrimeIocFifos - Initialize IOC request and reply FIFOs.
4425 * Returns 0 for success, non-zero for failure.
4441 if (ioc->reply_frames == NULL) { in PrimeIocFifos()
4443 return -1; in PrimeIocFifos()
4447 if (ioc->pcidev->device == MPI_MANUFACTPAGE_DEVID_SAS1078 && in PrimeIocFifos()
4448 ioc->dma_mask > DMA_BIT_MASK(35)) { in PrimeIocFifos()
4449 if (!dma_set_mask(&ioc->pcidev->dev, DMA_BIT_MASK(32)) in PrimeIocFifos()
4450 && !dma_set_coherent_mask(&ioc->pcidev->dev, DMA_BIT_MASK(32))) { in PrimeIocFifos()
4455 ioc->name)); in PrimeIocFifos()
4458 dma_set_mask(&ioc->pcidev->dev, in PrimeIocFifos()
4460 dma_set_coherent_mask(&ioc->pcidev->dev, in PrimeIocFifos()
4466 ioc->name); in PrimeIocFifos()
4467 return -1; in PrimeIocFifos()
4471 total_size = reply_sz = (ioc->reply_sz * ioc->reply_depth); in PrimeIocFifos()
4473 ioc->name, ioc->reply_sz, ioc->reply_depth)); in PrimeIocFifos()
4475 ioc->name, reply_sz, reply_sz)); in PrimeIocFifos()
4477 sz = (ioc->req_sz * ioc->req_depth); in PrimeIocFifos()
4479 ioc->name, ioc->req_sz, ioc->req_depth)); in PrimeIocFifos()
4481 ioc->name, sz, sz)); in PrimeIocFifos()
4484 sz = num_chain * ioc->req_sz; /* chain buffer pool size */ in PrimeIocFifos()
4486 ioc->name, ioc->req_sz, num_chain)); in PrimeIocFifos()
4488 ioc->name, sz, sz, num_chain)); in PrimeIocFifos()
4491 mem = dma_alloc_coherent(&ioc->pcidev->dev, total_size, in PrimeIocFifos()
4495 ioc->name); in PrimeIocFifos()
4500 ioc->name, mem, (void *)(ulong)alloc_dma, total_size, total_size)); in PrimeIocFifos()
4503 ioc->alloc_total += total_size; in PrimeIocFifos()
4504 ioc->alloc = mem; in PrimeIocFifos()
4505 ioc->alloc_dma = alloc_dma; in PrimeIocFifos()
4506 ioc->alloc_sz = total_size; in PrimeIocFifos()
4507 ioc->reply_frames = (MPT_FRAME_HDR *) mem; in PrimeIocFifos()
4508 ioc->reply_frames_low_dma = (u32) (alloc_dma & 0xFFFFFFFF); in PrimeIocFifos()
4511 ioc->name, ioc->reply_frames, (void *)(ulong)alloc_dma)); in PrimeIocFifos()
4516 /* Request FIFO - WE manage this! */ in PrimeIocFifos()
4518 ioc->req_frames = (MPT_FRAME_HDR *) mem; in PrimeIocFifos()
4519 ioc->req_frames_dma = alloc_dma; in PrimeIocFifos()
4522 ioc->name, mem, (void *)(ulong)alloc_dma)); in PrimeIocFifos()
4524 ioc->req_frames_low_dma = (u32) (alloc_dma & 0xFFFFFFFF); in PrimeIocFifos()
4526 for (i = 0; i < ioc->req_depth; i++) { in PrimeIocFifos()
4527 alloc_dma += ioc->req_sz; in PrimeIocFifos()
4528 mem += ioc->req_sz; in PrimeIocFifos()
4531 ioc->ChainBuffer = mem; in PrimeIocFifos()
4532 ioc->ChainBufferDMA = alloc_dma; in PrimeIocFifos()
4535 ioc->name, ioc->ChainBuffer, (void *)(ulong)ioc->ChainBufferDMA)); in PrimeIocFifos()
4540 INIT_LIST_HEAD(&ioc->FreeChainQ); in PrimeIocFifos()
4544 mem = (u8 *)ioc->ChainBuffer; in PrimeIocFifos()
4547 list_add_tail(&mf->u.frame.linkage.list, &ioc->FreeChainQ); in PrimeIocFifos()
4548 mem += ioc->req_sz; in PrimeIocFifos()
4553 alloc_dma = ioc->req_frames_dma; in PrimeIocFifos()
4554 mem = (u8 *) ioc->req_frames; in PrimeIocFifos()
4556 spin_lock_irqsave(&ioc->FreeQlock, flags); in PrimeIocFifos()
4557 INIT_LIST_HEAD(&ioc->FreeQ); in PrimeIocFifos()
4558 for (i = 0; i < ioc->req_depth; i++) { in PrimeIocFifos()
4562 list_add_tail(&mf->u.frame.linkage.list, &ioc->FreeQ); in PrimeIocFifos()
4564 mem += ioc->req_sz; in PrimeIocFifos()
4566 spin_unlock_irqrestore(&ioc->FreeQlock, flags); in PrimeIocFifos()
4568 sz = (ioc->req_depth * MPT_SENSE_BUFFER_ALLOC); in PrimeIocFifos()
4569 ioc->sense_buf_pool = dma_alloc_coherent(&ioc->pcidev->dev, sz, in PrimeIocFifos()
4570 &ioc->sense_buf_pool_dma, GFP_KERNEL); in PrimeIocFifos()
4571 if (ioc->sense_buf_pool == NULL) { in PrimeIocFifos()
4573 ioc->name); in PrimeIocFifos()
4577 ioc->sense_buf_low_dma = (u32) (ioc->sense_buf_pool_dma & 0xFFFFFFFF); in PrimeIocFifos()
4578 ioc->alloc_total += sz; in PrimeIocFifos()
4580 ioc->name, ioc->sense_buf_pool, (void *)(ulong)ioc->sense_buf_pool_dma)); in PrimeIocFifos()
4586 alloc_dma = ioc->alloc_dma; in PrimeIocFifos()
4588 ioc->name, ioc->reply_frames, (void *)(ulong)alloc_dma)); in PrimeIocFifos()
4590 for (i = 0; i < ioc->reply_depth; i++) { in PrimeIocFifos()
4592 CHIPREG_WRITE32(&ioc->chip->ReplyFifo, alloc_dma); in PrimeIocFifos()
4593 alloc_dma += ioc->reply_sz; in PrimeIocFifos()
4596 if (dma_mask == DMA_BIT_MASK(35) && !dma_set_mask(&ioc->pcidev->dev, in PrimeIocFifos()
4597 ioc->dma_mask) && !dma_set_coherent_mask(&ioc->pcidev->dev, in PrimeIocFifos()
4598 ioc->dma_mask)) in PrimeIocFifos()
4600 "restoring 64 bit addressing\n", ioc->name)); in PrimeIocFifos()
4606 if (ioc->alloc != NULL) { in PrimeIocFifos()
4607 sz = ioc->alloc_sz; in PrimeIocFifos()
4608 dma_free_coherent(&ioc->pcidev->dev, sz, ioc->alloc, in PrimeIocFifos()
4609 ioc->alloc_dma); in PrimeIocFifos()
4610 ioc->reply_frames = NULL; in PrimeIocFifos()
4611 ioc->req_frames = NULL; in PrimeIocFifos()
4612 ioc->alloc_total -= sz; in PrimeIocFifos()
4614 if (ioc->sense_buf_pool != NULL) { in PrimeIocFifos()
4615 sz = (ioc->req_depth * MPT_SENSE_BUFFER_ALLOC); in PrimeIocFifos()
4616 dma_free_coherent(&ioc->pcidev->dev, sz, ioc->sense_buf_pool, in PrimeIocFifos()
4617 ioc->sense_buf_pool_dma); in PrimeIocFifos()
4618 ioc->sense_buf_pool = NULL; in PrimeIocFifos()
4621 if (dma_mask == DMA_BIT_MASK(35) && !dma_set_mask(&ioc->pcidev->dev, in PrimeIocFifos()
4622 DMA_BIT_MASK(64)) && !dma_set_coherent_mask(&ioc->pcidev->dev, in PrimeIocFifos()
4625 "restoring 64 bit addressing\n", ioc->name)); in PrimeIocFifos()
4627 return -1; in PrimeIocFifos()
4630 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
4632 * mpt_handshake_req_reply_wait - Send MPT request to and receive reply
4639 * @maxwait: Max wait time for a reply (in seconds)
4642 * NOTES: It is the callers responsibility to byte-swap fields in the
4644 * callers responsibility to byte-swap response fields which are
4647 * Returns 0 for success, non-zero for failure.
4660 ioc->hs_reply_idx = 0; in mpt_handshake_req_reply_wait()
4661 mptReply = (MPIDefaultReply_t *) ioc->hs_reply; in mpt_handshake_req_reply_wait()
4662 mptReply->MsgLength = 0; in mpt_handshake_req_reply_wait()
4669 CHIPREG_WRITE32(&ioc->chip->IntStatus, 0); in mpt_handshake_req_reply_wait()
4670 CHIPREG_WRITE32(&ioc->chip->Doorbell, in mpt_handshake_req_reply_wait()
4681 ioc->name, reqBytes, t, failcnt ? " - MISSING DOORBELL HANDSHAKE!" : "")); in mpt_handshake_req_reply_wait()
4684 if (!(CHIPREG_READ32(&ioc->chip->Doorbell) & MPI_DOORBELL_ACTIVE)) in mpt_handshake_req_reply_wait()
4685 return -1; in mpt_handshake_req_reply_wait()
4692 CHIPREG_WRITE32(&ioc->chip->IntStatus, 0); in mpt_handshake_req_reply_wait()
4710 CHIPREG_WRITE32(&ioc->chip->Doorbell, word); in mpt_handshake_req_reply_wait()
4715 …dhsprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Handshake request frame (@%p) header\n", ioc->name, req)); in mpt_handshake_req_reply_wait()
4719 ioc->name, t, failcnt ? " - MISSING DOORBELL ACK!" : "")); in mpt_handshake_req_reply_wait()
4728 ioc->name, t, failcnt ? " - MISSING DOORBELL REPLY!" : "")); in mpt_handshake_req_reply_wait()
4733 for (ii=0; ii < min(replyBytes/2,mptReply->MsgLength*2); ii++) in mpt_handshake_req_reply_wait()
4734 u16reply[ii] = ioc->hs_reply[ii]; in mpt_handshake_req_reply_wait()
4736 return -99; in mpt_handshake_req_reply_wait()
4739 return -failcnt; in mpt_handshake_req_reply_wait()
4742 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
4744 * WaitForDoorbellAck - Wait for IOC doorbell handshake acknowledge
4749 * This routine waits (up to ~2 seconds max) for IOC doorbell
4765 while (--cntdn) { in WaitForDoorbellAck()
4767 intstat = CHIPREG_READ32(&ioc->chip->IntStatus); in WaitForDoorbellAck()
4773 while (--cntdn) { in WaitForDoorbellAck()
4775 intstat = CHIPREG_READ32(&ioc->chip->IntStatus); in WaitForDoorbellAck()
4784 ioc->name, count)); in WaitForDoorbellAck()
4789 ioc->name, count, intstat); in WaitForDoorbellAck()
4790 return -1; in WaitForDoorbellAck()
4793 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
4795 * WaitForDoorbellInt - Wait for IOC to set its doorbell interrupt bit
4800 * This routine waits (up to ~2 seconds max) for IOC doorbell interrupt
4814 while (--cntdn) { in WaitForDoorbellInt()
4815 intstat = CHIPREG_READ32(&ioc->chip->IntStatus); in WaitForDoorbellInt()
4822 while (--cntdn) { in WaitForDoorbellInt()
4823 intstat = CHIPREG_READ32(&ioc->chip->IntStatus); in WaitForDoorbellInt()
4833 ioc->name, count, howlong)); in WaitForDoorbellInt()
4838 ioc->name, count, intstat); in WaitForDoorbellInt()
4839 return -1; in WaitForDoorbellInt()
4842 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
4844 * WaitForDoorbellReply - Wait for and capture an IOC handshake reply.
4861 u16 *hs_reply = ioc->hs_reply; in WaitForDoorbellReply()
4862 volatile MPIDefaultReply_t *mptReply = (MPIDefaultReply_t *) ioc->hs_reply; in WaitForDoorbellReply()
4874 hs_reply[u16cnt++] = le16_to_cpu(CHIPREG_READ32(&ioc->chip->Doorbell) & 0x0000FFFF); in WaitForDoorbellReply()
4875 CHIPREG_WRITE32(&ioc->chip->IntStatus, 0); in WaitForDoorbellReply()
4879 hs_reply[u16cnt++] = le16_to_cpu(CHIPREG_READ32(&ioc->chip->Doorbell) & 0x0000FFFF); in WaitForDoorbellReply()
4880 CHIPREG_WRITE32(&ioc->chip->IntStatus, 0); in WaitForDoorbellReply()
4885 ioc->name, t, le32_to_cpu(*(u32 *)hs_reply), in WaitForDoorbellReply()
4886 failcnt ? " - MISSING DOORBELL HANDSHAKE!" : "")); in WaitForDoorbellReply()
4892 for (u16cnt=2; !failcnt && u16cnt < (2 * mptReply->MsgLength); u16cnt++) { in WaitForDoorbellReply()
4895 hword = le16_to_cpu(CHIPREG_READ32(&ioc->chip->Doorbell) & 0x0000FFFF); in WaitForDoorbellReply()
4897 if (u16cnt < ARRAY_SIZE(ioc->hs_reply)) in WaitForDoorbellReply()
4899 CHIPREG_WRITE32(&ioc->chip->IntStatus, 0); in WaitForDoorbellReply()
4904 CHIPREG_WRITE32(&ioc->chip->IntStatus, 0); in WaitForDoorbellReply()
4908 ioc->name); in WaitForDoorbellReply()
4909 return -failcnt; in WaitForDoorbellReply()
4912 else if (u16cnt != (2 * mptReply->MsgLength)) { in WaitForDoorbellReply()
4913 return -101; in WaitForDoorbellReply()
4915 else if ((mptReply->IOCStatus & MPI_IOCSTATUS_MASK) != MPI_IOCSTATUS_SUCCESS) { in WaitForDoorbellReply()
4916 return -102; in WaitForDoorbellReply()
4920 dhsprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Got Handshake reply:\n", ioc->name)); in WaitForDoorbellReply()
4924 ioc->name, t, u16cnt/2)); in WaitForDoorbellReply()
4928 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
4930 * GetLanConfigPages - Fetch LANConfig pages.
4934 * -ENOMEM if no memory available
4935 * -EPERM if not allowed due to ISR context
4936 * -EAGAIN if no msg frames currently available
4937 * -EFAULT for non-successful reply or no reply (timeout)
4958 cfg.physAddr = -1; in GetLanConfigPages()
4969 ppage0_alloc = dma_alloc_coherent(&ioc->pcidev->dev, data_sz, in GetLanConfigPages()
4971 rc = -ENOMEM; in GetLanConfigPages()
4980 memcpy(&ioc->lan_cnfg_page0, ppage0_alloc, copy_sz); in GetLanConfigPages()
4984 dma_free_coherent(&ioc->pcidev->dev, data_sz, in GetLanConfigPages()
4989 * by byte-swapping all > 1 byte fields! in GetLanConfigPages()
5004 cfg.physAddr = -1; in GetLanConfigPages()
5016 rc = -ENOMEM; in GetLanConfigPages()
5017 ppage1_alloc = dma_alloc_coherent(&ioc->pcidev->dev, data_sz, in GetLanConfigPages()
5027 memcpy(&ioc->lan_cnfg_page1, ppage1_alloc, copy_sz); in GetLanConfigPages()
5030 dma_free_coherent(&ioc->pcidev->dev, data_sz, in GetLanConfigPages()
5035 * by byte-swapping all > 1 byte fields! in GetLanConfigPages()
5043 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
5045 * mptbase_sas_persist_operation - Perform operation on SAS Persistent Table
5057 * Returns 0 for success, non-zero error
5060 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
5071 mutex_lock(&ioc->mptbase_cmds.mutex); in mptbase_sas_persist_operation()
5074 memset(ioc->mptbase_cmds.reply, 0 , MPT_DEFAULT_FRAME_SIZE); in mptbase_sas_persist_operation()
5075 INITIALIZE_MGMT_STATUS(ioc->mptbase_cmds.status) in mptbase_sas_persist_operation()
5085 ret = -1; in mptbase_sas_persist_operation()
5096 ret = -1; in mptbase_sas_persist_operation()
5103 sasIoUnitCntrReq->Function = MPI_FUNCTION_SAS_IO_UNIT_CONTROL; in mptbase_sas_persist_operation()
5104 sasIoUnitCntrReq->MsgContext = mpi_hdr->MsgContext; in mptbase_sas_persist_operation()
5105 sasIoUnitCntrReq->Operation = persist_opcode; in mptbase_sas_persist_operation()
5108 timeleft = wait_for_completion_timeout(&ioc->mptbase_cmds.done, 10*HZ); in mptbase_sas_persist_operation()
5109 if (!(ioc->mptbase_cmds.status & MPT_MGMT_STATUS_COMMAND_GOOD)) { in mptbase_sas_persist_operation()
5110 ret = -ETIME; in mptbase_sas_persist_operation()
5112 if (ioc->mptbase_cmds.status & MPT_MGMT_STATUS_DID_IOCRESET) in mptbase_sas_persist_operation()
5117 ioc->name, __func__, mpt_GetIocState(ioc, 0)); in mptbase_sas_persist_operation()
5124 if (!(ioc->mptbase_cmds.status & MPT_MGMT_STATUS_RF_VALID)) { in mptbase_sas_persist_operation()
5125 ret = -1; in mptbase_sas_persist_operation()
5130 (SasIoUnitControlReply_t *)ioc->mptbase_cmds.reply; in mptbase_sas_persist_operation()
5131 if (le16_to_cpu(sasIoUnitCntrReply->IOCStatus) != MPI_IOCSTATUS_SUCCESS) { in mptbase_sas_persist_operation()
5133 __func__, sasIoUnitCntrReply->IOCStatus, in mptbase_sas_persist_operation()
5134 sasIoUnitCntrReply->IOCLogInfo); in mptbase_sas_persist_operation()
5136 ret = -1; in mptbase_sas_persist_operation()
5141 CLEAR_MGMT_STATUS(ioc->mptbase_cmds.status) in mptbase_sas_persist_operation()
5142 mutex_unlock(&ioc->mptbase_cmds.mutex); in mptbase_sas_persist_operation()
5146 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
5159 volume = pRaidEventData->VolumeID; in mptbase_raid_process_event_data()
5160 reason = pRaidEventData->ReasonCode; in mptbase_raid_process_event_data()
5161 disk = pRaidEventData->PhysDiskNum; in mptbase_raid_process_event_data()
5162 status = le32_to_cpu(pRaidEventData->SettingsStatus); in mptbase_raid_process_event_data()
5174 ioc->name, disk, volume); in mptbase_raid_process_event_data()
5177 ioc->name, volume); in mptbase_raid_process_event_data()
5183 ioc->name); in mptbase_raid_process_event_data()
5189 ioc->name); in mptbase_raid_process_event_data()
5194 ioc->name); in mptbase_raid_process_event_data()
5199 ioc->name, in mptbase_raid_process_event_data()
5217 ioc->name, disk); in mptbase_raid_process_event_data()
5222 ioc->name); in mptbase_raid_process_event_data()
5227 ioc->name); in mptbase_raid_process_event_data()
5232 ioc->name); in mptbase_raid_process_event_data()
5237 ioc->name, in mptbase_raid_process_event_data()
5263 ioc->name, disk); in mptbase_raid_process_event_data()
5268 ioc->name, pRaidEventData->ASC, pRaidEventData->ASCQ); in mptbase_raid_process_event_data()
5273 ioc->name, disk); in mptbase_raid_process_event_data()
5278 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
5280 * GetIoUnitPage2 - Retrieve BIOS version and boot order information.
5284 * -ENOMEM if no memory available
5285 * -EPERM if not allowed due to ISR context
5286 * -EAGAIN if no msg frames currently available
5287 * -EFAULT for non-successful reply or no reply (timeout)
5305 cfg.physAddr = -1; in GetIoUnitPage2()
5319 rc = -ENOMEM; in GetIoUnitPage2()
5320 ppage_alloc = dma_alloc_coherent(&ioc->pcidev->dev, data_sz, in GetIoUnitPage2()
5329 ioc->biosVersion = le32_to_cpu(ppage_alloc->BiosVersion); in GetIoUnitPage2()
5331 dma_free_coherent(&ioc->pcidev->dev, data_sz, in GetIoUnitPage2()
5338 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
5340 * mpt_GetScsiPortSettings - read SCSI Port Page 0 and 2
5344 * Return: -EFAULT if read of config page header fails
5357 * CHECK - what type of locking mechanisms should be used????
5371 if (!ioc->spi_data.nvram) { in mpt_GetScsiPortSettings()
5377 return -EFAULT; in mpt_GetScsiPortSettings()
5379 ioc->spi_data.nvram = (int *) mem; in mpt_GetScsiPortSettings()
5382 ioc->name, ioc->spi_data.nvram, sz)); in mpt_GetScsiPortSettings()
5388 ioc->spi_data.nvram[ii] = MPT_HOST_NVRAM_INVALID; in mpt_GetScsiPortSettings()
5398 cfg.physAddr = -1; in mpt_GetScsiPortSettings()
5404 return -EFAULT; in mpt_GetScsiPortSettings()
5407 pbuf = dma_alloc_coherent(&ioc->pcidev->dev, in mpt_GetScsiPortSettings()
5414 ioc->spi_data.maxBusWidth = MPT_NARROW; in mpt_GetScsiPortSettings()
5415 ioc->spi_data.maxSyncOffset = 0; in mpt_GetScsiPortSettings()
5416 ioc->spi_data.minSyncFactor = MPT_ASYNC; in mpt_GetScsiPortSettings()
5417 ioc->spi_data.busType = MPT_HOST_BUS_UNKNOWN; in mpt_GetScsiPortSettings()
5421 ioc->name, ioc->spi_data.minSyncFactor)); in mpt_GetScsiPortSettings()
5426 pPP0->Capabilities = le32_to_cpu(pPP0->Capabilities); in mpt_GetScsiPortSettings()
5427 pPP0->PhysicalInterface = le32_to_cpu(pPP0->PhysicalInterface); in mpt_GetScsiPortSettings()
5429 if ( (pPP0->Capabilities & MPI_SCSIPORTPAGE0_CAP_QAS) == 0 ) { in mpt_GetScsiPortSettings()
5430 ioc->spi_data.noQas |= MPT_TARGET_NO_NEGO_QAS; in mpt_GetScsiPortSettings()
5433 ioc->name, pPP0->Capabilities)); in mpt_GetScsiPortSettings()
5435 ioc->spi_data.maxBusWidth = pPP0->Capabilities & MPI_SCSIPORTPAGE0_CAP_WIDE ? 1 : 0; in mpt_GetScsiPortSettings()
5436 data = pPP0->Capabilities & MPI_SCSIPORTPAGE0_CAP_MAX_SYNC_OFFSET_MASK; in mpt_GetScsiPortSettings()
5438 ioc->spi_data.maxSyncOffset = (u8) (data >> 16); in mpt_GetScsiPortSettings()
5439 data = pPP0->Capabilities & MPI_SCSIPORTPAGE0_CAP_MIN_SYNC_PERIOD_MASK; in mpt_GetScsiPortSettings()
5440 ioc->spi_data.minSyncFactor = (u8) (data >> 8); in mpt_GetScsiPortSettings()
5443 ioc->name, ioc->spi_data.minSyncFactor)); in mpt_GetScsiPortSettings()
5445 ioc->spi_data.maxSyncOffset = 0; in mpt_GetScsiPortSettings()
5446 ioc->spi_data.minSyncFactor = MPT_ASYNC; in mpt_GetScsiPortSettings()
5449 ioc->spi_data.busType = pPP0->PhysicalInterface & MPI_SCSIPORTPAGE0_PHY_SIGNAL_TYPE_MASK; in mpt_GetScsiPortSettings()
5453 if ((ioc->spi_data.busType == MPI_SCSIPORTPAGE0_PHY_SIGNAL_HVD) || in mpt_GetScsiPortSettings()
5454 (ioc->spi_data.busType == MPI_SCSIPORTPAGE0_PHY_SIGNAL_SE)) { in mpt_GetScsiPortSettings()
5456 if (ioc->spi_data.minSyncFactor < MPT_ULTRA) { in mpt_GetScsiPortSettings()
5457 ioc->spi_data.minSyncFactor = MPT_ULTRA; in mpt_GetScsiPortSettings()
5460 ioc->name, ioc->spi_data.minSyncFactor)); in mpt_GetScsiPortSettings()
5465 dma_free_coherent(&ioc->pcidev->dev, in mpt_GetScsiPortSettings()
5472 /* SCSI Port Page 2 - Read the header then the page. in mpt_GetScsiPortSettings()
5479 cfg.physAddr = -1; in mpt_GetScsiPortSettings()
5484 return -EFAULT; in mpt_GetScsiPortSettings()
5489 pbuf = dma_alloc_coherent(&ioc->pcidev->dev, in mpt_GetScsiPortSettings()
5499 } else if (ioc->pcidev->vendor == PCI_VENDOR_ID_ATTO) { in mpt_GetScsiPortSettings()
5511 pdevice = &pPP2->DeviceSettings[ii]; in mpt_GetScsiPortSettings()
5512 ATTOFlags = le16_to_cpu(pdevice->ATTOFlags); in mpt_GetScsiPortSettings()
5528 data = (data << 16) | (pdevice->Period << 8) | 10; in mpt_GetScsiPortSettings()
5529 ioc->spi_data.nvram[ii] = data; in mpt_GetScsiPortSettings()
5538 ioc->spi_data.bus_reset = in mpt_GetScsiPortSettings()
5539 (le32_to_cpu(pPP2->PortFlags) & in mpt_GetScsiPortSettings()
5546 data = le32_to_cpu(pPP2->PortFlags) & MPI_SCSIPORTPAGE2_PORT_FLAGS_DV_MASK; in mpt_GetScsiPortSettings()
5547 ioc->spi_data.PortFlags = data; in mpt_GetScsiPortSettings()
5549 pdevice = &pPP2->DeviceSettings[ii]; in mpt_GetScsiPortSettings()
5550 data = (le16_to_cpu(pdevice->DeviceFlags) << 16) | in mpt_GetScsiPortSettings()
5551 (pdevice->SyncFactor << 8) | pdevice->Timeout; in mpt_GetScsiPortSettings()
5552 ioc->spi_data.nvram[ii] = data; in mpt_GetScsiPortSettings()
5556 dma_free_coherent(&ioc->pcidev->dev, in mpt_GetScsiPortSettings()
5570 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
5572 * mpt_readScsiDevicePageHeaders - save version and length of SDP1
5576 * Return: -EFAULT if read of config page header fails
5592 cfg.physAddr = -1; in mpt_readScsiDevicePageHeaders()
5598 return -EFAULT; in mpt_readScsiDevicePageHeaders()
5600 ioc->spi_data.sdp1version = cfg.cfghdr.hdr->PageVersion; in mpt_readScsiDevicePageHeaders()
5601 ioc->spi_data.sdp1length = cfg.cfghdr.hdr->PageLength; in mpt_readScsiDevicePageHeaders()
5608 return -EFAULT; in mpt_readScsiDevicePageHeaders()
5610 ioc->spi_data.sdp0version = cfg.cfghdr.hdr->PageVersion; in mpt_readScsiDevicePageHeaders()
5611 ioc->spi_data.sdp0length = cfg.cfghdr.hdr->PageLength; in mpt_readScsiDevicePageHeaders()
5614 ioc->name, ioc->spi_data.sdp0version, ioc->spi_data.sdp0length)); in mpt_readScsiDevicePageHeaders()
5617 ioc->name, ioc->spi_data.sdp1version, ioc->spi_data.sdp1length)); in mpt_readScsiDevicePageHeaders()
5622 * mpt_inactive_raid_list_free - This clears this link list.
5630 if (list_empty(&ioc->raid_data.inactive_list)) in mpt_inactive_raid_list_free()
5633 mutex_lock(&ioc->raid_data.inactive_list_mutex); in mpt_inactive_raid_list_free()
5635 &ioc->raid_data.inactive_list, list) { in mpt_inactive_raid_list_free()
5636 list_del(&component_info->list); in mpt_inactive_raid_list_free()
5639 mutex_unlock(&ioc->raid_data.inactive_list_mutex); in mpt_inactive_raid_list_free()
5643 …* mpt_inactive_raid_volumes - sets up link list of phy_disk_nums for devices belonging in an inact…
5674 buffer = dma_alloc_coherent(&ioc->pcidev->dev, hdr.PageLength * 4, in mpt_inactive_raid_volumes()
5686 if (!buffer->NumPhysDisks) in mpt_inactive_raid_volumes()
5690 (buffer->VolumeStatus.Flags & MPI_RAIDVOL0_STATUS_FLAG_VOLUME_INACTIVE || in mpt_inactive_raid_volumes()
5691 (buffer->VolumeStatus.Flags & MPI_RAIDVOL0_STATUS_FLAG_ENABLED) == 0 || in mpt_inactive_raid_volumes()
5692 buffer->VolumeStatus.State == MPI_RAIDVOL0_STATUS_STATE_FAILED || in mpt_inactive_raid_volumes()
5693 buffer->VolumeStatus.State == MPI_RAIDVOL0_STATUS_STATE_MISSING) ? 1 : 0; in mpt_inactive_raid_volumes()
5698 mutex_lock(&ioc->raid_data.inactive_list_mutex); in mpt_inactive_raid_volumes()
5699 for (i = 0; i < buffer->NumPhysDisks; i++) { in mpt_inactive_raid_volumes()
5701 buffer->PhysDisk[i].PhysDiskNum, &phys_disk) != 0) in mpt_inactive_raid_volumes()
5708 component_info->volumeID = id; in mpt_inactive_raid_volumes()
5709 component_info->volumeBus = channel; in mpt_inactive_raid_volumes()
5710 component_info->d.PhysDiskNum = phys_disk.PhysDiskNum; in mpt_inactive_raid_volumes()
5711 component_info->d.PhysDiskBus = phys_disk.PhysDiskBus; in mpt_inactive_raid_volumes()
5712 component_info->d.PhysDiskID = phys_disk.PhysDiskID; in mpt_inactive_raid_volumes()
5713 component_info->d.PhysDiskIOC = phys_disk.PhysDiskIOC; in mpt_inactive_raid_volumes()
5715 list_add_tail(&component_info->list, in mpt_inactive_raid_volumes()
5716 &ioc->raid_data.inactive_list); in mpt_inactive_raid_volumes()
5718 mutex_unlock(&ioc->raid_data.inactive_list_mutex); in mpt_inactive_raid_volumes()
5722 dma_free_coherent(&ioc->pcidev->dev, hdr.PageLength * 4, in mpt_inactive_raid_volumes()
5727 * mpt_raid_phys_disk_pg0 - returns phys disk page zero
5734 * -EFAULT if read of config page header fails or data pointer not NULL
5735 * -ENOMEM if pci_alloc failed
5754 cfg.physAddr = -1; in mpt_raid_phys_disk_pg0()
5758 rc = -EFAULT; in mpt_raid_phys_disk_pg0()
5763 rc = -EFAULT; in mpt_raid_phys_disk_pg0()
5767 buffer = dma_alloc_coherent(&ioc->pcidev->dev, hdr.PageLength * 4, in mpt_raid_phys_disk_pg0()
5771 rc = -ENOMEM; in mpt_raid_phys_disk_pg0()
5780 rc = -EFAULT; in mpt_raid_phys_disk_pg0()
5786 phys_disk->MaxLBA = le32_to_cpu(buffer->MaxLBA); in mpt_raid_phys_disk_pg0()
5791 dma_free_coherent(&ioc->pcidev->dev, hdr.PageLength * 4, in mpt_raid_phys_disk_pg0()
5798 * mpt_raid_phys_disk_get_num_paths - returns number paths associated to this phys_num
5821 cfg.physAddr = -1; in mpt_raid_phys_disk_get_num_paths()
5834 buffer = dma_alloc_coherent(&ioc->pcidev->dev, hdr.PageLength * 4, in mpt_raid_phys_disk_get_num_paths()
5851 rc = buffer->NumPhysDiskPaths; in mpt_raid_phys_disk_get_num_paths()
5855 dma_free_coherent(&ioc->pcidev->dev, hdr.PageLength * 4, in mpt_raid_phys_disk_get_num_paths()
5863 * mpt_raid_phys_disk_pg1 - returns phys disk page 1
5870 * -EFAULT if read of config page header fails or data pointer not NULL
5871 * -ENOMEM if pci_alloc failed
5893 cfg.physAddr = -1; in mpt_raid_phys_disk_pg1()
5897 rc = -EFAULT; in mpt_raid_phys_disk_pg1()
5902 rc = -EFAULT; in mpt_raid_phys_disk_pg1()
5906 buffer = dma_alloc_coherent(&ioc->pcidev->dev, hdr.PageLength * 4, in mpt_raid_phys_disk_pg1()
5910 rc = -ENOMEM; in mpt_raid_phys_disk_pg1()
5919 rc = -EFAULT; in mpt_raid_phys_disk_pg1()
5923 phys_disk->NumPhysDiskPaths = buffer->NumPhysDiskPaths; in mpt_raid_phys_disk_pg1()
5924 phys_disk->PhysDiskNum = phys_disk_num; in mpt_raid_phys_disk_pg1()
5925 for (i = 0; i < phys_disk->NumPhysDiskPaths; i++) { in mpt_raid_phys_disk_pg1()
5926 phys_disk->Path[i].PhysDiskID = buffer->Path[i].PhysDiskID; in mpt_raid_phys_disk_pg1()
5927 phys_disk->Path[i].PhysDiskBus = buffer->Path[i].PhysDiskBus; in mpt_raid_phys_disk_pg1()
5928 phys_disk->Path[i].OwnerIdentifier = in mpt_raid_phys_disk_pg1()
5929 buffer->Path[i].OwnerIdentifier; in mpt_raid_phys_disk_pg1()
5930 phys_disk->Path[i].Flags = le16_to_cpu(buffer->Path[i].Flags); in mpt_raid_phys_disk_pg1()
5931 memcpy(&sas_address, &buffer->Path[i].WWID, sizeof(__le64)); in mpt_raid_phys_disk_pg1()
5933 memcpy(&phys_disk->Path[i].WWID, &sas_address, sizeof(__le64)); in mpt_raid_phys_disk_pg1()
5935 &buffer->Path[i].OwnerWWID, sizeof(__le64)); in mpt_raid_phys_disk_pg1()
5937 memcpy(&phys_disk->Path[i].OwnerWWID, in mpt_raid_phys_disk_pg1()
5944 dma_free_coherent(&ioc->pcidev->dev, hdr.PageLength * 4, in mpt_raid_phys_disk_pg1()
5953 * mpt_findImVolumes - Identify IDs of hidden disks and RAID Volumes
5958 * -EFAULT if read of config page header fails or data pointer not NULL
5959 * -ENOMEM if pci_alloc failed
5973 if (!ioc->ir_firmware) in mpt_findImVolumes()
5978 kfree(ioc->raid_data.pIocPg2); in mpt_findImVolumes()
5979 ioc->raid_data.pIocPg2 = NULL; in mpt_findImVolumes()
5989 cfg.physAddr = -1; in mpt_findImVolumes()
5995 return -EFAULT; in mpt_findImVolumes()
5998 return -EFAULT; in mpt_findImVolumes()
6001 pIoc2 = dma_alloc_coherent(&ioc->pcidev->dev, iocpage2sz, &ioc2_dma, in mpt_findImVolumes()
6004 return -ENOMEM; in mpt_findImVolumes()
6013 rc = -ENOMEM; in mpt_findImVolumes()
6017 ioc->raid_data.pIocPg2 = (IOCPage2_t *) mem; in mpt_findImVolumes()
6021 for (i = 0; i < pIoc2->NumActiveVolumes ; i++) in mpt_findImVolumes()
6023 pIoc2->RaidVolume[i].VolumeBus, in mpt_findImVolumes()
6024 pIoc2->RaidVolume[i].VolumeID); in mpt_findImVolumes()
6027 dma_free_coherent(&ioc->pcidev->dev, iocpage2sz, pIoc2, ioc2_dma); in mpt_findImVolumes()
6044 kfree(ioc->raid_data.pIocPg3); in mpt_read_ioc_pg_3()
6045 ioc->raid_data.pIocPg3 = NULL; in mpt_read_ioc_pg_3()
6055 cfg.physAddr = -1; in mpt_read_ioc_pg_3()
6069 pIoc3 = dma_alloc_coherent(&ioc->pcidev->dev, iocpage3sz, &ioc3_dma, in mpt_read_ioc_pg_3()
6083 ioc->raid_data.pIocPg3 = (IOCPage3_t *) mem; in mpt_read_ioc_pg_3()
6087 dma_free_coherent(&ioc->pcidev->dev, iocpage3sz, pIoc3, ioc3_dma); in mpt_read_ioc_pg_3()
6108 cfg.physAddr = -1; in mpt_read_ioc_pg_4()
6119 if ( (pIoc4 = ioc->spi_data.pIocPg4) == NULL ) { in mpt_read_ioc_pg_4()
6121 pIoc4 = dma_alloc_coherent(&ioc->pcidev->dev, iocpage4sz, in mpt_read_ioc_pg_4()
6125 ioc->alloc_total += iocpage4sz; in mpt_read_ioc_pg_4()
6127 ioc4_dma = ioc->spi_data.IocPg4_dma; in mpt_read_ioc_pg_4()
6128 iocpage4sz = ioc->spi_data.IocPg4Sz; in mpt_read_ioc_pg_4()
6136 ioc->spi_data.pIocPg4 = (IOCPage4_t *) pIoc4; in mpt_read_ioc_pg_4()
6137 ioc->spi_data.IocPg4_dma = ioc4_dma; in mpt_read_ioc_pg_4()
6138 ioc->spi_data.IocPg4Sz = iocpage4sz; in mpt_read_ioc_pg_4()
6140 dma_free_coherent(&ioc->pcidev->dev, iocpage4sz, pIoc4, in mpt_read_ioc_pg_4()
6142 ioc->spi_data.pIocPg4 = NULL; in mpt_read_ioc_pg_4()
6143 ioc->alloc_total -= iocpage4sz; in mpt_read_ioc_pg_4()
6164 cfg.physAddr = -1; in mpt_read_ioc_pg_1()
6178 pIoc1 = dma_alloc_coherent(&ioc->pcidev->dev, iocpage1sz, &ioc1_dma, in mpt_read_ioc_pg_1()
6189 tmp = le32_to_cpu(pIoc1->Flags) & MPI_IOCPAGE1_REPLY_COALESCING; in mpt_read_ioc_pg_1()
6191 tmp = le32_to_cpu(pIoc1->CoalescingTimeout); in mpt_read_ioc_pg_1()
6194 ioc->name, tmp)); in mpt_read_ioc_pg_1()
6197 pIoc1->CoalescingTimeout = cpu_to_le32(MPT_COALESCING_TIMEOUT); in mpt_read_ioc_pg_1()
6205 ioc->name, MPT_COALESCING_TIMEOUT)); in mpt_read_ioc_pg_1()
6211 ioc->name, MPT_COALESCING_TIMEOUT)); in mpt_read_ioc_pg_1()
6215 ioc->name)); in mpt_read_ioc_pg_1()
6221 ioc->name)); in mpt_read_ioc_pg_1()
6226 dprintk(ioc, printk(MYIOC_s_WARN_FMT "Coalescing Disabled\n", ioc->name)); in mpt_read_ioc_pg_1()
6230 dma_free_coherent(&ioc->pcidev->dev, iocpage1sz, pIoc1, ioc1_dma); in mpt_read_ioc_pg_1()
6248 cfg.physAddr = -1; in mpt_get_manufacturing_pg_0()
6255 if (!cfg.cfghdr.hdr->PageLength) in mpt_get_manufacturing_pg_0()
6259 pbuf = dma_alloc_coherent(&ioc->pcidev->dev, hdr.PageLength * 4, in mpt_get_manufacturing_pg_0()
6269 memcpy(ioc->board_name, pbuf->BoardName, sizeof(ioc->board_name)); in mpt_get_manufacturing_pg_0()
6270 memcpy(ioc->board_assembly, pbuf->BoardAssembly, sizeof(ioc->board_assembly)); in mpt_get_manufacturing_pg_0()
6271 memcpy(ioc->board_tracer, pbuf->BoardTracerNumber, sizeof(ioc->board_tracer)); in mpt_get_manufacturing_pg_0()
6276 dma_free_coherent(&ioc->pcidev->dev, hdr.PageLength * 4, pbuf, in mpt_get_manufacturing_pg_0()
6280 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
6282 * SendEventNotification - Send EventNotification (on or off) request to adapter
6302 ioc->name, EvSwitch, &evn)); in SendEventNotification()
6309 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
6311 * SendEventAck - Send EventAck request to MPT adapter.
6322 ioc->name, __func__)); in SendEventAck()
6323 return -1; in SendEventAck()
6326 devtverboseprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Sending EventAck\n", ioc->name)); in SendEventAck()
6328 pAck->Function = MPI_FUNCTION_EVENT_ACK; in SendEventAck()
6329 pAck->ChainOffset = 0; in SendEventAck()
6330 pAck->Reserved[0] = pAck->Reserved[1] = 0; in SendEventAck()
6331 pAck->MsgFlags = 0; in SendEventAck()
6332 pAck->Reserved1[0] = pAck->Reserved1[1] = pAck->Reserved1[2] = 0; in SendEventAck()
6333 pAck->Event = evnp->Event; in SendEventAck()
6334 pAck->EventContext = evnp->EventContext; in SendEventAck()
6341 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
6343 * mpt_config - Generic function to issue config message
6351 * -EAGAIN if no msg frames currently available
6352 * -EFAULT for non-successful reply or no reply (timeout)
6374 spin_lock_irqsave(&ioc->taskmgmt_lock, flags); in mpt_config()
6375 if (ioc->ioc_reset_in_progress) { in mpt_config()
6377 "%s: busy with host reset\n", ioc->name, __func__)); in mpt_config()
6378 spin_unlock_irqrestore(&ioc->taskmgmt_lock, flags); in mpt_config()
6379 return -EBUSY; in mpt_config()
6381 spin_unlock_irqrestore(&ioc->taskmgmt_lock, flags); in mpt_config()
6384 if (!ioc->active || in mpt_config()
6388 ioc->name, __func__, ioc->active, in mpt_config()
6390 return -EFAULT; in mpt_config()
6394 mutex_lock(&ioc->mptbase_cmds.mutex); in mpt_config()
6396 memset(ioc->mptbase_cmds.reply, 0 , MPT_DEFAULT_FRAME_SIZE); in mpt_config()
6397 INITIALIZE_MGMT_STATUS(ioc->mptbase_cmds.status) in mpt_config()
6403 "mpt_config: no msg frames!\n", ioc->name)); in mpt_config()
6404 ret = -EAGAIN; in mpt_config()
6409 pReq->Action = pCfg->action; in mpt_config()
6410 pReq->Reserved = 0; in mpt_config()
6411 pReq->ChainOffset = 0; in mpt_config()
6412 pReq->Function = MPI_FUNCTION_CONFIG; in mpt_config()
6415 pReq->ExtPageLength = 0; in mpt_config()
6416 pReq->ExtPageType = 0; in mpt_config()
6417 pReq->MsgFlags = 0; in mpt_config()
6420 pReq->Reserved2[ii] = 0; in mpt_config()
6422 pReq->Header.PageVersion = pCfg->cfghdr.hdr->PageVersion; in mpt_config()
6423 pReq->Header.PageLength = pCfg->cfghdr.hdr->PageLength; in mpt_config()
6424 pReq->Header.PageNumber = pCfg->cfghdr.hdr->PageNumber; in mpt_config()
6425 pReq->Header.PageType = (pCfg->cfghdr.hdr->PageType & MPI_CONFIG_PAGETYPE_MASK); in mpt_config()
6427 if ((pCfg->cfghdr.hdr->PageType & MPI_CONFIG_PAGETYPE_MASK) == MPI_CONFIG_PAGETYPE_EXTENDED) { in mpt_config()
6428 pExtHdr = (ConfigExtendedPageHeader_t *)pCfg->cfghdr.ehdr; in mpt_config()
6429 pReq->ExtPageLength = cpu_to_le16(pExtHdr->ExtPageLength); in mpt_config()
6430 pReq->ExtPageType = pExtHdr->ExtPageType; in mpt_config()
6431 pReq->Header.PageType = MPI_CONFIG_PAGETYPE_EXTENDED; in mpt_config()
6436 pReq->Header.PageLength = 0; in mpt_config()
6439 pReq->PageAddress = cpu_to_le32(pCfg->pageAddr); in mpt_config()
6443 if (pCfg->dir) in mpt_config()
6448 if ((pCfg->cfghdr.hdr->PageType & MPI_CONFIG_PAGETYPE_MASK) == in mpt_config()
6450 flagsLength |= pExtHdr->ExtPageLength * 4; in mpt_config()
6451 page_type = pReq->ExtPageType; in mpt_config()
6454 flagsLength |= pCfg->cfghdr.hdr->PageLength * 4; in mpt_config()
6455 page_type = pReq->Header.PageType; in mpt_config()
6461 ioc->name, page_type, pReq->Header.PageNumber, pReq->Action)); in mpt_config()
6463 ioc->add_sge((char *)&pReq->PageBufferSGE, flagsLength, pCfg->physAddr); in mpt_config()
6464 timeout = (pCfg->timeout < 15) ? HZ*15 : HZ*pCfg->timeout; in mpt_config()
6466 timeleft = wait_for_completion_timeout(&ioc->mptbase_cmds.done, in mpt_config()
6468 if (!(ioc->mptbase_cmds.status & MPT_MGMT_STATUS_COMMAND_GOOD)) { in mpt_config()
6469 ret = -ETIME; in mpt_config()
6473 ioc->name, page_type, pReq->Header.PageNumber, in mpt_config()
6474 pReq->Action, ioc->mptbase_cmds.status, timeleft)); in mpt_config()
6475 if (ioc->mptbase_cmds.status & MPT_MGMT_STATUS_DID_IOCRESET) in mpt_config()
6478 spin_lock_irqsave(&ioc->taskmgmt_lock, flags); in mpt_config()
6479 if (ioc->ioc_reset_in_progress) { in mpt_config()
6480 spin_unlock_irqrestore(&ioc->taskmgmt_lock, in mpt_config()
6484 __func__, ioc->name); in mpt_config()
6485 mutex_unlock(&ioc->mptbase_cmds.mutex); in mpt_config()
6486 return -EFAULT; in mpt_config()
6488 spin_unlock_irqrestore(&ioc->taskmgmt_lock, flags); in mpt_config()
6494 if (!(ioc->mptbase_cmds.status & MPT_MGMT_STATUS_RF_VALID)) { in mpt_config()
6495 ret = -1; in mpt_config()
6498 pReply = (ConfigReply_t *)ioc->mptbase_cmds.reply; in mpt_config()
6499 ret = le16_to_cpu(pReply->IOCStatus) & MPI_IOCSTATUS_MASK; in mpt_config()
6502 pCfg->cfghdr.ehdr->ExtPageLength = in mpt_config()
6503 le16_to_cpu(pReply->ExtPageLength); in mpt_config()
6504 pCfg->cfghdr.ehdr->ExtPageType = in mpt_config()
6505 pReply->ExtPageType; in mpt_config()
6507 pCfg->cfghdr.hdr->PageVersion = pReply->Header.PageVersion; in mpt_config()
6508 pCfg->cfghdr.hdr->PageLength = pReply->Header.PageLength; in mpt_config()
6509 pCfg->cfghdr.hdr->PageNumber = pReply->Header.PageNumber; in mpt_config()
6510 pCfg->cfghdr.hdr->PageType = pReply->Header.PageType; in mpt_config()
6517 ioc->name, ret, timeleft); in mpt_config()
6520 ret, le32_to_cpu(pReply->IOCLogInfo))); in mpt_config()
6524 CLEAR_MGMT_STATUS(ioc->mptbase_cmds.status) in mpt_config()
6525 mutex_unlock(&ioc->mptbase_cmds.mutex); in mpt_config()
6530 ioc->name, __func__, mpt_GetIocState(ioc, 0)); in mpt_config()
6543 " action %d\n", ioc->name, page_type, in mpt_config()
6544 pCfg->cfghdr.hdr->PageNumber, pCfg->action); in mpt_config()
6553 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
6555 * mpt_ioc_reset - Base cleanup for hard reset
6557 * @reset_phase: Indicates pre- or post-reset functionality
6566 ioc->taskmgmt_quiesce_io = 1; in mpt_ioc_reset()
6568 "%s: MPT_IOC_SETUP_RESET\n", ioc->name, __func__)); in mpt_ioc_reset()
6572 "%s: MPT_IOC_PRE_RESET\n", ioc->name, __func__)); in mpt_ioc_reset()
6576 "%s: MPT_IOC_POST_RESET\n", ioc->name, __func__)); in mpt_ioc_reset()
6578 if (ioc->mptbase_cmds.status & MPT_MGMT_STATUS_PENDING) { in mpt_ioc_reset()
6579 ioc->mptbase_cmds.status |= in mpt_ioc_reset()
6581 complete(&ioc->mptbase_cmds.done); in mpt_ioc_reset()
6584 if (ioc->taskmgmt_cmds.status & MPT_MGMT_STATUS_PENDING) { in mpt_ioc_reset()
6585 ioc->taskmgmt_cmds.status |= in mpt_ioc_reset()
6587 complete(&ioc->taskmgmt_cmds.done); in mpt_ioc_reset()
6599 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
6603 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
6605 * procmpt_create - Create %MPT_PROCFS_MPTBASEDIR entries.
6607 * Returns 0 for success, non-zero for failure.
6614 return -ENOTDIR; in procmpt_create()
6623 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
6625 * procmpt_destroy - Tear down %MPT_PROCFS_MPTBASEDIR entries.
6627 * Returns 0 for success, non-zero for failure.
6637 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
6645 MPT_ADAPTER *ioc = m->private; in mpt_summary_proc_show()
6664 seq_printf(m, "%s-%s\n", "mptlinux", MPT_LINUX_VERSION_COMMON); in mpt_version_proc_show()
6668 for (cb_idx = MPT_MAX_PROTOCOL_DRIVERS-1; cb_idx; cb_idx--) { in mpt_version_proc_show()
6702 MPT_ADAPTER *ioc = m->private; in mpt_iocinfo_proc_show()
6709 seq_printf(m, "%s:", ioc->name); in mpt_iocinfo_proc_show()
6710 if (ioc->facts.Flags & MPI_IOCFACTS_FLAGS_FW_DOWNLOAD_BOOT) in mpt_iocinfo_proc_show()
6712 // if (ioc->facts.IOCExceptions & MPI_IOCFACTS_EXCEPT_CONFIG_CHECKSUM_FAIL) in mpt_iocinfo_proc_show()
6716 ioc->facts.ProductID, in mpt_iocinfo_proc_show()
6717 ioc->prod_name); in mpt_iocinfo_proc_show()
6718 seq_printf(m, " FWVersion = 0x%08x%s", ioc->facts.FWVersion.Word, expVer); in mpt_iocinfo_proc_show()
6719 if (ioc->facts.FWImageSize) in mpt_iocinfo_proc_show()
6720 seq_printf(m, " (fw_size=%d)", ioc->facts.FWImageSize); in mpt_iocinfo_proc_show()
6721 seq_printf(m, "\n MsgVersion = 0x%04x\n", ioc->facts.MsgVersion); in mpt_iocinfo_proc_show()
6722 seq_printf(m, " FirstWhoInit = 0x%02x\n", ioc->FirstWhoInit); in mpt_iocinfo_proc_show()
6723 seq_printf(m, " EventState = 0x%02x\n", ioc->facts.EventState); in mpt_iocinfo_proc_show()
6726 ioc->facts.CurrentHostMfaHighAddr); in mpt_iocinfo_proc_show()
6728 ioc->facts.CurrentSenseBufferHighAddr); in mpt_iocinfo_proc_show()
6730 seq_printf(m, " MaxChainDepth = 0x%02x frames\n", ioc->facts.MaxChainDepth); in mpt_iocinfo_proc_show()
6731 seq_printf(m, " MinBlockSize = 0x%02x bytes\n", 4*ioc->facts.BlockSize); in mpt_iocinfo_proc_show()
6734 (void *)ioc->req_frames, (void *)(ulong)ioc->req_frames_dma); in mpt_iocinfo_proc_show()
6736 * Rounding UP to nearest 4-kB boundary here... in mpt_iocinfo_proc_show()
6738 sz = (ioc->req_sz * ioc->req_depth) + 128; in mpt_iocinfo_proc_show()
6739 sz = ((sz + 0x1000UL - 1UL) / 0x1000) * 0x1000; in mpt_iocinfo_proc_show()
6741 ioc->req_sz, ioc->req_depth, ioc->req_sz*ioc->req_depth, sz); in mpt_iocinfo_proc_show()
6743 4*ioc->facts.RequestFrameSize, in mpt_iocinfo_proc_show()
6744 ioc->facts.GlobalCredits); in mpt_iocinfo_proc_show()
6747 (void *)ioc->alloc, (void *)(ulong)ioc->alloc_dma); in mpt_iocinfo_proc_show()
6748 sz = (ioc->reply_sz * ioc->reply_depth) + 128; in mpt_iocinfo_proc_show()
6750 ioc->reply_sz, ioc->reply_depth, ioc->reply_sz*ioc->reply_depth, sz); in mpt_iocinfo_proc_show()
6752 ioc->facts.CurReplyFrameSize, in mpt_iocinfo_proc_show()
6753 ioc->facts.ReplyQueueDepth); in mpt_iocinfo_proc_show()
6756 (ioc->facts.MaxDevices==0) ? 255 : ioc->facts.MaxDevices); in mpt_iocinfo_proc_show()
6757 seq_printf(m, " MaxBuses = %d\n", ioc->facts.MaxBuses); in mpt_iocinfo_proc_show()
6759 /* per-port info */ in mpt_iocinfo_proc_show()
6760 for (p=0; p < ioc->facts.NumberOfPorts; p++) { in mpt_iocinfo_proc_show()
6763 ioc->facts.NumberOfPorts); in mpt_iocinfo_proc_show()
6764 if (ioc->bus_type == FC) { in mpt_iocinfo_proc_show()
6765 if (ioc->pfacts[p].ProtocolFlags & MPI_PORTFACTS_PROTOCOL_LAN) { in mpt_iocinfo_proc_show()
6766 u8 *a = (u8*)&ioc->lan_cnfg_page1.HardwareAddressLow; in mpt_iocinfo_proc_show()
6770 ioc->fc_port_page0[p].WWNN.High, in mpt_iocinfo_proc_show()
6771 ioc->fc_port_page0[p].WWNN.Low, in mpt_iocinfo_proc_show()
6772 ioc->fc_port_page0[p].WWPN.High, in mpt_iocinfo_proc_show()
6773 ioc->fc_port_page0[p].WWPN.Low); in mpt_iocinfo_proc_show()
6781 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
6786 if ((ioc->facts.FWVersion.Word >> 24) == 0x0E) { in mpt_get_fw_exp_ver()
6788 (ioc->facts.FWVersion.Word >> 16) & 0x00FF, /* Month */ in mpt_get_fw_exp_ver()
6789 (ioc->facts.FWVersion.Word >> 8) & 0x1F); /* Day */ in mpt_get_fw_exp_ver()
6792 if ((ioc->facts.FWVersion.Word >> 8) & 0x80) in mpt_get_fw_exp_ver()
6797 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
6799 * mpt_print_ioc_summary - Write ASCII summary of IOC to a buffer.
6821 ioc->name, in mpt_print_ioc_summary()
6822 ioc->prod_name, in mpt_print_ioc_summary()
6824 ioc->facts.FWVersion.Word, in mpt_print_ioc_summary()
6826 ioc->facts.NumberOfPorts, in mpt_print_ioc_summary()
6827 ioc->req_depth); in mpt_print_ioc_summary()
6829 if (showlan && (ioc->pfacts[0].ProtocolFlags & MPI_PORTFACTS_PROTOCOL_LAN)) { in mpt_print_ioc_summary()
6830 u8 *a = (u8*)&ioc->lan_cnfg_page1.HardwareAddressLow; in mpt_print_ioc_summary()
6834 y += sprintf(buffer+len+y, ", IRQ=%d", ioc->pci_irq); in mpt_print_ioc_summary()
6836 if (!ioc->active) in mpt_print_ioc_summary()
6855 ioc->name, in seq_mpt_print_ioc_summary()
6856 ioc->prod_name, in seq_mpt_print_ioc_summary()
6858 ioc->facts.FWVersion.Word, in seq_mpt_print_ioc_summary()
6860 ioc->facts.NumberOfPorts, in seq_mpt_print_ioc_summary()
6861 ioc->req_depth); in seq_mpt_print_ioc_summary()
6863 if (showlan && (ioc->pfacts[0].ProtocolFlags & MPI_PORTFACTS_PROTOCOL_LAN)) { in seq_mpt_print_ioc_summary()
6864 u8 *a = (u8*)&ioc->lan_cnfg_page1.HardwareAddressLow; in seq_mpt_print_ioc_summary()
6868 seq_printf(m, ", IRQ=%d", ioc->pci_irq); in seq_mpt_print_ioc_summary()
6870 if (!ioc->active) in seq_mpt_print_ioc_summary()
6878 * mpt_set_taskmgmt_in_progress_flag - set flags associated with task management
6881 * Returns 0 for SUCCESS or -1 if FAILED.
6883 * If -1 is return, then it was not possible to set the flags
6891 spin_lock_irqsave(&ioc->taskmgmt_lock, flags); in mpt_set_taskmgmt_in_progress_flag()
6892 if (ioc->ioc_reset_in_progress || ioc->taskmgmt_in_progress || in mpt_set_taskmgmt_in_progress_flag()
6893 (ioc->alt_ioc && ioc->alt_ioc->taskmgmt_in_progress)) { in mpt_set_taskmgmt_in_progress_flag()
6894 retval = -1; in mpt_set_taskmgmt_in_progress_flag()
6898 ioc->taskmgmt_in_progress = 1; in mpt_set_taskmgmt_in_progress_flag()
6899 ioc->taskmgmt_quiesce_io = 1; in mpt_set_taskmgmt_in_progress_flag()
6900 if (ioc->alt_ioc) { in mpt_set_taskmgmt_in_progress_flag()
6901 ioc->alt_ioc->taskmgmt_in_progress = 1; in mpt_set_taskmgmt_in_progress_flag()
6902 ioc->alt_ioc->taskmgmt_quiesce_io = 1; in mpt_set_taskmgmt_in_progress_flag()
6905 spin_unlock_irqrestore(&ioc->taskmgmt_lock, flags); in mpt_set_taskmgmt_in_progress_flag()
6911 * mpt_clear_taskmgmt_in_progress_flag - clear flags associated with task management
6920 spin_lock_irqsave(&ioc->taskmgmt_lock, flags); in mpt_clear_taskmgmt_in_progress_flag()
6921 ioc->taskmgmt_in_progress = 0; in mpt_clear_taskmgmt_in_progress_flag()
6922 ioc->taskmgmt_quiesce_io = 0; in mpt_clear_taskmgmt_in_progress_flag()
6923 if (ioc->alt_ioc) { in mpt_clear_taskmgmt_in_progress_flag()
6924 ioc->alt_ioc->taskmgmt_in_progress = 0; in mpt_clear_taskmgmt_in_progress_flag()
6925 ioc->alt_ioc->taskmgmt_quiesce_io = 0; in mpt_clear_taskmgmt_in_progress_flag()
6927 spin_unlock_irqrestore(&ioc->taskmgmt_lock, flags); in mpt_clear_taskmgmt_in_progress_flag()
6933 * mpt_halt_firmware - Halts the firmware if it is operational and panic
6947 ioc->name, ioc_raw_state & MPI_DOORBELL_DATA_MASK); in mpt_halt_firmware()
6948 panic("%s: IOC Fault (%04xh)!!!\n", ioc->name, in mpt_halt_firmware()
6951 CHIPREG_WRITE32(&ioc->chip->Doorbell, 0xC0FFEE00); in mpt_halt_firmware()
6953 ioc->name); in mpt_halt_firmware()
6959 * mpt_SoftResetHandler - Issues a less expensive reset
6963 * Returns 0 for SUCCESS or -1 if FAILED.
6965 * Message Unit Reset - instructs the IOC to reset the Reply Post and
6982 ioc->name)); in mpt_SoftResetHandler()
6992 "skipping, either in FAULT or RESET state!\n", ioc->name)); in mpt_SoftResetHandler()
6993 return -1; in mpt_SoftResetHandler()
6996 if (ioc->bus_type == FC) { in mpt_SoftResetHandler()
6998 "skipping, because the bus type is FC!\n", ioc->name)); in mpt_SoftResetHandler()
6999 return -1; in mpt_SoftResetHandler()
7002 spin_lock_irqsave(&ioc->taskmgmt_lock, flags); in mpt_SoftResetHandler()
7003 if (ioc->ioc_reset_in_progress) { in mpt_SoftResetHandler()
7004 spin_unlock_irqrestore(&ioc->taskmgmt_lock, flags); in mpt_SoftResetHandler()
7005 return -1; in mpt_SoftResetHandler()
7007 ioc->ioc_reset_in_progress = 1; in mpt_SoftResetHandler()
7008 spin_unlock_irqrestore(&ioc->taskmgmt_lock, flags); in mpt_SoftResetHandler()
7010 for (cb_idx = MPT_MAX_PROTOCOL_DRIVERS-1; cb_idx; cb_idx--) { in mpt_SoftResetHandler()
7015 spin_lock_irqsave(&ioc->taskmgmt_lock, flags); in mpt_SoftResetHandler()
7016 if (ioc->taskmgmt_in_progress) { in mpt_SoftResetHandler()
7017 ioc->ioc_reset_in_progress = 0; in mpt_SoftResetHandler()
7018 spin_unlock_irqrestore(&ioc->taskmgmt_lock, flags); in mpt_SoftResetHandler()
7019 return -1; in mpt_SoftResetHandler()
7021 spin_unlock_irqrestore(&ioc->taskmgmt_lock, flags); in mpt_SoftResetHandler()
7023 CHIPREG_WRITE32(&ioc->chip->IntMask, 0xFFFFFFFF); in mpt_SoftResetHandler()
7024 ioc->active = 0; in mpt_SoftResetHandler()
7029 for (cb_idx = MPT_MAX_PROTOCOL_DRIVERS-1; cb_idx; cb_idx--) { in mpt_SoftResetHandler()
7067 if (ioc->hard_resets < -1) in mpt_SoftResetHandler()
7068 ioc->hard_resets++; in mpt_SoftResetHandler()
7074 ioc->active = 1; in mpt_SoftResetHandler()
7075 CHIPREG_WRITE32(&ioc->chip->IntMask, MPI_HIM_DIM); in mpt_SoftResetHandler()
7078 spin_lock_irqsave(&ioc->taskmgmt_lock, flags); in mpt_SoftResetHandler()
7079 ioc->ioc_reset_in_progress = 0; in mpt_SoftResetHandler()
7080 ioc->taskmgmt_quiesce_io = 0; in mpt_SoftResetHandler()
7081 ioc->taskmgmt_in_progress = 0; in mpt_SoftResetHandler()
7082 spin_unlock_irqrestore(&ioc->taskmgmt_lock, flags); in mpt_SoftResetHandler()
7084 if (ioc->active) { /* otherwise, hard reset coming */ in mpt_SoftResetHandler()
7085 for (cb_idx = MPT_MAX_PROTOCOL_DRIVERS-1; cb_idx; cb_idx--) { in mpt_SoftResetHandler()
7094 ioc->name, jiffies_to_msecs(jiffies - time_count)/1000, in mpt_SoftResetHandler()
7101 * mpt_Soft_Hard_ResetHandler - Try less expensive reset
7105 * Returns 0 for SUCCESS or -1 if FAILED.
7111 int ret = -1; in mpt_Soft_Hard_ResetHandler()
7121 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
7125 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
7127 * mpt_HardResetHandler - Generic reset handler
7135 * or a non-interrupt thread. In the former, must not call schedule().
7137 * Note: A return of -1 is a FATAL error case, as it means a
7140 * Returns 0 for SUCCESS or -1 if FAILED.
7150 dtmprintk(ioc, printk(MYIOC_s_DEBUG_FMT "HardResetHandler Entered!\n", ioc->name)); in mpt_HardResetHandler()
7152 printk(MYIOC_s_INFO_FMT "HardResetHandler Entered!\n", ioc->name); in mpt_HardResetHandler()
7153 printk("MF count 0x%x !\n", ioc->mfcnt); in mpt_HardResetHandler()
7161 spin_lock_irqsave(&ioc->taskmgmt_lock, flags); in mpt_HardResetHandler()
7162 if (ioc->ioc_reset_in_progress) { in mpt_HardResetHandler()
7163 spin_unlock_irqrestore(&ioc->taskmgmt_lock, flags); in mpt_HardResetHandler()
7164 ioc->wait_on_reset_completion = 1; in mpt_HardResetHandler()
7167 } while (ioc->ioc_reset_in_progress == 1); in mpt_HardResetHandler()
7168 ioc->wait_on_reset_completion = 0; in mpt_HardResetHandler()
7169 return ioc->reset_status; in mpt_HardResetHandler()
7171 if (ioc->wait_on_reset_completion) { in mpt_HardResetHandler()
7172 spin_unlock_irqrestore(&ioc->taskmgmt_lock, flags); in mpt_HardResetHandler()
7177 ioc->ioc_reset_in_progress = 1; in mpt_HardResetHandler()
7178 if (ioc->alt_ioc) in mpt_HardResetHandler()
7179 ioc->alt_ioc->ioc_reset_in_progress = 1; in mpt_HardResetHandler()
7180 spin_unlock_irqrestore(&ioc->taskmgmt_lock, flags); in mpt_HardResetHandler()
7186 * For all other protocol drivers, this is a no-op. in mpt_HardResetHandler()
7188 for (cb_idx = MPT_MAX_PROTOCOL_DRIVERS-1; cb_idx; cb_idx--) { in mpt_HardResetHandler()
7191 if (ioc->alt_ioc) in mpt_HardResetHandler()
7192 mpt_signal_reset(cb_idx, ioc->alt_ioc, in mpt_HardResetHandler()
7201 ": WARNING - (%d) Cannot recover %s, doorbell=0x%08x\n", in mpt_HardResetHandler()
7202 rc, ioc->name, mpt_GetIocState(ioc, 0)); in mpt_HardResetHandler()
7204 if (ioc->hard_resets < -1) in mpt_HardResetHandler()
7205 ioc->hard_resets++; in mpt_HardResetHandler()
7208 spin_lock_irqsave(&ioc->taskmgmt_lock, flags); in mpt_HardResetHandler()
7209 ioc->ioc_reset_in_progress = 0; in mpt_HardResetHandler()
7210 ioc->taskmgmt_quiesce_io = 0; in mpt_HardResetHandler()
7211 ioc->taskmgmt_in_progress = 0; in mpt_HardResetHandler()
7212 ioc->reset_status = rc; in mpt_HardResetHandler()
7213 if (ioc->alt_ioc) { in mpt_HardResetHandler()
7214 ioc->alt_ioc->ioc_reset_in_progress = 0; in mpt_HardResetHandler()
7215 ioc->alt_ioc->taskmgmt_quiesce_io = 0; in mpt_HardResetHandler()
7216 ioc->alt_ioc->taskmgmt_in_progress = 0; in mpt_HardResetHandler()
7218 spin_unlock_irqrestore(&ioc->taskmgmt_lock, flags); in mpt_HardResetHandler()
7220 for (cb_idx = MPT_MAX_PROTOCOL_DRIVERS-1; cb_idx; cb_idx--) { in mpt_HardResetHandler()
7223 if (ioc->alt_ioc) in mpt_HardResetHandler()
7225 ioc->alt_ioc, MPT_IOC_POST_RESET); in mpt_HardResetHandler()
7231 "HardResetHandler: completed (%d seconds): %s\n", ioc->name, in mpt_HardResetHandler()
7232 jiffies_to_msecs(jiffies - time_count)/1000, ((rc == 0) ? in mpt_HardResetHandler()
7246 char *evStr = ioc->evStr; in mpt_display_event_info()
7248 event = le32_to_cpu(pEventReply->Event) & 0xFF; in mpt_display_event_info()
7249 evData0 = le32_to_cpu(pEventReply->Data[0]); in mpt_display_event_info()
7605 "SAS Initiator Device Table Overflow: max initiators=%02d " in mpt_display_event_info()
7674 ioc->name, event, evStr)); in mpt_display_event_info()
7678 for (ii = 0; ii < le16_to_cpu(pEventReply->EventDataLength); ii++) in mpt_display_event_info()
7680 le32_to_cpu(pEventReply->Data[ii]))); in mpt_display_event_info()
7684 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
7686 * ProcessEventNotification - Route EventNotificationReply to all event handlers
7709 event = le32_to_cpu(pEventReply->Event) & 0xFF; in ProcessEventNotification()
7710 evDataLen = le16_to_cpu(pEventReply->EventDataLength); in ProcessEventNotification()
7712 evData0 = le32_to_cpu(pEventReply->Data[0]); in ProcessEventNotification()
7731 if (ioc->facts.Function) { in ProcessEventNotification()
7732 ioc->facts.EventState = evState; in ProcessEventNotification()
7738 (MpiEventDataRaid_t *)pEventReply->Data); in ProcessEventNotification()
7748 if (ioc->events && (ioc->eventTypes & ( 1 << event))) { in ProcessEventNotification()
7751 idx = ioc->eventContext % MPTCTL_EVENT_LOG_SIZE; in ProcessEventNotification()
7753 ioc->events[idx].event = event; in ProcessEventNotification()
7754 ioc->events[idx].eventContext = ioc->eventContext; in ProcessEventNotification()
7758 ioc->events[idx].data[ii] = le32_to_cpu(pEventReply->Data[ii]); in ProcessEventNotification()
7760 ioc->events[idx].data[ii] = 0; in ProcessEventNotification()
7763 ioc->eventContext++; in ProcessEventNotification()
7770 for (cb_idx = MPT_MAX_PROTOCOL_DRIVERS-1; cb_idx; cb_idx--) { in ProcessEventNotification()
7774 ioc->name, cb_idx)); in ProcessEventNotification()
7784 if (pEventReply->AckRequired == MPI_EVENT_NOTIFICATION_ACK_REQUIRED) { in ProcessEventNotification()
7786 "EventAck required\n",ioc->name)); in ProcessEventNotification()
7789 ioc->name, ii)); in ProcessEventNotification()
7797 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
7799 * mpt_fc_log_info - Log information returned from Fibre Channel IOC.
7838 ioc->name, log_info, desc, (log_info & 0xFFFFFF)); in mpt_fc_log_info()
7841 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
7843 * mpt_spi_log_info - Log information returned from SCSI Parallel IOC.
7865 desc = "ASYNC Outbound Overrun"; in mpt_spi_log_info()
7885 desc = "Outbound DMA Overrun"; in mpt_spi_log_info()
7906 printk(MYIOC_s_INFO_FMT "LogInfo(0x%08x): F/W: %s\n", ioc->name, log_info, desc); in mpt_spi_log_info()
7932 "SATA Non-NCQ RW Error Bit Set", /* 06h */
7978 "Volume Creation Failed: Max Number "
8052 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
8054 * mpt_sas_log_info - Log information returned from SAS IOC.
8117 ioc->name, log_info, originator_desc, code_desc, in mpt_sas_log_info()
8123 ioc->name, log_info, originator_desc, code_desc, in mpt_sas_log_info()
8129 ioc->name, log_info, originator_desc, in mpt_sas_log_info()
8134 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
8136 * mpt_iocstatus_info_config - IOCSTATUS information for config pages
8152 if (pReq->Header.PageType == MPI_CONFIG_PAGETYPE_EXTENDED) in mpt_iocstatus_info_config()
8153 page_type = pReq->ExtPageType; in mpt_iocstatus_info_config()
8155 page_type = pReq->Header.PageType; in mpt_iocstatus_info_config()
8160 form = le32_to_cpu(pReq->PageAddress); in mpt_iocstatus_info_config()
8177 page_type, pReq->Header.PageNumber, pReq->Action, form); in mpt_iocstatus_info_config()
8210 ioc->name, ioc_status, desc, extend_desc)); in mpt_iocstatus_info_config()
8214 * mpt_iocstatus_info - IOCSTATUS information returned from IOC.
8437 ioc->name, status, desc)); in mpt_iocstatus_info()
8440 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
8472 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
8474 * fusion_init - Fusion MPT base driver initialization routine.
8476 * Returns 0 for success, non-zero for failure.
8509 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
8511 * fusion_exit - Perform driver unload cleanup.