aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/message/fusion/mptbase.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/message/fusion/mptbase.c')
-rw-r--r--drivers/message/fusion/mptbase.c602
1 files changed, 344 insertions, 258 deletions
diff --git a/drivers/message/fusion/mptbase.c b/drivers/message/fusion/mptbase.c
index 414c109f4cf5..52fb216dfe74 100644
--- a/drivers/message/fusion/mptbase.c
+++ b/drivers/message/fusion/mptbase.c
@@ -2,10 +2,10 @@
2 * linux/drivers/message/fusion/mptbase.c 2 * linux/drivers/message/fusion/mptbase.c
3 * This is the Fusion MPT base driver which supports multiple 3 * This is the Fusion MPT base driver which supports multiple
4 * (SCSI + LAN) specialized protocol drivers. 4 * (SCSI + LAN) specialized protocol drivers.
5 * For use with LSI Logic PCI chip/adapter(s) 5 * For use with LSI PCI chip/adapter(s)
6 * running LSI Logic Fusion MPT (Message Passing Technology) firmware. 6 * running LSI Fusion MPT (Message Passing Technology) firmware.
7 * 7 *
8 * Copyright (c) 1999-2007 LSI Logic Corporation 8 * Copyright (c) 1999-2007 LSI Corporation
9 * (mailto:DL-MPTFusionLinux@lsi.com) 9 * (mailto:DL-MPTFusionLinux@lsi.com)
10 * 10 *
11 */ 11 */
@@ -102,8 +102,6 @@ static int mfcounter = 0;
102/* 102/*
103 * Public data... 103 * Public data...
104 */ 104 */
105int mpt_lan_index = -1;
106int mpt_stm_index = -1;
107 105
108struct proc_dir_entry *mpt_proc_root_dir; 106struct proc_dir_entry *mpt_proc_root_dir;
109 107
@@ -125,11 +123,14 @@ static MPT_EVHANDLER MptEvHandlers[MPT_MAX_PROTOCOL_DRIVERS];
125static MPT_RESETHANDLER MptResetHandlers[MPT_MAX_PROTOCOL_DRIVERS]; 123static MPT_RESETHANDLER MptResetHandlers[MPT_MAX_PROTOCOL_DRIVERS];
126static struct mpt_pci_driver *MptDeviceDriverHandlers[MPT_MAX_PROTOCOL_DRIVERS]; 124static struct mpt_pci_driver *MptDeviceDriverHandlers[MPT_MAX_PROTOCOL_DRIVERS];
127 125
128static int mpt_base_index = -1;
129static int last_drv_idx = -1;
130
131static DECLARE_WAIT_QUEUE_HEAD(mpt_waitq); 126static DECLARE_WAIT_QUEUE_HEAD(mpt_waitq);
132 127
128/*
129 * Driver Callback Index's
130 */
131static u8 mpt_base_index = MPT_MAX_PROTOCOL_DRIVERS;
132static u8 last_drv_idx;
133
133/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 134/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
134/* 135/*
135 * Forward protos... 136 * Forward protos...
@@ -235,6 +236,23 @@ static int mpt_set_debug_level(const char *val, struct kernel_param *kp)
235 return 0; 236 return 0;
236} 237}
237 238
239/**
240 * mpt_get_cb_idx - obtain cb_idx for registered driver
241 * @dclass: class driver enum
242 *
243 * Returns cb_idx, or zero means it wasn't found
244 **/
245static u8
246mpt_get_cb_idx(MPT_DRIVER_CLASS dclass)
247{
248 u8 cb_idx;
249
250 for (cb_idx = MPT_MAX_PROTOCOL_DRIVERS-1; cb_idx; cb_idx--)
251 if (MptDriverClass[cb_idx] == dclass)
252 return cb_idx;
253 return 0;
254}
255
238/* 256/*
239 * Process turbo (context) reply... 257 * Process turbo (context) reply...
240 */ 258 */
@@ -243,8 +261,8 @@ mpt_turbo_reply(MPT_ADAPTER *ioc, u32 pa)
243{ 261{
244 MPT_FRAME_HDR *mf = NULL; 262 MPT_FRAME_HDR *mf = NULL;
245 MPT_FRAME_HDR *mr = NULL; 263 MPT_FRAME_HDR *mr = NULL;
246 int req_idx = 0; 264 u16 req_idx = 0;
247 int cb_idx; 265 u8 cb_idx;
248 266
249 dmfprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Got TURBO reply req_idx=%08x\n", 267 dmfprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Got TURBO reply req_idx=%08x\n",
250 ioc->name, pa)); 268 ioc->name, pa));
@@ -256,7 +274,7 @@ mpt_turbo_reply(MPT_ADAPTER *ioc, u32 pa)
256 mf = MPT_INDEX_2_MFPTR(ioc, req_idx); 274 mf = MPT_INDEX_2_MFPTR(ioc, req_idx);
257 break; 275 break;
258 case MPI_CONTEXT_REPLY_TYPE_LAN: 276 case MPI_CONTEXT_REPLY_TYPE_LAN:
259 cb_idx = mpt_lan_index; 277 cb_idx = mpt_get_cb_idx(MPTLAN_DRIVER);
260 /* 278 /*
261 * Blind set of mf to NULL here was fatal 279 * Blind set of mf to NULL here was fatal
262 * after lan_reply says "freeme" 280 * after lan_reply says "freeme"
@@ -277,7 +295,7 @@ mpt_turbo_reply(MPT_ADAPTER *ioc, u32 pa)
277 mr = (MPT_FRAME_HDR *) CAST_U32_TO_PTR(pa); 295 mr = (MPT_FRAME_HDR *) CAST_U32_TO_PTR(pa);
278 break; 296 break;
279 case MPI_CONTEXT_REPLY_TYPE_SCSI_TARGET: 297 case MPI_CONTEXT_REPLY_TYPE_SCSI_TARGET:
280 cb_idx = mpt_stm_index; 298 cb_idx = mpt_get_cb_idx(MPTSTM_DRIVER);
281 mr = (MPT_FRAME_HDR *) CAST_U32_TO_PTR(pa); 299 mr = (MPT_FRAME_HDR *) CAST_U32_TO_PTR(pa);
282 break; 300 break;
283 default: 301 default:
@@ -286,8 +304,8 @@ mpt_turbo_reply(MPT_ADAPTER *ioc, u32 pa)
286 } 304 }
287 305
288 /* Check for (valid) IO callback! */ 306 /* Check for (valid) IO callback! */
289 if (cb_idx < 1 || cb_idx >= MPT_MAX_PROTOCOL_DRIVERS || 307 if (!cb_idx || cb_idx >= MPT_MAX_PROTOCOL_DRIVERS ||
290 MptCallbacks[cb_idx] == NULL) { 308 MptCallbacks[cb_idx] == NULL) {
291 printk(MYIOC_s_WARN_FMT "%s: Invalid cb_idx (%d)!\n", 309 printk(MYIOC_s_WARN_FMT "%s: Invalid cb_idx (%d)!\n",
292 __FUNCTION__, ioc->name, cb_idx); 310 __FUNCTION__, ioc->name, cb_idx);
293 goto out; 311 goto out;
@@ -304,8 +322,8 @@ mpt_reply(MPT_ADAPTER *ioc, u32 pa)
304{ 322{
305 MPT_FRAME_HDR *mf; 323 MPT_FRAME_HDR *mf;
306 MPT_FRAME_HDR *mr; 324 MPT_FRAME_HDR *mr;
307 int req_idx; 325 u16 req_idx;
308 int cb_idx; 326 u8 cb_idx;
309 int freeme; 327 int freeme;
310 328
311 u32 reply_dma_low; 329 u32 reply_dma_low;
@@ -331,7 +349,7 @@ mpt_reply(MPT_ADAPTER *ioc, u32 pa)
331 349
332 dmfprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Got non-TURBO reply=%p req_idx=%x cb_idx=%x Function=%x\n", 350 dmfprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Got non-TURBO reply=%p req_idx=%x cb_idx=%x Function=%x\n",
333 ioc->name, mr, req_idx, cb_idx, mr->u.hdr.Function)); 351 ioc->name, mr, req_idx, cb_idx, mr->u.hdr.Function));
334 DBG_DUMP_REPLY_FRAME(ioc, (u32 *)mr) 352 DBG_DUMP_REPLY_FRAME(ioc, (u32 *)mr);
335 353
336 /* Check/log IOC log info 354 /* Check/log IOC log info
337 */ 355 */
@@ -350,8 +368,8 @@ mpt_reply(MPT_ADAPTER *ioc, u32 pa)
350 mpt_iocstatus_info(ioc, (u32)ioc_stat, mf); 368 mpt_iocstatus_info(ioc, (u32)ioc_stat, mf);
351 369
352 /* Check for (valid) IO callback! */ 370 /* Check for (valid) IO callback! */
353 if (cb_idx < 1 || cb_idx >= MPT_MAX_PROTOCOL_DRIVERS || 371 if (!cb_idx || cb_idx >= MPT_MAX_PROTOCOL_DRIVERS ||
354 MptCallbacks[cb_idx] == NULL) { 372 MptCallbacks[cb_idx] == NULL) {
355 printk(MYIOC_s_WARN_FMT "%s: Invalid cb_idx (%d)!\n", 373 printk(MYIOC_s_WARN_FMT "%s: Invalid cb_idx (%d)!\n",
356 __FUNCTION__, ioc->name, cb_idx); 374 __FUNCTION__, ioc->name, cb_idx);
357 freeme = 0; 375 freeme = 0;
@@ -433,8 +451,9 @@ mpt_base_reply(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *reply)
433#ifdef CONFIG_FUSION_LOGGING 451#ifdef CONFIG_FUSION_LOGGING
434 if ((ioc->debug_level & MPT_DEBUG_MSG_FRAME) && 452 if ((ioc->debug_level & MPT_DEBUG_MSG_FRAME) &&
435 !(reply->u.hdr.MsgFlags & MPI_MSGFLAGS_CONTINUATION_REPLY)) { 453 !(reply->u.hdr.MsgFlags & MPI_MSGFLAGS_CONTINUATION_REPLY)) {
436 dmfprintk(ioc, printk(KERN_INFO MYNAM ": Original request frame (@%p) header\n", mf)); 454 dmfprintk(ioc, printk(MYIOC_s_INFO_FMT ": Original request frame (@%p) header\n",
437 DBG_DUMP_REQUEST_FRAME_HDR(ioc, (u32 *)mf) 455 ioc->name, mf));
456 DBG_DUMP_REQUEST_FRAME_HDR(ioc, (u32 *)mf);
438 } 457 }
439#endif 458#endif
440 459
@@ -499,8 +518,8 @@ mpt_base_reply(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *reply)
499 u16 status; 518 u16 status;
500 519
501 status = le16_to_cpu(pReply->IOCStatus) & MPI_IOCSTATUS_MASK; 520 status = le16_to_cpu(pReply->IOCStatus) & MPI_IOCSTATUS_MASK;
502 dcprintk(ioc, printk(KERN_NOTICE " IOCStatus=%04xh, IOCLogInfo=%08xh\n", 521 dcprintk(ioc, printk(MYIOC_s_NOTE_FMT " IOCStatus=%04xh, IOCLogInfo=%08xh\n",
503 status, le32_to_cpu(pReply->IOCLogInfo))); 522 ioc->name, status, le32_to_cpu(pReply->IOCLogInfo)));
504 523
505 pCfg->status = status; 524 pCfg->status = status;
506 if (status == MPI_IOCSTATUS_SUCCESS) { 525 if (status == MPI_IOCSTATUS_SUCCESS) {
@@ -563,28 +582,27 @@ mpt_base_reply(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *reply)
563 * in order to register separate callbacks; one for "normal" SCSI IO; 582 * in order to register separate callbacks; one for "normal" SCSI IO;
564 * one for MptScsiTaskMgmt requests; one for Scan/DV requests. 583 * one for MptScsiTaskMgmt requests; one for Scan/DV requests.
565 * 584 *
566 * Returns a positive integer valued "handle" in the 585 * Returns u8 valued "handle" in the range (and S.O.D. order)
567 * range (and S.O.D. order) {N,...,7,6,5,...,1} if successful. 586 * {N,...,7,6,5,...,1} if successful.
568 * Any non-positive return value (including zero!) should be considered 587 * A return value of MPT_MAX_PROTOCOL_DRIVERS (including zero!) should be
569 * an error by the caller. 588 * considered an error by the caller.
570 */ 589 */
571int 590u8
572mpt_register(MPT_CALLBACK cbfunc, MPT_DRIVER_CLASS dclass) 591mpt_register(MPT_CALLBACK cbfunc, MPT_DRIVER_CLASS dclass)
573{ 592{
574 int i; 593 u8 cb_idx;
575 594 last_drv_idx = MPT_MAX_PROTOCOL_DRIVERS;
576 last_drv_idx = -1;
577 595
578 /* 596 /*
579 * Search for empty callback slot in this order: {N,...,7,6,5,...,1} 597 * Search for empty callback slot in this order: {N,...,7,6,5,...,1}
580 * (slot/handle 0 is reserved!) 598 * (slot/handle 0 is reserved!)
581 */ 599 */
582 for (i = MPT_MAX_PROTOCOL_DRIVERS-1; i; i--) { 600 for (cb_idx = MPT_MAX_PROTOCOL_DRIVERS-1; cb_idx; cb_idx--) {
583 if (MptCallbacks[i] == NULL) { 601 if (MptCallbacks[cb_idx] == NULL) {
584 MptCallbacks[i] = cbfunc; 602 MptCallbacks[cb_idx] = cbfunc;
585 MptDriverClass[i] = dclass; 603 MptDriverClass[cb_idx] = dclass;
586 MptEvHandlers[i] = NULL; 604 MptEvHandlers[cb_idx] = NULL;
587 last_drv_idx = i; 605 last_drv_idx = cb_idx;
588 break; 606 break;
589 } 607 }
590 } 608 }
@@ -601,9 +619,9 @@ mpt_register(MPT_CALLBACK cbfunc, MPT_DRIVER_CLASS dclass)
601 * module is unloaded. 619 * module is unloaded.
602 */ 620 */
603void 621void
604mpt_deregister(int cb_idx) 622mpt_deregister(u8 cb_idx)
605{ 623{
606 if ((cb_idx >= 0) && (cb_idx < MPT_MAX_PROTOCOL_DRIVERS)) { 624 if (cb_idx && (cb_idx < MPT_MAX_PROTOCOL_DRIVERS)) {
607 MptCallbacks[cb_idx] = NULL; 625 MptCallbacks[cb_idx] = NULL;
608 MptDriverClass[cb_idx] = MPTUNKNOWN_DRIVER; 626 MptDriverClass[cb_idx] = MPTUNKNOWN_DRIVER;
609 MptEvHandlers[cb_idx] = NULL; 627 MptEvHandlers[cb_idx] = NULL;
@@ -625,9 +643,9 @@ mpt_deregister(int cb_idx)
625 * Returns 0 for success. 643 * Returns 0 for success.
626 */ 644 */
627int 645int
628mpt_event_register(int cb_idx, MPT_EVHANDLER ev_cbfunc) 646mpt_event_register(u8 cb_idx, MPT_EVHANDLER ev_cbfunc)
629{ 647{
630 if (cb_idx < 1 || cb_idx >= MPT_MAX_PROTOCOL_DRIVERS) 648 if (!cb_idx || cb_idx >= MPT_MAX_PROTOCOL_DRIVERS)
631 return -1; 649 return -1;
632 650
633 MptEvHandlers[cb_idx] = ev_cbfunc; 651 MptEvHandlers[cb_idx] = ev_cbfunc;
@@ -645,9 +663,9 @@ mpt_event_register(int cb_idx, MPT_EVHANDLER ev_cbfunc)
645 * or when its module is unloaded. 663 * or when its module is unloaded.
646 */ 664 */
647void 665void
648mpt_event_deregister(int cb_idx) 666mpt_event_deregister(u8 cb_idx)
649{ 667{
650 if (cb_idx < 1 || cb_idx >= MPT_MAX_PROTOCOL_DRIVERS) 668 if (!cb_idx || cb_idx >= MPT_MAX_PROTOCOL_DRIVERS)
651 return; 669 return;
652 670
653 MptEvHandlers[cb_idx] = NULL; 671 MptEvHandlers[cb_idx] = NULL;
@@ -665,9 +683,9 @@ mpt_event_deregister(int cb_idx)
665 * Returns 0 for success. 683 * Returns 0 for success.
666 */ 684 */
667int 685int
668mpt_reset_register(int cb_idx, MPT_RESETHANDLER reset_func) 686mpt_reset_register(u8 cb_idx, MPT_RESETHANDLER reset_func)
669{ 687{
670 if (cb_idx < 1 || cb_idx >= MPT_MAX_PROTOCOL_DRIVERS) 688 if (!cb_idx || cb_idx >= MPT_MAX_PROTOCOL_DRIVERS)
671 return -1; 689 return -1;
672 690
673 MptResetHandlers[cb_idx] = reset_func; 691 MptResetHandlers[cb_idx] = reset_func;
@@ -684,9 +702,9 @@ mpt_reset_register(int cb_idx, MPT_RESETHANDLER reset_func)
684 * or when its module is unloaded. 702 * or when its module is unloaded.
685 */ 703 */
686void 704void
687mpt_reset_deregister(int cb_idx) 705mpt_reset_deregister(u8 cb_idx)
688{ 706{
689 if (cb_idx < 1 || cb_idx >= MPT_MAX_PROTOCOL_DRIVERS) 707 if (!cb_idx || cb_idx >= MPT_MAX_PROTOCOL_DRIVERS)
690 return; 708 return;
691 709
692 MptResetHandlers[cb_idx] = NULL; 710 MptResetHandlers[cb_idx] = NULL;
@@ -699,12 +717,12 @@ mpt_reset_deregister(int cb_idx)
699 * @cb_idx: MPT protocol driver index 717 * @cb_idx: MPT protocol driver index
700 */ 718 */
701int 719int
702mpt_device_driver_register(struct mpt_pci_driver * dd_cbfunc, int cb_idx) 720mpt_device_driver_register(struct mpt_pci_driver * dd_cbfunc, u8 cb_idx)
703{ 721{
704 MPT_ADAPTER *ioc; 722 MPT_ADAPTER *ioc;
705 const struct pci_device_id *id; 723 const struct pci_device_id *id;
706 724
707 if (cb_idx < 1 || cb_idx >= MPT_MAX_PROTOCOL_DRIVERS) 725 if (!cb_idx || cb_idx >= MPT_MAX_PROTOCOL_DRIVERS)
708 return -EINVAL; 726 return -EINVAL;
709 727
710 MptDeviceDriverHandlers[cb_idx] = dd_cbfunc; 728 MptDeviceDriverHandlers[cb_idx] = dd_cbfunc;
@@ -726,12 +744,12 @@ mpt_device_driver_register(struct mpt_pci_driver * dd_cbfunc, int cb_idx)
726 * @cb_idx: MPT protocol driver index 744 * @cb_idx: MPT protocol driver index
727 */ 745 */
728void 746void
729mpt_device_driver_deregister(int cb_idx) 747mpt_device_driver_deregister(u8 cb_idx)
730{ 748{
731 struct mpt_pci_driver *dd_cbfunc; 749 struct mpt_pci_driver *dd_cbfunc;
732 MPT_ADAPTER *ioc; 750 MPT_ADAPTER *ioc;
733 751
734 if (cb_idx < 1 || cb_idx >= MPT_MAX_PROTOCOL_DRIVERS) 752 if (!cb_idx || cb_idx >= MPT_MAX_PROTOCOL_DRIVERS)
735 return; 753 return;
736 754
737 dd_cbfunc = MptDeviceDriverHandlers[cb_idx]; 755 dd_cbfunc = MptDeviceDriverHandlers[cb_idx];
@@ -749,14 +767,14 @@ mpt_device_driver_deregister(int cb_idx)
749/** 767/**
750 * mpt_get_msg_frame - Obtain a MPT request frame from the pool (of 1024) 768 * mpt_get_msg_frame - Obtain a MPT request frame from the pool (of 1024)
751 * allocated per MPT adapter. 769 * allocated per MPT adapter.
752 * @handle: Handle of registered MPT protocol driver 770 * @cb_idx: Handle of registered MPT protocol driver
753 * @ioc: Pointer to MPT adapter structure 771 * @ioc: Pointer to MPT adapter structure
754 * 772 *
755 * Returns pointer to a MPT request frame or %NULL if none are available 773 * Returns pointer to a MPT request frame or %NULL if none are available
756 * or IOC is not active. 774 * or IOC is not active.
757 */ 775 */
758MPT_FRAME_HDR* 776MPT_FRAME_HDR*
759mpt_get_msg_frame(int handle, MPT_ADAPTER *ioc) 777mpt_get_msg_frame(u8 cb_idx, MPT_ADAPTER *ioc)
760{ 778{
761 MPT_FRAME_HDR *mf; 779 MPT_FRAME_HDR *mf;
762 unsigned long flags; 780 unsigned long flags;
@@ -766,7 +784,8 @@ mpt_get_msg_frame(int handle, MPT_ADAPTER *ioc)
766 784
767#ifdef MFCNT 785#ifdef MFCNT
768 if (!ioc->active) 786 if (!ioc->active)
769 printk(KERN_WARNING "IOC Not Active! mpt_get_msg_frame returning NULL!\n"); 787 printk(MYIOC_s_WARN_FMT "IOC Not Active! mpt_get_msg_frame "
788 "returning NULL!\n", ioc->name);
770#endif 789#endif
771 790
772 /* If interrupts are not attached, do not return a request frame */ 791 /* If interrupts are not attached, do not return a request frame */
@@ -781,13 +800,14 @@ mpt_get_msg_frame(int handle, MPT_ADAPTER *ioc)
781 u.frame.linkage.list); 800 u.frame.linkage.list);
782 list_del(&mf->u.frame.linkage.list); 801 list_del(&mf->u.frame.linkage.list);
783 mf->u.frame.linkage.arg1 = 0; 802 mf->u.frame.linkage.arg1 = 0;
784 mf->u.frame.hwhdr.msgctxu.fld.cb_idx = handle; /* byte */ 803 mf->u.frame.hwhdr.msgctxu.fld.cb_idx = cb_idx; /* byte */
785 req_offset = (u8 *)mf - (u8 *)ioc->req_frames; 804 req_offset = (u8 *)mf - (u8 *)ioc->req_frames;
786 /* u16! */ 805 /* u16! */
787 req_idx = req_offset / ioc->req_sz; 806 req_idx = req_offset / ioc->req_sz;
788 mf->u.frame.hwhdr.msgctxu.fld.req_idx = cpu_to_le16(req_idx); 807 mf->u.frame.hwhdr.msgctxu.fld.req_idx = cpu_to_le16(req_idx);
789 mf->u.frame.hwhdr.msgctxu.fld.rsvd = 0; 808 mf->u.frame.hwhdr.msgctxu.fld.rsvd = 0;
790 ioc->RequestNB[req_idx] = ioc->NB_for_64_byte_frame; /* Default, will be changed if necessary in SG generation */ 809 /* Default, will be changed if necessary in SG generation */
810 ioc->RequestNB[req_idx] = ioc->NB_for_64_byte_frame;
791#ifdef MFCNT 811#ifdef MFCNT
792 ioc->mfcnt++; 812 ioc->mfcnt++;
793#endif 813#endif
@@ -798,14 +818,17 @@ mpt_get_msg_frame(int handle, MPT_ADAPTER *ioc)
798 818
799#ifdef MFCNT 819#ifdef MFCNT
800 if (mf == NULL) 820 if (mf == NULL)
801 printk(KERN_WARNING "IOC Active. No free Msg Frames! Count 0x%x Max 0x%x\n", ioc->mfcnt, ioc->req_depth); 821 printk(MYIOC_s_WARN_FMT "IOC Active. No free Msg Frames! "
822 "Count 0x%x Max 0x%x\n", ioc->name, ioc->mfcnt,
823 ioc->req_depth);
802 mfcounter++; 824 mfcounter++;
803 if (mfcounter == PRINT_MF_COUNT) 825 if (mfcounter == PRINT_MF_COUNT)
804 printk(KERN_INFO "MF Count 0x%x Max 0x%x \n", ioc->mfcnt, ioc->req_depth); 826 printk(MYIOC_s_INFO_FMT "MF Count 0x%x Max 0x%x \n", ioc->name,
827 ioc->mfcnt, ioc->req_depth);
805#endif 828#endif
806 829
807 dmfprintk(ioc, printk(KERN_INFO MYNAM ": %s: mpt_get_msg_frame(%d,%d), got mf=%p\n", 830 dmfprintk(ioc, printk(MYIOC_s_DEBUG_FMT "mpt_get_msg_frame(%d,%d), got mf=%p\n",
808 ioc->name, handle, ioc->id, mf)); 831 ioc->name, cb_idx, ioc->id, mf));
809 return mf; 832 return mf;
810} 833}
811 834
@@ -813,7 +836,7 @@ mpt_get_msg_frame(int handle, MPT_ADAPTER *ioc)
813/** 836/**
814 * mpt_put_msg_frame - Send a protocol specific MPT request frame 837 * mpt_put_msg_frame - Send a protocol specific MPT request frame
815 * to a IOC. 838 * to a IOC.
816 * @handle: Handle of registered MPT protocol driver 839 * @cb_idx: Handle of registered MPT protocol driver
817 * @ioc: Pointer to MPT adapter structure 840 * @ioc: Pointer to MPT adapter structure
818 * @mf: Pointer to MPT request frame 841 * @mf: Pointer to MPT request frame
819 * 842 *
@@ -821,14 +844,14 @@ mpt_get_msg_frame(int handle, MPT_ADAPTER *ioc)
821 * specific MPT adapter. 844 * specific MPT adapter.
822 */ 845 */
823void 846void
824mpt_put_msg_frame(int handle, MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf) 847mpt_put_msg_frame(u8 cb_idx, MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf)
825{ 848{
826 u32 mf_dma_addr; 849 u32 mf_dma_addr;
827 int req_offset; 850 int req_offset;
828 u16 req_idx; /* Request index */ 851 u16 req_idx; /* Request index */
829 852
830 /* ensure values are reset properly! */ 853 /* ensure values are reset properly! */
831 mf->u.frame.hwhdr.msgctxu.fld.cb_idx = handle; /* byte */ 854 mf->u.frame.hwhdr.msgctxu.fld.cb_idx = cb_idx; /* byte */
832 req_offset = (u8 *)mf - (u8 *)ioc->req_frames; 855 req_offset = (u8 *)mf - (u8 *)ioc->req_frames;
833 /* u16! */ 856 /* u16! */
834 req_idx = req_offset / ioc->req_sz; 857 req_idx = req_offset / ioc->req_sz;
@@ -838,10 +861,44 @@ mpt_put_msg_frame(int handle, MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf)
838 DBG_DUMP_PUT_MSG_FRAME(ioc, (u32 *)mf); 861 DBG_DUMP_PUT_MSG_FRAME(ioc, (u32 *)mf);
839 862
840 mf_dma_addr = (ioc->req_frames_low_dma + req_offset) | ioc->RequestNB[req_idx]; 863 mf_dma_addr = (ioc->req_frames_low_dma + req_offset) | ioc->RequestNB[req_idx];
841 dsgprintk(ioc, printk(MYIOC_s_DEBUG_FMT "mf_dma_addr=%x req_idx=%d RequestNB=%x\n", ioc->name, mf_dma_addr, req_idx, ioc->RequestNB[req_idx])); 864 dsgprintk(ioc, printk(MYIOC_s_DEBUG_FMT "mf_dma_addr=%x req_idx=%d "
865 "RequestNB=%x\n", ioc->name, mf_dma_addr, req_idx,
866 ioc->RequestNB[req_idx]));
842 CHIPREG_WRITE32(&ioc->chip->RequestFifo, mf_dma_addr); 867 CHIPREG_WRITE32(&ioc->chip->RequestFifo, mf_dma_addr);
843} 868}
844 869
870/**
871 * mpt_put_msg_frame_hi_pri - Send a protocol specific MPT request frame
872 * to a IOC using hi priority request queue.
873 * @cb_idx: Handle of registered MPT protocol driver
874 * @ioc: Pointer to MPT adapter structure
875 * @mf: Pointer to MPT request frame
876 *
877 * This routine posts a MPT request frame to the request post FIFO of a
878 * specific MPT adapter.
879 **/
880void
881mpt_put_msg_frame_hi_pri(u8 cb_idx, MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf)
882{
883 u32 mf_dma_addr;
884 int req_offset;
885 u16 req_idx; /* Request index */
886
887 /* ensure values are reset properly! */
888 mf->u.frame.hwhdr.msgctxu.fld.cb_idx = cb_idx;
889 req_offset = (u8 *)mf - (u8 *)ioc->req_frames;
890 req_idx = req_offset / ioc->req_sz;
891 mf->u.frame.hwhdr.msgctxu.fld.req_idx = cpu_to_le16(req_idx);
892 mf->u.frame.hwhdr.msgctxu.fld.rsvd = 0;
893
894 DBG_DUMP_PUT_MSG_FRAME(ioc, (u32 *)mf);
895
896 mf_dma_addr = (ioc->req_frames_low_dma + req_offset);
897 dsgprintk(ioc, printk(MYIOC_s_DEBUG_FMT "mf_dma_addr=%x req_idx=%d\n",
898 ioc->name, mf_dma_addr, req_idx));
899 CHIPREG_WRITE32(&ioc->chip->RequestHiPriFifo, mf_dma_addr);
900}
901
845/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 902/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
846/** 903/**
847 * mpt_free_msg_frame - Place MPT request frame back on FreeQ. 904 * mpt_free_msg_frame - Place MPT request frame back on FreeQ.
@@ -899,7 +956,7 @@ mpt_add_sge(char *pAddr, u32 flagslength, dma_addr_t dma_addr)
899/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 956/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
900/** 957/**
901 * mpt_send_handshake_request - Send MPT request via doorbell handshake method. 958 * mpt_send_handshake_request - Send MPT request via doorbell handshake method.
902 * @handle: Handle of registered MPT protocol driver 959 * @cb_idx: Handle of registered MPT protocol driver
903 * @ioc: Pointer to MPT adapter structure 960 * @ioc: Pointer to MPT adapter structure
904 * @reqBytes: Size of the request in bytes 961 * @reqBytes: Size of the request in bytes
905 * @req: Pointer to MPT request frame 962 * @req: Pointer to MPT request frame
@@ -914,7 +971,7 @@ mpt_add_sge(char *pAddr, u32 flagslength, dma_addr_t dma_addr)
914 * Returns 0 for success, non-zero for failure. 971 * Returns 0 for success, non-zero for failure.
915 */ 972 */
916int 973int
917mpt_send_handshake_request(int handle, MPT_ADAPTER *ioc, int reqBytes, u32 *req, int sleepFlag) 974mpt_send_handshake_request(u8 cb_idx, MPT_ADAPTER *ioc, int reqBytes, u32 *req, int sleepFlag)
918{ 975{
919 int r = 0; 976 int r = 0;
920 u8 *req_as_bytes; 977 u8 *req_as_bytes;
@@ -934,7 +991,7 @@ mpt_send_handshake_request(int handle, MPT_ADAPTER *ioc, int reqBytes, u32 *req,
934 if (reqBytes >= 12 && ii >= 0 && ii < ioc->req_depth) { 991 if (reqBytes >= 12 && ii >= 0 && ii < ioc->req_depth) {
935 MPT_FRAME_HDR *mf = (MPT_FRAME_HDR*)req; 992 MPT_FRAME_HDR *mf = (MPT_FRAME_HDR*)req;
936 mf->u.frame.hwhdr.msgctxu.fld.req_idx = cpu_to_le16(ii); 993 mf->u.frame.hwhdr.msgctxu.fld.req_idx = cpu_to_le16(ii);
937 mf->u.frame.hwhdr.msgctxu.fld.cb_idx = handle; 994 mf->u.frame.hwhdr.msgctxu.fld.cb_idx = cb_idx;
938 } 995 }
939 996
940 /* Make sure there are no doorbells */ 997 /* Make sure there are no doorbells */
@@ -953,7 +1010,7 @@ mpt_send_handshake_request(int handle, MPT_ADAPTER *ioc, int reqBytes, u32 *req,
953 if (!(CHIPREG_READ32(&ioc->chip->Doorbell) & MPI_DOORBELL_ACTIVE)) 1010 if (!(CHIPREG_READ32(&ioc->chip->Doorbell) & MPI_DOORBELL_ACTIVE))
954 return -5; 1011 return -5;
955 1012
956 dhsprintk(ioc, printk(KERN_INFO MYNAM ": %s: mpt_send_handshake_request start, WaitCnt=%d\n", 1013 dhsprintk(ioc, printk(MYIOC_s_DEBUG_FMT "mpt_send_handshake_request start, WaitCnt=%d\n",
957 ioc->name, ii)); 1014 ioc->name, ii));
958 1015
959 CHIPREG_WRITE32(&ioc->chip->IntStatus, 0); 1016 CHIPREG_WRITE32(&ioc->chip->IntStatus, 0);
@@ -1395,11 +1452,13 @@ mpt_attach(struct pci_dev *pdev, const struct pci_device_id *id)
1395{ 1452{
1396 MPT_ADAPTER *ioc; 1453 MPT_ADAPTER *ioc;
1397 u8 __iomem *mem; 1454 u8 __iomem *mem;
1455 u8 __iomem *pmem;
1398 unsigned long mem_phys; 1456 unsigned long mem_phys;
1399 unsigned long port; 1457 unsigned long port;
1400 u32 msize; 1458 u32 msize;
1401 u32 psize; 1459 u32 psize;
1402 int ii; 1460 int ii;
1461 u8 cb_idx;
1403 int r = -ENODEV; 1462 int r = -ENODEV;
1404 u8 revision; 1463 u8 revision;
1405 u8 pcixcmd; 1464 u8 pcixcmd;
@@ -1408,35 +1467,39 @@ mpt_attach(struct pci_dev *pdev, const struct pci_device_id *id)
1408 struct proc_dir_entry *dent, *ent; 1467 struct proc_dir_entry *dent, *ent;
1409#endif 1468#endif
1410 1469
1470 if (mpt_debug_level)
1471 printk(KERN_INFO MYNAM ": mpt_debug_level=%xh\n", mpt_debug_level);
1472
1473 if (pci_enable_device(pdev))
1474 return r;
1475
1411 ioc = kzalloc(sizeof(MPT_ADAPTER), GFP_ATOMIC); 1476 ioc = kzalloc(sizeof(MPT_ADAPTER), GFP_ATOMIC);
1412 if (ioc == NULL) { 1477 if (ioc == NULL) {
1413 printk(KERN_ERR MYNAM ": ERROR - Insufficient memory to add adapter!\n"); 1478 printk(KERN_ERR MYNAM ": ERROR - Insufficient memory to add adapter!\n");
1414 return -ENOMEM; 1479 return -ENOMEM;
1415 } 1480 }
1416
1417 ioc->debug_level = mpt_debug_level; 1481 ioc->debug_level = mpt_debug_level;
1418 if (mpt_debug_level) 1482 ioc->id = mpt_ids++;
1419 printk(KERN_INFO MYNAM ": mpt_debug_level=%xh\n", mpt_debug_level); 1483 sprintf(ioc->name, "ioc%d", ioc->id);
1420
1421 if (pci_enable_device(pdev))
1422 return r;
1423 1484
1424 dinitprintk(ioc, printk(KERN_WARNING MYNAM ": mpt_adapter_install\n")); 1485 dinitprintk(ioc, printk(MYIOC_s_INFO_FMT ": mpt_adapter_install\n", ioc->name));
1425 1486
1426 if (!pci_set_dma_mask(pdev, DMA_64BIT_MASK)) { 1487 if (!pci_set_dma_mask(pdev, DMA_64BIT_MASK)) {
1427 dprintk(ioc, printk(KERN_INFO MYNAM 1488 dprintk(ioc, printk(MYIOC_s_INFO_FMT
1428 ": 64 BIT PCI BUS DMA ADDRESSING SUPPORTED\n")); 1489 ": 64 BIT PCI BUS DMA ADDRESSING SUPPORTED\n", ioc->name));
1429 } else if (pci_set_dma_mask(pdev, DMA_32BIT_MASK)) { 1490 } else if (pci_set_dma_mask(pdev, DMA_32BIT_MASK)) {
1430 printk(KERN_WARNING MYNAM ": 32 BIT PCI BUS DMA ADDRESSING NOT SUPPORTED\n"); 1491 printk(MYIOC_s_WARN_FMT ": 32 BIT PCI BUS DMA ADDRESSING NOT SUPPORTED\n",
1492 ioc->name);
1493 kfree(ioc);
1431 return r; 1494 return r;
1432 } 1495 }
1433 1496
1434 if (!pci_set_consistent_dma_mask(pdev, DMA_64BIT_MASK)) { 1497 if (!pci_set_consistent_dma_mask(pdev, DMA_64BIT_MASK)) {
1435 dprintk(ioc, printk(KERN_INFO MYNAM 1498 dprintk(ioc, printk(MYIOC_s_INFO_FMT
1436 ": Using 64 bit consistent mask\n")); 1499 ": Using 64 bit consistent mask\n", ioc->name));
1437 } else { 1500 } else {
1438 dprintk(ioc, printk(KERN_INFO MYNAM 1501 dprintk(ioc, printk(MYIOC_s_INFO_FMT
1439 ": Not using 64 bit consistent mask\n")); 1502 ": Not using 64 bit consistent mask\n", ioc->name));
1440 } 1503 }
1441 1504
1442 ioc->alloc_total = sizeof(MPT_ADAPTER); 1505 ioc->alloc_total = sizeof(MPT_ADAPTER);
@@ -1475,7 +1538,6 @@ mpt_attach(struct pci_dev *pdev, const struct pci_device_id *id)
1475 1538
1476 /* Find lookup slot. */ 1539 /* Find lookup slot. */
1477 INIT_LIST_HEAD(&ioc->list); 1540 INIT_LIST_HEAD(&ioc->list);
1478 ioc->id = mpt_ids++;
1479 1541
1480 mem_phys = msize = 0; 1542 mem_phys = msize = 0;
1481 port = psize = 0; 1543 port = psize = 0;
@@ -1501,25 +1563,23 @@ mpt_attach(struct pci_dev *pdev, const struct pci_device_id *id)
1501 /*mem = ioremap(mem_phys, msize);*/ 1563 /*mem = ioremap(mem_phys, msize);*/
1502 mem = ioremap(mem_phys, msize); 1564 mem = ioremap(mem_phys, msize);
1503 if (mem == NULL) { 1565 if (mem == NULL) {
1504 printk(KERN_ERR MYNAM ": ERROR - Unable to map adapter memory!\n"); 1566 printk(MYIOC_s_ERR_FMT "Unable to map adapter memory!\n", ioc->name);
1505 kfree(ioc); 1567 kfree(ioc);
1506 return -EINVAL; 1568 return -EINVAL;
1507 } 1569 }
1508 ioc->memmap = mem; 1570 ioc->memmap = mem;
1509 dinitprintk(ioc, printk(KERN_INFO MYNAM ": mem = %p, mem_phys = %lx\n", mem, mem_phys)); 1571 dinitprintk(ioc, printk(MYIOC_s_INFO_FMT "mem = %p, mem_phys = %lx\n", ioc->name, mem, mem_phys));
1510 1572
1511 dinitprintk(ioc, printk(KERN_INFO MYNAM ": facts @ %p, pfacts[0] @ %p\n", 1573 dinitprintk(ioc, printk(MYIOC_s_INFO_FMT "facts @ %p, pfacts[0] @ %p\n",
1512 &ioc->facts, &ioc->pfacts[0])); 1574 ioc->name, &ioc->facts, &ioc->pfacts[0]));
1513 1575
1514 ioc->mem_phys = mem_phys; 1576 ioc->mem_phys = mem_phys;
1515 ioc->chip = (SYSIF_REGS __iomem *)mem; 1577 ioc->chip = (SYSIF_REGS __iomem *)mem;
1516 1578
1517 /* Save Port IO values in case we need to do downloadboot */ 1579 /* Save Port IO values in case we need to do downloadboot */
1518 { 1580 ioc->pio_mem_phys = port;
1519 u8 *pmem = (u8*)port; 1581 pmem = (u8 __iomem *)port;
1520 ioc->pio_mem_phys = port; 1582 ioc->pio_chip = (SYSIF_REGS __iomem *)pmem;
1521 ioc->pio_chip = (SYSIF_REGS __iomem *)pmem;
1522 }
1523 1583
1524 pci_read_config_byte(pdev, PCI_CLASS_REVISION, &revision); 1584 pci_read_config_byte(pdev, PCI_CLASS_REVISION, &revision);
1525 mpt_get_product_name(pdev->vendor, pdev->device, revision, ioc->prod_name); 1585 mpt_get_product_name(pdev->vendor, pdev->device, revision, ioc->prod_name);
@@ -1591,8 +1651,6 @@ mpt_attach(struct pci_dev *pdev, const struct pci_device_id *id)
1591 if (ioc->errata_flag_1064) 1651 if (ioc->errata_flag_1064)
1592 pci_disable_io_access(pdev); 1652 pci_disable_io_access(pdev);
1593 1653
1594 sprintf(ioc->name, "ioc%d", ioc->id);
1595
1596 spin_lock_init(&ioc->FreeQlock); 1654 spin_lock_init(&ioc->FreeQlock);
1597 1655
1598 /* Disable all! */ 1656 /* Disable all! */
@@ -1609,9 +1667,8 @@ mpt_attach(struct pci_dev *pdev, const struct pci_device_id *id)
1609 1667
1610 if ((r = mpt_do_ioc_recovery(ioc, MPT_HOSTEVENT_IOC_BRINGUP, 1668 if ((r = mpt_do_ioc_recovery(ioc, MPT_HOSTEVENT_IOC_BRINGUP,
1611 CAN_SLEEP)) != 0){ 1669 CAN_SLEEP)) != 0){
1612 printk(KERN_WARNING MYNAM 1670 printk(MYIOC_s_ERR_FMT "didn't initialize properly! (%d)\n",
1613 ": WARNING - %s did not initialize properly! (%d)\n", 1671 ioc->name, r);
1614 ioc->name, r);
1615 1672
1616 list_del(&ioc->list); 1673 list_del(&ioc->list);
1617 if (ioc->alt_ioc) 1674 if (ioc->alt_ioc)
@@ -1623,10 +1680,10 @@ mpt_attach(struct pci_dev *pdev, const struct pci_device_id *id)
1623 } 1680 }
1624 1681
1625 /* call per device driver probe entry point */ 1682 /* call per device driver probe entry point */
1626 for(ii=0; ii<MPT_MAX_PROTOCOL_DRIVERS; ii++) { 1683 for(cb_idx = 0; cb_idx < MPT_MAX_PROTOCOL_DRIVERS; cb_idx++) {
1627 if(MptDeviceDriverHandlers[ii] && 1684 if(MptDeviceDriverHandlers[cb_idx] &&
1628 MptDeviceDriverHandlers[ii]->probe) { 1685 MptDeviceDriverHandlers[cb_idx]->probe) {
1629 MptDeviceDriverHandlers[ii]->probe(pdev,id); 1686 MptDeviceDriverHandlers[cb_idx]->probe(pdev,id);
1630 } 1687 }
1631 } 1688 }
1632 1689
@@ -1663,7 +1720,7 @@ mpt_detach(struct pci_dev *pdev)
1663{ 1720{
1664 MPT_ADAPTER *ioc = pci_get_drvdata(pdev); 1721 MPT_ADAPTER *ioc = pci_get_drvdata(pdev);
1665 char pname[32]; 1722 char pname[32];
1666 int ii; 1723 u8 cb_idx;
1667 1724
1668 sprintf(pname, MPT_PROCFS_MPTBASEDIR "/%s/summary", ioc->name); 1725 sprintf(pname, MPT_PROCFS_MPTBASEDIR "/%s/summary", ioc->name);
1669 remove_proc_entry(pname, NULL); 1726 remove_proc_entry(pname, NULL);
@@ -1673,10 +1730,10 @@ mpt_detach(struct pci_dev *pdev)
1673 remove_proc_entry(pname, NULL); 1730 remove_proc_entry(pname, NULL);
1674 1731
1675 /* call per device driver remove entry point */ 1732 /* call per device driver remove entry point */
1676 for(ii=0; ii<MPT_MAX_PROTOCOL_DRIVERS; ii++) { 1733 for(cb_idx = 0; cb_idx < MPT_MAX_PROTOCOL_DRIVERS; cb_idx++) {
1677 if(MptDeviceDriverHandlers[ii] && 1734 if(MptDeviceDriverHandlers[cb_idx] &&
1678 MptDeviceDriverHandlers[ii]->remove) { 1735 MptDeviceDriverHandlers[cb_idx]->remove) {
1679 MptDeviceDriverHandlers[ii]->remove(pdev); 1736 MptDeviceDriverHandlers[cb_idx]->remove(pdev);
1680 } 1737 }
1681 } 1738 }
1682 1739
@@ -1788,7 +1845,7 @@ mpt_resume(struct pci_dev *pdev)
1788#endif 1845#endif
1789 1846
1790static int 1847static int
1791mpt_signal_reset(int index, MPT_ADAPTER *ioc, int reset_phase) 1848mpt_signal_reset(u8 index, MPT_ADAPTER *ioc, int reset_phase)
1792{ 1849{
1793 if ((MptDriverClass[index] == MPTSPI_DRIVER && 1850 if ((MptDriverClass[index] == MPTSPI_DRIVER &&
1794 ioc->bus_type != SPI) || 1851 ioc->bus_type != SPI) ||
@@ -1830,14 +1887,15 @@ mpt_do_ioc_recovery(MPT_ADAPTER *ioc, u32 reason, int sleepFlag)
1830 int hard; 1887 int hard;
1831 int rc=0; 1888 int rc=0;
1832 int ii; 1889 int ii;
1890 u8 cb_idx;
1833 int handlers; 1891 int handlers;
1834 int ret = 0; 1892 int ret = 0;
1835 int reset_alt_ioc_active = 0; 1893 int reset_alt_ioc_active = 0;
1836 int irq_allocated = 0; 1894 int irq_allocated = 0;
1837 u8 *a; 1895 u8 *a;
1838 1896
1839 printk(KERN_INFO MYNAM ": Initiating %s %s\n", 1897 printk(MYIOC_s_INFO_FMT "Initiating %s\n", ioc->name,
1840 ioc->name, reason==MPT_HOSTEVENT_IOC_BRINGUP ? "bringup" : "recovery"); 1898 reason == MPT_HOSTEVENT_IOC_BRINGUP ? "bringup" : "recovery");
1841 1899
1842 /* Disable reply interrupts (also blocks FreeQ) */ 1900 /* Disable reply interrupts (also blocks FreeQ) */
1843 CHIPREG_WRITE32(&ioc->chip->IntMask, 0xFFFFFFFF); 1901 CHIPREG_WRITE32(&ioc->chip->IntMask, 0xFFFFFFFF);
@@ -1858,21 +1916,19 @@ mpt_do_ioc_recovery(MPT_ADAPTER *ioc, u32 reason, int sleepFlag)
1858 1916
1859 if ((hard_reset_done = MakeIocReady(ioc, hard, sleepFlag)) < 0) { 1917 if ((hard_reset_done = MakeIocReady(ioc, hard, sleepFlag)) < 0) {
1860 if (hard_reset_done == -4) { 1918 if (hard_reset_done == -4) {
1861 printk(KERN_WARNING MYNAM ": %s Owned by PEER..skipping!\n", 1919 printk(MYIOC_s_WARN_FMT "Owned by PEER..skipping!\n",
1862 ioc->name); 1920 ioc->name);
1863 1921
1864 if (reset_alt_ioc_active && ioc->alt_ioc) { 1922 if (reset_alt_ioc_active && ioc->alt_ioc) {
1865 /* (re)Enable alt-IOC! (reply interrupt, FreeQ) */ 1923 /* (re)Enable alt-IOC! (reply interrupt, FreeQ) */
1866 dprintk(ioc, printk(KERN_INFO MYNAM 1924 dprintk(ioc, printk(MYIOC_s_INFO_FMT
1867 ": alt-%s reply irq re-enabled\n", 1925 "alt_ioc reply irq re-enabled\n", ioc->alt_ioc->name));
1868 ioc->alt_ioc->name));
1869 CHIPREG_WRITE32(&ioc->alt_ioc->chip->IntMask, MPI_HIM_DIM); 1926 CHIPREG_WRITE32(&ioc->alt_ioc->chip->IntMask, MPI_HIM_DIM);
1870 ioc->alt_ioc->active = 1; 1927 ioc->alt_ioc->active = 1;
1871 } 1928 }
1872 1929
1873 } else { 1930 } else {
1874 printk(KERN_WARNING MYNAM ": %s NOT READY WARNING!\n", 1931 printk(MYIOC_s_WARN_FMT "NOT READY!\n", ioc->name);
1875 ioc->name);
1876 } 1932 }
1877 return -1; 1933 return -1;
1878 } 1934 }
@@ -1884,9 +1940,7 @@ mpt_do_ioc_recovery(MPT_ADAPTER *ioc, u32 reason, int sleepFlag)
1884 if ((rc = MakeIocReady(ioc->alt_ioc, 0, sleepFlag)) == 0) 1940 if ((rc = MakeIocReady(ioc->alt_ioc, 0, sleepFlag)) == 0)
1885 alt_ioc_ready = 1; 1941 alt_ioc_ready = 1;
1886 else 1942 else
1887 printk(KERN_WARNING MYNAM 1943 printk(MYIOC_s_WARN_FMT "alt_ioc not ready!\n", ioc->alt_ioc->name);
1888 ": alt-%s: Not ready WARNING!\n",
1889 ioc->alt_ioc->name);
1890 } 1944 }
1891 1945
1892 for (ii=0; ii<5; ii++) { 1946 for (ii=0; ii<5; ii++) {
@@ -1897,7 +1951,8 @@ mpt_do_ioc_recovery(MPT_ADAPTER *ioc, u32 reason, int sleepFlag)
1897 1951
1898 1952
1899 if (ii == 5) { 1953 if (ii == 5) {
1900 dinitprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Retry IocFacts failed rc=%x\n", ioc->name, rc)); 1954 dinitprintk(ioc, printk(MYIOC_s_DEBUG_FMT
1955 "Retry IocFacts failed rc=%x\n", ioc->name, rc));
1901 ret = -2; 1956 ret = -2;
1902 } else if (reason == MPT_HOSTEVENT_IOC_BRINGUP) { 1957 } else if (reason == MPT_HOSTEVENT_IOC_BRINGUP) {
1903 MptDisplayIocCapabilities(ioc); 1958 MptDisplayIocCapabilities(ioc);
@@ -1906,14 +1961,14 @@ mpt_do_ioc_recovery(MPT_ADAPTER *ioc, u32 reason, int sleepFlag)
1906 if (alt_ioc_ready) { 1961 if (alt_ioc_ready) {
1907 if ((rc = GetIocFacts(ioc->alt_ioc, sleepFlag, reason)) != 0) { 1962 if ((rc = GetIocFacts(ioc->alt_ioc, sleepFlag, reason)) != 0) {
1908 dinitprintk(ioc, printk(MYIOC_s_DEBUG_FMT 1963 dinitprintk(ioc, printk(MYIOC_s_DEBUG_FMT
1909 "Initial Alt IocFacts failed rc=%x\n", ioc->name, rc)); 1964 "Initial Alt IocFacts failed rc=%x\n", ioc->name, rc));
1910 /* Retry - alt IOC was initialized once 1965 /* Retry - alt IOC was initialized once
1911 */ 1966 */
1912 rc = GetIocFacts(ioc->alt_ioc, sleepFlag, reason); 1967 rc = GetIocFacts(ioc->alt_ioc, sleepFlag, reason);
1913 } 1968 }
1914 if (rc) { 1969 if (rc) {
1915 dinitprintk(ioc, printk(MYIOC_s_DEBUG_FMT 1970 dinitprintk(ioc, printk(MYIOC_s_DEBUG_FMT
1916 "Retry Alt IocFacts failed rc=%x\n", ioc->name, rc)); 1971 "Retry Alt IocFacts failed rc=%x\n", ioc->name, rc));
1917 alt_ioc_ready = 0; 1972 alt_ioc_ready = 0;
1918 reset_alt_ioc_active = 0; 1973 reset_alt_ioc_active = 0;
1919 } else if (reason == MPT_HOSTEVENT_IOC_BRINGUP) { 1974 } else if (reason == MPT_HOSTEVENT_IOC_BRINGUP) {
@@ -1931,13 +1986,12 @@ mpt_do_ioc_recovery(MPT_ADAPTER *ioc, u32 reason, int sleepFlag)
1931 if (ioc->pcidev->irq) { 1986 if (ioc->pcidev->irq) {
1932 if (mpt_msi_enable && !pci_enable_msi(ioc->pcidev)) 1987 if (mpt_msi_enable && !pci_enable_msi(ioc->pcidev))
1933 printk(MYIOC_s_INFO_FMT "PCI-MSI enabled\n", 1988 printk(MYIOC_s_INFO_FMT "PCI-MSI enabled\n",
1934 ioc->name); 1989 ioc->name);
1935 rc = request_irq(ioc->pcidev->irq, mpt_interrupt, 1990 rc = request_irq(ioc->pcidev->irq, mpt_interrupt,
1936 IRQF_SHARED, ioc->name, ioc); 1991 IRQF_SHARED, ioc->name, ioc);
1937 if (rc < 0) { 1992 if (rc < 0) {
1938 printk(MYIOC_s_ERR_FMT "Unable to allocate " 1993 printk(MYIOC_s_ERR_FMT "Unable to allocate "
1939 "interrupt %d!\n", ioc->name, 1994 "interrupt %d!\n", ioc->name, ioc->pcidev->irq);
1940 ioc->pcidev->irq);
1941 if (mpt_msi_enable) 1995 if (mpt_msi_enable)
1942 pci_disable_msi(ioc->pcidev); 1996 pci_disable_msi(ioc->pcidev);
1943 return -EBUSY; 1997 return -EBUSY;
@@ -1946,8 +2000,8 @@ mpt_do_ioc_recovery(MPT_ADAPTER *ioc, u32 reason, int sleepFlag)
1946 ioc->pci_irq = ioc->pcidev->irq; 2000 ioc->pci_irq = ioc->pcidev->irq;
1947 pci_set_master(ioc->pcidev); /* ?? */ 2001 pci_set_master(ioc->pcidev); /* ?? */
1948 pci_set_drvdata(ioc->pcidev, ioc); 2002 pci_set_drvdata(ioc->pcidev, ioc);
1949 dprintk(ioc, printk(KERN_INFO MYNAM ": %s installed at interrupt " 2003 dprintk(ioc, printk(MYIOC_s_INFO_FMT "installed at interrupt "
1950 "%d\n", ioc->name, ioc->pcidev->irq)); 2004 "%d\n", ioc->name, ioc->pcidev->irq));
1951 } 2005 }
1952 } 2006 }
1953 2007
@@ -1966,8 +2020,8 @@ mpt_do_ioc_recovery(MPT_ADAPTER *ioc, u32 reason, int sleepFlag)
1966 ret = -4; 2020 ret = -4;
1967// NEW! 2021// NEW!
1968 if (alt_ioc_ready && ((rc = PrimeIocFifos(ioc->alt_ioc)) != 0)) { 2022 if (alt_ioc_ready && ((rc = PrimeIocFifos(ioc->alt_ioc)) != 0)) {
1969 printk(KERN_WARNING MYNAM ": alt-%s: (%d) FIFO mgmt alloc WARNING!\n", 2023 printk(MYIOC_s_WARN_FMT ": alt_ioc (%d) FIFO mgmt alloc!\n",
1970 ioc->alt_ioc->name, rc); 2024 ioc->alt_ioc->name, rc);
1971 alt_ioc_ready = 0; 2025 alt_ioc_ready = 0;
1972 reset_alt_ioc_active = 0; 2026 reset_alt_ioc_active = 0;
1973 } 2027 }
@@ -1976,16 +2030,15 @@ mpt_do_ioc_recovery(MPT_ADAPTER *ioc, u32 reason, int sleepFlag)
1976 if ((rc = SendIocInit(ioc->alt_ioc, sleepFlag)) != 0) { 2030 if ((rc = SendIocInit(ioc->alt_ioc, sleepFlag)) != 0) {
1977 alt_ioc_ready = 0; 2031 alt_ioc_ready = 0;
1978 reset_alt_ioc_active = 0; 2032 reset_alt_ioc_active = 0;
1979 printk(KERN_WARNING MYNAM 2033 printk(MYIOC_s_WARN_FMT "alt_ioc (%d) init failure!\n",
1980 ": alt-%s: (%d) init failure WARNING!\n", 2034 ioc->alt_ioc->name, rc);
1981 ioc->alt_ioc->name, rc);
1982 } 2035 }
1983 } 2036 }
1984 2037
1985 if (reason == MPT_HOSTEVENT_IOC_BRINGUP){ 2038 if (reason == MPT_HOSTEVENT_IOC_BRINGUP){
1986 if (ioc->upload_fw) { 2039 if (ioc->upload_fw) {
1987 ddlprintk(ioc, printk(MYIOC_s_DEBUG_FMT 2040 ddlprintk(ioc, printk(MYIOC_s_DEBUG_FMT
1988 "firmware upload required!\n", ioc->name)); 2041 "firmware upload required!\n", ioc->name));
1989 2042
1990 /* Controller is not operational, cannot do upload 2043 /* Controller is not operational, cannot do upload
1991 */ 2044 */
@@ -2001,12 +2054,13 @@ mpt_do_ioc_recovery(MPT_ADAPTER *ioc, u32 reason, int sleepFlag)
2001 * mpt_diag_reset) 2054 * mpt_diag_reset)
2002 */ 2055 */
2003 ddlprintk(ioc, printk(MYIOC_s_DEBUG_FMT 2056 ddlprintk(ioc, printk(MYIOC_s_DEBUG_FMT
2004 ": mpt_upload: alt_%s has cached_fw=%p \n", 2057 "mpt_upload: alt_%s has cached_fw=%p \n",
2005 ioc->name, ioc->alt_ioc->name, ioc->alt_ioc->cached_fw)); 2058 ioc->name, ioc->alt_ioc->name, ioc->alt_ioc->cached_fw));
2006 ioc->alt_ioc->cached_fw = NULL; 2059 ioc->alt_ioc->cached_fw = NULL;
2007 } 2060 }
2008 } else { 2061 } else {
2009 printk(KERN_WARNING MYNAM ": firmware upload failure!\n"); 2062 printk(MYIOC_s_WARN_FMT
2063 "firmware upload failure!\n", ioc->name);
2010 ret = -5; 2064 ret = -5;
2011 } 2065 }
2012 } 2066 }
@@ -2021,8 +2075,8 @@ mpt_do_ioc_recovery(MPT_ADAPTER *ioc, u32 reason, int sleepFlag)
2021 2075
2022 if (reset_alt_ioc_active && ioc->alt_ioc) { 2076 if (reset_alt_ioc_active && ioc->alt_ioc) {
2023 /* (re)Enable alt-IOC! (reply interrupt) */ 2077 /* (re)Enable alt-IOC! (reply interrupt) */
2024 dinitprintk(ioc, printk(KERN_INFO MYNAM ": alt-%s reply irq re-enabled\n", 2078 dinitprintk(ioc, printk(MYIOC_s_INFO_FMT "alt_ioc reply irq re-enabled\n",
2025 ioc->alt_ioc->name)); 2079 ioc->alt_ioc->name));
2026 CHIPREG_WRITE32(&ioc->alt_ioc->chip->IntMask, MPI_HIM_DIM); 2080 CHIPREG_WRITE32(&ioc->alt_ioc->chip->IntMask, MPI_HIM_DIM);
2027 ioc->alt_ioc->active = 1; 2081 ioc->alt_ioc->active = 1;
2028 } 2082 }
@@ -2075,10 +2129,8 @@ mpt_do_ioc_recovery(MPT_ADAPTER *ioc, u32 reason, int sleepFlag)
2075 (void) GetLanConfigPages(ioc); 2129 (void) GetLanConfigPages(ioc);
2076 a = (u8*)&ioc->lan_cnfg_page1.HardwareAddressLow; 2130 a = (u8*)&ioc->lan_cnfg_page1.HardwareAddressLow;
2077 dprintk(ioc, printk(MYIOC_s_DEBUG_FMT 2131 dprintk(ioc, printk(MYIOC_s_DEBUG_FMT
2078 "LanAddr = %02X:%02X:%02X:" 2132 "LanAddr = %02X:%02X:%02X:%02X:%02X:%02X\n",
2079 "%02X:%02X:%02X\n", 2133 ioc->name, a[5], a[4], a[3], a[2], a[1], a[0]));
2080 ioc->name, a[5], a[4],
2081 a[3], a[2], a[1], a[0] ));
2082 2134
2083 } 2135 }
2084 } else { 2136 } else {
@@ -2114,20 +2166,20 @@ mpt_do_ioc_recovery(MPT_ADAPTER *ioc, u32 reason, int sleepFlag)
2114 */ 2166 */
2115 if (hard_reset_done) { 2167 if (hard_reset_done) {
2116 rc = handlers = 0; 2168 rc = handlers = 0;
2117 for (ii=MPT_MAX_PROTOCOL_DRIVERS-1; ii; ii--) { 2169 for (cb_idx = MPT_MAX_PROTOCOL_DRIVERS-1; cb_idx; cb_idx--) {
2118 if ((ret == 0) && MptResetHandlers[ii]) { 2170 if ((ret == 0) && MptResetHandlers[cb_idx]) {
2119 dprintk(ioc, printk(MYIOC_s_DEBUG_FMT 2171 dprintk(ioc, printk(MYIOC_s_DEBUG_FMT
2120 "Calling IOC post_reset handler #%d\n", 2172 "Calling IOC post_reset handler #%d\n",
2121 ioc->name, ii)); 2173 ioc->name, cb_idx));
2122 rc += mpt_signal_reset(ii, ioc, MPT_IOC_POST_RESET); 2174 rc += mpt_signal_reset(cb_idx, ioc, MPT_IOC_POST_RESET);
2123 handlers++; 2175 handlers++;
2124 } 2176 }
2125 2177
2126 if (alt_ioc_ready && MptResetHandlers[ii]) { 2178 if (alt_ioc_ready && MptResetHandlers[cb_idx]) {
2127 drsprintk(ioc, printk(MYIOC_s_DEBUG_FMT 2179 drsprintk(ioc, printk(MYIOC_s_DEBUG_FMT
2128 "Calling alt-%s post_reset handler #%d\n", 2180 "Calling IOC post_reset handler #%d\n",
2129 ioc->name, ioc->alt_ioc->name, ii)); 2181 ioc->alt_ioc->name, cb_idx));
2130 rc += mpt_signal_reset(ii, ioc->alt_ioc, MPT_IOC_POST_RESET); 2182 rc += mpt_signal_reset(cb_idx, ioc->alt_ioc, MPT_IOC_POST_RESET);
2131 handlers++; 2183 handlers++;
2132 } 2184 }
2133 } 2185 }
@@ -2166,8 +2218,8 @@ mpt_detect_bound_ports(MPT_ADAPTER *ioc, struct pci_dev *pdev)
2166 2218
2167 dprintk(ioc, printk(MYIOC_s_DEBUG_FMT "PCI device %s devfn=%x/%x," 2219 dprintk(ioc, printk(MYIOC_s_DEBUG_FMT "PCI device %s devfn=%x/%x,"
2168 " searching for devfn match on %x or %x\n", 2220 " searching for devfn match on %x or %x\n",
2169 ioc->name, pci_name(pdev), pdev->bus->number, 2221 ioc->name, pci_name(pdev), pdev->bus->number,
2170 pdev->devfn, func-1, func+1)); 2222 pdev->devfn, func-1, func+1));
2171 2223
2172 peer = pci_get_slot(pdev->bus, PCI_DEVFN(slot,func-1)); 2224 peer = pci_get_slot(pdev->bus, PCI_DEVFN(slot,func-1));
2173 if (!peer) { 2225 if (!peer) {
@@ -2181,15 +2233,15 @@ mpt_detect_bound_ports(MPT_ADAPTER *ioc, struct pci_dev *pdev)
2181 if (_pcidev == peer) { 2233 if (_pcidev == peer) {
2182 /* Paranoia checks */ 2234 /* Paranoia checks */
2183 if (ioc->alt_ioc != NULL) { 2235 if (ioc->alt_ioc != NULL) {
2184 printk(KERN_WARNING MYNAM ": Oops, already bound (%s <==> %s)!\n", 2236 printk(MYIOC_s_WARN_FMT "Oops, already bound to %s!\n",
2185 ioc->name, ioc->alt_ioc->name); 2237 ioc->name, ioc->alt_ioc->name);
2186 break; 2238 break;
2187 } else if (ioc_srch->alt_ioc != NULL) { 2239 } else if (ioc_srch->alt_ioc != NULL) {
2188 printk(KERN_WARNING MYNAM ": Oops, already bound (%s <==> %s)!\n", 2240 printk(MYIOC_s_WARN_FMT "Oops, already bound to %s!\n",
2189 ioc_srch->name, ioc_srch->alt_ioc->name); 2241 ioc_srch->name, ioc_srch->alt_ioc->name);
2190 break; 2242 break;
2191 } 2243 }
2192 dprintk(ioc, printk(KERN_INFO MYNAM ": FOUND! binding %s <==> %s\n", 2244 dprintk(ioc, printk(MYIOC_s_INFO_FMT "FOUND! binding to %s\n",
2193 ioc->name, ioc_srch->name)); 2245 ioc->name, ioc_srch->name));
2194 ioc_srch->alt_ioc = ioc; 2246 ioc_srch->alt_ioc = ioc;
2195 ioc->alt_ioc = ioc_srch; 2247 ioc->alt_ioc = ioc_srch;
@@ -2210,10 +2262,11 @@ mpt_adapter_disable(MPT_ADAPTER *ioc)
2210 int ret; 2262 int ret;
2211 2263
2212 if (ioc->cached_fw != NULL) { 2264 if (ioc->cached_fw != NULL) {
2213 ddlprintk(ioc, printk(KERN_INFO MYNAM ": mpt_adapter_disable: Pushing FW onto adapter\n")); 2265 ddlprintk(ioc, printk(MYIOC_s_INFO_FMT
2266 "mpt_adapter_disable: Pushing FW onto adapter\n", ioc->name));
2214 if ((ret = mpt_downloadboot(ioc, (MpiFwHeader_t *)ioc->cached_fw, NO_SLEEP)) < 0) { 2267 if ((ret = mpt_downloadboot(ioc, (MpiFwHeader_t *)ioc->cached_fw, NO_SLEEP)) < 0) {
2215 printk(KERN_WARNING MYNAM 2268 printk(MYIOC_s_WARN_FMT "firmware downloadboot failure (%d)!\n",
2216 ": firmware downloadboot failure (%d)!\n", ret); 2269 ioc->name, ret);
2217 } 2270 }
2218 } 2271 }
2219 2272
@@ -2225,8 +2278,8 @@ mpt_adapter_disable(MPT_ADAPTER *ioc)
2225 2278
2226 if (ioc->alloc != NULL) { 2279 if (ioc->alloc != NULL) {
2227 sz = ioc->alloc_sz; 2280 sz = ioc->alloc_sz;
2228 dexitprintk(ioc, printk(KERN_INFO MYNAM ": %s.free @ %p, sz=%d bytes\n", 2281 dexitprintk(ioc, printk(MYIOC_s_INFO_FMT "free @ %p, sz=%d bytes\n",
2229 ioc->name, ioc->alloc, ioc->alloc_sz)); 2282 ioc->name, ioc->alloc, ioc->alloc_sz));
2230 pci_free_consistent(ioc->pcidev, sz, 2283 pci_free_consistent(ioc->pcidev, sz,
2231 ioc->alloc, ioc->alloc_dma); 2284 ioc->alloc, ioc->alloc_dma);
2232 ioc->reply_frames = NULL; 2285 ioc->reply_frames = NULL;
@@ -2286,15 +2339,14 @@ mpt_adapter_disable(MPT_ADAPTER *ioc)
2286 if (ioc->HostPageBuffer != NULL) { 2339 if (ioc->HostPageBuffer != NULL) {
2287 if((ret = mpt_host_page_access_control(ioc, 2340 if((ret = mpt_host_page_access_control(ioc,
2288 MPI_DB_HPBAC_FREE_BUFFER, NO_SLEEP)) != 0) { 2341 MPI_DB_HPBAC_FREE_BUFFER, NO_SLEEP)) != 0) {
2289 printk(KERN_ERR MYNAM 2342 printk(MYIOC_s_ERR_FMT
2290 ": %s: host page buffers free failed (%d)!\n", 2343 "host page buffers free failed (%d)!\n",
2291 __FUNCTION__, ret); 2344 ioc->name, ret);
2292 } 2345 }
2293 dexitprintk(ioc, printk(KERN_INFO MYNAM ": %s HostPageBuffer free @ %p, sz=%d bytes\n", 2346 dexitprintk(ioc, printk(MYIOC_s_INFO_FMT "HostPageBuffer free @ %p, sz=%d bytes\n",
2294 ioc->name, ioc->HostPageBuffer, ioc->HostPageBuffer_sz)); 2347 ioc->name, ioc->HostPageBuffer, ioc->HostPageBuffer_sz));
2295 pci_free_consistent(ioc->pcidev, ioc->HostPageBuffer_sz, 2348 pci_free_consistent(ioc->pcidev, ioc->HostPageBuffer_sz,
2296 ioc->HostPageBuffer, 2349 ioc->HostPageBuffer, ioc->HostPageBuffer_dma);
2297 ioc->HostPageBuffer_dma);
2298 ioc->HostPageBuffer = NULL; 2350 ioc->HostPageBuffer = NULL;
2299 ioc->HostPageBuffer_sz = 0; 2351 ioc->HostPageBuffer_sz = 0;
2300 ioc->alloc_total -= ioc->HostPageBuffer_sz; 2352 ioc->alloc_total -= ioc->HostPageBuffer_sz;
@@ -2336,7 +2388,7 @@ mpt_adapter_dispose(MPT_ADAPTER *ioc)
2336#if defined(CONFIG_MTRR) && 0 2388#if defined(CONFIG_MTRR) && 0
2337 if (ioc->mtrr_reg > 0) { 2389 if (ioc->mtrr_reg > 0) {
2338 mtrr_del(ioc->mtrr_reg, 0, 0); 2390 mtrr_del(ioc->mtrr_reg, 0, 0);
2339 dprintk(ioc, printk(KERN_INFO MYNAM ": %s: MTRR region de-registered\n", ioc->name)); 2391 dprintk(ioc, printk(MYIOC_s_INFO_FMT "MTRR region de-registered\n", ioc->name));
2340 } 2392 }
2341#endif 2393#endif
2342 2394
@@ -2344,8 +2396,8 @@ mpt_adapter_dispose(MPT_ADAPTER *ioc)
2344 list_del(&ioc->list); 2396 list_del(&ioc->list);
2345 2397
2346 sz_last = ioc->alloc_total; 2398 sz_last = ioc->alloc_total;
2347 dprintk(ioc, printk(KERN_INFO MYNAM ": %s: free'd %d of %d bytes\n", 2399 dprintk(ioc, printk(MYIOC_s_INFO_FMT "free'd %d of %d bytes\n",
2348 ioc->name, sz_first-sz_last+(int)sizeof(*ioc), sz_first)); 2400 ioc->name, sz_first-sz_last+(int)sizeof(*ioc), sz_first));
2349 2401
2350 if (ioc->alt_ioc) 2402 if (ioc->alt_ioc)
2351 ioc->alt_ioc->alt_ioc = NULL; 2403 ioc->alt_ioc->alt_ioc = NULL;
@@ -2424,7 +2476,7 @@ MakeIocReady(MPT_ADAPTER *ioc, int force, int sleepFlag)
2424 2476
2425 /* Get current [raw] IOC state */ 2477 /* Get current [raw] IOC state */
2426 ioc_state = mpt_GetIocState(ioc, 0); 2478 ioc_state = mpt_GetIocState(ioc, 0);
2427 dhsprintk(ioc, printk(KERN_INFO MYNAM "::MakeIocReady, %s [raw] state=%08x\n", ioc->name, ioc_state)); 2479 dhsprintk(ioc, printk(MYIOC_s_INFO_FMT "MakeIocReady [raw] state=%08x\n", ioc->name, ioc_state));
2428 2480
2429 /* 2481 /*
2430 * Check to see if IOC got left/stuck in doorbell handshake 2482 * Check to see if IOC got left/stuck in doorbell handshake
@@ -2446,9 +2498,9 @@ MakeIocReady(MPT_ADAPTER *ioc, int force, int sleepFlag)
2446 if ((ioc_state & MPI_IOC_STATE_MASK) == MPI_IOC_STATE_FAULT) { 2498 if ((ioc_state & MPI_IOC_STATE_MASK) == MPI_IOC_STATE_FAULT) {
2447 statefault = 2; 2499 statefault = 2;
2448 printk(MYIOC_s_WARN_FMT "IOC is in FAULT state!!!\n", 2500 printk(MYIOC_s_WARN_FMT "IOC is in FAULT state!!!\n",
2449 ioc->name); 2501 ioc->name);
2450 printk(KERN_WARNING " FAULT code = %04xh\n", 2502 printk(MYIOC_s_WARN_FMT " FAULT code = %04xh\n",
2451 ioc_state & MPI_DOORBELL_DATA_MASK); 2503 ioc->name, ioc_state & MPI_DOORBELL_DATA_MASK);
2452 } 2504 }
2453 2505
2454 /* 2506 /*
@@ -2464,9 +2516,9 @@ MakeIocReady(MPT_ADAPTER *ioc, int force, int sleepFlag)
2464 * Else, fall through to KickStart case 2516 * Else, fall through to KickStart case
2465 */ 2517 */
2466 whoinit = (ioc_state & MPI_DOORBELL_WHO_INIT_MASK) >> MPI_DOORBELL_WHO_INIT_SHIFT; 2518 whoinit = (ioc_state & MPI_DOORBELL_WHO_INIT_MASK) >> MPI_DOORBELL_WHO_INIT_SHIFT;
2467 dinitprintk(ioc, printk(KERN_INFO MYNAM 2519 dinitprintk(ioc, printk(MYIOC_s_INFO_FMT
2468 ": whoinit 0x%x statefault %d force %d\n", 2520 "whoinit 0x%x statefault %d force %d\n",
2469 whoinit, statefault, force)); 2521 ioc->name, whoinit, statefault, force));
2470 if (whoinit == MPI_WHOINIT_PCI_PEER) 2522 if (whoinit == MPI_WHOINIT_PCI_PEER)
2471 return -4; 2523 return -4;
2472 else { 2524 else {
@@ -2549,7 +2601,6 @@ mpt_GetIocState(MPT_ADAPTER *ioc, int cooked)
2549 2601
2550 /* Get! */ 2602 /* Get! */
2551 s = CHIPREG_READ32(&ioc->chip->Doorbell); 2603 s = CHIPREG_READ32(&ioc->chip->Doorbell);
2552// dprintk((MYIOC_s_INFO_FMT "raw state = %08x\n", ioc->name, s));
2553 sc = s & MPI_IOC_STATE_MASK; 2604 sc = s & MPI_IOC_STATE_MASK;
2554 2605
2555 /* Save! */ 2606 /* Save! */
@@ -2581,9 +2632,8 @@ GetIocFacts(MPT_ADAPTER *ioc, int sleepFlag, int reason)
2581 2632
2582 /* IOC *must* NOT be in RESET state! */ 2633 /* IOC *must* NOT be in RESET state! */
2583 if (ioc->last_state == MPI_IOC_STATE_RESET) { 2634 if (ioc->last_state == MPI_IOC_STATE_RESET) {
2584 printk(KERN_ERR MYNAM ": ERROR - Can't get IOCFacts, %s NOT READY! (%08x)\n", 2635 printk(MYIOC_s_ERR_FMT "Can't get IOCFacts NOT READY! (%08x)\n",
2585 ioc->name, 2636 ioc->name, ioc->last_state );
2586 ioc->last_state );
2587 return -44; 2637 return -44;
2588 } 2638 }
2589 2639
@@ -2703,8 +2753,8 @@ GetIocFacts(MPT_ADAPTER *ioc, int sleepFlag, int reason)
2703 } 2753 }
2704 ioc->NBShiftFactor = shiftFactor; 2754 ioc->NBShiftFactor = shiftFactor;
2705 dinitprintk(ioc, printk(MYIOC_s_DEBUG_FMT 2755 dinitprintk(ioc, printk(MYIOC_s_DEBUG_FMT
2706 "NB_for_64_byte_frame=%x NBShiftFactor=%x BlockSize=%x\n", 2756 "NB_for_64_byte_frame=%x NBShiftFactor=%x BlockSize=%x\n",
2707 ioc->name, vv, shiftFactor, r)); 2757 ioc->name, vv, shiftFactor, r));
2708 2758
2709 if (reason == MPT_HOSTEVENT_IOC_BRINGUP) { 2759 if (reason == MPT_HOSTEVENT_IOC_BRINGUP) {
2710 /* 2760 /*
@@ -2757,9 +2807,8 @@ GetPortFacts(MPT_ADAPTER *ioc, int portnum, int sleepFlag)
2757 2807
2758 /* IOC *must* NOT be in RESET state! */ 2808 /* IOC *must* NOT be in RESET state! */
2759 if (ioc->last_state == MPI_IOC_STATE_RESET) { 2809 if (ioc->last_state == MPI_IOC_STATE_RESET) {
2760 printk(KERN_ERR MYNAM ": ERROR - Can't get PortFacts, %s NOT READY! (%08x)\n", 2810 printk(MYIOC_s_ERR_FMT "Can't get PortFacts NOT READY! (%08x)\n",
2761 ioc->name, 2811 ioc->name, ioc->last_state );
2762 ioc->last_state );
2763 return -4; 2812 return -4;
2764 } 2813 }
2765 2814
@@ -2934,7 +2983,7 @@ SendIocInit(MPT_ADAPTER *ioc, int sleepFlag)
2934 state = mpt_GetIocState(ioc, 1); 2983 state = mpt_GetIocState(ioc, 1);
2935 count++; 2984 count++;
2936 } 2985 }
2937 dinitprintk(ioc, printk(MYIOC_s_DEBUG_FMT "INFO - Wait IOC_OPERATIONAL state (cnt=%d)\n", 2986 dinitprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Wait IOC_OPERATIONAL state (cnt=%d)\n",
2938 ioc->name, count)); 2987 ioc->name, count));
2939 2988
2940 ioc->aen_event_read_flag=0; 2989 ioc->aen_event_read_flag=0;
@@ -3027,10 +3076,9 @@ mpt_free_fw_memory(MPT_ADAPTER *ioc)
3027 int sz; 3076 int sz;
3028 3077
3029 sz = ioc->facts.FWImageSize; 3078 sz = ioc->facts.FWImageSize;
3030 dinitprintk(ioc, printk(KERN_INFO MYNAM "free_fw_memory: FW Image @ %p[%p], sz=%d[%x] bytes\n", 3079 dinitprintk(ioc, printk(MYIOC_s_INFO_FMT "free_fw_memory: FW Image @ %p[%p], sz=%d[%x] bytes\n",
3031 ioc->cached_fw, (void *)(ulong)ioc->cached_fw_dma, sz, sz)); 3080 ioc->name, ioc->cached_fw, (void *)(ulong)ioc->cached_fw_dma, sz, sz));
3032 pci_free_consistent(ioc->pcidev, sz, 3081 pci_free_consistent(ioc->pcidev, sz, ioc->cached_fw, ioc->cached_fw_dma);
3033 ioc->cached_fw, ioc->cached_fw_dma);
3034 ioc->cached_fw = NULL; 3082 ioc->cached_fw = NULL;
3035 3083
3036 return; 3084 return;
@@ -3054,7 +3102,6 @@ mpt_free_fw_memory(MPT_ADAPTER *ioc)
3054static int 3102static int
3055mpt_do_upload(MPT_ADAPTER *ioc, int sleepFlag) 3103mpt_do_upload(MPT_ADAPTER *ioc, int sleepFlag)
3056{ 3104{
3057 u8 request[ioc->req_sz];
3058 u8 reply[sizeof(FWUploadReply_t)]; 3105 u8 reply[sizeof(FWUploadReply_t)];
3059 FWUpload_t *prequest; 3106 FWUpload_t *prequest;
3060 FWUploadReply_t *preply; 3107 FWUploadReply_t *preply;
@@ -3071,8 +3118,8 @@ mpt_do_upload(MPT_ADAPTER *ioc, int sleepFlag)
3071 3118
3072 mpt_alloc_fw_memory(ioc, sz); 3119 mpt_alloc_fw_memory(ioc, sz);
3073 3120
3074 dinitprintk(ioc, printk(KERN_INFO MYNAM ": FW Image @ %p[%p], sz=%d[%x] bytes\n", 3121 dinitprintk(ioc, printk(MYIOC_s_INFO_FMT ": FW Image @ %p[%p], sz=%d[%x] bytes\n",
3075 ioc->cached_fw, (void *)(ulong)ioc->cached_fw_dma, sz, sz)); 3122 ioc->name, ioc->cached_fw, (void *)(ulong)ioc->cached_fw_dma, sz, sz));
3076 3123
3077 if (ioc->cached_fw == NULL) { 3124 if (ioc->cached_fw == NULL) {
3078 /* Major Failure. 3125 /* Major Failure.
@@ -3080,11 +3127,16 @@ mpt_do_upload(MPT_ADAPTER *ioc, int sleepFlag)
3080 return -ENOMEM; 3127 return -ENOMEM;
3081 } 3128 }
3082 3129
3083 prequest = (FWUpload_t *)&request; 3130 prequest = (sleepFlag == NO_SLEEP) ? kzalloc(ioc->req_sz, GFP_ATOMIC) :
3084 preply = (FWUploadReply_t *)&reply; 3131 kzalloc(ioc->req_sz, GFP_KERNEL);
3132 if (!prequest) {
3133 dinitprintk(ioc, printk(MYIOC_s_DEBUG_FMT "fw upload failed "
3134 "while allocating memory \n", ioc->name));
3135 mpt_free_fw_memory(ioc);
3136 return -ENOMEM;
3137 }
3085 3138
3086 /* Destination... */ 3139 preply = (FWUploadReply_t *)&reply;
3087 memset(prequest, 0, ioc->req_sz);
3088 3140
3089 reply_sz = sizeof(reply); 3141 reply_sz = sizeof(reply);
3090 memset(preply, 0, reply_sz); 3142 memset(preply, 0, reply_sz);
@@ -3096,21 +3148,22 @@ mpt_do_upload(MPT_ADAPTER *ioc, int sleepFlag)
3096 ptcsge->DetailsLength = 12; 3148 ptcsge->DetailsLength = 12;
3097 ptcsge->Flags = MPI_SGE_FLAGS_TRANSACTION_ELEMENT; 3149 ptcsge->Flags = MPI_SGE_FLAGS_TRANSACTION_ELEMENT;
3098 ptcsge->ImageSize = cpu_to_le32(sz); 3150 ptcsge->ImageSize = cpu_to_le32(sz);
3151 ptcsge++;
3099 3152
3100 sgeoffset = sizeof(FWUpload_t) - sizeof(SGE_MPI_UNION) + sizeof(FWUploadTCSGE_t); 3153 sgeoffset = sizeof(FWUpload_t) - sizeof(SGE_MPI_UNION) + sizeof(FWUploadTCSGE_t);
3101 3154
3102 flagsLength = MPT_SGE_FLAGS_SSIMPLE_READ | sz; 3155 flagsLength = MPT_SGE_FLAGS_SSIMPLE_READ | sz;
3103 mpt_add_sge(&request[sgeoffset], flagsLength, ioc->cached_fw_dma); 3156 mpt_add_sge((char *)ptcsge, flagsLength, ioc->cached_fw_dma);
3104 3157
3105 sgeoffset += sizeof(u32) + sizeof(dma_addr_t); 3158 sgeoffset += sizeof(u32) + sizeof(dma_addr_t);
3106 dinitprintk(ioc, printk(KERN_INFO MYNAM ": Sending FW Upload (req @ %p) sgeoffset=%d \n", 3159 dinitprintk(ioc, printk(MYIOC_s_INFO_FMT ": Sending FW Upload (req @ %p) sgeoffset=%d \n",
3107 prequest, sgeoffset)); 3160 ioc->name, prequest, sgeoffset));
3108 DBG_DUMP_FW_REQUEST_FRAME(ioc, (u32 *)prequest) 3161 DBG_DUMP_FW_REQUEST_FRAME(ioc, (u32 *)prequest);
3109 3162
3110 ii = mpt_handshake_req_reply_wait(ioc, sgeoffset, (u32*)prequest, 3163 ii = mpt_handshake_req_reply_wait(ioc, sgeoffset, (u32*)prequest,
3111 reply_sz, (u16*)preply, 65 /*seconds*/, sleepFlag); 3164 reply_sz, (u16*)preply, 65 /*seconds*/, sleepFlag);
3112 3165
3113 dinitprintk(ioc, printk(KERN_INFO MYNAM ": FW Upload completed rc=%x \n", ii)); 3166 dinitprintk(ioc, printk(MYIOC_s_INFO_FMT ": FW Upload completed rc=%x \n", ioc->name, ii));
3114 3167
3115 cmdStatus = -EFAULT; 3168 cmdStatus = -EFAULT;
3116 if (ii == 0) { 3169 if (ii == 0) {
@@ -3135,6 +3188,7 @@ mpt_do_upload(MPT_ADAPTER *ioc, int sleepFlag)
3135 ioc->name)); 3188 ioc->name));
3136 mpt_free_fw_memory(ioc); 3189 mpt_free_fw_memory(ioc);
3137 } 3190 }
3191 kfree(prequest);
3138 3192
3139 return cmdStatus; 3193 return cmdStatus;
3140} 3194}
@@ -3381,7 +3435,7 @@ KickStart(MPT_ADAPTER *ioc, int force, int sleepFlag)
3381 u32 ioc_state=0; 3435 u32 ioc_state=0;
3382 int cnt,cntdn; 3436 int cnt,cntdn;
3383 3437
3384 dinitprintk(ioc, printk(KERN_WARNING MYNAM ": KickStarting %s!\n", ioc->name)); 3438 dinitprintk(ioc, printk(MYIOC_s_DEBUG_FMT "KickStarting!\n", ioc->name));
3385 if (ioc->bus_type == SPI) { 3439 if (ioc->bus_type == SPI) {
3386 /* Always issue a Msg Unit Reset first. This will clear some 3440 /* Always issue a Msg Unit Reset first. This will clear some
3387 * SCSI bus hang conditions. 3441 * SCSI bus hang conditions.
@@ -3400,7 +3454,7 @@ KickStart(MPT_ADAPTER *ioc, int force, int sleepFlag)
3400 return hard_reset_done; 3454 return hard_reset_done;
3401 3455
3402 dinitprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Diagnostic reset successful!\n", 3456 dinitprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Diagnostic reset successful!\n",
3403 ioc->name)); 3457 ioc->name));
3404 3458
3405 cntdn = ((sleepFlag == CAN_SLEEP) ? HZ : 1000) * 2; /* 2 seconds */ 3459 cntdn = ((sleepFlag == CAN_SLEEP) ? HZ : 1000) * 2; /* 2 seconds */
3406 for (cnt=0; cnt<cntdn; cnt++) { 3460 for (cnt=0; cnt<cntdn; cnt++) {
@@ -3417,8 +3471,8 @@ KickStart(MPT_ADAPTER *ioc, int force, int sleepFlag)
3417 } 3471 }
3418 } 3472 }
3419 3473
3420 printk(MYIOC_s_ERR_FMT "Failed to come READY after reset! IocState=%x\n", 3474 dinitprintk(ioc, printk(MYIOC_s_ERR_FMT "Failed to come READY after reset! IocState=%x\n",
3421 ioc->name, ioc_state); 3475 ioc->name, mpt_GetIocState(ioc, 0)));
3422 return -1; 3476 return -1;
3423} 3477}
3424 3478
@@ -3560,20 +3614,20 @@ mpt_diag_reset(MPT_ADAPTER *ioc, int ignore, int sleepFlag)
3560 * MptResetHandlers[] registered yet. 3614 * MptResetHandlers[] registered yet.
3561 */ 3615 */
3562 { 3616 {
3563 int ii; 3617 u8 cb_idx;
3564 int r = 0; 3618 int r = 0;
3565 3619
3566 for (ii=MPT_MAX_PROTOCOL_DRIVERS-1; ii; ii--) { 3620 for (cb_idx = MPT_MAX_PROTOCOL_DRIVERS-1; cb_idx; cb_idx--) {
3567 if (MptResetHandlers[ii]) { 3621 if (MptResetHandlers[cb_idx]) {
3568 dprintk(ioc, printk(MYIOC_s_DEBUG_FMT 3622 dprintk(ioc, printk(MYIOC_s_DEBUG_FMT
3569 "Calling IOC pre_reset handler #%d\n", 3623 "Calling IOC pre_reset handler #%d\n",
3570 ioc->name, ii)); 3624 ioc->name, cb_idx));
3571 r += mpt_signal_reset(ii, ioc, MPT_IOC_PRE_RESET); 3625 r += mpt_signal_reset(cb_idx, ioc, MPT_IOC_PRE_RESET);
3572 if (ioc->alt_ioc) { 3626 if (ioc->alt_ioc) {
3573 dprintk(ioc, printk(MYIOC_s_DEBUG_FMT 3627 dprintk(ioc, printk(MYIOC_s_DEBUG_FMT
3574 "Calling alt-%s pre_reset handler #%d\n", 3628 "Calling alt-%s pre_reset handler #%d\n",
3575 ioc->name, ioc->alt_ioc->name, ii)); 3629 ioc->name, ioc->alt_ioc->name, cb_idx));
3576 r += mpt_signal_reset(ii, ioc->alt_ioc, MPT_IOC_PRE_RESET); 3630 r += mpt_signal_reset(cb_idx, ioc->alt_ioc, MPT_IOC_PRE_RESET);
3577 } 3631 }
3578 } 3632 }
3579 } 3633 }
@@ -3606,8 +3660,8 @@ mpt_diag_reset(MPT_ADAPTER *ioc, int ignore, int sleepFlag)
3606 } 3660 }
3607 if ((count = mpt_downloadboot(ioc, 3661 if ((count = mpt_downloadboot(ioc,
3608 (MpiFwHeader_t *)iocp->cached_fw, sleepFlag)) < 0) { 3662 (MpiFwHeader_t *)iocp->cached_fw, sleepFlag)) < 0) {
3609 printk(KERN_WARNING MYNAM 3663 printk(MYIOC_s_WARN_FMT
3610 ": firmware downloadboot failure (%d)!\n", count); 3664 "firmware downloadboot failure (%d)!\n", ioc->name, count);
3611 } 3665 }
3612 3666
3613 } else { 3667 } else {
@@ -3750,8 +3804,8 @@ SendIocReset(MPT_ADAPTER *ioc, u8 reset_type, int sleepFlag)
3750 if (sleepFlag != CAN_SLEEP) 3804 if (sleepFlag != CAN_SLEEP)
3751 count *= 10; 3805 count *= 10;
3752 3806
3753 printk(KERN_ERR MYNAM ": %s: ERROR - Wait IOC_READY state timeout(%d)!\n", 3807 printk(MYIOC_s_ERR_FMT "Wait IOC_READY state timeout(%d)!\n",
3754 ioc->name, (int)((count+5)/HZ)); 3808 ioc->name, (int)((count+5)/HZ));
3755 return -ETIME; 3809 return -ETIME;
3756 } 3810 }
3757 3811
@@ -4144,7 +4198,7 @@ mpt_handshake_req_reply_wait(MPT_ADAPTER *ioc, int reqBytes, u32 *req,
4144 } 4198 }
4145 4199
4146 dhsprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Handshake request frame (@%p) header\n", ioc->name, req)); 4200 dhsprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Handshake request frame (@%p) header\n", ioc->name, req));
4147 DBG_DUMP_REQUEST_FRAME_HDR(ioc, (u32 *)req) 4201 DBG_DUMP_REQUEST_FRAME_HDR(ioc, (u32 *)req);
4148 4202
4149 dhsprintk(ioc, printk(MYIOC_s_DEBUG_FMT "HandShake request post done, WaitCnt=%d%s\n", 4203 dhsprintk(ioc, printk(MYIOC_s_DEBUG_FMT "HandShake request post done, WaitCnt=%d%s\n",
4150 ioc->name, t, failcnt ? " - MISSING DOORBELL ACK!" : "")); 4204 ioc->name, t, failcnt ? " - MISSING DOORBELL ACK!" : ""));
@@ -4349,7 +4403,7 @@ WaitForDoorbellReply(MPT_ADAPTER *ioc, int howlong, int sleepFlag)
4349#endif 4403#endif
4350 4404
4351 dhsprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Got Handshake reply:\n", ioc->name)); 4405 dhsprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Got Handshake reply:\n", ioc->name));
4352 DBG_DUMP_REPLY_FRAME(ioc, (u32 *)mptReply) 4406 DBG_DUMP_REPLY_FRAME(ioc, (u32 *)mptReply);
4353 4407
4354 dhsprintk(ioc, printk(MYIOC_s_DEBUG_FMT "WaitForDoorbell REPLY WaitCnt=%d (sz=%d)\n", 4408 dhsprintk(ioc, printk(MYIOC_s_DEBUG_FMT "WaitForDoorbell REPLY WaitCnt=%d (sz=%d)\n",
4355 ioc->name, t, u16cnt/2)); 4409 ioc->name, t, u16cnt/2));
@@ -4824,8 +4878,8 @@ mpt_GetScsiPortSettings(MPT_ADAPTER *ioc, int portnum)
4824 4878
4825 if ( (pPP0->Capabilities & MPI_SCSIPORTPAGE0_CAP_QAS) == 0 ) { 4879 if ( (pPP0->Capabilities & MPI_SCSIPORTPAGE0_CAP_QAS) == 0 ) {
4826 ioc->spi_data.noQas |= MPT_TARGET_NO_NEGO_QAS; 4880 ioc->spi_data.noQas |= MPT_TARGET_NO_NEGO_QAS;
4827 ddvprintk(ioc, printk(KERN_INFO MYNAM 4881 ddvprintk(ioc, printk(MYIOC_s_DEBUG_FMT
4828 " :%s noQas due to Capabilities=%x\n", 4882 "noQas due to Capabilities=%x\n",
4829 ioc->name, pPP0->Capabilities)); 4883 ioc->name, pPP0->Capabilities));
4830 } 4884 }
4831 ioc->spi_data.maxBusWidth = pPP0->Capabilities & MPI_SCSIPORTPAGE0_CAP_WIDE ? 1 : 0; 4885 ioc->spi_data.maxBusWidth = pPP0->Capabilities & MPI_SCSIPORTPAGE0_CAP_WIDE ? 1 : 0;
@@ -4888,6 +4942,38 @@ mpt_GetScsiPortSettings(MPT_ADAPTER *ioc, int portnum)
4888 /* Nvram data is left with INVALID mark 4942 /* Nvram data is left with INVALID mark
4889 */ 4943 */
4890 rc = 1; 4944 rc = 1;
4945 } else if (ioc->pcidev->vendor == PCI_VENDOR_ID_ATTO) {
4946
4947 /* This is an ATTO adapter, read Page2 accordingly
4948 */
4949 ATTO_SCSIPortPage2_t *pPP2 = (ATTO_SCSIPortPage2_t *) pbuf;
4950 ATTODeviceInfo_t *pdevice = NULL;
4951 u16 ATTOFlags;
4952
4953 /* Save the Port Page 2 data
4954 * (reformat into a 32bit quantity)
4955 */
4956 for (ii=0; ii < MPT_MAX_SCSI_DEVICES; ii++) {
4957 pdevice = &pPP2->DeviceSettings[ii];
4958 ATTOFlags = le16_to_cpu(pdevice->ATTOFlags);
4959 data = 0;
4960
4961 /* Translate ATTO device flags to LSI format
4962 */
4963 if (ATTOFlags & ATTOFLAG_DISC)
4964 data |= (MPI_SCSIPORTPAGE2_DEVICE_DISCONNECT_ENABLE);
4965 if (ATTOFlags & ATTOFLAG_ID_ENB)
4966 data |= (MPI_SCSIPORTPAGE2_DEVICE_ID_SCAN_ENABLE);
4967 if (ATTOFlags & ATTOFLAG_LUN_ENB)
4968 data |= (MPI_SCSIPORTPAGE2_DEVICE_LUN_SCAN_ENABLE);
4969 if (ATTOFlags & ATTOFLAG_TAGGED)
4970 data |= (MPI_SCSIPORTPAGE2_DEVICE_TAG_QUEUE_ENABLE);
4971 if (!(ATTOFlags & ATTOFLAG_WIDE_ENB))
4972 data |= (MPI_SCSIPORTPAGE2_DEVICE_WIDE_DISABLE);
4973
4974 data = (data << 16) | (pdevice->Period << 8) | 10;
4975 ioc->spi_data.nvram[ii] = data;
4976 }
4891 } else { 4977 } else {
4892 SCSIPortPage2_t *pPP2 = (SCSIPortPage2_t *) pbuf; 4978 SCSIPortPage2_t *pPP2 = (SCSIPortPage2_t *) pbuf;
4893 MpiDeviceInfo_t *pdevice = NULL; 4979 MpiDeviceInfo_t *pdevice = NULL;
@@ -5701,10 +5787,10 @@ mpt_ioc_reset(MPT_ADAPTER *ioc, int reset_phase)
5701 CONFIGPARMS *pCfg; 5787 CONFIGPARMS *pCfg;
5702 unsigned long flags; 5788 unsigned long flags;
5703 5789
5704 dprintk(ioc, printk(KERN_DEBUG MYNAM 5790 dprintk(ioc, printk(MYIOC_s_DEBUG_FMT
5705 ": IOC %s_reset routed to MPT base driver!\n", 5791 ": IOC %s_reset routed to MPT base driver!\n",
5706 reset_phase==MPT_IOC_SETUP_RESET ? "setup" : ( 5792 ioc->name, reset_phase==MPT_IOC_SETUP_RESET ? "setup" : (
5707 reset_phase==MPT_IOC_PRE_RESET ? "pre" : "post"))); 5793 reset_phase==MPT_IOC_PRE_RESET ? "pre" : "post")));
5708 5794
5709 if (reset_phase == MPT_IOC_SETUP_RESET) { 5795 if (reset_phase == MPT_IOC_SETUP_RESET) {
5710 ; 5796 ;
@@ -5843,7 +5929,7 @@ procmpt_summary_read(char *buf, char **start, off_t offset, int request, int *eo
5843static int 5929static int
5844procmpt_version_read(char *buf, char **start, off_t offset, int request, int *eof, void *data) 5930procmpt_version_read(char *buf, char **start, off_t offset, int request, int *eof, void *data)
5845{ 5931{
5846 int ii; 5932 u8 cb_idx;
5847 int scsi, fc, sas, lan, ctl, targ, dmp; 5933 int scsi, fc, sas, lan, ctl, targ, dmp;
5848 char *drvname; 5934 char *drvname;
5849 int len; 5935 int len;
@@ -5852,10 +5938,10 @@ procmpt_version_read(char *buf, char **start, off_t offset, int request, int *eo
5852 len += sprintf(buf+len, " Fusion MPT base driver\n"); 5938 len += sprintf(buf+len, " Fusion MPT base driver\n");
5853 5939
5854 scsi = fc = sas = lan = ctl = targ = dmp = 0; 5940 scsi = fc = sas = lan = ctl = targ = dmp = 0;
5855 for (ii=MPT_MAX_PROTOCOL_DRIVERS-1; ii; ii--) { 5941 for (cb_idx = MPT_MAX_PROTOCOL_DRIVERS-1; cb_idx; cb_idx--) {
5856 drvname = NULL; 5942 drvname = NULL;
5857 if (MptCallbacks[ii]) { 5943 if (MptCallbacks[cb_idx]) {
5858 switch (MptDriverClass[ii]) { 5944 switch (MptDriverClass[cb_idx]) {
5859 case MPTSPI_DRIVER: 5945 case MPTSPI_DRIVER:
5860 if (!scsi++) drvname = "SPI host"; 5946 if (!scsi++) drvname = "SPI host";
5861 break; 5947 break;
@@ -6099,26 +6185,25 @@ mpt_HardResetHandler(MPT_ADAPTER *ioc, int sleepFlag)
6099 * For all other protocol drivers, this is a no-op. 6185 * For all other protocol drivers, this is a no-op.
6100 */ 6186 */
6101 { 6187 {
6102 int ii; 6188 u8 cb_idx;
6103 int r = 0; 6189 int r = 0;
6104 6190
6105 for (ii=MPT_MAX_PROTOCOL_DRIVERS-1; ii; ii--) { 6191 for (cb_idx = MPT_MAX_PROTOCOL_DRIVERS-1; cb_idx; cb_idx--) {
6106 if (MptResetHandlers[ii]) { 6192 if (MptResetHandlers[cb_idx]) {
6107 dtmprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Calling IOC reset_setup handler #%d\n", 6193 dtmprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Calling IOC reset_setup handler #%d\n",
6108 ioc->name, ii)); 6194 ioc->name, cb_idx));
6109 r += mpt_signal_reset(ii, ioc, MPT_IOC_SETUP_RESET); 6195 r += mpt_signal_reset(cb_idx, ioc, MPT_IOC_SETUP_RESET);
6110 if (ioc->alt_ioc) { 6196 if (ioc->alt_ioc) {
6111 dtmprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Calling alt-%s setup reset handler #%d\n", 6197 dtmprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Calling alt-%s setup reset handler #%d\n",
6112 ioc->name, ioc->alt_ioc->name, ii)); 6198 ioc->name, ioc->alt_ioc->name, cb_idx));
6113 r += mpt_signal_reset(ii, ioc->alt_ioc, MPT_IOC_SETUP_RESET); 6199 r += mpt_signal_reset(cb_idx, ioc->alt_ioc, MPT_IOC_SETUP_RESET);
6114 } 6200 }
6115 } 6201 }
6116 } 6202 }
6117 } 6203 }
6118 6204
6119 if ((rc = mpt_do_ioc_recovery(ioc, MPT_HOSTEVENT_IOC_RECOVER, sleepFlag)) != 0) { 6205 if ((rc = mpt_do_ioc_recovery(ioc, MPT_HOSTEVENT_IOC_RECOVER, sleepFlag)) != 0) {
6120 printk(KERN_WARNING MYNAM ": WARNING - (%d) Cannot recover %s\n", 6206 printk(MYIOC_s_WARN_FMT "Cannot recover rc = %d!\n", ioc->name, rc);
6121 rc, ioc->name);
6122 } 6207 }
6123 ioc->reload_fw = 0; 6208 ioc->reload_fw = 0;
6124 if (ioc->alt_ioc) 6209 if (ioc->alt_ioc)
@@ -6515,6 +6600,7 @@ ProcessEventNotification(MPT_ADAPTER *ioc, EventNotificationReply_t *pEventReply
6515 u32 evData0 = 0; 6600 u32 evData0 = 0;
6516// u32 evCtx; 6601// u32 evCtx;
6517 int ii; 6602 int ii;
6603 u8 cb_idx;
6518 int r = 0; 6604 int r = 0;
6519 int handlers = 0; 6605 int handlers = 0;
6520 char evStr[EVENT_DESCR_STR_SZ]; 6606 char evStr[EVENT_DESCR_STR_SZ];
@@ -6537,12 +6623,12 @@ ProcessEventNotification(MPT_ADAPTER *ioc, EventNotificationReply_t *pEventReply
6537 evStr)); 6623 evStr));
6538 6624
6539#ifdef CONFIG_FUSION_LOGGING 6625#ifdef CONFIG_FUSION_LOGGING
6540 devtverboseprintk(ioc, printk(KERN_DEBUG MYNAM 6626 devtverboseprintk(ioc, printk(MYIOC_s_DEBUG_FMT
6541 ": Event data:\n")); 6627 ": Event data:\n", ioc->name));
6542 for (ii = 0; ii < evDataLen; ii++) 6628 for (ii = 0; ii < evDataLen; ii++)
6543 devtverboseprintk(ioc, printk(" %08x", 6629 devtverboseprintk(ioc, printk(" %08x",
6544 le32_to_cpu(pEventReply->Data[ii]))); 6630 le32_to_cpu(pEventReply->Data[ii])));
6545 devtverboseprintk(ioc, printk(KERN_DEBUG "\n")); 6631 devtverboseprintk(ioc, printk("\n"));
6546#endif 6632#endif
6547 6633
6548 /* 6634 /*
@@ -6595,11 +6681,11 @@ ProcessEventNotification(MPT_ADAPTER *ioc, EventNotificationReply_t *pEventReply
6595 /* 6681 /*
6596 * Call each currently registered protocol event handler. 6682 * Call each currently registered protocol event handler.
6597 */ 6683 */
6598 for (ii=MPT_MAX_PROTOCOL_DRIVERS-1; ii; ii--) { 6684 for (cb_idx = MPT_MAX_PROTOCOL_DRIVERS-1; cb_idx; cb_idx--) {
6599 if (MptEvHandlers[ii]) { 6685 if (MptEvHandlers[cb_idx]) {
6600 devtverboseprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Routing Event to event handler #%d\n", 6686 devtverboseprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Routing Event to event handler #%d\n",
6601 ioc->name, ii)); 6687 ioc->name, cb_idx));
6602 r += (*(MptEvHandlers[ii]))(ioc, pEventReply); 6688 r += (*(MptEvHandlers[cb_idx]))(ioc, pEventReply);
6603 handlers++; 6689 handlers++;
6604 } 6690 }
6605 } 6691 }
@@ -7034,8 +7120,8 @@ mpt_iocstatus_info_config(MPT_ADAPTER *ioc, u32 ioc_status, MPT_FRAME_HDR *mf)
7034 if (!desc) 7120 if (!desc)
7035 return; 7121 return;
7036 7122
7037 printk(MYIOC_s_INFO_FMT "IOCStatus(0x%04X): %s: %s\n", 7123 dreplyprintk(ioc, printk(MYIOC_s_DEBUG_FMT "IOCStatus(0x%04X): %s: %s\n",
7038 ioc->name, ioc_status, desc, extend_desc); 7124 ioc->name, ioc_status, desc, extend_desc));
7039} 7125}
7040 7126
7041/** 7127/**
@@ -7261,7 +7347,8 @@ mpt_iocstatus_info(MPT_ADAPTER *ioc, u32 ioc_status, MPT_FRAME_HDR *mf)
7261 if (!desc) 7347 if (!desc)
7262 return; 7348 return;
7263 7349
7264 printk(MYIOC_s_INFO_FMT "IOCStatus(0x%04X): %s\n", ioc->name, status, desc); 7350 dreplyprintk(ioc, printk(MYIOC_s_DEBUG_FMT "IOCStatus(0x%04X): %s\n",
7351 ioc->name, status, desc));
7265} 7352}
7266 7353
7267/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 7354/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
@@ -7283,14 +7370,13 @@ EXPORT_SYMBOL(mpt_device_driver_register);
7283EXPORT_SYMBOL(mpt_device_driver_deregister); 7370EXPORT_SYMBOL(mpt_device_driver_deregister);
7284EXPORT_SYMBOL(mpt_get_msg_frame); 7371EXPORT_SYMBOL(mpt_get_msg_frame);
7285EXPORT_SYMBOL(mpt_put_msg_frame); 7372EXPORT_SYMBOL(mpt_put_msg_frame);
7373EXPORT_SYMBOL(mpt_put_msg_frame_hi_pri);
7286EXPORT_SYMBOL(mpt_free_msg_frame); 7374EXPORT_SYMBOL(mpt_free_msg_frame);
7287EXPORT_SYMBOL(mpt_add_sge); 7375EXPORT_SYMBOL(mpt_add_sge);
7288EXPORT_SYMBOL(mpt_send_handshake_request); 7376EXPORT_SYMBOL(mpt_send_handshake_request);
7289EXPORT_SYMBOL(mpt_verify_adapter); 7377EXPORT_SYMBOL(mpt_verify_adapter);
7290EXPORT_SYMBOL(mpt_GetIocState); 7378EXPORT_SYMBOL(mpt_GetIocState);
7291EXPORT_SYMBOL(mpt_print_ioc_summary); 7379EXPORT_SYMBOL(mpt_print_ioc_summary);
7292EXPORT_SYMBOL(mpt_lan_index);
7293EXPORT_SYMBOL(mpt_stm_index);
7294EXPORT_SYMBOL(mpt_HardResetHandler); 7380EXPORT_SYMBOL(mpt_HardResetHandler);
7295EXPORT_SYMBOL(mpt_config); 7381EXPORT_SYMBOL(mpt_config);
7296EXPORT_SYMBOL(mpt_findImVolumes); 7382EXPORT_SYMBOL(mpt_findImVolumes);
@@ -7308,16 +7394,16 @@ EXPORT_SYMBOL(mpt_raid_phys_disk_pg0);
7308static int __init 7394static int __init
7309fusion_init(void) 7395fusion_init(void)
7310{ 7396{
7311 int i; 7397 u8 cb_idx;
7312 7398
7313 show_mptmod_ver(my_NAME, my_VERSION); 7399 show_mptmod_ver(my_NAME, my_VERSION);
7314 printk(KERN_INFO COPYRIGHT "\n"); 7400 printk(KERN_INFO COPYRIGHT "\n");
7315 7401
7316 for (i = 0; i < MPT_MAX_PROTOCOL_DRIVERS; i++) { 7402 for (cb_idx = 0; cb_idx < MPT_MAX_PROTOCOL_DRIVERS; cb_idx++) {
7317 MptCallbacks[i] = NULL; 7403 MptCallbacks[cb_idx] = NULL;
7318 MptDriverClass[i] = MPTUNKNOWN_DRIVER; 7404 MptDriverClass[cb_idx] = MPTUNKNOWN_DRIVER;
7319 MptEvHandlers[i] = NULL; 7405 MptEvHandlers[cb_idx] = NULL;
7320 MptResetHandlers[i] = NULL; 7406 MptResetHandlers[cb_idx] = NULL;
7321 } 7407 }
7322 7408
7323 /* Register ourselves (mptbase) in order to facilitate 7409 /* Register ourselves (mptbase) in order to facilitate