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.c775
1 files changed, 180 insertions, 595 deletions
diff --git a/drivers/message/fusion/mptscsih.c b/drivers/message/fusion/mptscsih.c
index 3a3ef127df04..c8492034cfe7 100644
--- a/drivers/message/fusion/mptscsih.c
+++ b/drivers/message/fusion/mptscsih.c
@@ -1,32 +1,11 @@
1/* 1/*
2 * linux/drivers/message/fusion/mptscsih.c 2 * linux/drivers/message/fusion/mptscsih.c
3 * High performance SCSI / Fibre Channel SCSI Host device driver. 3 * For use with LSI Logic PCI chip/adapter(s)
4 * For use with PCI chip/adapter(s):
5 * LSIFC9xx/LSI409xx Fibre Channel
6 * running LSI Logic Fusion MPT (Message Passing Technology) firmware. 4 * running LSI Logic Fusion MPT (Message Passing Technology) firmware.
7 * 5 *
8 * Credits: 6 * Copyright (c) 1999-2005 LSI Logic Corporation
9 * This driver would not exist if not for Alan Cox's development
10 * of the linux i2o driver.
11 *
12 * A special thanks to Pamela Delaney (LSI Logic) for tons of work
13 * and countless enhancements while adding support for the 1030
14 * chip family. Pam has been instrumental in the development of
15 * of the 2.xx.xx series fusion drivers, and her contributions are
16 * far too numerous to hope to list in one place.
17 *
18 * A huge debt of gratitude is owed to David S. Miller (DaveM)
19 * for fixing much of the stupid and broken stuff in the early
20 * driver while porting to sparc64 platform. THANK YOU!
21 *
22 * (see mptbase.c)
23 *
24 * Copyright (c) 1999-2004 LSI Logic Corporation
25 * Original author: Steven J. Ralston
26 * (mailto:sjralston1@netscape.net)
27 * (mailto:mpt_linux_developer@lsil.com) 7 * (mailto:mpt_linux_developer@lsil.com)
28 * 8 *
29 * $Id: mptscsih.c,v 1.104 2002/12/03 21:26:34 pdelaney Exp $
30 */ 9 */
31/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 10/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
32/* 11/*
@@ -96,27 +75,6 @@ MODULE_AUTHOR(MODULEAUTHOR);
96MODULE_DESCRIPTION(my_NAME); 75MODULE_DESCRIPTION(my_NAME);
97MODULE_LICENSE("GPL"); 76MODULE_LICENSE("GPL");
98 77
99/* Command line args */
100static int mpt_dv = MPTSCSIH_DOMAIN_VALIDATION;
101MODULE_PARM(mpt_dv, "i");
102MODULE_PARM_DESC(mpt_dv, " DV Algorithm: enhanced=1, basic=0 (default=MPTSCSIH_DOMAIN_VALIDATION=1)");
103
104static int mpt_width = MPTSCSIH_MAX_WIDTH;
105MODULE_PARM(mpt_width, "i");
106MODULE_PARM_DESC(mpt_width, " Max Bus Width: wide=1, narrow=0 (default=MPTSCSIH_MAX_WIDTH=1)");
107
108static int mpt_factor = MPTSCSIH_MIN_SYNC;
109MODULE_PARM(mpt_factor, "h");
110MODULE_PARM_DESC(mpt_factor, " Min Sync Factor (default=MPTSCSIH_MIN_SYNC=0x08)");
111
112static int mpt_saf_te = MPTSCSIH_SAF_TE;
113MODULE_PARM(mpt_saf_te, "i");
114MODULE_PARM_DESC(mpt_saf_te, " Force enabling SEP Processor: enable=1 (default=MPTSCSIH_SAF_TE=0)");
115
116static int mpt_pq_filter = 0;
117MODULE_PARM(mpt_pq_filter, "i");
118MODULE_PARM_DESC(mpt_pq_filter, " Enable peripheral qualifier filter: enable=1 (default=0)");
119
120/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 78/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
121 79
122typedef struct _BIG_SENSE_BUF { 80typedef struct _BIG_SENSE_BUF {
@@ -169,18 +127,17 @@ typedef struct _dv_parameters {
169 u16 pad1; 127 u16 pad1;
170} DVPARAMETERS; 128} DVPARAMETERS;
171 129
172
173/* 130/*
174 * Other private/forward protos... 131 * Other private/forward protos...
175 */ 132 */
176static int mptscsih_io_done(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *r); 133int mptscsih_io_done(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *r);
177static void mptscsih_report_queue_full(struct scsi_cmnd *sc, SCSIIOReply_t *pScsiReply, SCSIIORequest_t *pScsiReq); 134static void mptscsih_report_queue_full(struct scsi_cmnd *sc, SCSIIOReply_t *pScsiReply, SCSIIORequest_t *pScsiReq);
178static int mptscsih_taskmgmt_complete(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *r); 135int mptscsih_taskmgmt_complete(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *r);
179 136
180static int mptscsih_AddSGE(MPT_ADAPTER *ioc, struct scsi_cmnd *SCpnt, 137static int mptscsih_AddSGE(MPT_ADAPTER *ioc, struct scsi_cmnd *SCpnt,
181 SCSIIORequest_t *pReq, int req_idx); 138 SCSIIORequest_t *pReq, int req_idx);
182static void mptscsih_freeChainBuffers(MPT_ADAPTER *ioc, int req_idx); 139static void mptscsih_freeChainBuffers(MPT_ADAPTER *ioc, int req_idx);
183static void copy_sense_data(struct scsi_cmnd *sc, MPT_SCSI_HOST *hd, MPT_FRAME_HDR *mf, SCSIIOReply_t *pScsiReply); 140static void mptscsih_copy_sense_data(struct scsi_cmnd *sc, MPT_SCSI_HOST *hd, MPT_FRAME_HDR *mf, SCSIIOReply_t *pScsiReply);
184static int mptscsih_tm_pending_wait(MPT_SCSI_HOST * hd); 141static int mptscsih_tm_pending_wait(MPT_SCSI_HOST * hd);
185static int mptscsih_tm_wait_for_completion(MPT_SCSI_HOST * hd, ulong timeout ); 142static int mptscsih_tm_wait_for_completion(MPT_SCSI_HOST * hd, ulong timeout );
186static u32 SCPNT_TO_LOOKUP_IDX(struct scsi_cmnd *sc); 143static u32 SCPNT_TO_LOOKUP_IDX(struct scsi_cmnd *sc);
@@ -188,8 +145,8 @@ static u32 SCPNT_TO_LOOKUP_IDX(struct scsi_cmnd *sc);
188static int mptscsih_TMHandler(MPT_SCSI_HOST *hd, u8 type, u8 channel, u8 target, u8 lun, int ctx2abort, ulong timeout); 145static int mptscsih_TMHandler(MPT_SCSI_HOST *hd, u8 type, u8 channel, u8 target, u8 lun, int ctx2abort, ulong timeout);
189static int mptscsih_IssueTaskMgmt(MPT_SCSI_HOST *hd, u8 type, u8 channel, u8 target, u8 lun, int ctx2abort, ulong timeout); 146static int mptscsih_IssueTaskMgmt(MPT_SCSI_HOST *hd, u8 type, u8 channel, u8 target, u8 lun, int ctx2abort, ulong timeout);
190 147
191static int mptscsih_ioc_reset(MPT_ADAPTER *ioc, int post_reset); 148int mptscsih_ioc_reset(MPT_ADAPTER *ioc, int post_reset);
192static int mptscsih_event_process(MPT_ADAPTER *ioc, EventNotificationReply_t *pEvReply); 149int mptscsih_event_process(MPT_ADAPTER *ioc, EventNotificationReply_t *pEvReply);
193 150
194static void mptscsih_initTarget(MPT_SCSI_HOST *hd, int bus_id, int target_id, u8 lun, char *data, int dlen); 151static void mptscsih_initTarget(MPT_SCSI_HOST *hd, int bus_id, int target_id, u8 lun, char *data, int dlen);
195static void mptscsih_setTargetNegoParms(MPT_SCSI_HOST *hd, VirtDevice *target, char byte56); 152static void mptscsih_setTargetNegoParms(MPT_SCSI_HOST *hd, VirtDevice *target, char byte56);
@@ -198,8 +155,7 @@ static void mptscsih_setDevicePage1Flags (u8 width, u8 factor, u8 offset, int *r
198static void mptscsih_no_negotiate(MPT_SCSI_HOST *hd, int target_id); 155static void mptscsih_no_negotiate(MPT_SCSI_HOST *hd, int target_id);
199static int mptscsih_writeSDP1(MPT_SCSI_HOST *hd, int portnum, int target, int flags); 156static int mptscsih_writeSDP1(MPT_SCSI_HOST *hd, int portnum, int target, int flags);
200static int mptscsih_writeIOCPage4(MPT_SCSI_HOST *hd, int target_id, int bus); 157static int mptscsih_writeIOCPage4(MPT_SCSI_HOST *hd, int target_id, int bus);
201static int mptscsih_scandv_complete(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *r); 158int mptscsih_scandv_complete(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *r);
202static void mptscsih_timer_expired(unsigned long data);
203static int mptscsih_do_cmd(MPT_SCSI_HOST *hd, INTERNAL_CMD *iocmd); 159static int mptscsih_do_cmd(MPT_SCSI_HOST *hd, INTERNAL_CMD *iocmd);
204static int mptscsih_synchronize_cache(MPT_SCSI_HOST *hd, int portnum); 160static int mptscsih_synchronize_cache(MPT_SCSI_HOST *hd, int portnum);
205 161
@@ -212,29 +168,14 @@ static int mptscsih_doDv(MPT_SCSI_HOST *hd, int channel, int target);
212static void mptscsih_dv_parms(MPT_SCSI_HOST *hd, DVPARAMETERS *dv,void *pPage); 168static void mptscsih_dv_parms(MPT_SCSI_HOST *hd, DVPARAMETERS *dv,void *pPage);
213static void mptscsih_fillbuf(char *buffer, int size, int index, int width); 169static void mptscsih_fillbuf(char *buffer, int size, int index, int width);
214#endif 170#endif
215/* module entry point */
216static int __init mptscsih_init (void);
217static void __exit mptscsih_exit (void);
218 171
219static int mptscsih_probe (struct pci_dev *, const struct pci_device_id *); 172void mptscsih_remove(struct pci_dev *);
220static void mptscsih_remove(struct pci_dev *); 173void mptscsih_shutdown(struct device *);
221static void mptscsih_shutdown(struct device *);
222#ifdef CONFIG_PM 174#ifdef CONFIG_PM
223static int mptscsih_suspend(struct pci_dev *pdev, pm_message_t state); 175int mptscsih_suspend(struct pci_dev *pdev, pm_message_t state);
224static int mptscsih_resume(struct pci_dev *pdev); 176int mptscsih_resume(struct pci_dev *pdev);
225#endif 177#endif
226 178
227
228/*
229 * Private data...
230 */
231
232static int mpt_scsi_hosts = 0;
233
234static int ScsiDoneCtx = -1;
235static int ScsiTaskCtx = -1;
236static int ScsiScanDvCtx = -1; /* Used only for bus scan and dv */
237
238#define SNS_LEN(scp) sizeof((scp)->sense_buffer) 179#define SNS_LEN(scp) sizeof((scp)->sense_buffer)
239 180
240#ifdef MPTSCSIH_ENABLE_DOMAIN_VALIDATION 181#ifdef MPTSCSIH_ENABLE_DOMAIN_VALIDATION
@@ -244,20 +185,9 @@ static int ScsiScanDvCtx = -1; /* Used only for bus scan and dv */
244static DEFINE_SPINLOCK(dvtaskQ_lock); 185static DEFINE_SPINLOCK(dvtaskQ_lock);
245static int dvtaskQ_active = 0; 186static int dvtaskQ_active = 0;
246static int dvtaskQ_release = 0; 187static int dvtaskQ_release = 0;
247static struct work_struct mptscsih_dvTask; 188static struct work_struct dvTaskQ_task;
248#endif 189#endif
249 190
250/*
251 * Wait Queue setup
252 */
253static DECLARE_WAIT_QUEUE_HEAD (scandv_waitq);
254static int scandv_wait_done = 1;
255
256
257/* Driver command line structure
258 */
259static struct scsi_host_template driver_template;
260
261/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 191/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
262/** 192/**
263 * mptscsih_add_sge - Place a simple SGE at address pAddr. 193 * mptscsih_add_sge - Place a simple SGE at address pAddr.
@@ -619,7 +549,7 @@ nextSGEset:
619 * 549 *
620 * Returns 1 indicating alloc'd request frame ptr should be freed. 550 * Returns 1 indicating alloc'd request frame ptr should be freed.
621 */ 551 */
622static int 552int
623mptscsih_io_done(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *mr) 553mptscsih_io_done(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *mr)
624{ 554{
625 struct scsi_cmnd *sc; 555 struct scsi_cmnd *sc;
@@ -677,8 +607,8 @@ mptscsih_io_done(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *mr)
677 sc->request_bufflen, xfer_cnt)); 607 sc->request_bufflen, xfer_cnt));
678 608
679 if (scsi_state & MPI_SCSI_STATE_AUTOSENSE_VALID) 609 if (scsi_state & MPI_SCSI_STATE_AUTOSENSE_VALID)
680 copy_sense_data(sc, hd, mf, pScsiReply); 610 mptscsih_copy_sense_data(sc, hd, mf, pScsiReply);
681 611
682 /* 612 /*
683 * Look for + dump FCP ResponseInfo[]! 613 * Look for + dump FCP ResponseInfo[]!
684 */ 614 */
@@ -740,7 +670,7 @@ mptscsih_io_done(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *mr)
740 } 670 }
741 dreplyprintk((KERN_NOTICE "RESIDUAL_MISMATCH: result=%x on id=%d\n", sc->result, sc->target)); 671 dreplyprintk((KERN_NOTICE "RESIDUAL_MISMATCH: result=%x on id=%d\n", sc->result, sc->target));
742 break; 672 break;
743 673
744 case MPI_IOCSTATUS_SCSI_DATA_UNDERRUN: /* 0x0045 */ 674 case MPI_IOCSTATUS_SCSI_DATA_UNDERRUN: /* 0x0045 */
745 /* 675 /*
746 * Do upfront check for valid SenseData and give it 676 * Do upfront check for valid SenseData and give it
@@ -773,7 +703,7 @@ mptscsih_io_done(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *mr)
773 */ 703 */
774 if (scsi_status == MPI_SCSI_STATUS_TASK_SET_FULL) 704 if (scsi_status == MPI_SCSI_STATUS_TASK_SET_FULL)
775 mptscsih_report_queue_full(sc, pScsiReply, pScsiReq); 705 mptscsih_report_queue_full(sc, pScsiReply, pScsiReq);
776 706
777 break; 707 break;
778 708
779 case MPI_IOCSTATUS_SCSI_RECOVERED_ERROR: /* 0x0040 */ 709 case MPI_IOCSTATUS_SCSI_RECOVERED_ERROR: /* 0x0040 */
@@ -905,18 +835,16 @@ mptscsih_flush_running_cmds(MPT_SCSI_HOST *hd)
905 * Do OS callback 835 * Do OS callback
906 * Free driver resources (chain, msg buffers) 836 * Free driver resources (chain, msg buffers)
907 */ 837 */
908 if (scsi_device_online(SCpnt->device)) { 838 if (SCpnt->use_sg) {
909 if (SCpnt->use_sg) { 839 pci_unmap_sg(ioc->pcidev,
910 pci_unmap_sg(ioc->pcidev, 840 (struct scatterlist *) SCpnt->request_buffer,
911 (struct scatterlist *) SCpnt->request_buffer, 841 SCpnt->use_sg,
912 SCpnt->use_sg, 842 SCpnt->sc_data_direction);
913 SCpnt->sc_data_direction); 843 } else if (SCpnt->request_bufflen) {
914 } else if (SCpnt->request_bufflen) { 844 pci_unmap_single(ioc->pcidev,
915 pci_unmap_single(ioc->pcidev, 845 SCpnt->SCp.dma_handle,
916 SCpnt->SCp.dma_handle, 846 SCpnt->request_bufflen,
917 SCpnt->request_bufflen, 847 SCpnt->sc_data_direction);
918 SCpnt->sc_data_direction);
919 }
920 } 848 }
921 SCpnt->result = DID_RESET << 16; 849 SCpnt->result = DID_RESET << 16;
922 SCpnt->host_scribble = NULL; 850 SCpnt->host_scribble = NULL;
@@ -981,11 +909,6 @@ mptscsih_search_running_cmds(MPT_SCSI_HOST *hd, uint target, uint lun)
981} 909}
982 910
983/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 911/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
984/*
985 * Hack! It might be nice to report if a device is returning QUEUE_FULL
986 * but maybe not each and every time...
987 */
988static long last_queue_full = 0;
989 912
990/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 913/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
991/* 914/*
@@ -1003,280 +926,20 @@ static void
1003mptscsih_report_queue_full(struct scsi_cmnd *sc, SCSIIOReply_t *pScsiReply, SCSIIORequest_t *pScsiReq) 926mptscsih_report_queue_full(struct scsi_cmnd *sc, SCSIIOReply_t *pScsiReply, SCSIIORequest_t *pScsiReq)
1004{ 927{
1005 long time = jiffies; 928 long time = jiffies;
1006
1007 if (time - last_queue_full > 10 * HZ) {
1008 char *ioc_str = "ioc?";
1009
1010 if (sc->device && sc->device->host != NULL && sc->device->host->hostdata != NULL)
1011 ioc_str = ((MPT_SCSI_HOST *)sc->device->host->hostdata)->ioc->name;
1012 dprintk((MYIOC_s_WARN_FMT "Device (%d:%d:%d) reported QUEUE_FULL!\n",
1013 ioc_str, 0, sc->device->id, sc->device->lun));
1014 last_queue_full = time;
1015 }
1016}
1017
1018/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
1019static char *info_kbuf = NULL;
1020
1021/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
1022/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
1023/*
1024 * mptscsih_probe - Installs scsi devices per bus.
1025 * @pdev: Pointer to pci_dev structure
1026 *
1027 * Returns 0 for success, non-zero for failure.
1028 *
1029 */
1030
1031static int
1032mptscsih_probe(struct pci_dev *pdev, const struct pci_device_id *id)
1033{
1034 struct Scsi_Host *sh;
1035 MPT_SCSI_HOST *hd; 929 MPT_SCSI_HOST *hd;
1036 MPT_ADAPTER *ioc = pci_get_drvdata(pdev);
1037 unsigned long flags;
1038 int sz, ii;
1039 int numSGE = 0;
1040 int scale;
1041 int ioc_cap;
1042 u8 *mem;
1043 int error=0;
1044
1045
1046 /* 20010202 -sralston
1047 * Added sanity check on readiness of the MPT adapter.
1048 */
1049 if (ioc->last_state != MPI_IOC_STATE_OPERATIONAL) {
1050 printk(MYIOC_s_WARN_FMT
1051 "Skipping because it's not operational!\n",
1052 ioc->name);
1053 return -ENODEV;
1054 }
1055
1056 if (!ioc->active) {
1057 printk(MYIOC_s_WARN_FMT "Skipping because it's disabled!\n",
1058 ioc->name);
1059 return -ENODEV;
1060 }
1061 930
1062 /* Sanity check - ensure at least 1 port is INITIATOR capable 931 if (sc->device == NULL)
1063 */ 932 return;
1064 ioc_cap = 0; 933 if (sc->device->host == NULL)
1065 for (ii=0; ii < ioc->facts.NumberOfPorts; ii++) { 934 return;
1066 if (ioc->pfacts[ii].ProtocolFlags & 935 if ((hd = (MPT_SCSI_HOST *)sc->device->host->hostdata) == NULL)
1067 MPI_PORTFACTS_PROTOCOL_INITIATOR) 936 return;
1068 ioc_cap ++;
1069 }
1070
1071 if (!ioc_cap) {
1072 printk(MYIOC_s_WARN_FMT
1073 "Skipping ioc=%p because SCSI Initiator mode is NOT enabled!\n",
1074 ioc->name, ioc);
1075 return -ENODEV;
1076 }
1077
1078 sh = scsi_host_alloc(&driver_template, sizeof(MPT_SCSI_HOST));
1079
1080 if (!sh) {
1081 printk(MYIOC_s_WARN_FMT
1082 "Unable to register controller with SCSI subsystem\n",
1083 ioc->name);
1084 return -1;
1085 }
1086
1087 spin_lock_irqsave(&ioc->FreeQlock, flags);
1088
1089 /* Attach the SCSI Host to the IOC structure
1090 */
1091 ioc->sh = sh;
1092
1093 sh->io_port = 0;
1094 sh->n_io_port = 0;
1095 sh->irq = 0;
1096
1097 /* set 16 byte cdb's */
1098 sh->max_cmd_len = 16;
1099
1100 /* Yikes! This is important!
1101 * Otherwise, by default, linux
1102 * only scans target IDs 0-7!
1103 * pfactsN->MaxDevices unreliable
1104 * (not supported in early
1105 * versions of the FW).
1106 * max_id = 1 + actual max id,
1107 * max_lun = 1 + actual last lun,
1108 * see hosts.h :o(
1109 */
1110 if (ioc->bus_type == SCSI) {
1111 sh->max_id = MPT_MAX_SCSI_DEVICES;
1112 } else {
1113 /* For FC, increase the queue depth
1114 * from MPT_SCSI_CAN_QUEUE (31)
1115 * to MPT_FC_CAN_QUEUE (63).
1116 */
1117 sh->can_queue = MPT_FC_CAN_QUEUE;
1118 sh->max_id =
1119 MPT_MAX_FC_DEVICES<256 ? MPT_MAX_FC_DEVICES : 255;
1120 }
1121
1122 sh->max_lun = MPT_LAST_LUN + 1;
1123 sh->max_channel = 0;
1124 sh->this_id = ioc->pfacts[0].PortSCSIID;
1125
1126 /* Required entry.
1127 */
1128 sh->unique_id = ioc->id;
1129
1130 /* Verify that we won't exceed the maximum
1131 * number of chain buffers
1132 * We can optimize: ZZ = req_sz/sizeof(SGE)
1133 * For 32bit SGE's:
1134 * numSGE = 1 + (ZZ-1)*(maxChain -1) + ZZ
1135 * + (req_sz - 64)/sizeof(SGE)
1136 * A slightly different algorithm is required for
1137 * 64bit SGEs.
1138 */
1139 scale = ioc->req_sz/(sizeof(dma_addr_t) + sizeof(u32));
1140 if (sizeof(dma_addr_t) == sizeof(u64)) {
1141 numSGE = (scale - 1) *
1142 (ioc->facts.MaxChainDepth-1) + scale +
1143 (ioc->req_sz - 60) / (sizeof(dma_addr_t) +
1144 sizeof(u32));
1145 } else {
1146 numSGE = 1 + (scale - 1) *
1147 (ioc->facts.MaxChainDepth-1) + scale +
1148 (ioc->req_sz - 64) / (sizeof(dma_addr_t) +
1149 sizeof(u32));
1150 }
1151
1152 if (numSGE < sh->sg_tablesize) {
1153 /* Reset this value */
1154 dprintk((MYIOC_s_INFO_FMT
1155 "Resetting sg_tablesize to %d from %d\n",
1156 ioc->name, numSGE, sh->sg_tablesize));
1157 sh->sg_tablesize = numSGE;
1158 }
1159
1160 /* Set the pci device pointer in Scsi_Host structure.
1161 */
1162 scsi_set_device(sh, &ioc->pcidev->dev);
1163
1164 spin_unlock_irqrestore(&ioc->FreeQlock, flags);
1165
1166 hd = (MPT_SCSI_HOST *) sh->hostdata;
1167 hd->ioc = ioc;
1168
1169 /* SCSI needs scsi_cmnd lookup table!
1170 * (with size equal to req_depth*PtrSz!)
1171 */
1172 sz = ioc->req_depth * sizeof(void *);
1173 mem = kmalloc(sz, GFP_ATOMIC);
1174 if (mem == NULL) {
1175 error = -ENOMEM;
1176 goto mptscsih_probe_failed;
1177 }
1178
1179 memset(mem, 0, sz);
1180 hd->ScsiLookup = (struct scsi_cmnd **) mem;
1181
1182 dprintk((MYIOC_s_INFO_FMT "ScsiLookup @ %p, sz=%d\n",
1183 ioc->name, hd->ScsiLookup, sz));
1184
1185 /* Allocate memory for the device structures.
1186 * A non-Null pointer at an offset
1187 * indicates a device exists.
1188 * max_id = 1 + maximum id (hosts.h)
1189 */
1190 sz = sh->max_id * sizeof(void *);
1191 mem = kmalloc(sz, GFP_ATOMIC);
1192 if (mem == NULL) {
1193 error = -ENOMEM;
1194 goto mptscsih_probe_failed;
1195 }
1196
1197 memset(mem, 0, sz);
1198 hd->Targets = (VirtDevice **) mem;
1199
1200 dprintk((KERN_INFO
1201 " Targets @ %p, sz=%d\n", hd->Targets, sz));
1202
1203 /* Clear the TM flags
1204 */
1205 hd->tmPending = 0;
1206 hd->tmState = TM_STATE_NONE;
1207 hd->resetPending = 0;
1208 hd->abortSCpnt = NULL;
1209
1210 /* Clear the pointer used to store
1211 * single-threaded commands, i.e., those
1212 * issued during a bus scan, dv and
1213 * configuration pages.
1214 */
1215 hd->cmdPtr = NULL;
1216
1217 /* Initialize this SCSI Hosts' timers
1218 * To use, set the timer expires field
1219 * and add_timer
1220 */
1221 init_timer(&hd->timer);
1222 hd->timer.data = (unsigned long) hd;
1223 hd->timer.function = mptscsih_timer_expired;
1224
1225 if (ioc->bus_type == SCSI) {
1226 /* Update with the driver setup
1227 * values.
1228 */
1229 if (ioc->spi_data.maxBusWidth > mpt_width)
1230 ioc->spi_data.maxBusWidth = mpt_width;
1231 if (ioc->spi_data.minSyncFactor < mpt_factor)
1232 ioc->spi_data.minSyncFactor = mpt_factor;
1233
1234 if (ioc->spi_data.minSyncFactor == MPT_ASYNC) {
1235 ioc->spi_data.maxSyncOffset = 0;
1236 }
1237
1238 ioc->spi_data.Saf_Te = mpt_saf_te;
1239
1240 hd->negoNvram = 0;
1241#ifndef MPTSCSIH_ENABLE_DOMAIN_VALIDATION
1242 hd->negoNvram = MPT_SCSICFG_USE_NVRAM;
1243#endif
1244 ioc->spi_data.forceDv = 0;
1245 ioc->spi_data.noQas = 0;
1246 for (ii=0; ii < MPT_MAX_SCSI_DEVICES; ii++) {
1247 ioc->spi_data.dvStatus[ii] =
1248 MPT_SCSICFG_NEGOTIATE;
1249 }
1250
1251 for (ii=0; ii < MPT_MAX_SCSI_DEVICES; ii++)
1252 ioc->spi_data.dvStatus[ii] |=
1253 MPT_SCSICFG_DV_NOT_DONE;
1254
1255 dinitprintk((MYIOC_s_INFO_FMT
1256 "dv %x width %x factor %x saf_te %x\n",
1257 ioc->name, mpt_dv,
1258 mpt_width,
1259 mpt_factor,
1260 mpt_saf_te));
1261 }
1262
1263 mpt_scsi_hosts++;
1264 937
1265 error = scsi_add_host (sh, &ioc->pcidev->dev); 938 if (time - hd->last_queue_full > 10 * HZ) {
1266 if(error) { 939 dprintk((MYIOC_s_WARN_FMT "Device (%d:%d:%d) reported QUEUE_FULL!\n",
1267 dprintk((KERN_ERR MYNAM 940 hd->ioc->name, 0, sc->device->id, sc->device->lun));
1268 "scsi_add_host failed\n")); 941 hd->last_queue_full = time;
1269 goto mptscsih_probe_failed;
1270 } 942 }
1271
1272 scsi_scan_host(sh);
1273 return 0;
1274
1275mptscsih_probe_failed:
1276
1277 mptscsih_remove(pdev);
1278 return error;
1279
1280} 943}
1281 944
1282/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 945/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
@@ -1286,7 +949,7 @@ mptscsih_probe_failed:
1286 * 949 *
1287 * 950 *
1288 */ 951 */
1289static void 952void
1290mptscsih_remove(struct pci_dev *pdev) 953mptscsih_remove(struct pci_dev *pdev)
1291{ 954{
1292 MPT_ADAPTER *ioc = pci_get_drvdata(pdev); 955 MPT_ADAPTER *ioc = pci_get_drvdata(pdev);
@@ -1294,12 +957,16 @@ mptscsih_remove(struct pci_dev *pdev)
1294 MPT_SCSI_HOST *hd; 957 MPT_SCSI_HOST *hd;
1295 int count; 958 int count;
1296 unsigned long flags; 959 unsigned long flags;
960 int sz1;
1297 961
1298 if(!host) 962 if(!host)
1299 return; 963 return;
1300 964
1301 scsi_remove_host(host); 965 scsi_remove_host(host);
1302 966
967 if((hd = (MPT_SCSI_HOST *)host->hostdata) == NULL)
968 return;
969
1303#ifdef MPTSCSIH_ENABLE_DOMAIN_VALIDATION 970#ifdef MPTSCSIH_ENABLE_DOMAIN_VALIDATION
1304 /* Check DV thread active */ 971 /* Check DV thread active */
1305 count = 10 * HZ; 972 count = 10 * HZ;
@@ -1321,40 +988,36 @@ mptscsih_remove(struct pci_dev *pdev)
1321#endif 988#endif
1322#endif 989#endif
1323 990
1324 hd = (MPT_SCSI_HOST *)host->hostdata; 991 mptscsih_shutdown(&pdev->dev);
1325 if (hd != NULL) {
1326 int sz1;
1327 992
1328 mptscsih_shutdown(&pdev->dev); 993 sz1=0;
1329 994
1330 sz1=0; 995 if (hd->ScsiLookup != NULL) {
996 sz1 = hd->ioc->req_depth * sizeof(void *);
997 kfree(hd->ScsiLookup);
998 hd->ScsiLookup = NULL;
999 }
1331 1000
1332 if (hd->ScsiLookup != NULL) { 1001 /*
1333 sz1 = hd->ioc->req_depth * sizeof(void *); 1002 * Free pointer array.
1334 kfree(hd->ScsiLookup); 1003 */
1335 hd->ScsiLookup = NULL; 1004 kfree(hd->Targets);
1336 } 1005 hd->Targets = NULL;
1337 1006
1338 if (hd->Targets != NULL) { 1007 dprintk((MYIOC_s_INFO_FMT
1339 /* 1008 "Free'd ScsiLookup (%d) memory\n",
1340 * Free pointer array. 1009 hd->ioc->name, sz1));
1341 */
1342 kfree(hd->Targets);
1343 hd->Targets = NULL;
1344 }
1345 1010
1346 dprintk((MYIOC_s_INFO_FMT 1011 kfree(hd->info_kbuf);
1347 "Free'd ScsiLookup (%d) memory\n",
1348 hd->ioc->name, sz1));
1349 1012
1350 /* NULL the Scsi_Host pointer 1013 /* NULL the Scsi_Host pointer
1351 */ 1014 */
1352 hd->ioc->sh = NULL; 1015 hd->ioc->sh = NULL;
1353 }
1354 1016
1355 scsi_host_put(host); 1017 scsi_host_put(host);
1356 mpt_scsi_hosts--;
1357 1018
1019 mpt_detach(pdev);
1020
1358} 1021}
1359 1022
1360/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 1023/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
@@ -1362,7 +1025,7 @@ mptscsih_remove(struct pci_dev *pdev)
1362 * mptscsih_shutdown - reboot notifier 1025 * mptscsih_shutdown - reboot notifier
1363 * 1026 *
1364 */ 1027 */
1365static void 1028void
1366mptscsih_shutdown(struct device * dev) 1029mptscsih_shutdown(struct device * dev)
1367{ 1030{
1368 MPT_ADAPTER *ioc = pci_get_drvdata(to_pci_dev(dev)); 1031 MPT_ADAPTER *ioc = pci_get_drvdata(to_pci_dev(dev));
@@ -1384,15 +1047,15 @@ mptscsih_shutdown(struct device * dev)
1384#ifdef CONFIG_PM 1047#ifdef CONFIG_PM
1385/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 1048/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
1386/* 1049/*
1387 * mptscsih_suspend - Fusion MPT scsie driver suspend routine. 1050 * mptscsih_suspend - Fusion MPT scsi driver suspend routine.
1388 * 1051 *
1389 * 1052 *
1390 */ 1053 */
1391static int 1054int
1392mptscsih_suspend(struct pci_dev *pdev, pm_message_t state) 1055mptscsih_suspend(struct pci_dev *pdev, pm_message_t state)
1393{ 1056{
1394 mptscsih_shutdown(&pdev->dev); 1057 mptscsih_shutdown(&pdev->dev);
1395 return 0; 1058 return mpt_suspend(pdev,state);
1396} 1059}
1397 1060
1398/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 1061/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
@@ -1401,13 +1064,15 @@ mptscsih_suspend(struct pci_dev *pdev, pm_message_t state)
1401 * 1064 *
1402 * 1065 *
1403 */ 1066 */
1404static int 1067int
1405mptscsih_resume(struct pci_dev *pdev) 1068mptscsih_resume(struct pci_dev *pdev)
1406{ 1069{
1407 MPT_ADAPTER *ioc = pci_get_drvdata(pdev); 1070 MPT_ADAPTER *ioc = pci_get_drvdata(pdev);
1408 struct Scsi_Host *host = ioc->sh; 1071 struct Scsi_Host *host = ioc->sh;
1409 MPT_SCSI_HOST *hd; 1072 MPT_SCSI_HOST *hd;
1410 1073
1074 mpt_resume(pdev);
1075
1411 if(!host) 1076 if(!host)
1412 return 0; 1077 return 0;
1413 1078
@@ -1422,9 +1087,9 @@ mptscsih_resume(struct pci_dev *pdev)
1422 if (!dvtaskQ_active) { 1087 if (!dvtaskQ_active) {
1423 dvtaskQ_active = 1; 1088 dvtaskQ_active = 1;
1424 spin_unlock_irqrestore(&dvtaskQ_lock, lflags); 1089 spin_unlock_irqrestore(&dvtaskQ_lock, lflags);
1425 INIT_WORK(&mptscsih_dvTask, 1090 INIT_WORK(&dvTaskQ_task,
1426 mptscsih_domainValidation, (void *) hd); 1091 mptscsih_domainValidation, (void *) hd);
1427 schedule_work(&mptscsih_dvTask); 1092 schedule_work(&dvTaskQ_task);
1428 } else { 1093 } else {
1429 spin_unlock_irqrestore(&dvtaskQ_lock, lflags); 1094 spin_unlock_irqrestore(&dvtaskQ_lock, lflags);
1430 } 1095 }
@@ -1435,82 +1100,6 @@ mptscsih_resume(struct pci_dev *pdev)
1435 1100
1436#endif 1101#endif
1437 1102
1438static struct mpt_pci_driver mptscsih_driver = {
1439 .probe = mptscsih_probe,
1440 .remove = mptscsih_remove,
1441 .shutdown = mptscsih_shutdown,
1442#ifdef CONFIG_PM
1443 .suspend = mptscsih_suspend,
1444 .resume = mptscsih_resume,
1445#endif
1446};
1447
1448/* SCSI host fops start here... */
1449/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
1450/**
1451 * mptscsih_init - Register MPT adapter(s) as SCSI host(s) with
1452 * linux scsi mid-layer.
1453 *
1454 * Returns 0 for success, non-zero for failure.
1455 */
1456static int __init
1457mptscsih_init(void)
1458{
1459
1460 show_mptmod_ver(my_NAME, my_VERSION);
1461
1462 ScsiDoneCtx = mpt_register(mptscsih_io_done, MPTSCSIH_DRIVER);
1463 ScsiTaskCtx = mpt_register(mptscsih_taskmgmt_complete, MPTSCSIH_DRIVER);
1464 ScsiScanDvCtx = mpt_register(mptscsih_scandv_complete, MPTSCSIH_DRIVER);
1465
1466 if (mpt_event_register(ScsiDoneCtx, mptscsih_event_process) == 0) {
1467 devtprintk((KERN_INFO MYNAM
1468 ": Registered for IOC event notifications\n"));
1469 }
1470
1471 if (mpt_reset_register(ScsiDoneCtx, mptscsih_ioc_reset) == 0) {
1472 dprintk((KERN_INFO MYNAM
1473 ": Registered for IOC reset notifications\n"));
1474 }
1475
1476 if(mpt_device_driver_register(&mptscsih_driver,
1477 MPTSCSIH_DRIVER) != 0 ) {
1478 dprintk((KERN_INFO MYNAM
1479 ": failed to register dd callbacks\n"));
1480 }
1481
1482 return 0;
1483
1484}
1485
1486/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
1487/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
1488/**
1489 * mptscsih_exit - Unregisters MPT adapter(s)
1490 *
1491 */
1492static void __exit
1493mptscsih_exit(void)
1494{
1495 mpt_device_driver_deregister(MPTSCSIH_DRIVER);
1496
1497 mpt_reset_deregister(ScsiDoneCtx);
1498 dprintk((KERN_INFO MYNAM
1499 ": Deregistered for IOC reset notifications\n"));
1500
1501 mpt_event_deregister(ScsiDoneCtx);
1502 dprintk((KERN_INFO MYNAM
1503 ": Deregistered for IOC event notifications\n"));
1504
1505 mpt_deregister(ScsiScanDvCtx);
1506 mpt_deregister(ScsiTaskCtx);
1507 mpt_deregister(ScsiDoneCtx);
1508
1509 if (info_kbuf != NULL)
1510 kfree(info_kbuf);
1511
1512}
1513
1514/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 1103/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
1515/** 1104/**
1516 * mptscsih_info - Return information about MPT adapter 1105 * mptscsih_info - Return information about MPT adapter
@@ -1520,24 +1109,25 @@ mptscsih_exit(void)
1520 * 1109 *
1521 * Returns pointer to buffer where information was written. 1110 * Returns pointer to buffer where information was written.
1522 */ 1111 */
1523static const char * 1112const char *
1524mptscsih_info(struct Scsi_Host *SChost) 1113mptscsih_info(struct Scsi_Host *SChost)
1525{ 1114{
1526 MPT_SCSI_HOST *h; 1115 MPT_SCSI_HOST *h;
1527 int size = 0; 1116 int size = 0;
1528 1117
1529 if (info_kbuf == NULL)
1530 if ((info_kbuf = kmalloc(0x1000 /* 4Kb */, GFP_KERNEL)) == NULL)
1531 return info_kbuf;
1532
1533 h = (MPT_SCSI_HOST *)SChost->hostdata; 1118 h = (MPT_SCSI_HOST *)SChost->hostdata;
1534 info_kbuf[0] = '\0'; 1119
1535 if (h) { 1120 if (h) {
1536 mpt_print_ioc_summary(h->ioc, info_kbuf, &size, 0, 0); 1121 if (h->info_kbuf == NULL)
1537 info_kbuf[size-1] = '\0'; 1122 if ((h->info_kbuf = kmalloc(0x1000 /* 4Kb */, GFP_KERNEL)) == NULL)
1123 return h->info_kbuf;
1124 h->info_kbuf[0] = '\0';
1125
1126 mpt_print_ioc_summary(h->ioc, h->info_kbuf, &size, 0, 0);
1127 h->info_kbuf[size-1] = '\0';
1538 } 1128 }
1539 1129
1540 return info_kbuf; 1130 return h->info_kbuf;
1541} 1131}
1542 1132
1543struct info_str { 1133struct info_str {
@@ -1547,7 +1137,8 @@ struct info_str {
1547 int pos; 1137 int pos;
1548}; 1138};
1549 1139
1550static void copy_mem_info(struct info_str *info, char *data, int len) 1140static void
1141mptscsih_copy_mem_info(struct info_str *info, char *data, int len)
1551{ 1142{
1552 if (info->pos + len > info->length) 1143 if (info->pos + len > info->length)
1553 len = info->length - info->pos; 1144 len = info->length - info->pos;
@@ -1568,7 +1159,8 @@ static void copy_mem_info(struct info_str *info, char *data, int len)
1568 } 1159 }
1569} 1160}
1570 1161
1571static int copy_info(struct info_str *info, char *fmt, ...) 1162static int
1163mptscsih_copy_info(struct info_str *info, char *fmt, ...)
1572{ 1164{
1573 va_list args; 1165 va_list args;
1574 char buf[81]; 1166 char buf[81];
@@ -1578,11 +1170,12 @@ static int copy_info(struct info_str *info, char *fmt, ...)
1578 len = vsprintf(buf, fmt, args); 1170 len = vsprintf(buf, fmt, args);
1579 va_end(args); 1171 va_end(args);
1580 1172
1581 copy_mem_info(info, buf, len); 1173 mptscsih_copy_mem_info(info, buf, len);
1582 return len; 1174 return len;
1583} 1175}
1584 1176
1585static int mptscsih_host_info(MPT_ADAPTER *ioc, char *pbuf, off_t offset, int len) 1177static int
1178mptscsih_host_info(MPT_ADAPTER *ioc, char *pbuf, off_t offset, int len)
1586{ 1179{
1587 struct info_str info; 1180 struct info_str info;
1588 1181
@@ -1591,10 +1184,10 @@ static int mptscsih_host_info(MPT_ADAPTER *ioc, char *pbuf, off_t offset, int le
1591 info.offset = offset; 1184 info.offset = offset;
1592 info.pos = 0; 1185 info.pos = 0;
1593 1186
1594 copy_info(&info, "%s: %s, ", ioc->name, ioc->prod_name); 1187 mptscsih_copy_info(&info, "%s: %s, ", ioc->name, ioc->prod_name);
1595 copy_info(&info, "%s%08xh, ", MPT_FW_REV_MAGIC_ID_STRING, ioc->facts.FWVersion.Word); 1188 mptscsih_copy_info(&info, "%s%08xh, ", MPT_FW_REV_MAGIC_ID_STRING, ioc->facts.FWVersion.Word);
1596 copy_info(&info, "Ports=%d, ", ioc->facts.NumberOfPorts); 1189 mptscsih_copy_info(&info, "Ports=%d, ", ioc->facts.NumberOfPorts);
1597 copy_info(&info, "MaxQ=%d\n", ioc->req_depth); 1190 mptscsih_copy_info(&info, "MaxQ=%d\n", ioc->req_depth);
1598 1191
1599 return ((info.pos > info.offset) ? info.pos - info.offset : 0); 1192 return ((info.pos > info.offset) ? info.pos - info.offset : 0);
1600} 1193}
@@ -1612,7 +1205,7 @@ static int mptscsih_host_info(MPT_ADAPTER *ioc, char *pbuf, off_t offset, int le
1612 * hostno: scsi host number 1205 * hostno: scsi host number
1613 * func: if write = 1; if read = 0 1206 * func: if write = 1; if read = 0
1614 */ 1207 */
1615static int 1208int
1616mptscsih_proc_info(struct Scsi_Host *host, char *buffer, char **start, off_t offset, 1209mptscsih_proc_info(struct Scsi_Host *host, char *buffer, char **start, off_t offset,
1617 int length, int func) 1210 int length, int func)
1618{ 1211{
@@ -1649,7 +1242,7 @@ mptscsih_proc_info(struct Scsi_Host *host, char *buffer, char **start, off_t off
1649 * 1242 *
1650 * Returns 0. (rtn value discarded by linux scsi mid-layer) 1243 * Returns 0. (rtn value discarded by linux scsi mid-layer)
1651 */ 1244 */
1652static int 1245int
1653mptscsih_qcmd(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *)) 1246mptscsih_qcmd(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *))
1654{ 1247{
1655 MPT_SCSI_HOST *hd; 1248 MPT_SCSI_HOST *hd;
@@ -1684,7 +1277,7 @@ mptscsih_qcmd(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *))
1684 /* 1277 /*
1685 * Put together a MPT SCSI request... 1278 * Put together a MPT SCSI request...
1686 */ 1279 */
1687 if ((mf = mpt_get_msg_frame(ScsiDoneCtx, hd->ioc)) == NULL) { 1280 if ((mf = mpt_get_msg_frame(hd->ioc->DoneCtx, hd->ioc)) == NULL) {
1688 dprintk((MYIOC_s_WARN_FMT "QueueCmd, no msg frames!!\n", 1281 dprintk((MYIOC_s_WARN_FMT "QueueCmd, no msg frames!!\n",
1689 hd->ioc->name)); 1282 hd->ioc->name));
1690 return SCSI_MLQUEUE_HOST_BUSY; 1283 return SCSI_MLQUEUE_HOST_BUSY;
@@ -1696,8 +1289,7 @@ mptscsih_qcmd(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *))
1696 1289
1697 ADD_INDEX_LOG(my_idx); 1290 ADD_INDEX_LOG(my_idx);
1698 1291
1699 /* BUG FIX! 19991030 -sralston 1292 /* TUR's being issued with scsictl=0x02000000 (DATA_IN)!
1700 * TUR's being issued with scsictl=0x02000000 (DATA_IN)!
1701 * Seems we may receive a buffer (datalen>0) even when there 1293 * Seems we may receive a buffer (datalen>0) even when there
1702 * will be no data transfer! GRRRRR... 1294 * will be no data transfer! GRRRRR...
1703 */ 1295 */
@@ -1791,9 +1383,9 @@ mptscsih_qcmd(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *))
1791 if (!dvtaskQ_active) { 1383 if (!dvtaskQ_active) {
1792 dvtaskQ_active = 1; 1384 dvtaskQ_active = 1;
1793 spin_unlock_irqrestore(&dvtaskQ_lock, lflags); 1385 spin_unlock_irqrestore(&dvtaskQ_lock, lflags);
1794 INIT_WORK(&mptscsih_dvTask, mptscsih_domainValidation, (void *) hd); 1386 INIT_WORK(&dvTaskQ_task, mptscsih_domainValidation, (void *) hd);
1795 1387
1796 schedule_work(&mptscsih_dvTask); 1388 schedule_work(&dvTaskQ_task);
1797 } else { 1389 } else {
1798 spin_unlock_irqrestore(&dvtaskQ_lock, lflags); 1390 spin_unlock_irqrestore(&dvtaskQ_lock, lflags);
1799 } 1391 }
@@ -1819,7 +1411,7 @@ mptscsih_qcmd(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *))
1819 } 1411 }
1820#endif 1412#endif
1821 1413
1822 mpt_put_msg_frame(ScsiDoneCtx, hd->ioc, mf); 1414 mpt_put_msg_frame(hd->ioc->DoneCtx, hd->ioc, mf);
1823 dmfprintk((MYIOC_s_INFO_FMT "Issued SCSI cmd (%p) mf=%p idx=%d\n", 1415 dmfprintk((MYIOC_s_INFO_FMT "Issued SCSI cmd (%p) mf=%p idx=%d\n",
1824 hd->ioc->name, SCpnt, mf, my_idx)); 1416 hd->ioc->name, SCpnt, mf, my_idx));
1825 DBG_DUMP_REQUEST_FRAME(mf) 1417 DBG_DUMP_REQUEST_FRAME(mf)
@@ -2036,7 +1628,7 @@ mptscsih_IssueTaskMgmt(MPT_SCSI_HOST *hd, u8 type, u8 channel, u8 target, u8 lun
2036 1628
2037 /* Return Fail to calling function if no message frames available. 1629 /* Return Fail to calling function if no message frames available.
2038 */ 1630 */
2039 if ((mf = mpt_get_msg_frame(ScsiTaskCtx, hd->ioc)) == NULL) { 1631 if ((mf = mpt_get_msg_frame(hd->ioc->TaskCtx, hd->ioc)) == NULL) {
2040 dfailprintk((MYIOC_s_ERR_FMT "IssueTaskMgmt, no msg frames!!\n", 1632 dfailprintk((MYIOC_s_ERR_FMT "IssueTaskMgmt, no msg frames!!\n",
2041 hd->ioc->name)); 1633 hd->ioc->name));
2042 //return FAILED; 1634 //return FAILED;
@@ -2075,7 +1667,7 @@ mptscsih_IssueTaskMgmt(MPT_SCSI_HOST *hd, u8 type, u8 channel, u8 target, u8 lun
2075 1667
2076 DBG_DUMP_TM_REQUEST_FRAME((u32 *)pScsiTm); 1668 DBG_DUMP_TM_REQUEST_FRAME((u32 *)pScsiTm);
2077 1669
2078 if ((retval = mpt_send_handshake_request(ScsiTaskCtx, hd->ioc, 1670 if ((retval = mpt_send_handshake_request(hd->ioc->TaskCtx, hd->ioc,
2079 sizeof(SCSITaskMgmt_t), (u32*)pScsiTm, 1671 sizeof(SCSITaskMgmt_t), (u32*)pScsiTm,
2080 CAN_SLEEP)) != 0) { 1672 CAN_SLEEP)) != 0) {
2081 dfailprintk((MYIOC_s_ERR_FMT "_send_handshake FAILED!" 1673 dfailprintk((MYIOC_s_ERR_FMT "_send_handshake FAILED!"
@@ -2107,7 +1699,7 @@ mptscsih_IssueTaskMgmt(MPT_SCSI_HOST *hd, u8 type, u8 channel, u8 target, u8 lun
2107 * 1699 *
2108 * Returns SUCCESS or FAILED. 1700 * Returns SUCCESS or FAILED.
2109 */ 1701 */
2110static int 1702int
2111mptscsih_abort(struct scsi_cmnd * SCpnt) 1703mptscsih_abort(struct scsi_cmnd * SCpnt)
2112{ 1704{
2113 MPT_SCSI_HOST *hd; 1705 MPT_SCSI_HOST *hd;
@@ -2210,7 +1802,7 @@ mptscsih_abort(struct scsi_cmnd * SCpnt)
2210 * 1802 *
2211 * Returns SUCCESS or FAILED. 1803 * Returns SUCCESS or FAILED.
2212 */ 1804 */
2213static int 1805int
2214mptscsih_dev_reset(struct scsi_cmnd * SCpnt) 1806mptscsih_dev_reset(struct scsi_cmnd * SCpnt)
2215{ 1807{
2216 MPT_SCSI_HOST *hd; 1808 MPT_SCSI_HOST *hd;
@@ -2260,7 +1852,7 @@ mptscsih_dev_reset(struct scsi_cmnd * SCpnt)
2260 * 1852 *
2261 * Returns SUCCESS or FAILED. 1853 * Returns SUCCESS or FAILED.
2262 */ 1854 */
2263static int 1855int
2264mptscsih_bus_reset(struct scsi_cmnd * SCpnt) 1856mptscsih_bus_reset(struct scsi_cmnd * SCpnt)
2265{ 1857{
2266 MPT_SCSI_HOST *hd; 1858 MPT_SCSI_HOST *hd;
@@ -2312,7 +1904,7 @@ mptscsih_bus_reset(struct scsi_cmnd * SCpnt)
2312 * 1904 *
2313 * Returns SUCCESS or FAILED. 1905 * Returns SUCCESS or FAILED.
2314 */ 1906 */
2315static int 1907int
2316mptscsih_host_reset(struct scsi_cmnd *SCpnt) 1908mptscsih_host_reset(struct scsi_cmnd *SCpnt)
2317{ 1909{
2318 MPT_SCSI_HOST * hd; 1910 MPT_SCSI_HOST * hd;
@@ -2426,7 +2018,7 @@ mptscsih_tm_wait_for_completion(MPT_SCSI_HOST * hd, ulong timeout )
2426 * 2018 *
2427 * Returns 1 indicating alloc'd request frame ptr should be freed. 2019 * Returns 1 indicating alloc'd request frame ptr should be freed.
2428 */ 2020 */
2429static int 2021int
2430mptscsih_taskmgmt_complete(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *mr) 2022mptscsih_taskmgmt_complete(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *mr)
2431{ 2023{
2432 SCSITaskMgmtReply_t *pScsiTmReply; 2024 SCSITaskMgmtReply_t *pScsiTmReply;
@@ -2509,7 +2101,7 @@ mptscsih_taskmgmt_complete(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *m
2509/* 2101/*
2510 * This is anyones guess quite frankly. 2102 * This is anyones guess quite frankly.
2511 */ 2103 */
2512static int 2104int
2513mptscsih_bios_param(struct scsi_device * sdev, struct block_device *bdev, 2105mptscsih_bios_param(struct scsi_device * sdev, struct block_device *bdev,
2514 sector_t capacity, int geom[]) 2106 sector_t capacity, int geom[])
2515{ 2107{
@@ -2556,7 +2148,7 @@ mptscsih_bios_param(struct scsi_device * sdev, struct block_device *bdev,
2556 * Return non-zero if allocation fails. 2148 * Return non-zero if allocation fails.
2557 * Init memory once per id (not LUN). 2149 * Init memory once per id (not LUN).
2558 */ 2150 */
2559static int 2151int
2560mptscsih_slave_alloc(struct scsi_device *device) 2152mptscsih_slave_alloc(struct scsi_device *device)
2561{ 2153{
2562 struct Scsi_Host *host = device->host; 2154 struct Scsi_Host *host = device->host;
@@ -2599,7 +2191,8 @@ mptscsih_slave_alloc(struct scsi_device *device)
2599 return 0; 2191 return 0;
2600} 2192}
2601 2193
2602static int mptscsih_is_raid_volume(MPT_SCSI_HOST *hd, uint id) 2194static int
2195mptscsih_is_raid_volume(MPT_SCSI_HOST *hd, uint id)
2603{ 2196{
2604 int i; 2197 int i;
2605 2198
@@ -2618,7 +2211,7 @@ static int mptscsih_is_raid_volume(MPT_SCSI_HOST *hd, uint id)
2618 * OS entry point to allow for host driver to free allocated memory 2211 * OS entry point to allow for host driver to free allocated memory
2619 * Called if no device present or device being unloaded 2212 * Called if no device present or device being unloaded
2620 */ 2213 */
2621static void 2214void
2622mptscsih_slave_destroy(struct scsi_device *device) 2215mptscsih_slave_destroy(struct scsi_device *device)
2623{ 2216{
2624 struct Scsi_Host *host = device->host; 2217 struct Scsi_Host *host = device->host;
@@ -2639,7 +2232,7 @@ mptscsih_slave_destroy(struct scsi_device *device)
2639 2232
2640 kfree(hd->Targets[target]); 2233 kfree(hd->Targets[target]);
2641 hd->Targets[target] = NULL; 2234 hd->Targets[target] = NULL;
2642 2235
2643 if (hd->ioc->bus_type == SCSI) { 2236 if (hd->ioc->bus_type == SCSI) {
2644 if (mptscsih_is_raid_volume(hd, target)) { 2237 if (mptscsih_is_raid_volume(hd, target)) {
2645 hd->ioc->spi_data.forceDv |= MPT_SCSICFG_RELOAD_IOC_PG3; 2238 hd->ioc->spi_data.forceDv |= MPT_SCSICFG_RELOAD_IOC_PG3;
@@ -2695,7 +2288,7 @@ mptscsih_set_queue_depth(struct scsi_device *device, MPT_SCSI_HOST *hd,
2695 * member to 1 if a device does not support Q tags. 2288 * member to 1 if a device does not support Q tags.
2696 * Return non-zero if fails. 2289 * Return non-zero if fails.
2697 */ 2290 */
2698static int 2291int
2699mptscsih_slave_configure(struct scsi_device *device) 2292mptscsih_slave_configure(struct scsi_device *device)
2700{ 2293{
2701 struct Scsi_Host *sh = device->host; 2294 struct Scsi_Host *sh = device->host;
@@ -2758,7 +2351,7 @@ slave_configure_exit:
2758 return 0; 2351 return 0;
2759} 2352}
2760 2353
2761static ssize_t 2354ssize_t
2762mptscsih_store_queue_depth(struct device *dev, const char *buf, size_t count) 2355mptscsih_store_queue_depth(struct device *dev, const char *buf, size_t count)
2763{ 2356{
2764 int depth; 2357 int depth;
@@ -2788,7 +2381,7 @@ mptscsih_store_queue_depth(struct device *dev, const char *buf, size_t count)
2788 * 2381 *
2789 */ 2382 */
2790static void 2383static void
2791copy_sense_data(struct scsi_cmnd *sc, MPT_SCSI_HOST *hd, MPT_FRAME_HDR *mf, SCSIIOReply_t *pScsiReply) 2384mptscsih_copy_sense_data(struct scsi_cmnd *sc, MPT_SCSI_HOST *hd, MPT_FRAME_HDR *mf, SCSIIOReply_t *pScsiReply)
2792{ 2385{
2793 VirtDevice *target; 2386 VirtDevice *target;
2794 SCSIIORequest_t *pReq; 2387 SCSIIORequest_t *pReq;
@@ -2854,7 +2447,7 @@ SCPNT_TO_LOOKUP_IDX(struct scsi_cmnd *sc)
2854} 2447}
2855 2448
2856/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 2449/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
2857static int 2450int
2858mptscsih_ioc_reset(MPT_ADAPTER *ioc, int reset_phase) 2451mptscsih_ioc_reset(MPT_ADAPTER *ioc, int reset_phase)
2859{ 2452{
2860 MPT_SCSI_HOST *hd; 2453 MPT_SCSI_HOST *hd;
@@ -2949,8 +2542,8 @@ mptscsih_ioc_reset(MPT_ADAPTER *ioc, int reset_phase)
2949 */ 2542 */
2950 hd->pLocal = &hd->localReply; 2543 hd->pLocal = &hd->localReply;
2951 hd->pLocal->completion = MPT_SCANDV_DID_RESET; 2544 hd->pLocal->completion = MPT_SCANDV_DID_RESET;
2952 scandv_wait_done = 1; 2545 hd->scandv_wait_done = 1;
2953 wake_up(&scandv_waitq); 2546 wake_up(&hd->scandv_waitq);
2954 hd->cmdPtr = NULL; 2547 hd->cmdPtr = NULL;
2955 } 2548 }
2956 2549
@@ -2969,7 +2562,7 @@ mptscsih_ioc_reset(MPT_ADAPTER *ioc, int reset_phase)
2969} 2562}
2970 2563
2971/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 2564/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
2972static int 2565int
2973mptscsih_event_process(MPT_ADAPTER *ioc, EventNotificationReply_t *pEvReply) 2566mptscsih_event_process(MPT_ADAPTER *ioc, EventNotificationReply_t *pEvReply)
2974{ 2567{
2975 MPT_SCSI_HOST *hd; 2568 MPT_SCSI_HOST *hd;
@@ -3085,42 +2678,6 @@ mptscsih_event_process(MPT_ADAPTER *ioc, EventNotificationReply_t *pEvReply)
3085 return 1; /* currently means nothing really */ 2678 return 1; /* currently means nothing really */
3086} 2679}
3087 2680
3088static struct device_attribute mptscsih_queue_depth_attr = {
3089 .attr = {
3090 .name = "queue_depth",
3091 .mode = S_IWUSR,
3092 },
3093 .store = mptscsih_store_queue_depth,
3094};
3095
3096static struct device_attribute *mptscsih_dev_attrs[] = {
3097 &mptscsih_queue_depth_attr,
3098 NULL,
3099};
3100
3101static struct scsi_host_template driver_template = {
3102 .proc_name = "mptscsih",
3103 .proc_info = mptscsih_proc_info,
3104 .name = "MPT SCSI Host",
3105 .info = mptscsih_info,
3106 .queuecommand = mptscsih_qcmd,
3107 .slave_alloc = mptscsih_slave_alloc,
3108 .slave_configure = mptscsih_slave_configure,
3109 .slave_destroy = mptscsih_slave_destroy,
3110 .eh_abort_handler = mptscsih_abort,
3111 .eh_device_reset_handler = mptscsih_dev_reset,
3112 .eh_bus_reset_handler = mptscsih_bus_reset,
3113 .eh_host_reset_handler = mptscsih_host_reset,
3114 .bios_param = mptscsih_bios_param,
3115 .can_queue = MPT_SCSI_CAN_QUEUE,
3116 .this_id = -1,
3117 .sg_tablesize = MPT_SCSI_SG_DEPTH,
3118 .max_sectors = 8192,
3119 .cmd_per_lun = 7,
3120 .use_clustering = ENABLE_CLUSTERING,
3121 .sdev_attrs = mptscsih_dev_attrs,
3122};
3123
3124/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 2681/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
3125/* 2682/*
3126 * mptscsih_initTarget - Target, LUN alloc/free functionality. 2683 * mptscsih_initTarget - Target, LUN alloc/free functionality.
@@ -3158,9 +2715,9 @@ mptscsih_initTarget(MPT_SCSI_HOST *hd, int bus_id, int target_id, u8 lun, char *
3158 * around a bug in th emid-layer in some distributions in which the mid-layer will 2715 * around a bug in th emid-layer in some distributions in which the mid-layer will
3159 * continue to try to communicate to the LUN and evntually create a dummy LUN. 2716 * continue to try to communicate to the LUN and evntually create a dummy LUN.
3160 */ 2717 */
3161 if (mpt_pq_filter && dlen && (data[0] & 0xE0)) 2718 if (hd->mpt_pq_filter && dlen && (data[0] & 0xE0))
3162 data[0] |= 0x40; 2719 data[0] |= 0x40;
3163 2720
3164 /* Is LUN supported? If so, upper 2 bits will be 0 2721 /* Is LUN supported? If so, upper 2 bits will be 0
3165 * in first byte of inquiry data. 2722 * in first byte of inquiry data.
3166 */ 2723 */
@@ -3307,7 +2864,7 @@ mptscsih_setTargetNegoParms(MPT_SCSI_HOST *hd, VirtDevice *target, char byte56)
3307 ddvtprintk((KERN_INFO "Enabling QAS on id=%d due to ~TARGET_FLAGS_VALID_56!\n", id)); 2864 ddvtprintk((KERN_INFO "Enabling QAS on id=%d due to ~TARGET_FLAGS_VALID_56!\n", id));
3308 noQas = 0; 2865 noQas = 0;
3309 } 2866 }
3310 2867
3311 offset = pspi_data->maxSyncOffset; 2868 offset = pspi_data->maxSyncOffset;
3312 2869
3313 /* If RAID, never disable QAS 2870 /* If RAID, never disable QAS
@@ -3401,7 +2958,7 @@ mptscsih_setTargetNegoParms(MPT_SCSI_HOST *hd, VirtDevice *target, char byte56)
3401 if ( (vdev = hd->Targets[ii]) ) { 2958 if ( (vdev = hd->Targets[ii]) ) {
3402 vdev->negoFlags |= MPT_TARGET_NO_NEGO_QAS; 2959 vdev->negoFlags |= MPT_TARGET_NO_NEGO_QAS;
3403 mptscsih_writeSDP1(hd, 0, ii, vdev->negoFlags); 2960 mptscsih_writeSDP1(hd, 0, ii, vdev->negoFlags);
3404 } 2961 }
3405 } 2962 }
3406 } 2963 }
3407 } 2964 }
@@ -3426,14 +2983,15 @@ mptscsih_setTargetNegoParms(MPT_SCSI_HOST *hd, VirtDevice *target, char byte56)
3426 * Tapes, initTarget will set this flag on completion of Inquiry command. 2983 * Tapes, initTarget will set this flag on completion of Inquiry command.
3427 * Called only if DV_NOT_DONE flag is set 2984 * Called only if DV_NOT_DONE flag is set
3428 */ 2985 */
3429static void mptscsih_set_dvflags(MPT_SCSI_HOST *hd, SCSIIORequest_t *pReq) 2986static void
2987mptscsih_set_dvflags(MPT_SCSI_HOST *hd, SCSIIORequest_t *pReq)
3430{ 2988{
3431 u8 cmd; 2989 u8 cmd;
3432 ScsiCfgData *pSpi; 2990 ScsiCfgData *pSpi;
3433 2991
3434 ddvtprintk((" set_dvflags: id=%d lun=%d negoNvram=%x cmd=%x\n", 2992 ddvtprintk((" set_dvflags: id=%d lun=%d negoNvram=%x cmd=%x\n",
3435 pReq->TargetID, pReq->LUN[1], hd->negoNvram, pReq->CDB[0])); 2993 pReq->TargetID, pReq->LUN[1], hd->negoNvram, pReq->CDB[0]));
3436 2994
3437 if ((pReq->LUN[1] != 0) || (hd->negoNvram != 0)) 2995 if ((pReq->LUN[1] != 0) || (hd->negoNvram != 0))
3438 return; 2996 return;
3439 2997
@@ -3464,7 +3022,8 @@ static void mptscsih_set_dvflags(MPT_SCSI_HOST *hd, SCSIIORequest_t *pReq)
3464 * If no Target, bus reset on 1st I/O. Set the flag to 3022 * If no Target, bus reset on 1st I/O. Set the flag to
3465 * prevent any future negotiations to this device. 3023 * prevent any future negotiations to this device.
3466 */ 3024 */
3467static void mptscsih_no_negotiate(MPT_SCSI_HOST *hd, int target_id) 3025static void
3026mptscsih_no_negotiate(MPT_SCSI_HOST *hd, int target_id)
3468{ 3027{
3469 3028
3470 if ((hd->Targets) && (hd->Targets[target_id] == NULL)) 3029 if ((hd->Targets) && (hd->Targets[target_id] == NULL))
@@ -3631,7 +3190,7 @@ mptscsih_writeSDP1(MPT_SCSI_HOST *hd, int portnum, int target_id, int flags)
3631 offset = pTarget->maxOffset; 3190 offset = pTarget->maxOffset;
3632 negoFlags = pTarget->negoFlags; 3191 negoFlags = pTarget->negoFlags;
3633 } 3192 }
3634 3193
3635#ifdef MPTSCSIH_ENABLE_DOMAIN_VALIDATION 3194#ifdef MPTSCSIH_ENABLE_DOMAIN_VALIDATION
3636 /* Force to async and narrow if DV has not been executed 3195 /* Force to async and narrow if DV has not been executed
3637 * for this ID 3196 * for this ID
@@ -3653,7 +3212,7 @@ mptscsih_writeSDP1(MPT_SCSI_HOST *hd, int portnum, int target_id, int flags)
3653 3212
3654 /* Get a MF for this command. 3213 /* Get a MF for this command.
3655 */ 3214 */
3656 if ((mf = mpt_get_msg_frame(ScsiDoneCtx, ioc)) == NULL) { 3215 if ((mf = mpt_get_msg_frame(ioc->DoneCtx, ioc)) == NULL) {
3657 dprintk((MYIOC_s_WARN_FMT "write SDP1: no msg frames!\n", 3216 dprintk((MYIOC_s_WARN_FMT "write SDP1: no msg frames!\n",
3658 ioc->name)); 3217 ioc->name));
3659 return -EAGAIN; 3218 return -EAGAIN;
@@ -3717,7 +3276,7 @@ mptscsih_writeSDP1(MPT_SCSI_HOST *hd, int portnum, int target_id, int flags)
3717 ioc->name, id, (id | (bus<<8)), 3276 ioc->name, id, (id | (bus<<8)),
3718 requested, configuration)); 3277 requested, configuration));
3719 3278
3720 mpt_put_msg_frame(ScsiDoneCtx, ioc, mf); 3279 mpt_put_msg_frame(ioc->DoneCtx, ioc, mf);
3721 } 3280 }
3722 3281
3723 return 0; 3282 return 0;
@@ -3748,7 +3307,7 @@ mptscsih_writeIOCPage4(MPT_SCSI_HOST *hd, int target_id, int bus)
3748 3307
3749 /* Get a MF for this command. 3308 /* Get a MF for this command.
3750 */ 3309 */
3751 if ((mf = mpt_get_msg_frame(ScsiDoneCtx, ioc)) == NULL) { 3310 if ((mf = mpt_get_msg_frame(ioc->DoneCtx, ioc)) == NULL) {
3752 dprintk((MYIOC_s_WARN_FMT "writeIOCPage4 : no msg frames!\n", 3311 dprintk((MYIOC_s_WARN_FMT "writeIOCPage4 : no msg frames!\n",
3753 ioc->name)); 3312 ioc->name));
3754 return -EAGAIN; 3313 return -EAGAIN;
@@ -3794,7 +3353,7 @@ mptscsih_writeIOCPage4(MPT_SCSI_HOST *hd, int target_id, int bus)
3794 "writeIOCPage4: MaxSEP=%d ActiveSEP=%d id=%d bus=%d\n", 3353 "writeIOCPage4: MaxSEP=%d ActiveSEP=%d id=%d bus=%d\n",
3795 ioc->name, IOCPage4Ptr->MaxSEP, IOCPage4Ptr->ActiveSEP, target_id, bus)); 3354 ioc->name, IOCPage4Ptr->MaxSEP, IOCPage4Ptr->ActiveSEP, target_id, bus));
3796 3355
3797 mpt_put_msg_frame(ScsiDoneCtx, ioc, mf); 3356 mpt_put_msg_frame(ioc->DoneCtx, ioc, mf);
3798 3357
3799 return 0; 3358 return 0;
3800} 3359}
@@ -3824,7 +3383,7 @@ mptscsih_writeIOCPage4(MPT_SCSI_HOST *hd, int target_id, int bus)
3824 * in the IOC member localReply structure. 3383 * in the IOC member localReply structure.
3825 * Used ONLY for DV and other internal commands. 3384 * Used ONLY for DV and other internal commands.
3826 */ 3385 */
3827static int 3386int
3828mptscsih_scandv_complete(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *mr) 3387mptscsih_scandv_complete(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *mr)
3829{ 3388{
3830 MPT_SCSI_HOST *hd; 3389 MPT_SCSI_HOST *hd;
@@ -3832,6 +3391,8 @@ mptscsih_scandv_complete(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *mr)
3832 int completionCode; 3391 int completionCode;
3833 u16 req_idx; 3392 u16 req_idx;
3834 3393
3394 hd = (MPT_SCSI_HOST *) ioc->sh->hostdata;
3395
3835 if ((mf == NULL) || 3396 if ((mf == NULL) ||
3836 (mf >= MPT_INDEX_2_MFPTR(ioc, ioc->req_depth))) { 3397 (mf >= MPT_INDEX_2_MFPTR(ioc, ioc->req_depth))) {
3837 printk(MYIOC_s_ERR_FMT 3398 printk(MYIOC_s_ERR_FMT
@@ -3840,7 +3401,6 @@ mptscsih_scandv_complete(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *mr)
3840 goto wakeup; 3401 goto wakeup;
3841 } 3402 }
3842 3403
3843 hd = (MPT_SCSI_HOST *) ioc->sh->hostdata;
3844 del_timer(&hd->timer); 3404 del_timer(&hd->timer);
3845 req_idx = le16_to_cpu(mf->u.frame.hwhdr.msgctxu.fld.req_idx); 3405 req_idx = le16_to_cpu(mf->u.frame.hwhdr.msgctxu.fld.req_idx);
3846 hd->ScsiLookup[req_idx] = NULL; 3406 hd->ScsiLookup[req_idx] = NULL;
@@ -3972,8 +3532,8 @@ wakeup:
3972 /* 3532 /*
3973 * Wake up the original calling thread 3533 * Wake up the original calling thread
3974 */ 3534 */
3975 scandv_wait_done = 1; 3535 hd->scandv_wait_done = 1;
3976 wake_up(&scandv_waitq); 3536 wake_up(&hd->scandv_waitq);
3977 3537
3978 return 1; 3538 return 1;
3979} 3539}
@@ -3984,7 +3544,8 @@ wakeup:
3984 * @data: Pointer to MPT_SCSI_HOST recast as an unsigned long 3544 * @data: Pointer to MPT_SCSI_HOST recast as an unsigned long
3985 * 3545 *
3986 */ 3546 */
3987static void mptscsih_timer_expired(unsigned long data) 3547void
3548mptscsih_timer_expired(unsigned long data)
3988{ 3549{
3989 MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *) data; 3550 MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *) data;
3990 3551
@@ -4051,7 +3612,7 @@ mptscsih_do_raid(MPT_SCSI_HOST *hd, u8 action, INTERNAL_CMD *io)
4051 3612
4052 /* Get and Populate a free Frame 3613 /* Get and Populate a free Frame
4053 */ 3614 */
4054 if ((mf = mpt_get_msg_frame(ScsiScanDvCtx, hd->ioc)) == NULL) { 3615 if ((mf = mpt_get_msg_frame(hd->ioc->InternalCtx, hd->ioc)) == NULL) {
4055 ddvprintk((MYIOC_s_WARN_FMT "_do_raid: no msg frames!\n", 3616 ddvprintk((MYIOC_s_WARN_FMT "_do_raid: no msg frames!\n",
4056 hd->ioc->name)); 3617 hd->ioc->name));
4057 return -EAGAIN; 3618 return -EAGAIN;
@@ -4077,7 +3638,7 @@ mptscsih_do_raid(MPT_SCSI_HOST *hd, u8 action, INTERNAL_CMD *io)
4077 3638
4078 hd->pLocal = NULL; 3639 hd->pLocal = NULL;
4079 hd->timer.expires = jiffies + HZ*10; /* 10 second timeout */ 3640 hd->timer.expires = jiffies + HZ*10; /* 10 second timeout */
4080 scandv_wait_done = 0; 3641 hd->scandv_wait_done = 0;
4081 3642
4082 /* Save cmd pointer, for resource free if timeout or 3643 /* Save cmd pointer, for resource free if timeout or
4083 * FW reload occurs 3644 * FW reload occurs
@@ -4085,8 +3646,8 @@ mptscsih_do_raid(MPT_SCSI_HOST *hd, u8 action, INTERNAL_CMD *io)
4085 hd->cmdPtr = mf; 3646 hd->cmdPtr = mf;
4086 3647
4087 add_timer(&hd->timer); 3648 add_timer(&hd->timer);
4088 mpt_put_msg_frame(ScsiScanDvCtx, hd->ioc, mf); 3649 mpt_put_msg_frame(hd->ioc->InternalCtx, hd->ioc, mf);
4089 wait_event(scandv_waitq, scandv_wait_done); 3650 wait_event(hd->scandv_waitq, hd->scandv_wait_done);
4090 3651
4091 if ((hd->pLocal == NULL) || (hd->pLocal->completion != MPT_SCANDV_GOOD)) 3652 if ((hd->pLocal == NULL) || (hd->pLocal->completion != MPT_SCANDV_GOOD))
4092 return -1; 3653 return -1;
@@ -4232,7 +3793,7 @@ mptscsih_do_cmd(MPT_SCSI_HOST *hd, INTERNAL_CMD *io)
4232 3793
4233 /* Get and Populate a free Frame 3794 /* Get and Populate a free Frame
4234 */ 3795 */
4235 if ((mf = mpt_get_msg_frame(ScsiScanDvCtx, hd->ioc)) == NULL) { 3796 if ((mf = mpt_get_msg_frame(hd->ioc->InternalCtx, hd->ioc)) == NULL) {
4236 ddvprintk((MYIOC_s_WARN_FMT "No msg frames!\n", 3797 ddvprintk((MYIOC_s_WARN_FMT "No msg frames!\n",
4237 hd->ioc->name)); 3798 hd->ioc->name));
4238 return -EBUSY; 3799 return -EBUSY;
@@ -4314,7 +3875,7 @@ mptscsih_do_cmd(MPT_SCSI_HOST *hd, INTERNAL_CMD *io)
4314 */ 3875 */
4315 hd->pLocal = NULL; 3876 hd->pLocal = NULL;
4316 hd->timer.expires = jiffies + HZ*cmdTimeout; 3877 hd->timer.expires = jiffies + HZ*cmdTimeout;
4317 scandv_wait_done = 0; 3878 hd->scandv_wait_done = 0;
4318 3879
4319 /* Save cmd pointer, for resource free if timeout or 3880 /* Save cmd pointer, for resource free if timeout or
4320 * FW reload occurs 3881 * FW reload occurs
@@ -4322,8 +3883,8 @@ mptscsih_do_cmd(MPT_SCSI_HOST *hd, INTERNAL_CMD *io)
4322 hd->cmdPtr = mf; 3883 hd->cmdPtr = mf;
4323 3884
4324 add_timer(&hd->timer); 3885 add_timer(&hd->timer);
4325 mpt_put_msg_frame(ScsiScanDvCtx, hd->ioc, mf); 3886 mpt_put_msg_frame(hd->ioc->InternalCtx, hd->ioc, mf);
4326 wait_event(scandv_waitq, scandv_wait_done); 3887 wait_event(hd->scandv_waitq, hd->scandv_wait_done);
4327 3888
4328 if (hd->pLocal) { 3889 if (hd->pLocal) {
4329 rc = hd->pLocal->completion; 3890 rc = hd->pLocal->completion;
@@ -4640,7 +4201,8 @@ mptscsih_domainValidation(void *arg)
4640 4201
4641/* Search IOC page 3 to determine if this is hidden physical disk 4202/* Search IOC page 3 to determine if this is hidden physical disk
4642 */ 4203 */
4643static int mptscsih_is_phys_disk(MPT_ADAPTER *ioc, int id) 4204static int
4205mptscsih_is_phys_disk(MPT_ADAPTER *ioc, int id)
4644{ 4206{
4645 if (ioc->spi_data.pIocPg3) { 4207 if (ioc->spi_data.pIocPg3) {
4646 Ioc3PhysDisk_t *pPDisk = ioc->spi_data.pIocPg3->PhysDisk; 4208 Ioc3PhysDisk_t *pPDisk = ioc->spi_data.pIocPg3->PhysDisk;
@@ -4659,7 +4221,8 @@ static int mptscsih_is_phys_disk(MPT_ADAPTER *ioc, int id)
4659 4221
4660/* Write SDP1 if no QAS has been enabled 4222/* Write SDP1 if no QAS has been enabled
4661 */ 4223 */
4662static void mptscsih_qas_check(MPT_SCSI_HOST *hd, int id) 4224static void
4225mptscsih_qas_check(MPT_SCSI_HOST *hd, int id)
4663{ 4226{
4664 VirtDevice *pTarget; 4227 VirtDevice *pTarget;
4665 int ii; 4228 int ii;
@@ -5157,7 +4720,7 @@ mptscsih_doDv(MPT_SCSI_HOST *hd, int bus_number, int id)
5157 } 4720 }
5158 ddvprintk((MYIOC_s_NOTE_FMT "DV: Basic test on id=%d completed OK.\n", ioc->name, id)); 4721 ddvprintk((MYIOC_s_NOTE_FMT "DV: Basic test on id=%d completed OK.\n", ioc->name, id));
5159 4722
5160 if (mpt_dv == 0) 4723 if (ioc->spi_data.mpt_dv == 0)
5161 goto target_done; 4724 goto target_done;
5162 4725
5163 inq0 = (*pbuf1) & 0x1F; 4726 inq0 = (*pbuf1) & 0x1F;
@@ -6015,7 +5578,29 @@ mptscsih_fillbuf(char *buffer, int size, int index, int width)
6015} 5578}
6016#endif /* ~MPTSCSIH_ENABLE_DOMAIN_VALIDATION */ 5579#endif /* ~MPTSCSIH_ENABLE_DOMAIN_VALIDATION */
6017 5580
6018/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 5581EXPORT_SYMBOL(mptscsih_remove);
5582EXPORT_SYMBOL(mptscsih_shutdown);
5583#ifdef CONFIG_PM
5584EXPORT_SYMBOL(mptscsih_suspend);
5585EXPORT_SYMBOL(mptscsih_resume);
5586#endif
5587EXPORT_SYMBOL(mptscsih_proc_info);
5588EXPORT_SYMBOL(mptscsih_info);
5589EXPORT_SYMBOL(mptscsih_qcmd);
5590EXPORT_SYMBOL(mptscsih_slave_alloc);
5591EXPORT_SYMBOL(mptscsih_slave_destroy);
5592EXPORT_SYMBOL(mptscsih_slave_configure);
5593EXPORT_SYMBOL(mptscsih_abort);
5594EXPORT_SYMBOL(mptscsih_dev_reset);
5595EXPORT_SYMBOL(mptscsih_bus_reset);
5596EXPORT_SYMBOL(mptscsih_host_reset);
5597EXPORT_SYMBOL(mptscsih_bios_param);
5598EXPORT_SYMBOL(mptscsih_io_done);
5599EXPORT_SYMBOL(mptscsih_taskmgmt_complete);
5600EXPORT_SYMBOL(mptscsih_scandv_complete);
5601EXPORT_SYMBOL(mptscsih_event_process);
5602EXPORT_SYMBOL(mptscsih_ioc_reset);
5603EXPORT_SYMBOL(mptscsih_store_queue_depth);
5604EXPORT_SYMBOL(mptscsih_timer_expired);
6019 5605
6020module_init(mptscsih_init); 5606/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
6021module_exit(mptscsih_exit);