aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/message/fusion/mptscsih.c778
-rw-r--r--drivers/message/fusion/mptscsih.h43
2 files changed, 211 insertions, 610 deletions
diff --git a/drivers/message/fusion/mptscsih.c b/drivers/message/fusion/mptscsih.c
index 3a3ef127df04..cf058a399dab 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
1062 /* Sanity check - ensure at least 1 port is INITIATOR capable
1063 */
1064 ioc_cap = 0;
1065 for (ii=0; ii < ioc->facts.NumberOfPorts; ii++) {
1066 if (ioc->pfacts[ii].ProtocolFlags &
1067 MPI_PORTFACTS_PROTOCOL_INITIATOR)
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 930
1263 mpt_scsi_hosts++; 931 if (sc->device == NULL)
932 return;
933 if (sc->device->host == NULL)
934 return;
935 if ((hd = (MPT_SCSI_HOST *)sc->device->host->hostdata) == NULL)
936 return;
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,39 @@ 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 if (hd->Targets != NULL) {
1333 sz1 = hd->ioc->req_depth * sizeof(void *); 1002 /*
1334 kfree(hd->ScsiLookup); 1003 * Free pointer array.
1335 hd->ScsiLookup = NULL; 1004 */
1336 } 1005 kfree(hd->Targets);
1006 hd->Targets = NULL;
1007 }
1337 1008
1338 if (hd->Targets != NULL) { 1009 dprintk((MYIOC_s_INFO_FMT
1339 /* 1010 "Free'd ScsiLookup (%d) memory\n",
1340 * Free pointer array. 1011 hd->ioc->name, sz1));
1341 */
1342 kfree(hd->Targets);
1343 hd->Targets = NULL;
1344 }
1345 1012
1346 dprintk((MYIOC_s_INFO_FMT 1013 if (hd->info_kbuf != NULL)
1347 "Free'd ScsiLookup (%d) memory\n", 1014 kfree(hd->info_kbuf);
1348 hd->ioc->name, sz1));
1349 1015
1350 /* NULL the Scsi_Host pointer 1016 /* NULL the Scsi_Host pointer
1351 */ 1017 */
1352 hd->ioc->sh = NULL; 1018 hd->ioc->sh = NULL;
1353 }
1354 1019
1355 scsi_host_put(host); 1020 scsi_host_put(host);
1356 mpt_scsi_hosts--;
1357 1021
1022 mpt_detach(pdev);
1023
1358} 1024}
1359 1025
1360/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 1026/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
@@ -1362,7 +1028,7 @@ mptscsih_remove(struct pci_dev *pdev)
1362 * mptscsih_shutdown - reboot notifier 1028 * mptscsih_shutdown - reboot notifier
1363 * 1029 *
1364 */ 1030 */
1365static void 1031void
1366mptscsih_shutdown(struct device * dev) 1032mptscsih_shutdown(struct device * dev)
1367{ 1033{
1368 MPT_ADAPTER *ioc = pci_get_drvdata(to_pci_dev(dev)); 1034 MPT_ADAPTER *ioc = pci_get_drvdata(to_pci_dev(dev));
@@ -1384,15 +1050,15 @@ mptscsih_shutdown(struct device * dev)
1384#ifdef CONFIG_PM 1050#ifdef CONFIG_PM
1385/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 1051/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
1386/* 1052/*
1387 * mptscsih_suspend - Fusion MPT scsie driver suspend routine. 1053 * mptscsih_suspend - Fusion MPT scsi driver suspend routine.
1388 * 1054 *
1389 * 1055 *
1390 */ 1056 */
1391static int 1057int
1392mptscsih_suspend(struct pci_dev *pdev, pm_message_t state) 1058mptscsih_suspend(struct pci_dev *pdev, pm_message_t state)
1393{ 1059{
1394 mptscsih_shutdown(&pdev->dev); 1060 mptscsih_shutdown(&pdev->dev);
1395 return 0; 1061 return mpt_suspend(pdev,state);
1396} 1062}
1397 1063
1398/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 1064/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
@@ -1401,13 +1067,15 @@ mptscsih_suspend(struct pci_dev *pdev, pm_message_t state)
1401 * 1067 *
1402 * 1068 *
1403 */ 1069 */
1404static int 1070int
1405mptscsih_resume(struct pci_dev *pdev) 1071mptscsih_resume(struct pci_dev *pdev)
1406{ 1072{
1407 MPT_ADAPTER *ioc = pci_get_drvdata(pdev); 1073 MPT_ADAPTER *ioc = pci_get_drvdata(pdev);
1408 struct Scsi_Host *host = ioc->sh; 1074 struct Scsi_Host *host = ioc->sh;
1409 MPT_SCSI_HOST *hd; 1075 MPT_SCSI_HOST *hd;
1410 1076
1077 mpt_resume(pdev);
1078
1411 if(!host) 1079 if(!host)
1412 return 0; 1080 return 0;
1413 1081
@@ -1422,9 +1090,9 @@ mptscsih_resume(struct pci_dev *pdev)
1422 if (!dvtaskQ_active) { 1090 if (!dvtaskQ_active) {
1423 dvtaskQ_active = 1; 1091 dvtaskQ_active = 1;
1424 spin_unlock_irqrestore(&dvtaskQ_lock, lflags); 1092 spin_unlock_irqrestore(&dvtaskQ_lock, lflags);
1425 INIT_WORK(&mptscsih_dvTask, 1093 INIT_WORK(&dvTaskQ_task,
1426 mptscsih_domainValidation, (void *) hd); 1094 mptscsih_domainValidation, (void *) hd);
1427 schedule_work(&mptscsih_dvTask); 1095 schedule_work(&dvTaskQ_task);
1428 } else { 1096 } else {
1429 spin_unlock_irqrestore(&dvtaskQ_lock, lflags); 1097 spin_unlock_irqrestore(&dvtaskQ_lock, lflags);
1430 } 1098 }
@@ -1435,82 +1103,6 @@ mptscsih_resume(struct pci_dev *pdev)
1435 1103
1436#endif 1104#endif
1437 1105
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/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 1106/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
1515/** 1107/**
1516 * mptscsih_info - Return information about MPT adapter 1108 * mptscsih_info - Return information about MPT adapter
@@ -1520,24 +1112,25 @@ mptscsih_exit(void)
1520 * 1112 *
1521 * Returns pointer to buffer where information was written. 1113 * Returns pointer to buffer where information was written.
1522 */ 1114 */
1523static const char * 1115const char *
1524mptscsih_info(struct Scsi_Host *SChost) 1116mptscsih_info(struct Scsi_Host *SChost)
1525{ 1117{
1526 MPT_SCSI_HOST *h; 1118 MPT_SCSI_HOST *h;
1527 int size = 0; 1119 int size = 0;
1528 1120
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; 1121 h = (MPT_SCSI_HOST *)SChost->hostdata;
1534 info_kbuf[0] = '\0'; 1122
1535 if (h) { 1123 if (h) {
1536 mpt_print_ioc_summary(h->ioc, info_kbuf, &size, 0, 0); 1124 if (h->info_kbuf == NULL)
1537 info_kbuf[size-1] = '\0'; 1125 if ((h->info_kbuf = kmalloc(0x1000 /* 4Kb */, GFP_KERNEL)) == NULL)
1126 return h->info_kbuf;
1127 h->info_kbuf[0] = '\0';
1128
1129 mpt_print_ioc_summary(h->ioc, h->info_kbuf, &size, 0, 0);
1130 h->info_kbuf[size-1] = '\0';
1538 } 1131 }
1539 1132
1540 return info_kbuf; 1133 return h->info_kbuf;
1541} 1134}
1542 1135
1543struct info_str { 1136struct info_str {
@@ -1547,7 +1140,8 @@ struct info_str {
1547 int pos; 1140 int pos;
1548}; 1141};
1549 1142
1550static void copy_mem_info(struct info_str *info, char *data, int len) 1143static void
1144mptscsih_copy_mem_info(struct info_str *info, char *data, int len)
1551{ 1145{
1552 if (info->pos + len > info->length) 1146 if (info->pos + len > info->length)
1553 len = info->length - info->pos; 1147 len = info->length - info->pos;
@@ -1568,7 +1162,8 @@ static void copy_mem_info(struct info_str *info, char *data, int len)
1568 } 1162 }
1569} 1163}
1570 1164
1571static int copy_info(struct info_str *info, char *fmt, ...) 1165static int
1166mptscsih_copy_info(struct info_str *info, char *fmt, ...)
1572{ 1167{
1573 va_list args; 1168 va_list args;
1574 char buf[81]; 1169 char buf[81];
@@ -1578,11 +1173,12 @@ static int copy_info(struct info_str *info, char *fmt, ...)
1578 len = vsprintf(buf, fmt, args); 1173 len = vsprintf(buf, fmt, args);
1579 va_end(args); 1174 va_end(args);
1580 1175
1581 copy_mem_info(info, buf, len); 1176 mptscsih_copy_mem_info(info, buf, len);
1582 return len; 1177 return len;
1583} 1178}
1584 1179
1585static int mptscsih_host_info(MPT_ADAPTER *ioc, char *pbuf, off_t offset, int len) 1180static int
1181mptscsih_host_info(MPT_ADAPTER *ioc, char *pbuf, off_t offset, int len)
1586{ 1182{
1587 struct info_str info; 1183 struct info_str info;
1588 1184
@@ -1591,10 +1187,10 @@ static int mptscsih_host_info(MPT_ADAPTER *ioc, char *pbuf, off_t offset, int le
1591 info.offset = offset; 1187 info.offset = offset;
1592 info.pos = 0; 1188 info.pos = 0;
1593 1189
1594 copy_info(&info, "%s: %s, ", ioc->name, ioc->prod_name); 1190 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); 1191 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); 1192 mptscsih_copy_info(&info, "Ports=%d, ", ioc->facts.NumberOfPorts);
1597 copy_info(&info, "MaxQ=%d\n", ioc->req_depth); 1193 mptscsih_copy_info(&info, "MaxQ=%d\n", ioc->req_depth);
1598 1194
1599 return ((info.pos > info.offset) ? info.pos - info.offset : 0); 1195 return ((info.pos > info.offset) ? info.pos - info.offset : 0);
1600} 1196}
@@ -1612,7 +1208,7 @@ static int mptscsih_host_info(MPT_ADAPTER *ioc, char *pbuf, off_t offset, int le
1612 * hostno: scsi host number 1208 * hostno: scsi host number
1613 * func: if write = 1; if read = 0 1209 * func: if write = 1; if read = 0
1614 */ 1210 */
1615static int 1211int
1616mptscsih_proc_info(struct Scsi_Host *host, char *buffer, char **start, off_t offset, 1212mptscsih_proc_info(struct Scsi_Host *host, char *buffer, char **start, off_t offset,
1617 int length, int func) 1213 int length, int func)
1618{ 1214{
@@ -1649,7 +1245,7 @@ mptscsih_proc_info(struct Scsi_Host *host, char *buffer, char **start, off_t off
1649 * 1245 *
1650 * Returns 0. (rtn value discarded by linux scsi mid-layer) 1246 * Returns 0. (rtn value discarded by linux scsi mid-layer)
1651 */ 1247 */
1652static int 1248int
1653mptscsih_qcmd(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *)) 1249mptscsih_qcmd(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *))
1654{ 1250{
1655 MPT_SCSI_HOST *hd; 1251 MPT_SCSI_HOST *hd;
@@ -1684,7 +1280,7 @@ mptscsih_qcmd(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *))
1684 /* 1280 /*
1685 * Put together a MPT SCSI request... 1281 * Put together a MPT SCSI request...
1686 */ 1282 */
1687 if ((mf = mpt_get_msg_frame(ScsiDoneCtx, hd->ioc)) == NULL) { 1283 if ((mf = mpt_get_msg_frame(hd->ioc->DoneCtx, hd->ioc)) == NULL) {
1688 dprintk((MYIOC_s_WARN_FMT "QueueCmd, no msg frames!!\n", 1284 dprintk((MYIOC_s_WARN_FMT "QueueCmd, no msg frames!!\n",
1689 hd->ioc->name)); 1285 hd->ioc->name));
1690 return SCSI_MLQUEUE_HOST_BUSY; 1286 return SCSI_MLQUEUE_HOST_BUSY;
@@ -1696,8 +1292,7 @@ mptscsih_qcmd(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *))
1696 1292
1697 ADD_INDEX_LOG(my_idx); 1293 ADD_INDEX_LOG(my_idx);
1698 1294
1699 /* BUG FIX! 19991030 -sralston 1295 /* 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 1296 * Seems we may receive a buffer (datalen>0) even when there
1702 * will be no data transfer! GRRRRR... 1297 * will be no data transfer! GRRRRR...
1703 */ 1298 */
@@ -1791,9 +1386,9 @@ mptscsih_qcmd(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *))
1791 if (!dvtaskQ_active) { 1386 if (!dvtaskQ_active) {
1792 dvtaskQ_active = 1; 1387 dvtaskQ_active = 1;
1793 spin_unlock_irqrestore(&dvtaskQ_lock, lflags); 1388 spin_unlock_irqrestore(&dvtaskQ_lock, lflags);
1794 INIT_WORK(&mptscsih_dvTask, mptscsih_domainValidation, (void *) hd); 1389 INIT_WORK(&dvTaskQ_task, mptscsih_domainValidation, (void *) hd);
1795 1390
1796 schedule_work(&mptscsih_dvTask); 1391 schedule_work(&dvTaskQ_task);
1797 } else { 1392 } else {
1798 spin_unlock_irqrestore(&dvtaskQ_lock, lflags); 1393 spin_unlock_irqrestore(&dvtaskQ_lock, lflags);
1799 } 1394 }
@@ -1819,7 +1414,7 @@ mptscsih_qcmd(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *))
1819 } 1414 }
1820#endif 1415#endif
1821 1416
1822 mpt_put_msg_frame(ScsiDoneCtx, hd->ioc, mf); 1417 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", 1418 dmfprintk((MYIOC_s_INFO_FMT "Issued SCSI cmd (%p) mf=%p idx=%d\n",
1824 hd->ioc->name, SCpnt, mf, my_idx)); 1419 hd->ioc->name, SCpnt, mf, my_idx));
1825 DBG_DUMP_REQUEST_FRAME(mf) 1420 DBG_DUMP_REQUEST_FRAME(mf)
@@ -2036,7 +1631,7 @@ mptscsih_IssueTaskMgmt(MPT_SCSI_HOST *hd, u8 type, u8 channel, u8 target, u8 lun
2036 1631
2037 /* Return Fail to calling function if no message frames available. 1632 /* Return Fail to calling function if no message frames available.
2038 */ 1633 */
2039 if ((mf = mpt_get_msg_frame(ScsiTaskCtx, hd->ioc)) == NULL) { 1634 if ((mf = mpt_get_msg_frame(hd->ioc->TaskCtx, hd->ioc)) == NULL) {
2040 dfailprintk((MYIOC_s_ERR_FMT "IssueTaskMgmt, no msg frames!!\n", 1635 dfailprintk((MYIOC_s_ERR_FMT "IssueTaskMgmt, no msg frames!!\n",
2041 hd->ioc->name)); 1636 hd->ioc->name));
2042 //return FAILED; 1637 //return FAILED;
@@ -2075,7 +1670,7 @@ mptscsih_IssueTaskMgmt(MPT_SCSI_HOST *hd, u8 type, u8 channel, u8 target, u8 lun
2075 1670
2076 DBG_DUMP_TM_REQUEST_FRAME((u32 *)pScsiTm); 1671 DBG_DUMP_TM_REQUEST_FRAME((u32 *)pScsiTm);
2077 1672
2078 if ((retval = mpt_send_handshake_request(ScsiTaskCtx, hd->ioc, 1673 if ((retval = mpt_send_handshake_request(hd->ioc->TaskCtx, hd->ioc,
2079 sizeof(SCSITaskMgmt_t), (u32*)pScsiTm, 1674 sizeof(SCSITaskMgmt_t), (u32*)pScsiTm,
2080 CAN_SLEEP)) != 0) { 1675 CAN_SLEEP)) != 0) {
2081 dfailprintk((MYIOC_s_ERR_FMT "_send_handshake FAILED!" 1676 dfailprintk((MYIOC_s_ERR_FMT "_send_handshake FAILED!"
@@ -2107,7 +1702,7 @@ mptscsih_IssueTaskMgmt(MPT_SCSI_HOST *hd, u8 type, u8 channel, u8 target, u8 lun
2107 * 1702 *
2108 * Returns SUCCESS or FAILED. 1703 * Returns SUCCESS or FAILED.
2109 */ 1704 */
2110static int 1705int
2111mptscsih_abort(struct scsi_cmnd * SCpnt) 1706mptscsih_abort(struct scsi_cmnd * SCpnt)
2112{ 1707{
2113 MPT_SCSI_HOST *hd; 1708 MPT_SCSI_HOST *hd;
@@ -2210,7 +1805,7 @@ mptscsih_abort(struct scsi_cmnd * SCpnt)
2210 * 1805 *
2211 * Returns SUCCESS or FAILED. 1806 * Returns SUCCESS or FAILED.
2212 */ 1807 */
2213static int 1808int
2214mptscsih_dev_reset(struct scsi_cmnd * SCpnt) 1809mptscsih_dev_reset(struct scsi_cmnd * SCpnt)
2215{ 1810{
2216 MPT_SCSI_HOST *hd; 1811 MPT_SCSI_HOST *hd;
@@ -2260,7 +1855,7 @@ mptscsih_dev_reset(struct scsi_cmnd * SCpnt)
2260 * 1855 *
2261 * Returns SUCCESS or FAILED. 1856 * Returns SUCCESS or FAILED.
2262 */ 1857 */
2263static int 1858int
2264mptscsih_bus_reset(struct scsi_cmnd * SCpnt) 1859mptscsih_bus_reset(struct scsi_cmnd * SCpnt)
2265{ 1860{
2266 MPT_SCSI_HOST *hd; 1861 MPT_SCSI_HOST *hd;
@@ -2312,7 +1907,7 @@ mptscsih_bus_reset(struct scsi_cmnd * SCpnt)
2312 * 1907 *
2313 * Returns SUCCESS or FAILED. 1908 * Returns SUCCESS or FAILED.
2314 */ 1909 */
2315static int 1910int
2316mptscsih_host_reset(struct scsi_cmnd *SCpnt) 1911mptscsih_host_reset(struct scsi_cmnd *SCpnt)
2317{ 1912{
2318 MPT_SCSI_HOST * hd; 1913 MPT_SCSI_HOST * hd;
@@ -2426,7 +2021,7 @@ mptscsih_tm_wait_for_completion(MPT_SCSI_HOST * hd, ulong timeout )
2426 * 2021 *
2427 * Returns 1 indicating alloc'd request frame ptr should be freed. 2022 * Returns 1 indicating alloc'd request frame ptr should be freed.
2428 */ 2023 */
2429static int 2024int
2430mptscsih_taskmgmt_complete(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *mr) 2025mptscsih_taskmgmt_complete(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *mr)
2431{ 2026{
2432 SCSITaskMgmtReply_t *pScsiTmReply; 2027 SCSITaskMgmtReply_t *pScsiTmReply;
@@ -2509,7 +2104,7 @@ mptscsih_taskmgmt_complete(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *m
2509/* 2104/*
2510 * This is anyones guess quite frankly. 2105 * This is anyones guess quite frankly.
2511 */ 2106 */
2512static int 2107int
2513mptscsih_bios_param(struct scsi_device * sdev, struct block_device *bdev, 2108mptscsih_bios_param(struct scsi_device * sdev, struct block_device *bdev,
2514 sector_t capacity, int geom[]) 2109 sector_t capacity, int geom[])
2515{ 2110{
@@ -2556,7 +2151,7 @@ mptscsih_bios_param(struct scsi_device * sdev, struct block_device *bdev,
2556 * Return non-zero if allocation fails. 2151 * Return non-zero if allocation fails.
2557 * Init memory once per id (not LUN). 2152 * Init memory once per id (not LUN).
2558 */ 2153 */
2559static int 2154int
2560mptscsih_slave_alloc(struct scsi_device *device) 2155mptscsih_slave_alloc(struct scsi_device *device)
2561{ 2156{
2562 struct Scsi_Host *host = device->host; 2157 struct Scsi_Host *host = device->host;
@@ -2599,7 +2194,8 @@ mptscsih_slave_alloc(struct scsi_device *device)
2599 return 0; 2194 return 0;
2600} 2195}
2601 2196
2602static int mptscsih_is_raid_volume(MPT_SCSI_HOST *hd, uint id) 2197static int
2198mptscsih_is_raid_volume(MPT_SCSI_HOST *hd, uint id)
2603{ 2199{
2604 int i; 2200 int i;
2605 2201
@@ -2618,7 +2214,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 2214 * OS entry point to allow for host driver to free allocated memory
2619 * Called if no device present or device being unloaded 2215 * Called if no device present or device being unloaded
2620 */ 2216 */
2621static void 2217void
2622mptscsih_slave_destroy(struct scsi_device *device) 2218mptscsih_slave_destroy(struct scsi_device *device)
2623{ 2219{
2624 struct Scsi_Host *host = device->host; 2220 struct Scsi_Host *host = device->host;
@@ -2639,7 +2235,7 @@ mptscsih_slave_destroy(struct scsi_device *device)
2639 2235
2640 kfree(hd->Targets[target]); 2236 kfree(hd->Targets[target]);
2641 hd->Targets[target] = NULL; 2237 hd->Targets[target] = NULL;
2642 2238
2643 if (hd->ioc->bus_type == SCSI) { 2239 if (hd->ioc->bus_type == SCSI) {
2644 if (mptscsih_is_raid_volume(hd, target)) { 2240 if (mptscsih_is_raid_volume(hd, target)) {
2645 hd->ioc->spi_data.forceDv |= MPT_SCSICFG_RELOAD_IOC_PG3; 2241 hd->ioc->spi_data.forceDv |= MPT_SCSICFG_RELOAD_IOC_PG3;
@@ -2695,7 +2291,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. 2291 * member to 1 if a device does not support Q tags.
2696 * Return non-zero if fails. 2292 * Return non-zero if fails.
2697 */ 2293 */
2698static int 2294int
2699mptscsih_slave_configure(struct scsi_device *device) 2295mptscsih_slave_configure(struct scsi_device *device)
2700{ 2296{
2701 struct Scsi_Host *sh = device->host; 2297 struct Scsi_Host *sh = device->host;
@@ -2758,7 +2354,7 @@ slave_configure_exit:
2758 return 0; 2354 return 0;
2759} 2355}
2760 2356
2761static ssize_t 2357ssize_t
2762mptscsih_store_queue_depth(struct device *dev, const char *buf, size_t count) 2358mptscsih_store_queue_depth(struct device *dev, const char *buf, size_t count)
2763{ 2359{
2764 int depth; 2360 int depth;
@@ -2788,7 +2384,7 @@ mptscsih_store_queue_depth(struct device *dev, const char *buf, size_t count)
2788 * 2384 *
2789 */ 2385 */
2790static void 2386static void
2791copy_sense_data(struct scsi_cmnd *sc, MPT_SCSI_HOST *hd, MPT_FRAME_HDR *mf, SCSIIOReply_t *pScsiReply) 2387mptscsih_copy_sense_data(struct scsi_cmnd *sc, MPT_SCSI_HOST *hd, MPT_FRAME_HDR *mf, SCSIIOReply_t *pScsiReply)
2792{ 2388{
2793 VirtDevice *target; 2389 VirtDevice *target;
2794 SCSIIORequest_t *pReq; 2390 SCSIIORequest_t *pReq;
@@ -2854,7 +2450,7 @@ SCPNT_TO_LOOKUP_IDX(struct scsi_cmnd *sc)
2854} 2450}
2855 2451
2856/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 2452/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
2857static int 2453int
2858mptscsih_ioc_reset(MPT_ADAPTER *ioc, int reset_phase) 2454mptscsih_ioc_reset(MPT_ADAPTER *ioc, int reset_phase)
2859{ 2455{
2860 MPT_SCSI_HOST *hd; 2456 MPT_SCSI_HOST *hd;
@@ -2949,8 +2545,8 @@ mptscsih_ioc_reset(MPT_ADAPTER *ioc, int reset_phase)
2949 */ 2545 */
2950 hd->pLocal = &hd->localReply; 2546 hd->pLocal = &hd->localReply;
2951 hd->pLocal->completion = MPT_SCANDV_DID_RESET; 2547 hd->pLocal->completion = MPT_SCANDV_DID_RESET;
2952 scandv_wait_done = 1; 2548 hd->scandv_wait_done = 1;
2953 wake_up(&scandv_waitq); 2549 wake_up(&hd->scandv_waitq);
2954 hd->cmdPtr = NULL; 2550 hd->cmdPtr = NULL;
2955 } 2551 }
2956 2552
@@ -2969,7 +2565,7 @@ mptscsih_ioc_reset(MPT_ADAPTER *ioc, int reset_phase)
2969} 2565}
2970 2566
2971/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 2567/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
2972static int 2568int
2973mptscsih_event_process(MPT_ADAPTER *ioc, EventNotificationReply_t *pEvReply) 2569mptscsih_event_process(MPT_ADAPTER *ioc, EventNotificationReply_t *pEvReply)
2974{ 2570{
2975 MPT_SCSI_HOST *hd; 2571 MPT_SCSI_HOST *hd;
@@ -3085,42 +2681,6 @@ mptscsih_event_process(MPT_ADAPTER *ioc, EventNotificationReply_t *pEvReply)
3085 return 1; /* currently means nothing really */ 2681 return 1; /* currently means nothing really */
3086} 2682}
3087 2683
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/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 2684/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
3125/* 2685/*
3126 * mptscsih_initTarget - Target, LUN alloc/free functionality. 2686 * mptscsih_initTarget - Target, LUN alloc/free functionality.
@@ -3158,9 +2718,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 2718 * 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. 2719 * continue to try to communicate to the LUN and evntually create a dummy LUN.
3160 */ 2720 */
3161 if (mpt_pq_filter && dlen && (data[0] & 0xE0)) 2721 if (hd->mpt_pq_filter && dlen && (data[0] & 0xE0))
3162 data[0] |= 0x40; 2722 data[0] |= 0x40;
3163 2723
3164 /* Is LUN supported? If so, upper 2 bits will be 0 2724 /* Is LUN supported? If so, upper 2 bits will be 0
3165 * in first byte of inquiry data. 2725 * in first byte of inquiry data.
3166 */ 2726 */
@@ -3307,7 +2867,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)); 2867 ddvtprintk((KERN_INFO "Enabling QAS on id=%d due to ~TARGET_FLAGS_VALID_56!\n", id));
3308 noQas = 0; 2868 noQas = 0;
3309 } 2869 }
3310 2870
3311 offset = pspi_data->maxSyncOffset; 2871 offset = pspi_data->maxSyncOffset;
3312 2872
3313 /* If RAID, never disable QAS 2873 /* If RAID, never disable QAS
@@ -3401,7 +2961,7 @@ mptscsih_setTargetNegoParms(MPT_SCSI_HOST *hd, VirtDevice *target, char byte56)
3401 if ( (vdev = hd->Targets[ii]) ) { 2961 if ( (vdev = hd->Targets[ii]) ) {
3402 vdev->negoFlags |= MPT_TARGET_NO_NEGO_QAS; 2962 vdev->negoFlags |= MPT_TARGET_NO_NEGO_QAS;
3403 mptscsih_writeSDP1(hd, 0, ii, vdev->negoFlags); 2963 mptscsih_writeSDP1(hd, 0, ii, vdev->negoFlags);
3404 } 2964 }
3405 } 2965 }
3406 } 2966 }
3407 } 2967 }
@@ -3426,14 +2986,15 @@ mptscsih_setTargetNegoParms(MPT_SCSI_HOST *hd, VirtDevice *target, char byte56)
3426 * Tapes, initTarget will set this flag on completion of Inquiry command. 2986 * Tapes, initTarget will set this flag on completion of Inquiry command.
3427 * Called only if DV_NOT_DONE flag is set 2987 * Called only if DV_NOT_DONE flag is set
3428 */ 2988 */
3429static void mptscsih_set_dvflags(MPT_SCSI_HOST *hd, SCSIIORequest_t *pReq) 2989static void
2990mptscsih_set_dvflags(MPT_SCSI_HOST *hd, SCSIIORequest_t *pReq)
3430{ 2991{
3431 u8 cmd; 2992 u8 cmd;
3432 ScsiCfgData *pSpi; 2993 ScsiCfgData *pSpi;
3433 2994
3434 ddvtprintk((" set_dvflags: id=%d lun=%d negoNvram=%x cmd=%x\n", 2995 ddvtprintk((" set_dvflags: id=%d lun=%d negoNvram=%x cmd=%x\n",
3435 pReq->TargetID, pReq->LUN[1], hd->negoNvram, pReq->CDB[0])); 2996 pReq->TargetID, pReq->LUN[1], hd->negoNvram, pReq->CDB[0]));
3436 2997
3437 if ((pReq->LUN[1] != 0) || (hd->negoNvram != 0)) 2998 if ((pReq->LUN[1] != 0) || (hd->negoNvram != 0))
3438 return; 2999 return;
3439 3000
@@ -3464,7 +3025,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 3025 * If no Target, bus reset on 1st I/O. Set the flag to
3465 * prevent any future negotiations to this device. 3026 * prevent any future negotiations to this device.
3466 */ 3027 */
3467static void mptscsih_no_negotiate(MPT_SCSI_HOST *hd, int target_id) 3028static void
3029mptscsih_no_negotiate(MPT_SCSI_HOST *hd, int target_id)
3468{ 3030{
3469 3031
3470 if ((hd->Targets) && (hd->Targets[target_id] == NULL)) 3032 if ((hd->Targets) && (hd->Targets[target_id] == NULL))
@@ -3631,7 +3193,7 @@ mptscsih_writeSDP1(MPT_SCSI_HOST *hd, int portnum, int target_id, int flags)
3631 offset = pTarget->maxOffset; 3193 offset = pTarget->maxOffset;
3632 negoFlags = pTarget->negoFlags; 3194 negoFlags = pTarget->negoFlags;
3633 } 3195 }
3634 3196
3635#ifdef MPTSCSIH_ENABLE_DOMAIN_VALIDATION 3197#ifdef MPTSCSIH_ENABLE_DOMAIN_VALIDATION
3636 /* Force to async and narrow if DV has not been executed 3198 /* Force to async and narrow if DV has not been executed
3637 * for this ID 3199 * for this ID
@@ -3653,7 +3215,7 @@ mptscsih_writeSDP1(MPT_SCSI_HOST *hd, int portnum, int target_id, int flags)
3653 3215
3654 /* Get a MF for this command. 3216 /* Get a MF for this command.
3655 */ 3217 */
3656 if ((mf = mpt_get_msg_frame(ScsiDoneCtx, ioc)) == NULL) { 3218 if ((mf = mpt_get_msg_frame(ioc->DoneCtx, ioc)) == NULL) {
3657 dprintk((MYIOC_s_WARN_FMT "write SDP1: no msg frames!\n", 3219 dprintk((MYIOC_s_WARN_FMT "write SDP1: no msg frames!\n",
3658 ioc->name)); 3220 ioc->name));
3659 return -EAGAIN; 3221 return -EAGAIN;
@@ -3717,7 +3279,7 @@ mptscsih_writeSDP1(MPT_SCSI_HOST *hd, int portnum, int target_id, int flags)
3717 ioc->name, id, (id | (bus<<8)), 3279 ioc->name, id, (id | (bus<<8)),
3718 requested, configuration)); 3280 requested, configuration));
3719 3281
3720 mpt_put_msg_frame(ScsiDoneCtx, ioc, mf); 3282 mpt_put_msg_frame(ioc->DoneCtx, ioc, mf);
3721 } 3283 }
3722 3284
3723 return 0; 3285 return 0;
@@ -3748,7 +3310,7 @@ mptscsih_writeIOCPage4(MPT_SCSI_HOST *hd, int target_id, int bus)
3748 3310
3749 /* Get a MF for this command. 3311 /* Get a MF for this command.
3750 */ 3312 */
3751 if ((mf = mpt_get_msg_frame(ScsiDoneCtx, ioc)) == NULL) { 3313 if ((mf = mpt_get_msg_frame(ioc->DoneCtx, ioc)) == NULL) {
3752 dprintk((MYIOC_s_WARN_FMT "writeIOCPage4 : no msg frames!\n", 3314 dprintk((MYIOC_s_WARN_FMT "writeIOCPage4 : no msg frames!\n",
3753 ioc->name)); 3315 ioc->name));
3754 return -EAGAIN; 3316 return -EAGAIN;
@@ -3794,7 +3356,7 @@ mptscsih_writeIOCPage4(MPT_SCSI_HOST *hd, int target_id, int bus)
3794 "writeIOCPage4: MaxSEP=%d ActiveSEP=%d id=%d bus=%d\n", 3356 "writeIOCPage4: MaxSEP=%d ActiveSEP=%d id=%d bus=%d\n",
3795 ioc->name, IOCPage4Ptr->MaxSEP, IOCPage4Ptr->ActiveSEP, target_id, bus)); 3357 ioc->name, IOCPage4Ptr->MaxSEP, IOCPage4Ptr->ActiveSEP, target_id, bus));
3796 3358
3797 mpt_put_msg_frame(ScsiDoneCtx, ioc, mf); 3359 mpt_put_msg_frame(ioc->DoneCtx, ioc, mf);
3798 3360
3799 return 0; 3361 return 0;
3800} 3362}
@@ -3824,7 +3386,7 @@ mptscsih_writeIOCPage4(MPT_SCSI_HOST *hd, int target_id, int bus)
3824 * in the IOC member localReply structure. 3386 * in the IOC member localReply structure.
3825 * Used ONLY for DV and other internal commands. 3387 * Used ONLY for DV and other internal commands.
3826 */ 3388 */
3827static int 3389int
3828mptscsih_scandv_complete(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *mr) 3390mptscsih_scandv_complete(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *mr)
3829{ 3391{
3830 MPT_SCSI_HOST *hd; 3392 MPT_SCSI_HOST *hd;
@@ -3832,6 +3394,8 @@ mptscsih_scandv_complete(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *mr)
3832 int completionCode; 3394 int completionCode;
3833 u16 req_idx; 3395 u16 req_idx;
3834 3396
3397 hd = (MPT_SCSI_HOST *) ioc->sh->hostdata;
3398
3835 if ((mf == NULL) || 3399 if ((mf == NULL) ||
3836 (mf >= MPT_INDEX_2_MFPTR(ioc, ioc->req_depth))) { 3400 (mf >= MPT_INDEX_2_MFPTR(ioc, ioc->req_depth))) {
3837 printk(MYIOC_s_ERR_FMT 3401 printk(MYIOC_s_ERR_FMT
@@ -3840,7 +3404,6 @@ mptscsih_scandv_complete(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *mr)
3840 goto wakeup; 3404 goto wakeup;
3841 } 3405 }
3842 3406
3843 hd = (MPT_SCSI_HOST *) ioc->sh->hostdata;
3844 del_timer(&hd->timer); 3407 del_timer(&hd->timer);
3845 req_idx = le16_to_cpu(mf->u.frame.hwhdr.msgctxu.fld.req_idx); 3408 req_idx = le16_to_cpu(mf->u.frame.hwhdr.msgctxu.fld.req_idx);
3846 hd->ScsiLookup[req_idx] = NULL; 3409 hd->ScsiLookup[req_idx] = NULL;
@@ -3972,8 +3535,8 @@ wakeup:
3972 /* 3535 /*
3973 * Wake up the original calling thread 3536 * Wake up the original calling thread
3974 */ 3537 */
3975 scandv_wait_done = 1; 3538 hd->scandv_wait_done = 1;
3976 wake_up(&scandv_waitq); 3539 wake_up(&hd->scandv_waitq);
3977 3540
3978 return 1; 3541 return 1;
3979} 3542}
@@ -3984,7 +3547,8 @@ wakeup:
3984 * @data: Pointer to MPT_SCSI_HOST recast as an unsigned long 3547 * @data: Pointer to MPT_SCSI_HOST recast as an unsigned long
3985 * 3548 *
3986 */ 3549 */
3987static void mptscsih_timer_expired(unsigned long data) 3550void
3551mptscsih_timer_expired(unsigned long data)
3988{ 3552{
3989 MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *) data; 3553 MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *) data;
3990 3554
@@ -4051,7 +3615,7 @@ mptscsih_do_raid(MPT_SCSI_HOST *hd, u8 action, INTERNAL_CMD *io)
4051 3615
4052 /* Get and Populate a free Frame 3616 /* Get and Populate a free Frame
4053 */ 3617 */
4054 if ((mf = mpt_get_msg_frame(ScsiScanDvCtx, hd->ioc)) == NULL) { 3618 if ((mf = mpt_get_msg_frame(hd->ioc->InternalCtx, hd->ioc)) == NULL) {
4055 ddvprintk((MYIOC_s_WARN_FMT "_do_raid: no msg frames!\n", 3619 ddvprintk((MYIOC_s_WARN_FMT "_do_raid: no msg frames!\n",
4056 hd->ioc->name)); 3620 hd->ioc->name));
4057 return -EAGAIN; 3621 return -EAGAIN;
@@ -4077,7 +3641,7 @@ mptscsih_do_raid(MPT_SCSI_HOST *hd, u8 action, INTERNAL_CMD *io)
4077 3641
4078 hd->pLocal = NULL; 3642 hd->pLocal = NULL;
4079 hd->timer.expires = jiffies + HZ*10; /* 10 second timeout */ 3643 hd->timer.expires = jiffies + HZ*10; /* 10 second timeout */
4080 scandv_wait_done = 0; 3644 hd->scandv_wait_done = 0;
4081 3645
4082 /* Save cmd pointer, for resource free if timeout or 3646 /* Save cmd pointer, for resource free if timeout or
4083 * FW reload occurs 3647 * FW reload occurs
@@ -4085,8 +3649,8 @@ mptscsih_do_raid(MPT_SCSI_HOST *hd, u8 action, INTERNAL_CMD *io)
4085 hd->cmdPtr = mf; 3649 hd->cmdPtr = mf;
4086 3650
4087 add_timer(&hd->timer); 3651 add_timer(&hd->timer);
4088 mpt_put_msg_frame(ScsiScanDvCtx, hd->ioc, mf); 3652 mpt_put_msg_frame(hd->ioc->InternalCtx, hd->ioc, mf);
4089 wait_event(scandv_waitq, scandv_wait_done); 3653 wait_event(hd->scandv_waitq, hd->scandv_wait_done);
4090 3654
4091 if ((hd->pLocal == NULL) || (hd->pLocal->completion != MPT_SCANDV_GOOD)) 3655 if ((hd->pLocal == NULL) || (hd->pLocal->completion != MPT_SCANDV_GOOD))
4092 return -1; 3656 return -1;
@@ -4232,7 +3796,7 @@ mptscsih_do_cmd(MPT_SCSI_HOST *hd, INTERNAL_CMD *io)
4232 3796
4233 /* Get and Populate a free Frame 3797 /* Get and Populate a free Frame
4234 */ 3798 */
4235 if ((mf = mpt_get_msg_frame(ScsiScanDvCtx, hd->ioc)) == NULL) { 3799 if ((mf = mpt_get_msg_frame(hd->ioc->InternalCtx, hd->ioc)) == NULL) {
4236 ddvprintk((MYIOC_s_WARN_FMT "No msg frames!\n", 3800 ddvprintk((MYIOC_s_WARN_FMT "No msg frames!\n",
4237 hd->ioc->name)); 3801 hd->ioc->name));
4238 return -EBUSY; 3802 return -EBUSY;
@@ -4314,7 +3878,7 @@ mptscsih_do_cmd(MPT_SCSI_HOST *hd, INTERNAL_CMD *io)
4314 */ 3878 */
4315 hd->pLocal = NULL; 3879 hd->pLocal = NULL;
4316 hd->timer.expires = jiffies + HZ*cmdTimeout; 3880 hd->timer.expires = jiffies + HZ*cmdTimeout;
4317 scandv_wait_done = 0; 3881 hd->scandv_wait_done = 0;
4318 3882
4319 /* Save cmd pointer, for resource free if timeout or 3883 /* Save cmd pointer, for resource free if timeout or
4320 * FW reload occurs 3884 * FW reload occurs
@@ -4322,8 +3886,8 @@ mptscsih_do_cmd(MPT_SCSI_HOST *hd, INTERNAL_CMD *io)
4322 hd->cmdPtr = mf; 3886 hd->cmdPtr = mf;
4323 3887
4324 add_timer(&hd->timer); 3888 add_timer(&hd->timer);
4325 mpt_put_msg_frame(ScsiScanDvCtx, hd->ioc, mf); 3889 mpt_put_msg_frame(hd->ioc->InternalCtx, hd->ioc, mf);
4326 wait_event(scandv_waitq, scandv_wait_done); 3890 wait_event(hd->scandv_waitq, hd->scandv_wait_done);
4327 3891
4328 if (hd->pLocal) { 3892 if (hd->pLocal) {
4329 rc = hd->pLocal->completion; 3893 rc = hd->pLocal->completion;
@@ -4640,7 +4204,8 @@ mptscsih_domainValidation(void *arg)
4640 4204
4641/* Search IOC page 3 to determine if this is hidden physical disk 4205/* Search IOC page 3 to determine if this is hidden physical disk
4642 */ 4206 */
4643static int mptscsih_is_phys_disk(MPT_ADAPTER *ioc, int id) 4207static int
4208mptscsih_is_phys_disk(MPT_ADAPTER *ioc, int id)
4644{ 4209{
4645 if (ioc->spi_data.pIocPg3) { 4210 if (ioc->spi_data.pIocPg3) {
4646 Ioc3PhysDisk_t *pPDisk = ioc->spi_data.pIocPg3->PhysDisk; 4211 Ioc3PhysDisk_t *pPDisk = ioc->spi_data.pIocPg3->PhysDisk;
@@ -4659,7 +4224,8 @@ static int mptscsih_is_phys_disk(MPT_ADAPTER *ioc, int id)
4659 4224
4660/* Write SDP1 if no QAS has been enabled 4225/* Write SDP1 if no QAS has been enabled
4661 */ 4226 */
4662static void mptscsih_qas_check(MPT_SCSI_HOST *hd, int id) 4227static void
4228mptscsih_qas_check(MPT_SCSI_HOST *hd, int id)
4663{ 4229{
4664 VirtDevice *pTarget; 4230 VirtDevice *pTarget;
4665 int ii; 4231 int ii;
@@ -5157,7 +4723,7 @@ mptscsih_doDv(MPT_SCSI_HOST *hd, int bus_number, int id)
5157 } 4723 }
5158 ddvprintk((MYIOC_s_NOTE_FMT "DV: Basic test on id=%d completed OK.\n", ioc->name, id)); 4724 ddvprintk((MYIOC_s_NOTE_FMT "DV: Basic test on id=%d completed OK.\n", ioc->name, id));
5159 4725
5160 if (mpt_dv == 0) 4726 if (ioc->spi_data.mpt_dv == 0)
5161 goto target_done; 4727 goto target_done;
5162 4728
5163 inq0 = (*pbuf1) & 0x1F; 4729 inq0 = (*pbuf1) & 0x1F;
@@ -6015,7 +5581,29 @@ mptscsih_fillbuf(char *buffer, int size, int index, int width)
6015} 5581}
6016#endif /* ~MPTSCSIH_ENABLE_DOMAIN_VALIDATION */ 5582#endif /* ~MPTSCSIH_ENABLE_DOMAIN_VALIDATION */
6017 5583
6018/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 5584EXPORT_SYMBOL(mptscsih_remove);
5585EXPORT_SYMBOL(mptscsih_shutdown);
5586#ifdef CONFIG_PM
5587EXPORT_SYMBOL(mptscsih_suspend);
5588EXPORT_SYMBOL(mptscsih_resume);
5589#endif
5590EXPORT_SYMBOL(mptscsih_proc_info);
5591EXPORT_SYMBOL(mptscsih_info);
5592EXPORT_SYMBOL(mptscsih_qcmd);
5593EXPORT_SYMBOL(mptscsih_slave_alloc);
5594EXPORT_SYMBOL(mptscsih_slave_destroy);
5595EXPORT_SYMBOL(mptscsih_slave_configure);
5596EXPORT_SYMBOL(mptscsih_abort);
5597EXPORT_SYMBOL(mptscsih_dev_reset);
5598EXPORT_SYMBOL(mptscsih_bus_reset);
5599EXPORT_SYMBOL(mptscsih_host_reset);
5600EXPORT_SYMBOL(mptscsih_bios_param);
5601EXPORT_SYMBOL(mptscsih_io_done);
5602EXPORT_SYMBOL(mptscsih_taskmgmt_complete);
5603EXPORT_SYMBOL(mptscsih_scandv_complete);
5604EXPORT_SYMBOL(mptscsih_event_process);
5605EXPORT_SYMBOL(mptscsih_ioc_reset);
5606EXPORT_SYMBOL(mptscsih_store_queue_depth);
5607EXPORT_SYMBOL(mptscsih_timer_expired);
6019 5608
6020module_init(mptscsih_init); 5609/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
6021module_exit(mptscsih_exit);
diff --git a/drivers/message/fusion/mptscsih.h b/drivers/message/fusion/mptscsih.h
index 5cb2fd45c38f..9f519836effa 100644
--- a/drivers/message/fusion/mptscsih.h
+++ b/drivers/message/fusion/mptscsih.h
@@ -1,26 +1,13 @@
1/* 1/*
2 * linux/drivers/message/fusion/mptscsih.h 2 * linux/drivers/message/fusion/mptscsi.h
3 * High performance SCSI / Fibre Channel SCSI Host device driver. 3 * High performance SCSI / Fibre Channel SCSI Host device driver.
4 * For use with PCI chip/adapter(s): 4 * For use with PCI chip/adapter(s):
5 * LSIFC9xx/LSI409xx Fibre Channel 5 * LSIFC9xx/LSI409xx Fibre Channel
6 * running LSI Logic Fusion MPT (Message Passing Technology) firmware. 6 * running LSI Logic Fusion MPT (Message Passing Technology) firmware.
7 * 7 *
8 * Credits: 8 * 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 huge debt of gratitude is owed to David S. Miller (DaveM)
13 * for fixing much of the stupid and broken stuff in the early
14 * driver while porting to sparc64 platform. THANK YOU!
15 *
16 * (see also mptbase.c)
17 *
18 * Copyright (c) 1999-2004 LSI Logic Corporation
19 * Originally By: Steven J. Ralston
20 * (mailto:netscape.net)
21 * (mailto:mpt_linux_developer@lsil.com) 9 * (mailto:mpt_linux_developer@lsil.com)
22 * 10 *
23 * $Id: mptscsih.h,v 1.21 2002/12/03 21:26:35 pdelaney Exp $
24 */ 11 */
25/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 12/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
26/* 13/*
@@ -91,4 +78,30 @@
91#define MPTSCSIH_MIN_SYNC 0x08 78#define MPTSCSIH_MIN_SYNC 0x08
92#define MPTSCSIH_SAF_TE 0 79#define MPTSCSIH_SAF_TE 0
93 80
81
82#endif
83
84extern void mptscsih_remove(struct pci_dev *);
85extern void mptscsih_shutdown(struct device *);
86#ifdef CONFIG_PM
87extern int mptscsih_suspend(struct pci_dev *pdev, u32 state);
88extern int mptscsih_resume(struct pci_dev *pdev);
94#endif 89#endif
90extern int mptscsih_proc_info(struct Scsi_Host *host, char *buffer, char **start, off_t offset, int length, int func);
91extern const char * mptscsih_info(struct Scsi_Host *SChost);
92extern int mptscsih_qcmd(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *));
93extern int mptscsih_slave_alloc(struct scsi_device *device);
94extern void mptscsih_slave_destroy(struct scsi_device *device);
95extern int mptscsih_slave_configure(struct scsi_device *device);
96extern int mptscsih_abort(struct scsi_cmnd * SCpnt);
97extern int mptscsih_dev_reset(struct scsi_cmnd * SCpnt);
98extern int mptscsih_bus_reset(struct scsi_cmnd * SCpnt);
99extern int mptscsih_host_reset(struct scsi_cmnd *SCpnt);
100extern int mptscsih_bios_param(struct scsi_device * sdev, struct block_device *bdev, sector_t capacity, int geom[]);
101extern int mptscsih_io_done(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *r);
102extern int mptscsih_taskmgmt_complete(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *r);
103extern int mptscsih_scandv_complete(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *r);
104extern int mptscsih_event_process(MPT_ADAPTER *ioc, EventNotificationReply_t *pEvReply);
105extern int mptscsih_ioc_reset(MPT_ADAPTER *ioc, int post_reset);
106extern ssize_t mptscsih_store_queue_depth(struct device *dev, const char *buf, size_t count);
107extern void mptscsih_timer_expired(unsigned long data);