aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/message/fusion/mptscsih.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/message/fusion/mptscsih.c')
-rw-r--r--drivers/message/fusion/mptscsih.c643
1 files changed, 355 insertions, 288 deletions
diff --git a/drivers/message/fusion/mptscsih.c b/drivers/message/fusion/mptscsih.c
index 5431529741ad..bdff950a54a1 100644
--- a/drivers/message/fusion/mptscsih.c
+++ b/drivers/message/fusion/mptscsih.c
@@ -1,9 +1,9 @@
1/* 1/*
2 * linux/drivers/message/fusion/mptscsih.c 2 * linux/drivers/message/fusion/mptscsih.c
3 * For use with LSI Logic PCI chip/adapter(s) 3 * For use with LSI PCI chip/adapter(s)
4 * running LSI Logic Fusion MPT (Message Passing Technology) firmware. 4 * running LSI Fusion MPT (Message Passing Technology) firmware.
5 * 5 *
6 * Copyright (c) 1999-2007 LSI Logic Corporation 6 * Copyright (c) 1999-2007 LSI Corporation
7 * (mailto:DL-MPTFusionLinux@lsi.com) 7 * (mailto:DL-MPTFusionLinux@lsi.com)
8 * 8 *
9 */ 9 */
@@ -80,6 +80,10 @@ MODULE_VERSION(my_VERSION);
80/* 80/*
81 * Other private/forward protos... 81 * Other private/forward protos...
82 */ 82 */
83static struct scsi_cmnd * mptscsih_get_scsi_lookup(MPT_ADAPTER *ioc, int i);
84static struct scsi_cmnd * mptscsih_getclear_scsi_lookup(MPT_ADAPTER *ioc, int i);
85static void mptscsih_set_scsi_lookup(MPT_ADAPTER *ioc, int i, struct scsi_cmnd *scmd);
86static int SCPNT_TO_LOOKUP_IDX(MPT_ADAPTER *ioc, struct scsi_cmnd *scmd);
83int mptscsih_io_done(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *r); 87int mptscsih_io_done(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *r);
84static void mptscsih_report_queue_full(struct scsi_cmnd *sc, SCSIIOReply_t *pScsiReply, SCSIIORequest_t *pScsiReq); 88static void mptscsih_report_queue_full(struct scsi_cmnd *sc, SCSIIOReply_t *pScsiReply, SCSIIORequest_t *pScsiReq);
85int mptscsih_taskmgmt_complete(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *r); 89int mptscsih_taskmgmt_complete(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *r);
@@ -90,7 +94,6 @@ static void mptscsih_freeChainBuffers(MPT_ADAPTER *ioc, int req_idx);
90static void mptscsih_copy_sense_data(struct scsi_cmnd *sc, MPT_SCSI_HOST *hd, MPT_FRAME_HDR *mf, SCSIIOReply_t *pScsiReply); 94static void mptscsih_copy_sense_data(struct scsi_cmnd *sc, MPT_SCSI_HOST *hd, MPT_FRAME_HDR *mf, SCSIIOReply_t *pScsiReply);
91static int mptscsih_tm_pending_wait(MPT_SCSI_HOST * hd); 95static int mptscsih_tm_pending_wait(MPT_SCSI_HOST * hd);
92static int mptscsih_tm_wait_for_completion(MPT_SCSI_HOST * hd, ulong timeout ); 96static int mptscsih_tm_wait_for_completion(MPT_SCSI_HOST * hd, ulong timeout );
93static int SCPNT_TO_LOOKUP_IDX(struct scsi_cmnd *sc);
94 97
95static int mptscsih_IssueTaskMgmt(MPT_SCSI_HOST *hd, u8 type, u8 channel, u8 id, int lun, int ctx2abort, ulong timeout); 98static int mptscsih_IssueTaskMgmt(MPT_SCSI_HOST *hd, u8 type, u8 channel, u8 id, int lun, int ctx2abort, ulong timeout);
96 99
@@ -192,7 +195,7 @@ mptscsih_getFreeChainBuffer(MPT_ADAPTER *ioc, int *retIndex)
192 int chain_idx; 195 int chain_idx;
193 196
194 dsgprintk(ioc, printk(MYIOC_s_DEBUG_FMT "getFreeChainBuffer called\n", 197 dsgprintk(ioc, printk(MYIOC_s_DEBUG_FMT "getFreeChainBuffer called\n",
195 ioc->name)); 198 ioc->name));
196 spin_lock_irqsave(&ioc->FreeQlock, flags); 199 spin_lock_irqsave(&ioc->FreeQlock, flags);
197 if (!list_empty(&ioc->FreeChainQ)) { 200 if (!list_empty(&ioc->FreeChainQ)) {
198 int offset; 201 int offset;
@@ -203,13 +206,14 @@ mptscsih_getFreeChainBuffer(MPT_ADAPTER *ioc, int *retIndex)
203 offset = (u8 *)chainBuf - (u8 *)ioc->ChainBuffer; 206 offset = (u8 *)chainBuf - (u8 *)ioc->ChainBuffer;
204 chain_idx = offset / ioc->req_sz; 207 chain_idx = offset / ioc->req_sz;
205 rc = SUCCESS; 208 rc = SUCCESS;
206 dsgprintk(ioc, printk(MYIOC_s_DEBUG_FMT "getFreeChainBuffer chainBuf=%p ChainBuffer=%p offset=%d chain_idx=%d\n", 209 dsgprintk(ioc, printk(MYIOC_s_DEBUG_FMT
207 ioc->name, chainBuf, ioc->ChainBuffer, offset, chain_idx)); 210 "getFreeChainBuffer chainBuf=%p ChainBuffer=%p offset=%d chain_idx=%d\n",
211 ioc->name, chainBuf, ioc->ChainBuffer, offset, chain_idx));
208 } else { 212 } else {
209 rc = FAILED; 213 rc = FAILED;
210 chain_idx = MPT_HOST_NO_CHAIN; 214 chain_idx = MPT_HOST_NO_CHAIN;
211 dfailprintk(ioc, printk(MYIOC_s_DEBUG_FMT "getFreeChainBuffer failed\n", 215 dfailprintk(ioc, printk(MYIOC_s_ERR_FMT "getFreeChainBuffer failed\n",
212 ioc->name)); 216 ioc->name));
213 } 217 }
214 spin_unlock_irqrestore(&ioc->FreeQlock, flags); 218 spin_unlock_irqrestore(&ioc->FreeQlock, flags);
215 219
@@ -419,8 +423,8 @@ nextSGEset:
419 * out the Address and Flags fields. 423 * out the Address and Flags fields.
420 */ 424 */
421 chainSge = (char *) psge; 425 chainSge = (char *) psge;
422 dsgprintk(ioc, printk(KERN_DEBUG " Current buff @ %p (index 0x%x)", 426 dsgprintk(ioc, printk(MYIOC_s_DEBUG_FMT " Current buff @ %p (index 0x%x)",
423 psge, req_idx)); 427 ioc->name, psge, req_idx));
424 428
425 /* Start the SGE for the next buffer 429 /* Start the SGE for the next buffer
426 */ 430 */
@@ -428,8 +432,8 @@ nextSGEset:
428 sgeOffset = 0; 432 sgeOffset = 0;
429 sg_done = 0; 433 sg_done = 0;
430 434
431 dsgprintk(ioc, printk(KERN_DEBUG " Chain buff @ %p (index 0x%x)\n", 435 dsgprintk(ioc, printk(MYIOC_s_DEBUG_FMT " Chain buff @ %p (index 0x%x)\n",
432 psge, chain_idx)); 436 ioc->name, psge, chain_idx));
433 437
434 /* Start the SGE for the next buffer 438 /* Start the SGE for the next buffer
435 */ 439 */
@@ -588,18 +592,17 @@ mptscsih_info_scsiio(MPT_ADAPTER *ioc, struct scsi_cmnd *sc, SCSIIOReply_t * pSc
588 } 592 }
589 593
590 scsi_print_command(sc); 594 scsi_print_command(sc);
591 printk(KERN_DEBUG "\tfw_channel = %d, fw_id = %d\n", 595 printk(MYIOC_s_DEBUG_FMT "\tfw_channel = %d, fw_id = %d\n",
592 pScsiReply->Bus, pScsiReply->TargetID); 596 ioc->name, pScsiReply->Bus, pScsiReply->TargetID);
593 printk(KERN_DEBUG "\trequest_len = %d, underflow = %d, resid = %d\n", 597 printk(MYIOC_s_DEBUG_FMT "\trequest_len = %d, underflow = %d, "
594 scsi_bufflen(sc), sc->underflow, scsi_get_resid(sc)); 598 "resid = %d\n", ioc->name, scsi_bufflen(sc), sc->underflow,
595 printk(KERN_DEBUG "\ttag = %d, transfer_count = %d, sc->result = %08X\n", 599 scsi_get_resid(sc));
596 le16_to_cpu(pScsiReply->TaskTag), 600 printk(MYIOC_s_DEBUG_FMT "\ttag = %d, transfer_count = %d, "
601 "sc->result = %08X\n", ioc->name, le16_to_cpu(pScsiReply->TaskTag),
597 le32_to_cpu(pScsiReply->TransferCount), sc->result); 602 le32_to_cpu(pScsiReply->TransferCount), sc->result);
598 603 printk(MYIOC_s_DEBUG_FMT "\tiocstatus = %s (0x%04x), "
599 printk(KERN_DEBUG "\tiocstatus = %s (0x%04x), "
600 "scsi_status = %s (0x%02x), scsi_state = (0x%02x)\n", 604 "scsi_status = %s (0x%02x), scsi_state = (0x%02x)\n",
601 desc, ioc_status, 605 ioc->name, desc, ioc_status, desc1, pScsiReply->SCSIStatus,
602 desc1, pScsiReply->SCSIStatus,
603 pScsiReply->SCSIState); 606 pScsiReply->SCSIState);
604 607
605 if (pScsiReply->SCSIState & MPI_SCSI_STATE_AUTOSENSE_VALID) { 608 if (pScsiReply->SCSIState & MPI_SCSI_STATE_AUTOSENSE_VALID) {
@@ -607,9 +610,8 @@ mptscsih_info_scsiio(MPT_ADAPTER *ioc, struct scsi_cmnd *sc, SCSIIOReply_t * pSc
607 asc = sc->sense_buffer[12]; 610 asc = sc->sense_buffer[12];
608 ascq = sc->sense_buffer[13]; 611 ascq = sc->sense_buffer[13];
609 612
610 printk(KERN_DEBUG "\t[sense_key,asc,ascq]: " 613 printk(MYIOC_s_DEBUG_FMT "\t[sense_key,asc,ascq]: "
611 "[0x%02x,0x%02x,0x%02x]\n", 614 "[0x%02x,0x%02x,0x%02x]\n", ioc->name, skey, asc, ascq);
612 skey, asc, ascq);
613 } 615 }
614 616
615 /* 617 /*
@@ -617,8 +619,8 @@ mptscsih_info_scsiio(MPT_ADAPTER *ioc, struct scsi_cmnd *sc, SCSIIOReply_t * pSc
617 */ 619 */
618 if (pScsiReply->SCSIState & MPI_SCSI_STATE_RESPONSE_INFO_VALID && 620 if (pScsiReply->SCSIState & MPI_SCSI_STATE_RESPONSE_INFO_VALID &&
619 pScsiReply->ResponseInfo) 621 pScsiReply->ResponseInfo)
620 printk(KERN_DEBUG "response_info = %08xh\n", 622 printk(MYIOC_s_DEBUG_FMT "response_info = %08xh\n",
621 le32_to_cpu(pScsiReply->ResponseInfo)); 623 ioc->name, le32_to_cpu(pScsiReply->ResponseInfo));
622} 624}
623#endif 625#endif
624 626
@@ -645,11 +647,10 @@ mptscsih_io_done(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *mr)
645 SCSIIORequest_t *pScsiReq; 647 SCSIIORequest_t *pScsiReq;
646 SCSIIOReply_t *pScsiReply; 648 SCSIIOReply_t *pScsiReply;
647 u16 req_idx, req_idx_MR; 649 u16 req_idx, req_idx_MR;
648 VirtDevice *vdev; 650 VirtDevice *vdevice;
649 VirtTarget *vtarget; 651 VirtTarget *vtarget;
650 652
651 hd = (MPT_SCSI_HOST *) ioc->sh->hostdata; 653 hd = shost_priv(ioc->sh);
652
653 req_idx = le16_to_cpu(mf->u.frame.hwhdr.msgctxu.fld.req_idx); 654 req_idx = le16_to_cpu(mf->u.frame.hwhdr.msgctxu.fld.req_idx);
654 req_idx_MR = (mr != NULL) ? 655 req_idx_MR = (mr != NULL) ?
655 le16_to_cpu(mr->u.frame.hwhdr.msgctxu.fld.req_idx) : req_idx; 656 le16_to_cpu(mr->u.frame.hwhdr.msgctxu.fld.req_idx) : req_idx;
@@ -660,12 +661,11 @@ mptscsih_io_done(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *mr)
660 printk (MYIOC_s_ERR_FMT 661 printk (MYIOC_s_ERR_FMT
661 "req_idx=%x req_idx_MR=%x mf=%p mr=%p sc=%p\n", 662 "req_idx=%x req_idx_MR=%x mf=%p mr=%p sc=%p\n",
662 ioc->name, req_idx, req_idx_MR, mf, mr, 663 ioc->name, req_idx, req_idx_MR, mf, mr,
663 hd->ScsiLookup[req_idx_MR]); 664 mptscsih_get_scsi_lookup(ioc, req_idx_MR));
664 return 0; 665 return 0;
665 } 666 }
666 667
667 sc = hd->ScsiLookup[req_idx]; 668 sc = mptscsih_getclear_scsi_lookup(ioc, req_idx);
668 hd->ScsiLookup[req_idx] = NULL;
669 if (sc == NULL) { 669 if (sc == NULL) {
670 MPIHeader_t *hdr = (MPIHeader_t *)mf; 670 MPIHeader_t *hdr = (MPIHeader_t *)mf;
671 671
@@ -738,8 +738,8 @@ mptscsih_io_done(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *mr)
738 */ 738 */
739 if (scsi_state & MPI_SCSI_STATE_RESPONSE_INFO_VALID && 739 if (scsi_state & MPI_SCSI_STATE_RESPONSE_INFO_VALID &&
740 pScsiReply->ResponseInfo) { 740 pScsiReply->ResponseInfo) {
741 printk(KERN_NOTICE "[%d:%d:%d:%d] " 741 printk(MYIOC_s_NOTE_FMT "[%d:%d:%d:%d] "
742 "FCP_ResponseInfo=%08xh\n", 742 "FCP_ResponseInfo=%08xh\n", ioc->name,
743 sc->device->host->host_no, sc->device->channel, 743 sc->device->host->host_no, sc->device->channel,
744 sc->device->id, sc->device->lun, 744 sc->device->id, sc->device->lun,
745 le32_to_cpu(pScsiReply->ResponseInfo)); 745 le32_to_cpu(pScsiReply->ResponseInfo));
@@ -771,10 +771,10 @@ mptscsih_io_done(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *mr)
771 if (hd->sel_timeout[pScsiReq->TargetID] < 0xFFFF) 771 if (hd->sel_timeout[pScsiReq->TargetID] < 0xFFFF)
772 hd->sel_timeout[pScsiReq->TargetID]++; 772 hd->sel_timeout[pScsiReq->TargetID]++;
773 773
774 vdev = sc->device->hostdata; 774 vdevice = sc->device->hostdata;
775 if (!vdev) 775 if (!vdevice)
776 break; 776 break;
777 vtarget = vdev->vtarget; 777 vtarget = vdevice->vtarget;
778 if (vtarget->tflags & MPT_TARGET_FLAGS_LED_ON) { 778 if (vtarget->tflags & MPT_TARGET_FLAGS_LED_ON) {
779 mptscsih_issue_sep_command(ioc, vtarget, 779 mptscsih_issue_sep_command(ioc, vtarget,
780 MPI_SEP_REQ_SLOTSTATUS_UNCONFIGURED); 780 MPI_SEP_REQ_SLOTSTATUS_UNCONFIGURED);
@@ -824,9 +824,9 @@ mptscsih_io_done(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *mr)
824 sc->result=DID_SOFT_ERROR << 16; 824 sc->result=DID_SOFT_ERROR << 16;
825 else /* Sufficient data transfer occurred */ 825 else /* Sufficient data transfer occurred */
826 sc->result = (DID_OK << 16) | scsi_status; 826 sc->result = (DID_OK << 16) | scsi_status;
827 dreplyprintk(ioc, printk(KERN_DEBUG 827 dreplyprintk(ioc, printk(MYIOC_s_DEBUG_FMT
828 "RESIDUAL_MISMATCH: result=%x on channel=%d id=%d\n", 828 "RESIDUAL_MISMATCH: result=%x on channel=%d id=%d\n",
829 sc->result, sc->device->channel, sc->device->id)); 829 ioc->name, sc->result, sc->device->channel, sc->device->id));
830 break; 830 break;
831 831
832 case MPI_IOCSTATUS_SCSI_DATA_UNDERRUN: /* 0x0045 */ 832 case MPI_IOCSTATUS_SCSI_DATA_UNDERRUN: /* 0x0045 */
@@ -858,9 +858,11 @@ mptscsih_io_done(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *mr)
858 } 858 }
859 859
860 860
861 dreplyprintk(ioc, printk(KERN_DEBUG " sc->underflow={report ERR if < %02xh bytes xfer'd}\n", 861 dreplyprintk(ioc, printk(MYIOC_s_DEBUG_FMT
862 sc->underflow)); 862 " sc->underflow={report ERR if < %02xh bytes xfer'd}\n",
863 dreplyprintk(ioc, printk(KERN_DEBUG " ActBytesXferd=%02xh\n", xfer_cnt)); 863 ioc->name, sc->underflow));
864 dreplyprintk(ioc, printk(MYIOC_s_DEBUG_FMT
865 " ActBytesXferd=%02xh\n", ioc->name, xfer_cnt));
864 866
865 /* Report Queue Full 867 /* Report Queue Full
866 */ 868 */
@@ -969,48 +971,32 @@ static void
969mptscsih_flush_running_cmds(MPT_SCSI_HOST *hd) 971mptscsih_flush_running_cmds(MPT_SCSI_HOST *hd)
970{ 972{
971 MPT_ADAPTER *ioc = hd->ioc; 973 MPT_ADAPTER *ioc = hd->ioc;
972 struct scsi_cmnd *SCpnt; 974 struct scsi_cmnd *sc;
973 MPT_FRAME_HDR *mf; 975 SCSIIORequest_t *mf = NULL;
974 int ii; 976 int ii;
975 int max = ioc->req_depth; 977 int channel, id;
976
977 dprintk(ioc, printk(KERN_DEBUG MYNAM ": flush_ScsiLookup called\n"));
978 for (ii= 0; ii < max; ii++) {
979 if ((SCpnt = hd->ScsiLookup[ii]) != NULL) {
980
981 /* Command found.
982 */
983
984 /* Null ScsiLookup index
985 */
986 hd->ScsiLookup[ii] = NULL;
987
988 mf = MPT_INDEX_2_MFPTR(ioc, ii);
989 dmfprintk(ioc, printk(KERN_DEBUG MYNAM ": flush: ScsiDone (mf=%p,sc=%p)\n",
990 mf, SCpnt));
991
992 /* Free Chain buffers */
993 mptscsih_freeChainBuffers(ioc, ii);
994
995 /* Free Message frames */
996 mpt_free_msg_frame(ioc, mf);
997
998 if ((unsigned char *)mf != SCpnt->host_scribble)
999 continue;
1000
1001 /* Set status, free OS resources (SG DMA buffers)
1002 * Do OS callback
1003 */
1004 scsi_dma_unmap(SCpnt);
1005
1006 SCpnt->result = DID_RESET << 16;
1007 SCpnt->host_scribble = NULL;
1008 978
1009 SCpnt->scsi_done(SCpnt); /* Issue the command callback */ 979 for (ii= 0; ii < ioc->req_depth; ii++) {
1010 } 980 sc = mptscsih_getclear_scsi_lookup(ioc, ii);
981 if (!sc)
982 continue;
983 mf = (SCSIIORequest_t *)MPT_INDEX_2_MFPTR(ioc, ii);
984 if (!mf)
985 continue;
986 channel = mf->Bus;
987 id = mf->TargetID;
988 mptscsih_freeChainBuffers(ioc, ii);
989 mpt_free_msg_frame(ioc, (MPT_FRAME_HDR *)mf);
990 if ((unsigned char *)mf != sc->host_scribble)
991 continue;
992 scsi_dma_unmap(sc);
993 sc->result = DID_RESET << 16;
994 sc->host_scribble = NULL;
995 sdev_printk(KERN_INFO, sc->device, MYIOC_s_FMT
996 "completing cmds: fw_channel %d, fw_id %d, sc=%p,"
997 " mf = %p, idx=%x\n", ioc->name, channel, id, sc, mf, ii);
998 sc->scsi_done(sc);
1011 } 999 }
1012
1013 return;
1014} 1000}
1015 1001
1016/* 1002/*
@@ -1032,17 +1018,16 @@ mptscsih_search_running_cmds(MPT_SCSI_HOST *hd, VirtDevice *vdevice)
1032{ 1018{
1033 SCSIIORequest_t *mf = NULL; 1019 SCSIIORequest_t *mf = NULL;
1034 int ii; 1020 int ii;
1035 int max = hd->ioc->req_depth;
1036 struct scsi_cmnd *sc; 1021 struct scsi_cmnd *sc;
1037 struct scsi_lun lun; 1022 struct scsi_lun lun;
1023 MPT_ADAPTER *ioc = hd->ioc;
1024 unsigned long flags;
1038 1025
1039 dsprintk(hd->ioc, printk(KERN_DEBUG MYNAM ": search_running channel %d id %d lun %d max %d\n", 1026 spin_lock_irqsave(&ioc->scsi_lookup_lock, flags);
1040 vdevice->vtarget->channel, vdevice->vtarget->id, vdevice->lun, max)); 1027 for (ii = 0; ii < ioc->req_depth; ii++) {
1041 1028 if ((sc = ioc->ScsiLookup[ii]) != NULL) {
1042 for (ii=0; ii < max; ii++) {
1043 if ((sc = hd->ScsiLookup[ii]) != NULL) {
1044 1029
1045 mf = (SCSIIORequest_t *)MPT_INDEX_2_MFPTR(hd->ioc, ii); 1030 mf = (SCSIIORequest_t *)MPT_INDEX_2_MFPTR(ioc, ii);
1046 if (mf == NULL) 1031 if (mf == NULL)
1047 continue; 1032 continue;
1048 /* If the device is a hidden raid component, then its 1033 /* If the device is a hidden raid component, then its
@@ -1059,22 +1044,23 @@ mptscsih_search_running_cmds(MPT_SCSI_HOST *hd, VirtDevice *vdevice)
1059 memcmp(lun.scsi_lun, mf->LUN, 8)) 1044 memcmp(lun.scsi_lun, mf->LUN, 8))
1060 continue; 1045 continue;
1061 1046
1062 /* Cleanup
1063 */
1064 hd->ScsiLookup[ii] = NULL;
1065 mptscsih_freeChainBuffers(hd->ioc, ii);
1066 mpt_free_msg_frame(hd->ioc, (MPT_FRAME_HDR *)mf);
1067 if ((unsigned char *)mf != sc->host_scribble) 1047 if ((unsigned char *)mf != sc->host_scribble)
1068 continue; 1048 continue;
1049 ioc->ScsiLookup[ii] = NULL;
1050 spin_unlock_irqrestore(&ioc->scsi_lookup_lock, flags);
1051 mptscsih_freeChainBuffers(ioc, ii);
1052 mpt_free_msg_frame(ioc, (MPT_FRAME_HDR *)mf);
1069 scsi_dma_unmap(sc); 1053 scsi_dma_unmap(sc);
1070 sc->host_scribble = NULL; 1054 sc->host_scribble = NULL;
1071 sc->result = DID_NO_CONNECT << 16; 1055 sc->result = DID_NO_CONNECT << 16;
1072 sdev_printk(KERN_INFO, sc->device, "completing cmds: fw_channel %d," 1056 sdev_printk(KERN_INFO, sc->device, MYIOC_s_FMT "completing cmds: fw_channel %d,"
1073 "fw_id %d, sc=%p, mf = %p, idx=%x\n", vdevice->vtarget->channel, 1057 "fw_id %d, sc=%p, mf = %p, idx=%x\n", ioc->name, vdevice->vtarget->channel,
1074 vdevice->vtarget->id, sc, mf, ii); 1058 vdevice->vtarget->id, sc, mf, ii);
1075 sc->scsi_done(sc); 1059 sc->scsi_done(sc);
1060 spin_lock_irqsave(&ioc->scsi_lookup_lock, flags);
1076 } 1061 }
1077 } 1062 }
1063 spin_unlock_irqrestore(&ioc->scsi_lookup_lock, flags);
1078 return; 1064 return;
1079} 1065}
1080 1066
@@ -1097,17 +1083,18 @@ mptscsih_report_queue_full(struct scsi_cmnd *sc, SCSIIOReply_t *pScsiReply, SCSI
1097{ 1083{
1098 long time = jiffies; 1084 long time = jiffies;
1099 MPT_SCSI_HOST *hd; 1085 MPT_SCSI_HOST *hd;
1086 MPT_ADAPTER *ioc;
1100 1087
1101 if (sc->device == NULL) 1088 if (sc->device == NULL)
1102 return; 1089 return;
1103 if (sc->device->host == NULL) 1090 if (sc->device->host == NULL)
1104 return; 1091 return;
1105 if ((hd = (MPT_SCSI_HOST *)sc->device->host->hostdata) == NULL) 1092 if ((hd = shost_priv(sc->device->host)) == NULL)
1106 return; 1093 return;
1107 1094 ioc = hd->ioc;
1108 if (time - hd->last_queue_full > 10 * HZ) { 1095 if (time - hd->last_queue_full > 10 * HZ) {
1109 dprintk(hd->ioc, printk(MYIOC_s_WARN_FMT "Device (%d:%d:%d) reported QUEUE_FULL!\n", 1096 dprintk(ioc, printk(MYIOC_s_WARN_FMT "Device (%d:%d:%d) reported QUEUE_FULL!\n",
1110 hd->ioc->name, 0, sc->device->id, sc->device->lun)); 1097 ioc->name, 0, sc->device->id, sc->device->lun));
1111 hd->last_queue_full = time; 1098 hd->last_queue_full = time;
1112 } 1099 }
1113} 1100}
@@ -1134,28 +1121,28 @@ mptscsih_remove(struct pci_dev *pdev)
1134 1121
1135 scsi_remove_host(host); 1122 scsi_remove_host(host);
1136 1123
1137 if((hd = (MPT_SCSI_HOST *)host->hostdata) == NULL) 1124 if((hd = shost_priv(host)) == NULL)
1138 return; 1125 return;
1139 1126
1140 mptscsih_shutdown(pdev); 1127 mptscsih_shutdown(pdev);
1141 1128
1142 sz1=0; 1129 sz1=0;
1143 1130
1144 if (hd->ScsiLookup != NULL) { 1131 if (ioc->ScsiLookup != NULL) {
1145 sz1 = hd->ioc->req_depth * sizeof(void *); 1132 sz1 = ioc->req_depth * sizeof(void *);
1146 kfree(hd->ScsiLookup); 1133 kfree(ioc->ScsiLookup);
1147 hd->ScsiLookup = NULL; 1134 ioc->ScsiLookup = NULL;
1148 } 1135 }
1149 1136
1150 dprintk(hd->ioc, printk(MYIOC_s_DEBUG_FMT 1137 dprintk(ioc, printk(MYIOC_s_DEBUG_FMT
1151 "Free'd ScsiLookup (%d) memory\n", 1138 "Free'd ScsiLookup (%d) memory\n",
1152 hd->ioc->name, sz1)); 1139 ioc->name, sz1));
1153 1140
1154 kfree(hd->info_kbuf); 1141 kfree(hd->info_kbuf);
1155 1142
1156 /* NULL the Scsi_Host pointer 1143 /* NULL the Scsi_Host pointer
1157 */ 1144 */
1158 hd->ioc->sh = NULL; 1145 ioc->sh = NULL;
1159 1146
1160 scsi_host_put(host); 1147 scsi_host_put(host);
1161 1148
@@ -1171,15 +1158,6 @@ mptscsih_remove(struct pci_dev *pdev)
1171void 1158void
1172mptscsih_shutdown(struct pci_dev *pdev) 1159mptscsih_shutdown(struct pci_dev *pdev)
1173{ 1160{
1174 MPT_ADAPTER *ioc = pci_get_drvdata(pdev);
1175 struct Scsi_Host *host = ioc->sh;
1176 MPT_SCSI_HOST *hd;
1177
1178 if(!host)
1179 return;
1180
1181 hd = (MPT_SCSI_HOST *)host->hostdata;
1182
1183} 1161}
1184 1162
1185#ifdef CONFIG_PM 1163#ifdef CONFIG_PM
@@ -1225,7 +1203,7 @@ mptscsih_info(struct Scsi_Host *SChost)
1225 MPT_SCSI_HOST *h; 1203 MPT_SCSI_HOST *h;
1226 int size = 0; 1204 int size = 0;
1227 1205
1228 h = (MPT_SCSI_HOST *)SChost->hostdata; 1206 h = shost_priv(SChost);
1229 1207
1230 if (h) { 1208 if (h) {
1231 if (h->info_kbuf == NULL) 1209 if (h->info_kbuf == NULL)
@@ -1319,7 +1297,7 @@ int
1319mptscsih_proc_info(struct Scsi_Host *host, char *buffer, char **start, off_t offset, 1297mptscsih_proc_info(struct Scsi_Host *host, char *buffer, char **start, off_t offset,
1320 int length, int func) 1298 int length, int func)
1321{ 1299{
1322 MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *)host->hostdata; 1300 MPT_SCSI_HOST *hd = shost_priv(host);
1323 MPT_ADAPTER *ioc = hd->ioc; 1301 MPT_ADAPTER *ioc = hd->ioc;
1324 int size = 0; 1302 int size = 0;
1325 1303
@@ -1358,7 +1336,7 @@ mptscsih_qcmd(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *))
1358 MPT_SCSI_HOST *hd; 1336 MPT_SCSI_HOST *hd;
1359 MPT_FRAME_HDR *mf; 1337 MPT_FRAME_HDR *mf;
1360 SCSIIORequest_t *pScsiReq; 1338 SCSIIORequest_t *pScsiReq;
1361 VirtDevice *vdev = SCpnt->device->hostdata; 1339 VirtDevice *vdevice = SCpnt->device->hostdata;
1362 int lun; 1340 int lun;
1363 u32 datalen; 1341 u32 datalen;
1364 u32 scsictl; 1342 u32 scsictl;
@@ -1368,7 +1346,7 @@ mptscsih_qcmd(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *))
1368 int ii; 1346 int ii;
1369 MPT_ADAPTER *ioc; 1347 MPT_ADAPTER *ioc;
1370 1348
1371 hd = (MPT_SCSI_HOST *) SCpnt->device->host->hostdata; 1349 hd = shost_priv(SCpnt->device->host);
1372 ioc = hd->ioc; 1350 ioc = hd->ioc;
1373 lun = SCpnt->device->lun; 1351 lun = SCpnt->device->lun;
1374 SCpnt->scsi_done = done; 1352 SCpnt->scsi_done = done;
@@ -1385,7 +1363,7 @@ mptscsih_qcmd(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *))
1385 /* 1363 /*
1386 * Put together a MPT SCSI request... 1364 * Put together a MPT SCSI request...
1387 */ 1365 */
1388 if ((mf = mpt_get_msg_frame(hd->ioc->DoneCtx, hd->ioc)) == NULL) { 1366 if ((mf = mpt_get_msg_frame(ioc->DoneCtx, ioc)) == NULL) {
1389 dprintk(ioc, printk(MYIOC_s_WARN_FMT "QueueCmd, no msg frames!!\n", 1367 dprintk(ioc, printk(MYIOC_s_WARN_FMT "QueueCmd, no msg frames!!\n",
1390 ioc->name)); 1368 ioc->name));
1391 return SCSI_MLQUEUE_HOST_BUSY; 1369 return SCSI_MLQUEUE_HOST_BUSY;
@@ -1415,8 +1393,8 @@ mptscsih_qcmd(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *))
1415 /* Default to untagged. Once a target structure has been allocated, 1393 /* Default to untagged. Once a target structure has been allocated,
1416 * use the Inquiry data to determine if device supports tagged. 1394 * use the Inquiry data to determine if device supports tagged.
1417 */ 1395 */
1418 if (vdev 1396 if (vdevice
1419 && (vdev->vtarget->tflags & MPT_TARGET_FLAGS_Q_YES) 1397 && (vdevice->vtarget->tflags & MPT_TARGET_FLAGS_Q_YES)
1420 && (SCpnt->device->tagged_supported)) { 1398 && (SCpnt->device->tagged_supported)) {
1421 scsictl = scsidir | MPI_SCSIIO_CONTROL_SIMPLEQ; 1399 scsictl = scsidir | MPI_SCSIIO_CONTROL_SIMPLEQ;
1422 } else { 1400 } else {
@@ -1425,10 +1403,10 @@ mptscsih_qcmd(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *))
1425 1403
1426 /* Use the above information to set up the message frame 1404 /* Use the above information to set up the message frame
1427 */ 1405 */
1428 pScsiReq->TargetID = (u8) vdev->vtarget->id; 1406 pScsiReq->TargetID = (u8) vdevice->vtarget->id;
1429 pScsiReq->Bus = vdev->vtarget->channel; 1407 pScsiReq->Bus = vdevice->vtarget->channel;
1430 pScsiReq->ChainOffset = 0; 1408 pScsiReq->ChainOffset = 0;
1431 if (vdev->vtarget->tflags & MPT_TARGET_FLAGS_RAID_COMPONENT) 1409 if (vdevice->vtarget->tflags & MPT_TARGET_FLAGS_RAID_COMPONENT)
1432 pScsiReq->Function = MPI_FUNCTION_RAID_SCSI_IO_PASSTHROUGH; 1410 pScsiReq->Function = MPI_FUNCTION_RAID_SCSI_IO_PASSTHROUGH;
1433 else 1411 else
1434 pScsiReq->Function = MPI_FUNCTION_SCSI_IO_REQUEST; 1412 pScsiReq->Function = MPI_FUNCTION_SCSI_IO_REQUEST;
@@ -1453,7 +1431,7 @@ mptscsih_qcmd(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *))
1453 pScsiReq->DataLength = cpu_to_le32(datalen); 1431 pScsiReq->DataLength = cpu_to_le32(datalen);
1454 1432
1455 /* SenseBuffer low address */ 1433 /* SenseBuffer low address */
1456 pScsiReq->SenseBufferLowAddr = cpu_to_le32(hd->ioc->sense_buf_low_dma 1434 pScsiReq->SenseBufferLowAddr = cpu_to_le32(ioc->sense_buf_low_dma
1457 + (my_idx * MPT_SENSE_BUFFER_ALLOC)); 1435 + (my_idx * MPT_SENSE_BUFFER_ALLOC));
1458 1436
1459 /* Now add the SG list 1437 /* Now add the SG list
@@ -1465,23 +1443,22 @@ mptscsih_qcmd(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *))
1465 (dma_addr_t) -1); 1443 (dma_addr_t) -1);
1466 } else { 1444 } else {
1467 /* Add a 32 or 64 bit SGE */ 1445 /* Add a 32 or 64 bit SGE */
1468 if (mptscsih_AddSGE(hd->ioc, SCpnt, pScsiReq, my_idx) != SUCCESS) 1446 if (mptscsih_AddSGE(ioc, SCpnt, pScsiReq, my_idx) != SUCCESS)
1469 goto fail; 1447 goto fail;
1470 } 1448 }
1471 1449
1472 SCpnt->host_scribble = (unsigned char *)mf; 1450 SCpnt->host_scribble = (unsigned char *)mf;
1473 hd->ScsiLookup[my_idx] = SCpnt; 1451 mptscsih_set_scsi_lookup(ioc, my_idx, SCpnt);
1474 1452
1475 mpt_put_msg_frame(hd->ioc->DoneCtx, hd->ioc, mf); 1453 mpt_put_msg_frame(ioc->DoneCtx, ioc, mf);
1476 dmfprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Issued SCSI cmd (%p) mf=%p idx=%d\n", 1454 dmfprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Issued SCSI cmd (%p) mf=%p idx=%d\n",
1477 ioc->name, SCpnt, mf, my_idx)); 1455 ioc->name, SCpnt, mf, my_idx));
1478 DBG_DUMP_REQUEST_FRAME(ioc, (u32 *)mf) 1456 DBG_DUMP_REQUEST_FRAME(ioc, (u32 *)mf);
1479 return 0; 1457 return 0;
1480 1458
1481 fail: 1459 fail:
1482 hd->ScsiLookup[my_idx] = NULL; 1460 mptscsih_freeChainBuffers(ioc, my_idx);
1483 mptscsih_freeChainBuffers(hd->ioc, my_idx); 1461 mpt_free_msg_frame(ioc, mf);
1484 mpt_free_msg_frame(hd->ioc, mf);
1485 return SCSI_MLQUEUE_HOST_BUSY; 1462 return SCSI_MLQUEUE_HOST_BUSY;
1486} 1463}
1487 1464
@@ -1590,38 +1567,38 @@ mptscsih_TMHandler(MPT_SCSI_HOST *hd, u8 type, u8 channel, u8 id, int lun, int c
1590 */ 1567 */
1591 if (mptscsih_tm_pending_wait(hd) == FAILED) { 1568 if (mptscsih_tm_pending_wait(hd) == FAILED) {
1592 if (type == MPI_SCSITASKMGMT_TASKTYPE_ABORT_TASK) { 1569 if (type == MPI_SCSITASKMGMT_TASKTYPE_ABORT_TASK) {
1593 dtmprintk(ioc, printk(KERN_DEBUG MYNAM ": %s: TMHandler abort: " 1570 dtmprintk(ioc, printk(MYIOC_s_DEBUG_FMT "TMHandler abort: "
1594 "Timed out waiting for last TM (%d) to complete! \n", 1571 "Timed out waiting for last TM (%d) to complete! \n",
1595 ioc->name, hd->tmPending)); 1572 ioc->name, hd->tmPending));
1596 return FAILED; 1573 return FAILED;
1597 } else if (type == MPI_SCSITASKMGMT_TASKTYPE_TARGET_RESET) { 1574 } else if (type == MPI_SCSITASKMGMT_TASKTYPE_TARGET_RESET) {
1598 dtmprintk(ioc, printk(KERN_DEBUG MYNAM ": %s: TMHandler target " 1575 dtmprintk(ioc, printk(MYIOC_s_DEBUG_FMT "TMHandler target "
1599 "reset: Timed out waiting for last TM (%d) " 1576 "reset: Timed out waiting for last TM (%d) "
1600 "to complete! \n", ioc->name, 1577 "to complete! \n", ioc->name,
1601 hd->tmPending)); 1578 hd->tmPending));
1602 return FAILED; 1579 return FAILED;
1603 } else if (type == MPI_SCSITASKMGMT_TASKTYPE_RESET_BUS) { 1580 } else if (type == MPI_SCSITASKMGMT_TASKTYPE_RESET_BUS) {
1604 dtmprintk(ioc, printk(KERN_DEBUG MYNAM ": %s: TMHandler bus reset: " 1581 dtmprintk(ioc, printk(MYIOC_s_DEBUG_FMT "TMHandler bus reset: "
1605 "Timed out waiting for last TM (%d) to complete! \n", 1582 "Timed out waiting for last TM (%d) to complete! \n",
1606 ioc->name, hd->tmPending)); 1583 ioc->name, hd->tmPending));
1607 return FAILED; 1584 return FAILED;
1608 } 1585 }
1609 } else { 1586 } else {
1610 spin_lock_irqsave(&hd->ioc->FreeQlock, flags); 1587 spin_lock_irqsave(&ioc->FreeQlock, flags);
1611 hd->tmPending |= (1 << type); 1588 hd->tmPending |= (1 << type);
1612 spin_unlock_irqrestore(&hd->ioc->FreeQlock, flags); 1589 spin_unlock_irqrestore(&ioc->FreeQlock, flags);
1613 } 1590 }
1614 1591
1615 ioc_raw_state = mpt_GetIocState(hd->ioc, 0); 1592 ioc_raw_state = mpt_GetIocState(ioc, 0);
1616 1593
1617 if ((ioc_raw_state & MPI_IOC_STATE_MASK) != MPI_IOC_STATE_OPERATIONAL) { 1594 if ((ioc_raw_state & MPI_IOC_STATE_MASK) != MPI_IOC_STATE_OPERATIONAL) {
1618 printk(MYIOC_s_WARN_FMT 1595 printk(MYIOC_s_WARN_FMT
1619 "TM Handler for type=%x: IOC Not operational (0x%x)!\n", 1596 "TM Handler for type=%x: IOC Not operational (0x%x)!\n",
1620 ioc->name, type, ioc_raw_state); 1597 ioc->name, type, ioc_raw_state);
1621 printk(KERN_WARNING " Issuing HardReset!!\n"); 1598 printk(MYIOC_s_WARN_FMT " Issuing HardReset!!\n", ioc->name);
1622 if (mpt_HardResetHandler(ioc, CAN_SLEEP) < 0) 1599 if (mpt_HardResetHandler(ioc, CAN_SLEEP) < 0)
1623 printk((KERN_WARNING "TMHandler: HardReset " 1600 printk(MYIOC_s_WARN_FMT "TMHandler: HardReset "
1624 "FAILED!!\n")); 1601 "FAILED!!\n", ioc->name);
1625 return FAILED; 1602 return FAILED;
1626 } 1603 }
1627 1604
@@ -1680,16 +1657,17 @@ mptscsih_IssueTaskMgmt(MPT_SCSI_HOST *hd, u8 type, u8 channel, u8 id, int lun, i
1680 SCSITaskMgmt_t *pScsiTm; 1657 SCSITaskMgmt_t *pScsiTm;
1681 int ii; 1658 int ii;
1682 int retval; 1659 int retval;
1660 MPT_ADAPTER *ioc = hd->ioc;
1683 1661
1684 /* Return Fail to calling function if no message frames available. 1662 /* Return Fail to calling function if no message frames available.
1685 */ 1663 */
1686 if ((mf = mpt_get_msg_frame(hd->ioc->TaskCtx, hd->ioc)) == NULL) { 1664 if ((mf = mpt_get_msg_frame(ioc->TaskCtx, ioc)) == NULL) {
1687 dfailprintk(hd->ioc, printk(MYIOC_s_ERR_FMT "IssueTaskMgmt, no msg frames!!\n", 1665 dfailprintk(ioc, printk(MYIOC_s_ERR_FMT "IssueTaskMgmt, no msg frames!!\n",
1688 hd->ioc->name)); 1666 ioc->name));
1689 return FAILED; 1667 return FAILED;
1690 } 1668 }
1691 dtmprintk(hd->ioc, printk(MYIOC_s_DEBUG_FMT "IssueTaskMgmt request @ %p\n", 1669 dtmprintk(ioc, printk(MYIOC_s_DEBUG_FMT "IssueTaskMgmt request @ %p\n",
1692 hd->ioc->name, mf)); 1670 ioc->name, mf));
1693 1671
1694 /* Format the Request 1672 /* Format the Request
1695 */ 1673 */
@@ -1712,28 +1690,34 @@ mptscsih_IssueTaskMgmt(MPT_SCSI_HOST *hd, u8 type, u8 channel, u8 id, int lun, i
1712 1690
1713 pScsiTm->TaskMsgContext = ctx2abort; 1691 pScsiTm->TaskMsgContext = ctx2abort;
1714 1692
1715 dtmprintk(hd->ioc, printk(MYIOC_s_DEBUG_FMT "IssueTaskMgmt: ctx2abort (0x%08x) " 1693 dtmprintk(ioc, printk(MYIOC_s_DEBUG_FMT "IssueTaskMgmt: ctx2abort (0x%08x) "
1716 "type=%d\n", hd->ioc->name, ctx2abort, type)); 1694 "type=%d\n", ioc->name, ctx2abort, type));
1717 1695
1718 DBG_DUMP_TM_REQUEST_FRAME(ioc, (u32 *)pScsiTm); 1696 DBG_DUMP_TM_REQUEST_FRAME(ioc, (u32 *)pScsiTm);
1719 1697
1720 if ((retval = mpt_send_handshake_request(hd->ioc->TaskCtx, hd->ioc, 1698 if ((ioc->facts.IOCCapabilities & MPI_IOCFACTS_CAPABILITY_HIGH_PRI_Q) &&
1721 sizeof(SCSITaskMgmt_t), (u32*)pScsiTm, CAN_SLEEP)) != 0) { 1699 (ioc->facts.MsgVersion >= MPI_VERSION_01_05))
1722 dfailprintk(hd->ioc, printk(MYIOC_s_ERR_FMT "send_handshake FAILED!" 1700 mpt_put_msg_frame_hi_pri(ioc->TaskCtx, ioc, mf);
1723 " (hd %p, ioc %p, mf %p, rc=%d) \n", hd->ioc->name, hd, 1701 else {
1724 hd->ioc, mf, retval)); 1702 retval = mpt_send_handshake_request(ioc->TaskCtx, ioc,
1725 goto fail_out; 1703 sizeof(SCSITaskMgmt_t), (u32*)pScsiTm, CAN_SLEEP);
1704 if (retval) {
1705 dfailprintk(ioc, printk(MYIOC_s_ERR_FMT "send_handshake FAILED!"
1706 " (hd %p, ioc %p, mf %p, rc=%d) \n", ioc->name, hd,
1707 ioc, mf, retval));
1708 goto fail_out;
1709 }
1726 } 1710 }
1727 1711
1728 if(mptscsih_tm_wait_for_completion(hd, timeout) == FAILED) { 1712 if(mptscsih_tm_wait_for_completion(hd, timeout) == FAILED) {
1729 dfailprintk(hd->ioc, printk(MYIOC_s_ERR_FMT "task management request TIMED OUT!" 1713 dfailprintk(ioc, printk(MYIOC_s_ERR_FMT "task management request TIMED OUT!"
1730 " (hd %p, ioc %p, mf %p) \n", hd->ioc->name, hd, 1714 " (hd %p, ioc %p, mf %p) \n", ioc->name, hd,
1731 hd->ioc, mf)); 1715 ioc, mf));
1732 dtmprintk(hd->ioc, printk(MYIOC_s_DEBUG_FMT "Calling HardReset! \n", 1716 dtmprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Calling HardReset! \n",
1733 hd->ioc->name)); 1717 ioc->name));
1734 retval = mpt_HardResetHandler(hd->ioc, CAN_SLEEP); 1718 retval = mpt_HardResetHandler(ioc, CAN_SLEEP);
1735 dtmprintk(hd->ioc, printk(MYIOC_s_DEBUG_FMT "rc=%d \n", 1719 dtmprintk(ioc, printk(MYIOC_s_DEBUG_FMT "rc=%d \n",
1736 hd->ioc->name, retval)); 1720 ioc->name, retval));
1737 goto fail_out; 1721 goto fail_out;
1738 } 1722 }
1739 1723
@@ -1754,7 +1738,7 @@ mptscsih_IssueTaskMgmt(MPT_SCSI_HOST *hd, u8 type, u8 channel, u8 id, int lun, i
1754 /* 1738 /*
1755 * Free task managment mf, and corresponding tm flags 1739 * Free task managment mf, and corresponding tm flags
1756 */ 1740 */
1757 mpt_free_msg_frame(hd->ioc, mf); 1741 mpt_free_msg_frame(ioc, mf);
1758 hd->tmPending = 0; 1742 hd->tmPending = 0;
1759 hd->tmState = TM_STATE_NONE; 1743 hd->tmState = TM_STATE_NONE;
1760 return FAILED; 1744 return FAILED;
@@ -1797,11 +1781,11 @@ mptscsih_abort(struct scsi_cmnd * SCpnt)
1797 1781
1798 /* If we can't locate our host adapter structure, return FAILED status. 1782 /* If we can't locate our host adapter structure, return FAILED status.
1799 */ 1783 */
1800 if ((hd = (MPT_SCSI_HOST *) SCpnt->device->host->hostdata) == NULL) { 1784 if ((hd = shost_priv(SCpnt->device->host)) == NULL) {
1801 SCpnt->result = DID_RESET << 16; 1785 SCpnt->result = DID_RESET << 16;
1802 SCpnt->scsi_done(SCpnt); 1786 SCpnt->scsi_done(SCpnt);
1803 printk(KERN_DEBUG MYNAM ": mptscsih_abort: Can't locate " 1787 printk(KERN_ERR MYNAM ": task abort: "
1804 "host! (sc=%p)\n", SCpnt); 1788 "can't locate host! (sc=%p)\n", SCpnt);
1805 return FAILED; 1789 return FAILED;
1806 } 1790 }
1807 1791
@@ -1812,8 +1796,9 @@ mptscsih_abort(struct scsi_cmnd * SCpnt)
1812 1796
1813 vdevice = SCpnt->device->hostdata; 1797 vdevice = SCpnt->device->hostdata;
1814 if (!vdevice || !vdevice->vtarget) { 1798 if (!vdevice || !vdevice->vtarget) {
1815 dtmprintk(ioc, printk(MYIOC_s_DEBUG_FMT "task abort: device has been " 1799 dtmprintk(ioc, printk(MYIOC_s_DEBUG_FMT
1816 "deleted (sc=%p)\n", ioc->name, SCpnt)); 1800 "task abort: device has been deleted (sc=%p)\n",
1801 ioc->name, SCpnt));
1817 SCpnt->result = DID_NO_CONNECT << 16; 1802 SCpnt->result = DID_NO_CONNECT << 16;
1818 SCpnt->scsi_done(SCpnt); 1803 SCpnt->scsi_done(SCpnt);
1819 retval = 0; 1804 retval = 0;
@@ -1823,8 +1808,9 @@ mptscsih_abort(struct scsi_cmnd * SCpnt)
1823 /* Task aborts are not supported for hidden raid components. 1808 /* Task aborts are not supported for hidden raid components.
1824 */ 1809 */
1825 if (vdevice->vtarget->tflags & MPT_TARGET_FLAGS_RAID_COMPONENT) { 1810 if (vdevice->vtarget->tflags & MPT_TARGET_FLAGS_RAID_COMPONENT) {
1826 dtmprintk(ioc, printk(MYIOC_s_DEBUG_FMT "task abort: hidden raid " 1811 dtmprintk(ioc, printk(MYIOC_s_DEBUG_FMT
1827 "component (sc=%p)\n", ioc->name, SCpnt)); 1812 "task abort: hidden raid component (sc=%p)\n",
1813 ioc->name, SCpnt));
1828 SCpnt->result = DID_RESET << 16; 1814 SCpnt->result = DID_RESET << 16;
1829 retval = FAILED; 1815 retval = FAILED;
1830 goto out; 1816 goto out;
@@ -1832,12 +1818,12 @@ mptscsih_abort(struct scsi_cmnd * SCpnt)
1832 1818
1833 /* Find this command 1819 /* Find this command
1834 */ 1820 */
1835 if ((scpnt_idx = SCPNT_TO_LOOKUP_IDX(SCpnt)) < 0) { 1821 if ((scpnt_idx = SCPNT_TO_LOOKUP_IDX(ioc, SCpnt)) < 0) {
1836 /* Cmd not found in ScsiLookup. 1822 /* Cmd not found in ScsiLookup.
1837 * Do OS callback. 1823 * Do OS callback.
1838 */ 1824 */
1839 SCpnt->result = DID_RESET << 16; 1825 SCpnt->result = DID_RESET << 16;
1840 dtmprintk(ioc, printk(KERN_DEBUG MYNAM ": %s: mptscsih_abort: " 1826 dtmprintk(ioc, printk(MYIOC_s_DEBUG_FMT "task abort: "
1841 "Command not in the active list! (sc=%p)\n", ioc->name, 1827 "Command not in the active list! (sc=%p)\n", ioc->name,
1842 SCpnt)); 1828 SCpnt));
1843 retval = 0; 1829 retval = 0;
@@ -1859,7 +1845,7 @@ mptscsih_abort(struct scsi_cmnd * SCpnt)
1859 * swap it here either. It is an opaque cookie to 1845 * swap it here either. It is an opaque cookie to
1860 * the controller, so it does not matter. -DaveM 1846 * the controller, so it does not matter. -DaveM
1861 */ 1847 */
1862 mf = MPT_INDEX_2_MFPTR(hd->ioc, scpnt_idx); 1848 mf = MPT_INDEX_2_MFPTR(ioc, scpnt_idx);
1863 ctx2abort = mf->u.frame.hwhdr.msgctxu.MsgContext; 1849 ctx2abort = mf->u.frame.hwhdr.msgctxu.MsgContext;
1864 1850
1865 hd->abortSCpnt = SCpnt; 1851 hd->abortSCpnt = SCpnt;
@@ -1868,7 +1854,7 @@ mptscsih_abort(struct scsi_cmnd * SCpnt)
1868 vdevice->vtarget->channel, vdevice->vtarget->id, vdevice->lun, 1854 vdevice->vtarget->channel, vdevice->vtarget->id, vdevice->lun,
1869 ctx2abort, mptscsih_get_tm_timeout(ioc)); 1855 ctx2abort, mptscsih_get_tm_timeout(ioc));
1870 1856
1871 if (SCPNT_TO_LOOKUP_IDX(SCpnt) == scpnt_idx && 1857 if (SCPNT_TO_LOOKUP_IDX(ioc, SCpnt) == scpnt_idx &&
1872 SCpnt->serial_number == sn) 1858 SCpnt->serial_number == sn)
1873 retval = FAILED; 1859 retval = FAILED;
1874 1860
@@ -1901,9 +1887,9 @@ mptscsih_dev_reset(struct scsi_cmnd * SCpnt)
1901 1887
1902 /* If we can't locate our host adapter structure, return FAILED status. 1888 /* If we can't locate our host adapter structure, return FAILED status.
1903 */ 1889 */
1904 if ((hd = (MPT_SCSI_HOST *) SCpnt->device->host->hostdata) == NULL){ 1890 if ((hd = shost_priv(SCpnt->device->host)) == NULL){
1905 printk(KERN_DEBUG MYNAM ": mptscsih_dev_reset: Can't " 1891 printk(KERN_ERR MYNAM ": target reset: "
1906 "locate host! (sc=%p)\n", SCpnt); 1892 "Can't locate host! (sc=%p)\n", SCpnt);
1907 return FAILED; 1893 return FAILED;
1908 } 1894 }
1909 1895
@@ -1959,14 +1945,14 @@ mptscsih_bus_reset(struct scsi_cmnd * SCpnt)
1959{ 1945{
1960 MPT_SCSI_HOST *hd; 1946 MPT_SCSI_HOST *hd;
1961 int retval; 1947 int retval;
1962 VirtDevice *vdev; 1948 VirtDevice *vdevice;
1963 MPT_ADAPTER *ioc; 1949 MPT_ADAPTER *ioc;
1964 1950
1965 /* If we can't locate our host adapter structure, return FAILED status. 1951 /* If we can't locate our host adapter structure, return FAILED status.
1966 */ 1952 */
1967 if ((hd = (MPT_SCSI_HOST *) SCpnt->device->host->hostdata) == NULL){ 1953 if ((hd = shost_priv(SCpnt->device->host)) == NULL){
1968 printk(KERN_DEBUG MYNAM ": mptscsih_bus_reset: Can't " 1954 printk(KERN_ERR MYNAM ": bus reset: "
1969 "locate host! (sc=%p)\n", SCpnt ); 1955 "Can't locate host! (sc=%p)\n", SCpnt);
1970 return FAILED; 1956 return FAILED;
1971 } 1957 }
1972 1958
@@ -1978,9 +1964,9 @@ mptscsih_bus_reset(struct scsi_cmnd * SCpnt)
1978 if (hd->timeouts < -1) 1964 if (hd->timeouts < -1)
1979 hd->timeouts++; 1965 hd->timeouts++;
1980 1966
1981 vdev = SCpnt->device->hostdata; 1967 vdevice = SCpnt->device->hostdata;
1982 retval = mptscsih_TMHandler(hd, MPI_SCSITASKMGMT_TASKTYPE_RESET_BUS, 1968 retval = mptscsih_TMHandler(hd, MPI_SCSITASKMGMT_TASKTYPE_RESET_BUS,
1983 vdev->vtarget->channel, 0, 0, 0, mptscsih_get_tm_timeout(ioc)); 1969 vdevice->vtarget->channel, 0, 0, 0, mptscsih_get_tm_timeout(ioc));
1984 1970
1985 printk(MYIOC_s_INFO_FMT "bus reset: %s (sc=%p)\n", 1971 printk(MYIOC_s_INFO_FMT "bus reset: %s (sc=%p)\n",
1986 ioc->name, ((retval == 0) ? "SUCCESS" : "FAILED" ), SCpnt); 1972 ioc->name, ((retval == 0) ? "SUCCESS" : "FAILED" ), SCpnt);
@@ -2008,9 +1994,9 @@ mptscsih_host_reset(struct scsi_cmnd *SCpnt)
2008 MPT_ADAPTER *ioc; 1994 MPT_ADAPTER *ioc;
2009 1995
2010 /* If we can't locate the host to reset, then we failed. */ 1996 /* If we can't locate the host to reset, then we failed. */
2011 if ((hd = (MPT_SCSI_HOST *) SCpnt->device->host->hostdata) == NULL){ 1997 if ((hd = shost_priv(SCpnt->device->host)) == NULL){
2012 printk( KERN_DEBUG MYNAM ": mptscsih_host_reset: Can't " 1998 printk(KERN_ERR MYNAM ": host reset: "
2013 "locate host! (sc=%p)\n", SCpnt); 1999 "Can't locate host! (sc=%p)\n", SCpnt);
2014 return FAILED; 2000 return FAILED;
2015 } 2001 }
2016 2002
@@ -2021,7 +2007,7 @@ mptscsih_host_reset(struct scsi_cmnd *SCpnt)
2021 /* If our attempts to reset the host failed, then return a failed 2007 /* If our attempts to reset the host failed, then return a failed
2022 * status. The host will be taken off line by the SCSI mid-layer. 2008 * status. The host will be taken off line by the SCSI mid-layer.
2023 */ 2009 */
2024 if (mpt_HardResetHandler(hd->ioc, CAN_SLEEP) < 0) { 2010 if (mpt_HardResetHandler(ioc, CAN_SLEEP) < 0) {
2025 retval = FAILED; 2011 retval = FAILED;
2026 } else { 2012 } else {
2027 /* Make sure TM pending is cleared and TM state is set to 2013 /* Make sure TM pending is cleared and TM state is set to
@@ -2051,17 +2037,18 @@ mptscsih_tm_pending_wait(MPT_SCSI_HOST * hd)
2051 unsigned long flags; 2037 unsigned long flags;
2052 int loop_count = 4 * 10; /* Wait 10 seconds */ 2038 int loop_count = 4 * 10; /* Wait 10 seconds */
2053 int status = FAILED; 2039 int status = FAILED;
2040 MPT_ADAPTER *ioc = hd->ioc;
2054 2041
2055 do { 2042 do {
2056 spin_lock_irqsave(&hd->ioc->FreeQlock, flags); 2043 spin_lock_irqsave(&ioc->FreeQlock, flags);
2057 if (hd->tmState == TM_STATE_NONE) { 2044 if (hd->tmState == TM_STATE_NONE) {
2058 hd->tmState = TM_STATE_IN_PROGRESS; 2045 hd->tmState = TM_STATE_IN_PROGRESS;
2059 hd->tmPending = 1; 2046 hd->tmPending = 1;
2060 spin_unlock_irqrestore(&hd->ioc->FreeQlock, flags); 2047 spin_unlock_irqrestore(&ioc->FreeQlock, flags);
2061 status = SUCCESS; 2048 status = SUCCESS;
2062 break; 2049 break;
2063 } 2050 }
2064 spin_unlock_irqrestore(&hd->ioc->FreeQlock, flags); 2051 spin_unlock_irqrestore(&ioc->FreeQlock, flags);
2065 msleep(250); 2052 msleep(250);
2066 } while (--loop_count); 2053 } while (--loop_count);
2067 2054
@@ -2082,15 +2069,16 @@ mptscsih_tm_wait_for_completion(MPT_SCSI_HOST * hd, ulong timeout )
2082 unsigned long flags; 2069 unsigned long flags;
2083 int loop_count = 4 * timeout; 2070 int loop_count = 4 * timeout;
2084 int status = FAILED; 2071 int status = FAILED;
2072 MPT_ADAPTER *ioc = hd->ioc;
2085 2073
2086 do { 2074 do {
2087 spin_lock_irqsave(&hd->ioc->FreeQlock, flags); 2075 spin_lock_irqsave(&ioc->FreeQlock, flags);
2088 if(hd->tmPending == 0) { 2076 if(hd->tmPending == 0) {
2089 status = SUCCESS; 2077 status = SUCCESS;
2090 spin_unlock_irqrestore(&hd->ioc->FreeQlock, flags); 2078 spin_unlock_irqrestore(&ioc->FreeQlock, flags);
2091 break; 2079 break;
2092 } 2080 }
2093 spin_unlock_irqrestore(&hd->ioc->FreeQlock, flags); 2081 spin_unlock_irqrestore(&ioc->FreeQlock, flags);
2094 msleep(250); 2082 msleep(250);
2095 } while (--loop_count); 2083 } while (--loop_count);
2096 2084
@@ -2172,7 +2160,7 @@ mptscsih_taskmgmt_complete(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *m
2172 return 1; 2160 return 1;
2173 } 2161 }
2174 2162
2175 hd = (MPT_SCSI_HOST *)ioc->sh->hostdata; 2163 hd = shost_priv(ioc->sh);
2176 pScsiTmReply = (SCSITaskMgmtReply_t*)mr; 2164 pScsiTmReply = (SCSITaskMgmtReply_t*)mr;
2177 pScsiTmReq = (SCSITaskMgmt_t*)mf; 2165 pScsiTmReq = (SCSITaskMgmt_t*)mf;
2178 tmType = pScsiTmReq->TaskType; 2166 tmType = pScsiTmReq->TaskType;
@@ -2223,7 +2211,7 @@ mptscsih_taskmgmt_complete(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *m
2223 if (iocstatus == MPI_IOCSTATUS_SCSI_TASK_MGMT_FAILED || 2211 if (iocstatus == MPI_IOCSTATUS_SCSI_TASK_MGMT_FAILED ||
2224 hd->cmdPtr) 2212 hd->cmdPtr)
2225 if (mpt_HardResetHandler(ioc, NO_SLEEP) < 0) 2213 if (mpt_HardResetHandler(ioc, NO_SLEEP) < 0)
2226 printk((KERN_WARNING " Firmware Reload FAILED!!\n")); 2214 printk(MYIOC_s_WARN_FMT " Firmware Reload FAILED!!\n", ioc->name);
2227 break; 2215 break;
2228 2216
2229 case MPI_SCSITASKMGMT_TASKTYPE_TARGET_RESET: 2217 case MPI_SCSITASKMGMT_TASKTYPE_TARGET_RESET:
@@ -2366,7 +2354,7 @@ void
2366mptscsih_slave_destroy(struct scsi_device *sdev) 2354mptscsih_slave_destroy(struct scsi_device *sdev)
2367{ 2355{
2368 struct Scsi_Host *host = sdev->host; 2356 struct Scsi_Host *host = sdev->host;
2369 MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *)host->hostdata; 2357 MPT_SCSI_HOST *hd = shost_priv(host);
2370 VirtTarget *vtarget; 2358 VirtTarget *vtarget;
2371 VirtDevice *vdevice; 2359 VirtDevice *vdevice;
2372 struct scsi_target *starget; 2360 struct scsi_target *starget;
@@ -2393,16 +2381,17 @@ mptscsih_slave_destroy(struct scsi_device *sdev)
2393int 2381int
2394mptscsih_change_queue_depth(struct scsi_device *sdev, int qdepth) 2382mptscsih_change_queue_depth(struct scsi_device *sdev, int qdepth)
2395{ 2383{
2396 MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *)sdev->host->hostdata; 2384 MPT_SCSI_HOST *hd = shost_priv(sdev->host);
2397 VirtTarget *vtarget; 2385 VirtTarget *vtarget;
2398 struct scsi_target *starget; 2386 struct scsi_target *starget;
2399 int max_depth; 2387 int max_depth;
2400 int tagged; 2388 int tagged;
2389 MPT_ADAPTER *ioc = hd->ioc;
2401 2390
2402 starget = scsi_target(sdev); 2391 starget = scsi_target(sdev);
2403 vtarget = starget->hostdata; 2392 vtarget = starget->hostdata;
2404 2393
2405 if (hd->ioc->bus_type == SPI) { 2394 if (ioc->bus_type == SPI) {
2406 if (!(vtarget->tflags & MPT_TARGET_FLAGS_Q_YES)) 2395 if (!(vtarget->tflags & MPT_TARGET_FLAGS_Q_YES))
2407 max_depth = 1; 2396 max_depth = 1;
2408 else if (sdev->type == TYPE_DISK && 2397 else if (sdev->type == TYPE_DISK &&
@@ -2437,19 +2426,20 @@ mptscsih_slave_configure(struct scsi_device *sdev)
2437 VirtTarget *vtarget; 2426 VirtTarget *vtarget;
2438 VirtDevice *vdevice; 2427 VirtDevice *vdevice;
2439 struct scsi_target *starget; 2428 struct scsi_target *starget;
2440 MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *)sh->hostdata; 2429 MPT_SCSI_HOST *hd = shost_priv(sh);
2430 MPT_ADAPTER *ioc = hd->ioc;
2441 2431
2442 starget = scsi_target(sdev); 2432 starget = scsi_target(sdev);
2443 vtarget = starget->hostdata; 2433 vtarget = starget->hostdata;
2444 vdevice = sdev->hostdata; 2434 vdevice = sdev->hostdata;
2445 2435
2446 dsprintk(hd->ioc, printk(MYIOC_s_DEBUG_FMT 2436 dsprintk(ioc, printk(MYIOC_s_DEBUG_FMT
2447 "device @ %p, channel=%d, id=%d, lun=%d\n", 2437 "device @ %p, channel=%d, id=%d, lun=%d\n",
2448 hd->ioc->name, sdev, sdev->channel, sdev->id, sdev->lun)); 2438 ioc->name, sdev, sdev->channel, sdev->id, sdev->lun));
2449 if (hd->ioc->bus_type == SPI) 2439 if (ioc->bus_type == SPI)
2450 dsprintk(hd->ioc, printk(MYIOC_s_DEBUG_FMT 2440 dsprintk(ioc, printk(MYIOC_s_DEBUG_FMT
2451 "sdtr %d wdtr %d ppr %d inq length=%d\n", 2441 "sdtr %d wdtr %d ppr %d inq length=%d\n",
2452 hd->ioc->name, sdev->sdtr, sdev->wdtr, 2442 ioc->name, sdev->sdtr, sdev->wdtr,
2453 sdev->ppr, sdev->inquiry_len)); 2443 sdev->ppr, sdev->inquiry_len));
2454 2444
2455 if (sdev->id > sh->max_id) { 2445 if (sdev->id > sh->max_id) {
@@ -2461,21 +2451,21 @@ mptscsih_slave_configure(struct scsi_device *sdev)
2461 vdevice->configured_lun = 1; 2451 vdevice->configured_lun = 1;
2462 mptscsih_change_queue_depth(sdev, MPT_SCSI_CMD_PER_DEV_HIGH); 2452 mptscsih_change_queue_depth(sdev, MPT_SCSI_CMD_PER_DEV_HIGH);
2463 2453
2464 dsprintk(hd->ioc, printk(MYIOC_s_DEBUG_FMT 2454 dsprintk(ioc, printk(MYIOC_s_DEBUG_FMT
2465 "Queue depth=%d, tflags=%x\n", 2455 "Queue depth=%d, tflags=%x\n",
2466 hd->ioc->name, sdev->queue_depth, vtarget->tflags)); 2456 ioc->name, sdev->queue_depth, vtarget->tflags));
2467 2457
2468 if (hd->ioc->bus_type == SPI) 2458 if (ioc->bus_type == SPI)
2469 dsprintk(hd->ioc, printk(MYIOC_s_DEBUG_FMT 2459 dsprintk(ioc, printk(MYIOC_s_DEBUG_FMT
2470 "negoFlags=%x, maxOffset=%x, SyncFactor=%x\n", 2460 "negoFlags=%x, maxOffset=%x, SyncFactor=%x\n",
2471 hd->ioc->name, vtarget->negoFlags, vtarget->maxOffset, 2461 ioc->name, vtarget->negoFlags, vtarget->maxOffset,
2472 vtarget->minSyncFactor)); 2462 vtarget->minSyncFactor));
2473 2463
2474slave_configure_exit: 2464slave_configure_exit:
2475 2465
2476 dsprintk(hd->ioc, printk(MYIOC_s_DEBUG_FMT 2466 dsprintk(ioc, printk(MYIOC_s_DEBUG_FMT
2477 "tagged %d, simple %d, ordered %d\n", 2467 "tagged %d, simple %d, ordered %d\n",
2478 hd->ioc->name,sdev->tagged_supported, sdev->simple_tags, 2468 ioc->name,sdev->tagged_supported, sdev->simple_tags,
2479 sdev->ordered_tags)); 2469 sdev->ordered_tags));
2480 2470
2481 return 0; 2471 return 0;
@@ -2494,14 +2484,15 @@ slave_configure_exit:
2494static void 2484static void
2495mptscsih_copy_sense_data(struct scsi_cmnd *sc, MPT_SCSI_HOST *hd, MPT_FRAME_HDR *mf, SCSIIOReply_t *pScsiReply) 2485mptscsih_copy_sense_data(struct scsi_cmnd *sc, MPT_SCSI_HOST *hd, MPT_FRAME_HDR *mf, SCSIIOReply_t *pScsiReply)
2496{ 2486{
2497 VirtDevice *vdev; 2487 VirtDevice *vdevice;
2498 SCSIIORequest_t *pReq; 2488 SCSIIORequest_t *pReq;
2499 u32 sense_count = le32_to_cpu(pScsiReply->SenseCount); 2489 u32 sense_count = le32_to_cpu(pScsiReply->SenseCount);
2490 MPT_ADAPTER *ioc = hd->ioc;
2500 2491
2501 /* Get target structure 2492 /* Get target structure
2502 */ 2493 */
2503 pReq = (SCSIIORequest_t *) mf; 2494 pReq = (SCSIIORequest_t *) mf;
2504 vdev = sc->device->hostdata; 2495 vdevice = sc->device->hostdata;
2505 2496
2506 if (sense_count) { 2497 if (sense_count) {
2507 u8 *sense_data; 2498 u8 *sense_data;
@@ -2509,15 +2500,14 @@ mptscsih_copy_sense_data(struct scsi_cmnd *sc, MPT_SCSI_HOST *hd, MPT_FRAME_HDR
2509 2500
2510 /* Copy the sense received into the scsi command block. */ 2501 /* Copy the sense received into the scsi command block. */
2511 req_index = le16_to_cpu(mf->u.frame.hwhdr.msgctxu.fld.req_idx); 2502 req_index = le16_to_cpu(mf->u.frame.hwhdr.msgctxu.fld.req_idx);
2512 sense_data = ((u8 *)hd->ioc->sense_buf_pool + (req_index * MPT_SENSE_BUFFER_ALLOC)); 2503 sense_data = ((u8 *)ioc->sense_buf_pool + (req_index * MPT_SENSE_BUFFER_ALLOC));
2513 memcpy(sc->sense_buffer, sense_data, SNS_LEN(sc)); 2504 memcpy(sc->sense_buffer, sense_data, SNS_LEN(sc));
2514 2505
2515 /* Log SMART data (asc = 0x5D, non-IM case only) if required. 2506 /* Log SMART data (asc = 0x5D, non-IM case only) if required.
2516 */ 2507 */
2517 if ((hd->ioc->events) && (hd->ioc->eventTypes & (1 << MPI_EVENT_SCSI_DEVICE_STATUS_CHANGE))) { 2508 if ((ioc->events) && (ioc->eventTypes & (1 << MPI_EVENT_SCSI_DEVICE_STATUS_CHANGE))) {
2518 if ((sense_data[12] == 0x5D) && (vdev->vtarget->raidVolume == 0)) { 2509 if ((sense_data[12] == 0x5D) && (vdevice->vtarget->raidVolume == 0)) {
2519 int idx; 2510 int idx;
2520 MPT_ADAPTER *ioc = hd->ioc;
2521 2511
2522 idx = ioc->eventContext % MPTCTL_EVENT_LOG_SIZE; 2512 idx = ioc->eventContext % MPTCTL_EVENT_LOG_SIZE;
2523 ioc->events[idx].event = MPI_EVENT_SCSI_DEVICE_STATUS_CHANGE; 2513 ioc->events[idx].event = MPI_EVENT_SCSI_DEVICE_STATUS_CHANGE;
@@ -2530,36 +2520,116 @@ mptscsih_copy_sense_data(struct scsi_cmnd *sc, MPT_SCSI_HOST *hd, MPT_FRAME_HDR
2530 ioc->events[idx].data[1] = (sense_data[13] << 8) | sense_data[12]; 2520 ioc->events[idx].data[1] = (sense_data[13] << 8) | sense_data[12];
2531 2521
2532 ioc->eventContext++; 2522 ioc->eventContext++;
2533 if (hd->ioc->pcidev->vendor == 2523 if (ioc->pcidev->vendor ==
2534 PCI_VENDOR_ID_IBM) { 2524 PCI_VENDOR_ID_IBM) {
2535 mptscsih_issue_sep_command(hd->ioc, 2525 mptscsih_issue_sep_command(ioc,
2536 vdev->vtarget, MPI_SEP_REQ_SLOTSTATUS_PREDICTED_FAULT); 2526 vdevice->vtarget, MPI_SEP_REQ_SLOTSTATUS_PREDICTED_FAULT);
2537 vdev->vtarget->tflags |= 2527 vdevice->vtarget->tflags |=
2538 MPT_TARGET_FLAGS_LED_ON; 2528 MPT_TARGET_FLAGS_LED_ON;
2539 } 2529 }
2540 } 2530 }
2541 } 2531 }
2542 } else { 2532 } else {
2543 dprintk(hd->ioc, printk(MYIOC_s_DEBUG_FMT "Hmmm... SenseData len=0! (?)\n", 2533 dprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Hmmm... SenseData len=0! (?)\n",
2544 hd->ioc->name)); 2534 ioc->name));
2545 } 2535 }
2546} 2536}
2547 2537
2548static int 2538/**
2549SCPNT_TO_LOOKUP_IDX(struct scsi_cmnd *sc) 2539 * mptscsih_get_scsi_lookup
2540 *
2541 * retrieves scmd entry from ScsiLookup[] array list
2542 *
2543 * @ioc: Pointer to MPT_ADAPTER structure
2544 * @i: index into the array
2545 *
2546 * Returns the scsi_cmd pointer
2547 *
2548 **/
2549static struct scsi_cmnd *
2550mptscsih_get_scsi_lookup(MPT_ADAPTER *ioc, int i)
2550{ 2551{
2551 MPT_SCSI_HOST *hd; 2552 unsigned long flags;
2552 int i; 2553 struct scsi_cmnd *scmd;
2553 2554
2554 hd = (MPT_SCSI_HOST *) sc->device->host->hostdata; 2555 spin_lock_irqsave(&ioc->scsi_lookup_lock, flags);
2556 scmd = ioc->ScsiLookup[i];
2557 spin_unlock_irqrestore(&ioc->scsi_lookup_lock, flags);
2558
2559 return scmd;
2560}
2561
2562/**
2563 * mptscsih_getclear_scsi_lookup
2564 *
2565 * retrieves and clears scmd entry from ScsiLookup[] array list
2566 *
2567 * @ioc: Pointer to MPT_ADAPTER structure
2568 * @i: index into the array
2569 *
2570 * Returns the scsi_cmd pointer
2571 *
2572 **/
2573static struct scsi_cmnd *
2574mptscsih_getclear_scsi_lookup(MPT_ADAPTER *ioc, int i)
2575{
2576 unsigned long flags;
2577 struct scsi_cmnd *scmd;
2578
2579 spin_lock_irqsave(&ioc->scsi_lookup_lock, flags);
2580 scmd = ioc->ScsiLookup[i];
2581 ioc->ScsiLookup[i] = NULL;
2582 spin_unlock_irqrestore(&ioc->scsi_lookup_lock, flags);
2583
2584 return scmd;
2585}
2555 2586
2556 for (i = 0; i < hd->ioc->req_depth; i++) { 2587/**
2557 if (hd->ScsiLookup[i] == sc) { 2588 * mptscsih_set_scsi_lookup
2558 return i; 2589 *
2590 * writes a scmd entry into the ScsiLookup[] array list
2591 *
2592 * @ioc: Pointer to MPT_ADAPTER structure
2593 * @i: index into the array
2594 * @scmd: scsi_cmnd pointer
2595 *
2596 **/
2597static void
2598mptscsih_set_scsi_lookup(MPT_ADAPTER *ioc, int i, struct scsi_cmnd *scmd)
2599{
2600 unsigned long flags;
2601
2602 spin_lock_irqsave(&ioc->scsi_lookup_lock, flags);
2603 ioc->ScsiLookup[i] = scmd;
2604 spin_unlock_irqrestore(&ioc->scsi_lookup_lock, flags);
2605}
2606
2607/**
2608 * SCPNT_TO_LOOKUP_IDX
2609 *
2610 * search's for a given scmd in the ScsiLookup[] array list
2611 *
2612 * @ioc: Pointer to MPT_ADAPTER structure
2613 * @scmd: scsi_cmnd pointer
2614 *
2615 **/
2616static int
2617SCPNT_TO_LOOKUP_IDX(MPT_ADAPTER *ioc, struct scsi_cmnd *sc)
2618{
2619 unsigned long flags;
2620 int i, index=-1;
2621
2622 spin_lock_irqsave(&ioc->scsi_lookup_lock, flags);
2623 for (i = 0; i < ioc->req_depth; i++) {
2624 if (ioc->ScsiLookup[i] == sc) {
2625 index = i;
2626 goto out;
2559 } 2627 }
2560 } 2628 }
2561 2629
2562 return -1; 2630 out:
2631 spin_unlock_irqrestore(&ioc->scsi_lookup_lock, flags);
2632 return index;
2563} 2633}
2564 2634
2565/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 2635/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
@@ -2568,21 +2638,20 @@ mptscsih_ioc_reset(MPT_ADAPTER *ioc, int reset_phase)
2568{ 2638{
2569 MPT_SCSI_HOST *hd; 2639 MPT_SCSI_HOST *hd;
2570 unsigned long flags; 2640 unsigned long flags;
2571 int ii;
2572 2641
2573 dtmprintk(ioc, printk(KERN_DEBUG MYNAM 2642 dtmprintk(ioc, printk(MYIOC_s_DEBUG_FMT
2574 ": IOC %s_reset routed to SCSI host driver!\n", 2643 ": IOC %s_reset routed to SCSI host driver!\n",
2575 reset_phase==MPT_IOC_SETUP_RESET ? "setup" : ( 2644 ioc->name, reset_phase==MPT_IOC_SETUP_RESET ? "setup" : (
2576 reset_phase==MPT_IOC_PRE_RESET ? "pre" : "post"))); 2645 reset_phase==MPT_IOC_PRE_RESET ? "pre" : "post")));
2577 2646
2578 /* If a FW reload request arrives after base installed but 2647 /* If a FW reload request arrives after base installed but
2579 * before all scsi hosts have been attached, then an alt_ioc 2648 * before all scsi hosts have been attached, then an alt_ioc
2580 * may have a NULL sh pointer. 2649 * may have a NULL sh pointer.
2581 */ 2650 */
2582 if ((ioc->sh == NULL) || (ioc->sh->hostdata == NULL)) 2651 if (ioc->sh == NULL || shost_priv(ioc->sh) == NULL)
2583 return 0; 2652 return 0;
2584 else 2653 else
2585 hd = (MPT_SCSI_HOST *) ioc->sh->hostdata; 2654 hd = shost_priv(ioc->sh);
2586 2655
2587 if (reset_phase == MPT_IOC_SETUP_RESET) { 2656 if (reset_phase == MPT_IOC_SETUP_RESET) {
2588 dtmprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Setup-Diag Reset\n", ioc->name)); 2657 dtmprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Setup-Diag Reset\n", ioc->name));
@@ -2624,11 +2693,6 @@ mptscsih_ioc_reset(MPT_ADAPTER *ioc, int reset_phase)
2624 * Init all control structures. 2693 * Init all control structures.
2625 */ 2694 */
2626 2695
2627 /* ScsiLookup initialization
2628 */
2629 for (ii=0; ii < hd->ioc->req_depth; ii++)
2630 hd->ScsiLookup[ii] = NULL;
2631
2632 /* 2. Chain Buffer initialization 2696 /* 2. Chain Buffer initialization
2633 */ 2697 */
2634 2698
@@ -2675,7 +2739,7 @@ mptscsih_event_process(MPT_ADAPTER *ioc, EventNotificationReply_t *pEvReply)
2675 ioc->name, event)); 2739 ioc->name, event));
2676 2740
2677 if (ioc->sh == NULL || 2741 if (ioc->sh == NULL ||
2678 ((hd = (MPT_SCSI_HOST *)ioc->sh->hostdata) == NULL)) 2742 ((hd = shost_priv(ioc->sh)) == NULL))
2679 return 1; 2743 return 1;
2680 2744
2681 switch (event) { 2745 switch (event) {
@@ -2713,7 +2777,8 @@ mptscsih_event_process(MPT_ADAPTER *ioc, EventNotificationReply_t *pEvReply)
2713 case MPI_EVENT_STATE_CHANGE: /* 02 */ 2777 case MPI_EVENT_STATE_CHANGE: /* 02 */
2714 case MPI_EVENT_EVENT_CHANGE: /* 0A */ 2778 case MPI_EVENT_EVENT_CHANGE: /* 0A */
2715 default: 2779 default:
2716 dprintk(ioc, printk(KERN_DEBUG MYNAM ": Ignoring event (=%02Xh)\n", event)); 2780 dprintk(ioc, printk(MYIOC_s_DEBUG_FMT ": Ignoring event (=%02Xh)\n",
2781 ioc->name, event));
2717 break; 2782 break;
2718 } 2783 }
2719 2784
@@ -2753,7 +2818,7 @@ mptscsih_scandv_complete(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *mr)
2753 int completionCode; 2818 int completionCode;
2754 u16 req_idx; 2819 u16 req_idx;
2755 2820
2756 hd = (MPT_SCSI_HOST *) ioc->sh->hostdata; 2821 hd = shost_priv(ioc->sh);
2757 2822
2758 if ((mf == NULL) || 2823 if ((mf == NULL) ||
2759 (mf >= MPT_INDEX_2_MFPTR(ioc, ioc->req_depth))) { 2824 (mf >= MPT_INDEX_2_MFPTR(ioc, ioc->req_depth))) {
@@ -2765,17 +2830,17 @@ mptscsih_scandv_complete(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *mr)
2765 2830
2766 del_timer(&hd->timer); 2831 del_timer(&hd->timer);
2767 req_idx = le16_to_cpu(mf->u.frame.hwhdr.msgctxu.fld.req_idx); 2832 req_idx = le16_to_cpu(mf->u.frame.hwhdr.msgctxu.fld.req_idx);
2768 hd->ScsiLookup[req_idx] = NULL; 2833 mptscsih_set_scsi_lookup(ioc, req_idx, NULL);
2769 pReq = (SCSIIORequest_t *) mf; 2834 pReq = (SCSIIORequest_t *) mf;
2770 2835
2771 if (mf != hd->cmdPtr) { 2836 if (mf != hd->cmdPtr) {
2772 printk(MYIOC_s_WARN_FMT "ScanDvComplete (mf=%p, cmdPtr=%p, idx=%d)\n", 2837 printk(MYIOC_s_WARN_FMT "ScanDvComplete (mf=%p, cmdPtr=%p, idx=%d)\n",
2773 hd->ioc->name, (void *)mf, (void *) hd->cmdPtr, req_idx); 2838 ioc->name, (void *)mf, (void *) hd->cmdPtr, req_idx);
2774 } 2839 }
2775 hd->cmdPtr = NULL; 2840 hd->cmdPtr = NULL;
2776 2841
2777 ddvprintk(ioc, printk(MYIOC_s_DEBUG_FMT "ScanDvComplete (mf=%p,mr=%p,idx=%d)\n", 2842 ddvprintk(ioc, printk(MYIOC_s_DEBUG_FMT "ScanDvComplete (mf=%p,mr=%p,idx=%d)\n",
2778 hd->ioc->name, mf, mr, req_idx)); 2843 ioc->name, mf, mr, req_idx));
2779 2844
2780 hd->pLocal = &hd->localReply; 2845 hd->pLocal = &hd->localReply;
2781 hd->pLocal->scsiStatus = 0; 2846 hd->pLocal->scsiStatus = 0;
@@ -2839,15 +2904,15 @@ mptscsih_scandv_complete(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *mr)
2839 */ 2904 */
2840 completionCode = MPT_SCANDV_SENSE; 2905 completionCode = MPT_SCANDV_SENSE;
2841 hd->pLocal->scsiStatus = scsi_status; 2906 hd->pLocal->scsiStatus = scsi_status;
2842 sense_data = ((u8 *)hd->ioc->sense_buf_pool + 2907 sense_data = ((u8 *)ioc->sense_buf_pool +
2843 (req_idx * MPT_SENSE_BUFFER_ALLOC)); 2908 (req_idx * MPT_SENSE_BUFFER_ALLOC));
2844 2909
2845 sz = min_t(int, pReq->SenseBufferLength, 2910 sz = min_t(int, pReq->SenseBufferLength,
2846 SCSI_STD_SENSE_BYTES); 2911 SCSI_STD_SENSE_BYTES);
2847 memcpy(hd->pLocal->sense, sense_data, sz); 2912 memcpy(hd->pLocal->sense, sense_data, sz);
2848 2913
2849 ddvprintk(ioc, printk(KERN_DEBUG " Check Condition, sense ptr %p\n", 2914 ddvprintk(ioc, printk(MYIOC_s_DEBUG_FMT " Check Condition, sense ptr %p\n",
2850 sense_data)); 2915 ioc->name, sense_data));
2851 } else if (pReply->SCSIState & MPI_SCSI_STATE_AUTOSENSE_FAILED) { 2916 } else if (pReply->SCSIState & MPI_SCSI_STATE_AUTOSENSE_FAILED) {
2852 if (pReq->CDB[0] == INQUIRY) 2917 if (pReq->CDB[0] == INQUIRY)
2853 completionCode = MPT_SCANDV_ISSUE_SENSE; 2918 completionCode = MPT_SCANDV_ISSUE_SENSE;
@@ -2906,8 +2971,9 @@ void
2906mptscsih_timer_expired(unsigned long data) 2971mptscsih_timer_expired(unsigned long data)
2907{ 2972{
2908 MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *) data; 2973 MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *) data;
2974 MPT_ADAPTER *ioc = hd->ioc;
2909 2975
2910 ddvprintk(hd->ioc, printk(MYIOC_s_DEBUG_FMT "Timer Expired! Cmd %p\n", hd->ioc->name, hd->cmdPtr)); 2976 ddvprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Timer Expired! Cmd %p\n", ioc->name, hd->cmdPtr));
2911 2977
2912 if (hd->cmdPtr) { 2978 if (hd->cmdPtr) {
2913 MPIHeader_t *cmd = (MPIHeader_t *)hd->cmdPtr; 2979 MPIHeader_t *cmd = (MPIHeader_t *)hd->cmdPtr;
@@ -2921,13 +2987,13 @@ mptscsih_timer_expired(unsigned long data)
2921 */ 2987 */
2922 } else { 2988 } else {
2923 /* Perform a FW reload */ 2989 /* Perform a FW reload */
2924 if (mpt_HardResetHandler(hd->ioc, NO_SLEEP) < 0) { 2990 if (mpt_HardResetHandler(ioc, NO_SLEEP) < 0) {
2925 printk(MYIOC_s_WARN_FMT "Firmware Reload FAILED!\n", hd->ioc->name); 2991 printk(MYIOC_s_WARN_FMT "Firmware Reload FAILED!\n", ioc->name);
2926 } 2992 }
2927 } 2993 }
2928 } else { 2994 } else {
2929 /* This should NEVER happen */ 2995 /* This should NEVER happen */
2930 printk(MYIOC_s_WARN_FMT "Null cmdPtr!!!!\n", hd->ioc->name); 2996 printk(MYIOC_s_WARN_FMT "Null cmdPtr!!!!\n", ioc->name);
2931 } 2997 }
2932 2998
2933 /* No more processing. 2999 /* No more processing.
@@ -2935,7 +3001,7 @@ mptscsih_timer_expired(unsigned long data)
2935 * The FW will reply to all outstanding commands, callback will finish cleanup. 3001 * The FW will reply to all outstanding commands, callback will finish cleanup.
2936 * Hard reset clean-up will free all resources. 3002 * Hard reset clean-up will free all resources.
2937 */ 3003 */
2938 ddvprintk(hd->ioc, printk(MYIOC_s_DEBUG_FMT "Timer Expired Complete!\n", hd->ioc->name)); 3004 ddvprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Timer Expired Complete!\n", ioc->name));
2939 3005
2940 return; 3006 return;
2941} 3007}
@@ -2973,11 +3039,12 @@ mptscsih_do_cmd(MPT_SCSI_HOST *hd, INTERNAL_CMD *io)
2973 char cmdLen; 3039 char cmdLen;
2974 char CDB[]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; 3040 char CDB[]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
2975 char cmd = io->cmd; 3041 char cmd = io->cmd;
3042 MPT_ADAPTER *ioc = hd->ioc;
2976 3043
2977 in_isr = in_interrupt(); 3044 in_isr = in_interrupt();
2978 if (in_isr) { 3045 if (in_isr) {
2979 dprintk(hd->ioc, printk(MYIOC_s_DEBUG_FMT "Internal SCSI IO request not allowed in ISR context!\n", 3046 dprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Internal SCSI IO request not allowed in ISR context!\n",
2980 hd->ioc->name)); 3047 ioc->name));
2981 return -EPERM; 3048 return -EPERM;
2982 } 3049 }
2983 3050
@@ -3078,9 +3145,9 @@ mptscsih_do_cmd(MPT_SCSI_HOST *hd, INTERNAL_CMD *io)
3078 3145
3079 /* Get and Populate a free Frame 3146 /* Get and Populate a free Frame
3080 */ 3147 */
3081 if ((mf = mpt_get_msg_frame(hd->ioc->InternalCtx, hd->ioc)) == NULL) { 3148 if ((mf = mpt_get_msg_frame(ioc->InternalCtx, ioc)) == NULL) {
3082 ddvprintk(hd->ioc, printk(MYIOC_s_DEBUG_FMT "No msg frames!\n", 3149 dfailprintk(ioc, printk(MYIOC_s_WARN_FMT "No msg frames!\n",
3083 hd->ioc->name)); 3150 ioc->name));
3084 return -EBUSY; 3151 return -EBUSY;
3085 } 3152 }
3086 3153
@@ -3119,19 +3186,19 @@ mptscsih_do_cmd(MPT_SCSI_HOST *hd, INTERNAL_CMD *io)
3119 3186
3120 if (cmd == REQUEST_SENSE) { 3187 if (cmd == REQUEST_SENSE) {
3121 pScsiReq->Control = cpu_to_le32(dir | MPI_SCSIIO_CONTROL_UNTAGGED); 3188 pScsiReq->Control = cpu_to_le32(dir | MPI_SCSIIO_CONTROL_UNTAGGED);
3122 ddvprintk(hd->ioc, printk(MYIOC_s_DEBUG_FMT "Untagged! 0x%2x\n", 3189 ddvprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Untagged! 0x%2x\n",
3123 hd->ioc->name, cmd)); 3190 ioc->name, cmd));
3124 } 3191 }
3125 3192
3126 for (ii=0; ii < 16; ii++) 3193 for (ii=0; ii < 16; ii++)
3127 pScsiReq->CDB[ii] = CDB[ii]; 3194 pScsiReq->CDB[ii] = CDB[ii];
3128 3195
3129 pScsiReq->DataLength = cpu_to_le32(io->size); 3196 pScsiReq->DataLength = cpu_to_le32(io->size);
3130 pScsiReq->SenseBufferLowAddr = cpu_to_le32(hd->ioc->sense_buf_low_dma 3197 pScsiReq->SenseBufferLowAddr = cpu_to_le32(ioc->sense_buf_low_dma
3131 + (my_idx * MPT_SENSE_BUFFER_ALLOC)); 3198 + (my_idx * MPT_SENSE_BUFFER_ALLOC));
3132 3199
3133 ddvprintk(hd->ioc, printk(MYIOC_s_DEBUG_FMT "Sending Command 0x%x for (%d:%d:%d)\n", 3200 ddvprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Sending Command 0x%x for (%d:%d:%d)\n",
3134 hd->ioc->name, cmd, io->channel, io->id, io->lun)); 3201 ioc->name, cmd, io->channel, io->id, io->lun));
3135 3202
3136 if (dir == MPI_SCSIIO_CONTROL_READ) { 3203 if (dir == MPI_SCSIIO_CONTROL_READ) {
3137 mpt_add_sge((char *) &pScsiReq->SGL, 3204 mpt_add_sge((char *) &pScsiReq->SGL,
@@ -3166,7 +3233,7 @@ mptscsih_do_cmd(MPT_SCSI_HOST *hd, INTERNAL_CMD *io)
3166 hd->cmdPtr = mf; 3233 hd->cmdPtr = mf;
3167 3234
3168 add_timer(&hd->timer); 3235 add_timer(&hd->timer);
3169 mpt_put_msg_frame(hd->ioc->InternalCtx, hd->ioc, mf); 3236 mpt_put_msg_frame(ioc->InternalCtx, ioc, mf);
3170 wait_event(hd->scandv_waitq, hd->scandv_wait_done); 3237 wait_event(hd->scandv_waitq, hd->scandv_wait_done);
3171 3238
3172 if (hd->pLocal) { 3239 if (hd->pLocal) {
@@ -3182,8 +3249,8 @@ mptscsih_do_cmd(MPT_SCSI_HOST *hd, INTERNAL_CMD *io)
3182 } else { 3249 } else {
3183 rc = -EFAULT; 3250 rc = -EFAULT;
3184 /* This should never happen. */ 3251 /* This should never happen. */
3185 ddvprintk(hd->ioc, printk(MYIOC_s_DEBUG_FMT "_do_cmd: Null pLocal!!!\n", 3252 ddvprintk(ioc, printk(MYIOC_s_DEBUG_FMT "_do_cmd: Null pLocal!!!\n",
3186 hd->ioc->name)); 3253 ioc->name));
3187 } 3254 }
3188 3255
3189 return rc; 3256 return rc;
@@ -3235,7 +3302,7 @@ static ssize_t
3235mptscsih_version_fw_show(struct class_device *cdev, char *buf) 3302mptscsih_version_fw_show(struct class_device *cdev, char *buf)
3236{ 3303{
3237 struct Scsi_Host *host = class_to_shost(cdev); 3304 struct Scsi_Host *host = class_to_shost(cdev);
3238 MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *)host->hostdata; 3305 MPT_SCSI_HOST *hd = shost_priv(host);
3239 MPT_ADAPTER *ioc = hd->ioc; 3306 MPT_ADAPTER *ioc = hd->ioc;
3240 3307
3241 return snprintf(buf, PAGE_SIZE, "%02d.%02d.%02d.%02d\n", 3308 return snprintf(buf, PAGE_SIZE, "%02d.%02d.%02d.%02d\n",
@@ -3250,7 +3317,7 @@ static ssize_t
3250mptscsih_version_bios_show(struct class_device *cdev, char *buf) 3317mptscsih_version_bios_show(struct class_device *cdev, char *buf)
3251{ 3318{
3252 struct Scsi_Host *host = class_to_shost(cdev); 3319 struct Scsi_Host *host = class_to_shost(cdev);
3253 MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *)host->hostdata; 3320 MPT_SCSI_HOST *hd = shost_priv(host);
3254 MPT_ADAPTER *ioc = hd->ioc; 3321 MPT_ADAPTER *ioc = hd->ioc;
3255 3322
3256 return snprintf(buf, PAGE_SIZE, "%02x.%02x.%02x.%02x\n", 3323 return snprintf(buf, PAGE_SIZE, "%02x.%02x.%02x.%02x\n",
@@ -3265,7 +3332,7 @@ static ssize_t
3265mptscsih_version_mpi_show(struct class_device *cdev, char *buf) 3332mptscsih_version_mpi_show(struct class_device *cdev, char *buf)
3266{ 3333{
3267 struct Scsi_Host *host = class_to_shost(cdev); 3334 struct Scsi_Host *host = class_to_shost(cdev);
3268 MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *)host->hostdata; 3335 MPT_SCSI_HOST *hd = shost_priv(host);
3269 MPT_ADAPTER *ioc = hd->ioc; 3336 MPT_ADAPTER *ioc = hd->ioc;
3270 3337
3271 return snprintf(buf, PAGE_SIZE, "%03x\n", ioc->facts.MsgVersion); 3338 return snprintf(buf, PAGE_SIZE, "%03x\n", ioc->facts.MsgVersion);
@@ -3276,7 +3343,7 @@ static ssize_t
3276mptscsih_version_product_show(struct class_device *cdev, char *buf) 3343mptscsih_version_product_show(struct class_device *cdev, char *buf)
3277{ 3344{
3278 struct Scsi_Host *host = class_to_shost(cdev); 3345 struct Scsi_Host *host = class_to_shost(cdev);
3279 MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *)host->hostdata; 3346 MPT_SCSI_HOST *hd = shost_priv(host);
3280 MPT_ADAPTER *ioc = hd->ioc; 3347 MPT_ADAPTER *ioc = hd->ioc;
3281 3348
3282 return snprintf(buf, PAGE_SIZE, "%s\n", ioc->prod_name); 3349 return snprintf(buf, PAGE_SIZE, "%s\n", ioc->prod_name);
@@ -3288,7 +3355,7 @@ static ssize_t
3288mptscsih_version_nvdata_persistent_show(struct class_device *cdev, char *buf) 3355mptscsih_version_nvdata_persistent_show(struct class_device *cdev, char *buf)
3289{ 3356{
3290 struct Scsi_Host *host = class_to_shost(cdev); 3357 struct Scsi_Host *host = class_to_shost(cdev);
3291 MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *)host->hostdata; 3358 MPT_SCSI_HOST *hd = shost_priv(host);
3292 MPT_ADAPTER *ioc = hd->ioc; 3359 MPT_ADAPTER *ioc = hd->ioc;
3293 3360
3294 return snprintf(buf, PAGE_SIZE, "%02xh\n", 3361 return snprintf(buf, PAGE_SIZE, "%02xh\n",
@@ -3301,7 +3368,7 @@ static ssize_t
3301mptscsih_version_nvdata_default_show(struct class_device *cdev, char *buf) 3368mptscsih_version_nvdata_default_show(struct class_device *cdev, char *buf)
3302{ 3369{
3303 struct Scsi_Host *host = class_to_shost(cdev); 3370 struct Scsi_Host *host = class_to_shost(cdev);
3304 MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *)host->hostdata; 3371 MPT_SCSI_HOST *hd = shost_priv(host);
3305 MPT_ADAPTER *ioc = hd->ioc; 3372 MPT_ADAPTER *ioc = hd->ioc;
3306 3373
3307 return snprintf(buf, PAGE_SIZE, "%02xh\n",ioc->nvdata_version_default); 3374 return snprintf(buf, PAGE_SIZE, "%02xh\n",ioc->nvdata_version_default);
@@ -3313,7 +3380,7 @@ static ssize_t
3313mptscsih_board_name_show(struct class_device *cdev, char *buf) 3380mptscsih_board_name_show(struct class_device *cdev, char *buf)
3314{ 3381{
3315 struct Scsi_Host *host = class_to_shost(cdev); 3382 struct Scsi_Host *host = class_to_shost(cdev);
3316 MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *)host->hostdata; 3383 MPT_SCSI_HOST *hd = shost_priv(host);
3317 MPT_ADAPTER *ioc = hd->ioc; 3384 MPT_ADAPTER *ioc = hd->ioc;
3318 3385
3319 return snprintf(buf, PAGE_SIZE, "%s\n", ioc->board_name); 3386 return snprintf(buf, PAGE_SIZE, "%s\n", ioc->board_name);
@@ -3324,7 +3391,7 @@ static ssize_t
3324mptscsih_board_assembly_show(struct class_device *cdev, char *buf) 3391mptscsih_board_assembly_show(struct class_device *cdev, char *buf)
3325{ 3392{
3326 struct Scsi_Host *host = class_to_shost(cdev); 3393 struct Scsi_Host *host = class_to_shost(cdev);
3327 MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *)host->hostdata; 3394 MPT_SCSI_HOST *hd = shost_priv(host);
3328 MPT_ADAPTER *ioc = hd->ioc; 3395 MPT_ADAPTER *ioc = hd->ioc;
3329 3396
3330 return snprintf(buf, PAGE_SIZE, "%s\n", ioc->board_assembly); 3397 return snprintf(buf, PAGE_SIZE, "%s\n", ioc->board_assembly);
@@ -3336,7 +3403,7 @@ static ssize_t
3336mptscsih_board_tracer_show(struct class_device *cdev, char *buf) 3403mptscsih_board_tracer_show(struct class_device *cdev, char *buf)
3337{ 3404{
3338 struct Scsi_Host *host = class_to_shost(cdev); 3405 struct Scsi_Host *host = class_to_shost(cdev);
3339 MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *)host->hostdata; 3406 MPT_SCSI_HOST *hd = shost_priv(host);
3340 MPT_ADAPTER *ioc = hd->ioc; 3407 MPT_ADAPTER *ioc = hd->ioc;
3341 3408
3342 return snprintf(buf, PAGE_SIZE, "%s\n", ioc->board_tracer); 3409 return snprintf(buf, PAGE_SIZE, "%s\n", ioc->board_tracer);
@@ -3348,7 +3415,7 @@ static ssize_t
3348mptscsih_io_delay_show(struct class_device *cdev, char *buf) 3415mptscsih_io_delay_show(struct class_device *cdev, char *buf)
3349{ 3416{
3350 struct Scsi_Host *host = class_to_shost(cdev); 3417 struct Scsi_Host *host = class_to_shost(cdev);
3351 MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *)host->hostdata; 3418 MPT_SCSI_HOST *hd = shost_priv(host);
3352 MPT_ADAPTER *ioc = hd->ioc; 3419 MPT_ADAPTER *ioc = hd->ioc;
3353 3420
3354 return snprintf(buf, PAGE_SIZE, "%02d\n", ioc->io_missing_delay); 3421 return snprintf(buf, PAGE_SIZE, "%02d\n", ioc->io_missing_delay);
@@ -3360,7 +3427,7 @@ static ssize_t
3360mptscsih_device_delay_show(struct class_device *cdev, char *buf) 3427mptscsih_device_delay_show(struct class_device *cdev, char *buf)
3361{ 3428{
3362 struct Scsi_Host *host = class_to_shost(cdev); 3429 struct Scsi_Host *host = class_to_shost(cdev);
3363 MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *)host->hostdata; 3430 MPT_SCSI_HOST *hd = shost_priv(host);
3364 MPT_ADAPTER *ioc = hd->ioc; 3431 MPT_ADAPTER *ioc = hd->ioc;
3365 3432
3366 return snprintf(buf, PAGE_SIZE, "%02d\n", ioc->device_missing_delay); 3433 return snprintf(buf, PAGE_SIZE, "%02d\n", ioc->device_missing_delay);
@@ -3372,7 +3439,7 @@ static ssize_t
3372mptscsih_debug_level_show(struct class_device *cdev, char *buf) 3439mptscsih_debug_level_show(struct class_device *cdev, char *buf)
3373{ 3440{
3374 struct Scsi_Host *host = class_to_shost(cdev); 3441 struct Scsi_Host *host = class_to_shost(cdev);
3375 MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *)host->hostdata; 3442 MPT_SCSI_HOST *hd = shost_priv(host);
3376 MPT_ADAPTER *ioc = hd->ioc; 3443 MPT_ADAPTER *ioc = hd->ioc;
3377 3444
3378 return snprintf(buf, PAGE_SIZE, "%08xh\n", ioc->debug_level); 3445 return snprintf(buf, PAGE_SIZE, "%08xh\n", ioc->debug_level);
@@ -3382,7 +3449,7 @@ mptscsih_debug_level_store(struct class_device *cdev, const char *buf,
3382 size_t count) 3449 size_t count)
3383{ 3450{
3384 struct Scsi_Host *host = class_to_shost(cdev); 3451 struct Scsi_Host *host = class_to_shost(cdev);
3385 MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *)host->hostdata; 3452 MPT_SCSI_HOST *hd = shost_priv(host);
3386 MPT_ADAPTER *ioc = hd->ioc; 3453 MPT_ADAPTER *ioc = hd->ioc;
3387 int val = 0; 3454 int val = 0;
3388 3455