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 = dma_alloc_coherent(&ioc->pcidev->dev, hdr.ExtPageLength * 4, in mpt_is_discovery_complete()
314 if (!(buffer->PhyData[0].PortFlags & in mpt_is_discovery_complete()
319 dma_free_coherent(&ioc->pcidev->dev, hdr.ExtPageLength * 4, buffer, in mpt_is_discovery_complete()
327 * mpt_remove_dead_ioc_func - kthread context to remove dead ioc
331 * Return -1 for other case.
339 return -1; in mpt_remove_dead_ioc_func()
341 pdev = ioc->pcidev; in mpt_remove_dead_ioc_func()
343 return -1; in mpt_remove_dead_ioc_func()
352 * mpt_fault_reset_work - work performed on workq after ioc fault
367 if (ioc->ioc_reset_in_progress || !ioc->active) in mpt_fault_reset_work()
373 printk(MYIOC_s_INFO_FMT "%s: IOC is non-operational !!!!\n", in mpt_fault_reset_work()
374 ioc->name, __func__); in mpt_fault_reset_work()
383 hd = shost_priv(ioc->sh); in mpt_fault_reset_work()
384 ioc->schedule_dead_ioc_flush_running_cmds(hd); in mpt_fault_reset_work()
388 "mpt_dead_ioc_%d", ioc->id); in mpt_fault_reset_work()
392 ioc->name, __func__); in mpt_fault_reset_work()
396 ioc->name, __func__); in mpt_fault_reset_work()
404 ioc->name, ioc_raw_state & MPI_DOORBELL_DATA_MASK); in mpt_fault_reset_work()
406 ioc->name, __func__); in mpt_fault_reset_work()
408 printk(MYIOC_s_WARN_FMT "%s: HardReset: %s\n", ioc->name, in mpt_fault_reset_work()
413 "reset (%04xh)\n", ioc->name, ioc_raw_state & in mpt_fault_reset_work()
415 } else if (ioc->bus_type == SAS && ioc->sas_discovery_quiesce_io) { in mpt_fault_reset_work()
418 "discovery_quiesce_io flag\n", ioc->name)); in mpt_fault_reset_work()
419 ioc->sas_discovery_quiesce_io = 0; in mpt_fault_reset_work()
427 if (ioc->alt_ioc) in mpt_fault_reset_work()
428 ioc = ioc->alt_ioc; in mpt_fault_reset_work()
431 spin_lock_irqsave(&ioc->taskmgmt_lock, flags); in mpt_fault_reset_work()
432 if (ioc->reset_work_q) in mpt_fault_reset_work()
433 queue_delayed_work(ioc->reset_work_q, &ioc->fault_reset_work, in mpt_fault_reset_work()
435 spin_unlock_irqrestore(&ioc->taskmgmt_lock, flags); in mpt_fault_reset_work()
451 ioc->name, pa)); in mpt_turbo_reply()
464 * Fix sort of combined with an optimization here; in mpt_turbo_reply()
468 * proper mf value first here:-) in mpt_turbo_reply()
492 __func__, ioc->name, cb_idx); in mpt_turbo_reply()
514 /* non-TURBO reply! Hmmm, something may be up... in mpt_reply()
520 * pa is 32 bits - but the dma address may be 32 or 64 bits in mpt_reply()
525 mr = (MPT_FRAME_HDR *)((u8 *)ioc->reply_frames + in mpt_reply()
526 (reply_dma_low - ioc->reply_frames_low_dma)); in mpt_reply()
528 req_idx = le16_to_cpu(mr->u.frame.hwhdr.msgctxu.fld.req_idx); in mpt_reply()
529 cb_idx = mr->u.frame.hwhdr.msgctxu.fld.cb_idx; in mpt_reply()
532 …dmfprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Got non-TURBO reply=%p req_idx=%x cb_idx=%x Function=%x\n… in mpt_reply()
533 ioc->name, mr, req_idx, cb_idx, mr->u.hdr.Function)); in mpt_reply()
538 ioc_stat = le16_to_cpu(mr->u.reply.IOCStatus); in mpt_reply()
540 u32 log_info = le32_to_cpu(mr->u.reply.IOCLogInfo); in mpt_reply()
541 if (ioc->bus_type == FC) in mpt_reply()
543 else if (ioc->bus_type == SPI) in mpt_reply()
545 else if (ioc->bus_type == SAS) in mpt_reply()
556 __func__, ioc->name, cb_idx); in mpt_reply()
564 /* Flush (non-TURBO) reply with a WRITE! */ in mpt_reply()
565 CHIPREG_WRITE32(&ioc->chip->ReplyFifo, pa); in mpt_reply()
572 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
574 * mpt_interrupt - MPT adapter (IOC) specific interrupt handler.
585 * This routine handles register-level access of the adapter but
586 * dispatches (calls) a protocol-specific callback routine to handle
587 * the protocol-specific details of the MPT request completion.
593 u32 pa = CHIPREG_READ32_dmasync(&ioc->chip->ReplyFifo); in mpt_interrupt()
606 pa = CHIPREG_READ32_dmasync(&ioc->chip->ReplyFifo); in mpt_interrupt()
612 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
614 * mptbase_reply - MPT base driver's callback routine
616 * @req: Pointer to original MPT request frame
627 mptbase_reply(MPT_ADAPTER *ioc, MPT_FRAME_HDR *req, MPT_FRAME_HDR *reply) in mptbase_reply() argument
634 switch (reply->u.hdr.Function) { in mptbase_reply()
639 event = le32_to_cpu(pEventReply->Event) & 0xFF; in mptbase_reply()
640 if (pEventReply->MsgFlags & MPI_MSGFLAGS_CONTINUATION_REPLY) in mptbase_reply()
647 ioc->mptbase_cmds.status |= MPT_MGMT_STATUS_COMMAND_GOOD; in mptbase_reply()
648 ioc->mptbase_cmds.status |= MPT_MGMT_STATUS_RF_VALID; in mptbase_reply()
649 memcpy(ioc->mptbase_cmds.reply, reply, in mptbase_reply()
651 4 * reply->u.reply.MsgLength)); in mptbase_reply()
652 if (ioc->mptbase_cmds.status & MPT_MGMT_STATUS_PENDING) { in mptbase_reply()
653 ioc->mptbase_cmds.status &= ~MPT_MGMT_STATUS_PENDING; in mptbase_reply()
654 complete(&ioc->mptbase_cmds.done); in mptbase_reply()
657 if (ioc->mptbase_cmds.status & MPT_MGMT_STATUS_FREE_MF) in mptbase_reply()
662 "EventAck reply received\n", ioc->name)); in mptbase_reply()
667 ioc->name, reply->u.hdr.Function); in mptbase_reply()
678 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
680 * mpt_register - Register protocol-specific main callback handler.
685 * This routine is called by a protocol-specific driver (SCSI host,
687 * protocol-specific driver must do this before it will be able to
709 for (cb_idx = MPT_MAX_PROTOCOL_DRIVERS-1; cb_idx; cb_idx--) { in mpt_register()
724 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
726 * mpt_deregister - Deregister a protocol drivers resources.
729 * Each protocol-specific driver should call this routine when its
744 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
746 * mpt_event_register - Register protocol-specific event callback handler.
750 * This routine can be called by one or more protocol-specific drivers
759 return -1; in mpt_event_register()
765 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
767 * mpt_event_deregister - Deregister protocol-specific event callback handler
770 * Each protocol-specific driver should call this routine
783 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
785 * mpt_reset_register - Register protocol-specific IOC reset handler.
789 * This routine can be called by one or more protocol-specific drivers
798 return -1; in mpt_reset_register()
804 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
806 * mpt_reset_deregister - Deregister protocol-specific IOC reset handler.
809 * Each protocol-specific driver should call this routine
822 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
824 * mpt_device_driver_register - Register device driver hooks
834 return -EINVAL; in mpt_device_driver_register()
840 if (dd_cbfunc->probe) in mpt_device_driver_register()
841 dd_cbfunc->probe(ioc->pcidev); in mpt_device_driver_register()
847 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
849 * mpt_device_driver_deregister - DeRegister device driver hooks
864 if (dd_cbfunc->remove) in mpt_device_driver_deregister()
865 dd_cbfunc->remove(ioc->pcidev); in mpt_device_driver_deregister()
872 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
874 * mpt_get_msg_frame - Obtain an MPT request frame from the pool
894 if (!ioc->active) in mpt_get_msg_frame()
896 "returning NULL!\n", ioc->name); in mpt_get_msg_frame()
900 if (!ioc->active) in mpt_get_msg_frame()
903 spin_lock_irqsave(&ioc->FreeQlock, flags); in mpt_get_msg_frame()
904 if (!list_empty(&ioc->FreeQ)) { in mpt_get_msg_frame()
907 mf = list_entry(ioc->FreeQ.next, MPT_FRAME_HDR, in mpt_get_msg_frame()
909 list_del(&mf->u.frame.linkage.list); in mpt_get_msg_frame()
910 mf->u.frame.linkage.arg1 = 0; in mpt_get_msg_frame()
911 mf->u.frame.hwhdr.msgctxu.fld.cb_idx = cb_idx; /* byte */ in mpt_get_msg_frame()
912 req_offset = (u8 *)mf - (u8 *)ioc->req_frames; in mpt_get_msg_frame()
914 req_idx = req_offset / ioc->req_sz; in mpt_get_msg_frame()
915 mf->u.frame.hwhdr.msgctxu.fld.req_idx = cpu_to_le16(req_idx); in mpt_get_msg_frame()
916 mf->u.frame.hwhdr.msgctxu.fld.rsvd = 0; in mpt_get_msg_frame()
918 ioc->RequestNB[req_idx] = ioc->NB_for_64_byte_frame; in mpt_get_msg_frame()
920 ioc->mfcnt++; in mpt_get_msg_frame()
925 spin_unlock_irqrestore(&ioc->FreeQlock, flags); in mpt_get_msg_frame()
930 "Count 0x%x Max 0x%x\n", ioc->name, ioc->mfcnt, in mpt_get_msg_frame()
931 ioc->req_depth); in mpt_get_msg_frame()
934 printk(MYIOC_s_INFO_FMT "MF Count 0x%x Max 0x%x \n", ioc->name, in mpt_get_msg_frame()
935 ioc->mfcnt, ioc->req_depth); in mpt_get_msg_frame()
939 ioc->name, cb_idx, ioc->id, mf)); in mpt_get_msg_frame()
943 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
945 * mpt_put_msg_frame - Send a protocol-specific MPT request frame to an IOC
961 mf->u.frame.hwhdr.msgctxu.fld.cb_idx = cb_idx; /* byte */ in mpt_put_msg_frame()
962 req_offset = (u8 *)mf - (u8 *)ioc->req_frames; in mpt_put_msg_frame()
964 req_idx = req_offset / ioc->req_sz; in mpt_put_msg_frame()
965 mf->u.frame.hwhdr.msgctxu.fld.req_idx = cpu_to_le16(req_idx); in mpt_put_msg_frame()
966 mf->u.frame.hwhdr.msgctxu.fld.rsvd = 0; in mpt_put_msg_frame()
970 mf_dma_addr = (ioc->req_frames_low_dma + req_offset) | ioc->RequestNB[req_idx]; in mpt_put_msg_frame()
972 "RequestNB=%x\n", ioc->name, mf_dma_addr, req_idx, in mpt_put_msg_frame()
973 ioc->RequestNB[req_idx])); in mpt_put_msg_frame()
974 CHIPREG_WRITE32(&ioc->chip->RequestFifo, mf_dma_addr); in mpt_put_msg_frame()
978 * mpt_put_msg_frame_hi_pri - Send a hi-pri protocol-specific MPT request frame
983 * Send a protocol-specific MPT request frame to an IOC using
984 * hi-priority request queue.
997 mf->u.frame.hwhdr.msgctxu.fld.cb_idx = cb_idx; in mpt_put_msg_frame_hi_pri()
998 req_offset = (u8 *)mf - (u8 *)ioc->req_frames; in mpt_put_msg_frame_hi_pri()
999 req_idx = req_offset / ioc->req_sz; in mpt_put_msg_frame_hi_pri()
1000 mf->u.frame.hwhdr.msgctxu.fld.req_idx = cpu_to_le16(req_idx); in mpt_put_msg_frame_hi_pri()
1001 mf->u.frame.hwhdr.msgctxu.fld.rsvd = 0; in mpt_put_msg_frame_hi_pri()
1005 mf_dma_addr = (ioc->req_frames_low_dma + req_offset); in mpt_put_msg_frame_hi_pri()
1007 ioc->name, mf_dma_addr, req_idx)); in mpt_put_msg_frame_hi_pri()
1008 CHIPREG_WRITE32(&ioc->chip->RequestHiPriFifo, mf_dma_addr); in mpt_put_msg_frame_hi_pri()
1011 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
1013 * mpt_free_msg_frame - Place MPT request frame back on FreeQ.
1026 spin_lock_irqsave(&ioc->FreeQlock, flags); in mpt_free_msg_frame()
1027 if (cpu_to_le32(mf->u.frame.linkage.arg1) == 0xdeadbeaf) in mpt_free_msg_frame()
1030 mf->u.frame.linkage.arg1 = cpu_to_le32(0xdeadbeaf); in mpt_free_msg_frame()
1031 list_add(&mf->u.frame.linkage.list, &ioc->FreeQ); in mpt_free_msg_frame()
1033 ioc->mfcnt--; in mpt_free_msg_frame()
1036 spin_unlock_irqrestore(&ioc->FreeQlock, flags); in mpt_free_msg_frame()
1039 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
1041 * mpt_add_sge - Place a simple 32 bit SGE at address pAddr.
1053 pSge->FlagsLength = cpu_to_le32(flagslength); in mpt_add_sge()
1054 pSge->Address = cpu_to_le32(dma_addr); in mpt_add_sge()
1058 * mpt_add_sge_64bit - Place a simple 64 bit SGE at address pAddr.
1070 pSge->Address.Low = cpu_to_le32 in mpt_add_sge_64bit()
1072 pSge->Address.High = cpu_to_le32 in mpt_add_sge_64bit()
1074 pSge->FlagsLength = cpu_to_le32 in mpt_add_sge_64bit()
1079 * mpt_add_sge_64bit_1078 - Place a simple 64 bit SGE at address pAddr (1078 workaround).
1093 pSge->Address.Low = cpu_to_le32 in mpt_add_sge_64bit_1078()
1111 pSge->Address.High = cpu_to_le32(tmp); in mpt_add_sge_64bit_1078()
1112 pSge->FlagsLength = cpu_to_le32( in mpt_add_sge_64bit_1078()
1116 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
1118 * mpt_add_chain - Place a 32 bit chain SGE at address pAddr.
1130 pChain->Length = cpu_to_le16(length); in mpt_add_chain()
1131 pChain->Flags = MPI_SGE_FLAGS_CHAIN_ELEMENT; in mpt_add_chain()
1132 pChain->NextChainOffset = next; in mpt_add_chain()
1133 pChain->Address = cpu_to_le32(dma_addr); in mpt_add_chain()
1136 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
1138 * mpt_add_chain_64bit - Place a 64 bit chain SGE at address pAddr.
1151 pChain->Length = cpu_to_le16(length); in mpt_add_chain_64bit()
1152 pChain->Flags = (MPI_SGE_FLAGS_CHAIN_ELEMENT | in mpt_add_chain_64bit()
1155 pChain->NextChainOffset = next; in mpt_add_chain_64bit()
1157 pChain->Address.Low = cpu_to_le32(tmp); in mpt_add_chain_64bit()
1159 pChain->Address.High = cpu_to_le32(tmp); in mpt_add_chain_64bit()
1162 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
1164 * mpt_send_handshake_request - Send MPT request via doorbell handshake method.
1168 * @req: Pointer to MPT request frame
1174 * NOTE: It is the callers responsibility to byte-swap fields in the
1177 * Returns 0 for success, non-zero for failure.
1180 mpt_send_handshake_request(u8 cb_idx, MPT_ADAPTER *ioc, int reqBytes, u32 *req, int sleepFlag) in mpt_send_handshake_request() argument
1194 * is in proper (pre-alloc'd) request buffer range... in mpt_send_handshake_request()
1196 ii = MFPTR_2_MPT_INDEX(ioc,(MPT_FRAME_HDR*)req); in mpt_send_handshake_request()
1197 if (reqBytes >= 12 && ii >= 0 && ii < ioc->req_depth) { in mpt_send_handshake_request()
1198 MPT_FRAME_HDR *mf = (MPT_FRAME_HDR*)req; in mpt_send_handshake_request()
1199 mf->u.frame.hwhdr.msgctxu.fld.req_idx = cpu_to_le16(ii); in mpt_send_handshake_request()
1200 mf->u.frame.hwhdr.msgctxu.fld.cb_idx = cb_idx; in mpt_send_handshake_request()
1204 CHIPREG_WRITE32(&ioc->chip->IntStatus, 0); in mpt_send_handshake_request()
1206 CHIPREG_WRITE32(&ioc->chip->Doorbell, in mpt_send_handshake_request()
1216 if (!(CHIPREG_READ32(&ioc->chip->Doorbell) & MPI_DOORBELL_ACTIVE)) in mpt_send_handshake_request()
1217 return -5; in mpt_send_handshake_request()
1220 ioc->name, ii)); in mpt_send_handshake_request()
1222 CHIPREG_WRITE32(&ioc->chip->IntStatus, 0); in mpt_send_handshake_request()
1225 return -2; in mpt_send_handshake_request()
1229 req_as_bytes = (u8 *) req; in mpt_send_handshake_request()
1237 CHIPREG_WRITE32(&ioc->chip->Doorbell, word); in mpt_send_handshake_request()
1239 r = -3; in mpt_send_handshake_request()
1247 r = -4; in mpt_send_handshake_request()
1250 CHIPREG_WRITE32(&ioc->chip->IntStatus, 0); in mpt_send_handshake_request()
1255 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
1257 * mpt_host_page_access_control - control the IOC's Host Page Buffer access
1265 * Access Control Value - bits[15:12]
1271 * Returns 0 for success, non-zero for failure.
1278 if (CHIPREG_READ32(&ioc->chip->Doorbell) in mpt_host_page_access_control()
1280 return -1; in mpt_host_page_access_control()
1282 CHIPREG_WRITE32(&ioc->chip->IntStatus, 0); in mpt_host_page_access_control()
1284 CHIPREG_WRITE32(&ioc->chip->Doorbell, in mpt_host_page_access_control()
1291 return -2; in mpt_host_page_access_control()
1296 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
1298 * mpt_host_page_alloc - allocate system memory for the fw
1303 * Returns 0 for success, non-zero for failure.
1312 if(!ioc->HostPageBuffer) { in mpt_host_page_alloc()
1315 le32_to_cpu(ioc->facts.HostPageBufferSGE.FlagsLength) & 0xFFFFFF; in mpt_host_page_alloc()
1322 ioc->HostPageBuffer = in mpt_host_page_alloc()
1323 dma_alloc_coherent(&ioc->pcidev->dev, in mpt_host_page_alloc()
1325 &ioc->HostPageBuffer_dma, in mpt_host_page_alloc()
1327 if (ioc->HostPageBuffer) { in mpt_host_page_alloc()
1330 ioc->name, ioc->HostPageBuffer, in mpt_host_page_alloc()
1331 (u32)ioc->HostPageBuffer_dma, in mpt_host_page_alloc()
1333 ioc->alloc_total += host_page_buffer_sz; in mpt_host_page_alloc()
1334 ioc->HostPageBuffer_sz = host_page_buffer_sz; in mpt_host_page_alloc()
1338 host_page_buffer_sz -= (4*1024); in mpt_host_page_alloc()
1342 if(!ioc->HostPageBuffer) { in mpt_host_page_alloc()
1345 ioc->name); in mpt_host_page_alloc()
1346 return -999; in mpt_host_page_alloc()
1349 psge = (char *)&ioc_init->HostPageBufferSGE; in mpt_host_page_alloc()
1355 flags_length |= ioc->HostPageBuffer_sz; in mpt_host_page_alloc()
1356 ioc->add_sge(psge, flags_length, ioc->HostPageBuffer_dma); in mpt_host_page_alloc()
1357 ioc->facts.HostPageBufferSGE = ioc_init->HostPageBufferSGE; in mpt_host_page_alloc()
1362 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
1364 * mpt_verify_adapter - Given IOC identifier, set pointer to its adapter structure.
1372 * Returns -1 if iocid is not found.
1380 if (ioc->id == iocid) { in mpt_verify_adapter()
1387 return -1; in mpt_verify_adapter()
1391 * mpt_get_product_name - returns product string
1631 * mpt_mapresources - map in memory mapped io
1644 int r = -ENODEV; in mpt_mapresources()
1647 pdev = ioc->pcidev; in mpt_mapresources()
1648 ioc->bars = pci_select_bars(pdev, IORESOURCE_MEM); in mpt_mapresources()
1651 "failed\n", ioc->name); in mpt_mapresources()
1654 if (pci_request_selected_regions(pdev, ioc->bars, "mpt")) { in mpt_mapresources()
1656 "MEM failed\n", ioc->name); in mpt_mapresources()
1662 (&pdev->dev); in mpt_mapresources()
1664 && !dma_set_mask(&pdev->dev, DMA_BIT_MASK(64)) in mpt_mapresources()
1665 && !dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(64))) { in mpt_mapresources()
1666 ioc->dma_mask = DMA_BIT_MASK(64); in mpt_mapresources()
1669 ioc->name)); in mpt_mapresources()
1670 } else if (!dma_set_mask(&pdev->dev, DMA_BIT_MASK(32)) in mpt_mapresources()
1671 && !dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(32))) { in mpt_mapresources()
1672 ioc->dma_mask = DMA_BIT_MASK(32); in mpt_mapresources()
1675 ioc->name)); in mpt_mapresources()
1678 ioc->name, pci_name(pdev)); in mpt_mapresources()
1682 if (!dma_set_mask(&pdev->dev, DMA_BIT_MASK(32)) in mpt_mapresources()
1683 && !dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(32))) { in mpt_mapresources()
1684 ioc->dma_mask = DMA_BIT_MASK(32); in mpt_mapresources()
1687 ioc->name)); in mpt_mapresources()
1690 ioc->name, pci_name(pdev)); in mpt_mapresources()
1712 ioc->mem_size = msize; in mpt_mapresources()
1719 printk(MYIOC_s_ERR_FMT ": ERROR - Unable to map adapter" in mpt_mapresources()
1720 " memory!\n", ioc->name); in mpt_mapresources()
1721 r = -EINVAL; in mpt_mapresources()
1724 ioc->memmap = mem; in mpt_mapresources()
1726 ioc->name, mem, (unsigned long long)mem_phys)); in mpt_mapresources()
1728 ioc->mem_phys = mem_phys; in mpt_mapresources()
1729 ioc->chip = (SYSIF_REGS __iomem *)mem; in mpt_mapresources()
1732 ioc->pio_mem_phys = port; in mpt_mapresources()
1733 ioc->pio_chip = (SYSIF_REGS __iomem *)port; in mpt_mapresources()
1738 pci_release_selected_regions(pdev, ioc->bars); in mpt_mapresources()
1744 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
1746 * mpt_attach - Install a PCI intelligent MPT adapter.
1755 * This routine also pre-fetches the LAN MAC address of a Fibre Channel
1758 * Returns 0 for success, non-zero for failure.
1767 int r = -ENODEV; in mpt_attach()
1776 printk(KERN_ERR MYNAM ": ERROR - Insufficient memory to add adapter!\n"); in mpt_attach()
1777 return -ENOMEM; in mpt_attach()
1780 ioc->id = mpt_ids++; in mpt_attach()
1781 sprintf(ioc->name, "ioc%d", ioc->id); in mpt_attach()
1789 ioc->debug_level = mpt_debug_level; in mpt_attach()
1793 dinitprintk(ioc, printk(MYIOC_s_INFO_FMT ": mpt_adapter_install\n", ioc->name)); in mpt_attach()
1795 ioc->pcidev = pdev; in mpt_attach()
1803 if (ioc->dma_mask == DMA_BIT_MASK(64)) { in mpt_attach()
1804 if (pdev->device == MPI_MANUFACTPAGE_DEVID_SAS1078) in mpt_attach()
1805 ioc->add_sge = &mpt_add_sge_64bit_1078; in mpt_attach()
1807 ioc->add_sge = &mpt_add_sge_64bit; in mpt_attach()
1808 ioc->add_chain = &mpt_add_chain_64bit; in mpt_attach()
1809 ioc->sg_addr_size = 8; in mpt_attach()
1811 ioc->add_sge = &mpt_add_sge; in mpt_attach()
1812 ioc->add_chain = &mpt_add_chain; in mpt_attach()
1813 ioc->sg_addr_size = 4; in mpt_attach()
1815 ioc->SGE_size = sizeof(u32) + ioc->sg_addr_size; in mpt_attach()
1817 ioc->alloc_total = sizeof(MPT_ADAPTER); in mpt_attach()
1818 ioc->req_sz = MPT_DEFAULT_FRAME_SIZE; /* avoid div by zero! */ in mpt_attach()
1819 ioc->reply_sz = MPT_REPLY_FRAME_SIZE; in mpt_attach()
1822 spin_lock_init(&ioc->taskmgmt_lock); in mpt_attach()
1823 mutex_init(&ioc->internal_cmds.mutex); in mpt_attach()
1824 init_completion(&ioc->internal_cmds.done); in mpt_attach()
1825 mutex_init(&ioc->mptbase_cmds.mutex); in mpt_attach()
1826 init_completion(&ioc->mptbase_cmds.done); in mpt_attach()
1827 mutex_init(&ioc->taskmgmt_cmds.mutex); in mpt_attach()
1828 init_completion(&ioc->taskmgmt_cmds.done); in mpt_attach()
1832 ioc->eventTypes = 0; /* None */ in mpt_attach()
1833 ioc->eventContext = 0; in mpt_attach()
1834 ioc->eventLogSize = 0; in mpt_attach()
1835 ioc->events = NULL; in mpt_attach()
1838 ioc->mfcnt = 0; in mpt_attach()
1841 ioc->sh = NULL; in mpt_attach()
1842 ioc->cached_fw = NULL; in mpt_attach()
1846 memset(&ioc->spi_data, 0, sizeof(SpiCfgData)); in mpt_attach()
1850 INIT_LIST_HEAD(&ioc->fc_rports); in mpt_attach()
1853 INIT_LIST_HEAD(&ioc->list); in mpt_attach()
1857 INIT_DELAYED_WORK(&ioc->fault_reset_work, mpt_fault_reset_work); in mpt_attach()
1859 ioc->reset_work_q = in mpt_attach()
1860 alloc_workqueue("mpt_poll_%d", WQ_MEM_RECLAIM, 0, ioc->id); in mpt_attach()
1861 if (!ioc->reset_work_q) { in mpt_attach()
1863 ioc->name); in mpt_attach()
1864 r = -ENOMEM; in mpt_attach()
1869 ioc->name, &ioc->facts, &ioc->pfacts[0])); in mpt_attach()
1871 ioc->prod_name = mpt_get_product_name(pdev->vendor, pdev->device, in mpt_attach()
1872 pdev->revision); in mpt_attach()
1874 switch (pdev->device) in mpt_attach()
1878 ioc->errata_flag_1064 = 1; in mpt_attach()
1884 ioc->bus_type = FC; in mpt_attach()
1888 if (pdev->revision < XL_929) { in mpt_attach()
1902 ioc->bus_type = FC; in mpt_attach()
1912 ioc->bus_type = FC; in mpt_attach()
1919 if (pdev->revision < C0_1030) { in mpt_attach()
1927 ioc->bus_type = SPI; in mpt_attach()
1932 ioc->errata_flag_1064 = 1; in mpt_attach()
1933 ioc->bus_type = SAS; in mpt_attach()
1939 ioc->bus_type = SAS; in mpt_attach()
1944 switch (ioc->bus_type) { in mpt_attach()
1947 ioc->msi_enable = mpt_msi_enable_sas; in mpt_attach()
1951 ioc->msi_enable = mpt_msi_enable_spi; in mpt_attach()
1955 ioc->msi_enable = mpt_msi_enable_fc; in mpt_attach()
1959 ioc->msi_enable = 0; in mpt_attach()
1963 ioc->fw_events_off = 1; in mpt_attach()
1965 if (ioc->errata_flag_1064) in mpt_attach()
1968 spin_lock_init(&ioc->FreeQlock); in mpt_attach()
1971 CHIPREG_WRITE32(&ioc->chip->IntMask, 0xFFFFFFFF); in mpt_attach()
1972 ioc->active = 0; in mpt_attach()
1973 CHIPREG_WRITE32(&ioc->chip->IntStatus, 0); in mpt_attach()
1976 pci_set_drvdata(ioc->pcidev, ioc); in mpt_attach()
1979 list_add_tail(&ioc->list, &ioc_list); in mpt_attach()
1985 INIT_LIST_HEAD(&ioc->fw_event_list); in mpt_attach()
1986 spin_lock_init(&ioc->fw_event_lock); in mpt_attach()
1987 ioc->fw_event_q = alloc_workqueue("mpt/%d", WQ_MEM_RECLAIM, 0, ioc->id); in mpt_attach()
1988 if (!ioc->fw_event_q) { in mpt_attach()
1990 ioc->name); in mpt_attach()
1991 r = -ENOMEM; in mpt_attach()
1998 ioc->name, r); in mpt_attach()
2000 destroy_workqueue(ioc->fw_event_q); in mpt_attach()
2001 ioc->fw_event_q = NULL; in mpt_attach()
2003 list_del(&ioc->list); in mpt_attach()
2004 if (ioc->alt_ioc) in mpt_attach()
2005 ioc->alt_ioc->alt_ioc = NULL; in mpt_attach()
2006 iounmap(ioc->memmap); in mpt_attach()
2009 if (r != -5) in mpt_attach()
2010 pci_release_selected_regions(pdev, ioc->bars); in mpt_attach()
2012 destroy_workqueue(ioc->reset_work_q); in mpt_attach()
2013 ioc->reset_work_q = NULL; in mpt_attach()
2022 MptDeviceDriverHandlers[cb_idx]->probe) { in mpt_attach()
2023 MptDeviceDriverHandlers[cb_idx]->probe(pdev); in mpt_attach()
2031 dent = proc_mkdir(ioc->name, mpt_proc_root_dir); in mpt_attach()
2040 if (!ioc->alt_ioc) in mpt_attach()
2041 queue_delayed_work(ioc->reset_work_q, &ioc->fault_reset_work, in mpt_attach()
2047 list_del(&ioc->list); in mpt_attach()
2048 if (ioc->alt_ioc) in mpt_attach()
2049 ioc->alt_ioc->alt_ioc = NULL; in mpt_attach()
2051 destroy_workqueue(ioc->reset_work_q); in mpt_attach()
2052 ioc->reset_work_q = NULL; in mpt_attach()
2055 iounmap(ioc->memmap); in mpt_attach()
2057 pci_release_selected_regions(pdev, ioc->bars); in mpt_attach()
2065 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
2067 * mpt_detach - Remove a PCI intelligent MPT adapter.
2083 spin_lock_irqsave(&ioc->taskmgmt_lock, flags); in mpt_detach()
2084 wq = ioc->reset_work_q; in mpt_detach()
2085 ioc->reset_work_q = NULL; in mpt_detach()
2086 spin_unlock_irqrestore(&ioc->taskmgmt_lock, flags); in mpt_detach()
2087 cancel_delayed_work(&ioc->fault_reset_work); in mpt_detach()
2090 spin_lock_irqsave(&ioc->fw_event_lock, flags); in mpt_detach()
2091 wq = ioc->fw_event_q; in mpt_detach()
2092 ioc->fw_event_q = NULL; in mpt_detach()
2093 spin_unlock_irqrestore(&ioc->fw_event_lock, flags); in mpt_detach()
2096 snprintf(pname, sizeof(pname), MPT_PROCFS_MPTBASEDIR "/%s/summary", ioc->name); in mpt_detach()
2098 snprintf(pname, sizeof(pname), MPT_PROCFS_MPTBASEDIR "/%s/info", ioc->name); in mpt_detach()
2100 snprintf(pname, sizeof(pname), MPT_PROCFS_MPTBASEDIR "/%s", ioc->name); in mpt_detach()
2106 MptDeviceDriverHandlers[cb_idx]->remove) { in mpt_detach()
2107 MptDeviceDriverHandlers[cb_idx]->remove(pdev); in mpt_detach()
2112 CHIPREG_WRITE32(&ioc->chip->IntMask, 0xFFFFFFFF); in mpt_detach()
2114 ioc->active = 0; in mpt_detach()
2115 synchronize_irq(pdev->irq); in mpt_detach()
2118 CHIPREG_WRITE32(&ioc->chip->IntStatus, 0); in mpt_detach()
2120 CHIPREG_READ32(&ioc->chip->IntStatus); in mpt_detach()
2127 * Power Management
2130 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
2132 * mpt_suspend - Fusion MPT base driver suspend routine.
2143 printk(MYIOC_s_INFO_FMT "pci-suspend: pdev=0x%p, slot=%s, Entering " in mpt_suspend()
2144 "operating state [D%d]\n", ioc->name, pdev, pci_name(pdev), in mpt_suspend()
2150 "pci-suspend: IOC msg unit reset failed!\n", ioc->name); in mpt_suspend()
2154 CHIPREG_WRITE32(&ioc->chip->IntMask, 0xFFFFFFFF); in mpt_suspend()
2155 ioc->active = 0; in mpt_suspend()
2158 CHIPREG_WRITE32(&ioc->chip->IntStatus, 0); in mpt_suspend()
2160 free_irq(ioc->pci_irq, ioc); in mpt_suspend()
2161 if (ioc->msi_enable) in mpt_suspend()
2162 pci_disable_msi(ioc->pcidev); in mpt_suspend()
2163 ioc->pci_irq = -1; in mpt_suspend()
2166 pci_release_selected_regions(pdev, ioc->bars); in mpt_suspend()
2171 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
2173 * mpt_resume - Fusion MPT base driver resume routine.
2180 u32 device_state = pdev->current_state; in mpt_resume()
2184 printk(MYIOC_s_INFO_FMT "pci-resume: pdev=0x%p, slot=%s, Previous " in mpt_resume()
2185 "operating state [D%d]\n", ioc->name, pdev, pci_name(pdev), in mpt_resume()
2191 ioc->pcidev = pdev; in mpt_resume()
2196 if (ioc->dma_mask == DMA_BIT_MASK(64)) { in mpt_resume()
2197 if (pdev->device == MPI_MANUFACTPAGE_DEVID_SAS1078) in mpt_resume()
2198 ioc->add_sge = &mpt_add_sge_64bit_1078; in mpt_resume()
2200 ioc->add_sge = &mpt_add_sge_64bit; in mpt_resume()
2201 ioc->add_chain = &mpt_add_chain_64bit; in mpt_resume()
2202 ioc->sg_addr_size = 8; in mpt_resume()
2205 ioc->add_sge = &mpt_add_sge; in mpt_resume()
2206 ioc->add_chain = &mpt_add_chain; in mpt_resume()
2207 ioc->sg_addr_size = 4; in mpt_resume()
2209 ioc->SGE_size = sizeof(u32) + ioc->sg_addr_size; in mpt_resume()
2211 printk(MYIOC_s_INFO_FMT "pci-resume: ioc-state=0x%x,doorbell=0x%x\n", in mpt_resume()
2212 ioc->name, (mpt_GetIocState(ioc, 1) >> MPI_IOC_STATE_SHIFT), in mpt_resume()
2213 CHIPREG_READ32(&ioc->chip->Doorbell)); in mpt_resume()
2222 if (ioc->bus_type == SAS && (pdev->device == in mpt_resume()
2223 MPI_MANUFACTPAGE_DEVID_SAS1068E || pdev->device == in mpt_resume()
2226 printk(MYIOC_s_WARN_FMT "pci-resume: Cannot recover\n", in mpt_resume()
2227 ioc->name); in mpt_resume()
2233 printk(MYIOC_s_INFO_FMT "Sending mpt_do_ioc_recovery\n", ioc->name); in mpt_resume()
2237 printk(MYIOC_s_WARN_FMT "pci-resume: Cannot recover, " in mpt_resume()
2238 "error:[%x]\n", ioc->name, recovery_state); in mpt_resume()
2241 "pci-resume: success\n", ioc->name); in mpt_resume()
2252 ioc->bus_type != SPI) || in mpt_signal_reset()
2254 ioc->bus_type != FC) || in mpt_signal_reset()
2256 ioc->bus_type != SAS)) in mpt_signal_reset()
2263 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
2265 * mpt_do_ioc_recovery - Initialize or recover MPT adapter.
2273 * This routine also pre-fetches the LAN MAC address of a Fibre Channel
2278 * -1 if failed to get board READY
2279 * -2 if READY but IOCFacts Failed
2280 * -3 if READY but PrimeIOCFifos Failed
2281 * -4 if READY but IOCInit Failed
2282 * -5 if failed to enable_device and/or request_selected_regions
2283 * -6 if failed to upload firmware
2298 printk(MYIOC_s_INFO_FMT "Initiating %s\n", ioc->name, in mpt_do_ioc_recovery()
2302 CHIPREG_WRITE32(&ioc->chip->IntMask, 0xFFFFFFFF); in mpt_do_ioc_recovery()
2303 ioc->active = 0; in mpt_do_ioc_recovery()
2305 if (ioc->alt_ioc) { in mpt_do_ioc_recovery()
2306 if (ioc->alt_ioc->active || in mpt_do_ioc_recovery()
2309 /* Disable alt-IOC's reply interrupts in mpt_do_ioc_recovery()
2312 CHIPREG_WRITE32(&ioc->alt_ioc->chip->IntMask, in mpt_do_ioc_recovery()
2314 ioc->alt_ioc->active = 0; in mpt_do_ioc_recovery()
2323 if (hard_reset_done == -4) { in mpt_do_ioc_recovery()
2325 ioc->name); in mpt_do_ioc_recovery()
2327 if (reset_alt_ioc_active && ioc->alt_ioc) { in mpt_do_ioc_recovery()
2328 /* (re)Enable alt-IOC! (reply interrupt, FreeQ) */ in mpt_do_ioc_recovery()
2330 "alt_ioc reply irq re-enabled\n", ioc->alt_ioc->name)); in mpt_do_ioc_recovery()
2331 CHIPREG_WRITE32(&ioc->alt_ioc->chip->IntMask, MPI_HIM_DIM); in mpt_do_ioc_recovery()
2332 ioc->alt_ioc->active = 1; in mpt_do_ioc_recovery()
2337 "NOT READY WARNING!\n", ioc->name); in mpt_do_ioc_recovery()
2339 ret = -1; in mpt_do_ioc_recovery()
2346 if (hard_reset_done && reset_alt_ioc_active && ioc->alt_ioc) { in mpt_do_ioc_recovery()
2347 if ((rc = MakeIocReady(ioc->alt_ioc, 0, sleepFlag)) == 0) in mpt_do_ioc_recovery()
2351 ": alt-ioc Not ready WARNING!\n", in mpt_do_ioc_recovery()
2352 ioc->alt_ioc->name); in mpt_do_ioc_recovery()
2364 "Retry IocFacts failed rc=%x\n", ioc->name, rc)); in mpt_do_ioc_recovery()
2365 ret = -2; in mpt_do_ioc_recovery()
2371 if ((rc = GetIocFacts(ioc->alt_ioc, sleepFlag, reason)) != 0) { in mpt_do_ioc_recovery()
2374 ioc->name, rc)); in mpt_do_ioc_recovery()
2375 /* Retry - alt IOC was initialized once in mpt_do_ioc_recovery()
2377 rc = GetIocFacts(ioc->alt_ioc, sleepFlag, reason); in mpt_do_ioc_recovery()
2381 "Retry Alt IocFacts failed rc=%x\n", ioc->name, rc)); in mpt_do_ioc_recovery()
2385 MptDisplayIocCapabilities(ioc->alt_ioc); in mpt_do_ioc_recovery()
2390 (ioc->facts.Flags & MPI_IOCFACTS_FLAGS_FW_DOWNLOAD_BOOT)) { in mpt_do_ioc_recovery()
2391 pci_release_selected_regions(ioc->pcidev, ioc->bars); in mpt_do_ioc_recovery()
2392 ioc->bars = pci_select_bars(ioc->pcidev, IORESOURCE_MEM | in mpt_do_ioc_recovery()
2394 if (pci_enable_device(ioc->pcidev)) in mpt_do_ioc_recovery()
2395 return -5; in mpt_do_ioc_recovery()
2396 if (pci_request_selected_regions(ioc->pcidev, ioc->bars, in mpt_do_ioc_recovery()
2398 return -5; in mpt_do_ioc_recovery()
2402 * Device is reset now. It must have de-asserted the interrupt line in mpt_do_ioc_recovery()
2407 ioc->pci_irq = -1; in mpt_do_ioc_recovery()
2408 if (ioc->pcidev->irq) { in mpt_do_ioc_recovery()
2409 if (ioc->msi_enable && !pci_enable_msi(ioc->pcidev)) in mpt_do_ioc_recovery()
2410 printk(MYIOC_s_INFO_FMT "PCI-MSI enabled\n", in mpt_do_ioc_recovery()
2411 ioc->name); in mpt_do_ioc_recovery()
2413 ioc->msi_enable = 0; in mpt_do_ioc_recovery()
2414 rc = request_irq(ioc->pcidev->irq, mpt_interrupt, in mpt_do_ioc_recovery()
2415 IRQF_SHARED, ioc->name, ioc); in mpt_do_ioc_recovery()
2419 ioc->name, ioc->pcidev->irq); in mpt_do_ioc_recovery()
2420 if (ioc->msi_enable) in mpt_do_ioc_recovery()
2421 pci_disable_msi(ioc->pcidev); in mpt_do_ioc_recovery()
2422 ret = -EBUSY; in mpt_do_ioc_recovery()
2426 ioc->pci_irq = ioc->pcidev->irq; in mpt_do_ioc_recovery()
2427 pci_set_master(ioc->pcidev); /* ?? */ in mpt_do_ioc_recovery()
2428 pci_set_drvdata(ioc->pcidev, ioc); in mpt_do_ioc_recovery()
2430 "installed at interrupt %d\n", ioc->name, in mpt_do_ioc_recovery()
2431 ioc->pcidev->irq)); in mpt_do_ioc_recovery()
2438 * If fails, continue with alt-ioc processing in mpt_do_ioc_recovery()
2441 ioc->name)); in mpt_do_ioc_recovery()
2443 ret = -3; in mpt_do_ioc_recovery()
2446 * If fails, continue with alt-ioc processing in mpt_do_ioc_recovery()
2449 ioc->name)); in mpt_do_ioc_recovery()
2451 ret = -4; in mpt_do_ioc_recovery()
2453 if (alt_ioc_ready && ((rc = PrimeIocFifos(ioc->alt_ioc)) != 0)) { in mpt_do_ioc_recovery()
2455 ": alt-ioc (%d) FIFO mgmt alloc WARNING!\n", in mpt_do_ioc_recovery()
2456 ioc->alt_ioc->name, rc); in mpt_do_ioc_recovery()
2462 if ((rc = SendIocInit(ioc->alt_ioc, sleepFlag)) != 0) { in mpt_do_ioc_recovery()
2466 ": alt-ioc: (%d) init failure WARNING!\n", in mpt_do_ioc_recovery()
2467 ioc->alt_ioc->name, rc); in mpt_do_ioc_recovery()
2472 if (ioc->upload_fw) { in mpt_do_ioc_recovery()
2474 "firmware upload required!\n", ioc->name)); in mpt_do_ioc_recovery()
2481 if (ioc->alt_ioc && ioc->alt_ioc->cached_fw) { in mpt_do_ioc_recovery()
2491 ioc->name, ioc->alt_ioc->name, ioc->alt_ioc->cached_fw)); in mpt_do_ioc_recovery()
2492 ioc->cached_fw = NULL; in mpt_do_ioc_recovery()
2496 "firmware upload failure!\n", ioc->name); in mpt_do_ioc_recovery()
2497 ret = -6; in mpt_do_ioc_recovery()
2506 if ((ret == 0) && (!ioc->facts.EventState)) { in mpt_do_ioc_recovery()
2509 ioc->name)); in mpt_do_ioc_recovery()
2513 if (ioc->alt_ioc && alt_ioc_ready && !ioc->alt_ioc->facts.EventState) in mpt_do_ioc_recovery()
2514 rc = SendEventNotification(ioc->alt_ioc, 1, sleepFlag); in mpt_do_ioc_recovery()
2518 CHIPREG_WRITE32(&ioc->chip->IntMask, MPI_HIM_DIM); in mpt_do_ioc_recovery()
2519 ioc->active = 1; in mpt_do_ioc_recovery()
2522 if (reset_alt_ioc_active && ioc->alt_ioc) { in mpt_do_ioc_recovery()
2523 /* (re)Enable alt-IOC! (reply interrupt) */ in mpt_do_ioc_recovery()
2524 dinitprintk(ioc, printk(MYIOC_s_DEBUG_FMT "alt-ioc" in mpt_do_ioc_recovery()
2525 "reply irq re-enabled\n", in mpt_do_ioc_recovery()
2526 ioc->alt_ioc->name)); in mpt_do_ioc_recovery()
2527 CHIPREG_WRITE32(&ioc->alt_ioc->chip->IntMask, in mpt_do_ioc_recovery()
2529 ioc->alt_ioc->active = 1; in mpt_do_ioc_recovery()
2535 * (combined with GetIoUnitPage2 call). This prevents a somewhat in mpt_do_ioc_recovery()
2545 mutex_init(&ioc->raid_data.inactive_list_mutex); in mpt_do_ioc_recovery()
2546 INIT_LIST_HEAD(&ioc->raid_data.inactive_list); in mpt_do_ioc_recovery()
2548 switch (ioc->bus_type) { in mpt_do_ioc_recovery()
2552 if(ioc->facts.IOCExceptions & in mpt_do_ioc_recovery()
2571 if ((ioc->pfacts[0].ProtocolFlags & in mpt_do_ioc_recovery()
2573 (ioc->lan_cnfg_page0.Header.PageLength == 0)) { in mpt_do_ioc_recovery()
2575 * Pre-fetch the ports LAN MAC address! in mpt_do_ioc_recovery()
2579 a = (u8*)&ioc->lan_cnfg_page1.HardwareAddressLow; in mpt_do_ioc_recovery()
2581 "LanAddr = %pMR\n", ioc->name, a)); in mpt_do_ioc_recovery()
2596 if (ioc->facts.MsgVersion >= MPI_VERSION_01_02) in mpt_do_ioc_recovery()
2614 free_irq(ioc->pci_irq, ioc); in mpt_do_ioc_recovery()
2615 if (ioc->msi_enable) in mpt_do_ioc_recovery()
2616 pci_disable_msi(ioc->pcidev); in mpt_do_ioc_recovery()
2621 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
2623 * mpt_detect_bound_ports - Search for matching PCI bus/dev_function
2628 * PCI bus/dev_function (+/-1) for newly discovered 929,
2631 * If match on PCI dev_function +/-1 is found, bind the two MPT adapters
2638 unsigned int slot = PCI_SLOT(pdev->devfn); in mpt_detect_bound_ports()
2639 unsigned int func = PCI_FUNC(pdev->devfn); in mpt_detect_bound_ports()
2644 ioc->name, pci_name(pdev), pdev->bus->number, in mpt_detect_bound_ports()
2645 pdev->devfn, func-1, func+1)); in mpt_detect_bound_ports()
2647 peer = pci_get_slot(pdev->bus, PCI_DEVFN(slot,func-1)); in mpt_detect_bound_ports()
2649 peer = pci_get_slot(pdev->bus, PCI_DEVFN(slot,func+1)); in mpt_detect_bound_ports()
2655 struct pci_dev *_pcidev = ioc_srch->pcidev; in mpt_detect_bound_ports()
2658 if (ioc->alt_ioc != NULL) { in mpt_detect_bound_ports()
2661 ioc->name, ioc->name, ioc->alt_ioc->name); in mpt_detect_bound_ports()
2663 } else if (ioc_srch->alt_ioc != NULL) { in mpt_detect_bound_ports()
2666 ioc_srch->name, ioc_srch->name, in mpt_detect_bound_ports()
2667 ioc_srch->alt_ioc->name); in mpt_detect_bound_ports()
2672 ioc->name, ioc->name, ioc_srch->name)); in mpt_detect_bound_ports()
2673 ioc_srch->alt_ioc = ioc; in mpt_detect_bound_ports()
2674 ioc->alt_ioc = ioc_srch; in mpt_detect_bound_ports()
2680 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
2682 * mpt_adapter_disable - Disable misbehaving MPT adapter.
2691 if (ioc->cached_fw != NULL) { in mpt_adapter_disable()
2693 "%s: Pushing FW onto adapter\n", __func__, ioc->name)); in mpt_adapter_disable()
2695 ioc->cached_fw, CAN_SLEEP)) < 0) { in mpt_adapter_disable()
2698 ioc->name, ret); in mpt_adapter_disable()
2711 ioc->name, __func__); in mpt_adapter_disable()
2714 "failed!\n", ioc->name, __func__); in mpt_adapter_disable()
2719 synchronize_irq(ioc->pcidev->irq); in mpt_adapter_disable()
2720 CHIPREG_WRITE32(&ioc->chip->IntMask, 0xFFFFFFFF); in mpt_adapter_disable()
2721 ioc->active = 0; in mpt_adapter_disable()
2724 CHIPREG_WRITE32(&ioc->chip->IntStatus, 0); in mpt_adapter_disable()
2725 CHIPREG_READ32(&ioc->chip->IntStatus); in mpt_adapter_disable()
2727 if (ioc->alloc != NULL) { in mpt_adapter_disable()
2728 sz = ioc->alloc_sz; in mpt_adapter_disable()
2730 ioc->name, ioc->alloc, ioc->alloc_sz)); in mpt_adapter_disable()
2731 dma_free_coherent(&ioc->pcidev->dev, sz, ioc->alloc, in mpt_adapter_disable()
2732 ioc->alloc_dma); in mpt_adapter_disable()
2733 ioc->reply_frames = NULL; in mpt_adapter_disable()
2734 ioc->req_frames = NULL; in mpt_adapter_disable()
2735 ioc->alloc = NULL; in mpt_adapter_disable()
2736 ioc->alloc_total -= sz; in mpt_adapter_disable()
2739 if (ioc->sense_buf_pool != NULL) { in mpt_adapter_disable()
2740 sz = (ioc->req_depth * MPT_SENSE_BUFFER_ALLOC); in mpt_adapter_disable()
2741 dma_free_coherent(&ioc->pcidev->dev, sz, ioc->sense_buf_pool, in mpt_adapter_disable()
2742 ioc->sense_buf_pool_dma); in mpt_adapter_disable()
2743 ioc->sense_buf_pool = NULL; in mpt_adapter_disable()
2744 ioc->alloc_total -= sz; in mpt_adapter_disable()
2747 if (ioc->events != NULL){ in mpt_adapter_disable()
2749 kfree(ioc->events); in mpt_adapter_disable()
2750 ioc->events = NULL; in mpt_adapter_disable()
2751 ioc->alloc_total -= sz; in mpt_adapter_disable()
2756 kfree(ioc->spi_data.nvram); in mpt_adapter_disable()
2758 kfree(ioc->raid_data.pIocPg2); in mpt_adapter_disable()
2759 kfree(ioc->raid_data.pIocPg3); in mpt_adapter_disable()
2760 ioc->spi_data.nvram = NULL; in mpt_adapter_disable()
2761 ioc->raid_data.pIocPg3 = NULL; in mpt_adapter_disable()
2763 if (ioc->spi_data.pIocPg4 != NULL) { in mpt_adapter_disable()
2764 sz = ioc->spi_data.IocPg4Sz; in mpt_adapter_disable()
2765 dma_free_coherent(&ioc->pcidev->dev, sz, in mpt_adapter_disable()
2766 ioc->spi_data.pIocPg4, in mpt_adapter_disable()
2767 ioc->spi_data.IocPg4_dma); in mpt_adapter_disable()
2768 ioc->spi_data.pIocPg4 = NULL; in mpt_adapter_disable()
2769 ioc->alloc_total -= sz; in mpt_adapter_disable()
2772 if (ioc->ReqToChain != NULL) { in mpt_adapter_disable()
2773 kfree(ioc->ReqToChain); in mpt_adapter_disable()
2774 kfree(ioc->RequestNB); in mpt_adapter_disable()
2775 ioc->ReqToChain = NULL; in mpt_adapter_disable()
2778 kfree(ioc->ChainToChain); in mpt_adapter_disable()
2779 ioc->ChainToChain = NULL; in mpt_adapter_disable()
2781 if (ioc->HostPageBuffer != NULL) { in mpt_adapter_disable()
2786 ioc->name, __func__, ret); in mpt_adapter_disable()
2790 ioc->name, ioc->HostPageBuffer, in mpt_adapter_disable()
2791 ioc->HostPageBuffer_sz)); in mpt_adapter_disable()
2792 dma_free_coherent(&ioc->pcidev->dev, ioc->HostPageBuffer_sz, in mpt_adapter_disable()
2793 ioc->HostPageBuffer, ioc->HostPageBuffer_dma); in mpt_adapter_disable()
2794 ioc->HostPageBuffer = NULL; in mpt_adapter_disable()
2795 ioc->HostPageBuffer_sz = 0; in mpt_adapter_disable()
2796 ioc->alloc_total -= ioc->HostPageBuffer_sz; in mpt_adapter_disable()
2799 pci_set_drvdata(ioc->pcidev, NULL); in mpt_adapter_disable()
2801 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
2803 * mpt_adapter_dispose - Free all resources associated with an MPT adapter
2817 sz_first = ioc->alloc_total; in mpt_adapter_dispose()
2821 if (ioc->pci_irq != -1) { in mpt_adapter_dispose()
2822 free_irq(ioc->pci_irq, ioc); in mpt_adapter_dispose()
2823 if (ioc->msi_enable) in mpt_adapter_dispose()
2824 pci_disable_msi(ioc->pcidev); in mpt_adapter_dispose()
2825 ioc->pci_irq = -1; in mpt_adapter_dispose()
2828 if (ioc->memmap != NULL) { in mpt_adapter_dispose()
2829 iounmap(ioc->memmap); in mpt_adapter_dispose()
2830 ioc->memmap = NULL; in mpt_adapter_dispose()
2833 pci_disable_device(ioc->pcidev); in mpt_adapter_dispose()
2834 pci_release_selected_regions(ioc->pcidev, ioc->bars); in mpt_adapter_dispose()
2837 list_del(&ioc->list); in mpt_adapter_dispose()
2839 sz_last = ioc->alloc_total; in mpt_adapter_dispose()
2841 ioc->name, sz_first-sz_last+(int)sizeof(*ioc), sz_first)); in mpt_adapter_dispose()
2843 if (ioc->alt_ioc) in mpt_adapter_dispose()
2844 ioc->alt_ioc->alt_ioc = NULL; in mpt_adapter_dispose()
2849 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
2851 * MptDisplayIocCapabilities - Disply IOC's capabilities.
2859 printk(KERN_INFO "%s: ", ioc->name); in MptDisplayIocCapabilities()
2860 if (ioc->prod_name) in MptDisplayIocCapabilities()
2861 pr_cont("%s: ", ioc->prod_name); in MptDisplayIocCapabilities()
2864 if (ioc->pfacts[0].ProtocolFlags & MPI_PORTFACTS_PROTOCOL_INITIATOR) { in MptDisplayIocCapabilities()
2869 if (ioc->pfacts[0].ProtocolFlags & MPI_PORTFACTS_PROTOCOL_TARGET) { in MptDisplayIocCapabilities()
2874 if (ioc->pfacts[0].ProtocolFlags & MPI_PORTFACTS_PROTOCOL_LAN) { in MptDisplayIocCapabilities()
2883 if (ioc->pfacts[0].ProtocolFlags & MPI_PORTFACTS_PROTOCOL_TARGET) { in MptDisplayIocCapabilities()
2892 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
2894 * MakeIocReady - Get IOC to a READY state, using KickStart if needed.
2900 * 1 - DIAG reset and READY
2901 * 0 - READY initially OR soft reset and READY
2902 * -1 - Any failure on KickStart
2903 * -2 - Msg Unit Reset Failed
2904 * -3 - IO Unit Reset Failed
2905 * -4 - IOC owned by a PEER
2920 dhsprintk(ioc, printk(MYIOC_s_INFO_FMT "MakeIocReady [raw] state=%08x\n", ioc->name, ioc_state)); in MakeIocReady()
2929 ioc->name); in MakeIocReady()
2936 "IOC is in READY state\n", ioc->name)); in MakeIocReady()
2946 ioc->name); in MakeIocReady()
2948 ioc->name, ioc_state & MPI_DOORBELL_DATA_MASK); in MakeIocReady()
2956 ioc->name)); in MakeIocReady()
2966 ioc->name, whoinit, statefault, force)); in MakeIocReady()
2968 return -4; in MakeIocReady()
2980 return -1; in MakeIocReady()
2995 printk(MYIOC_s_ERR_FMT "IOC msg unit reset failed!\n", ioc->name); in MakeIocReady()
2996 return -2; in MakeIocReady()
3004 printk(MYIOC_s_ERR_FMT "IO unit reset failed!\n", ioc->name); in MakeIocReady()
3005 return -3; in MakeIocReady()
3009 ii++; cntdn--; in MakeIocReady()
3013 ioc->name, ioc_state, (int)((ii+5)/HZ)); in MakeIocReady()
3014 return -ETIME; in MakeIocReady()
3026 printk(MYIOC_s_INFO_FMT "Recovered from %s\n", ioc->name, in MakeIocReady()
3033 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
3035 * mpt_GetIocState - Get the current state of a MPT adapter.
3048 s = CHIPREG_READ32(&ioc->chip->Doorbell); in mpt_GetIocState()
3052 ioc->last_state = sc; in mpt_GetIocState()
3057 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
3059 * GetIocFacts - Send IOCFacts request to MPT adapter.
3064 * Returns 0 for success, non-zero for failure.
3079 if (ioc->last_state == MPI_IOC_STATE_RESET) { in GetIocFacts()
3081 ": ERROR - Can't get IOCFacts, %s NOT READY! (%08x)\n", in GetIocFacts()
3082 ioc->name, ioc->last_state); in GetIocFacts()
3083 return -44; in GetIocFacts()
3086 facts = &ioc->facts; in GetIocFacts()
3101 ioc->name, req_sz, reply_sz)); in GetIocFacts()
3103 /* No non-zero fields in the get_facts request are greater than in GetIocFacts()
3119 if (facts->MsgLength > offsetof(IOCFactsReply_t, RequestFrameSize)/sizeof(u32)) { in GetIocFacts()
3124 if (ioc->FirstWhoInit == WHOINIT_UNKNOWN) in GetIocFacts()
3125 ioc->FirstWhoInit = facts->WhoInit; in GetIocFacts()
3128 facts->MsgVersion = le16_to_cpu(facts->MsgVersion); in GetIocFacts()
3129 facts->MsgContext = le32_to_cpu(facts->MsgContext); in GetIocFacts()
3130 facts->IOCExceptions = le16_to_cpu(facts->IOCExceptions); in GetIocFacts()
3131 facts->IOCStatus = le16_to_cpu(facts->IOCStatus); in GetIocFacts()
3132 facts->IOCLogInfo = le32_to_cpu(facts->IOCLogInfo); in GetIocFacts()
3135 facts->ReplyQueueDepth = le16_to_cpu(facts->ReplyQueueDepth); in GetIocFacts()
3136 facts->RequestFrameSize = le16_to_cpu(facts->RequestFrameSize); in GetIocFacts()
3143 if (facts->MsgVersion < MPI_VERSION_01_02) { in GetIocFacts()
3147 u16 oldv = le16_to_cpu(facts->Reserved_0101_FWVersion); in GetIocFacts()
3148 facts->FWVersion.Word = in GetIocFacts()
3152 facts->FWVersion.Word = le32_to_cpu(facts->FWVersion.Word); in GetIocFacts()
3154 facts->ProductID = le16_to_cpu(facts->ProductID); in GetIocFacts()
3156 if ((ioc->facts.ProductID & MPI_FW_HEADER_PID_PROD_MASK) in GetIocFacts()
3158 ioc->ir_firmware = 1; in GetIocFacts()
3160 facts->CurrentHostMfaHighAddr = in GetIocFacts()
3161 le32_to_cpu(facts->CurrentHostMfaHighAddr); in GetIocFacts()
3162 facts->GlobalCredits = le16_to_cpu(facts->GlobalCredits); in GetIocFacts()
3163 facts->CurrentSenseBufferHighAddr = in GetIocFacts()
3164 le32_to_cpu(facts->CurrentSenseBufferHighAddr); in GetIocFacts()
3165 facts->CurReplyFrameSize = in GetIocFacts()
3166 le16_to_cpu(facts->CurReplyFrameSize); in GetIocFacts()
3167 facts->IOCCapabilities = le32_to_cpu(facts->IOCCapabilities); in GetIocFacts()
3170 * Handle NEW (!) IOCFactsReply fields in MPI-1.01.xx in GetIocFacts()
3171 * Older MPI-1.00.xx struct had 13 dwords, and enlarged in GetIocFacts()
3172 * to 14 in MPI-1.01.0x. in GetIocFacts()
3174 if (facts->MsgLength >= (offsetof(IOCFactsReply_t,FWImageSize) + 7)/4 && in GetIocFacts()
3175 facts->MsgVersion > MPI_VERSION_01_00) { in GetIocFacts()
3176 facts->FWImageSize = le32_to_cpu(facts->FWImageSize); in GetIocFacts()
3179 facts->FWImageSize = ALIGN(facts->FWImageSize, 4); in GetIocFacts()
3181 if (!facts->RequestFrameSize) { in GetIocFacts()
3184 ioc->name); in GetIocFacts()
3185 return -55; in GetIocFacts()
3188 r = sz = facts->BlockSize; in GetIocFacts()
3190 ioc->NB_for_64_byte_frame = vv; in GetIocFacts()
3196 ioc->NBShiftFactor = shiftFactor; in GetIocFacts()
3199 ioc->name, vv, shiftFactor, r)); in GetIocFacts()
3206 ioc->req_sz = min(MPT_DEFAULT_FRAME_SIZE, facts->RequestFrameSize * 4); in GetIocFacts()
3207 ioc->req_depth = min_t(int, MPT_MAX_REQ_DEPTH, facts->GlobalCredits); in GetIocFacts()
3208 ioc->reply_sz = MPT_REPLY_FRAME_SIZE; in GetIocFacts()
3209 ioc->reply_depth = min_t(int, MPT_DEFAULT_REPLY_DEPTH, facts->ReplyQueueDepth); in GetIocFacts()
3212 ioc->name, ioc->reply_sz, ioc->reply_depth)); in GetIocFacts()
3214 ioc->name, ioc->req_sz, ioc->req_depth)); in GetIocFacts()
3223 ioc->name, facts->MsgLength, (offsetof(IOCFactsReply_t, in GetIocFacts()
3225 return -66; in GetIocFacts()
3231 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
3233 * GetPortFacts - Send PortFacts request to MPT adapter.
3238 * Returns 0 for success, non-zero for failure.
3251 if (ioc->last_state == MPI_IOC_STATE_RESET) { in GetPortFacts()
3253 ioc->name, ioc->last_state ); in GetPortFacts()
3254 return -4; in GetPortFacts()
3257 pfacts = &ioc->pfacts[portnum]; in GetPortFacts()
3272 ioc->name, portnum)); in GetPortFacts()
3274 /* No non-zero fields in the get_pfacts request are greater than in GetPortFacts()
3285 pfacts->MsgContext = le32_to_cpu(pfacts->MsgContext); in GetPortFacts()
3286 pfacts->IOCStatus = le16_to_cpu(pfacts->IOCStatus); in GetPortFacts()
3287 pfacts->IOCLogInfo = le32_to_cpu(pfacts->IOCLogInfo); in GetPortFacts()
3288 pfacts->MaxDevices = le16_to_cpu(pfacts->MaxDevices); in GetPortFacts()
3289 pfacts->PortSCSIID = le16_to_cpu(pfacts->PortSCSIID); in GetPortFacts()
3290 pfacts->ProtocolFlags = le16_to_cpu(pfacts->ProtocolFlags); in GetPortFacts()
3291 pfacts->MaxPostedCmdBuffers = le16_to_cpu(pfacts->MaxPostedCmdBuffers); in GetPortFacts()
3292 pfacts->MaxPersistentIDs = le16_to_cpu(pfacts->MaxPersistentIDs); in GetPortFacts()
3293 pfacts->MaxLanBuckets = le16_to_cpu(pfacts->MaxLanBuckets); in GetPortFacts()
3295 max_id = (ioc->bus_type == SAS) ? pfacts->PortSCSIID : in GetPortFacts()
3296 pfacts->MaxDevices; in GetPortFacts()
3297 ioc->devices_per_bus = (max_id > 255) ? 256 : max_id; in GetPortFacts()
3298 ioc->number_of_buses = (ioc->devices_per_bus < 256) ? 1 : max_id/256; in GetPortFacts()
3306 ioc->devices_per_bus = 1; in GetPortFacts()
3307 ioc->number_of_buses = (max_id > 255) ? 255 : max_id; in GetPortFacts()
3313 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
3315 * SendIocInit - Send IOCInit request to MPT adapter.
3321 * Returns 0 for success, non-zero for failure.
3343 if (ioc->facts.Flags & MPI_IOCFACTS_FLAGS_FW_DOWNLOAD_BOOT) in SendIocInit()
3344 ioc->upload_fw = 1; in SendIocInit()
3346 ioc->upload_fw = 0; in SendIocInit()
3348 ioc->name, ioc->upload_fw, ioc->facts.Flags)); in SendIocInit()
3350 ioc_init.MaxDevices = (U8)ioc->devices_per_bus; in SendIocInit()
3351 ioc_init.MaxBuses = (U8)ioc->number_of_buses; in SendIocInit()
3354 ioc->name, ioc->facts.MsgVersion)); in SendIocInit()
3355 if (ioc->facts.MsgVersion >= MPI_VERSION_01_05) { in SendIocInit()
3360 if (ioc->facts.Flags & MPI_IOCFACTS_FLAGS_HOST_PAGE_BUFFER_PERSISTENT) { in SendIocInit()
3361 ioc_init.HostPageBufferSGE = ioc->facts.HostPageBufferSGE; in SendIocInit()
3363 return -99; in SendIocInit()
3365 ioc_init.ReplyFrameSize = cpu_to_le16(ioc->reply_sz); /* in BYTES */ in SendIocInit()
3367 if (ioc->sg_addr_size == sizeof(u64)) { in SendIocInit()
3368 /* Save the upper 32-bits of the request in SendIocInit()
3371 ioc_init.HostMfaHighAddr = cpu_to_le32((u32)((u64)ioc->alloc_dma >> 32)); in SendIocInit()
3372 ioc_init.SenseBufferHighAddr = cpu_to_le32((u32)((u64)ioc->sense_buf_pool_dma >> 32)); in SendIocInit()
3374 /* Force 32-bit addressing */ in SendIocInit()
3379 ioc->facts.CurrentHostMfaHighAddr = ioc_init.HostMfaHighAddr; in SendIocInit()
3380 ioc->facts.CurrentSenseBufferHighAddr = ioc_init.SenseBufferHighAddr; in SendIocInit()
3381 ioc->facts.MaxDevices = ioc_init.MaxDevices; in SendIocInit()
3382 ioc->facts.MaxBuses = ioc_init.MaxBuses; in SendIocInit()
3384 dhsprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Sending IOCInit (req @ %p)\n", in SendIocInit()
3385 ioc->name, &ioc_init)); in SendIocInit()
3390 printk(MYIOC_s_ERR_FMT "Sending IOCInit failed(%d)!\n",ioc->name, r); in SendIocInit()
3398 dhsprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Sending PortEnable (req @ %p)\n", in SendIocInit()
3399 ioc->name, &ioc_init)); in SendIocInit()
3402 printk(MYIOC_s_ERR_FMT "Sending PortEnable failed(%d)!\n",ioc->name, r); in SendIocInit()
3413 while (state != MPI_IOC_STATE_OPERATIONAL && --cntdn) { in SendIocInit()
3422 ioc->name, (int)((count+5)/HZ)); in SendIocInit()
3423 return -9; in SendIocInit()
3430 ioc->name, count)); in SendIocInit()
3432 ioc->aen_event_read_flag=0; in SendIocInit()
3436 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
3438 * SendPortEnable - Send PortEnable request to MPT adapter port.
3445 * Returns 0 for success, non-zero for failure.
3469 dinitprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Sending Port(%d)Enable (req @ %p)\n", in SendPortEnable()
3470 ioc->name, portnum, &port_enable)); in SendPortEnable()
3474 if (ioc->ir_firmware || ioc->bus_type == SAS) { in SendPortEnable()
3487 * mpt_alloc_fw_memory - allocate firmware memory
3494 * Return 0 if successful, or non-zero for failure
3501 if (ioc->cached_fw) { in mpt_alloc_fw_memory()
3505 else if (ioc->alt_ioc && ioc->alt_ioc->cached_fw) { in mpt_alloc_fw_memory()
3506 ioc->cached_fw = ioc->alt_ioc->cached_fw; /* use alt_ioc's memory */ in mpt_alloc_fw_memory()
3507 ioc->cached_fw_dma = ioc->alt_ioc->cached_fw_dma; in mpt_alloc_fw_memory()
3511 ioc->cached_fw = dma_alloc_coherent(&ioc->pcidev->dev, size, in mpt_alloc_fw_memory()
3512 &ioc->cached_fw_dma, GFP_ATOMIC); in mpt_alloc_fw_memory()
3513 if (!ioc->cached_fw) { in mpt_alloc_fw_memory()
3515 ioc->name); in mpt_alloc_fw_memory()
3516 rc = -1; in mpt_alloc_fw_memory()
3519 ioc->name, ioc->cached_fw, (void *)(ulong)ioc->cached_fw_dma, size, size)); in mpt_alloc_fw_memory()
3520 ioc->alloc_total += size; in mpt_alloc_fw_memory()
3528 * mpt_free_fw_memory - free firmware memory
3539 if (!ioc->cached_fw) in mpt_free_fw_memory()
3542 sz = ioc->facts.FWImageSize; in mpt_free_fw_memory()
3544 ioc->name, ioc->cached_fw, (void *)(ulong)ioc->cached_fw_dma, sz, sz)); in mpt_free_fw_memory()
3545 dma_free_coherent(&ioc->pcidev->dev, sz, ioc->cached_fw, in mpt_free_fw_memory()
3546 ioc->cached_fw_dma); in mpt_free_fw_memory()
3547 ioc->alloc_total -= sz; in mpt_free_fw_memory()
3548 ioc->cached_fw = NULL; in mpt_free_fw_memory()
3551 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
3553 * mpt_do_upload - Construct and Send FWUpload request to MPT adapter port.
3578 if ((sz = ioc->facts.FWImageSize) == 0) in mpt_do_upload()
3581 if (mpt_alloc_fw_memory(ioc, ioc->facts.FWImageSize) != 0) in mpt_do_upload()
3582 return -ENOMEM; in mpt_do_upload()
3585 ioc->name, ioc->cached_fw, (void *)(ulong)ioc->cached_fw_dma, sz, sz)); in mpt_do_upload()
3587 prequest = (sleepFlag == NO_SLEEP) ? kzalloc(ioc->req_sz, GFP_ATOMIC) : in mpt_do_upload()
3588 kzalloc(ioc->req_sz, GFP_KERNEL); in mpt_do_upload()
3591 "while allocating memory \n", ioc->name)); in mpt_do_upload()
3593 return -ENOMEM; in mpt_do_upload()
3601 prequest->ImageType = MPI_FW_UPLOAD_ITYPE_FW_IOC_MEM; in mpt_do_upload()
3602 prequest->Function = MPI_FUNCTION_FW_UPLOAD; in mpt_do_upload()
3604 ptcsge = (FWUploadTCSGE_t *) &prequest->SGL; in mpt_do_upload()
3605 ptcsge->DetailsLength = 12; in mpt_do_upload()
3606 ptcsge->Flags = MPI_SGE_FLAGS_TRANSACTION_ELEMENT; in mpt_do_upload()
3607 ptcsge->ImageSize = cpu_to_le32(sz); in mpt_do_upload()
3611 ioc->add_sge((char *)ptcsge, flagsLength, ioc->cached_fw_dma); in mpt_do_upload()
3613 ioc->SGE_size; in mpt_do_upload()
3615 " (req @ %p) fw_size=%d mf_request_size=%d\n", ioc->name, prequest, in mpt_do_upload()
3616 ioc->facts.FWImageSize, request_size)); in mpt_do_upload()
3623 "rc=%x \n", ioc->name, ii)); in mpt_do_upload()
3625 cmdStatus = -EFAULT; in mpt_do_upload()
3631 status = le16_to_cpu(preply->IOCStatus) & in mpt_do_upload()
3634 ioc->facts.FWImageSize == in mpt_do_upload()
3635 le32_to_cpu(preply->ActualImageSize)) in mpt_do_upload()
3639 ioc->name, cmdStatus)); in mpt_do_upload()
3644 "freeing image \n", ioc->name)); in mpt_do_upload()
3652 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
3654 * mpt_downloadboot - DownloadBoot code
3662 * -1 FW Image size is 0
3663 * -2 No valid cached_fw Pointer
3680 ioc->name, pFwHeader->ImageSize, pFwHeader->ImageSize, pFwHeader)); in mpt_downloadboot()
3682 CHIPREG_WRITE32(&ioc->chip->WriteSequence, 0xFF); in mpt_downloadboot()
3683 CHIPREG_WRITE32(&ioc->chip->WriteSequence, MPI_WRSEQ_1ST_KEY_VALUE); in mpt_downloadboot()
3684 CHIPREG_WRITE32(&ioc->chip->WriteSequence, MPI_WRSEQ_2ND_KEY_VALUE); in mpt_downloadboot()
3685 CHIPREG_WRITE32(&ioc->chip->WriteSequence, MPI_WRSEQ_3RD_KEY_VALUE); in mpt_downloadboot()
3686 CHIPREG_WRITE32(&ioc->chip->WriteSequence, MPI_WRSEQ_4TH_KEY_VALUE); in mpt_downloadboot()
3687 CHIPREG_WRITE32(&ioc->chip->WriteSequence, MPI_WRSEQ_5TH_KEY_VALUE); in mpt_downloadboot()
3689 CHIPREG_WRITE32(&ioc->chip->Diagnostic, (MPI_DIAG_PREVENT_IOC_BOOT | MPI_DIAG_DISABLE_ARM)); in mpt_downloadboot()
3698 diag0val = CHIPREG_READ32(&ioc->chip->Diagnostic); in mpt_downloadboot()
3699 CHIPREG_WRITE32(&ioc->chip->Diagnostic, diag0val | MPI_DIAG_RESET_ADAPTER); in mpt_downloadboot()
3702 diag0val = CHIPREG_READ32(&ioc->chip->Diagnostic); in mpt_downloadboot()
3705 ioc->name, count)); in mpt_downloadboot()
3719 ioc->name, diag0val)); in mpt_downloadboot()
3720 return -3; in mpt_downloadboot()
3723 CHIPREG_WRITE32(&ioc->chip->WriteSequence, 0xFF); in mpt_downloadboot()
3724 CHIPREG_WRITE32(&ioc->chip->WriteSequence, MPI_WRSEQ_1ST_KEY_VALUE); in mpt_downloadboot()
3725 CHIPREG_WRITE32(&ioc->chip->WriteSequence, MPI_WRSEQ_2ND_KEY_VALUE); in mpt_downloadboot()
3726 CHIPREG_WRITE32(&ioc->chip->WriteSequence, MPI_WRSEQ_3RD_KEY_VALUE); in mpt_downloadboot()
3727 CHIPREG_WRITE32(&ioc->chip->WriteSequence, MPI_WRSEQ_4TH_KEY_VALUE); in mpt_downloadboot()
3728 CHIPREG_WRITE32(&ioc->chip->WriteSequence, MPI_WRSEQ_5TH_KEY_VALUE); in mpt_downloadboot()
3731 CHIPREG_WRITE32(&ioc->chip->Diagnostic, (MPI_DIAG_RW_ENABLE | MPI_DIAG_DISABLE_ARM)); in mpt_downloadboot()
3733 fwSize = (pFwHeader->ImageSize + 3)/4; in mpt_downloadboot()
3739 if (ioc->errata_flag_1064) in mpt_downloadboot()
3740 pci_enable_io_access(ioc->pcidev); in mpt_downloadboot()
3742 CHIPREG_PIO_WRITE32(&ioc->pio_chip->DiagRwAddress, pFwHeader->LoadStartAddress); in mpt_downloadboot()
3744 ioc->name, pFwHeader->LoadStartAddress)); in mpt_downloadboot()
3747 ioc->name, fwSize*4, ptrFw)); in mpt_downloadboot()
3748 while (fwSize--) { in mpt_downloadboot()
3749 CHIPREG_PIO_WRITE32(&ioc->pio_chip->DiagRwData, *ptrFw++); in mpt_downloadboot()
3752 nextImage = pFwHeader->NextImageHeaderOffset; in mpt_downloadboot()
3756 load_addr = pExtImage->LoadStartAddress; in mpt_downloadboot()
3758 fwSize = (pExtImage->ImageSize + 3) >> 2; in mpt_downloadboot()
3762 ioc->name, fwSize*4, fwSize*4, ptrFw, load_addr)); in mpt_downloadboot()
3763 CHIPREG_PIO_WRITE32(&ioc->pio_chip->DiagRwAddress, load_addr); in mpt_downloadboot()
3765 while (fwSize--) { in mpt_downloadboot()
3766 CHIPREG_PIO_WRITE32(&ioc->pio_chip->DiagRwData, *ptrFw++); in mpt_downloadboot()
3768 nextImage = pExtImage->NextImageHeaderOffset; in mpt_downloadboot()
3772 …ddlprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Write IopResetVector Addr=%x! \n", ioc->name, pFwHeader- in mpt_downloadboot()
3773 CHIPREG_PIO_WRITE32(&ioc->pio_chip->DiagRwAddress, pFwHeader->IopResetRegAddr); in mpt_downloadboot()
3776 …ddlprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Write IopResetVector Value=%x! \n", ioc->name, pFwHeader- in mpt_downloadboot()
3777 CHIPREG_PIO_WRITE32(&ioc->pio_chip->DiagRwData, pFwHeader->IopResetVectorValue); in mpt_downloadboot()
3779 /* Clear the internal flash bad bit - autoincrementing register, in mpt_downloadboot()
3782 if (ioc->bus_type == SPI) { in mpt_downloadboot()
3787 CHIPREG_PIO_WRITE32(&ioc->pio_chip->DiagRwAddress, 0x3F000000); in mpt_downloadboot()
3788 diagRwData = CHIPREG_PIO_READ32(&ioc->pio_chip->DiagRwData); in mpt_downloadboot()
3790 CHIPREG_PIO_WRITE32(&ioc->pio_chip->DiagRwAddress, 0x3F000000); in mpt_downloadboot()
3791 CHIPREG_PIO_WRITE32(&ioc->pio_chip->DiagRwData, diagRwData); in mpt_downloadboot()
3793 } else /* if((ioc->bus_type == SAS) || (ioc->bus_type == FC)) */ { in mpt_downloadboot()
3794 diag0val = CHIPREG_READ32(&ioc->chip->Diagnostic); in mpt_downloadboot()
3795 CHIPREG_WRITE32(&ioc->chip->Diagnostic, diag0val | in mpt_downloadboot()
3806 if (ioc->errata_flag_1064) in mpt_downloadboot()
3807 pci_disable_io_access(ioc->pcidev); in mpt_downloadboot()
3809 diag0val = CHIPREG_READ32(&ioc->chip->Diagnostic); in mpt_downloadboot()
3812 ioc->name, diag0val)); in mpt_downloadboot()
3815 ioc->name, diag0val)); in mpt_downloadboot()
3816 CHIPREG_WRITE32(&ioc->chip->Diagnostic, diag0val); in mpt_downloadboot()
3819 CHIPREG_WRITE32(&ioc->chip->WriteSequence, 0xFF); in mpt_downloadboot()
3821 if (ioc->bus_type == SAS) { in mpt_downloadboot()
3826 ioc->name, ioc_state)); in mpt_downloadboot()
3827 return -EFAULT; in mpt_downloadboot()
3835 ioc->name, count, ioc_state)); in mpt_downloadboot()
3836 if (ioc->bus_type == SAS) { in mpt_downloadboot()
3842 ioc->name)); in mpt_downloadboot()
3843 return -EFAULT; in mpt_downloadboot()
3847 ioc->name)); in mpt_downloadboot()
3857 "downloadboot failed! IocState=%x\n",ioc->name, ioc_state)); in mpt_downloadboot()
3858 return -EFAULT; in mpt_downloadboot()
3861 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
3863 * KickStart - Perform hard reset of MPT adapter.
3872 * Inputs: sleepflag - CAN_SLEEP (non-interrupt thread)
3874 * force - 1 if doorbell active, board fault state
3880 * 1 - hard reset, READY
3881 * 0 - no reset due to History bit, READY
3882 * -1 - no reset due to History bit but not READY
3884 * -2 - no reset, could not enter DIAG mode
3885 * -3 - reset but bad FW bit
3894 dinitprintk(ioc, printk(MYIOC_s_DEBUG_FMT "KickStarting!\n", ioc->name)); in KickStart()
3895 if (ioc->bus_type == SPI) { in KickStart()
3913 ioc->name)); in KickStart()
3920 ioc->name, cnt)); in KickStart()
3931 ioc->name, mpt_GetIocState(ioc, 0))); in KickStart()
3932 return -1; in KickStart()
3935 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
3937 * mpt_diag_reset - Perform hard reset of the adapter.
3941 * @sleepFlag: CAN_SLEEP if called in a non-interrupt thread,
3951 * -2 enabling diagnostic mode failed
3952 * -3 diagnostic reset failed
3966 CHIPREG_WRITE32(&ioc->chip->IntStatus, 0); in mpt_diag_reset()
3968 if (ioc->pcidev->device == MPI_MANUFACTPAGE_DEVID_SAS1078) { in mpt_diag_reset()
3974 "address=%p\n", ioc->name, __func__, in mpt_diag_reset()
3975 &ioc->chip->Doorbell, &ioc->chip->Reset_1078)); in mpt_diag_reset()
3976 CHIPREG_WRITE32(&ioc->chip->Reset_1078, 0x07); in mpt_diag_reset()
3984 * with pre-reset indication. in mpt_diag_reset()
3988 for (cb_idx = MPT_MAX_PROTOCOL_DRIVERS-1; cb_idx; cb_idx--) { in mpt_diag_reset()
3995 doorbell = CHIPREG_READ32(&ioc->chip->Doorbell); in mpt_diag_reset()
4001 ioc->name, doorbell, count)); in mpt_diag_reset()
4013 return -1; in mpt_diag_reset()
4017 diag0val = CHIPREG_READ32(&ioc->chip->Diagnostic); in mpt_diag_reset()
4019 if (ioc->debug_level & MPT_DEBUG) { in mpt_diag_reset()
4020 if (ioc->alt_ioc) in mpt_diag_reset()
4021 diag1val = CHIPREG_READ32(&ioc->alt_ioc->chip->Diagnostic); in mpt_diag_reset()
4023 ioc->name, diag0val, diag1val)); in mpt_diag_reset()
4034 CHIPREG_WRITE32(&ioc->chip->WriteSequence, 0xFF); in mpt_diag_reset()
4035 CHIPREG_WRITE32(&ioc->chip->WriteSequence, MPI_WRSEQ_1ST_KEY_VALUE); in mpt_diag_reset()
4036 CHIPREG_WRITE32(&ioc->chip->WriteSequence, MPI_WRSEQ_2ND_KEY_VALUE); in mpt_diag_reset()
4037 CHIPREG_WRITE32(&ioc->chip->WriteSequence, MPI_WRSEQ_3RD_KEY_VALUE); in mpt_diag_reset()
4038 CHIPREG_WRITE32(&ioc->chip->WriteSequence, MPI_WRSEQ_4TH_KEY_VALUE); in mpt_diag_reset()
4039 CHIPREG_WRITE32(&ioc->chip->WriteSequence, MPI_WRSEQ_5TH_KEY_VALUE); in mpt_diag_reset()
4051 ioc->name, diag0val); in mpt_diag_reset()
4052 return -2; in mpt_diag_reset()
4056 diag0val = CHIPREG_READ32(&ioc->chip->Diagnostic); in mpt_diag_reset()
4059 ioc->name, diag0val)); in mpt_diag_reset()
4062 if (ioc->debug_level & MPT_DEBUG) { in mpt_diag_reset()
4063 if (ioc->alt_ioc) in mpt_diag_reset()
4064 diag1val = CHIPREG_READ32(&ioc->alt_ioc->chip->Diagnostic); in mpt_diag_reset()
4066 ioc->name, diag0val, diag1val)); in mpt_diag_reset()
4072 CHIPREG_WRITE32(&ioc->chip->Diagnostic, diag0val | MPI_DIAG_DISABLE_ARM); in mpt_diag_reset()
4079 CHIPREG_WRITE32(&ioc->chip->Diagnostic, diag0val | MPI_DIAG_RESET_ADAPTER); in mpt_diag_reset()
4082 ioc->name)); in mpt_diag_reset()
4086 * with pre-reset indication. in mpt_diag_reset()
4090 for (cb_idx = MPT_MAX_PROTOCOL_DRIVERS-1; cb_idx; cb_idx--) { in mpt_diag_reset()
4094 if (ioc->alt_ioc) { in mpt_diag_reset()
4096 ioc->alt_ioc, MPT_IOC_PRE_RESET); in mpt_diag_reset()
4101 if (ioc->cached_fw) in mpt_diag_reset()
4102 cached_fw = (MpiFwHeader_t *)ioc->cached_fw; in mpt_diag_reset()
4103 else if (ioc->alt_ioc && ioc->alt_ioc->cached_fw) in mpt_diag_reset()
4104 cached_fw = (MpiFwHeader_t *)ioc->alt_ioc->cached_fw; in mpt_diag_reset()
4113 diag0val = CHIPREG_READ32(&ioc->chip->Diagnostic); in mpt_diag_reset()
4119 ioc->name, diag0val, count)); in mpt_diag_reset()
4129 "firmware downloadboot failure (%d)!\n", ioc->name, count); in mpt_diag_reset()
4140 doorbell = CHIPREG_READ32(&ioc->chip->Doorbell); in mpt_diag_reset()
4145 " count=%d\n", ioc->name, doorbell, count)); in mpt_diag_reset()
4161 "after reset! IocState=%x", ioc->name, in mpt_diag_reset()
4166 diag0val = CHIPREG_READ32(&ioc->chip->Diagnostic); in mpt_diag_reset()
4167 if (ioc->debug_level & MPT_DEBUG) { in mpt_diag_reset()
4168 if (ioc->alt_ioc) in mpt_diag_reset()
4169 diag1val = CHIPREG_READ32(&ioc->alt_ioc->chip->Diagnostic); in mpt_diag_reset()
4171 ioc->name, diag0val, diag1val)); in mpt_diag_reset()
4177 diag0val = CHIPREG_READ32(&ioc->chip->Diagnostic); in mpt_diag_reset()
4183 CHIPREG_WRITE32(&ioc->chip->WriteSequence, 0xFF); in mpt_diag_reset()
4184 CHIPREG_WRITE32(&ioc->chip->WriteSequence, MPI_WRSEQ_1ST_KEY_VALUE); in mpt_diag_reset()
4185 CHIPREG_WRITE32(&ioc->chip->WriteSequence, MPI_WRSEQ_2ND_KEY_VALUE); in mpt_diag_reset()
4186 CHIPREG_WRITE32(&ioc->chip->WriteSequence, MPI_WRSEQ_3RD_KEY_VALUE); in mpt_diag_reset()
4187 CHIPREG_WRITE32(&ioc->chip->WriteSequence, MPI_WRSEQ_4TH_KEY_VALUE); in mpt_diag_reset()
4188 CHIPREG_WRITE32(&ioc->chip->WriteSequence, MPI_WRSEQ_5TH_KEY_VALUE); in mpt_diag_reset()
4200 ioc->name, diag0val); in mpt_diag_reset()
4203 diag0val = CHIPREG_READ32(&ioc->chip->Diagnostic); in mpt_diag_reset()
4206 CHIPREG_WRITE32(&ioc->chip->Diagnostic, diag0val); in mpt_diag_reset()
4207 diag0val = CHIPREG_READ32(&ioc->chip->Diagnostic); in mpt_diag_reset()
4210 ioc->name); in mpt_diag_reset()
4215 CHIPREG_WRITE32(&ioc->chip->WriteSequence, 0xFFFFFFFF); in mpt_diag_reset()
4219 diag0val = CHIPREG_READ32(&ioc->chip->Diagnostic); in mpt_diag_reset()
4222 ioc->name, diag0val); in mpt_diag_reset()
4223 return -3; in mpt_diag_reset()
4226 if (ioc->debug_level & MPT_DEBUG) { in mpt_diag_reset()
4227 if (ioc->alt_ioc) in mpt_diag_reset()
4228 diag1val = CHIPREG_READ32(&ioc->alt_ioc->chip->Diagnostic); in mpt_diag_reset()
4230 ioc->name, diag0val, diag1val)); in mpt_diag_reset()
4236 ioc->facts.EventState = 0; in mpt_diag_reset()
4238 if (ioc->alt_ioc) in mpt_diag_reset()
4239 ioc->alt_ioc->facts.EventState = 0; in mpt_diag_reset()
4244 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
4246 * SendIocReset - Send IOCReset request to MPT adapter.
4254 * Returns 0 for success, non-zero for failure.
4264 ioc->name, reset_type)); in SendIocReset()
4265 CHIPREG_WRITE32(&ioc->chip->Doorbell, reset_type<<MPI_DOORBELL_FUNCTION_SHIFT); in SendIocReset()
4275 cntdn--; in SendIocReset()
4283 ioc->name, state, (int)((count+5)/HZ)); in SendIocReset()
4284 return -ETIME; in SendIocReset()
4295 * Cleanup all event stuff for this IOC; re-issue EventNotification in SendIocReset()
4298 if (ioc->facts.Function) in SendIocReset()
4299 ioc->facts.EventState = 0; in SendIocReset()
4304 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
4306 * initChainBuffers - Allocate memory for and initialize chain buffers
4322 if (ioc->ReqToChain == NULL) { in initChainBuffers()
4323 sz = ioc->req_depth * sizeof(int); in initChainBuffers()
4326 return -1; in initChainBuffers()
4328 ioc->ReqToChain = (int *) mem; in initChainBuffers()
4330 ioc->name, mem, sz)); in initChainBuffers()
4333 return -1; in initChainBuffers()
4335 ioc->RequestNB = (int *) mem; in initChainBuffers()
4337 ioc->name, mem, sz)); in initChainBuffers()
4339 for (ii = 0; ii < ioc->req_depth; ii++) { in initChainBuffers()
4340 ioc->ReqToChain[ii] = MPT_HOST_NO_CHAIN; in initChainBuffers()
4353 scale = ioc->req_sz / ioc->SGE_size; in initChainBuffers()
4354 if (ioc->sg_addr_size == sizeof(u64)) in initChainBuffers()
4355 num_sge = scale + (ioc->req_sz - 60) / ioc->SGE_size; in initChainBuffers()
4357 num_sge = 1 + scale + (ioc->req_sz - 64) / ioc->SGE_size; in initChainBuffers()
4359 if (ioc->sg_addr_size == sizeof(u64)) { in initChainBuffers()
4360 numSGE = (scale - 1) * (ioc->facts.MaxChainDepth-1) + scale + in initChainBuffers()
4361 (ioc->req_sz - 60) / ioc->SGE_size; in initChainBuffers()
4363 numSGE = 1 + (scale - 1) * (ioc->facts.MaxChainDepth-1) + in initChainBuffers()
4364 scale + (ioc->req_sz - 64) / ioc->SGE_size; in initChainBuffers()
4367 ioc->name, num_sge, numSGE)); in initChainBuffers()
4369 if (ioc->bus_type == FC) { in initChainBuffers()
4378 while (numSGE - num_sge > 0) { in initChainBuffers()
4380 num_sge += (scale - 1); in initChainBuffers()
4385 ioc->name, numSGE, num_sge, num_chain)); in initChainBuffers()
4387 if (ioc->bus_type == SPI) in initChainBuffers()
4389 else if (ioc->bus_type == SAS) in initChainBuffers()
4394 ioc->num_chain = num_chain; in initChainBuffers()
4397 if (ioc->ChainToChain == NULL) { in initChainBuffers()
4400 return -1; in initChainBuffers()
4402 ioc->ChainToChain = (int *) mem; in initChainBuffers()
4404 ioc->name, mem, sz)); in initChainBuffers()
4406 mem = (u8 *) ioc->ChainToChain; in initChainBuffers()
4412 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
4414 * PrimeIocFifos - Initialize IOC request and reply FIFOs.
4421 * Returns 0 for success, non-zero for failure.
4437 if (ioc->reply_frames == NULL) { in PrimeIocFifos()
4439 return -1; in PrimeIocFifos()
4443 if (ioc->pcidev->device == MPI_MANUFACTPAGE_DEVID_SAS1078 && in PrimeIocFifos()
4444 ioc->dma_mask > DMA_BIT_MASK(35)) { in PrimeIocFifos()
4445 if (!dma_set_mask(&ioc->pcidev->dev, DMA_BIT_MASK(32)) in PrimeIocFifos()
4446 && !dma_set_coherent_mask(&ioc->pcidev->dev, DMA_BIT_MASK(32))) { in PrimeIocFifos()
4451 ioc->name)); in PrimeIocFifos()
4454 dma_set_mask(&ioc->pcidev->dev, in PrimeIocFifos()
4456 dma_set_coherent_mask(&ioc->pcidev->dev, in PrimeIocFifos()
4462 ioc->name); in PrimeIocFifos()
4463 return -1; in PrimeIocFifos()
4467 total_size = reply_sz = (ioc->reply_sz * ioc->reply_depth); in PrimeIocFifos()
4469 ioc->name, ioc->reply_sz, ioc->reply_depth)); in PrimeIocFifos()
4471 ioc->name, reply_sz, reply_sz)); in PrimeIocFifos()
4473 sz = (ioc->req_sz * ioc->req_depth); in PrimeIocFifos()
4475 ioc->name, ioc->req_sz, ioc->req_depth)); in PrimeIocFifos()
4477 ioc->name, sz, sz)); in PrimeIocFifos()
4480 sz = num_chain * ioc->req_sz; /* chain buffer pool size */ in PrimeIocFifos()
4482 ioc->name, ioc->req_sz, num_chain)); in PrimeIocFifos()
4484 ioc->name, sz, sz, num_chain)); in PrimeIocFifos()
4487 mem = dma_alloc_coherent(&ioc->pcidev->dev, total_size, in PrimeIocFifos()
4491 ioc->name); in PrimeIocFifos()
4496 ioc->name, mem, (void *)(ulong)alloc_dma, total_size, total_size)); in PrimeIocFifos()
4499 ioc->alloc_total += total_size; in PrimeIocFifos()
4500 ioc->alloc = mem; in PrimeIocFifos()
4501 ioc->alloc_dma = alloc_dma; in PrimeIocFifos()
4502 ioc->alloc_sz = total_size; in PrimeIocFifos()
4503 ioc->reply_frames = (MPT_FRAME_HDR *) mem; in PrimeIocFifos()
4504 ioc->reply_frames_low_dma = (u32) (alloc_dma & 0xFFFFFFFF); in PrimeIocFifos()
4507 ioc->name, ioc->reply_frames, (void *)(ulong)alloc_dma)); in PrimeIocFifos()
4512 /* Request FIFO - WE manage this! */ in PrimeIocFifos()
4514 ioc->req_frames = (MPT_FRAME_HDR *) mem; in PrimeIocFifos()
4515 ioc->req_frames_dma = alloc_dma; in PrimeIocFifos()
4518 ioc->name, mem, (void *)(ulong)alloc_dma)); in PrimeIocFifos()
4520 ioc->req_frames_low_dma = (u32) (alloc_dma & 0xFFFFFFFF); in PrimeIocFifos()
4522 for (i = 0; i < ioc->req_depth; i++) { in PrimeIocFifos()
4523 alloc_dma += ioc->req_sz; in PrimeIocFifos()
4524 mem += ioc->req_sz; in PrimeIocFifos()
4527 ioc->ChainBuffer = mem; in PrimeIocFifos()
4528 ioc->ChainBufferDMA = alloc_dma; in PrimeIocFifos()
4531 ioc->name, ioc->ChainBuffer, (void *)(ulong)ioc->ChainBufferDMA)); in PrimeIocFifos()
4536 INIT_LIST_HEAD(&ioc->FreeChainQ); in PrimeIocFifos()
4540 mem = (u8 *)ioc->ChainBuffer; in PrimeIocFifos()
4543 list_add_tail(&mf->u.frame.linkage.list, &ioc->FreeChainQ); in PrimeIocFifos()
4544 mem += ioc->req_sz; in PrimeIocFifos()
4549 alloc_dma = ioc->req_frames_dma; in PrimeIocFifos()
4550 mem = (u8 *) ioc->req_frames; in PrimeIocFifos()
4552 spin_lock_irqsave(&ioc->FreeQlock, flags); in PrimeIocFifos()
4553 INIT_LIST_HEAD(&ioc->FreeQ); in PrimeIocFifos()
4554 for (i = 0; i < ioc->req_depth; i++) { in PrimeIocFifos()
4558 list_add_tail(&mf->u.frame.linkage.list, &ioc->FreeQ); in PrimeIocFifos()
4560 mem += ioc->req_sz; in PrimeIocFifos()
4562 spin_unlock_irqrestore(&ioc->FreeQlock, flags); in PrimeIocFifos()
4564 sz = (ioc->req_depth * MPT_SENSE_BUFFER_ALLOC); in PrimeIocFifos()
4565 ioc->sense_buf_pool = dma_alloc_coherent(&ioc->pcidev->dev, sz, in PrimeIocFifos()
4566 &ioc->sense_buf_pool_dma, GFP_KERNEL); in PrimeIocFifos()
4567 if (ioc->sense_buf_pool == NULL) { in PrimeIocFifos()
4569 ioc->name); in PrimeIocFifos()
4573 ioc->sense_buf_low_dma = (u32) (ioc->sense_buf_pool_dma & 0xFFFFFFFF); in PrimeIocFifos()
4574 ioc->alloc_total += sz; in PrimeIocFifos()
4576 ioc->name, ioc->sense_buf_pool, (void *)(ulong)ioc->sense_buf_pool_dma)); in PrimeIocFifos()
4582 alloc_dma = ioc->alloc_dma; in PrimeIocFifos()
4584 ioc->name, ioc->reply_frames, (void *)(ulong)alloc_dma)); in PrimeIocFifos()
4586 for (i = 0; i < ioc->reply_depth; i++) { in PrimeIocFifos()
4588 CHIPREG_WRITE32(&ioc->chip->ReplyFifo, alloc_dma); in PrimeIocFifos()
4589 alloc_dma += ioc->reply_sz; in PrimeIocFifos()
4592 if (dma_mask == DMA_BIT_MASK(35) && !dma_set_mask(&ioc->pcidev->dev, in PrimeIocFifos()
4593 ioc->dma_mask) && !dma_set_coherent_mask(&ioc->pcidev->dev, in PrimeIocFifos()
4594 ioc->dma_mask)) in PrimeIocFifos()
4596 "restoring 64 bit addressing\n", ioc->name)); in PrimeIocFifos()
4602 if (ioc->alloc != NULL) { in PrimeIocFifos()
4603 sz = ioc->alloc_sz; in PrimeIocFifos()
4604 dma_free_coherent(&ioc->pcidev->dev, sz, ioc->alloc, in PrimeIocFifos()
4605 ioc->alloc_dma); in PrimeIocFifos()
4606 ioc->reply_frames = NULL; in PrimeIocFifos()
4607 ioc->req_frames = NULL; in PrimeIocFifos()
4608 ioc->alloc_total -= sz; in PrimeIocFifos()
4610 if (ioc->sense_buf_pool != NULL) { in PrimeIocFifos()
4611 sz = (ioc->req_depth * MPT_SENSE_BUFFER_ALLOC); in PrimeIocFifos()
4612 dma_free_coherent(&ioc->pcidev->dev, sz, ioc->sense_buf_pool, in PrimeIocFifos()
4613 ioc->sense_buf_pool_dma); in PrimeIocFifos()
4614 ioc->sense_buf_pool = NULL; in PrimeIocFifos()
4617 if (dma_mask == DMA_BIT_MASK(35) && !dma_set_mask(&ioc->pcidev->dev, in PrimeIocFifos()
4618 DMA_BIT_MASK(64)) && !dma_set_coherent_mask(&ioc->pcidev->dev, in PrimeIocFifos()
4621 "restoring 64 bit addressing\n", ioc->name)); in PrimeIocFifos()
4623 return -1; in PrimeIocFifos()
4626 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
4628 * mpt_handshake_req_reply_wait - Send MPT request to and receive reply
4632 * @req: Pointer to MPT request frame
4638 * NOTES: It is the callers responsibility to byte-swap fields in the
4640 * callers responsibility to byte-swap response fields which are
4643 * Returns 0 for success, non-zero for failure.
4646 mpt_handshake_req_reply_wait(MPT_ADAPTER *ioc, int reqBytes, u32 *req, in mpt_handshake_req_reply_wait() argument
4656 ioc->hs_reply_idx = 0; in mpt_handshake_req_reply_wait()
4657 mptReply = (MPIDefaultReply_t *) ioc->hs_reply; in mpt_handshake_req_reply_wait()
4658 mptReply->MsgLength = 0; in mpt_handshake_req_reply_wait()
4665 CHIPREG_WRITE32(&ioc->chip->IntStatus, 0); in mpt_handshake_req_reply_wait()
4666 CHIPREG_WRITE32(&ioc->chip->Doorbell, in mpt_handshake_req_reply_wait()
4677 ioc->name, reqBytes, t, failcnt ? " - MISSING DOORBELL HANDSHAKE!" : "")); in mpt_handshake_req_reply_wait()
4680 if (!(CHIPREG_READ32(&ioc->chip->Doorbell) & MPI_DOORBELL_ACTIVE)) in mpt_handshake_req_reply_wait()
4681 return -1; in mpt_handshake_req_reply_wait()
4688 CHIPREG_WRITE32(&ioc->chip->IntStatus, 0); in mpt_handshake_req_reply_wait()
4694 u8 *req_as_bytes = (u8 *) req; in mpt_handshake_req_reply_wait()
4706 CHIPREG_WRITE32(&ioc->chip->Doorbell, word); in mpt_handshake_req_reply_wait()
4711 …dhsprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Handshake request frame (@%p) header\n", ioc->name, req)); in mpt_handshake_req_reply_wait()
4712 DBG_DUMP_REQUEST_FRAME_HDR(ioc, (u32 *)req); in mpt_handshake_req_reply_wait()
4715 ioc->name, t, failcnt ? " - MISSING DOORBELL ACK!" : "")); in mpt_handshake_req_reply_wait()
4724 ioc->name, t, failcnt ? " - MISSING DOORBELL REPLY!" : "")); in mpt_handshake_req_reply_wait()
4729 for (ii=0; ii < min(replyBytes/2,mptReply->MsgLength*2); ii++) in mpt_handshake_req_reply_wait()
4730 u16reply[ii] = ioc->hs_reply[ii]; in mpt_handshake_req_reply_wait()
4732 return -99; in mpt_handshake_req_reply_wait()
4735 return -failcnt; in mpt_handshake_req_reply_wait()
4738 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
4740 * WaitForDoorbellAck - Wait for IOC doorbell handshake acknowledge
4761 while (--cntdn) { in WaitForDoorbellAck()
4763 intstat = CHIPREG_READ32(&ioc->chip->IntStatus); in WaitForDoorbellAck()
4769 while (--cntdn) { in WaitForDoorbellAck()
4771 intstat = CHIPREG_READ32(&ioc->chip->IntStatus); in WaitForDoorbellAck()
4780 ioc->name, count)); in WaitForDoorbellAck()
4785 ioc->name, count, intstat); in WaitForDoorbellAck()
4786 return -1; in WaitForDoorbellAck()
4789 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
4791 * WaitForDoorbellInt - Wait for IOC to set its doorbell interrupt bit
4810 while (--cntdn) { in WaitForDoorbellInt()
4811 intstat = CHIPREG_READ32(&ioc->chip->IntStatus); in WaitForDoorbellInt()
4818 while (--cntdn) { in WaitForDoorbellInt()
4819 intstat = CHIPREG_READ32(&ioc->chip->IntStatus); in WaitForDoorbellInt()
4829 ioc->name, count, howlong)); in WaitForDoorbellInt()
4834 ioc->name, count, intstat); in WaitForDoorbellInt()
4835 return -1; in WaitForDoorbellInt()
4838 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
4840 * WaitForDoorbellReply - Wait for and capture an IOC handshake reply.
4857 u16 *hs_reply = ioc->hs_reply; in WaitForDoorbellReply()
4858 volatile MPIDefaultReply_t *mptReply = (MPIDefaultReply_t *) ioc->hs_reply; in WaitForDoorbellReply()
4870 hs_reply[u16cnt++] = le16_to_cpu(CHIPREG_READ32(&ioc->chip->Doorbell) & 0x0000FFFF); in WaitForDoorbellReply()
4871 CHIPREG_WRITE32(&ioc->chip->IntStatus, 0); in WaitForDoorbellReply()
4875 hs_reply[u16cnt++] = le16_to_cpu(CHIPREG_READ32(&ioc->chip->Doorbell) & 0x0000FFFF); in WaitForDoorbellReply()
4876 CHIPREG_WRITE32(&ioc->chip->IntStatus, 0); in WaitForDoorbellReply()
4881 ioc->name, t, le32_to_cpu(*(u32 *)hs_reply), in WaitForDoorbellReply()
4882 failcnt ? " - MISSING DOORBELL HANDSHAKE!" : "")); in WaitForDoorbellReply()
4888 for (u16cnt=2; !failcnt && u16cnt < (2 * mptReply->MsgLength); u16cnt++) { in WaitForDoorbellReply()
4891 hword = le16_to_cpu(CHIPREG_READ32(&ioc->chip->Doorbell) & 0x0000FFFF); in WaitForDoorbellReply()
4893 if (u16cnt < ARRAY_SIZE(ioc->hs_reply)) in WaitForDoorbellReply()
4895 CHIPREG_WRITE32(&ioc->chip->IntStatus, 0); in WaitForDoorbellReply()
4900 CHIPREG_WRITE32(&ioc->chip->IntStatus, 0); in WaitForDoorbellReply()
4904 ioc->name); in WaitForDoorbellReply()
4905 return -failcnt; in WaitForDoorbellReply()
4908 else if (u16cnt != (2 * mptReply->MsgLength)) { in WaitForDoorbellReply()
4909 return -101; in WaitForDoorbellReply()
4911 else if ((mptReply->IOCStatus & MPI_IOCSTATUS_MASK) != MPI_IOCSTATUS_SUCCESS) { in WaitForDoorbellReply()
4912 return -102; in WaitForDoorbellReply()
4916 dhsprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Got Handshake reply:\n", ioc->name)); in WaitForDoorbellReply()
4920 ioc->name, t, u16cnt/2)); in WaitForDoorbellReply()
4924 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
4926 * GetLanConfigPages - Fetch LANConfig pages.
4930 * -ENOMEM if no memory available
4931 * -EPERM if not allowed due to ISR context
4932 * -EAGAIN if no msg frames currently available
4933 * -EFAULT for non-successful reply or no reply (timeout)
4954 cfg.physAddr = -1; in GetLanConfigPages()
4965 ppage0_alloc = dma_alloc_coherent(&ioc->pcidev->dev, data_sz, in GetLanConfigPages()
4967 rc = -ENOMEM; in GetLanConfigPages()
4976 memcpy(&ioc->lan_cnfg_page0, ppage0_alloc, copy_sz); in GetLanConfigPages()
4980 dma_free_coherent(&ioc->pcidev->dev, data_sz, in GetLanConfigPages()
4985 * by byte-swapping all > 1 byte fields! in GetLanConfigPages()
5000 cfg.physAddr = -1; in GetLanConfigPages()
5012 rc = -ENOMEM; in GetLanConfigPages()
5013 ppage1_alloc = dma_alloc_coherent(&ioc->pcidev->dev, data_sz, in GetLanConfigPages()
5023 memcpy(&ioc->lan_cnfg_page1, ppage1_alloc, copy_sz); in GetLanConfigPages()
5026 dma_free_coherent(&ioc->pcidev->dev, data_sz, in GetLanConfigPages()
5031 * by byte-swapping all > 1 byte fields! in GetLanConfigPages()
5039 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
5041 * mptbase_sas_persist_operation - Perform operation on SAS Persistent Table
5053 * Returns 0 for success, non-zero error
5056 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
5067 mutex_lock(&ioc->mptbase_cmds.mutex); in mptbase_sas_persist_operation()
5070 memset(ioc->mptbase_cmds.reply, 0 , MPT_DEFAULT_FRAME_SIZE); in mptbase_sas_persist_operation()
5071 INITIALIZE_MGMT_STATUS(ioc->mptbase_cmds.status) in mptbase_sas_persist_operation()
5081 ret = -1; in mptbase_sas_persist_operation()
5092 ret = -1; in mptbase_sas_persist_operation()
5099 sasIoUnitCntrReq->Function = MPI_FUNCTION_SAS_IO_UNIT_CONTROL; in mptbase_sas_persist_operation()
5100 sasIoUnitCntrReq->MsgContext = mpi_hdr->MsgContext; in mptbase_sas_persist_operation()
5101 sasIoUnitCntrReq->Operation = persist_opcode; in mptbase_sas_persist_operation()
5104 timeleft = wait_for_completion_timeout(&ioc->mptbase_cmds.done, 10*HZ); in mptbase_sas_persist_operation()
5105 if (!(ioc->mptbase_cmds.status & MPT_MGMT_STATUS_COMMAND_GOOD)) { in mptbase_sas_persist_operation()
5106 ret = -ETIME; in mptbase_sas_persist_operation()
5108 if (ioc->mptbase_cmds.status & MPT_MGMT_STATUS_DID_IOCRESET) in mptbase_sas_persist_operation()
5113 ioc->name, __func__, mpt_GetIocState(ioc, 0)); in mptbase_sas_persist_operation()
5120 if (!(ioc->mptbase_cmds.status & MPT_MGMT_STATUS_RF_VALID)) { in mptbase_sas_persist_operation()
5121 ret = -1; in mptbase_sas_persist_operation()
5126 (SasIoUnitControlReply_t *)ioc->mptbase_cmds.reply; in mptbase_sas_persist_operation()
5127 if (le16_to_cpu(sasIoUnitCntrReply->IOCStatus) != MPI_IOCSTATUS_SUCCESS) { in mptbase_sas_persist_operation()
5129 __func__, sasIoUnitCntrReply->IOCStatus, in mptbase_sas_persist_operation()
5130 sasIoUnitCntrReply->IOCLogInfo); in mptbase_sas_persist_operation()
5132 ret = -1; in mptbase_sas_persist_operation()
5137 CLEAR_MGMT_STATUS(ioc->mptbase_cmds.status) in mptbase_sas_persist_operation()
5138 mutex_unlock(&ioc->mptbase_cmds.mutex); in mptbase_sas_persist_operation()
5142 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
5155 volume = pRaidEventData->VolumeID; in mptbase_raid_process_event_data()
5156 reason = pRaidEventData->ReasonCode; in mptbase_raid_process_event_data()
5157 disk = pRaidEventData->PhysDiskNum; in mptbase_raid_process_event_data()
5158 status = le32_to_cpu(pRaidEventData->SettingsStatus); in mptbase_raid_process_event_data()
5170 ioc->name, disk, volume); in mptbase_raid_process_event_data()
5173 ioc->name, volume); in mptbase_raid_process_event_data()
5179 ioc->name); in mptbase_raid_process_event_data()
5185 ioc->name); in mptbase_raid_process_event_data()
5190 ioc->name); in mptbase_raid_process_event_data()
5195 ioc->name, in mptbase_raid_process_event_data()
5213 ioc->name, disk); in mptbase_raid_process_event_data()
5218 ioc->name); in mptbase_raid_process_event_data()
5223 ioc->name); in mptbase_raid_process_event_data()
5228 ioc->name); in mptbase_raid_process_event_data()
5233 ioc->name, in mptbase_raid_process_event_data()
5259 ioc->name, disk); in mptbase_raid_process_event_data()
5264 ioc->name, pRaidEventData->ASC, pRaidEventData->ASCQ); in mptbase_raid_process_event_data()
5269 ioc->name, disk); in mptbase_raid_process_event_data()
5274 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
5276 * GetIoUnitPage2 - Retrieve BIOS version and boot order information.
5280 * -ENOMEM if no memory available
5281 * -EPERM if not allowed due to ISR context
5282 * -EAGAIN if no msg frames currently available
5283 * -EFAULT for non-successful reply or no reply (timeout)
5301 cfg.physAddr = -1; in GetIoUnitPage2()
5315 rc = -ENOMEM; in GetIoUnitPage2()
5316 ppage_alloc = dma_alloc_coherent(&ioc->pcidev->dev, data_sz, in GetIoUnitPage2()
5325 ioc->biosVersion = le32_to_cpu(ppage_alloc->BiosVersion); in GetIoUnitPage2()
5327 dma_free_coherent(&ioc->pcidev->dev, data_sz, in GetIoUnitPage2()
5334 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
5336 * mpt_GetScsiPortSettings - read SCSI Port Page 0 and 2
5340 * Return: -EFAULT if read of config page header fails
5353 * CHECK - what type of locking mechanisms should be used????
5367 if (!ioc->spi_data.nvram) { in mpt_GetScsiPortSettings()
5373 return -EFAULT; in mpt_GetScsiPortSettings()
5375 ioc->spi_data.nvram = (int *) mem; in mpt_GetScsiPortSettings()
5378 ioc->name, ioc->spi_data.nvram, sz)); in mpt_GetScsiPortSettings()
5384 ioc->spi_data.nvram[ii] = MPT_HOST_NVRAM_INVALID; in mpt_GetScsiPortSettings()
5394 cfg.physAddr = -1; in mpt_GetScsiPortSettings()
5400 return -EFAULT; in mpt_GetScsiPortSettings()
5403 pbuf = dma_alloc_coherent(&ioc->pcidev->dev, in mpt_GetScsiPortSettings()
5410 ioc->spi_data.maxBusWidth = MPT_NARROW; in mpt_GetScsiPortSettings()
5411 ioc->spi_data.maxSyncOffset = 0; in mpt_GetScsiPortSettings()
5412 ioc->spi_data.minSyncFactor = MPT_ASYNC; in mpt_GetScsiPortSettings()
5413 ioc->spi_data.busType = MPT_HOST_BUS_UNKNOWN; in mpt_GetScsiPortSettings()
5417 ioc->name, ioc->spi_data.minSyncFactor)); in mpt_GetScsiPortSettings()
5422 pPP0->Capabilities = le32_to_cpu(pPP0->Capabilities); in mpt_GetScsiPortSettings()
5423 pPP0->PhysicalInterface = le32_to_cpu(pPP0->PhysicalInterface); in mpt_GetScsiPortSettings()
5425 if ( (pPP0->Capabilities & MPI_SCSIPORTPAGE0_CAP_QAS) == 0 ) { in mpt_GetScsiPortSettings()
5426 ioc->spi_data.noQas |= MPT_TARGET_NO_NEGO_QAS; in mpt_GetScsiPortSettings()
5429 ioc->name, pPP0->Capabilities)); in mpt_GetScsiPortSettings()
5431 ioc->spi_data.maxBusWidth = pPP0->Capabilities & MPI_SCSIPORTPAGE0_CAP_WIDE ? 1 : 0; in mpt_GetScsiPortSettings()
5432 data = pPP0->Capabilities & MPI_SCSIPORTPAGE0_CAP_MAX_SYNC_OFFSET_MASK; in mpt_GetScsiPortSettings()
5434 ioc->spi_data.maxSyncOffset = (u8) (data >> 16); in mpt_GetScsiPortSettings()
5435 data = pPP0->Capabilities & MPI_SCSIPORTPAGE0_CAP_MIN_SYNC_PERIOD_MASK; in mpt_GetScsiPortSettings()
5436 ioc->spi_data.minSyncFactor = (u8) (data >> 8); in mpt_GetScsiPortSettings()
5439 ioc->name, ioc->spi_data.minSyncFactor)); in mpt_GetScsiPortSettings()
5441 ioc->spi_data.maxSyncOffset = 0; in mpt_GetScsiPortSettings()
5442 ioc->spi_data.minSyncFactor = MPT_ASYNC; in mpt_GetScsiPortSettings()
5445 ioc->spi_data.busType = pPP0->PhysicalInterface & MPI_SCSIPORTPAGE0_PHY_SIGNAL_TYPE_MASK; in mpt_GetScsiPortSettings()
5449 if ((ioc->spi_data.busType == MPI_SCSIPORTPAGE0_PHY_SIGNAL_HVD) || in mpt_GetScsiPortSettings()
5450 (ioc->spi_data.busType == MPI_SCSIPORTPAGE0_PHY_SIGNAL_SE)) { in mpt_GetScsiPortSettings()
5452 if (ioc->spi_data.minSyncFactor < MPT_ULTRA) { in mpt_GetScsiPortSettings()
5453 ioc->spi_data.minSyncFactor = MPT_ULTRA; in mpt_GetScsiPortSettings()
5456 ioc->name, ioc->spi_data.minSyncFactor)); in mpt_GetScsiPortSettings()
5461 dma_free_coherent(&ioc->pcidev->dev, in mpt_GetScsiPortSettings()
5468 /* SCSI Port Page 2 - Read the header then the page. in mpt_GetScsiPortSettings()
5475 cfg.physAddr = -1; in mpt_GetScsiPortSettings()
5480 return -EFAULT; in mpt_GetScsiPortSettings()
5485 pbuf = dma_alloc_coherent(&ioc->pcidev->dev, in mpt_GetScsiPortSettings()
5495 } else if (ioc->pcidev->vendor == PCI_VENDOR_ID_ATTO) { in mpt_GetScsiPortSettings()
5507 pdevice = &pPP2->DeviceSettings[ii]; in mpt_GetScsiPortSettings()
5508 ATTOFlags = le16_to_cpu(pdevice->ATTOFlags); in mpt_GetScsiPortSettings()
5524 data = (data << 16) | (pdevice->Period << 8) | 10; in mpt_GetScsiPortSettings()
5525 ioc->spi_data.nvram[ii] = data; in mpt_GetScsiPortSettings()
5534 ioc->spi_data.bus_reset = in mpt_GetScsiPortSettings()
5535 (le32_to_cpu(pPP2->PortFlags) & in mpt_GetScsiPortSettings()
5542 data = le32_to_cpu(pPP2->PortFlags) & MPI_SCSIPORTPAGE2_PORT_FLAGS_DV_MASK; in mpt_GetScsiPortSettings()
5543 ioc->spi_data.PortFlags = data; in mpt_GetScsiPortSettings()
5545 pdevice = &pPP2->DeviceSettings[ii]; in mpt_GetScsiPortSettings()
5546 data = (le16_to_cpu(pdevice->DeviceFlags) << 16) | in mpt_GetScsiPortSettings()
5547 (pdevice->SyncFactor << 8) | pdevice->Timeout; in mpt_GetScsiPortSettings()
5548 ioc->spi_data.nvram[ii] = data; in mpt_GetScsiPortSettings()
5552 dma_free_coherent(&ioc->pcidev->dev, in mpt_GetScsiPortSettings()
5566 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
5568 * mpt_readScsiDevicePageHeaders - save version and length of SDP1
5572 * Return: -EFAULT if read of config page header fails
5588 cfg.physAddr = -1; in mpt_readScsiDevicePageHeaders()
5594 return -EFAULT; in mpt_readScsiDevicePageHeaders()
5596 ioc->spi_data.sdp1version = cfg.cfghdr.hdr->PageVersion; in mpt_readScsiDevicePageHeaders()
5597 ioc->spi_data.sdp1length = cfg.cfghdr.hdr->PageLength; in mpt_readScsiDevicePageHeaders()
5604 return -EFAULT; in mpt_readScsiDevicePageHeaders()
5606 ioc->spi_data.sdp0version = cfg.cfghdr.hdr->PageVersion; in mpt_readScsiDevicePageHeaders()
5607 ioc->spi_data.sdp0length = cfg.cfghdr.hdr->PageLength; in mpt_readScsiDevicePageHeaders()
5610 ioc->name, ioc->spi_data.sdp0version, ioc->spi_data.sdp0length)); in mpt_readScsiDevicePageHeaders()
5613 ioc->name, ioc->spi_data.sdp1version, ioc->spi_data.sdp1length)); in mpt_readScsiDevicePageHeaders()
5618 * mpt_inactive_raid_list_free - This clears this link list.
5626 if (list_empty(&ioc->raid_data.inactive_list)) in mpt_inactive_raid_list_free()
5629 mutex_lock(&ioc->raid_data.inactive_list_mutex); in mpt_inactive_raid_list_free()
5631 &ioc->raid_data.inactive_list, list) { in mpt_inactive_raid_list_free()
5632 list_del(&component_info->list); in mpt_inactive_raid_list_free()
5635 mutex_unlock(&ioc->raid_data.inactive_list_mutex); in mpt_inactive_raid_list_free()
5639 …* mpt_inactive_raid_volumes - sets up link list of phy_disk_nums for devices belonging in an inact…
5670 buffer = dma_alloc_coherent(&ioc->pcidev->dev, hdr.PageLength * 4, in mpt_inactive_raid_volumes()
5682 if (!buffer->NumPhysDisks) in mpt_inactive_raid_volumes()
5686 (buffer->VolumeStatus.Flags & MPI_RAIDVOL0_STATUS_FLAG_VOLUME_INACTIVE || in mpt_inactive_raid_volumes()
5687 (buffer->VolumeStatus.Flags & MPI_RAIDVOL0_STATUS_FLAG_ENABLED) == 0 || in mpt_inactive_raid_volumes()
5688 buffer->VolumeStatus.State == MPI_RAIDVOL0_STATUS_STATE_FAILED || in mpt_inactive_raid_volumes()
5689 buffer->VolumeStatus.State == MPI_RAIDVOL0_STATUS_STATE_MISSING) ? 1 : 0; in mpt_inactive_raid_volumes()
5694 mutex_lock(&ioc->raid_data.inactive_list_mutex); in mpt_inactive_raid_volumes()
5695 for (i = 0; i < buffer->NumPhysDisks; i++) { in mpt_inactive_raid_volumes()
5697 buffer->PhysDisk[i].PhysDiskNum, &phys_disk) != 0) in mpt_inactive_raid_volumes()
5704 component_info->volumeID = id; in mpt_inactive_raid_volumes()
5705 component_info->volumeBus = channel; in mpt_inactive_raid_volumes()
5706 component_info->d.PhysDiskNum = phys_disk.PhysDiskNum; in mpt_inactive_raid_volumes()
5707 component_info->d.PhysDiskBus = phys_disk.PhysDiskBus; in mpt_inactive_raid_volumes()
5708 component_info->d.PhysDiskID = phys_disk.PhysDiskID; in mpt_inactive_raid_volumes()
5709 component_info->d.PhysDiskIOC = phys_disk.PhysDiskIOC; in mpt_inactive_raid_volumes()
5711 list_add_tail(&component_info->list, in mpt_inactive_raid_volumes()
5712 &ioc->raid_data.inactive_list); in mpt_inactive_raid_volumes()
5714 mutex_unlock(&ioc->raid_data.inactive_list_mutex); in mpt_inactive_raid_volumes()
5718 dma_free_coherent(&ioc->pcidev->dev, hdr.PageLength * 4, in mpt_inactive_raid_volumes()
5723 * mpt_raid_phys_disk_pg0 - returns phys disk page zero
5730 * -EFAULT if read of config page header fails or data pointer not NULL
5731 * -ENOMEM if pci_alloc failed
5750 cfg.physAddr = -1; in mpt_raid_phys_disk_pg0()
5754 rc = -EFAULT; in mpt_raid_phys_disk_pg0()
5759 rc = -EFAULT; in mpt_raid_phys_disk_pg0()
5763 buffer = dma_alloc_coherent(&ioc->pcidev->dev, hdr.PageLength * 4, in mpt_raid_phys_disk_pg0()
5767 rc = -ENOMEM; in mpt_raid_phys_disk_pg0()
5776 rc = -EFAULT; in mpt_raid_phys_disk_pg0()
5782 phys_disk->MaxLBA = le32_to_cpu(buffer->MaxLBA); in mpt_raid_phys_disk_pg0()
5787 dma_free_coherent(&ioc->pcidev->dev, hdr.PageLength * 4, in mpt_raid_phys_disk_pg0()
5794 * mpt_raid_phys_disk_get_num_paths - returns number paths associated to this phys_num
5817 cfg.physAddr = -1; in mpt_raid_phys_disk_get_num_paths()
5830 buffer = dma_alloc_coherent(&ioc->pcidev->dev, hdr.PageLength * 4, in mpt_raid_phys_disk_get_num_paths()
5847 rc = buffer->NumPhysDiskPaths; in mpt_raid_phys_disk_get_num_paths()
5851 dma_free_coherent(&ioc->pcidev->dev, hdr.PageLength * 4, in mpt_raid_phys_disk_get_num_paths()
5859 * mpt_raid_phys_disk_pg1 - returns phys disk page 1
5866 * -EFAULT if read of config page header fails or data pointer not NULL
5867 * -ENOMEM if pci_alloc failed
5889 cfg.physAddr = -1; in mpt_raid_phys_disk_pg1()
5893 rc = -EFAULT; in mpt_raid_phys_disk_pg1()
5898 rc = -EFAULT; in mpt_raid_phys_disk_pg1()
5902 buffer = dma_alloc_coherent(&ioc->pcidev->dev, hdr.PageLength * 4, in mpt_raid_phys_disk_pg1()
5906 rc = -ENOMEM; in mpt_raid_phys_disk_pg1()
5915 rc = -EFAULT; in mpt_raid_phys_disk_pg1()
5919 phys_disk->NumPhysDiskPaths = buffer->NumPhysDiskPaths; in mpt_raid_phys_disk_pg1()
5920 phys_disk->PhysDiskNum = phys_disk_num; in mpt_raid_phys_disk_pg1()
5921 for (i = 0; i < phys_disk->NumPhysDiskPaths; i++) { in mpt_raid_phys_disk_pg1()
5922 phys_disk->Path[i].PhysDiskID = buffer->Path[i].PhysDiskID; in mpt_raid_phys_disk_pg1()
5923 phys_disk->Path[i].PhysDiskBus = buffer->Path[i].PhysDiskBus; in mpt_raid_phys_disk_pg1()
5924 phys_disk->Path[i].OwnerIdentifier = in mpt_raid_phys_disk_pg1()
5925 buffer->Path[i].OwnerIdentifier; in mpt_raid_phys_disk_pg1()
5926 phys_disk->Path[i].Flags = le16_to_cpu(buffer->Path[i].Flags); in mpt_raid_phys_disk_pg1()
5927 memcpy(&sas_address, &buffer->Path[i].WWID, sizeof(__le64)); in mpt_raid_phys_disk_pg1()
5929 memcpy(&phys_disk->Path[i].WWID, &sas_address, sizeof(__le64)); in mpt_raid_phys_disk_pg1()
5931 &buffer->Path[i].OwnerWWID, sizeof(__le64)); in mpt_raid_phys_disk_pg1()
5933 memcpy(&phys_disk->Path[i].OwnerWWID, in mpt_raid_phys_disk_pg1()
5940 dma_free_coherent(&ioc->pcidev->dev, hdr.PageLength * 4, in mpt_raid_phys_disk_pg1()
5949 * mpt_findImVolumes - Identify IDs of hidden disks and RAID Volumes
5954 * -EFAULT if read of config page header fails or data pointer not NULL
5955 * -ENOMEM if pci_alloc failed
5969 if (!ioc->ir_firmware) in mpt_findImVolumes()
5974 kfree(ioc->raid_data.pIocPg2); in mpt_findImVolumes()
5975 ioc->raid_data.pIocPg2 = NULL; in mpt_findImVolumes()
5985 cfg.physAddr = -1; in mpt_findImVolumes()
5991 return -EFAULT; in mpt_findImVolumes()
5994 return -EFAULT; in mpt_findImVolumes()
5997 pIoc2 = dma_alloc_coherent(&ioc->pcidev->dev, iocpage2sz, &ioc2_dma, in mpt_findImVolumes()
6000 return -ENOMEM; in mpt_findImVolumes()
6009 rc = -ENOMEM; in mpt_findImVolumes()
6013 ioc->raid_data.pIocPg2 = (IOCPage2_t *) mem; in mpt_findImVolumes()
6017 for (i = 0; i < pIoc2->NumActiveVolumes ; i++) in mpt_findImVolumes()
6019 pIoc2->RaidVolume[i].VolumeBus, in mpt_findImVolumes()
6020 pIoc2->RaidVolume[i].VolumeID); in mpt_findImVolumes()
6023 dma_free_coherent(&ioc->pcidev->dev, iocpage2sz, pIoc2, ioc2_dma); in mpt_findImVolumes()
6040 kfree(ioc->raid_data.pIocPg3); in mpt_read_ioc_pg_3()
6041 ioc->raid_data.pIocPg3 = NULL; in mpt_read_ioc_pg_3()
6051 cfg.physAddr = -1; in mpt_read_ioc_pg_3()
6065 pIoc3 = dma_alloc_coherent(&ioc->pcidev->dev, iocpage3sz, &ioc3_dma, in mpt_read_ioc_pg_3()
6079 ioc->raid_data.pIocPg3 = (IOCPage3_t *) mem; in mpt_read_ioc_pg_3()
6083 dma_free_coherent(&ioc->pcidev->dev, iocpage3sz, pIoc3, ioc3_dma); in mpt_read_ioc_pg_3()
6104 cfg.physAddr = -1; in mpt_read_ioc_pg_4()
6115 if ( (pIoc4 = ioc->spi_data.pIocPg4) == NULL ) { in mpt_read_ioc_pg_4()
6117 pIoc4 = dma_alloc_coherent(&ioc->pcidev->dev, iocpage4sz, in mpt_read_ioc_pg_4()
6121 ioc->alloc_total += iocpage4sz; in mpt_read_ioc_pg_4()
6123 ioc4_dma = ioc->spi_data.IocPg4_dma; in mpt_read_ioc_pg_4()
6124 iocpage4sz = ioc->spi_data.IocPg4Sz; in mpt_read_ioc_pg_4()
6132 ioc->spi_data.pIocPg4 = (IOCPage4_t *) pIoc4; in mpt_read_ioc_pg_4()
6133 ioc->spi_data.IocPg4_dma = ioc4_dma; in mpt_read_ioc_pg_4()
6134 ioc->spi_data.IocPg4Sz = iocpage4sz; in mpt_read_ioc_pg_4()
6136 dma_free_coherent(&ioc->pcidev->dev, iocpage4sz, pIoc4, in mpt_read_ioc_pg_4()
6138 ioc->spi_data.pIocPg4 = NULL; in mpt_read_ioc_pg_4()
6139 ioc->alloc_total -= iocpage4sz; in mpt_read_ioc_pg_4()
6160 cfg.physAddr = -1; in mpt_read_ioc_pg_1()
6174 pIoc1 = dma_alloc_coherent(&ioc->pcidev->dev, iocpage1sz, &ioc1_dma, in mpt_read_ioc_pg_1()
6185 tmp = le32_to_cpu(pIoc1->Flags) & MPI_IOCPAGE1_REPLY_COALESCING; in mpt_read_ioc_pg_1()
6187 tmp = le32_to_cpu(pIoc1->CoalescingTimeout); in mpt_read_ioc_pg_1()
6190 ioc->name, tmp)); in mpt_read_ioc_pg_1()
6193 pIoc1->CoalescingTimeout = cpu_to_le32(MPT_COALESCING_TIMEOUT); in mpt_read_ioc_pg_1()
6201 ioc->name, MPT_COALESCING_TIMEOUT)); in mpt_read_ioc_pg_1()
6207 ioc->name, MPT_COALESCING_TIMEOUT)); in mpt_read_ioc_pg_1()
6211 ioc->name)); in mpt_read_ioc_pg_1()
6217 ioc->name)); in mpt_read_ioc_pg_1()
6222 dprintk(ioc, printk(MYIOC_s_WARN_FMT "Coalescing Disabled\n", ioc->name)); in mpt_read_ioc_pg_1()
6226 dma_free_coherent(&ioc->pcidev->dev, iocpage1sz, pIoc1, ioc1_dma); in mpt_read_ioc_pg_1()
6244 cfg.physAddr = -1; in mpt_get_manufacturing_pg_0()
6251 if (!cfg.cfghdr.hdr->PageLength) in mpt_get_manufacturing_pg_0()
6255 pbuf = dma_alloc_coherent(&ioc->pcidev->dev, hdr.PageLength * 4, in mpt_get_manufacturing_pg_0()
6265 memcpy(ioc->board_name, pbuf->BoardName, sizeof(ioc->board_name)); in mpt_get_manufacturing_pg_0()
6266 memcpy(ioc->board_assembly, pbuf->BoardAssembly, sizeof(ioc->board_assembly)); in mpt_get_manufacturing_pg_0()
6267 memcpy(ioc->board_tracer, pbuf->BoardTracerNumber, sizeof(ioc->board_tracer)); in mpt_get_manufacturing_pg_0()
6272 dma_free_coherent(&ioc->pcidev->dev, hdr.PageLength * 4, pbuf, in mpt_get_manufacturing_pg_0()
6276 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
6278 * SendEventNotification - Send EventNotification (on or off) request to adapter
6298 ioc->name, EvSwitch, &evn)); in SendEventNotification()
6305 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
6307 * SendEventAck - Send EventAck request to MPT adapter.
6318 ioc->name, __func__)); in SendEventAck()
6319 return -1; in SendEventAck()
6322 devtverboseprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Sending EventAck\n", ioc->name)); in SendEventAck()
6324 pAck->Function = MPI_FUNCTION_EVENT_ACK; in SendEventAck()
6325 pAck->ChainOffset = 0; in SendEventAck()
6326 pAck->Reserved[0] = pAck->Reserved[1] = 0; in SendEventAck()
6327 pAck->MsgFlags = 0; in SendEventAck()
6328 pAck->Reserved1[0] = pAck->Reserved1[1] = pAck->Reserved1[2] = 0; in SendEventAck()
6329 pAck->Event = evnp->Event; in SendEventAck()
6330 pAck->EventContext = evnp->EventContext; in SendEventAck()
6337 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
6339 * mpt_config - Generic function to issue config message
6347 * -EAGAIN if no msg frames currently available
6348 * -EFAULT for non-successful reply or no reply (timeout)
6370 spin_lock_irqsave(&ioc->taskmgmt_lock, flags); in mpt_config()
6371 if (ioc->ioc_reset_in_progress) { in mpt_config()
6373 "%s: busy with host reset\n", ioc->name, __func__)); in mpt_config()
6374 spin_unlock_irqrestore(&ioc->taskmgmt_lock, flags); in mpt_config()
6375 return -EBUSY; in mpt_config()
6377 spin_unlock_irqrestore(&ioc->taskmgmt_lock, flags); in mpt_config()
6380 if (!ioc->active || in mpt_config()
6384 ioc->name, __func__, ioc->active, in mpt_config()
6386 return -EFAULT; in mpt_config()
6390 mutex_lock(&ioc->mptbase_cmds.mutex); in mpt_config()
6392 memset(ioc->mptbase_cmds.reply, 0 , MPT_DEFAULT_FRAME_SIZE); in mpt_config()
6393 INITIALIZE_MGMT_STATUS(ioc->mptbase_cmds.status) in mpt_config()
6399 "mpt_config: no msg frames!\n", ioc->name)); in mpt_config()
6400 ret = -EAGAIN; in mpt_config()
6405 pReq->Action = pCfg->action; in mpt_config()
6406 pReq->Reserved = 0; in mpt_config()
6407 pReq->ChainOffset = 0; in mpt_config()
6408 pReq->Function = MPI_FUNCTION_CONFIG; in mpt_config()
6411 pReq->ExtPageLength = 0; in mpt_config()
6412 pReq->ExtPageType = 0; in mpt_config()
6413 pReq->MsgFlags = 0; in mpt_config()
6416 pReq->Reserved2[ii] = 0; in mpt_config()
6418 pReq->Header.PageVersion = pCfg->cfghdr.hdr->PageVersion; in mpt_config()
6419 pReq->Header.PageLength = pCfg->cfghdr.hdr->PageLength; in mpt_config()
6420 pReq->Header.PageNumber = pCfg->cfghdr.hdr->PageNumber; in mpt_config()
6421 pReq->Header.PageType = (pCfg->cfghdr.hdr->PageType & MPI_CONFIG_PAGETYPE_MASK); in mpt_config()
6423 if ((pCfg->cfghdr.hdr->PageType & MPI_CONFIG_PAGETYPE_MASK) == MPI_CONFIG_PAGETYPE_EXTENDED) { in mpt_config()
6424 pExtHdr = (ConfigExtendedPageHeader_t *)pCfg->cfghdr.ehdr; in mpt_config()
6425 pReq->ExtPageLength = cpu_to_le16(pExtHdr->ExtPageLength); in mpt_config()
6426 pReq->ExtPageType = pExtHdr->ExtPageType; in mpt_config()
6427 pReq->Header.PageType = MPI_CONFIG_PAGETYPE_EXTENDED; in mpt_config()
6432 pReq->Header.PageLength = 0; in mpt_config()
6435 pReq->PageAddress = cpu_to_le32(pCfg->pageAddr); in mpt_config()
6439 if (pCfg->dir) in mpt_config()
6444 if ((pCfg->cfghdr.hdr->PageType & MPI_CONFIG_PAGETYPE_MASK) == in mpt_config()
6446 flagsLength |= pExtHdr->ExtPageLength * 4; in mpt_config()
6447 page_type = pReq->ExtPageType; in mpt_config()
6450 flagsLength |= pCfg->cfghdr.hdr->PageLength * 4; in mpt_config()
6451 page_type = pReq->Header.PageType; in mpt_config()
6457 ioc->name, page_type, pReq->Header.PageNumber, pReq->Action)); in mpt_config()
6459 ioc->add_sge((char *)&pReq->PageBufferSGE, flagsLength, pCfg->physAddr); in mpt_config()
6460 timeout = (pCfg->timeout < 15) ? HZ*15 : HZ*pCfg->timeout; in mpt_config()
6462 timeleft = wait_for_completion_timeout(&ioc->mptbase_cmds.done, in mpt_config()
6464 if (!(ioc->mptbase_cmds.status & MPT_MGMT_STATUS_COMMAND_GOOD)) { in mpt_config()
6465 ret = -ETIME; in mpt_config()
6469 ioc->name, page_type, pReq->Header.PageNumber, in mpt_config()
6470 pReq->Action, ioc->mptbase_cmds.status, timeleft)); in mpt_config()
6471 if (ioc->mptbase_cmds.status & MPT_MGMT_STATUS_DID_IOCRESET) in mpt_config()
6474 spin_lock_irqsave(&ioc->taskmgmt_lock, flags); in mpt_config()
6475 if (ioc->ioc_reset_in_progress) { in mpt_config()
6476 spin_unlock_irqrestore(&ioc->taskmgmt_lock, in mpt_config()
6480 __func__, ioc->name); in mpt_config()
6481 mutex_unlock(&ioc->mptbase_cmds.mutex); in mpt_config()
6482 return -EFAULT; in mpt_config()
6484 spin_unlock_irqrestore(&ioc->taskmgmt_lock, flags); in mpt_config()
6490 if (!(ioc->mptbase_cmds.status & MPT_MGMT_STATUS_RF_VALID)) { in mpt_config()
6491 ret = -1; in mpt_config()
6494 pReply = (ConfigReply_t *)ioc->mptbase_cmds.reply; in mpt_config()
6495 ret = le16_to_cpu(pReply->IOCStatus) & MPI_IOCSTATUS_MASK; in mpt_config()
6498 pCfg->cfghdr.ehdr->ExtPageLength = in mpt_config()
6499 le16_to_cpu(pReply->ExtPageLength); in mpt_config()
6500 pCfg->cfghdr.ehdr->ExtPageType = in mpt_config()
6501 pReply->ExtPageType; in mpt_config()
6503 pCfg->cfghdr.hdr->PageVersion = pReply->Header.PageVersion; in mpt_config()
6504 pCfg->cfghdr.hdr->PageLength = pReply->Header.PageLength; in mpt_config()
6505 pCfg->cfghdr.hdr->PageNumber = pReply->Header.PageNumber; in mpt_config()
6506 pCfg->cfghdr.hdr->PageType = pReply->Header.PageType; in mpt_config()
6513 ioc->name, ret, timeleft); in mpt_config()
6516 ret, le32_to_cpu(pReply->IOCLogInfo))); in mpt_config()
6520 CLEAR_MGMT_STATUS(ioc->mptbase_cmds.status) in mpt_config()
6521 mutex_unlock(&ioc->mptbase_cmds.mutex); in mpt_config()
6526 ioc->name, __func__, mpt_GetIocState(ioc, 0)); in mpt_config()
6539 " action %d\n", ioc->name, page_type, in mpt_config()
6540 pCfg->cfghdr.hdr->PageNumber, pCfg->action); in mpt_config()
6549 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
6551 * mpt_ioc_reset - Base cleanup for hard reset
6553 * @reset_phase: Indicates pre- or post-reset functionality
6562 ioc->taskmgmt_quiesce_io = 1; in mpt_ioc_reset()
6564 "%s: MPT_IOC_SETUP_RESET\n", ioc->name, __func__)); in mpt_ioc_reset()
6568 "%s: MPT_IOC_PRE_RESET\n", ioc->name, __func__)); in mpt_ioc_reset()
6572 "%s: MPT_IOC_POST_RESET\n", ioc->name, __func__)); in mpt_ioc_reset()
6574 if (ioc->mptbase_cmds.status & MPT_MGMT_STATUS_PENDING) { in mpt_ioc_reset()
6575 ioc->mptbase_cmds.status |= in mpt_ioc_reset()
6577 complete(&ioc->mptbase_cmds.done); in mpt_ioc_reset()
6580 if (ioc->taskmgmt_cmds.status & MPT_MGMT_STATUS_PENDING) { in mpt_ioc_reset()
6581 ioc->taskmgmt_cmds.status |= in mpt_ioc_reset()
6583 complete(&ioc->taskmgmt_cmds.done); in mpt_ioc_reset()
6595 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
6599 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
6601 * procmpt_create - Create %MPT_PROCFS_MPTBASEDIR entries.
6603 * Returns 0 for success, non-zero for failure.
6610 return -ENOTDIR; in procmpt_create()
6619 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
6621 * procmpt_destroy - Tear down %MPT_PROCFS_MPTBASEDIR entries.
6623 * Returns 0 for success, non-zero for failure.
6633 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
6641 MPT_ADAPTER *ioc = m->private; in mpt_summary_proc_show()
6660 seq_printf(m, "%s-%s\n", "mptlinux", MPT_LINUX_VERSION_COMMON); in mpt_version_proc_show()
6664 for (cb_idx = MPT_MAX_PROTOCOL_DRIVERS-1; cb_idx; cb_idx--) { in mpt_version_proc_show()
6698 MPT_ADAPTER *ioc = m->private; in mpt_iocinfo_proc_show()
6705 seq_printf(m, "%s:", ioc->name); in mpt_iocinfo_proc_show()
6706 if (ioc->facts.Flags & MPI_IOCFACTS_FLAGS_FW_DOWNLOAD_BOOT) in mpt_iocinfo_proc_show()
6708 // if (ioc->facts.IOCExceptions & MPI_IOCFACTS_EXCEPT_CONFIG_CHECKSUM_FAIL) in mpt_iocinfo_proc_show()
6712 ioc->facts.ProductID, in mpt_iocinfo_proc_show()
6713 ioc->prod_name); in mpt_iocinfo_proc_show()
6714 seq_printf(m, " FWVersion = 0x%08x%s", ioc->facts.FWVersion.Word, expVer); in mpt_iocinfo_proc_show()
6715 if (ioc->facts.FWImageSize) in mpt_iocinfo_proc_show()
6716 seq_printf(m, " (fw_size=%d)", ioc->facts.FWImageSize); in mpt_iocinfo_proc_show()
6717 seq_printf(m, "\n MsgVersion = 0x%04x\n", ioc->facts.MsgVersion); in mpt_iocinfo_proc_show()
6718 seq_printf(m, " FirstWhoInit = 0x%02x\n", ioc->FirstWhoInit); in mpt_iocinfo_proc_show()
6719 seq_printf(m, " EventState = 0x%02x\n", ioc->facts.EventState); in mpt_iocinfo_proc_show()
6722 ioc->facts.CurrentHostMfaHighAddr); in mpt_iocinfo_proc_show()
6724 ioc->facts.CurrentSenseBufferHighAddr); in mpt_iocinfo_proc_show()
6726 seq_printf(m, " MaxChainDepth = 0x%02x frames\n", ioc->facts.MaxChainDepth); in mpt_iocinfo_proc_show()
6727 seq_printf(m, " MinBlockSize = 0x%02x bytes\n", 4*ioc->facts.BlockSize); in mpt_iocinfo_proc_show()
6730 (void *)ioc->req_frames, (void *)(ulong)ioc->req_frames_dma); in mpt_iocinfo_proc_show()
6732 * Rounding UP to nearest 4-kB boundary here... in mpt_iocinfo_proc_show()
6734 sz = (ioc->req_sz * ioc->req_depth) + 128; in mpt_iocinfo_proc_show()
6735 sz = ((sz + 0x1000UL - 1UL) / 0x1000) * 0x1000; in mpt_iocinfo_proc_show()
6737 ioc->req_sz, ioc->req_depth, ioc->req_sz*ioc->req_depth, sz); in mpt_iocinfo_proc_show()
6739 4*ioc->facts.RequestFrameSize, in mpt_iocinfo_proc_show()
6740 ioc->facts.GlobalCredits); in mpt_iocinfo_proc_show()
6743 (void *)ioc->alloc, (void *)(ulong)ioc->alloc_dma); in mpt_iocinfo_proc_show()
6744 sz = (ioc->reply_sz * ioc->reply_depth) + 128; in mpt_iocinfo_proc_show()
6746 ioc->reply_sz, ioc->reply_depth, ioc->reply_sz*ioc->reply_depth, sz); in mpt_iocinfo_proc_show()
6748 ioc->facts.CurReplyFrameSize, in mpt_iocinfo_proc_show()
6749 ioc->facts.ReplyQueueDepth); in mpt_iocinfo_proc_show()
6752 (ioc->facts.MaxDevices==0) ? 255 : ioc->facts.MaxDevices); in mpt_iocinfo_proc_show()
6753 seq_printf(m, " MaxBuses = %d\n", ioc->facts.MaxBuses); in mpt_iocinfo_proc_show()
6755 /* per-port info */ in mpt_iocinfo_proc_show()
6756 for (p=0; p < ioc->facts.NumberOfPorts; p++) { in mpt_iocinfo_proc_show()
6759 ioc->facts.NumberOfPorts); in mpt_iocinfo_proc_show()
6760 if (ioc->bus_type == FC) { in mpt_iocinfo_proc_show()
6761 if (ioc->pfacts[p].ProtocolFlags & MPI_PORTFACTS_PROTOCOL_LAN) { in mpt_iocinfo_proc_show()
6762 u8 *a = (u8*)&ioc->lan_cnfg_page1.HardwareAddressLow; in mpt_iocinfo_proc_show()
6766 ioc->fc_port_page0[p].WWNN.High, in mpt_iocinfo_proc_show()
6767 ioc->fc_port_page0[p].WWNN.Low, in mpt_iocinfo_proc_show()
6768 ioc->fc_port_page0[p].WWPN.High, in mpt_iocinfo_proc_show()
6769 ioc->fc_port_page0[p].WWPN.Low); in mpt_iocinfo_proc_show()
6777 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
6782 if ((ioc->facts.FWVersion.Word >> 24) == 0x0E) { in mpt_get_fw_exp_ver()
6784 (ioc->facts.FWVersion.Word >> 16) & 0x00FF, /* Month */ in mpt_get_fw_exp_ver()
6785 (ioc->facts.FWVersion.Word >> 8) & 0x1F); /* Day */ in mpt_get_fw_exp_ver()
6788 if ((ioc->facts.FWVersion.Word >> 8) & 0x80) in mpt_get_fw_exp_ver()
6793 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
6795 * mpt_print_ioc_summary - Write ASCII summary of IOC to a buffer.
6817 ioc->name, in mpt_print_ioc_summary()
6818 ioc->prod_name, in mpt_print_ioc_summary()
6820 ioc->facts.FWVersion.Word, in mpt_print_ioc_summary()
6822 ioc->facts.NumberOfPorts, in mpt_print_ioc_summary()
6823 ioc->req_depth); in mpt_print_ioc_summary()
6825 if (showlan && (ioc->pfacts[0].ProtocolFlags & MPI_PORTFACTS_PROTOCOL_LAN)) { in mpt_print_ioc_summary()
6826 u8 *a = (u8*)&ioc->lan_cnfg_page1.HardwareAddressLow; in mpt_print_ioc_summary()
6830 y += sprintf(buffer+len+y, ", IRQ=%d", ioc->pci_irq); in mpt_print_ioc_summary()
6832 if (!ioc->active) in mpt_print_ioc_summary()
6851 ioc->name, in seq_mpt_print_ioc_summary()
6852 ioc->prod_name, in seq_mpt_print_ioc_summary()
6854 ioc->facts.FWVersion.Word, in seq_mpt_print_ioc_summary()
6856 ioc->facts.NumberOfPorts, in seq_mpt_print_ioc_summary()
6857 ioc->req_depth); in seq_mpt_print_ioc_summary()
6859 if (showlan && (ioc->pfacts[0].ProtocolFlags & MPI_PORTFACTS_PROTOCOL_LAN)) { in seq_mpt_print_ioc_summary()
6860 u8 *a = (u8*)&ioc->lan_cnfg_page1.HardwareAddressLow; in seq_mpt_print_ioc_summary()
6864 seq_printf(m, ", IRQ=%d", ioc->pci_irq); in seq_mpt_print_ioc_summary()
6866 if (!ioc->active) in seq_mpt_print_ioc_summary()
6874 * mpt_set_taskmgmt_in_progress_flag - set flags associated with task management
6877 * Returns 0 for SUCCESS or -1 if FAILED.
6879 * If -1 is return, then it was not possible to set the flags
6887 spin_lock_irqsave(&ioc->taskmgmt_lock, flags); in mpt_set_taskmgmt_in_progress_flag()
6888 if (ioc->ioc_reset_in_progress || ioc->taskmgmt_in_progress || in mpt_set_taskmgmt_in_progress_flag()
6889 (ioc->alt_ioc && ioc->alt_ioc->taskmgmt_in_progress)) { in mpt_set_taskmgmt_in_progress_flag()
6890 retval = -1; in mpt_set_taskmgmt_in_progress_flag()
6894 ioc->taskmgmt_in_progress = 1; in mpt_set_taskmgmt_in_progress_flag()
6895 ioc->taskmgmt_quiesce_io = 1; in mpt_set_taskmgmt_in_progress_flag()
6896 if (ioc->alt_ioc) { in mpt_set_taskmgmt_in_progress_flag()
6897 ioc->alt_ioc->taskmgmt_in_progress = 1; in mpt_set_taskmgmt_in_progress_flag()
6898 ioc->alt_ioc->taskmgmt_quiesce_io = 1; in mpt_set_taskmgmt_in_progress_flag()
6901 spin_unlock_irqrestore(&ioc->taskmgmt_lock, flags); in mpt_set_taskmgmt_in_progress_flag()
6907 * mpt_clear_taskmgmt_in_progress_flag - clear flags associated with task management
6916 spin_lock_irqsave(&ioc->taskmgmt_lock, flags); in mpt_clear_taskmgmt_in_progress_flag()
6917 ioc->taskmgmt_in_progress = 0; in mpt_clear_taskmgmt_in_progress_flag()
6918 ioc->taskmgmt_quiesce_io = 0; in mpt_clear_taskmgmt_in_progress_flag()
6919 if (ioc->alt_ioc) { in mpt_clear_taskmgmt_in_progress_flag()
6920 ioc->alt_ioc->taskmgmt_in_progress = 0; in mpt_clear_taskmgmt_in_progress_flag()
6921 ioc->alt_ioc->taskmgmt_quiesce_io = 0; in mpt_clear_taskmgmt_in_progress_flag()
6923 spin_unlock_irqrestore(&ioc->taskmgmt_lock, flags); in mpt_clear_taskmgmt_in_progress_flag()
6929 * mpt_halt_firmware - Halts the firmware if it is operational and panic
6943 ioc->name, ioc_raw_state & MPI_DOORBELL_DATA_MASK); in mpt_halt_firmware()
6944 panic("%s: IOC Fault (%04xh)!!!\n", ioc->name, in mpt_halt_firmware()
6947 CHIPREG_WRITE32(&ioc->chip->Doorbell, 0xC0FFEE00); in mpt_halt_firmware()
6949 ioc->name); in mpt_halt_firmware()
6955 * mpt_SoftResetHandler - Issues a less expensive reset
6959 * Returns 0 for SUCCESS or -1 if FAILED.
6961 * Message Unit Reset - instructs the IOC to reset the Reply Post and
6978 ioc->name)); in mpt_SoftResetHandler()
6988 "skipping, either in FAULT or RESET state!\n", ioc->name)); in mpt_SoftResetHandler()
6989 return -1; in mpt_SoftResetHandler()
6992 if (ioc->bus_type == FC) { in mpt_SoftResetHandler()
6994 "skipping, because the bus type is FC!\n", ioc->name)); in mpt_SoftResetHandler()
6995 return -1; in mpt_SoftResetHandler()
6998 spin_lock_irqsave(&ioc->taskmgmt_lock, flags); in mpt_SoftResetHandler()
6999 if (ioc->ioc_reset_in_progress) { in mpt_SoftResetHandler()
7000 spin_unlock_irqrestore(&ioc->taskmgmt_lock, flags); in mpt_SoftResetHandler()
7001 return -1; in mpt_SoftResetHandler()
7003 ioc->ioc_reset_in_progress = 1; in mpt_SoftResetHandler()
7004 spin_unlock_irqrestore(&ioc->taskmgmt_lock, flags); in mpt_SoftResetHandler()
7006 for (cb_idx = MPT_MAX_PROTOCOL_DRIVERS-1; cb_idx; cb_idx--) { in mpt_SoftResetHandler()
7011 spin_lock_irqsave(&ioc->taskmgmt_lock, flags); in mpt_SoftResetHandler()
7012 if (ioc->taskmgmt_in_progress) { in mpt_SoftResetHandler()
7013 ioc->ioc_reset_in_progress = 0; in mpt_SoftResetHandler()
7014 spin_unlock_irqrestore(&ioc->taskmgmt_lock, flags); in mpt_SoftResetHandler()
7015 return -1; in mpt_SoftResetHandler()
7017 spin_unlock_irqrestore(&ioc->taskmgmt_lock, flags); in mpt_SoftResetHandler()
7019 CHIPREG_WRITE32(&ioc->chip->IntMask, 0xFFFFFFFF); in mpt_SoftResetHandler()
7020 ioc->active = 0; in mpt_SoftResetHandler()
7025 for (cb_idx = MPT_MAX_PROTOCOL_DRIVERS-1; cb_idx; cb_idx--) { in mpt_SoftResetHandler()
7063 if (ioc->hard_resets < -1) in mpt_SoftResetHandler()
7064 ioc->hard_resets++; in mpt_SoftResetHandler()
7070 ioc->active = 1; in mpt_SoftResetHandler()
7071 CHIPREG_WRITE32(&ioc->chip->IntMask, MPI_HIM_DIM); in mpt_SoftResetHandler()
7074 spin_lock_irqsave(&ioc->taskmgmt_lock, flags); in mpt_SoftResetHandler()
7075 ioc->ioc_reset_in_progress = 0; in mpt_SoftResetHandler()
7076 ioc->taskmgmt_quiesce_io = 0; in mpt_SoftResetHandler()
7077 ioc->taskmgmt_in_progress = 0; in mpt_SoftResetHandler()
7078 spin_unlock_irqrestore(&ioc->taskmgmt_lock, flags); in mpt_SoftResetHandler()
7080 if (ioc->active) { /* otherwise, hard reset coming */ in mpt_SoftResetHandler()
7081 for (cb_idx = MPT_MAX_PROTOCOL_DRIVERS-1; cb_idx; cb_idx--) { in mpt_SoftResetHandler()
7090 ioc->name, jiffies_to_msecs(jiffies - time_count)/1000, in mpt_SoftResetHandler()
7097 * mpt_Soft_Hard_ResetHandler - Try less expensive reset
7101 * Returns 0 for SUCCESS or -1 if FAILED.
7107 int ret = -1; in mpt_Soft_Hard_ResetHandler()
7117 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
7121 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
7123 * mpt_HardResetHandler - Generic reset handler
7131 * or a non-interrupt thread. In the former, must not call schedule().
7133 * Note: A return of -1 is a FATAL error case, as it means a
7136 * Returns 0 for SUCCESS or -1 if FAILED.
7146 dtmprintk(ioc, printk(MYIOC_s_DEBUG_FMT "HardResetHandler Entered!\n", ioc->name)); in mpt_HardResetHandler()
7148 printk(MYIOC_s_INFO_FMT "HardResetHandler Entered!\n", ioc->name); in mpt_HardResetHandler()
7149 printk("MF count 0x%x !\n", ioc->mfcnt); in mpt_HardResetHandler()
7157 spin_lock_irqsave(&ioc->taskmgmt_lock, flags); in mpt_HardResetHandler()
7158 if (ioc->ioc_reset_in_progress) { in mpt_HardResetHandler()
7159 spin_unlock_irqrestore(&ioc->taskmgmt_lock, flags); in mpt_HardResetHandler()
7160 ioc->wait_on_reset_completion = 1; in mpt_HardResetHandler()
7163 } while (ioc->ioc_reset_in_progress == 1); in mpt_HardResetHandler()
7164 ioc->wait_on_reset_completion = 0; in mpt_HardResetHandler()
7165 return ioc->reset_status; in mpt_HardResetHandler()
7167 if (ioc->wait_on_reset_completion) { in mpt_HardResetHandler()
7168 spin_unlock_irqrestore(&ioc->taskmgmt_lock, flags); in mpt_HardResetHandler()
7173 ioc->ioc_reset_in_progress = 1; in mpt_HardResetHandler()
7174 if (ioc->alt_ioc) in mpt_HardResetHandler()
7175 ioc->alt_ioc->ioc_reset_in_progress = 1; in mpt_HardResetHandler()
7176 spin_unlock_irqrestore(&ioc->taskmgmt_lock, flags); in mpt_HardResetHandler()
7182 * For all other protocol drivers, this is a no-op. in mpt_HardResetHandler()
7184 for (cb_idx = MPT_MAX_PROTOCOL_DRIVERS-1; cb_idx; cb_idx--) { in mpt_HardResetHandler()
7187 if (ioc->alt_ioc) in mpt_HardResetHandler()
7188 mpt_signal_reset(cb_idx, ioc->alt_ioc, in mpt_HardResetHandler()
7197 ": WARNING - (%d) Cannot recover %s, doorbell=0x%08x\n", in mpt_HardResetHandler()
7198 rc, ioc->name, mpt_GetIocState(ioc, 0)); in mpt_HardResetHandler()
7200 if (ioc->hard_resets < -1) in mpt_HardResetHandler()
7201 ioc->hard_resets++; in mpt_HardResetHandler()
7204 spin_lock_irqsave(&ioc->taskmgmt_lock, flags); in mpt_HardResetHandler()
7205 ioc->ioc_reset_in_progress = 0; in mpt_HardResetHandler()
7206 ioc->taskmgmt_quiesce_io = 0; in mpt_HardResetHandler()
7207 ioc->taskmgmt_in_progress = 0; in mpt_HardResetHandler()
7208 ioc->reset_status = rc; in mpt_HardResetHandler()
7209 if (ioc->alt_ioc) { in mpt_HardResetHandler()
7210 ioc->alt_ioc->ioc_reset_in_progress = 0; in mpt_HardResetHandler()
7211 ioc->alt_ioc->taskmgmt_quiesce_io = 0; in mpt_HardResetHandler()
7212 ioc->alt_ioc->taskmgmt_in_progress = 0; in mpt_HardResetHandler()
7214 spin_unlock_irqrestore(&ioc->taskmgmt_lock, flags); in mpt_HardResetHandler()
7216 for (cb_idx = MPT_MAX_PROTOCOL_DRIVERS-1; cb_idx; cb_idx--) { in mpt_HardResetHandler()
7219 if (ioc->alt_ioc) in mpt_HardResetHandler()
7221 ioc->alt_ioc, MPT_IOC_POST_RESET); in mpt_HardResetHandler()
7227 "HardResetHandler: completed (%d seconds): %s\n", ioc->name, in mpt_HardResetHandler()
7228 jiffies_to_msecs(jiffies - time_count)/1000, ((rc == 0) ? in mpt_HardResetHandler()
7242 char *evStr = ioc->evStr; in mpt_display_event_info()
7244 event = le32_to_cpu(pEventReply->Event) & 0xFF; in mpt_display_event_info()
7245 evData0 = le32_to_cpu(pEventReply->Data[0]); in mpt_display_event_info()
7670 ioc->name, event, evStr)); in mpt_display_event_info()
7674 for (ii = 0; ii < le16_to_cpu(pEventReply->EventDataLength); ii++) in mpt_display_event_info()
7676 le32_to_cpu(pEventReply->Data[ii]))); in mpt_display_event_info()
7680 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
7682 * ProcessEventNotification - Route EventNotificationReply to all event handlers
7705 event = le32_to_cpu(pEventReply->Event) & 0xFF; in ProcessEventNotification()
7706 evDataLen = le16_to_cpu(pEventReply->EventDataLength); in ProcessEventNotification()
7708 evData0 = le32_to_cpu(pEventReply->Data[0]); in ProcessEventNotification()
7727 if (ioc->facts.Function) { in ProcessEventNotification()
7728 ioc->facts.EventState = evState; in ProcessEventNotification()
7734 (MpiEventDataRaid_t *)pEventReply->Data); in ProcessEventNotification()
7744 if (ioc->events && (ioc->eventTypes & ( 1 << event))) { in ProcessEventNotification()
7747 idx = ioc->eventContext % MPTCTL_EVENT_LOG_SIZE; in ProcessEventNotification()
7749 ioc->events[idx].event = event; in ProcessEventNotification()
7750 ioc->events[idx].eventContext = ioc->eventContext; in ProcessEventNotification()
7754 ioc->events[idx].data[ii] = le32_to_cpu(pEventReply->Data[ii]); in ProcessEventNotification()
7756 ioc->events[idx].data[ii] = 0; in ProcessEventNotification()
7759 ioc->eventContext++; in ProcessEventNotification()
7766 for (cb_idx = MPT_MAX_PROTOCOL_DRIVERS-1; cb_idx; cb_idx--) { in ProcessEventNotification()
7770 ioc->name, cb_idx)); in ProcessEventNotification()
7780 if (pEventReply->AckRequired == MPI_EVENT_NOTIFICATION_ACK_REQUIRED) { in ProcessEventNotification()
7782 "EventAck required\n",ioc->name)); in ProcessEventNotification()
7785 ioc->name, ii)); in ProcessEventNotification()
7793 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
7795 * mpt_fc_log_info - Log information returned from Fibre Channel IOC.
7834 ioc->name, log_info, desc, (log_info & 0xFFFFFF)); in mpt_fc_log_info()
7837 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
7839 * mpt_spi_log_info - Log information returned from SCSI Parallel IOC.
7902 printk(MYIOC_s_INFO_FMT "LogInfo(0x%08x): F/W: %s\n", ioc->name, log_info, desc); in mpt_spi_log_info()
7928 "SATA Non-NCQ RW Error Bit Set", /* 06h */
8048 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
8050 * mpt_sas_log_info - Log information returned from SAS IOC.
8113 ioc->name, log_info, originator_desc, code_desc, in mpt_sas_log_info()
8119 ioc->name, log_info, originator_desc, code_desc, in mpt_sas_log_info()
8125 ioc->name, log_info, originator_desc, in mpt_sas_log_info()
8130 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
8132 * mpt_iocstatus_info_config - IOCSTATUS information for config pages
8148 if (pReq->Header.PageType == MPI_CONFIG_PAGETYPE_EXTENDED) in mpt_iocstatus_info_config()
8149 page_type = pReq->ExtPageType; in mpt_iocstatus_info_config()
8151 page_type = pReq->Header.PageType; in mpt_iocstatus_info_config()
8156 form = le32_to_cpu(pReq->PageAddress); in mpt_iocstatus_info_config()
8173 page_type, pReq->Header.PageNumber, pReq->Action, form); in mpt_iocstatus_info_config()
8206 ioc->name, ioc_status, desc, extend_desc)); in mpt_iocstatus_info_config()
8210 * mpt_iocstatus_info - IOCSTATUS information returned from IOC.
8433 ioc->name, status, desc)); in mpt_iocstatus_info()
8436 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
8468 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
8470 * fusion_init - Fusion MPT base driver initialization routine.
8472 * Returns 0 for success, non-zero for failure.
8505 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
8507 * fusion_exit - Perform driver unload cleanup.