Lines Matching +full:combined +full:- +full:power +full:- +full:req

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 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
160 static int mptbase_reply(MPT_ADAPTER *ioc, MPT_FRAME_HDR *req,
163 u32 *req, int replyBytes, u16 *u16reply, int maxwait,
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 = pci_alloc_consistent(ioc->pcidev, hdr.ExtPageLength * 4, in mpt_is_discovery_complete()
314 if (!(buffer->PhyData[0].PortFlags & in mpt_is_discovery_complete()
319 pci_free_consistent(ioc->pcidev, hdr.ExtPageLength * 4, 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()
464 * Fix sort of combined with an optimization here; in mpt_turbo_reply()
468 * proper mf value first here:-) in mpt_turbo_reply()
493 __func__, ioc->name, cb_idx); in mpt_turbo_reply()
515 /* non-TURBO reply! Hmmm, something may be up... in mpt_reply()
521 * pa is 32 bits - but the dma address may be 32 or 64 bits in mpt_reply()
526 mr = (MPT_FRAME_HDR *)((u8 *)ioc->reply_frames + in mpt_reply()
527 (reply_dma_low - ioc->reply_frames_low_dma)); in mpt_reply()
529 req_idx = le16_to_cpu(mr->u.frame.hwhdr.msgctxu.fld.req_idx); in mpt_reply()
530 cb_idx = mr->u.frame.hwhdr.msgctxu.fld.cb_idx; in mpt_reply()
533 …dmfprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Got non-TURBO reply=%p req_idx=%x cb_idx=%x Function=%x\n… in mpt_reply()
534 ioc->name, mr, req_idx, cb_idx, mr->u.hdr.Function)); in mpt_reply()
539 ioc_stat = le16_to_cpu(mr->u.reply.IOCStatus); in mpt_reply()
541 u32 log_info = le32_to_cpu(mr->u.reply.IOCLogInfo); in mpt_reply()
542 if (ioc->bus_type == FC) in mpt_reply()
544 else if (ioc->bus_type == SPI) in mpt_reply()
546 else if (ioc->bus_type == SAS) in mpt_reply()
557 __func__, ioc->name, cb_idx); in mpt_reply()
565 /* Flush (non-TURBO) reply with a WRITE! */ in mpt_reply()
566 CHIPREG_WRITE32(&ioc->chip->ReplyFifo, pa); in mpt_reply()
573 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
575 * mpt_interrupt - MPT adapter (IOC) specific interrupt handler.
586 * This routine handles register-level access of the adapter but
587 * dispatches (calls) a protocol-specific callback routine to handle
588 * the protocol-specific details of the MPT request completion.
594 u32 pa = CHIPREG_READ32_dmasync(&ioc->chip->ReplyFifo); in mpt_interrupt()
607 pa = CHIPREG_READ32_dmasync(&ioc->chip->ReplyFifo); in mpt_interrupt()
613 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
615 * mptbase_reply - MPT base driver's callback routine
617 * @req: Pointer to original MPT request frame
628 mptbase_reply(MPT_ADAPTER *ioc, MPT_FRAME_HDR *req, MPT_FRAME_HDR *reply) in mptbase_reply() argument
635 switch (reply->u.hdr.Function) { in mptbase_reply()
640 event = le32_to_cpu(pEventReply->Event) & 0xFF; in mptbase_reply()
641 if (pEventReply->MsgFlags & MPI_MSGFLAGS_CONTINUATION_REPLY) in mptbase_reply()
648 ioc->mptbase_cmds.status |= MPT_MGMT_STATUS_COMMAND_GOOD; in mptbase_reply()
649 ioc->mptbase_cmds.status |= MPT_MGMT_STATUS_RF_VALID; in mptbase_reply()
650 memcpy(ioc->mptbase_cmds.reply, reply, in mptbase_reply()
652 4 * reply->u.reply.MsgLength)); in mptbase_reply()
653 if (ioc->mptbase_cmds.status & MPT_MGMT_STATUS_PENDING) { in mptbase_reply()
654 ioc->mptbase_cmds.status &= ~MPT_MGMT_STATUS_PENDING; in mptbase_reply()
655 complete(&ioc->mptbase_cmds.done); in mptbase_reply()
658 if (ioc->mptbase_cmds.status & MPT_MGMT_STATUS_FREE_MF) in mptbase_reply()
663 "EventAck reply received\n", ioc->name)); in mptbase_reply()
668 ioc->name, reply->u.hdr.Function); in mptbase_reply()
679 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
681 * mpt_register - Register protocol-specific main callback handler.
686 * This routine is called by a protocol-specific driver (SCSI host,
688 * protocol-specific driver must do this before it will be able to
710 for (cb_idx = MPT_MAX_PROTOCOL_DRIVERS-1; cb_idx; cb_idx--) { in mpt_register()
725 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
727 * mpt_deregister - Deregister a protocol drivers resources.
730 * Each protocol-specific driver should call this routine when its
745 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
747 * mpt_event_register - Register protocol-specific event callback handler.
751 * This routine can be called by one or more protocol-specific drivers
760 return -1; in mpt_event_register()
766 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
768 * mpt_event_deregister - Deregister protocol-specific event callback handler
771 * Each protocol-specific driver should call this routine
784 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
786 * mpt_reset_register - Register protocol-specific IOC reset handler.
790 * This routine can be called by one or more protocol-specific drivers
799 return -1; in mpt_reset_register()
805 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
807 * mpt_reset_deregister - Deregister protocol-specific IOC reset handler.
810 * Each protocol-specific driver should call this routine
823 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
825 * mpt_device_driver_register - Register device driver hooks
836 return -EINVAL; in mpt_device_driver_register()
842 id = ioc->pcidev->driver ? in mpt_device_driver_register()
843 ioc->pcidev->driver->id_table : NULL; in mpt_device_driver_register()
844 if (dd_cbfunc->probe) in mpt_device_driver_register()
845 dd_cbfunc->probe(ioc->pcidev, id); in mpt_device_driver_register()
851 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
853 * mpt_device_driver_deregister - DeRegister device driver hooks
868 if (dd_cbfunc->remove) in mpt_device_driver_deregister()
869 dd_cbfunc->remove(ioc->pcidev); in mpt_device_driver_deregister()
876 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
878 * mpt_get_msg_frame - Obtain an MPT request frame from the pool
898 if (!ioc->active) in mpt_get_msg_frame()
900 "returning NULL!\n", ioc->name); in mpt_get_msg_frame()
904 if (!ioc->active) in mpt_get_msg_frame()
907 spin_lock_irqsave(&ioc->FreeQlock, flags); in mpt_get_msg_frame()
908 if (!list_empty(&ioc->FreeQ)) { in mpt_get_msg_frame()
911 mf = list_entry(ioc->FreeQ.next, MPT_FRAME_HDR, in mpt_get_msg_frame()
913 list_del(&mf->u.frame.linkage.list); in mpt_get_msg_frame()
914 mf->u.frame.linkage.arg1 = 0; in mpt_get_msg_frame()
915 mf->u.frame.hwhdr.msgctxu.fld.cb_idx = cb_idx; /* byte */ in mpt_get_msg_frame()
916 req_offset = (u8 *)mf - (u8 *)ioc->req_frames; in mpt_get_msg_frame()
918 req_idx = req_offset / ioc->req_sz; in mpt_get_msg_frame()
919 mf->u.frame.hwhdr.msgctxu.fld.req_idx = cpu_to_le16(req_idx); in mpt_get_msg_frame()
920 mf->u.frame.hwhdr.msgctxu.fld.rsvd = 0; in mpt_get_msg_frame()
922 ioc->RequestNB[req_idx] = ioc->NB_for_64_byte_frame; in mpt_get_msg_frame()
924 ioc->mfcnt++; in mpt_get_msg_frame()
929 spin_unlock_irqrestore(&ioc->FreeQlock, flags); in mpt_get_msg_frame()
934 "Count 0x%x Max 0x%x\n", ioc->name, ioc->mfcnt, in mpt_get_msg_frame()
935 ioc->req_depth); in mpt_get_msg_frame()
938 printk(MYIOC_s_INFO_FMT "MF Count 0x%x Max 0x%x \n", ioc->name, in mpt_get_msg_frame()
939 ioc->mfcnt, ioc->req_depth); in mpt_get_msg_frame()
943 ioc->name, cb_idx, ioc->id, mf)); in mpt_get_msg_frame()
947 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
949 * mpt_put_msg_frame - Send a protocol-specific MPT request frame to an IOC
965 mf->u.frame.hwhdr.msgctxu.fld.cb_idx = cb_idx; /* byte */ in mpt_put_msg_frame()
966 req_offset = (u8 *)mf - (u8 *)ioc->req_frames; in mpt_put_msg_frame()
968 req_idx = req_offset / ioc->req_sz; in mpt_put_msg_frame()
969 mf->u.frame.hwhdr.msgctxu.fld.req_idx = cpu_to_le16(req_idx); in mpt_put_msg_frame()
970 mf->u.frame.hwhdr.msgctxu.fld.rsvd = 0; in mpt_put_msg_frame()
974 mf_dma_addr = (ioc->req_frames_low_dma + req_offset) | ioc->RequestNB[req_idx]; in mpt_put_msg_frame()
976 "RequestNB=%x\n", ioc->name, mf_dma_addr, req_idx, in mpt_put_msg_frame()
977 ioc->RequestNB[req_idx])); in mpt_put_msg_frame()
978 CHIPREG_WRITE32(&ioc->chip->RequestFifo, mf_dma_addr); in mpt_put_msg_frame()
982 * mpt_put_msg_frame_hi_pri - Send a hi-pri protocol-specific MPT request frame
987 * Send a protocol-specific MPT request frame to an IOC using
988 * hi-priority request queue.
1001 mf->u.frame.hwhdr.msgctxu.fld.cb_idx = cb_idx; in mpt_put_msg_frame_hi_pri()
1002 req_offset = (u8 *)mf - (u8 *)ioc->req_frames; in mpt_put_msg_frame_hi_pri()
1003 req_idx = req_offset / ioc->req_sz; in mpt_put_msg_frame_hi_pri()
1004 mf->u.frame.hwhdr.msgctxu.fld.req_idx = cpu_to_le16(req_idx); in mpt_put_msg_frame_hi_pri()
1005 mf->u.frame.hwhdr.msgctxu.fld.rsvd = 0; in mpt_put_msg_frame_hi_pri()
1009 mf_dma_addr = (ioc->req_frames_low_dma + req_offset); in mpt_put_msg_frame_hi_pri()
1011 ioc->name, mf_dma_addr, req_idx)); in mpt_put_msg_frame_hi_pri()
1012 CHIPREG_WRITE32(&ioc->chip->RequestHiPriFifo, mf_dma_addr); in mpt_put_msg_frame_hi_pri()
1015 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
1017 * mpt_free_msg_frame - Place MPT request frame back on FreeQ.
1030 spin_lock_irqsave(&ioc->FreeQlock, flags); in mpt_free_msg_frame()
1031 if (cpu_to_le32(mf->u.frame.linkage.arg1) == 0xdeadbeaf) in mpt_free_msg_frame()
1034 mf->u.frame.linkage.arg1 = cpu_to_le32(0xdeadbeaf); in mpt_free_msg_frame()
1035 list_add(&mf->u.frame.linkage.list, &ioc->FreeQ); in mpt_free_msg_frame()
1037 ioc->mfcnt--; in mpt_free_msg_frame()
1040 spin_unlock_irqrestore(&ioc->FreeQlock, flags); in mpt_free_msg_frame()
1043 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
1045 * mpt_add_sge - Place a simple 32 bit SGE at address pAddr.
1057 pSge->FlagsLength = cpu_to_le32(flagslength); in mpt_add_sge()
1058 pSge->Address = cpu_to_le32(dma_addr); in mpt_add_sge()
1062 * mpt_add_sge_64bit - Place a simple 64 bit SGE at address pAddr.
1074 pSge->Address.Low = cpu_to_le32 in mpt_add_sge_64bit()
1076 pSge->Address.High = cpu_to_le32 in mpt_add_sge_64bit()
1078 pSge->FlagsLength = cpu_to_le32 in mpt_add_sge_64bit()
1083 * mpt_add_sge_64bit_1078 - Place a simple 64 bit SGE at address pAddr (1078 workaround).
1097 pSge->Address.Low = cpu_to_le32 in mpt_add_sge_64bit_1078()
1115 pSge->Address.High = cpu_to_le32(tmp); in mpt_add_sge_64bit_1078()
1116 pSge->FlagsLength = cpu_to_le32( in mpt_add_sge_64bit_1078()
1120 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
1122 * mpt_add_chain - Place a 32 bit chain SGE at address pAddr.
1134 pChain->Length = cpu_to_le16(length); in mpt_add_chain()
1135 pChain->Flags = MPI_SGE_FLAGS_CHAIN_ELEMENT; in mpt_add_chain()
1136 pChain->NextChainOffset = next; in mpt_add_chain()
1137 pChain->Address = cpu_to_le32(dma_addr); in mpt_add_chain()
1140 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
1142 * mpt_add_chain_64bit - Place a 64 bit chain SGE at address pAddr.
1155 pChain->Length = cpu_to_le16(length); in mpt_add_chain_64bit()
1156 pChain->Flags = (MPI_SGE_FLAGS_CHAIN_ELEMENT | in mpt_add_chain_64bit()
1159 pChain->NextChainOffset = next; in mpt_add_chain_64bit()
1161 pChain->Address.Low = cpu_to_le32(tmp); in mpt_add_chain_64bit()
1163 pChain->Address.High = cpu_to_le32(tmp); in mpt_add_chain_64bit()
1166 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
1168 * mpt_send_handshake_request - Send MPT request via doorbell handshake method.
1172 * @req: Pointer to MPT request frame
1178 * NOTE: It is the callers responsibility to byte-swap fields in the
1181 * Returns 0 for success, non-zero for failure.
1184 mpt_send_handshake_request(u8 cb_idx, MPT_ADAPTER *ioc, int reqBytes, u32 *req, int sleepFlag) in mpt_send_handshake_request() argument
1198 * is in proper (pre-alloc'd) request buffer range... in mpt_send_handshake_request()
1200 ii = MFPTR_2_MPT_INDEX(ioc,(MPT_FRAME_HDR*)req); in mpt_send_handshake_request()
1201 if (reqBytes >= 12 && ii >= 0 && ii < ioc->req_depth) { in mpt_send_handshake_request()
1202 MPT_FRAME_HDR *mf = (MPT_FRAME_HDR*)req; in mpt_send_handshake_request()
1203 mf->u.frame.hwhdr.msgctxu.fld.req_idx = cpu_to_le16(ii); in mpt_send_handshake_request()
1204 mf->u.frame.hwhdr.msgctxu.fld.cb_idx = cb_idx; in mpt_send_handshake_request()
1208 CHIPREG_WRITE32(&ioc->chip->IntStatus, 0); in mpt_send_handshake_request()
1210 CHIPREG_WRITE32(&ioc->chip->Doorbell, in mpt_send_handshake_request()
1220 if (!(CHIPREG_READ32(&ioc->chip->Doorbell) & MPI_DOORBELL_ACTIVE)) in mpt_send_handshake_request()
1221 return -5; in mpt_send_handshake_request()
1224 ioc->name, ii)); in mpt_send_handshake_request()
1226 CHIPREG_WRITE32(&ioc->chip->IntStatus, 0); in mpt_send_handshake_request()
1229 return -2; in mpt_send_handshake_request()
1233 req_as_bytes = (u8 *) req; in mpt_send_handshake_request()
1241 CHIPREG_WRITE32(&ioc->chip->Doorbell, word); in mpt_send_handshake_request()
1243 r = -3; in mpt_send_handshake_request()
1251 r = -4; in mpt_send_handshake_request()
1254 CHIPREG_WRITE32(&ioc->chip->IntStatus, 0); in mpt_send_handshake_request()
1259 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
1261 * mpt_host_page_access_control - control the IOC's Host Page Buffer access
1269 * Access Control Value - bits[15:12]
1275 * Returns 0 for success, non-zero for failure.
1284 if (CHIPREG_READ32(&ioc->chip->Doorbell) in mpt_host_page_access_control()
1286 return -1; in mpt_host_page_access_control()
1288 CHIPREG_WRITE32(&ioc->chip->IntStatus, 0); in mpt_host_page_access_control()
1290 CHIPREG_WRITE32(&ioc->chip->Doorbell, in mpt_host_page_access_control()
1297 return -2; in mpt_host_page_access_control()
1302 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
1304 * mpt_host_page_alloc - allocate system memory for the fw
1309 * Returns 0 for success, non-zero for failure.
1318 if(!ioc->HostPageBuffer) { in mpt_host_page_alloc()
1321 le32_to_cpu(ioc->facts.HostPageBufferSGE.FlagsLength) & 0xFFFFFF; in mpt_host_page_alloc()
1328 ioc->HostPageBuffer = in mpt_host_page_alloc()
1329 dma_alloc_coherent(&ioc->pcidev->dev, in mpt_host_page_alloc()
1331 &ioc->HostPageBuffer_dma, in mpt_host_page_alloc()
1333 if (ioc->HostPageBuffer) { in mpt_host_page_alloc()
1336 ioc->name, ioc->HostPageBuffer, in mpt_host_page_alloc()
1337 (u32)ioc->HostPageBuffer_dma, in mpt_host_page_alloc()
1339 ioc->alloc_total += host_page_buffer_sz; in mpt_host_page_alloc()
1340 ioc->HostPageBuffer_sz = host_page_buffer_sz; in mpt_host_page_alloc()
1344 host_page_buffer_sz -= (4*1024); in mpt_host_page_alloc()
1348 if(!ioc->HostPageBuffer) { in mpt_host_page_alloc()
1351 ioc->name); in mpt_host_page_alloc()
1352 return -999; in mpt_host_page_alloc()
1355 psge = (char *)&ioc_init->HostPageBufferSGE; in mpt_host_page_alloc()
1361 flags_length |= ioc->HostPageBuffer_sz; in mpt_host_page_alloc()
1362 ioc->add_sge(psge, flags_length, ioc->HostPageBuffer_dma); in mpt_host_page_alloc()
1363 ioc->facts.HostPageBufferSGE = ioc_init->HostPageBufferSGE; in mpt_host_page_alloc()
1368 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
1370 * mpt_verify_adapter - Given IOC identifier, set pointer to its adapter structure.
1378 * Returns -1 if iocid is not found.
1386 if (ioc->id == iocid) { in mpt_verify_adapter()
1393 return -1; in mpt_verify_adapter()
1397 * mpt_get_product_name - returns product string
1637 * mpt_mapresources - map in memory mapped io
1650 int r = -ENODEV; in mpt_mapresources()
1653 pdev = ioc->pcidev; in mpt_mapresources()
1654 ioc->bars = pci_select_bars(pdev, IORESOURCE_MEM); in mpt_mapresources()
1657 "failed\n", ioc->name); in mpt_mapresources()
1660 if (pci_request_selected_regions(pdev, ioc->bars, "mpt")) { in mpt_mapresources()
1662 "MEM failed\n", ioc->name); in mpt_mapresources()
1668 (&pdev->dev); in mpt_mapresources()
1673 ioc->dma_mask = DMA_BIT_MASK(64); in mpt_mapresources()
1676 ioc->name)); in mpt_mapresources()
1680 ioc->dma_mask = DMA_BIT_MASK(32); in mpt_mapresources()
1683 ioc->name)); in mpt_mapresources()
1686 ioc->name, pci_name(pdev)); in mpt_mapresources()
1693 ioc->dma_mask = DMA_BIT_MASK(32); in mpt_mapresources()
1696 ioc->name)); in mpt_mapresources()
1699 ioc->name, pci_name(pdev)); in mpt_mapresources()
1721 ioc->mem_size = msize; in mpt_mapresources()
1728 printk(MYIOC_s_ERR_FMT ": ERROR - Unable to map adapter" in mpt_mapresources()
1729 " memory!\n", ioc->name); in mpt_mapresources()
1730 r = -EINVAL; in mpt_mapresources()
1733 ioc->memmap = mem; in mpt_mapresources()
1735 ioc->name, mem, (unsigned long long)mem_phys)); in mpt_mapresources()
1737 ioc->mem_phys = mem_phys; in mpt_mapresources()
1738 ioc->chip = (SYSIF_REGS __iomem *)mem; in mpt_mapresources()
1741 ioc->pio_mem_phys = port; in mpt_mapresources()
1742 ioc->pio_chip = (SYSIF_REGS __iomem *)port; in mpt_mapresources()
1747 pci_release_selected_regions(pdev, ioc->bars); in mpt_mapresources()
1753 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
1755 * mpt_attach - Install a PCI intelligent MPT adapter.
1764 * This routine also pre-fetches the LAN MAC address of a Fibre Channel
1767 * Returns 0 for success, non-zero for failure.
1776 int r = -ENODEV; in mpt_attach()
1785 printk(KERN_ERR MYNAM ": ERROR - Insufficient memory to add adapter!\n"); in mpt_attach()
1786 return -ENOMEM; in mpt_attach()
1789 ioc->id = mpt_ids++; in mpt_attach()
1790 sprintf(ioc->name, "ioc%d", ioc->id); in mpt_attach()
1798 ioc->debug_level = mpt_debug_level; in mpt_attach()
1802 dinitprintk(ioc, printk(MYIOC_s_INFO_FMT ": mpt_adapter_install\n", ioc->name)); in mpt_attach()
1804 ioc->pcidev = pdev; in mpt_attach()
1812 if (ioc->dma_mask == DMA_BIT_MASK(64)) { in mpt_attach()
1813 if (pdev->device == MPI_MANUFACTPAGE_DEVID_SAS1078) in mpt_attach()
1814 ioc->add_sge = &mpt_add_sge_64bit_1078; in mpt_attach()
1816 ioc->add_sge = &mpt_add_sge_64bit; in mpt_attach()
1817 ioc->add_chain = &mpt_add_chain_64bit; in mpt_attach()
1818 ioc->sg_addr_size = 8; in mpt_attach()
1820 ioc->add_sge = &mpt_add_sge; in mpt_attach()
1821 ioc->add_chain = &mpt_add_chain; in mpt_attach()
1822 ioc->sg_addr_size = 4; in mpt_attach()
1824 ioc->SGE_size = sizeof(u32) + ioc->sg_addr_size; in mpt_attach()
1826 ioc->alloc_total = sizeof(MPT_ADAPTER); in mpt_attach()
1827 ioc->req_sz = MPT_DEFAULT_FRAME_SIZE; /* avoid div by zero! */ in mpt_attach()
1828 ioc->reply_sz = MPT_REPLY_FRAME_SIZE; in mpt_attach()
1831 spin_lock_init(&ioc->taskmgmt_lock); in mpt_attach()
1832 mutex_init(&ioc->internal_cmds.mutex); in mpt_attach()
1833 init_completion(&ioc->internal_cmds.done); in mpt_attach()
1834 mutex_init(&ioc->mptbase_cmds.mutex); in mpt_attach()
1835 init_completion(&ioc->mptbase_cmds.done); in mpt_attach()
1836 mutex_init(&ioc->taskmgmt_cmds.mutex); in mpt_attach()
1837 init_completion(&ioc->taskmgmt_cmds.done); in mpt_attach()
1841 ioc->eventTypes = 0; /* None */ in mpt_attach()
1842 ioc->eventContext = 0; in mpt_attach()
1843 ioc->eventLogSize = 0; in mpt_attach()
1844 ioc->events = NULL; in mpt_attach()
1847 ioc->mfcnt = 0; in mpt_attach()
1850 ioc->sh = NULL; in mpt_attach()
1851 ioc->cached_fw = NULL; in mpt_attach()
1855 memset(&ioc->spi_data, 0, sizeof(SpiCfgData)); in mpt_attach()
1859 INIT_LIST_HEAD(&ioc->fc_rports); in mpt_attach()
1862 INIT_LIST_HEAD(&ioc->list); in mpt_attach()
1866 INIT_DELAYED_WORK(&ioc->fault_reset_work, mpt_fault_reset_work); in mpt_attach()
1868 snprintf(ioc->reset_work_q_name, MPT_KOBJ_NAME_LEN, in mpt_attach()
1869 "mpt_poll_%d", ioc->id); in mpt_attach()
1870 ioc->reset_work_q = alloc_workqueue(ioc->reset_work_q_name, in mpt_attach()
1872 if (!ioc->reset_work_q) { in mpt_attach()
1874 ioc->name); in mpt_attach()
1875 r = -ENOMEM; in mpt_attach()
1880 ioc->name, &ioc->facts, &ioc->pfacts[0])); in mpt_attach()
1882 ioc->prod_name = mpt_get_product_name(pdev->vendor, pdev->device, in mpt_attach()
1883 pdev->revision); in mpt_attach()
1885 switch (pdev->device) in mpt_attach()
1889 ioc->errata_flag_1064 = 1; in mpt_attach()
1895 ioc->bus_type = FC; in mpt_attach()
1899 if (pdev->revision < XL_929) { in mpt_attach()
1913 ioc->bus_type = FC; in mpt_attach()
1923 ioc->bus_type = FC; in mpt_attach()
1930 if (pdev->revision < C0_1030) { in mpt_attach()
1938 ioc->bus_type = SPI; in mpt_attach()
1943 ioc->errata_flag_1064 = 1; in mpt_attach()
1944 ioc->bus_type = SAS; in mpt_attach()
1950 ioc->bus_type = SAS; in mpt_attach()
1955 switch (ioc->bus_type) { in mpt_attach()
1958 ioc->msi_enable = mpt_msi_enable_sas; in mpt_attach()
1962 ioc->msi_enable = mpt_msi_enable_spi; in mpt_attach()
1966 ioc->msi_enable = mpt_msi_enable_fc; in mpt_attach()
1970 ioc->msi_enable = 0; in mpt_attach()
1974 ioc->fw_events_off = 1; in mpt_attach()
1976 if (ioc->errata_flag_1064) in mpt_attach()
1979 spin_lock_init(&ioc->FreeQlock); in mpt_attach()
1982 CHIPREG_WRITE32(&ioc->chip->IntMask, 0xFFFFFFFF); in mpt_attach()
1983 ioc->active = 0; in mpt_attach()
1984 CHIPREG_WRITE32(&ioc->chip->IntStatus, 0); in mpt_attach()
1987 pci_set_drvdata(ioc->pcidev, ioc); in mpt_attach()
1990 list_add_tail(&ioc->list, &ioc_list); in mpt_attach()
1996 INIT_LIST_HEAD(&ioc->fw_event_list); in mpt_attach()
1997 spin_lock_init(&ioc->fw_event_lock); in mpt_attach()
1998 snprintf(ioc->fw_event_q_name, MPT_KOBJ_NAME_LEN, "mpt/%d", ioc->id); in mpt_attach()
1999 ioc->fw_event_q = alloc_workqueue(ioc->fw_event_q_name, in mpt_attach()
2001 if (!ioc->fw_event_q) { in mpt_attach()
2003 ioc->name); in mpt_attach()
2004 r = -ENOMEM; in mpt_attach()
2011 ioc->name, r); in mpt_attach()
2013 destroy_workqueue(ioc->fw_event_q); in mpt_attach()
2014 ioc->fw_event_q = NULL; in mpt_attach()
2016 list_del(&ioc->list); in mpt_attach()
2017 if (ioc->alt_ioc) in mpt_attach()
2018 ioc->alt_ioc->alt_ioc = NULL; in mpt_attach()
2019 iounmap(ioc->memmap); in mpt_attach()
2022 if (r != -5) in mpt_attach()
2023 pci_release_selected_regions(pdev, ioc->bars); in mpt_attach()
2025 destroy_workqueue(ioc->reset_work_q); in mpt_attach()
2026 ioc->reset_work_q = NULL; in mpt_attach()
2035 MptDeviceDriverHandlers[cb_idx]->probe) { in mpt_attach()
2036 MptDeviceDriverHandlers[cb_idx]->probe(pdev,id); in mpt_attach()
2044 dent = proc_mkdir(ioc->name, mpt_proc_root_dir); in mpt_attach()
2053 if (!ioc->alt_ioc) in mpt_attach()
2054 queue_delayed_work(ioc->reset_work_q, &ioc->fault_reset_work, in mpt_attach()
2060 list_del(&ioc->list); in mpt_attach()
2061 if (ioc->alt_ioc) in mpt_attach()
2062 ioc->alt_ioc->alt_ioc = NULL; in mpt_attach()
2064 destroy_workqueue(ioc->reset_work_q); in mpt_attach()
2065 ioc->reset_work_q = NULL; in mpt_attach()
2068 iounmap(ioc->memmap); in mpt_attach()
2070 pci_release_selected_regions(pdev, ioc->bars); in mpt_attach()
2078 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
2080 * mpt_detach - Remove a PCI intelligent MPT adapter.
2096 spin_lock_irqsave(&ioc->taskmgmt_lock, flags); in mpt_detach()
2097 wq = ioc->reset_work_q; in mpt_detach()
2098 ioc->reset_work_q = NULL; in mpt_detach()
2099 spin_unlock_irqrestore(&ioc->taskmgmt_lock, flags); in mpt_detach()
2100 cancel_delayed_work(&ioc->fault_reset_work); in mpt_detach()
2103 spin_lock_irqsave(&ioc->fw_event_lock, flags); in mpt_detach()
2104 wq = ioc->fw_event_q; in mpt_detach()
2105 ioc->fw_event_q = NULL; in mpt_detach()
2106 spin_unlock_irqrestore(&ioc->fw_event_lock, flags); in mpt_detach()
2109 snprintf(pname, sizeof(pname), MPT_PROCFS_MPTBASEDIR "/%s/summary", ioc->name); in mpt_detach()
2111 snprintf(pname, sizeof(pname), MPT_PROCFS_MPTBASEDIR "/%s/info", ioc->name); in mpt_detach()
2113 snprintf(pname, sizeof(pname), MPT_PROCFS_MPTBASEDIR "/%s", ioc->name); in mpt_detach()
2119 MptDeviceDriverHandlers[cb_idx]->remove) { in mpt_detach()
2120 MptDeviceDriverHandlers[cb_idx]->remove(pdev); in mpt_detach()
2125 CHIPREG_WRITE32(&ioc->chip->IntMask, 0xFFFFFFFF); in mpt_detach()
2127 ioc->active = 0; in mpt_detach()
2128 synchronize_irq(pdev->irq); in mpt_detach()
2131 CHIPREG_WRITE32(&ioc->chip->IntStatus, 0); in mpt_detach()
2133 CHIPREG_READ32(&ioc->chip->IntStatus); in mpt_detach()
2140 * Power Management
2143 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
2145 * mpt_suspend - Fusion MPT base driver suspend routine.
2156 printk(MYIOC_s_INFO_FMT "pci-suspend: pdev=0x%p, slot=%s, Entering " in mpt_suspend()
2157 "operating state [D%d]\n", ioc->name, pdev, pci_name(pdev), in mpt_suspend()
2163 "pci-suspend: IOC msg unit reset failed!\n", ioc->name); in mpt_suspend()
2167 CHIPREG_WRITE32(&ioc->chip->IntMask, 0xFFFFFFFF); in mpt_suspend()
2168 ioc->active = 0; in mpt_suspend()
2171 CHIPREG_WRITE32(&ioc->chip->IntStatus, 0); in mpt_suspend()
2173 free_irq(ioc->pci_irq, ioc); in mpt_suspend()
2174 if (ioc->msi_enable) in mpt_suspend()
2175 pci_disable_msi(ioc->pcidev); in mpt_suspend()
2176 ioc->pci_irq = -1; in mpt_suspend()
2179 pci_release_selected_regions(pdev, ioc->bars); in mpt_suspend()
2184 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
2186 * mpt_resume - Fusion MPT base driver resume routine.
2193 u32 device_state = pdev->current_state; in mpt_resume()
2197 printk(MYIOC_s_INFO_FMT "pci-resume: pdev=0x%p, slot=%s, Previous " in mpt_resume()
2198 "operating state [D%d]\n", ioc->name, pdev, pci_name(pdev), in mpt_resume()
2204 ioc->pcidev = pdev; in mpt_resume()
2209 if (ioc->dma_mask == DMA_BIT_MASK(64)) { in mpt_resume()
2210 if (pdev->device == MPI_MANUFACTPAGE_DEVID_SAS1078) in mpt_resume()
2211 ioc->add_sge = &mpt_add_sge_64bit_1078; in mpt_resume()
2213 ioc->add_sge = &mpt_add_sge_64bit; in mpt_resume()
2214 ioc->add_chain = &mpt_add_chain_64bit; in mpt_resume()
2215 ioc->sg_addr_size = 8; in mpt_resume()
2218 ioc->add_sge = &mpt_add_sge; in mpt_resume()
2219 ioc->add_chain = &mpt_add_chain; in mpt_resume()
2220 ioc->sg_addr_size = 4; in mpt_resume()
2222 ioc->SGE_size = sizeof(u32) + ioc->sg_addr_size; in mpt_resume()
2224 printk(MYIOC_s_INFO_FMT "pci-resume: ioc-state=0x%x,doorbell=0x%x\n", in mpt_resume()
2225 ioc->name, (mpt_GetIocState(ioc, 1) >> MPI_IOC_STATE_SHIFT), in mpt_resume()
2226 CHIPREG_READ32(&ioc->chip->Doorbell)); in mpt_resume()
2235 if (ioc->bus_type == SAS && (pdev->device == in mpt_resume()
2236 MPI_MANUFACTPAGE_DEVID_SAS1068E || pdev->device == in mpt_resume()
2239 printk(MYIOC_s_WARN_FMT "pci-resume: Cannot recover\n", in mpt_resume()
2240 ioc->name); in mpt_resume()
2246 printk(MYIOC_s_INFO_FMT "Sending mpt_do_ioc_recovery\n", ioc->name); in mpt_resume()
2250 printk(MYIOC_s_WARN_FMT "pci-resume: Cannot recover, " in mpt_resume()
2251 "error:[%x]\n", ioc->name, recovery_state); in mpt_resume()
2254 "pci-resume: success\n", ioc->name); in mpt_resume()
2265 ioc->bus_type != SPI) || in mpt_signal_reset()
2267 ioc->bus_type != FC) || in mpt_signal_reset()
2269 ioc->bus_type != SAS)) in mpt_signal_reset()
2276 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
2278 * mpt_do_ioc_recovery - Initialize or recover MPT adapter.
2286 * This routine also pre-fetches the LAN MAC address of a Fibre Channel
2291 * -1 if failed to get board READY
2292 * -2 if READY but IOCFacts Failed
2293 * -3 if READY but PrimeIOCFifos Failed
2294 * -4 if READY but IOCInit Failed
2295 * -5 if failed to enable_device and/or request_selected_regions
2296 * -6 if failed to upload firmware
2311 printk(MYIOC_s_INFO_FMT "Initiating %s\n", ioc->name, in mpt_do_ioc_recovery()
2315 CHIPREG_WRITE32(&ioc->chip->IntMask, 0xFFFFFFFF); in mpt_do_ioc_recovery()
2316 ioc->active = 0; in mpt_do_ioc_recovery()
2318 if (ioc->alt_ioc) { in mpt_do_ioc_recovery()
2319 if (ioc->alt_ioc->active || in mpt_do_ioc_recovery()
2322 /* Disable alt-IOC's reply interrupts in mpt_do_ioc_recovery()
2325 CHIPREG_WRITE32(&ioc->alt_ioc->chip->IntMask, in mpt_do_ioc_recovery()
2327 ioc->alt_ioc->active = 0; in mpt_do_ioc_recovery()
2336 if (hard_reset_done == -4) { in mpt_do_ioc_recovery()
2338 ioc->name); in mpt_do_ioc_recovery()
2340 if (reset_alt_ioc_active && ioc->alt_ioc) { in mpt_do_ioc_recovery()
2341 /* (re)Enable alt-IOC! (reply interrupt, FreeQ) */ in mpt_do_ioc_recovery()
2343 "alt_ioc reply irq re-enabled\n", ioc->alt_ioc->name)); in mpt_do_ioc_recovery()
2344 CHIPREG_WRITE32(&ioc->alt_ioc->chip->IntMask, MPI_HIM_DIM); in mpt_do_ioc_recovery()
2345 ioc->alt_ioc->active = 1; in mpt_do_ioc_recovery()
2350 "NOT READY WARNING!\n", ioc->name); in mpt_do_ioc_recovery()
2352 ret = -1; in mpt_do_ioc_recovery()
2359 if (hard_reset_done && reset_alt_ioc_active && ioc->alt_ioc) { in mpt_do_ioc_recovery()
2360 if ((rc = MakeIocReady(ioc->alt_ioc, 0, sleepFlag)) == 0) in mpt_do_ioc_recovery()
2364 ": alt-ioc Not ready WARNING!\n", in mpt_do_ioc_recovery()
2365 ioc->alt_ioc->name); in mpt_do_ioc_recovery()
2377 "Retry IocFacts failed rc=%x\n", ioc->name, rc)); in mpt_do_ioc_recovery()
2378 ret = -2; in mpt_do_ioc_recovery()
2384 if ((rc = GetIocFacts(ioc->alt_ioc, sleepFlag, reason)) != 0) { in mpt_do_ioc_recovery()
2387 ioc->name, rc)); in mpt_do_ioc_recovery()
2388 /* Retry - alt IOC was initialized once in mpt_do_ioc_recovery()
2390 rc = GetIocFacts(ioc->alt_ioc, sleepFlag, reason); in mpt_do_ioc_recovery()
2394 "Retry Alt IocFacts failed rc=%x\n", ioc->name, rc)); in mpt_do_ioc_recovery()
2398 MptDisplayIocCapabilities(ioc->alt_ioc); in mpt_do_ioc_recovery()
2403 (ioc->facts.Flags & MPI_IOCFACTS_FLAGS_FW_DOWNLOAD_BOOT)) { in mpt_do_ioc_recovery()
2404 pci_release_selected_regions(ioc->pcidev, ioc->bars); in mpt_do_ioc_recovery()
2405 ioc->bars = pci_select_bars(ioc->pcidev, IORESOURCE_MEM | in mpt_do_ioc_recovery()
2407 if (pci_enable_device(ioc->pcidev)) in mpt_do_ioc_recovery()
2408 return -5; in mpt_do_ioc_recovery()
2409 if (pci_request_selected_regions(ioc->pcidev, ioc->bars, in mpt_do_ioc_recovery()
2411 return -5; in mpt_do_ioc_recovery()
2415 * Device is reset now. It must have de-asserted the interrupt line in mpt_do_ioc_recovery()
2420 ioc->pci_irq = -1; in mpt_do_ioc_recovery()
2421 if (ioc->pcidev->irq) { in mpt_do_ioc_recovery()
2422 if (ioc->msi_enable && !pci_enable_msi(ioc->pcidev)) in mpt_do_ioc_recovery()
2423 printk(MYIOC_s_INFO_FMT "PCI-MSI enabled\n", in mpt_do_ioc_recovery()
2424 ioc->name); in mpt_do_ioc_recovery()
2426 ioc->msi_enable = 0; in mpt_do_ioc_recovery()
2427 rc = request_irq(ioc->pcidev->irq, mpt_interrupt, in mpt_do_ioc_recovery()
2428 IRQF_SHARED, ioc->name, ioc); in mpt_do_ioc_recovery()
2432 ioc->name, ioc->pcidev->irq); in mpt_do_ioc_recovery()
2433 if (ioc->msi_enable) in mpt_do_ioc_recovery()
2434 pci_disable_msi(ioc->pcidev); in mpt_do_ioc_recovery()
2435 ret = -EBUSY; in mpt_do_ioc_recovery()
2439 ioc->pci_irq = ioc->pcidev->irq; in mpt_do_ioc_recovery()
2440 pci_set_master(ioc->pcidev); /* ?? */ in mpt_do_ioc_recovery()
2441 pci_set_drvdata(ioc->pcidev, ioc); in mpt_do_ioc_recovery()
2443 "installed at interrupt %d\n", ioc->name, in mpt_do_ioc_recovery()
2444 ioc->pcidev->irq)); in mpt_do_ioc_recovery()
2451 * If fails, continue with alt-ioc processing in mpt_do_ioc_recovery()
2454 ioc->name)); in mpt_do_ioc_recovery()
2456 ret = -3; in mpt_do_ioc_recovery()
2459 * If fails, continue with alt-ioc processing in mpt_do_ioc_recovery()
2462 ioc->name)); in mpt_do_ioc_recovery()
2464 ret = -4; in mpt_do_ioc_recovery()
2466 if (alt_ioc_ready && ((rc = PrimeIocFifos(ioc->alt_ioc)) != 0)) { in mpt_do_ioc_recovery()
2468 ": alt-ioc (%d) FIFO mgmt alloc WARNING!\n", in mpt_do_ioc_recovery()
2469 ioc->alt_ioc->name, rc); in mpt_do_ioc_recovery()
2475 if ((rc = SendIocInit(ioc->alt_ioc, sleepFlag)) != 0) { in mpt_do_ioc_recovery()
2479 ": alt-ioc: (%d) init failure WARNING!\n", in mpt_do_ioc_recovery()
2480 ioc->alt_ioc->name, rc); in mpt_do_ioc_recovery()
2485 if (ioc->upload_fw) { in mpt_do_ioc_recovery()
2487 "firmware upload required!\n", ioc->name)); in mpt_do_ioc_recovery()
2494 if (ioc->alt_ioc && ioc->alt_ioc->cached_fw) { in mpt_do_ioc_recovery()
2504 ioc->name, ioc->alt_ioc->name, ioc->alt_ioc->cached_fw)); in mpt_do_ioc_recovery()
2505 ioc->cached_fw = NULL; in mpt_do_ioc_recovery()
2509 "firmware upload failure!\n", ioc->name); in mpt_do_ioc_recovery()
2510 ret = -6; in mpt_do_ioc_recovery()
2519 if ((ret == 0) && (!ioc->facts.EventState)) { in mpt_do_ioc_recovery()
2522 ioc->name)); in mpt_do_ioc_recovery()
2526 if (ioc->alt_ioc && alt_ioc_ready && !ioc->alt_ioc->facts.EventState) in mpt_do_ioc_recovery()
2527 rc = SendEventNotification(ioc->alt_ioc, 1, sleepFlag); in mpt_do_ioc_recovery()
2531 CHIPREG_WRITE32(&ioc->chip->IntMask, MPI_HIM_DIM); in mpt_do_ioc_recovery()
2532 ioc->active = 1; in mpt_do_ioc_recovery()
2535 if (reset_alt_ioc_active && ioc->alt_ioc) { in mpt_do_ioc_recovery()
2536 /* (re)Enable alt-IOC! (reply interrupt) */ in mpt_do_ioc_recovery()
2537 dinitprintk(ioc, printk(MYIOC_s_DEBUG_FMT "alt-ioc" in mpt_do_ioc_recovery()
2538 "reply irq re-enabled\n", in mpt_do_ioc_recovery()
2539 ioc->alt_ioc->name)); in mpt_do_ioc_recovery()
2540 CHIPREG_WRITE32(&ioc->alt_ioc->chip->IntMask, in mpt_do_ioc_recovery()
2542 ioc->alt_ioc->active = 1; in mpt_do_ioc_recovery()
2548 * (combined with GetIoUnitPage2 call). This prevents a somewhat in mpt_do_ioc_recovery()
2558 mutex_init(&ioc->raid_data.inactive_list_mutex); in mpt_do_ioc_recovery()
2559 INIT_LIST_HEAD(&ioc->raid_data.inactive_list); in mpt_do_ioc_recovery()
2561 switch (ioc->bus_type) { in mpt_do_ioc_recovery()
2565 if(ioc->facts.IOCExceptions & in mpt_do_ioc_recovery()
2584 if ((ioc->pfacts[0].ProtocolFlags & in mpt_do_ioc_recovery()
2586 (ioc->lan_cnfg_page0.Header.PageLength == 0)) { in mpt_do_ioc_recovery()
2588 * Pre-fetch the ports LAN MAC address! in mpt_do_ioc_recovery()
2592 a = (u8*)&ioc->lan_cnfg_page1.HardwareAddressLow; in mpt_do_ioc_recovery()
2594 "LanAddr = %pMR\n", ioc->name, a)); in mpt_do_ioc_recovery()
2609 if (ioc->facts.MsgVersion >= MPI_VERSION_01_02) in mpt_do_ioc_recovery()
2627 free_irq(ioc->pci_irq, ioc); in mpt_do_ioc_recovery()
2628 if (ioc->msi_enable) in mpt_do_ioc_recovery()
2629 pci_disable_msi(ioc->pcidev); in mpt_do_ioc_recovery()
2634 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
2636 * mpt_detect_bound_ports - Search for matching PCI bus/dev_function
2641 * PCI bus/dev_function (+/-1) for newly discovered 929,
2644 * If match on PCI dev_function +/-1 is found, bind the two MPT adapters
2651 unsigned int slot = PCI_SLOT(pdev->devfn); in mpt_detect_bound_ports()
2652 unsigned int func = PCI_FUNC(pdev->devfn); in mpt_detect_bound_ports()
2657 ioc->name, pci_name(pdev), pdev->bus->number, in mpt_detect_bound_ports()
2658 pdev->devfn, func-1, func+1)); in mpt_detect_bound_ports()
2660 peer = pci_get_slot(pdev->bus, PCI_DEVFN(slot,func-1)); in mpt_detect_bound_ports()
2662 peer = pci_get_slot(pdev->bus, PCI_DEVFN(slot,func+1)); in mpt_detect_bound_ports()
2668 struct pci_dev *_pcidev = ioc_srch->pcidev; in mpt_detect_bound_ports()
2671 if (ioc->alt_ioc != NULL) { in mpt_detect_bound_ports()
2674 ioc->name, ioc->name, ioc->alt_ioc->name); in mpt_detect_bound_ports()
2676 } else if (ioc_srch->alt_ioc != NULL) { in mpt_detect_bound_ports()
2679 ioc_srch->name, ioc_srch->name, in mpt_detect_bound_ports()
2680 ioc_srch->alt_ioc->name); in mpt_detect_bound_ports()
2685 ioc->name, ioc->name, ioc_srch->name)); in mpt_detect_bound_ports()
2686 ioc_srch->alt_ioc = ioc; in mpt_detect_bound_ports()
2687 ioc->alt_ioc = ioc_srch; in mpt_detect_bound_ports()
2693 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
2695 * mpt_adapter_disable - Disable misbehaving MPT adapter.
2704 if (ioc->cached_fw != NULL) { in mpt_adapter_disable()
2706 "%s: Pushing FW onto adapter\n", __func__, ioc->name)); in mpt_adapter_disable()
2708 ioc->cached_fw, CAN_SLEEP)) < 0) { in mpt_adapter_disable()
2711 ioc->name, ret); in mpt_adapter_disable()
2724 ioc->name, __func__); in mpt_adapter_disable()
2727 "failed!\n", ioc->name, __func__); in mpt_adapter_disable()
2732 synchronize_irq(ioc->pcidev->irq); in mpt_adapter_disable()
2733 CHIPREG_WRITE32(&ioc->chip->IntMask, 0xFFFFFFFF); in mpt_adapter_disable()
2734 ioc->active = 0; in mpt_adapter_disable()
2737 CHIPREG_WRITE32(&ioc->chip->IntStatus, 0); in mpt_adapter_disable()
2738 CHIPREG_READ32(&ioc->chip->IntStatus); in mpt_adapter_disable()
2740 if (ioc->alloc != NULL) { in mpt_adapter_disable()
2741 sz = ioc->alloc_sz; in mpt_adapter_disable()
2743 ioc->name, ioc->alloc, ioc->alloc_sz)); in mpt_adapter_disable()
2744 dma_free_coherent(&ioc->pcidev->dev, sz, ioc->alloc, in mpt_adapter_disable()
2745 ioc->alloc_dma); in mpt_adapter_disable()
2746 ioc->reply_frames = NULL; in mpt_adapter_disable()
2747 ioc->req_frames = NULL; in mpt_adapter_disable()
2748 ioc->alloc = NULL; in mpt_adapter_disable()
2749 ioc->alloc_total -= sz; in mpt_adapter_disable()
2752 if (ioc->sense_buf_pool != NULL) { in mpt_adapter_disable()
2753 sz = (ioc->req_depth * MPT_SENSE_BUFFER_ALLOC); in mpt_adapter_disable()
2754 dma_free_coherent(&ioc->pcidev->dev, sz, ioc->sense_buf_pool, in mpt_adapter_disable()
2755 ioc->sense_buf_pool_dma); in mpt_adapter_disable()
2756 ioc->sense_buf_pool = NULL; in mpt_adapter_disable()
2757 ioc->alloc_total -= sz; in mpt_adapter_disable()
2760 if (ioc->events != NULL){ in mpt_adapter_disable()
2762 kfree(ioc->events); in mpt_adapter_disable()
2763 ioc->events = NULL; in mpt_adapter_disable()
2764 ioc->alloc_total -= sz; in mpt_adapter_disable()
2769 kfree(ioc->spi_data.nvram); in mpt_adapter_disable()
2771 kfree(ioc->raid_data.pIocPg2); in mpt_adapter_disable()
2772 kfree(ioc->raid_data.pIocPg3); in mpt_adapter_disable()
2773 ioc->spi_data.nvram = NULL; in mpt_adapter_disable()
2774 ioc->raid_data.pIocPg3 = NULL; in mpt_adapter_disable()
2776 if (ioc->spi_data.pIocPg4 != NULL) { in mpt_adapter_disable()
2777 sz = ioc->spi_data.IocPg4Sz; in mpt_adapter_disable()
2778 pci_free_consistent(ioc->pcidev, sz, in mpt_adapter_disable()
2779 ioc->spi_data.pIocPg4, in mpt_adapter_disable()
2780 ioc->spi_data.IocPg4_dma); in mpt_adapter_disable()
2781 ioc->spi_data.pIocPg4 = NULL; in mpt_adapter_disable()
2782 ioc->alloc_total -= sz; in mpt_adapter_disable()
2785 if (ioc->ReqToChain != NULL) { in mpt_adapter_disable()
2786 kfree(ioc->ReqToChain); in mpt_adapter_disable()
2787 kfree(ioc->RequestNB); in mpt_adapter_disable()
2788 ioc->ReqToChain = NULL; in mpt_adapter_disable()
2791 kfree(ioc->ChainToChain); in mpt_adapter_disable()
2792 ioc->ChainToChain = NULL; in mpt_adapter_disable()
2794 if (ioc->HostPageBuffer != NULL) { in mpt_adapter_disable()
2799 ioc->name, __func__, ret); in mpt_adapter_disable()
2803 ioc->name, ioc->HostPageBuffer, in mpt_adapter_disable()
2804 ioc->HostPageBuffer_sz)); in mpt_adapter_disable()
2805 dma_free_coherent(&ioc->pcidev->dev, ioc->HostPageBuffer_sz, in mpt_adapter_disable()
2806 ioc->HostPageBuffer, ioc->HostPageBuffer_dma); in mpt_adapter_disable()
2807 ioc->HostPageBuffer = NULL; in mpt_adapter_disable()
2808 ioc->HostPageBuffer_sz = 0; in mpt_adapter_disable()
2809 ioc->alloc_total -= ioc->HostPageBuffer_sz; in mpt_adapter_disable()
2812 pci_set_drvdata(ioc->pcidev, NULL); in mpt_adapter_disable()
2814 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
2816 * mpt_adapter_dispose - Free all resources associated with an MPT adapter
2830 sz_first = ioc->alloc_total; in mpt_adapter_dispose()
2834 if (ioc->pci_irq != -1) { in mpt_adapter_dispose()
2835 free_irq(ioc->pci_irq, ioc); in mpt_adapter_dispose()
2836 if (ioc->msi_enable) in mpt_adapter_dispose()
2837 pci_disable_msi(ioc->pcidev); in mpt_adapter_dispose()
2838 ioc->pci_irq = -1; in mpt_adapter_dispose()
2841 if (ioc->memmap != NULL) { in mpt_adapter_dispose()
2842 iounmap(ioc->memmap); in mpt_adapter_dispose()
2843 ioc->memmap = NULL; in mpt_adapter_dispose()
2846 pci_disable_device(ioc->pcidev); in mpt_adapter_dispose()
2847 pci_release_selected_regions(ioc->pcidev, ioc->bars); in mpt_adapter_dispose()
2850 list_del(&ioc->list); in mpt_adapter_dispose()
2852 sz_last = ioc->alloc_total; in mpt_adapter_dispose()
2854 ioc->name, sz_first-sz_last+(int)sizeof(*ioc), sz_first)); in mpt_adapter_dispose()
2856 if (ioc->alt_ioc) in mpt_adapter_dispose()
2857 ioc->alt_ioc->alt_ioc = NULL; in mpt_adapter_dispose()
2862 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
2864 * MptDisplayIocCapabilities - Disply IOC's capabilities.
2872 printk(KERN_INFO "%s: ", ioc->name); in MptDisplayIocCapabilities()
2873 if (ioc->prod_name) in MptDisplayIocCapabilities()
2874 pr_cont("%s: ", ioc->prod_name); in MptDisplayIocCapabilities()
2877 if (ioc->pfacts[0].ProtocolFlags & MPI_PORTFACTS_PROTOCOL_INITIATOR) { in MptDisplayIocCapabilities()
2882 if (ioc->pfacts[0].ProtocolFlags & MPI_PORTFACTS_PROTOCOL_TARGET) { in MptDisplayIocCapabilities()
2887 if (ioc->pfacts[0].ProtocolFlags & MPI_PORTFACTS_PROTOCOL_LAN) { in MptDisplayIocCapabilities()
2896 if (ioc->pfacts[0].ProtocolFlags & MPI_PORTFACTS_PROTOCOL_TARGET) { in MptDisplayIocCapabilities()
2905 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
2907 * MakeIocReady - Get IOC to a READY state, using KickStart if needed.
2913 * 1 - DIAG reset and READY
2914 * 0 - READY initially OR soft reset and READY
2915 * -1 - Any failure on KickStart
2916 * -2 - Msg Unit Reset Failed
2917 * -3 - IO Unit Reset Failed
2918 * -4 - IOC owned by a PEER
2933 dhsprintk(ioc, printk(MYIOC_s_INFO_FMT "MakeIocReady [raw] state=%08x\n", ioc->name, ioc_state)); in MakeIocReady()
2942 ioc->name); in MakeIocReady()
2949 "IOC is in READY state\n", ioc->name)); in MakeIocReady()
2959 ioc->name); in MakeIocReady()
2961 ioc->name, ioc_state & MPI_DOORBELL_DATA_MASK); in MakeIocReady()
2969 ioc->name)); in MakeIocReady()
2979 ioc->name, whoinit, statefault, force)); in MakeIocReady()
2981 return -4; in MakeIocReady()
2993 return -1; in MakeIocReady()
3008 printk(MYIOC_s_ERR_FMT "IOC msg unit reset failed!\n", ioc->name); in MakeIocReady()
3009 return -2; in MakeIocReady()
3017 printk(MYIOC_s_ERR_FMT "IO unit reset failed!\n", ioc->name); in MakeIocReady()
3018 return -3; in MakeIocReady()
3022 ii++; cntdn--; in MakeIocReady()
3026 ioc->name, ioc_state, (int)((ii+5)/HZ)); in MakeIocReady()
3027 return -ETIME; in MakeIocReady()
3039 printk(MYIOC_s_INFO_FMT "Recovered from %s\n", ioc->name, in MakeIocReady()
3046 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
3048 * mpt_GetIocState - Get the current state of a MPT adapter.
3061 s = CHIPREG_READ32(&ioc->chip->Doorbell); in mpt_GetIocState()
3065 ioc->last_state = sc; in mpt_GetIocState()
3070 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
3072 * GetIocFacts - Send IOCFacts request to MPT adapter.
3077 * Returns 0 for success, non-zero for failure.
3092 if (ioc->last_state == MPI_IOC_STATE_RESET) { in GetIocFacts()
3094 ": ERROR - Can't get IOCFacts, %s NOT READY! (%08x)\n", in GetIocFacts()
3095 ioc->name, ioc->last_state); in GetIocFacts()
3096 return -44; in GetIocFacts()
3099 facts = &ioc->facts; in GetIocFacts()
3114 ioc->name, req_sz, reply_sz)); in GetIocFacts()
3116 /* No non-zero fields in the get_facts request are greater than in GetIocFacts()
3132 if (facts->MsgLength > offsetof(IOCFactsReply_t, RequestFrameSize)/sizeof(u32)) { in GetIocFacts()
3137 if (ioc->FirstWhoInit == WHOINIT_UNKNOWN) in GetIocFacts()
3138 ioc->FirstWhoInit = facts->WhoInit; in GetIocFacts()
3141 facts->MsgVersion = le16_to_cpu(facts->MsgVersion); in GetIocFacts()
3142 facts->MsgContext = le32_to_cpu(facts->MsgContext); in GetIocFacts()
3143 facts->IOCExceptions = le16_to_cpu(facts->IOCExceptions); in GetIocFacts()
3144 facts->IOCStatus = le16_to_cpu(facts->IOCStatus); in GetIocFacts()
3145 facts->IOCLogInfo = le32_to_cpu(facts->IOCLogInfo); in GetIocFacts()
3146 status = le16_to_cpu(facts->IOCStatus) & MPI_IOCSTATUS_MASK; in GetIocFacts()
3149 facts->ReplyQueueDepth = le16_to_cpu(facts->ReplyQueueDepth); in GetIocFacts()
3150 facts->RequestFrameSize = le16_to_cpu(facts->RequestFrameSize); in GetIocFacts()
3157 if (facts->MsgVersion < MPI_VERSION_01_02) { in GetIocFacts()
3161 u16 oldv = le16_to_cpu(facts->Reserved_0101_FWVersion); in GetIocFacts()
3162 facts->FWVersion.Word = in GetIocFacts()
3166 facts->FWVersion.Word = le32_to_cpu(facts->FWVersion.Word); in GetIocFacts()
3168 facts->ProductID = le16_to_cpu(facts->ProductID); in GetIocFacts()
3170 if ((ioc->facts.ProductID & MPI_FW_HEADER_PID_PROD_MASK) in GetIocFacts()
3172 ioc->ir_firmware = 1; in GetIocFacts()
3174 facts->CurrentHostMfaHighAddr = in GetIocFacts()
3175 le32_to_cpu(facts->CurrentHostMfaHighAddr); in GetIocFacts()
3176 facts->GlobalCredits = le16_to_cpu(facts->GlobalCredits); in GetIocFacts()
3177 facts->CurrentSenseBufferHighAddr = in GetIocFacts()
3178 le32_to_cpu(facts->CurrentSenseBufferHighAddr); in GetIocFacts()
3179 facts->CurReplyFrameSize = in GetIocFacts()
3180 le16_to_cpu(facts->CurReplyFrameSize); in GetIocFacts()
3181 facts->IOCCapabilities = le32_to_cpu(facts->IOCCapabilities); in GetIocFacts()
3184 * Handle NEW (!) IOCFactsReply fields in MPI-1.01.xx in GetIocFacts()
3185 * Older MPI-1.00.xx struct had 13 dwords, and enlarged in GetIocFacts()
3186 * to 14 in MPI-1.01.0x. in GetIocFacts()
3188 if (facts->MsgLength >= (offsetof(IOCFactsReply_t,FWImageSize) + 7)/4 && in GetIocFacts()
3189 facts->MsgVersion > MPI_VERSION_01_00) { in GetIocFacts()
3190 facts->FWImageSize = le32_to_cpu(facts->FWImageSize); in GetIocFacts()
3193 facts->FWImageSize = ALIGN(facts->FWImageSize, 4); in GetIocFacts()
3195 if (!facts->RequestFrameSize) { in GetIocFacts()
3198 ioc->name); in GetIocFacts()
3199 return -55; in GetIocFacts()
3202 r = sz = facts->BlockSize; in GetIocFacts()
3204 ioc->NB_for_64_byte_frame = vv; in GetIocFacts()
3210 ioc->NBShiftFactor = shiftFactor; in GetIocFacts()
3213 ioc->name, vv, shiftFactor, r)); in GetIocFacts()
3220 ioc->req_sz = min(MPT_DEFAULT_FRAME_SIZE, facts->RequestFrameSize * 4); in GetIocFacts()
3221 ioc->req_depth = min_t(int, MPT_MAX_REQ_DEPTH, facts->GlobalCredits); in GetIocFacts()
3222 ioc->reply_sz = MPT_REPLY_FRAME_SIZE; in GetIocFacts()
3223 ioc->reply_depth = min_t(int, MPT_DEFAULT_REPLY_DEPTH, facts->ReplyQueueDepth); in GetIocFacts()
3226 ioc->name, ioc->reply_sz, ioc->reply_depth)); in GetIocFacts()
3228 ioc->name, ioc->req_sz, ioc->req_depth)); in GetIocFacts()
3237 ioc->name, facts->MsgLength, (offsetof(IOCFactsReply_t, in GetIocFacts()
3239 return -66; in GetIocFacts()
3245 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
3247 * GetPortFacts - Send PortFacts request to MPT adapter.
3252 * Returns 0 for success, non-zero for failure.
3265 if (ioc->last_state == MPI_IOC_STATE_RESET) { in GetPortFacts()
3267 ioc->name, ioc->last_state ); in GetPortFacts()
3268 return -4; in GetPortFacts()
3271 pfacts = &ioc->pfacts[portnum]; in GetPortFacts()
3286 ioc->name, portnum)); in GetPortFacts()
3288 /* No non-zero fields in the get_pfacts request are greater than in GetPortFacts()
3299 pfacts->MsgContext = le32_to_cpu(pfacts->MsgContext); in GetPortFacts()
3300 pfacts->IOCStatus = le16_to_cpu(pfacts->IOCStatus); in GetPortFacts()
3301 pfacts->IOCLogInfo = le32_to_cpu(pfacts->IOCLogInfo); in GetPortFacts()
3302 pfacts->MaxDevices = le16_to_cpu(pfacts->MaxDevices); in GetPortFacts()
3303 pfacts->PortSCSIID = le16_to_cpu(pfacts->PortSCSIID); in GetPortFacts()
3304 pfacts->ProtocolFlags = le16_to_cpu(pfacts->ProtocolFlags); in GetPortFacts()
3305 pfacts->MaxPostedCmdBuffers = le16_to_cpu(pfacts->MaxPostedCmdBuffers); in GetPortFacts()
3306 pfacts->MaxPersistentIDs = le16_to_cpu(pfacts->MaxPersistentIDs); in GetPortFacts()
3307 pfacts->MaxLanBuckets = le16_to_cpu(pfacts->MaxLanBuckets); in GetPortFacts()
3309 max_id = (ioc->bus_type == SAS) ? pfacts->PortSCSIID : in GetPortFacts()
3310 pfacts->MaxDevices; in GetPortFacts()
3311 ioc->devices_per_bus = (max_id > 255) ? 256 : max_id; in GetPortFacts()
3312 ioc->number_of_buses = (ioc->devices_per_bus < 256) ? 1 : max_id/256; in GetPortFacts()
3320 ioc->devices_per_bus = 1; in GetPortFacts()
3321 ioc->number_of_buses = (max_id > 255) ? 255 : max_id; in GetPortFacts()
3327 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
3329 * SendIocInit - Send IOCInit request to MPT adapter.
3335 * Returns 0 for success, non-zero for failure.
3357 if (ioc->facts.Flags & MPI_IOCFACTS_FLAGS_FW_DOWNLOAD_BOOT) in SendIocInit()
3358 ioc->upload_fw = 1; in SendIocInit()
3360 ioc->upload_fw = 0; in SendIocInit()
3362 ioc->name, ioc->upload_fw, ioc->facts.Flags)); in SendIocInit()
3364 ioc_init.MaxDevices = (U8)ioc->devices_per_bus; in SendIocInit()
3365 ioc_init.MaxBuses = (U8)ioc->number_of_buses; in SendIocInit()
3368 ioc->name, ioc->facts.MsgVersion)); in SendIocInit()
3369 if (ioc->facts.MsgVersion >= MPI_VERSION_01_05) { in SendIocInit()
3374 if (ioc->facts.Flags & MPI_IOCFACTS_FLAGS_HOST_PAGE_BUFFER_PERSISTENT) { in SendIocInit()
3375 ioc_init.HostPageBufferSGE = ioc->facts.HostPageBufferSGE; in SendIocInit()
3377 return -99; in SendIocInit()
3379 ioc_init.ReplyFrameSize = cpu_to_le16(ioc->reply_sz); /* in BYTES */ in SendIocInit()
3381 if (ioc->sg_addr_size == sizeof(u64)) { in SendIocInit()
3382 /* Save the upper 32-bits of the request in SendIocInit()
3385 ioc_init.HostMfaHighAddr = cpu_to_le32((u32)((u64)ioc->alloc_dma >> 32)); in SendIocInit()
3386 ioc_init.SenseBufferHighAddr = cpu_to_le32((u32)((u64)ioc->sense_buf_pool_dma >> 32)); in SendIocInit()
3388 /* Force 32-bit addressing */ in SendIocInit()
3393 ioc->facts.CurrentHostMfaHighAddr = ioc_init.HostMfaHighAddr; in SendIocInit()
3394 ioc->facts.CurrentSenseBufferHighAddr = ioc_init.SenseBufferHighAddr; in SendIocInit()
3395 ioc->facts.MaxDevices = ioc_init.MaxDevices; in SendIocInit()
3396 ioc->facts.MaxBuses = ioc_init.MaxBuses; in SendIocInit()
3398 dhsprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Sending IOCInit (req @ %p)\n", in SendIocInit()
3399 ioc->name, &ioc_init)); in SendIocInit()
3404 printk(MYIOC_s_ERR_FMT "Sending IOCInit failed(%d)!\n",ioc->name, r); in SendIocInit()
3412 dhsprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Sending PortEnable (req @ %p)\n", in SendIocInit()
3413 ioc->name, &ioc_init)); in SendIocInit()
3416 printk(MYIOC_s_ERR_FMT "Sending PortEnable failed(%d)!\n",ioc->name, r); in SendIocInit()
3427 while (state != MPI_IOC_STATE_OPERATIONAL && --cntdn) { in SendIocInit()
3436 ioc->name, (int)((count+5)/HZ)); in SendIocInit()
3437 return -9; in SendIocInit()
3444 ioc->name, count)); in SendIocInit()
3446 ioc->aen_event_read_flag=0; in SendIocInit()
3450 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
3452 * SendPortEnable - Send PortEnable request to MPT adapter port.
3459 * Returns 0 for success, non-zero for failure.
3483 dinitprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Sending Port(%d)Enable (req @ %p)\n", in SendPortEnable()
3484 ioc->name, portnum, &port_enable)); in SendPortEnable()
3488 if (ioc->ir_firmware || ioc->bus_type == SAS) { in SendPortEnable()
3501 * mpt_alloc_fw_memory - allocate firmware memory
3508 * Return 0 if successful, or non-zero for failure
3515 if (ioc->cached_fw) { in mpt_alloc_fw_memory()
3519 else if (ioc->alt_ioc && ioc->alt_ioc->cached_fw) { in mpt_alloc_fw_memory()
3520 ioc->cached_fw = ioc->alt_ioc->cached_fw; /* use alt_ioc's memory */ in mpt_alloc_fw_memory()
3521 ioc->cached_fw_dma = ioc->alt_ioc->cached_fw_dma; in mpt_alloc_fw_memory()
3525 ioc->cached_fw = pci_alloc_consistent(ioc->pcidev, size, &ioc->cached_fw_dma); in mpt_alloc_fw_memory()
3526 if (!ioc->cached_fw) { in mpt_alloc_fw_memory()
3528 ioc->name); in mpt_alloc_fw_memory()
3529 rc = -1; in mpt_alloc_fw_memory()
3532 ioc->name, ioc->cached_fw, (void *)(ulong)ioc->cached_fw_dma, size, size)); in mpt_alloc_fw_memory()
3533 ioc->alloc_total += size; in mpt_alloc_fw_memory()
3541 * mpt_free_fw_memory - free firmware memory
3552 if (!ioc->cached_fw) in mpt_free_fw_memory()
3555 sz = ioc->facts.FWImageSize; in mpt_free_fw_memory()
3557 ioc->name, ioc->cached_fw, (void *)(ulong)ioc->cached_fw_dma, sz, sz)); in mpt_free_fw_memory()
3558 pci_free_consistent(ioc->pcidev, sz, ioc->cached_fw, ioc->cached_fw_dma); in mpt_free_fw_memory()
3559 ioc->alloc_total -= sz; in mpt_free_fw_memory()
3560 ioc->cached_fw = NULL; in mpt_free_fw_memory()
3563 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
3565 * mpt_do_upload - Construct and Send FWUpload request to MPT adapter port.
3590 if ((sz = ioc->facts.FWImageSize) == 0) in mpt_do_upload()
3593 if (mpt_alloc_fw_memory(ioc, ioc->facts.FWImageSize) != 0) in mpt_do_upload()
3594 return -ENOMEM; in mpt_do_upload()
3597 ioc->name, ioc->cached_fw, (void *)(ulong)ioc->cached_fw_dma, sz, sz)); in mpt_do_upload()
3599 prequest = (sleepFlag == NO_SLEEP) ? kzalloc(ioc->req_sz, GFP_ATOMIC) : in mpt_do_upload()
3600 kzalloc(ioc->req_sz, GFP_KERNEL); in mpt_do_upload()
3603 "while allocating memory \n", ioc->name)); in mpt_do_upload()
3605 return -ENOMEM; in mpt_do_upload()
3613 prequest->ImageType = MPI_FW_UPLOAD_ITYPE_FW_IOC_MEM; in mpt_do_upload()
3614 prequest->Function = MPI_FUNCTION_FW_UPLOAD; in mpt_do_upload()
3616 ptcsge = (FWUploadTCSGE_t *) &prequest->SGL; in mpt_do_upload()
3617 ptcsge->DetailsLength = 12; in mpt_do_upload()
3618 ptcsge->Flags = MPI_SGE_FLAGS_TRANSACTION_ELEMENT; in mpt_do_upload()
3619 ptcsge->ImageSize = cpu_to_le32(sz); in mpt_do_upload()
3623 ioc->add_sge((char *)ptcsge, flagsLength, ioc->cached_fw_dma); in mpt_do_upload()
3625 ioc->SGE_size; in mpt_do_upload()
3627 " (req @ %p) fw_size=%d mf_request_size=%d\n", ioc->name, prequest, in mpt_do_upload()
3628 ioc->facts.FWImageSize, request_size)); in mpt_do_upload()
3635 "rc=%x \n", ioc->name, ii)); in mpt_do_upload()
3637 cmdStatus = -EFAULT; in mpt_do_upload()
3643 status = le16_to_cpu(preply->IOCStatus) & in mpt_do_upload()
3646 ioc->facts.FWImageSize == in mpt_do_upload()
3647 le32_to_cpu(preply->ActualImageSize)) in mpt_do_upload()
3651 ioc->name, cmdStatus)); in mpt_do_upload()
3656 "freeing image \n", ioc->name)); in mpt_do_upload()
3664 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
3666 * mpt_downloadboot - DownloadBoot code
3674 * -1 FW Image size is 0
3675 * -2 No valid cached_fw Pointer
3692 ioc->name, pFwHeader->ImageSize, pFwHeader->ImageSize, pFwHeader)); in mpt_downloadboot()
3694 CHIPREG_WRITE32(&ioc->chip->WriteSequence, 0xFF); in mpt_downloadboot()
3695 CHIPREG_WRITE32(&ioc->chip->WriteSequence, MPI_WRSEQ_1ST_KEY_VALUE); in mpt_downloadboot()
3696 CHIPREG_WRITE32(&ioc->chip->WriteSequence, MPI_WRSEQ_2ND_KEY_VALUE); in mpt_downloadboot()
3697 CHIPREG_WRITE32(&ioc->chip->WriteSequence, MPI_WRSEQ_3RD_KEY_VALUE); in mpt_downloadboot()
3698 CHIPREG_WRITE32(&ioc->chip->WriteSequence, MPI_WRSEQ_4TH_KEY_VALUE); in mpt_downloadboot()
3699 CHIPREG_WRITE32(&ioc->chip->WriteSequence, MPI_WRSEQ_5TH_KEY_VALUE); in mpt_downloadboot()
3701 CHIPREG_WRITE32(&ioc->chip->Diagnostic, (MPI_DIAG_PREVENT_IOC_BOOT | MPI_DIAG_DISABLE_ARM)); in mpt_downloadboot()
3710 diag0val = CHIPREG_READ32(&ioc->chip->Diagnostic); in mpt_downloadboot()
3711 CHIPREG_WRITE32(&ioc->chip->Diagnostic, diag0val | MPI_DIAG_RESET_ADAPTER); in mpt_downloadboot()
3714 diag0val = CHIPREG_READ32(&ioc->chip->Diagnostic); in mpt_downloadboot()
3717 ioc->name, count)); in mpt_downloadboot()
3731 ioc->name, diag0val)); in mpt_downloadboot()
3732 return -3; in mpt_downloadboot()
3735 CHIPREG_WRITE32(&ioc->chip->WriteSequence, 0xFF); in mpt_downloadboot()
3736 CHIPREG_WRITE32(&ioc->chip->WriteSequence, MPI_WRSEQ_1ST_KEY_VALUE); in mpt_downloadboot()
3737 CHIPREG_WRITE32(&ioc->chip->WriteSequence, MPI_WRSEQ_2ND_KEY_VALUE); in mpt_downloadboot()
3738 CHIPREG_WRITE32(&ioc->chip->WriteSequence, MPI_WRSEQ_3RD_KEY_VALUE); in mpt_downloadboot()
3739 CHIPREG_WRITE32(&ioc->chip->WriteSequence, MPI_WRSEQ_4TH_KEY_VALUE); in mpt_downloadboot()
3740 CHIPREG_WRITE32(&ioc->chip->WriteSequence, MPI_WRSEQ_5TH_KEY_VALUE); in mpt_downloadboot()
3743 CHIPREG_WRITE32(&ioc->chip->Diagnostic, (MPI_DIAG_RW_ENABLE | MPI_DIAG_DISABLE_ARM)); in mpt_downloadboot()
3745 fwSize = (pFwHeader->ImageSize + 3)/4; in mpt_downloadboot()
3751 if (ioc->errata_flag_1064) in mpt_downloadboot()
3752 pci_enable_io_access(ioc->pcidev); in mpt_downloadboot()
3754 CHIPREG_PIO_WRITE32(&ioc->pio_chip->DiagRwAddress, pFwHeader->LoadStartAddress); in mpt_downloadboot()
3756 ioc->name, pFwHeader->LoadStartAddress)); in mpt_downloadboot()
3759 ioc->name, fwSize*4, ptrFw)); in mpt_downloadboot()
3760 while (fwSize--) { in mpt_downloadboot()
3761 CHIPREG_PIO_WRITE32(&ioc->pio_chip->DiagRwData, *ptrFw++); in mpt_downloadboot()
3764 nextImage = pFwHeader->NextImageHeaderOffset; in mpt_downloadboot()
3768 load_addr = pExtImage->LoadStartAddress; in mpt_downloadboot()
3770 fwSize = (pExtImage->ImageSize + 3) >> 2; in mpt_downloadboot()
3774 ioc->name, fwSize*4, fwSize*4, ptrFw, load_addr)); in mpt_downloadboot()
3775 CHIPREG_PIO_WRITE32(&ioc->pio_chip->DiagRwAddress, load_addr); in mpt_downloadboot()
3777 while (fwSize--) { in mpt_downloadboot()
3778 CHIPREG_PIO_WRITE32(&ioc->pio_chip->DiagRwData, *ptrFw++); in mpt_downloadboot()
3780 nextImage = pExtImage->NextImageHeaderOffset; in mpt_downloadboot()
3784 …ddlprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Write IopResetVector Addr=%x! \n", ioc->name, pFwHeader- in mpt_downloadboot()
3785 CHIPREG_PIO_WRITE32(&ioc->pio_chip->DiagRwAddress, pFwHeader->IopResetRegAddr); in mpt_downloadboot()
3788 …ddlprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Write IopResetVector Value=%x! \n", ioc->name, pFwHeader- in mpt_downloadboot()
3789 CHIPREG_PIO_WRITE32(&ioc->pio_chip->DiagRwData, pFwHeader->IopResetVectorValue); in mpt_downloadboot()
3791 /* Clear the internal flash bad bit - autoincrementing register, in mpt_downloadboot()
3794 if (ioc->bus_type == SPI) { in mpt_downloadboot()
3799 CHIPREG_PIO_WRITE32(&ioc->pio_chip->DiagRwAddress, 0x3F000000); in mpt_downloadboot()
3800 diagRwData = CHIPREG_PIO_READ32(&ioc->pio_chip->DiagRwData); in mpt_downloadboot()
3802 CHIPREG_PIO_WRITE32(&ioc->pio_chip->DiagRwAddress, 0x3F000000); in mpt_downloadboot()
3803 CHIPREG_PIO_WRITE32(&ioc->pio_chip->DiagRwData, diagRwData); in mpt_downloadboot()
3805 } else /* if((ioc->bus_type == SAS) || (ioc->bus_type == FC)) */ { in mpt_downloadboot()
3806 diag0val = CHIPREG_READ32(&ioc->chip->Diagnostic); in mpt_downloadboot()
3807 CHIPREG_WRITE32(&ioc->chip->Diagnostic, diag0val | in mpt_downloadboot()
3818 if (ioc->errata_flag_1064) in mpt_downloadboot()
3819 pci_disable_io_access(ioc->pcidev); in mpt_downloadboot()
3821 diag0val = CHIPREG_READ32(&ioc->chip->Diagnostic); in mpt_downloadboot()
3824 ioc->name, diag0val)); in mpt_downloadboot()
3827 ioc->name, diag0val)); in mpt_downloadboot()
3828 CHIPREG_WRITE32(&ioc->chip->Diagnostic, diag0val); in mpt_downloadboot()
3831 CHIPREG_WRITE32(&ioc->chip->WriteSequence, 0xFF); in mpt_downloadboot()
3833 if (ioc->bus_type == SAS) { in mpt_downloadboot()
3838 ioc->name, ioc_state)); in mpt_downloadboot()
3839 return -EFAULT; in mpt_downloadboot()
3847 ioc->name, count, ioc_state)); in mpt_downloadboot()
3848 if (ioc->bus_type == SAS) { in mpt_downloadboot()
3854 ioc->name)); in mpt_downloadboot()
3855 return -EFAULT; in mpt_downloadboot()
3859 ioc->name)); in mpt_downloadboot()
3869 "downloadboot failed! IocState=%x\n",ioc->name, ioc_state)); in mpt_downloadboot()
3870 return -EFAULT; in mpt_downloadboot()
3873 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
3875 * KickStart - Perform hard reset of MPT adapter.
3884 * Inputs: sleepflag - CAN_SLEEP (non-interrupt thread)
3886 * force - 1 if doorbell active, board fault state
3892 * 1 - hard reset, READY
3893 * 0 - no reset due to History bit, READY
3894 * -1 - no reset due to History bit but not READY
3896 * -2 - no reset, could not enter DIAG mode
3897 * -3 - reset but bad FW bit
3906 dinitprintk(ioc, printk(MYIOC_s_DEBUG_FMT "KickStarting!\n", ioc->name)); in KickStart()
3907 if (ioc->bus_type == SPI) { in KickStart()
3925 ioc->name)); in KickStart()
3932 ioc->name, cnt)); in KickStart()
3943 ioc->name, mpt_GetIocState(ioc, 0))); in KickStart()
3944 return -1; in KickStart()
3947 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
3949 * mpt_diag_reset - Perform hard reset of the adapter.
3953 * @sleepFlag: CAN_SLEEP if called in a non-interrupt thread,
3963 * -2 enabling diagnostic mode failed
3964 * -3 diagnostic reset failed
3978 CHIPREG_WRITE32(&ioc->chip->IntStatus, 0); in mpt_diag_reset()
3980 if (ioc->pcidev->device == MPI_MANUFACTPAGE_DEVID_SAS1078) { in mpt_diag_reset()
3986 "address=%p\n", ioc->name, __func__, in mpt_diag_reset()
3987 &ioc->chip->Doorbell, &ioc->chip->Reset_1078)); in mpt_diag_reset()
3988 CHIPREG_WRITE32(&ioc->chip->Reset_1078, 0x07); in mpt_diag_reset()
3996 * with pre-reset indication. in mpt_diag_reset()
4000 for (cb_idx = MPT_MAX_PROTOCOL_DRIVERS-1; cb_idx; cb_idx--) { in mpt_diag_reset()
4007 doorbell = CHIPREG_READ32(&ioc->chip->Doorbell); in mpt_diag_reset()
4013 ioc->name, doorbell, count)); in mpt_diag_reset()
4025 return -1; in mpt_diag_reset()
4029 diag0val = CHIPREG_READ32(&ioc->chip->Diagnostic); in mpt_diag_reset()
4031 if (ioc->debug_level & MPT_DEBUG) { in mpt_diag_reset()
4032 if (ioc->alt_ioc) in mpt_diag_reset()
4033 diag1val = CHIPREG_READ32(&ioc->alt_ioc->chip->Diagnostic); in mpt_diag_reset()
4035 ioc->name, diag0val, diag1val)); in mpt_diag_reset()
4046 CHIPREG_WRITE32(&ioc->chip->WriteSequence, 0xFF); in mpt_diag_reset()
4047 CHIPREG_WRITE32(&ioc->chip->WriteSequence, MPI_WRSEQ_1ST_KEY_VALUE); in mpt_diag_reset()
4048 CHIPREG_WRITE32(&ioc->chip->WriteSequence, MPI_WRSEQ_2ND_KEY_VALUE); in mpt_diag_reset()
4049 CHIPREG_WRITE32(&ioc->chip->WriteSequence, MPI_WRSEQ_3RD_KEY_VALUE); in mpt_diag_reset()
4050 CHIPREG_WRITE32(&ioc->chip->WriteSequence, MPI_WRSEQ_4TH_KEY_VALUE); in mpt_diag_reset()
4051 CHIPREG_WRITE32(&ioc->chip->WriteSequence, MPI_WRSEQ_5TH_KEY_VALUE); in mpt_diag_reset()
4063 ioc->name, diag0val); in mpt_diag_reset()
4064 return -2; in mpt_diag_reset()
4068 diag0val = CHIPREG_READ32(&ioc->chip->Diagnostic); in mpt_diag_reset()
4071 ioc->name, diag0val)); in mpt_diag_reset()
4074 if (ioc->debug_level & MPT_DEBUG) { in mpt_diag_reset()
4075 if (ioc->alt_ioc) in mpt_diag_reset()
4076 diag1val = CHIPREG_READ32(&ioc->alt_ioc->chip->Diagnostic); in mpt_diag_reset()
4078 ioc->name, diag0val, diag1val)); in mpt_diag_reset()
4084 CHIPREG_WRITE32(&ioc->chip->Diagnostic, diag0val | MPI_DIAG_DISABLE_ARM); in mpt_diag_reset()
4091 CHIPREG_WRITE32(&ioc->chip->Diagnostic, diag0val | MPI_DIAG_RESET_ADAPTER); in mpt_diag_reset()
4094 ioc->name)); in mpt_diag_reset()
4098 * with pre-reset indication. in mpt_diag_reset()
4102 for (cb_idx = MPT_MAX_PROTOCOL_DRIVERS-1; cb_idx; cb_idx--) { in mpt_diag_reset()
4106 if (ioc->alt_ioc) { in mpt_diag_reset()
4108 ioc->alt_ioc, MPT_IOC_PRE_RESET); in mpt_diag_reset()
4113 if (ioc->cached_fw) in mpt_diag_reset()
4114 cached_fw = (MpiFwHeader_t *)ioc->cached_fw; in mpt_diag_reset()
4115 else if (ioc->alt_ioc && ioc->alt_ioc->cached_fw) in mpt_diag_reset()
4116 cached_fw = (MpiFwHeader_t *)ioc->alt_ioc->cached_fw; in mpt_diag_reset()
4125 diag0val = CHIPREG_READ32(&ioc->chip->Diagnostic); in mpt_diag_reset()
4131 ioc->name, diag0val, count)); in mpt_diag_reset()
4141 "firmware downloadboot failure (%d)!\n", ioc->name, count); in mpt_diag_reset()
4152 doorbell = CHIPREG_READ32(&ioc->chip->Doorbell); in mpt_diag_reset()
4157 " count=%d\n", ioc->name, doorbell, count)); in mpt_diag_reset()
4173 "after reset! IocState=%x", ioc->name, in mpt_diag_reset()
4178 diag0val = CHIPREG_READ32(&ioc->chip->Diagnostic); in mpt_diag_reset()
4179 if (ioc->debug_level & MPT_DEBUG) { in mpt_diag_reset()
4180 if (ioc->alt_ioc) in mpt_diag_reset()
4181 diag1val = CHIPREG_READ32(&ioc->alt_ioc->chip->Diagnostic); in mpt_diag_reset()
4183 ioc->name, diag0val, diag1val)); in mpt_diag_reset()
4189 diag0val = CHIPREG_READ32(&ioc->chip->Diagnostic); in mpt_diag_reset()
4195 CHIPREG_WRITE32(&ioc->chip->WriteSequence, 0xFF); in mpt_diag_reset()
4196 CHIPREG_WRITE32(&ioc->chip->WriteSequence, MPI_WRSEQ_1ST_KEY_VALUE); in mpt_diag_reset()
4197 CHIPREG_WRITE32(&ioc->chip->WriteSequence, MPI_WRSEQ_2ND_KEY_VALUE); in mpt_diag_reset()
4198 CHIPREG_WRITE32(&ioc->chip->WriteSequence, MPI_WRSEQ_3RD_KEY_VALUE); in mpt_diag_reset()
4199 CHIPREG_WRITE32(&ioc->chip->WriteSequence, MPI_WRSEQ_4TH_KEY_VALUE); in mpt_diag_reset()
4200 CHIPREG_WRITE32(&ioc->chip->WriteSequence, MPI_WRSEQ_5TH_KEY_VALUE); in mpt_diag_reset()
4212 ioc->name, diag0val); in mpt_diag_reset()
4215 diag0val = CHIPREG_READ32(&ioc->chip->Diagnostic); in mpt_diag_reset()
4218 CHIPREG_WRITE32(&ioc->chip->Diagnostic, diag0val); in mpt_diag_reset()
4219 diag0val = CHIPREG_READ32(&ioc->chip->Diagnostic); in mpt_diag_reset()
4222 ioc->name); in mpt_diag_reset()
4227 CHIPREG_WRITE32(&ioc->chip->WriteSequence, 0xFFFFFFFF); in mpt_diag_reset()
4231 diag0val = CHIPREG_READ32(&ioc->chip->Diagnostic); in mpt_diag_reset()
4234 ioc->name, diag0val); in mpt_diag_reset()
4235 return -3; in mpt_diag_reset()
4238 if (ioc->debug_level & MPT_DEBUG) { in mpt_diag_reset()
4239 if (ioc->alt_ioc) in mpt_diag_reset()
4240 diag1val = CHIPREG_READ32(&ioc->alt_ioc->chip->Diagnostic); in mpt_diag_reset()
4242 ioc->name, diag0val, diag1val)); in mpt_diag_reset()
4248 ioc->facts.EventState = 0; in mpt_diag_reset()
4250 if (ioc->alt_ioc) in mpt_diag_reset()
4251 ioc->alt_ioc->facts.EventState = 0; in mpt_diag_reset()
4256 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
4258 * SendIocReset - Send IOCReset request to MPT adapter.
4266 * Returns 0 for success, non-zero for failure.
4276 ioc->name, reset_type)); in SendIocReset()
4277 CHIPREG_WRITE32(&ioc->chip->Doorbell, reset_type<<MPI_DOORBELL_FUNCTION_SHIFT); in SendIocReset()
4287 cntdn--; in SendIocReset()
4295 ioc->name, state, (int)((count+5)/HZ)); in SendIocReset()
4296 return -ETIME; in SendIocReset()
4307 * Cleanup all event stuff for this IOC; re-issue EventNotification in SendIocReset()
4310 if (ioc->facts.Function) in SendIocReset()
4311 ioc->facts.EventState = 0; in SendIocReset()
4316 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
4318 * initChainBuffers - Allocate memory for and initialize chain buffers
4334 if (ioc->ReqToChain == NULL) { in initChainBuffers()
4335 sz = ioc->req_depth * sizeof(int); in initChainBuffers()
4338 return -1; in initChainBuffers()
4340 ioc->ReqToChain = (int *) mem; in initChainBuffers()
4342 ioc->name, mem, sz)); in initChainBuffers()
4345 return -1; in initChainBuffers()
4347 ioc->RequestNB = (int *) mem; in initChainBuffers()
4349 ioc->name, mem, sz)); in initChainBuffers()
4351 for (ii = 0; ii < ioc->req_depth; ii++) { in initChainBuffers()
4352 ioc->ReqToChain[ii] = MPT_HOST_NO_CHAIN; in initChainBuffers()
4365 scale = ioc->req_sz / ioc->SGE_size; in initChainBuffers()
4366 if (ioc->sg_addr_size == sizeof(u64)) in initChainBuffers()
4367 num_sge = scale + (ioc->req_sz - 60) / ioc->SGE_size; in initChainBuffers()
4369 num_sge = 1 + scale + (ioc->req_sz - 64) / ioc->SGE_size; in initChainBuffers()
4371 if (ioc->sg_addr_size == sizeof(u64)) { in initChainBuffers()
4372 numSGE = (scale - 1) * (ioc->facts.MaxChainDepth-1) + scale + in initChainBuffers()
4373 (ioc->req_sz - 60) / ioc->SGE_size; in initChainBuffers()
4375 numSGE = 1 + (scale - 1) * (ioc->facts.MaxChainDepth-1) + in initChainBuffers()
4376 scale + (ioc->req_sz - 64) / ioc->SGE_size; in initChainBuffers()
4379 ioc->name, num_sge, numSGE)); in initChainBuffers()
4381 if (ioc->bus_type == FC) { in initChainBuffers()
4390 while (numSGE - num_sge > 0) { in initChainBuffers()
4392 num_sge += (scale - 1); in initChainBuffers()
4397 ioc->name, numSGE, num_sge, num_chain)); in initChainBuffers()
4399 if (ioc->bus_type == SPI) in initChainBuffers()
4401 else if (ioc->bus_type == SAS) in initChainBuffers()
4406 ioc->num_chain = num_chain; in initChainBuffers()
4409 if (ioc->ChainToChain == NULL) { in initChainBuffers()
4412 return -1; in initChainBuffers()
4414 ioc->ChainToChain = (int *) mem; in initChainBuffers()
4416 ioc->name, mem, sz)); in initChainBuffers()
4418 mem = (u8 *) ioc->ChainToChain; in initChainBuffers()
4424 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
4426 * PrimeIocFifos - Initialize IOC request and reply FIFOs.
4433 * Returns 0 for success, non-zero for failure.
4449 if (ioc->reply_frames == NULL) { in PrimeIocFifos()
4451 return -1; in PrimeIocFifos()
4455 if (ioc->pcidev->device == MPI_MANUFACTPAGE_DEVID_SAS1078 && in PrimeIocFifos()
4456 ioc->dma_mask > DMA_BIT_MASK(35)) { in PrimeIocFifos()
4457 if (!pci_set_dma_mask(ioc->pcidev, DMA_BIT_MASK(32)) in PrimeIocFifos()
4458 && !pci_set_consistent_dma_mask(ioc->pcidev, in PrimeIocFifos()
4464 ioc->name)); in PrimeIocFifos()
4467 pci_set_dma_mask(ioc->pcidev, in PrimeIocFifos()
4469 pci_set_consistent_dma_mask(ioc->pcidev, in PrimeIocFifos()
4475 ioc->name); in PrimeIocFifos()
4476 return -1; in PrimeIocFifos()
4480 total_size = reply_sz = (ioc->reply_sz * ioc->reply_depth); in PrimeIocFifos()
4482 ioc->name, ioc->reply_sz, ioc->reply_depth)); in PrimeIocFifos()
4484 ioc->name, reply_sz, reply_sz)); in PrimeIocFifos()
4486 sz = (ioc->req_sz * ioc->req_depth); in PrimeIocFifos()
4488 ioc->name, ioc->req_sz, ioc->req_depth)); in PrimeIocFifos()
4490 ioc->name, sz, sz)); in PrimeIocFifos()
4493 sz = num_chain * ioc->req_sz; /* chain buffer pool size */ in PrimeIocFifos()
4495 ioc->name, ioc->req_sz, num_chain)); in PrimeIocFifos()
4497 ioc->name, sz, sz, num_chain)); in PrimeIocFifos()
4500 mem = dma_alloc_coherent(&ioc->pcidev->dev, total_size, in PrimeIocFifos()
4504 ioc->name); in PrimeIocFifos()
4509 ioc->name, mem, (void *)(ulong)alloc_dma, total_size, total_size)); in PrimeIocFifos()
4512 ioc->alloc_total += total_size; in PrimeIocFifos()
4513 ioc->alloc = mem; in PrimeIocFifos()
4514 ioc->alloc_dma = alloc_dma; in PrimeIocFifos()
4515 ioc->alloc_sz = total_size; in PrimeIocFifos()
4516 ioc->reply_frames = (MPT_FRAME_HDR *) mem; in PrimeIocFifos()
4517 ioc->reply_frames_low_dma = (u32) (alloc_dma & 0xFFFFFFFF); in PrimeIocFifos()
4520 ioc->name, ioc->reply_frames, (void *)(ulong)alloc_dma)); in PrimeIocFifos()
4525 /* Request FIFO - WE manage this! */ in PrimeIocFifos()
4527 ioc->req_frames = (MPT_FRAME_HDR *) mem; in PrimeIocFifos()
4528 ioc->req_frames_dma = alloc_dma; in PrimeIocFifos()
4531 ioc->name, mem, (void *)(ulong)alloc_dma)); in PrimeIocFifos()
4533 ioc->req_frames_low_dma = (u32) (alloc_dma & 0xFFFFFFFF); in PrimeIocFifos()
4535 for (i = 0; i < ioc->req_depth; i++) { in PrimeIocFifos()
4536 alloc_dma += ioc->req_sz; in PrimeIocFifos()
4537 mem += ioc->req_sz; in PrimeIocFifos()
4540 ioc->ChainBuffer = mem; in PrimeIocFifos()
4541 ioc->ChainBufferDMA = alloc_dma; in PrimeIocFifos()
4544 ioc->name, ioc->ChainBuffer, (void *)(ulong)ioc->ChainBufferDMA)); in PrimeIocFifos()
4549 INIT_LIST_HEAD(&ioc->FreeChainQ); in PrimeIocFifos()
4553 mem = (u8 *)ioc->ChainBuffer; in PrimeIocFifos()
4556 list_add_tail(&mf->u.frame.linkage.list, &ioc->FreeChainQ); in PrimeIocFifos()
4557 mem += ioc->req_sz; in PrimeIocFifos()
4562 alloc_dma = ioc->req_frames_dma; in PrimeIocFifos()
4563 mem = (u8 *) ioc->req_frames; in PrimeIocFifos()
4565 spin_lock_irqsave(&ioc->FreeQlock, flags); in PrimeIocFifos()
4566 INIT_LIST_HEAD(&ioc->FreeQ); in PrimeIocFifos()
4567 for (i = 0; i < ioc->req_depth; i++) { in PrimeIocFifos()
4571 list_add_tail(&mf->u.frame.linkage.list, &ioc->FreeQ); in PrimeIocFifos()
4573 mem += ioc->req_sz; in PrimeIocFifos()
4575 spin_unlock_irqrestore(&ioc->FreeQlock, flags); in PrimeIocFifos()
4577 sz = (ioc->req_depth * MPT_SENSE_BUFFER_ALLOC); in PrimeIocFifos()
4578 ioc->sense_buf_pool = dma_alloc_coherent(&ioc->pcidev->dev, sz, in PrimeIocFifos()
4579 &ioc->sense_buf_pool_dma, GFP_KERNEL); in PrimeIocFifos()
4580 if (ioc->sense_buf_pool == NULL) { in PrimeIocFifos()
4582 ioc->name); in PrimeIocFifos()
4586 ioc->sense_buf_low_dma = (u32) (ioc->sense_buf_pool_dma & 0xFFFFFFFF); in PrimeIocFifos()
4587 ioc->alloc_total += sz; in PrimeIocFifos()
4589 ioc->name, ioc->sense_buf_pool, (void *)(ulong)ioc->sense_buf_pool_dma)); in PrimeIocFifos()
4595 alloc_dma = ioc->alloc_dma; in PrimeIocFifos()
4597 ioc->name, ioc->reply_frames, (void *)(ulong)alloc_dma)); in PrimeIocFifos()
4599 for (i = 0; i < ioc->reply_depth; i++) { in PrimeIocFifos()
4601 CHIPREG_WRITE32(&ioc->chip->ReplyFifo, alloc_dma); in PrimeIocFifos()
4602 alloc_dma += ioc->reply_sz; in PrimeIocFifos()
4605 if (dma_mask == DMA_BIT_MASK(35) && !pci_set_dma_mask(ioc->pcidev, in PrimeIocFifos()
4606 ioc->dma_mask) && !pci_set_consistent_dma_mask(ioc->pcidev, in PrimeIocFifos()
4607 ioc->dma_mask)) in PrimeIocFifos()
4609 "restoring 64 bit addressing\n", ioc->name)); in PrimeIocFifos()
4615 if (ioc->alloc != NULL) { in PrimeIocFifos()
4616 sz = ioc->alloc_sz; in PrimeIocFifos()
4617 dma_free_coherent(&ioc->pcidev->dev, sz, ioc->alloc, in PrimeIocFifos()
4618 ioc->alloc_dma); in PrimeIocFifos()
4619 ioc->reply_frames = NULL; in PrimeIocFifos()
4620 ioc->req_frames = NULL; in PrimeIocFifos()
4621 ioc->alloc_total -= sz; in PrimeIocFifos()
4623 if (ioc->sense_buf_pool != NULL) { in PrimeIocFifos()
4624 sz = (ioc->req_depth * MPT_SENSE_BUFFER_ALLOC); in PrimeIocFifos()
4625 dma_free_coherent(&ioc->pcidev->dev, sz, ioc->sense_buf_pool, in PrimeIocFifos()
4626 ioc->sense_buf_pool_dma); in PrimeIocFifos()
4627 ioc->sense_buf_pool = NULL; in PrimeIocFifos()
4630 if (dma_mask == DMA_BIT_MASK(35) && !pci_set_dma_mask(ioc->pcidev, in PrimeIocFifos()
4631 DMA_BIT_MASK(64)) && !pci_set_consistent_dma_mask(ioc->pcidev, in PrimeIocFifos()
4634 "restoring 64 bit addressing\n", ioc->name)); in PrimeIocFifos()
4636 return -1; in PrimeIocFifos()
4639 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
4641 * mpt_handshake_req_reply_wait - Send MPT request to and receive reply
4645 * @req: Pointer to MPT request frame
4651 * NOTES: It is the callers responsibility to byte-swap fields in the
4653 * callers responsibility to byte-swap response fields which are
4656 * Returns 0 for success, non-zero for failure.
4659 mpt_handshake_req_reply_wait(MPT_ADAPTER *ioc, int reqBytes, u32 *req, in mpt_handshake_req_reply_wait() argument
4669 ioc->hs_reply_idx = 0; in mpt_handshake_req_reply_wait()
4670 mptReply = (MPIDefaultReply_t *) ioc->hs_reply; in mpt_handshake_req_reply_wait()
4671 mptReply->MsgLength = 0; in mpt_handshake_req_reply_wait()
4678 CHIPREG_WRITE32(&ioc->chip->IntStatus, 0); in mpt_handshake_req_reply_wait()
4679 CHIPREG_WRITE32(&ioc->chip->Doorbell, in mpt_handshake_req_reply_wait()
4690 ioc->name, reqBytes, t, failcnt ? " - MISSING DOORBELL HANDSHAKE!" : "")); in mpt_handshake_req_reply_wait()
4693 if (!(CHIPREG_READ32(&ioc->chip->Doorbell) & MPI_DOORBELL_ACTIVE)) in mpt_handshake_req_reply_wait()
4694 return -1; in mpt_handshake_req_reply_wait()
4701 CHIPREG_WRITE32(&ioc->chip->IntStatus, 0); in mpt_handshake_req_reply_wait()
4707 u8 *req_as_bytes = (u8 *) req; in mpt_handshake_req_reply_wait()
4719 CHIPREG_WRITE32(&ioc->chip->Doorbell, word); in mpt_handshake_req_reply_wait()
4724 …dhsprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Handshake request frame (@%p) header\n", ioc->name, req)); in mpt_handshake_req_reply_wait()
4725 DBG_DUMP_REQUEST_FRAME_HDR(ioc, (u32 *)req); in mpt_handshake_req_reply_wait()
4728 ioc->name, t, failcnt ? " - MISSING DOORBELL ACK!" : "")); in mpt_handshake_req_reply_wait()
4737 ioc->name, t, failcnt ? " - MISSING DOORBELL REPLY!" : "")); in mpt_handshake_req_reply_wait()
4742 for (ii=0; ii < min(replyBytes/2,mptReply->MsgLength*2); ii++) in mpt_handshake_req_reply_wait()
4743 u16reply[ii] = ioc->hs_reply[ii]; in mpt_handshake_req_reply_wait()
4745 return -99; in mpt_handshake_req_reply_wait()
4748 return -failcnt; in mpt_handshake_req_reply_wait()
4751 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
4753 * WaitForDoorbellAck - Wait for IOC doorbell handshake acknowledge
4774 while (--cntdn) { in WaitForDoorbellAck()
4776 intstat = CHIPREG_READ32(&ioc->chip->IntStatus); in WaitForDoorbellAck()
4782 while (--cntdn) { in WaitForDoorbellAck()
4784 intstat = CHIPREG_READ32(&ioc->chip->IntStatus); in WaitForDoorbellAck()
4793 ioc->name, count)); in WaitForDoorbellAck()
4798 ioc->name, count, intstat); in WaitForDoorbellAck()
4799 return -1; in WaitForDoorbellAck()
4802 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
4804 * WaitForDoorbellInt - Wait for IOC to set its doorbell interrupt bit
4823 while (--cntdn) { in WaitForDoorbellInt()
4824 intstat = CHIPREG_READ32(&ioc->chip->IntStatus); in WaitForDoorbellInt()
4831 while (--cntdn) { in WaitForDoorbellInt()
4832 intstat = CHIPREG_READ32(&ioc->chip->IntStatus); in WaitForDoorbellInt()
4842 ioc->name, count, howlong)); in WaitForDoorbellInt()
4847 ioc->name, count, intstat); in WaitForDoorbellInt()
4848 return -1; in WaitForDoorbellInt()
4851 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
4853 * WaitForDoorbellReply - Wait for and capture an IOC handshake reply.
4870 u16 *hs_reply = ioc->hs_reply; in WaitForDoorbellReply()
4871 volatile MPIDefaultReply_t *mptReply = (MPIDefaultReply_t *) ioc->hs_reply; in WaitForDoorbellReply()
4883 hs_reply[u16cnt++] = le16_to_cpu(CHIPREG_READ32(&ioc->chip->Doorbell) & 0x0000FFFF); in WaitForDoorbellReply()
4884 CHIPREG_WRITE32(&ioc->chip->IntStatus, 0); in WaitForDoorbellReply()
4888 hs_reply[u16cnt++] = le16_to_cpu(CHIPREG_READ32(&ioc->chip->Doorbell) & 0x0000FFFF); in WaitForDoorbellReply()
4889 CHIPREG_WRITE32(&ioc->chip->IntStatus, 0); in WaitForDoorbellReply()
4894 ioc->name, t, le32_to_cpu(*(u32 *)hs_reply), in WaitForDoorbellReply()
4895 failcnt ? " - MISSING DOORBELL HANDSHAKE!" : "")); in WaitForDoorbellReply()
4901 for (u16cnt=2; !failcnt && u16cnt < (2 * mptReply->MsgLength); u16cnt++) { in WaitForDoorbellReply()
4904 hword = le16_to_cpu(CHIPREG_READ32(&ioc->chip->Doorbell) & 0x0000FFFF); in WaitForDoorbellReply()
4906 if (u16cnt < ARRAY_SIZE(ioc->hs_reply)) in WaitForDoorbellReply()
4908 CHIPREG_WRITE32(&ioc->chip->IntStatus, 0); in WaitForDoorbellReply()
4913 CHIPREG_WRITE32(&ioc->chip->IntStatus, 0); in WaitForDoorbellReply()
4917 ioc->name); in WaitForDoorbellReply()
4918 return -failcnt; in WaitForDoorbellReply()
4921 else if (u16cnt != (2 * mptReply->MsgLength)) { in WaitForDoorbellReply()
4922 return -101; in WaitForDoorbellReply()
4924 else if ((mptReply->IOCStatus & MPI_IOCSTATUS_MASK) != MPI_IOCSTATUS_SUCCESS) { in WaitForDoorbellReply()
4925 return -102; in WaitForDoorbellReply()
4929 dhsprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Got Handshake reply:\n", ioc->name)); in WaitForDoorbellReply()
4933 ioc->name, t, u16cnt/2)); in WaitForDoorbellReply()
4937 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
4939 * GetLanConfigPages - Fetch LANConfig pages.
4943 * -ENOMEM if no memory available
4944 * -EPERM if not allowed due to ISR context
4945 * -EAGAIN if no msg frames currently available
4946 * -EFAULT for non-successful reply or no reply (timeout)
4967 cfg.physAddr = -1; in GetLanConfigPages()
4978 ppage0_alloc = (LANPage0_t *) pci_alloc_consistent(ioc->pcidev, data_sz, &page0_dma); in GetLanConfigPages()
4979 rc = -ENOMEM; in GetLanConfigPages()
4988 memcpy(&ioc->lan_cnfg_page0, ppage0_alloc, copy_sz); in GetLanConfigPages()
4992 pci_free_consistent(ioc->pcidev, data_sz, (u8 *) ppage0_alloc, page0_dma); in GetLanConfigPages()
4996 * by byte-swapping all > 1 byte fields! in GetLanConfigPages()
5011 cfg.physAddr = -1; in GetLanConfigPages()
5023 rc = -ENOMEM; in GetLanConfigPages()
5024 ppage1_alloc = (LANPage1_t *) pci_alloc_consistent(ioc->pcidev, data_sz, &page1_dma); in GetLanConfigPages()
5033 memcpy(&ioc->lan_cnfg_page1, ppage1_alloc, copy_sz); in GetLanConfigPages()
5036 pci_free_consistent(ioc->pcidev, data_sz, (u8 *) ppage1_alloc, page1_dma); in GetLanConfigPages()
5040 * by byte-swapping all > 1 byte fields! in GetLanConfigPages()
5048 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
5050 * mptbase_sas_persist_operation - Perform operation on SAS Persistent Table
5062 * Returns 0 for success, non-zero error
5065 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
5076 mutex_lock(&ioc->mptbase_cmds.mutex); in mptbase_sas_persist_operation()
5079 memset(ioc->mptbase_cmds.reply, 0 , MPT_DEFAULT_FRAME_SIZE); in mptbase_sas_persist_operation()
5080 INITIALIZE_MGMT_STATUS(ioc->mptbase_cmds.status) in mptbase_sas_persist_operation()
5090 ret = -1; in mptbase_sas_persist_operation()
5101 ret = -1; in mptbase_sas_persist_operation()
5108 sasIoUnitCntrReq->Function = MPI_FUNCTION_SAS_IO_UNIT_CONTROL; in mptbase_sas_persist_operation()
5109 sasIoUnitCntrReq->MsgContext = mpi_hdr->MsgContext; in mptbase_sas_persist_operation()
5110 sasIoUnitCntrReq->Operation = persist_opcode; in mptbase_sas_persist_operation()
5113 timeleft = wait_for_completion_timeout(&ioc->mptbase_cmds.done, 10*HZ); in mptbase_sas_persist_operation()
5114 if (!(ioc->mptbase_cmds.status & MPT_MGMT_STATUS_COMMAND_GOOD)) { in mptbase_sas_persist_operation()
5115 ret = -ETIME; in mptbase_sas_persist_operation()
5117 if (ioc->mptbase_cmds.status & MPT_MGMT_STATUS_DID_IOCRESET) in mptbase_sas_persist_operation()
5122 ioc->name, __func__, mpt_GetIocState(ioc, 0)); in mptbase_sas_persist_operation()
5129 if (!(ioc->mptbase_cmds.status & MPT_MGMT_STATUS_RF_VALID)) { in mptbase_sas_persist_operation()
5130 ret = -1; in mptbase_sas_persist_operation()
5135 (SasIoUnitControlReply_t *)ioc->mptbase_cmds.reply; in mptbase_sas_persist_operation()
5136 if (le16_to_cpu(sasIoUnitCntrReply->IOCStatus) != MPI_IOCSTATUS_SUCCESS) { in mptbase_sas_persist_operation()
5138 __func__, sasIoUnitCntrReply->IOCStatus, in mptbase_sas_persist_operation()
5139 sasIoUnitCntrReply->IOCLogInfo); in mptbase_sas_persist_operation()
5141 ret = -1; in mptbase_sas_persist_operation()
5146 CLEAR_MGMT_STATUS(ioc->mptbase_cmds.status) in mptbase_sas_persist_operation()
5147 mutex_unlock(&ioc->mptbase_cmds.mutex); in mptbase_sas_persist_operation()
5151 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
5164 volume = pRaidEventData->VolumeID; in mptbase_raid_process_event_data()
5165 reason = pRaidEventData->ReasonCode; in mptbase_raid_process_event_data()
5166 disk = pRaidEventData->PhysDiskNum; in mptbase_raid_process_event_data()
5167 status = le32_to_cpu(pRaidEventData->SettingsStatus); in mptbase_raid_process_event_data()
5179 ioc->name, disk, volume); in mptbase_raid_process_event_data()
5182 ioc->name, volume); in mptbase_raid_process_event_data()
5188 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()
5204 ioc->name, in mptbase_raid_process_event_data()
5222 ioc->name, disk); 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()
5242 ioc->name, in mptbase_raid_process_event_data()
5268 ioc->name, disk); in mptbase_raid_process_event_data()
5273 ioc->name, pRaidEventData->ASC, pRaidEventData->ASCQ); in mptbase_raid_process_event_data()
5278 ioc->name, disk); in mptbase_raid_process_event_data()
5283 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
5285 * GetIoUnitPage2 - Retrieve BIOS version and boot order information.
5289 * -ENOMEM if no memory available
5290 * -EPERM if not allowed due to ISR context
5291 * -EAGAIN if no msg frames currently available
5292 * -EFAULT for non-successful reply or no reply (timeout)
5310 cfg.physAddr = -1; in GetIoUnitPage2()
5324 rc = -ENOMEM; in GetIoUnitPage2()
5325 ppage_alloc = (IOUnitPage2_t *) pci_alloc_consistent(ioc->pcidev, data_sz, &page_dma); in GetIoUnitPage2()
5333 ioc->biosVersion = le32_to_cpu(ppage_alloc->BiosVersion); in GetIoUnitPage2()
5335 pci_free_consistent(ioc->pcidev, data_sz, (u8 *) ppage_alloc, page_dma); in GetIoUnitPage2()
5341 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
5343 * mpt_GetScsiPortSettings - read SCSI Port Page 0 and 2
5347 * Return: -EFAULT if read of config page header fails
5360 * CHECK - what type of locking mechanisms should be used????
5374 if (!ioc->spi_data.nvram) { in mpt_GetScsiPortSettings()
5380 return -EFAULT; in mpt_GetScsiPortSettings()
5382 ioc->spi_data.nvram = (int *) mem; in mpt_GetScsiPortSettings()
5385 ioc->name, ioc->spi_data.nvram, sz)); in mpt_GetScsiPortSettings()
5391 ioc->spi_data.nvram[ii] = MPT_HOST_NVRAM_INVALID; in mpt_GetScsiPortSettings()
5401 cfg.physAddr = -1; in mpt_GetScsiPortSettings()
5407 return -EFAULT; in mpt_GetScsiPortSettings()
5410 pbuf = pci_alloc_consistent(ioc->pcidev, header.PageLength * 4, &buf_dma); in mpt_GetScsiPortSettings()
5415 ioc->spi_data.maxBusWidth = MPT_NARROW; in mpt_GetScsiPortSettings()
5416 ioc->spi_data.maxSyncOffset = 0; in mpt_GetScsiPortSettings()
5417 ioc->spi_data.minSyncFactor = MPT_ASYNC; in mpt_GetScsiPortSettings()
5418 ioc->spi_data.busType = MPT_HOST_BUS_UNKNOWN; in mpt_GetScsiPortSettings()
5422 ioc->name, ioc->spi_data.minSyncFactor)); in mpt_GetScsiPortSettings()
5427 pPP0->Capabilities = le32_to_cpu(pPP0->Capabilities); in mpt_GetScsiPortSettings()
5428 pPP0->PhysicalInterface = le32_to_cpu(pPP0->PhysicalInterface); in mpt_GetScsiPortSettings()
5430 if ( (pPP0->Capabilities & MPI_SCSIPORTPAGE0_CAP_QAS) == 0 ) { in mpt_GetScsiPortSettings()
5431 ioc->spi_data.noQas |= MPT_TARGET_NO_NEGO_QAS; in mpt_GetScsiPortSettings()
5434 ioc->name, pPP0->Capabilities)); in mpt_GetScsiPortSettings()
5436 ioc->spi_data.maxBusWidth = pPP0->Capabilities & MPI_SCSIPORTPAGE0_CAP_WIDE ? 1 : 0; in mpt_GetScsiPortSettings()
5437 data = pPP0->Capabilities & MPI_SCSIPORTPAGE0_CAP_MAX_SYNC_OFFSET_MASK; in mpt_GetScsiPortSettings()
5439 ioc->spi_data.maxSyncOffset = (u8) (data >> 16); in mpt_GetScsiPortSettings()
5440 data = pPP0->Capabilities & MPI_SCSIPORTPAGE0_CAP_MIN_SYNC_PERIOD_MASK; in mpt_GetScsiPortSettings()
5441 ioc->spi_data.minSyncFactor = (u8) (data >> 8); in mpt_GetScsiPortSettings()
5444 ioc->name, ioc->spi_data.minSyncFactor)); in mpt_GetScsiPortSettings()
5446 ioc->spi_data.maxSyncOffset = 0; in mpt_GetScsiPortSettings()
5447 ioc->spi_data.minSyncFactor = MPT_ASYNC; in mpt_GetScsiPortSettings()
5450 ioc->spi_data.busType = pPP0->PhysicalInterface & MPI_SCSIPORTPAGE0_PHY_SIGNAL_TYPE_MASK; in mpt_GetScsiPortSettings()
5454 if ((ioc->spi_data.busType == MPI_SCSIPORTPAGE0_PHY_SIGNAL_HVD) || in mpt_GetScsiPortSettings()
5455 (ioc->spi_data.busType == MPI_SCSIPORTPAGE0_PHY_SIGNAL_SE)) { in mpt_GetScsiPortSettings()
5457 if (ioc->spi_data.minSyncFactor < MPT_ULTRA) { in mpt_GetScsiPortSettings()
5458 ioc->spi_data.minSyncFactor = MPT_ULTRA; in mpt_GetScsiPortSettings()
5461 ioc->name, ioc->spi_data.minSyncFactor)); in mpt_GetScsiPortSettings()
5466 pci_free_consistent(ioc->pcidev, header.PageLength * 4, pbuf, buf_dma); in mpt_GetScsiPortSettings()
5471 /* SCSI Port Page 2 - Read the header then the page. in mpt_GetScsiPortSettings()
5478 cfg.physAddr = -1; in mpt_GetScsiPortSettings()
5483 return -EFAULT; in mpt_GetScsiPortSettings()
5488 pbuf = pci_alloc_consistent(ioc->pcidev, header.PageLength * 4, &buf_dma); in mpt_GetScsiPortSettings()
5496 } else if (ioc->pcidev->vendor == PCI_VENDOR_ID_ATTO) { in mpt_GetScsiPortSettings()
5508 pdevice = &pPP2->DeviceSettings[ii]; in mpt_GetScsiPortSettings()
5509 ATTOFlags = le16_to_cpu(pdevice->ATTOFlags); in mpt_GetScsiPortSettings()
5525 data = (data << 16) | (pdevice->Period << 8) | 10; in mpt_GetScsiPortSettings()
5526 ioc->spi_data.nvram[ii] = data; in mpt_GetScsiPortSettings()
5535 ioc->spi_data.bus_reset = in mpt_GetScsiPortSettings()
5536 (le32_to_cpu(pPP2->PortFlags) & in mpt_GetScsiPortSettings()
5543 data = le32_to_cpu(pPP2->PortFlags) & MPI_SCSIPORTPAGE2_PORT_FLAGS_DV_MASK; in mpt_GetScsiPortSettings()
5544 ioc->spi_data.PortFlags = data; in mpt_GetScsiPortSettings()
5546 pdevice = &pPP2->DeviceSettings[ii]; in mpt_GetScsiPortSettings()
5547 data = (le16_to_cpu(pdevice->DeviceFlags) << 16) | in mpt_GetScsiPortSettings()
5548 (pdevice->SyncFactor << 8) | pdevice->Timeout; in mpt_GetScsiPortSettings()
5549 ioc->spi_data.nvram[ii] = data; in mpt_GetScsiPortSettings()
5553 pci_free_consistent(ioc->pcidev, header.PageLength * 4, pbuf, buf_dma); in mpt_GetScsiPortSettings()
5565 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
5567 * mpt_readScsiDevicePageHeaders - save version and length of SDP1
5571 * Return: -EFAULT if read of config page header fails
5587 cfg.physAddr = -1; in mpt_readScsiDevicePageHeaders()
5593 return -EFAULT; in mpt_readScsiDevicePageHeaders()
5595 ioc->spi_data.sdp1version = cfg.cfghdr.hdr->PageVersion; in mpt_readScsiDevicePageHeaders()
5596 ioc->spi_data.sdp1length = cfg.cfghdr.hdr->PageLength; in mpt_readScsiDevicePageHeaders()
5603 return -EFAULT; in mpt_readScsiDevicePageHeaders()
5605 ioc->spi_data.sdp0version = cfg.cfghdr.hdr->PageVersion; in mpt_readScsiDevicePageHeaders()
5606 ioc->spi_data.sdp0length = cfg.cfghdr.hdr->PageLength; in mpt_readScsiDevicePageHeaders()
5609 ioc->name, ioc->spi_data.sdp0version, ioc->spi_data.sdp0length)); in mpt_readScsiDevicePageHeaders()
5612 ioc->name, ioc->spi_data.sdp1version, ioc->spi_data.sdp1length)); in mpt_readScsiDevicePageHeaders()
5617 * mpt_inactive_raid_list_free - This clears this link list.
5625 if (list_empty(&ioc->raid_data.inactive_list)) in mpt_inactive_raid_list_free()
5628 mutex_lock(&ioc->raid_data.inactive_list_mutex); in mpt_inactive_raid_list_free()
5630 &ioc->raid_data.inactive_list, list) { in mpt_inactive_raid_list_free()
5631 list_del(&component_info->list); in mpt_inactive_raid_list_free()
5634 mutex_unlock(&ioc->raid_data.inactive_list_mutex); in mpt_inactive_raid_list_free()
5638 …* mpt_inactive_raid_volumes - sets up link list of phy_disk_nums for devices belonging in an inact…
5669 buffer = pci_alloc_consistent(ioc->pcidev, hdr.PageLength * 4, in mpt_inactive_raid_volumes()
5681 if (!buffer->NumPhysDisks) in mpt_inactive_raid_volumes()
5685 (buffer->VolumeStatus.Flags & MPI_RAIDVOL0_STATUS_FLAG_VOLUME_INACTIVE || in mpt_inactive_raid_volumes()
5686 (buffer->VolumeStatus.Flags & MPI_RAIDVOL0_STATUS_FLAG_ENABLED) == 0 || in mpt_inactive_raid_volumes()
5687 buffer->VolumeStatus.State == MPI_RAIDVOL0_STATUS_STATE_FAILED || in mpt_inactive_raid_volumes()
5688 buffer->VolumeStatus.State == MPI_RAIDVOL0_STATUS_STATE_MISSING) ? 1 : 0; in mpt_inactive_raid_volumes()
5693 mutex_lock(&ioc->raid_data.inactive_list_mutex); in mpt_inactive_raid_volumes()
5694 for (i = 0; i < buffer->NumPhysDisks; i++) { in mpt_inactive_raid_volumes()
5696 buffer->PhysDisk[i].PhysDiskNum, &phys_disk) != 0) in mpt_inactive_raid_volumes()
5703 component_info->volumeID = id; in mpt_inactive_raid_volumes()
5704 component_info->volumeBus = channel; in mpt_inactive_raid_volumes()
5705 component_info->d.PhysDiskNum = phys_disk.PhysDiskNum; in mpt_inactive_raid_volumes()
5706 component_info->d.PhysDiskBus = phys_disk.PhysDiskBus; in mpt_inactive_raid_volumes()
5707 component_info->d.PhysDiskID = phys_disk.PhysDiskID; in mpt_inactive_raid_volumes()
5708 component_info->d.PhysDiskIOC = phys_disk.PhysDiskIOC; in mpt_inactive_raid_volumes()
5710 list_add_tail(&component_info->list, in mpt_inactive_raid_volumes()
5711 &ioc->raid_data.inactive_list); in mpt_inactive_raid_volumes()
5713 mutex_unlock(&ioc->raid_data.inactive_list_mutex); in mpt_inactive_raid_volumes()
5717 pci_free_consistent(ioc->pcidev, hdr.PageLength * 4, buffer, in mpt_inactive_raid_volumes()
5722 * mpt_raid_phys_disk_pg0 - returns phys disk page zero
5729 * -EFAULT if read of config page header fails or data pointer not NULL
5730 * -ENOMEM if pci_alloc failed
5749 cfg.physAddr = -1; in mpt_raid_phys_disk_pg0()
5753 rc = -EFAULT; in mpt_raid_phys_disk_pg0()
5758 rc = -EFAULT; in mpt_raid_phys_disk_pg0()
5762 buffer = pci_alloc_consistent(ioc->pcidev, hdr.PageLength * 4, in mpt_raid_phys_disk_pg0()
5766 rc = -ENOMEM; in mpt_raid_phys_disk_pg0()
5775 rc = -EFAULT; in mpt_raid_phys_disk_pg0()
5781 phys_disk->MaxLBA = le32_to_cpu(buffer->MaxLBA); in mpt_raid_phys_disk_pg0()
5786 pci_free_consistent(ioc->pcidev, hdr.PageLength * 4, buffer, in mpt_raid_phys_disk_pg0()
5793 * mpt_raid_phys_disk_get_num_paths - returns number paths associated to this phys_num
5816 cfg.physAddr = -1; in mpt_raid_phys_disk_get_num_paths()
5829 buffer = pci_alloc_consistent(ioc->pcidev, hdr.PageLength * 4, in mpt_raid_phys_disk_get_num_paths()
5846 rc = buffer->NumPhysDiskPaths; in mpt_raid_phys_disk_get_num_paths()
5850 pci_free_consistent(ioc->pcidev, hdr.PageLength * 4, buffer, in mpt_raid_phys_disk_get_num_paths()
5858 * mpt_raid_phys_disk_pg1 - returns phys disk page 1
5865 * -EFAULT if read of config page header fails or data pointer not NULL
5866 * -ENOMEM if pci_alloc failed
5888 cfg.physAddr = -1; in mpt_raid_phys_disk_pg1()
5892 rc = -EFAULT; in mpt_raid_phys_disk_pg1()
5897 rc = -EFAULT; in mpt_raid_phys_disk_pg1()
5901 buffer = pci_alloc_consistent(ioc->pcidev, hdr.PageLength * 4, in mpt_raid_phys_disk_pg1()
5905 rc = -ENOMEM; in mpt_raid_phys_disk_pg1()
5914 rc = -EFAULT; in mpt_raid_phys_disk_pg1()
5918 phys_disk->NumPhysDiskPaths = buffer->NumPhysDiskPaths; in mpt_raid_phys_disk_pg1()
5919 phys_disk->PhysDiskNum = phys_disk_num; in mpt_raid_phys_disk_pg1()
5920 for (i = 0; i < phys_disk->NumPhysDiskPaths; i++) { in mpt_raid_phys_disk_pg1()
5921 phys_disk->Path[i].PhysDiskID = buffer->Path[i].PhysDiskID; in mpt_raid_phys_disk_pg1()
5922 phys_disk->Path[i].PhysDiskBus = buffer->Path[i].PhysDiskBus; in mpt_raid_phys_disk_pg1()
5923 phys_disk->Path[i].OwnerIdentifier = in mpt_raid_phys_disk_pg1()
5924 buffer->Path[i].OwnerIdentifier; in mpt_raid_phys_disk_pg1()
5925 phys_disk->Path[i].Flags = le16_to_cpu(buffer->Path[i].Flags); in mpt_raid_phys_disk_pg1()
5926 memcpy(&sas_address, &buffer->Path[i].WWID, sizeof(__le64)); in mpt_raid_phys_disk_pg1()
5928 memcpy(&phys_disk->Path[i].WWID, &sas_address, sizeof(__le64)); in mpt_raid_phys_disk_pg1()
5930 &buffer->Path[i].OwnerWWID, sizeof(__le64)); in mpt_raid_phys_disk_pg1()
5932 memcpy(&phys_disk->Path[i].OwnerWWID, in mpt_raid_phys_disk_pg1()
5939 pci_free_consistent(ioc->pcidev, hdr.PageLength * 4, buffer, in mpt_raid_phys_disk_pg1()
5948 * mpt_findImVolumes - Identify IDs of hidden disks and RAID Volumes
5953 * -EFAULT if read of config page header fails or data pointer not NULL
5954 * -ENOMEM if pci_alloc failed
5968 if (!ioc->ir_firmware) in mpt_findImVolumes()
5973 kfree(ioc->raid_data.pIocPg2); in mpt_findImVolumes()
5974 ioc->raid_data.pIocPg2 = NULL; in mpt_findImVolumes()
5984 cfg.physAddr = -1; in mpt_findImVolumes()
5990 return -EFAULT; in mpt_findImVolumes()
5993 return -EFAULT; in mpt_findImVolumes()
5996 pIoc2 = pci_alloc_consistent(ioc->pcidev, iocpage2sz, &ioc2_dma); in mpt_findImVolumes()
5998 return -ENOMEM; in mpt_findImVolumes()
6007 rc = -ENOMEM; in mpt_findImVolumes()
6011 ioc->raid_data.pIocPg2 = (IOCPage2_t *) mem; in mpt_findImVolumes()
6015 for (i = 0; i < pIoc2->NumActiveVolumes ; i++) in mpt_findImVolumes()
6017 pIoc2->RaidVolume[i].VolumeBus, in mpt_findImVolumes()
6018 pIoc2->RaidVolume[i].VolumeID); in mpt_findImVolumes()
6021 pci_free_consistent(ioc->pcidev, iocpage2sz, pIoc2, ioc2_dma); in mpt_findImVolumes()
6038 kfree(ioc->raid_data.pIocPg3); in mpt_read_ioc_pg_3()
6039 ioc->raid_data.pIocPg3 = NULL; in mpt_read_ioc_pg_3()
6049 cfg.physAddr = -1; in mpt_read_ioc_pg_3()
6063 pIoc3 = pci_alloc_consistent(ioc->pcidev, iocpage3sz, &ioc3_dma); in mpt_read_ioc_pg_3()
6076 ioc->raid_data.pIocPg3 = (IOCPage3_t *) mem; in mpt_read_ioc_pg_3()
6080 pci_free_consistent(ioc->pcidev, iocpage3sz, pIoc3, ioc3_dma); in mpt_read_ioc_pg_3()
6101 cfg.physAddr = -1; in mpt_read_ioc_pg_4()
6112 if ( (pIoc4 = ioc->spi_data.pIocPg4) == NULL ) { in mpt_read_ioc_pg_4()
6114 pIoc4 = pci_alloc_consistent(ioc->pcidev, iocpage4sz, &ioc4_dma); in mpt_read_ioc_pg_4()
6117 ioc->alloc_total += iocpage4sz; in mpt_read_ioc_pg_4()
6119 ioc4_dma = ioc->spi_data.IocPg4_dma; in mpt_read_ioc_pg_4()
6120 iocpage4sz = ioc->spi_data.IocPg4Sz; in mpt_read_ioc_pg_4()
6128 ioc->spi_data.pIocPg4 = (IOCPage4_t *) pIoc4; in mpt_read_ioc_pg_4()
6129 ioc->spi_data.IocPg4_dma = ioc4_dma; in mpt_read_ioc_pg_4()
6130 ioc->spi_data.IocPg4Sz = iocpage4sz; in mpt_read_ioc_pg_4()
6132 pci_free_consistent(ioc->pcidev, iocpage4sz, pIoc4, ioc4_dma); in mpt_read_ioc_pg_4()
6133 ioc->spi_data.pIocPg4 = NULL; in mpt_read_ioc_pg_4()
6134 ioc->alloc_total -= iocpage4sz; in mpt_read_ioc_pg_4()
6155 cfg.physAddr = -1; in mpt_read_ioc_pg_1()
6169 pIoc1 = pci_alloc_consistent(ioc->pcidev, iocpage1sz, &ioc1_dma); in mpt_read_ioc_pg_1()
6179 tmp = le32_to_cpu(pIoc1->Flags) & MPI_IOCPAGE1_REPLY_COALESCING; in mpt_read_ioc_pg_1()
6181 tmp = le32_to_cpu(pIoc1->CoalescingTimeout); in mpt_read_ioc_pg_1()
6184 ioc->name, tmp)); in mpt_read_ioc_pg_1()
6187 pIoc1->CoalescingTimeout = cpu_to_le32(MPT_COALESCING_TIMEOUT); in mpt_read_ioc_pg_1()
6195 ioc->name, MPT_COALESCING_TIMEOUT)); in mpt_read_ioc_pg_1()
6201 ioc->name, MPT_COALESCING_TIMEOUT)); in mpt_read_ioc_pg_1()
6205 ioc->name)); in mpt_read_ioc_pg_1()
6211 ioc->name)); in mpt_read_ioc_pg_1()
6216 dprintk(ioc, printk(MYIOC_s_WARN_FMT "Coalescing Disabled\n", ioc->name)); in mpt_read_ioc_pg_1()
6220 pci_free_consistent(ioc->pcidev, iocpage1sz, pIoc1, ioc1_dma); in mpt_read_ioc_pg_1()
6238 cfg.physAddr = -1; in mpt_get_manufacturing_pg_0()
6245 if (!cfg.cfghdr.hdr->PageLength) in mpt_get_manufacturing_pg_0()
6249 pbuf = pci_alloc_consistent(ioc->pcidev, hdr.PageLength * 4, &buf_dma); in mpt_get_manufacturing_pg_0()
6258 memcpy(ioc->board_name, pbuf->BoardName, sizeof(ioc->board_name)); in mpt_get_manufacturing_pg_0()
6259 memcpy(ioc->board_assembly, pbuf->BoardAssembly, sizeof(ioc->board_assembly)); in mpt_get_manufacturing_pg_0()
6260 memcpy(ioc->board_tracer, pbuf->BoardTracerNumber, sizeof(ioc->board_tracer)); in mpt_get_manufacturing_pg_0()
6265 pci_free_consistent(ioc->pcidev, hdr.PageLength * 4, pbuf, buf_dma); in mpt_get_manufacturing_pg_0()
6268 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
6270 * SendEventNotification - Send EventNotification (on or off) request to adapter
6290 ioc->name, EvSwitch, &evn)); in SendEventNotification()
6297 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
6299 * SendEventAck - Send EventAck request to MPT adapter.
6310 ioc->name, __func__)); in SendEventAck()
6311 return -1; in SendEventAck()
6314 devtverboseprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Sending EventAck\n", ioc->name)); in SendEventAck()
6316 pAck->Function = MPI_FUNCTION_EVENT_ACK; in SendEventAck()
6317 pAck->ChainOffset = 0; in SendEventAck()
6318 pAck->Reserved[0] = pAck->Reserved[1] = 0; in SendEventAck()
6319 pAck->MsgFlags = 0; in SendEventAck()
6320 pAck->Reserved1[0] = pAck->Reserved1[1] = pAck->Reserved1[2] = 0; in SendEventAck()
6321 pAck->Event = evnp->Event; in SendEventAck()
6322 pAck->EventContext = evnp->EventContext; in SendEventAck()
6329 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
6331 * mpt_config - Generic function to issue config message
6339 * -EPERM if not allowed due to ISR context
6340 * -EAGAIN if no msg frames currently available
6341 * -EFAULT for non-successful reply or no reply (timeout)
6367 ioc->name)); in mpt_config()
6368 return -EPERM; in mpt_config()
6372 spin_lock_irqsave(&ioc->taskmgmt_lock, flags); in mpt_config()
6373 if (ioc->ioc_reset_in_progress) { in mpt_config()
6375 "%s: busy with host reset\n", ioc->name, __func__)); in mpt_config()
6376 spin_unlock_irqrestore(&ioc->taskmgmt_lock, flags); in mpt_config()
6377 return -EBUSY; in mpt_config()
6379 spin_unlock_irqrestore(&ioc->taskmgmt_lock, flags); in mpt_config()
6382 if (!ioc->active || in mpt_config()
6386 ioc->name, __func__, ioc->active, in mpt_config()
6388 return -EFAULT; in mpt_config()
6392 mutex_lock(&ioc->mptbase_cmds.mutex); in mpt_config()
6394 memset(ioc->mptbase_cmds.reply, 0 , MPT_DEFAULT_FRAME_SIZE); in mpt_config()
6395 INITIALIZE_MGMT_STATUS(ioc->mptbase_cmds.status) in mpt_config()
6401 "mpt_config: no msg frames!\n", ioc->name)); in mpt_config()
6402 ret = -EAGAIN; in mpt_config()
6407 pReq->Action = pCfg->action; in mpt_config()
6408 pReq->Reserved = 0; in mpt_config()
6409 pReq->ChainOffset = 0; in mpt_config()
6410 pReq->Function = MPI_FUNCTION_CONFIG; in mpt_config()
6413 pReq->ExtPageLength = 0; in mpt_config()
6414 pReq->ExtPageType = 0; in mpt_config()
6415 pReq->MsgFlags = 0; in mpt_config()
6418 pReq->Reserved2[ii] = 0; in mpt_config()
6420 pReq->Header.PageVersion = pCfg->cfghdr.hdr->PageVersion; in mpt_config()
6421 pReq->Header.PageLength = pCfg->cfghdr.hdr->PageLength; in mpt_config()
6422 pReq->Header.PageNumber = pCfg->cfghdr.hdr->PageNumber; in mpt_config()
6423 pReq->Header.PageType = (pCfg->cfghdr.hdr->PageType & MPI_CONFIG_PAGETYPE_MASK); in mpt_config()
6425 if ((pCfg->cfghdr.hdr->PageType & MPI_CONFIG_PAGETYPE_MASK) == MPI_CONFIG_PAGETYPE_EXTENDED) { in mpt_config()
6426 pExtHdr = (ConfigExtendedPageHeader_t *)pCfg->cfghdr.ehdr; in mpt_config()
6427 pReq->ExtPageLength = cpu_to_le16(pExtHdr->ExtPageLength); in mpt_config()
6428 pReq->ExtPageType = pExtHdr->ExtPageType; in mpt_config()
6429 pReq->Header.PageType = MPI_CONFIG_PAGETYPE_EXTENDED; in mpt_config()
6434 pReq->Header.PageLength = 0; in mpt_config()
6437 pReq->PageAddress = cpu_to_le32(pCfg->pageAddr); in mpt_config()
6441 if (pCfg->dir) in mpt_config()
6446 if ((pCfg->cfghdr.hdr->PageType & MPI_CONFIG_PAGETYPE_MASK) == in mpt_config()
6448 flagsLength |= pExtHdr->ExtPageLength * 4; in mpt_config()
6449 page_type = pReq->ExtPageType; in mpt_config()
6452 flagsLength |= pCfg->cfghdr.hdr->PageLength * 4; in mpt_config()
6453 page_type = pReq->Header.PageType; in mpt_config()
6459 ioc->name, page_type, pReq->Header.PageNumber, pReq->Action)); in mpt_config()
6461 ioc->add_sge((char *)&pReq->PageBufferSGE, flagsLength, pCfg->physAddr); in mpt_config()
6462 timeout = (pCfg->timeout < 15) ? HZ*15 : HZ*pCfg->timeout; in mpt_config()
6464 timeleft = wait_for_completion_timeout(&ioc->mptbase_cmds.done, in mpt_config()
6466 if (!(ioc->mptbase_cmds.status & MPT_MGMT_STATUS_COMMAND_GOOD)) { in mpt_config()
6467 ret = -ETIME; in mpt_config()
6471 ioc->name, page_type, pReq->Header.PageNumber, in mpt_config()
6472 pReq->Action, ioc->mptbase_cmds.status, timeleft)); in mpt_config()
6473 if (ioc->mptbase_cmds.status & MPT_MGMT_STATUS_DID_IOCRESET) in mpt_config()
6476 spin_lock_irqsave(&ioc->taskmgmt_lock, flags); in mpt_config()
6477 if (ioc->ioc_reset_in_progress) { in mpt_config()
6478 spin_unlock_irqrestore(&ioc->taskmgmt_lock, in mpt_config()
6482 __func__, ioc->name); in mpt_config()
6483 mutex_unlock(&ioc->mptbase_cmds.mutex); in mpt_config()
6484 return -EFAULT; in mpt_config()
6486 spin_unlock_irqrestore(&ioc->taskmgmt_lock, flags); in mpt_config()
6492 if (!(ioc->mptbase_cmds.status & MPT_MGMT_STATUS_RF_VALID)) { in mpt_config()
6493 ret = -1; in mpt_config()
6496 pReply = (ConfigReply_t *)ioc->mptbase_cmds.reply; in mpt_config()
6497 ret = le16_to_cpu(pReply->IOCStatus) & MPI_IOCSTATUS_MASK; in mpt_config()
6500 pCfg->cfghdr.ehdr->ExtPageLength = in mpt_config()
6501 le16_to_cpu(pReply->ExtPageLength); in mpt_config()
6502 pCfg->cfghdr.ehdr->ExtPageType = in mpt_config()
6503 pReply->ExtPageType; in mpt_config()
6505 pCfg->cfghdr.hdr->PageVersion = pReply->Header.PageVersion; in mpt_config()
6506 pCfg->cfghdr.hdr->PageLength = pReply->Header.PageLength; in mpt_config()
6507 pCfg->cfghdr.hdr->PageNumber = pReply->Header.PageNumber; in mpt_config()
6508 pCfg->cfghdr.hdr->PageType = pReply->Header.PageType; in mpt_config()
6515 ioc->name, ret, timeleft); in mpt_config()
6518 ret, le32_to_cpu(pReply->IOCLogInfo))); in mpt_config()
6522 CLEAR_MGMT_STATUS(ioc->mptbase_cmds.status) in mpt_config()
6523 mutex_unlock(&ioc->mptbase_cmds.mutex); in mpt_config()
6528 ioc->name, __func__, mpt_GetIocState(ioc, 0)); in mpt_config()
6541 " action %d\n", ioc->name, page_type, in mpt_config()
6542 pCfg->cfghdr.hdr->PageNumber, pCfg->action); in mpt_config()
6551 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
6553 * mpt_ioc_reset - Base cleanup for hard reset
6555 * @reset_phase: Indicates pre- or post-reset functionality
6564 ioc->taskmgmt_quiesce_io = 1; in mpt_ioc_reset()
6566 "%s: MPT_IOC_SETUP_RESET\n", ioc->name, __func__)); in mpt_ioc_reset()
6570 "%s: MPT_IOC_PRE_RESET\n", ioc->name, __func__)); in mpt_ioc_reset()
6574 "%s: MPT_IOC_POST_RESET\n", ioc->name, __func__)); in mpt_ioc_reset()
6576 if (ioc->mptbase_cmds.status & MPT_MGMT_STATUS_PENDING) { in mpt_ioc_reset()
6577 ioc->mptbase_cmds.status |= in mpt_ioc_reset()
6579 complete(&ioc->mptbase_cmds.done); in mpt_ioc_reset()
6582 if (ioc->taskmgmt_cmds.status & MPT_MGMT_STATUS_PENDING) { in mpt_ioc_reset()
6583 ioc->taskmgmt_cmds.status |= in mpt_ioc_reset()
6585 complete(&ioc->taskmgmt_cmds.done); in mpt_ioc_reset()
6597 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
6601 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
6603 * procmpt_create - Create %MPT_PROCFS_MPTBASEDIR entries.
6605 * Returns 0 for success, non-zero for failure.
6612 return -ENOTDIR; in procmpt_create()
6621 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
6623 * procmpt_destroy - Tear down %MPT_PROCFS_MPTBASEDIR entries.
6625 * Returns 0 for success, non-zero for failure.
6635 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
6643 MPT_ADAPTER *ioc = m->private; in mpt_summary_proc_show()
6662 seq_printf(m, "%s-%s\n", "mptlinux", MPT_LINUX_VERSION_COMMON); in mpt_version_proc_show()
6666 for (cb_idx = MPT_MAX_PROTOCOL_DRIVERS-1; cb_idx; cb_idx--) { in mpt_version_proc_show()
6700 MPT_ADAPTER *ioc = m->private; in mpt_iocinfo_proc_show()
6707 seq_printf(m, "%s:", ioc->name); in mpt_iocinfo_proc_show()
6708 if (ioc->facts.Flags & MPI_IOCFACTS_FLAGS_FW_DOWNLOAD_BOOT) in mpt_iocinfo_proc_show()
6710 // if (ioc->facts.IOCExceptions & MPI_IOCFACTS_EXCEPT_CONFIG_CHECKSUM_FAIL) in mpt_iocinfo_proc_show()
6714 ioc->facts.ProductID, in mpt_iocinfo_proc_show()
6715 ioc->prod_name); in mpt_iocinfo_proc_show()
6716 seq_printf(m, " FWVersion = 0x%08x%s", ioc->facts.FWVersion.Word, expVer); in mpt_iocinfo_proc_show()
6717 if (ioc->facts.FWImageSize) in mpt_iocinfo_proc_show()
6718 seq_printf(m, " (fw_size=%d)", ioc->facts.FWImageSize); in mpt_iocinfo_proc_show()
6719 seq_printf(m, "\n MsgVersion = 0x%04x\n", ioc->facts.MsgVersion); in mpt_iocinfo_proc_show()
6720 seq_printf(m, " FirstWhoInit = 0x%02x\n", ioc->FirstWhoInit); in mpt_iocinfo_proc_show()
6721 seq_printf(m, " EventState = 0x%02x\n", ioc->facts.EventState); in mpt_iocinfo_proc_show()
6724 ioc->facts.CurrentHostMfaHighAddr); in mpt_iocinfo_proc_show()
6726 ioc->facts.CurrentSenseBufferHighAddr); in mpt_iocinfo_proc_show()
6728 seq_printf(m, " MaxChainDepth = 0x%02x frames\n", ioc->facts.MaxChainDepth); in mpt_iocinfo_proc_show()
6729 seq_printf(m, " MinBlockSize = 0x%02x bytes\n", 4*ioc->facts.BlockSize); in mpt_iocinfo_proc_show()
6732 (void *)ioc->req_frames, (void *)(ulong)ioc->req_frames_dma); in mpt_iocinfo_proc_show()
6734 * Rounding UP to nearest 4-kB boundary here... in mpt_iocinfo_proc_show()
6736 sz = (ioc->req_sz * ioc->req_depth) + 128; in mpt_iocinfo_proc_show()
6737 sz = ((sz + 0x1000UL - 1UL) / 0x1000) * 0x1000; in mpt_iocinfo_proc_show()
6739 ioc->req_sz, ioc->req_depth, ioc->req_sz*ioc->req_depth, sz); in mpt_iocinfo_proc_show()
6741 4*ioc->facts.RequestFrameSize, in mpt_iocinfo_proc_show()
6742 ioc->facts.GlobalCredits); in mpt_iocinfo_proc_show()
6745 (void *)ioc->alloc, (void *)(ulong)ioc->alloc_dma); in mpt_iocinfo_proc_show()
6746 sz = (ioc->reply_sz * ioc->reply_depth) + 128; in mpt_iocinfo_proc_show()
6748 ioc->reply_sz, ioc->reply_depth, ioc->reply_sz*ioc->reply_depth, sz); in mpt_iocinfo_proc_show()
6750 ioc->facts.CurReplyFrameSize, in mpt_iocinfo_proc_show()
6751 ioc->facts.ReplyQueueDepth); in mpt_iocinfo_proc_show()
6754 (ioc->facts.MaxDevices==0) ? 255 : ioc->facts.MaxDevices); in mpt_iocinfo_proc_show()
6755 seq_printf(m, " MaxBuses = %d\n", ioc->facts.MaxBuses); in mpt_iocinfo_proc_show()
6757 /* per-port info */ in mpt_iocinfo_proc_show()
6758 for (p=0; p < ioc->facts.NumberOfPorts; p++) { in mpt_iocinfo_proc_show()
6761 ioc->facts.NumberOfPorts); in mpt_iocinfo_proc_show()
6762 if (ioc->bus_type == FC) { in mpt_iocinfo_proc_show()
6763 if (ioc->pfacts[p].ProtocolFlags & MPI_PORTFACTS_PROTOCOL_LAN) { in mpt_iocinfo_proc_show()
6764 u8 *a = (u8*)&ioc->lan_cnfg_page1.HardwareAddressLow; in mpt_iocinfo_proc_show()
6768 ioc->fc_port_page0[p].WWNN.High, in mpt_iocinfo_proc_show()
6769 ioc->fc_port_page0[p].WWNN.Low, in mpt_iocinfo_proc_show()
6770 ioc->fc_port_page0[p].WWPN.High, in mpt_iocinfo_proc_show()
6771 ioc->fc_port_page0[p].WWPN.Low); in mpt_iocinfo_proc_show()
6779 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
6784 if ((ioc->facts.FWVersion.Word >> 24) == 0x0E) { in mpt_get_fw_exp_ver()
6786 (ioc->facts.FWVersion.Word >> 16) & 0x00FF, /* Month */ in mpt_get_fw_exp_ver()
6787 (ioc->facts.FWVersion.Word >> 8) & 0x1F); /* Day */ in mpt_get_fw_exp_ver()
6790 if ((ioc->facts.FWVersion.Word >> 8) & 0x80) in mpt_get_fw_exp_ver()
6795 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
6797 * mpt_print_ioc_summary - Write ASCII summary of IOC to a buffer.
6819 ioc->name, in mpt_print_ioc_summary()
6820 ioc->prod_name, in mpt_print_ioc_summary()
6822 ioc->facts.FWVersion.Word, in mpt_print_ioc_summary()
6824 ioc->facts.NumberOfPorts, in mpt_print_ioc_summary()
6825 ioc->req_depth); in mpt_print_ioc_summary()
6827 if (showlan && (ioc->pfacts[0].ProtocolFlags & MPI_PORTFACTS_PROTOCOL_LAN)) { in mpt_print_ioc_summary()
6828 u8 *a = (u8*)&ioc->lan_cnfg_page1.HardwareAddressLow; in mpt_print_ioc_summary()
6832 y += sprintf(buffer+len+y, ", IRQ=%d", ioc->pci_irq); in mpt_print_ioc_summary()
6834 if (!ioc->active) in mpt_print_ioc_summary()
6853 ioc->name, in seq_mpt_print_ioc_summary()
6854 ioc->prod_name, in seq_mpt_print_ioc_summary()
6856 ioc->facts.FWVersion.Word, in seq_mpt_print_ioc_summary()
6858 ioc->facts.NumberOfPorts, in seq_mpt_print_ioc_summary()
6859 ioc->req_depth); in seq_mpt_print_ioc_summary()
6861 if (showlan && (ioc->pfacts[0].ProtocolFlags & MPI_PORTFACTS_PROTOCOL_LAN)) { in seq_mpt_print_ioc_summary()
6862 u8 *a = (u8*)&ioc->lan_cnfg_page1.HardwareAddressLow; in seq_mpt_print_ioc_summary()
6866 seq_printf(m, ", IRQ=%d", ioc->pci_irq); in seq_mpt_print_ioc_summary()
6868 if (!ioc->active) in seq_mpt_print_ioc_summary()
6876 * mpt_set_taskmgmt_in_progress_flag - set flags associated with task management
6879 * Returns 0 for SUCCESS or -1 if FAILED.
6881 * If -1 is return, then it was not possible to set the flags
6889 spin_lock_irqsave(&ioc->taskmgmt_lock, flags); in mpt_set_taskmgmt_in_progress_flag()
6890 if (ioc->ioc_reset_in_progress || ioc->taskmgmt_in_progress || in mpt_set_taskmgmt_in_progress_flag()
6891 (ioc->alt_ioc && ioc->alt_ioc->taskmgmt_in_progress)) { in mpt_set_taskmgmt_in_progress_flag()
6892 retval = -1; in mpt_set_taskmgmt_in_progress_flag()
6896 ioc->taskmgmt_in_progress = 1; in mpt_set_taskmgmt_in_progress_flag()
6897 ioc->taskmgmt_quiesce_io = 1; in mpt_set_taskmgmt_in_progress_flag()
6898 if (ioc->alt_ioc) { in mpt_set_taskmgmt_in_progress_flag()
6899 ioc->alt_ioc->taskmgmt_in_progress = 1; in mpt_set_taskmgmt_in_progress_flag()
6900 ioc->alt_ioc->taskmgmt_quiesce_io = 1; in mpt_set_taskmgmt_in_progress_flag()
6903 spin_unlock_irqrestore(&ioc->taskmgmt_lock, flags); in mpt_set_taskmgmt_in_progress_flag()
6909 * mpt_clear_taskmgmt_in_progress_flag - clear flags associated with task management
6918 spin_lock_irqsave(&ioc->taskmgmt_lock, flags); in mpt_clear_taskmgmt_in_progress_flag()
6919 ioc->taskmgmt_in_progress = 0; in mpt_clear_taskmgmt_in_progress_flag()
6920 ioc->taskmgmt_quiesce_io = 0; in mpt_clear_taskmgmt_in_progress_flag()
6921 if (ioc->alt_ioc) { in mpt_clear_taskmgmt_in_progress_flag()
6922 ioc->alt_ioc->taskmgmt_in_progress = 0; in mpt_clear_taskmgmt_in_progress_flag()
6923 ioc->alt_ioc->taskmgmt_quiesce_io = 0; in mpt_clear_taskmgmt_in_progress_flag()
6925 spin_unlock_irqrestore(&ioc->taskmgmt_lock, flags); in mpt_clear_taskmgmt_in_progress_flag()
6931 * mpt_halt_firmware - Halts the firmware if it is operational and panic
6945 ioc->name, ioc_raw_state & MPI_DOORBELL_DATA_MASK); in mpt_halt_firmware()
6946 panic("%s: IOC Fault (%04xh)!!!\n", ioc->name, in mpt_halt_firmware()
6949 CHIPREG_WRITE32(&ioc->chip->Doorbell, 0xC0FFEE00); in mpt_halt_firmware()
6951 ioc->name); in mpt_halt_firmware()
6957 * mpt_SoftResetHandler - Issues a less expensive reset
6961 * Returns 0 for SUCCESS or -1 if FAILED.
6963 * Message Unit Reset - instructs the IOC to reset the Reply Post and
6980 ioc->name)); in mpt_SoftResetHandler()
6990 "skipping, either in FAULT or RESET state!\n", ioc->name)); in mpt_SoftResetHandler()
6991 return -1; in mpt_SoftResetHandler()
6994 if (ioc->bus_type == FC) { in mpt_SoftResetHandler()
6996 "skipping, because the bus type is FC!\n", ioc->name)); in mpt_SoftResetHandler()
6997 return -1; in mpt_SoftResetHandler()
7000 spin_lock_irqsave(&ioc->taskmgmt_lock, flags); in mpt_SoftResetHandler()
7001 if (ioc->ioc_reset_in_progress) { in mpt_SoftResetHandler()
7002 spin_unlock_irqrestore(&ioc->taskmgmt_lock, flags); in mpt_SoftResetHandler()
7003 return -1; in mpt_SoftResetHandler()
7005 ioc->ioc_reset_in_progress = 1; in mpt_SoftResetHandler()
7006 spin_unlock_irqrestore(&ioc->taskmgmt_lock, flags); in mpt_SoftResetHandler()
7008 rc = -1; 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()
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.
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 */
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.