diff options
Diffstat (limited to 'drivers/message/fusion/mptscsih.c')
-rw-r--r-- | drivers/message/fusion/mptscsih.c | 793 |
1 files changed, 182 insertions, 611 deletions
diff --git a/drivers/message/fusion/mptscsih.c b/drivers/message/fusion/mptscsih.c index 3a3ef127df04..48ff314cdfbf 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); | |||
96 | MODULE_DESCRIPTION(my_NAME); | 75 | MODULE_DESCRIPTION(my_NAME); |
97 | MODULE_LICENSE("GPL"); | 76 | MODULE_LICENSE("GPL"); |
98 | 77 | ||
99 | /* Command line args */ | ||
100 | static int mpt_dv = MPTSCSIH_DOMAIN_VALIDATION; | ||
101 | MODULE_PARM(mpt_dv, "i"); | ||
102 | MODULE_PARM_DESC(mpt_dv, " DV Algorithm: enhanced=1, basic=0 (default=MPTSCSIH_DOMAIN_VALIDATION=1)"); | ||
103 | |||
104 | static int mpt_width = MPTSCSIH_MAX_WIDTH; | ||
105 | MODULE_PARM(mpt_width, "i"); | ||
106 | MODULE_PARM_DESC(mpt_width, " Max Bus Width: wide=1, narrow=0 (default=MPTSCSIH_MAX_WIDTH=1)"); | ||
107 | |||
108 | static int mpt_factor = MPTSCSIH_MIN_SYNC; | ||
109 | MODULE_PARM(mpt_factor, "h"); | ||
110 | MODULE_PARM_DESC(mpt_factor, " Min Sync Factor (default=MPTSCSIH_MIN_SYNC=0x08)"); | ||
111 | |||
112 | static int mpt_saf_te = MPTSCSIH_SAF_TE; | ||
113 | MODULE_PARM(mpt_saf_te, "i"); | ||
114 | MODULE_PARM_DESC(mpt_saf_te, " Force enabling SEP Processor: enable=1 (default=MPTSCSIH_SAF_TE=0)"); | ||
115 | |||
116 | static int mpt_pq_filter = 0; | ||
117 | MODULE_PARM(mpt_pq_filter, "i"); | ||
118 | MODULE_PARM_DESC(mpt_pq_filter, " Enable peripheral qualifier filter: enable=1 (default=0)"); | ||
119 | |||
120 | /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ | 78 | /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ |
121 | 79 | ||
122 | typedef struct _BIG_SENSE_BUF { | 80 | typedef 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 | */ |
176 | static int mptscsih_io_done(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *r); | 133 | int mptscsih_io_done(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *r); |
177 | static void mptscsih_report_queue_full(struct scsi_cmnd *sc, SCSIIOReply_t *pScsiReply, SCSIIORequest_t *pScsiReq); | 134 | static void mptscsih_report_queue_full(struct scsi_cmnd *sc, SCSIIOReply_t *pScsiReply, SCSIIORequest_t *pScsiReq); |
178 | static int mptscsih_taskmgmt_complete(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *r); | 135 | int mptscsih_taskmgmt_complete(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *r); |
179 | 136 | ||
180 | static int mptscsih_AddSGE(MPT_ADAPTER *ioc, struct scsi_cmnd *SCpnt, | 137 | static int mptscsih_AddSGE(MPT_ADAPTER *ioc, struct scsi_cmnd *SCpnt, |
181 | SCSIIORequest_t *pReq, int req_idx); | 138 | SCSIIORequest_t *pReq, int req_idx); |
182 | static void mptscsih_freeChainBuffers(MPT_ADAPTER *ioc, int req_idx); | 139 | static void mptscsih_freeChainBuffers(MPT_ADAPTER *ioc, int req_idx); |
183 | static void copy_sense_data(struct scsi_cmnd *sc, MPT_SCSI_HOST *hd, MPT_FRAME_HDR *mf, SCSIIOReply_t *pScsiReply); | 140 | static void mptscsih_copy_sense_data(struct scsi_cmnd *sc, MPT_SCSI_HOST *hd, MPT_FRAME_HDR *mf, SCSIIOReply_t *pScsiReply); |
184 | static int mptscsih_tm_pending_wait(MPT_SCSI_HOST * hd); | 141 | static int mptscsih_tm_pending_wait(MPT_SCSI_HOST * hd); |
185 | static int mptscsih_tm_wait_for_completion(MPT_SCSI_HOST * hd, ulong timeout ); | 142 | static int mptscsih_tm_wait_for_completion(MPT_SCSI_HOST * hd, ulong timeout ); |
186 | static u32 SCPNT_TO_LOOKUP_IDX(struct scsi_cmnd *sc); | 143 | static u32 SCPNT_TO_LOOKUP_IDX(struct scsi_cmnd *sc); |
@@ -188,8 +145,8 @@ static u32 SCPNT_TO_LOOKUP_IDX(struct scsi_cmnd *sc); | |||
188 | static int mptscsih_TMHandler(MPT_SCSI_HOST *hd, u8 type, u8 channel, u8 target, u8 lun, int ctx2abort, ulong timeout); | 145 | static int mptscsih_TMHandler(MPT_SCSI_HOST *hd, u8 type, u8 channel, u8 target, u8 lun, int ctx2abort, ulong timeout); |
189 | static int mptscsih_IssueTaskMgmt(MPT_SCSI_HOST *hd, u8 type, u8 channel, u8 target, u8 lun, int ctx2abort, ulong timeout); | 146 | static int mptscsih_IssueTaskMgmt(MPT_SCSI_HOST *hd, u8 type, u8 channel, u8 target, u8 lun, int ctx2abort, ulong timeout); |
190 | 147 | ||
191 | static int mptscsih_ioc_reset(MPT_ADAPTER *ioc, int post_reset); | 148 | int mptscsih_ioc_reset(MPT_ADAPTER *ioc, int post_reset); |
192 | static int mptscsih_event_process(MPT_ADAPTER *ioc, EventNotificationReply_t *pEvReply); | 149 | int mptscsih_event_process(MPT_ADAPTER *ioc, EventNotificationReply_t *pEvReply); |
193 | 150 | ||
194 | static void mptscsih_initTarget(MPT_SCSI_HOST *hd, int bus_id, int target_id, u8 lun, char *data, int dlen); | 151 | static void mptscsih_initTarget(MPT_SCSI_HOST *hd, int bus_id, int target_id, u8 lun, char *data, int dlen); |
195 | static void mptscsih_setTargetNegoParms(MPT_SCSI_HOST *hd, VirtDevice *target, char byte56); | 152 | static 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 | |||
198 | static void mptscsih_no_negotiate(MPT_SCSI_HOST *hd, int target_id); | 155 | static void mptscsih_no_negotiate(MPT_SCSI_HOST *hd, int target_id); |
199 | static int mptscsih_writeSDP1(MPT_SCSI_HOST *hd, int portnum, int target, int flags); | 156 | static int mptscsih_writeSDP1(MPT_SCSI_HOST *hd, int portnum, int target, int flags); |
200 | static int mptscsih_writeIOCPage4(MPT_SCSI_HOST *hd, int target_id, int bus); | 157 | static int mptscsih_writeIOCPage4(MPT_SCSI_HOST *hd, int target_id, int bus); |
201 | static int mptscsih_scandv_complete(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *r); | 158 | int mptscsih_scandv_complete(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *r); |
202 | static void mptscsih_timer_expired(unsigned long data); | ||
203 | static int mptscsih_do_cmd(MPT_SCSI_HOST *hd, INTERNAL_CMD *iocmd); | 159 | static int mptscsih_do_cmd(MPT_SCSI_HOST *hd, INTERNAL_CMD *iocmd); |
204 | static int mptscsih_synchronize_cache(MPT_SCSI_HOST *hd, int portnum); | 160 | static 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); | |||
212 | static void mptscsih_dv_parms(MPT_SCSI_HOST *hd, DVPARAMETERS *dv,void *pPage); | 168 | static void mptscsih_dv_parms(MPT_SCSI_HOST *hd, DVPARAMETERS *dv,void *pPage); |
213 | static void mptscsih_fillbuf(char *buffer, int size, int index, int width); | 169 | static void mptscsih_fillbuf(char *buffer, int size, int index, int width); |
214 | #endif | 170 | #endif |
215 | /* module entry point */ | ||
216 | static int __init mptscsih_init (void); | ||
217 | static void __exit mptscsih_exit (void); | ||
218 | 171 | ||
219 | static int mptscsih_probe (struct pci_dev *, const struct pci_device_id *); | 172 | void mptscsih_remove(struct pci_dev *); |
220 | static void mptscsih_remove(struct pci_dev *); | 173 | void mptscsih_shutdown(struct device *); |
221 | static void mptscsih_shutdown(struct device *); | ||
222 | #ifdef CONFIG_PM | 174 | #ifdef CONFIG_PM |
223 | static int mptscsih_suspend(struct pci_dev *pdev, pm_message_t state); | 175 | int mptscsih_suspend(struct pci_dev *pdev, pm_message_t state); |
224 | static int mptscsih_resume(struct pci_dev *pdev); | 176 | int mptscsih_resume(struct pci_dev *pdev); |
225 | #endif | 177 | #endif |
226 | 178 | ||
227 | |||
228 | /* | ||
229 | * Private data... | ||
230 | */ | ||
231 | |||
232 | static int mpt_scsi_hosts = 0; | ||
233 | |||
234 | static int ScsiDoneCtx = -1; | ||
235 | static int ScsiTaskCtx = -1; | ||
236 | static 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 */ | |||
244 | static DEFINE_SPINLOCK(dvtaskQ_lock); | 185 | static DEFINE_SPINLOCK(dvtaskQ_lock); |
245 | static int dvtaskQ_active = 0; | 186 | static int dvtaskQ_active = 0; |
246 | static int dvtaskQ_release = 0; | 187 | static int dvtaskQ_release = 0; |
247 | static struct work_struct mptscsih_dvTask; | 188 | static struct work_struct dvTaskQ_task; |
248 | #endif | 189 | #endif |
249 | 190 | ||
250 | /* | ||
251 | * Wait Queue setup | ||
252 | */ | ||
253 | static DECLARE_WAIT_QUEUE_HEAD (scandv_waitq); | ||
254 | static int scandv_wait_done = 1; | ||
255 | |||
256 | |||
257 | /* Driver command line structure | ||
258 | */ | ||
259 | static 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 | */ |
622 | static int | 552 | int |
623 | mptscsih_io_done(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *mr) | 553 | mptscsih_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 | */ | ||
988 | static long last_queue_full = 0; | ||
989 | 912 | ||
990 | /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ | 913 | /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ |
991 | /* | 914 | /* |
@@ -1003,280 +926,20 @@ static void | |||
1003 | mptscsih_report_queue_full(struct scsi_cmnd *sc, SCSIIOReply_t *pScsiReply, SCSIIORequest_t *pScsiReq) | 926 | mptscsih_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 | /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ | ||
1019 | static 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 | |||
1031 | static int | ||
1032 | mptscsih_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 | 930 | ||
1217 | /* Initialize this SCSI Hosts' timers | 931 | if (sc->device == NULL) |
1218 | * To use, set the timer expires field | 932 | return; |
1219 | * and add_timer | 933 | if (sc->device->host == NULL) |
1220 | */ | 934 | return; |
1221 | init_timer(&hd->timer); | 935 | if ((hd = (MPT_SCSI_HOST *)sc->device->host->hostdata) == NULL) |
1222 | hd->timer.data = (unsigned long) hd; | 936 | return; |
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 | |||
1275 | mptscsih_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 | */ |
1289 | static void | 952 | void |
1290 | mptscsih_remove(struct pci_dev *pdev) | 953 | mptscsih_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 | */ |
1365 | static void | 1028 | void |
1366 | mptscsih_shutdown(struct device * dev) | 1029 | mptscsih_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 | */ |
1391 | static int | 1054 | int |
1392 | mptscsih_suspend(struct pci_dev *pdev, pm_message_t state) | 1055 | mptscsih_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 | */ |
1404 | static int | 1067 | int |
1405 | mptscsih_resume(struct pci_dev *pdev) | 1068 | mptscsih_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 | ||
1438 | static 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 | */ | ||
1456 | static int __init | ||
1457 | mptscsih_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 | */ | ||
1492 | static void __exit | ||
1493 | mptscsih_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 | */ |
1523 | static const char * | 1112 | const char * |
1524 | mptscsih_info(struct Scsi_Host *SChost) | 1113 | mptscsih_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 | ||
1543 | struct info_str { | 1133 | struct info_str { |
@@ -1547,7 +1137,8 @@ struct info_str { | |||
1547 | int pos; | 1137 | int pos; |
1548 | }; | 1138 | }; |
1549 | 1139 | ||
1550 | static void copy_mem_info(struct info_str *info, char *data, int len) | 1140 | static void |
1141 | mptscsih_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 | ||
1571 | static int copy_info(struct info_str *info, char *fmt, ...) | 1162 | static int |
1163 | mptscsih_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 | ||
1585 | static int mptscsih_host_info(MPT_ADAPTER *ioc, char *pbuf, off_t offset, int len) | 1177 | static int |
1178 | mptscsih_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 | */ |
1615 | static int | 1208 | int |
1616 | mptscsih_proc_info(struct Scsi_Host *host, char *buffer, char **start, off_t offset, | 1209 | mptscsih_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 | */ |
1652 | static int | 1245 | int |
1653 | mptscsih_qcmd(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *)) | 1246 | mptscsih_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 | */ |
2110 | static int | 1702 | int |
2111 | mptscsih_abort(struct scsi_cmnd * SCpnt) | 1703 | mptscsih_abort(struct scsi_cmnd * SCpnt) |
2112 | { | 1704 | { |
2113 | MPT_SCSI_HOST *hd; | 1705 | MPT_SCSI_HOST *hd; |
@@ -2115,7 +1707,6 @@ mptscsih_abort(struct scsi_cmnd * SCpnt) | |||
2115 | MPT_FRAME_HDR *mf; | 1707 | MPT_FRAME_HDR *mf; |
2116 | u32 ctx2abort; | 1708 | u32 ctx2abort; |
2117 | int scpnt_idx; | 1709 | int scpnt_idx; |
2118 | spinlock_t *host_lock = SCpnt->device->host->host_lock; | ||
2119 | 1710 | ||
2120 | /* If we can't locate our host adapter structure, return FAILED status. | 1711 | /* If we can't locate our host adapter structure, return FAILED status. |
2121 | */ | 1712 | */ |
@@ -2163,7 +1754,6 @@ mptscsih_abort(struct scsi_cmnd * SCpnt) | |||
2163 | 1754 | ||
2164 | hd->abortSCpnt = SCpnt; | 1755 | hd->abortSCpnt = SCpnt; |
2165 | 1756 | ||
2166 | spin_unlock_irq(host_lock); | ||
2167 | if (mptscsih_TMHandler(hd, MPI_SCSITASKMGMT_TASKTYPE_ABORT_TASK, | 1757 | if (mptscsih_TMHandler(hd, MPI_SCSITASKMGMT_TASKTYPE_ABORT_TASK, |
2168 | SCpnt->device->channel, SCpnt->device->id, SCpnt->device->lun, | 1758 | SCpnt->device->channel, SCpnt->device->id, SCpnt->device->lun, |
2169 | ctx2abort, 2 /* 2 second timeout */) | 1759 | ctx2abort, 2 /* 2 second timeout */) |
@@ -2180,8 +1770,6 @@ mptscsih_abort(struct scsi_cmnd * SCpnt) | |||
2180 | hd->tmPending = 0; | 1770 | hd->tmPending = 0; |
2181 | hd->tmState = TM_STATE_NONE; | 1771 | hd->tmState = TM_STATE_NONE; |
2182 | 1772 | ||
2183 | spin_lock_irq(host_lock); | ||
2184 | |||
2185 | /* Unmap the DMA buffers, if any. */ | 1773 | /* Unmap the DMA buffers, if any. */ |
2186 | if (SCpnt->use_sg) { | 1774 | if (SCpnt->use_sg) { |
2187 | pci_unmap_sg(ioc->pcidev, (struct scatterlist *) SCpnt->request_buffer, | 1775 | pci_unmap_sg(ioc->pcidev, (struct scatterlist *) SCpnt->request_buffer, |
@@ -2197,7 +1785,6 @@ mptscsih_abort(struct scsi_cmnd * SCpnt) | |||
2197 | mpt_free_msg_frame(ioc, mf); | 1785 | mpt_free_msg_frame(ioc, mf); |
2198 | return FAILED; | 1786 | return FAILED; |
2199 | } | 1787 | } |
2200 | spin_lock_irq(host_lock); | ||
2201 | return SUCCESS; | 1788 | return SUCCESS; |
2202 | } | 1789 | } |
2203 | 1790 | ||
@@ -2210,11 +1797,10 @@ mptscsih_abort(struct scsi_cmnd * SCpnt) | |||
2210 | * | 1797 | * |
2211 | * Returns SUCCESS or FAILED. | 1798 | * Returns SUCCESS or FAILED. |
2212 | */ | 1799 | */ |
2213 | static int | 1800 | int |
2214 | mptscsih_dev_reset(struct scsi_cmnd * SCpnt) | 1801 | mptscsih_dev_reset(struct scsi_cmnd * SCpnt) |
2215 | { | 1802 | { |
2216 | MPT_SCSI_HOST *hd; | 1803 | MPT_SCSI_HOST *hd; |
2217 | spinlock_t *host_lock = SCpnt->device->host->host_lock; | ||
2218 | 1804 | ||
2219 | /* If we can't locate our host adapter structure, return FAILED status. | 1805 | /* If we can't locate our host adapter structure, return FAILED status. |
2220 | */ | 1806 | */ |
@@ -2231,7 +1817,6 @@ mptscsih_dev_reset(struct scsi_cmnd * SCpnt) | |||
2231 | printk(KERN_WARNING MYNAM ": %s: >> Attempting target reset! (sc=%p)\n", | 1817 | printk(KERN_WARNING MYNAM ": %s: >> Attempting target reset! (sc=%p)\n", |
2232 | hd->ioc->name, SCpnt); | 1818 | hd->ioc->name, SCpnt); |
2233 | 1819 | ||
2234 | spin_unlock_irq(host_lock); | ||
2235 | if (mptscsih_TMHandler(hd, MPI_SCSITASKMGMT_TASKTYPE_TARGET_RESET, | 1820 | if (mptscsih_TMHandler(hd, MPI_SCSITASKMGMT_TASKTYPE_TARGET_RESET, |
2236 | SCpnt->device->channel, SCpnt->device->id, | 1821 | SCpnt->device->channel, SCpnt->device->id, |
2237 | 0, 0, 5 /* 5 second timeout */) | 1822 | 0, 0, 5 /* 5 second timeout */) |
@@ -2243,12 +1828,10 @@ mptscsih_dev_reset(struct scsi_cmnd * SCpnt) | |||
2243 | hd->ioc->name, SCpnt); | 1828 | hd->ioc->name, SCpnt); |
2244 | hd->tmPending = 0; | 1829 | hd->tmPending = 0; |
2245 | hd->tmState = TM_STATE_NONE; | 1830 | hd->tmState = TM_STATE_NONE; |
2246 | spin_lock_irq(host_lock); | ||
2247 | return FAILED; | 1831 | return FAILED; |
2248 | } | 1832 | } |
2249 | spin_lock_irq(host_lock); | ||
2250 | return SUCCESS; | ||
2251 | 1833 | ||
1834 | return SUCCESS; | ||
2252 | } | 1835 | } |
2253 | 1836 | ||
2254 | /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ | 1837 | /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ |
@@ -2260,7 +1843,7 @@ mptscsih_dev_reset(struct scsi_cmnd * SCpnt) | |||
2260 | * | 1843 | * |
2261 | * Returns SUCCESS or FAILED. | 1844 | * Returns SUCCESS or FAILED. |
2262 | */ | 1845 | */ |
2263 | static int | 1846 | int |
2264 | mptscsih_bus_reset(struct scsi_cmnd * SCpnt) | 1847 | mptscsih_bus_reset(struct scsi_cmnd * SCpnt) |
2265 | { | 1848 | { |
2266 | MPT_SCSI_HOST *hd; | 1849 | MPT_SCSI_HOST *hd; |
@@ -2282,7 +1865,6 @@ mptscsih_bus_reset(struct scsi_cmnd * SCpnt) | |||
2282 | hd->timeouts++; | 1865 | hd->timeouts++; |
2283 | 1866 | ||
2284 | /* We are now ready to execute the task management request. */ | 1867 | /* We are now ready to execute the task management request. */ |
2285 | spin_unlock_irq(host_lock); | ||
2286 | if (mptscsih_TMHandler(hd, MPI_SCSITASKMGMT_TASKTYPE_RESET_BUS, | 1868 | if (mptscsih_TMHandler(hd, MPI_SCSITASKMGMT_TASKTYPE_RESET_BUS, |
2287 | SCpnt->device->channel, 0, 0, 0, 5 /* 5 second timeout */) | 1869 | SCpnt->device->channel, 0, 0, 0, 5 /* 5 second timeout */) |
2288 | < 0){ | 1870 | < 0){ |
@@ -2298,7 +1880,7 @@ mptscsih_bus_reset(struct scsi_cmnd * SCpnt) | |||
2298 | spin_lock_irq(host_lock); | 1880 | spin_lock_irq(host_lock); |
2299 | return FAILED; | 1881 | return FAILED; |
2300 | } | 1882 | } |
2301 | spin_lock_irq(host_lock); | 1883 | |
2302 | return SUCCESS; | 1884 | return SUCCESS; |
2303 | } | 1885 | } |
2304 | 1886 | ||
@@ -2312,12 +1894,11 @@ mptscsih_bus_reset(struct scsi_cmnd * SCpnt) | |||
2312 | * | 1894 | * |
2313 | * Returns SUCCESS or FAILED. | 1895 | * Returns SUCCESS or FAILED. |
2314 | */ | 1896 | */ |
2315 | static int | 1897 | int |
2316 | mptscsih_host_reset(struct scsi_cmnd *SCpnt) | 1898 | mptscsih_host_reset(struct scsi_cmnd *SCpnt) |
2317 | { | 1899 | { |
2318 | MPT_SCSI_HOST * hd; | 1900 | MPT_SCSI_HOST * hd; |
2319 | int status = SUCCESS; | 1901 | int status = SUCCESS; |
2320 | spinlock_t *host_lock = SCpnt->device->host->host_lock; | ||
2321 | 1902 | ||
2322 | /* If we can't locate the host to reset, then we failed. */ | 1903 | /* If we can't locate the host to reset, then we failed. */ |
2323 | if ((hd = (MPT_SCSI_HOST *) SCpnt->device->host->hostdata) == NULL){ | 1904 | if ((hd = (MPT_SCSI_HOST *) SCpnt->device->host->hostdata) == NULL){ |
@@ -2333,7 +1914,6 @@ mptscsih_host_reset(struct scsi_cmnd *SCpnt) | |||
2333 | /* If our attempts to reset the host failed, then return a failed | 1914 | /* If our attempts to reset the host failed, then return a failed |
2334 | * status. The host will be taken off line by the SCSI mid-layer. | 1915 | * status. The host will be taken off line by the SCSI mid-layer. |
2335 | */ | 1916 | */ |
2336 | spin_unlock_irq(host_lock); | ||
2337 | if (mpt_HardResetHandler(hd->ioc, CAN_SLEEP) < 0){ | 1917 | if (mpt_HardResetHandler(hd->ioc, CAN_SLEEP) < 0){ |
2338 | status = FAILED; | 1918 | status = FAILED; |
2339 | } else { | 1919 | } else { |
@@ -2343,8 +1923,6 @@ mptscsih_host_reset(struct scsi_cmnd *SCpnt) | |||
2343 | hd->tmPending = 0; | 1923 | hd->tmPending = 0; |
2344 | hd->tmState = TM_STATE_NONE; | 1924 | hd->tmState = TM_STATE_NONE; |
2345 | } | 1925 | } |
2346 | spin_lock_irq(host_lock); | ||
2347 | |||
2348 | 1926 | ||
2349 | dtmprintk( ( KERN_WARNING MYNAM ": mptscsih_host_reset: " | 1927 | dtmprintk( ( KERN_WARNING MYNAM ": mptscsih_host_reset: " |
2350 | "Status = %s\n", | 1928 | "Status = %s\n", |
@@ -2426,7 +2004,7 @@ mptscsih_tm_wait_for_completion(MPT_SCSI_HOST * hd, ulong timeout ) | |||
2426 | * | 2004 | * |
2427 | * Returns 1 indicating alloc'd request frame ptr should be freed. | 2005 | * Returns 1 indicating alloc'd request frame ptr should be freed. |
2428 | */ | 2006 | */ |
2429 | static int | 2007 | int |
2430 | mptscsih_taskmgmt_complete(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *mr) | 2008 | mptscsih_taskmgmt_complete(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *mr) |
2431 | { | 2009 | { |
2432 | SCSITaskMgmtReply_t *pScsiTmReply; | 2010 | SCSITaskMgmtReply_t *pScsiTmReply; |
@@ -2509,7 +2087,7 @@ mptscsih_taskmgmt_complete(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *m | |||
2509 | /* | 2087 | /* |
2510 | * This is anyones guess quite frankly. | 2088 | * This is anyones guess quite frankly. |
2511 | */ | 2089 | */ |
2512 | static int | 2090 | int |
2513 | mptscsih_bios_param(struct scsi_device * sdev, struct block_device *bdev, | 2091 | mptscsih_bios_param(struct scsi_device * sdev, struct block_device *bdev, |
2514 | sector_t capacity, int geom[]) | 2092 | sector_t capacity, int geom[]) |
2515 | { | 2093 | { |
@@ -2556,7 +2134,7 @@ mptscsih_bios_param(struct scsi_device * sdev, struct block_device *bdev, | |||
2556 | * Return non-zero if allocation fails. | 2134 | * Return non-zero if allocation fails. |
2557 | * Init memory once per id (not LUN). | 2135 | * Init memory once per id (not LUN). |
2558 | */ | 2136 | */ |
2559 | static int | 2137 | int |
2560 | mptscsih_slave_alloc(struct scsi_device *device) | 2138 | mptscsih_slave_alloc(struct scsi_device *device) |
2561 | { | 2139 | { |
2562 | struct Scsi_Host *host = device->host; | 2140 | struct Scsi_Host *host = device->host; |
@@ -2599,7 +2177,8 @@ mptscsih_slave_alloc(struct scsi_device *device) | |||
2599 | return 0; | 2177 | return 0; |
2600 | } | 2178 | } |
2601 | 2179 | ||
2602 | static int mptscsih_is_raid_volume(MPT_SCSI_HOST *hd, uint id) | 2180 | static int |
2181 | mptscsih_is_raid_volume(MPT_SCSI_HOST *hd, uint id) | ||
2603 | { | 2182 | { |
2604 | int i; | 2183 | int i; |
2605 | 2184 | ||
@@ -2618,7 +2197,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 | 2197 | * OS entry point to allow for host driver to free allocated memory |
2619 | * Called if no device present or device being unloaded | 2198 | * Called if no device present or device being unloaded |
2620 | */ | 2199 | */ |
2621 | static void | 2200 | void |
2622 | mptscsih_slave_destroy(struct scsi_device *device) | 2201 | mptscsih_slave_destroy(struct scsi_device *device) |
2623 | { | 2202 | { |
2624 | struct Scsi_Host *host = device->host; | 2203 | struct Scsi_Host *host = device->host; |
@@ -2639,7 +2218,7 @@ mptscsih_slave_destroy(struct scsi_device *device) | |||
2639 | 2218 | ||
2640 | kfree(hd->Targets[target]); | 2219 | kfree(hd->Targets[target]); |
2641 | hd->Targets[target] = NULL; | 2220 | hd->Targets[target] = NULL; |
2642 | 2221 | ||
2643 | if (hd->ioc->bus_type == SCSI) { | 2222 | if (hd->ioc->bus_type == SCSI) { |
2644 | if (mptscsih_is_raid_volume(hd, target)) { | 2223 | if (mptscsih_is_raid_volume(hd, target)) { |
2645 | hd->ioc->spi_data.forceDv |= MPT_SCSICFG_RELOAD_IOC_PG3; | 2224 | hd->ioc->spi_data.forceDv |= MPT_SCSICFG_RELOAD_IOC_PG3; |
@@ -2695,7 +2274,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. | 2274 | * member to 1 if a device does not support Q tags. |
2696 | * Return non-zero if fails. | 2275 | * Return non-zero if fails. |
2697 | */ | 2276 | */ |
2698 | static int | 2277 | int |
2699 | mptscsih_slave_configure(struct scsi_device *device) | 2278 | mptscsih_slave_configure(struct scsi_device *device) |
2700 | { | 2279 | { |
2701 | struct Scsi_Host *sh = device->host; | 2280 | struct Scsi_Host *sh = device->host; |
@@ -2758,7 +2337,7 @@ slave_configure_exit: | |||
2758 | return 0; | 2337 | return 0; |
2759 | } | 2338 | } |
2760 | 2339 | ||
2761 | static ssize_t | 2340 | ssize_t |
2762 | mptscsih_store_queue_depth(struct device *dev, const char *buf, size_t count) | 2341 | mptscsih_store_queue_depth(struct device *dev, const char *buf, size_t count) |
2763 | { | 2342 | { |
2764 | int depth; | 2343 | int depth; |
@@ -2788,7 +2367,7 @@ mptscsih_store_queue_depth(struct device *dev, const char *buf, size_t count) | |||
2788 | * | 2367 | * |
2789 | */ | 2368 | */ |
2790 | static void | 2369 | static void |
2791 | copy_sense_data(struct scsi_cmnd *sc, MPT_SCSI_HOST *hd, MPT_FRAME_HDR *mf, SCSIIOReply_t *pScsiReply) | 2370 | mptscsih_copy_sense_data(struct scsi_cmnd *sc, MPT_SCSI_HOST *hd, MPT_FRAME_HDR *mf, SCSIIOReply_t *pScsiReply) |
2792 | { | 2371 | { |
2793 | VirtDevice *target; | 2372 | VirtDevice *target; |
2794 | SCSIIORequest_t *pReq; | 2373 | SCSIIORequest_t *pReq; |
@@ -2854,7 +2433,7 @@ SCPNT_TO_LOOKUP_IDX(struct scsi_cmnd *sc) | |||
2854 | } | 2433 | } |
2855 | 2434 | ||
2856 | /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ | 2435 | /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ |
2857 | static int | 2436 | int |
2858 | mptscsih_ioc_reset(MPT_ADAPTER *ioc, int reset_phase) | 2437 | mptscsih_ioc_reset(MPT_ADAPTER *ioc, int reset_phase) |
2859 | { | 2438 | { |
2860 | MPT_SCSI_HOST *hd; | 2439 | MPT_SCSI_HOST *hd; |
@@ -2949,8 +2528,8 @@ mptscsih_ioc_reset(MPT_ADAPTER *ioc, int reset_phase) | |||
2949 | */ | 2528 | */ |
2950 | hd->pLocal = &hd->localReply; | 2529 | hd->pLocal = &hd->localReply; |
2951 | hd->pLocal->completion = MPT_SCANDV_DID_RESET; | 2530 | hd->pLocal->completion = MPT_SCANDV_DID_RESET; |
2952 | scandv_wait_done = 1; | 2531 | hd->scandv_wait_done = 1; |
2953 | wake_up(&scandv_waitq); | 2532 | wake_up(&hd->scandv_waitq); |
2954 | hd->cmdPtr = NULL; | 2533 | hd->cmdPtr = NULL; |
2955 | } | 2534 | } |
2956 | 2535 | ||
@@ -2969,7 +2548,7 @@ mptscsih_ioc_reset(MPT_ADAPTER *ioc, int reset_phase) | |||
2969 | } | 2548 | } |
2970 | 2549 | ||
2971 | /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ | 2550 | /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ |
2972 | static int | 2551 | int |
2973 | mptscsih_event_process(MPT_ADAPTER *ioc, EventNotificationReply_t *pEvReply) | 2552 | mptscsih_event_process(MPT_ADAPTER *ioc, EventNotificationReply_t *pEvReply) |
2974 | { | 2553 | { |
2975 | MPT_SCSI_HOST *hd; | 2554 | MPT_SCSI_HOST *hd; |
@@ -3085,42 +2664,6 @@ mptscsih_event_process(MPT_ADAPTER *ioc, EventNotificationReply_t *pEvReply) | |||
3085 | return 1; /* currently means nothing really */ | 2664 | return 1; /* currently means nothing really */ |
3086 | } | 2665 | } |
3087 | 2666 | ||
3088 | static 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 | |||
3096 | static struct device_attribute *mptscsih_dev_attrs[] = { | ||
3097 | &mptscsih_queue_depth_attr, | ||
3098 | NULL, | ||
3099 | }; | ||
3100 | |||
3101 | static 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 | /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ | 2667 | /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ |
3125 | /* | 2668 | /* |
3126 | * mptscsih_initTarget - Target, LUN alloc/free functionality. | 2669 | * mptscsih_initTarget - Target, LUN alloc/free functionality. |
@@ -3158,9 +2701,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 | 2701 | * 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. | 2702 | * continue to try to communicate to the LUN and evntually create a dummy LUN. |
3160 | */ | 2703 | */ |
3161 | if (mpt_pq_filter && dlen && (data[0] & 0xE0)) | 2704 | if (hd->mpt_pq_filter && dlen && (data[0] & 0xE0)) |
3162 | data[0] |= 0x40; | 2705 | data[0] |= 0x40; |
3163 | 2706 | ||
3164 | /* Is LUN supported? If so, upper 2 bits will be 0 | 2707 | /* Is LUN supported? If so, upper 2 bits will be 0 |
3165 | * in first byte of inquiry data. | 2708 | * in first byte of inquiry data. |
3166 | */ | 2709 | */ |
@@ -3307,7 +2850,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)); | 2850 | ddvtprintk((KERN_INFO "Enabling QAS on id=%d due to ~TARGET_FLAGS_VALID_56!\n", id)); |
3308 | noQas = 0; | 2851 | noQas = 0; |
3309 | } | 2852 | } |
3310 | 2853 | ||
3311 | offset = pspi_data->maxSyncOffset; | 2854 | offset = pspi_data->maxSyncOffset; |
3312 | 2855 | ||
3313 | /* If RAID, never disable QAS | 2856 | /* If RAID, never disable QAS |
@@ -3401,7 +2944,7 @@ mptscsih_setTargetNegoParms(MPT_SCSI_HOST *hd, VirtDevice *target, char byte56) | |||
3401 | if ( (vdev = hd->Targets[ii]) ) { | 2944 | if ( (vdev = hd->Targets[ii]) ) { |
3402 | vdev->negoFlags |= MPT_TARGET_NO_NEGO_QAS; | 2945 | vdev->negoFlags |= MPT_TARGET_NO_NEGO_QAS; |
3403 | mptscsih_writeSDP1(hd, 0, ii, vdev->negoFlags); | 2946 | mptscsih_writeSDP1(hd, 0, ii, vdev->negoFlags); |
3404 | } | 2947 | } |
3405 | } | 2948 | } |
3406 | } | 2949 | } |
3407 | } | 2950 | } |
@@ -3426,14 +2969,15 @@ mptscsih_setTargetNegoParms(MPT_SCSI_HOST *hd, VirtDevice *target, char byte56) | |||
3426 | * Tapes, initTarget will set this flag on completion of Inquiry command. | 2969 | * Tapes, initTarget will set this flag on completion of Inquiry command. |
3427 | * Called only if DV_NOT_DONE flag is set | 2970 | * Called only if DV_NOT_DONE flag is set |
3428 | */ | 2971 | */ |
3429 | static void mptscsih_set_dvflags(MPT_SCSI_HOST *hd, SCSIIORequest_t *pReq) | 2972 | static void |
2973 | mptscsih_set_dvflags(MPT_SCSI_HOST *hd, SCSIIORequest_t *pReq) | ||
3430 | { | 2974 | { |
3431 | u8 cmd; | 2975 | u8 cmd; |
3432 | ScsiCfgData *pSpi; | 2976 | ScsiCfgData *pSpi; |
3433 | 2977 | ||
3434 | ddvtprintk((" set_dvflags: id=%d lun=%d negoNvram=%x cmd=%x\n", | 2978 | ddvtprintk((" set_dvflags: id=%d lun=%d negoNvram=%x cmd=%x\n", |
3435 | pReq->TargetID, pReq->LUN[1], hd->negoNvram, pReq->CDB[0])); | 2979 | pReq->TargetID, pReq->LUN[1], hd->negoNvram, pReq->CDB[0])); |
3436 | 2980 | ||
3437 | if ((pReq->LUN[1] != 0) || (hd->negoNvram != 0)) | 2981 | if ((pReq->LUN[1] != 0) || (hd->negoNvram != 0)) |
3438 | return; | 2982 | return; |
3439 | 2983 | ||
@@ -3464,7 +3008,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 | 3008 | * If no Target, bus reset on 1st I/O. Set the flag to |
3465 | * prevent any future negotiations to this device. | 3009 | * prevent any future negotiations to this device. |
3466 | */ | 3010 | */ |
3467 | static void mptscsih_no_negotiate(MPT_SCSI_HOST *hd, int target_id) | 3011 | static void |
3012 | mptscsih_no_negotiate(MPT_SCSI_HOST *hd, int target_id) | ||
3468 | { | 3013 | { |
3469 | 3014 | ||
3470 | if ((hd->Targets) && (hd->Targets[target_id] == NULL)) | 3015 | if ((hd->Targets) && (hd->Targets[target_id] == NULL)) |
@@ -3631,7 +3176,7 @@ mptscsih_writeSDP1(MPT_SCSI_HOST *hd, int portnum, int target_id, int flags) | |||
3631 | offset = pTarget->maxOffset; | 3176 | offset = pTarget->maxOffset; |
3632 | negoFlags = pTarget->negoFlags; | 3177 | negoFlags = pTarget->negoFlags; |
3633 | } | 3178 | } |
3634 | 3179 | ||
3635 | #ifdef MPTSCSIH_ENABLE_DOMAIN_VALIDATION | 3180 | #ifdef MPTSCSIH_ENABLE_DOMAIN_VALIDATION |
3636 | /* Force to async and narrow if DV has not been executed | 3181 | /* Force to async and narrow if DV has not been executed |
3637 | * for this ID | 3182 | * for this ID |
@@ -3653,7 +3198,7 @@ mptscsih_writeSDP1(MPT_SCSI_HOST *hd, int portnum, int target_id, int flags) | |||
3653 | 3198 | ||
3654 | /* Get a MF for this command. | 3199 | /* Get a MF for this command. |
3655 | */ | 3200 | */ |
3656 | if ((mf = mpt_get_msg_frame(ScsiDoneCtx, ioc)) == NULL) { | 3201 | if ((mf = mpt_get_msg_frame(ioc->DoneCtx, ioc)) == NULL) { |
3657 | dprintk((MYIOC_s_WARN_FMT "write SDP1: no msg frames!\n", | 3202 | dprintk((MYIOC_s_WARN_FMT "write SDP1: no msg frames!\n", |
3658 | ioc->name)); | 3203 | ioc->name)); |
3659 | return -EAGAIN; | 3204 | return -EAGAIN; |
@@ -3717,7 +3262,7 @@ mptscsih_writeSDP1(MPT_SCSI_HOST *hd, int portnum, int target_id, int flags) | |||
3717 | ioc->name, id, (id | (bus<<8)), | 3262 | ioc->name, id, (id | (bus<<8)), |
3718 | requested, configuration)); | 3263 | requested, configuration)); |
3719 | 3264 | ||
3720 | mpt_put_msg_frame(ScsiDoneCtx, ioc, mf); | 3265 | mpt_put_msg_frame(ioc->DoneCtx, ioc, mf); |
3721 | } | 3266 | } |
3722 | 3267 | ||
3723 | return 0; | 3268 | return 0; |
@@ -3748,7 +3293,7 @@ mptscsih_writeIOCPage4(MPT_SCSI_HOST *hd, int target_id, int bus) | |||
3748 | 3293 | ||
3749 | /* Get a MF for this command. | 3294 | /* Get a MF for this command. |
3750 | */ | 3295 | */ |
3751 | if ((mf = mpt_get_msg_frame(ScsiDoneCtx, ioc)) == NULL) { | 3296 | if ((mf = mpt_get_msg_frame(ioc->DoneCtx, ioc)) == NULL) { |
3752 | dprintk((MYIOC_s_WARN_FMT "writeIOCPage4 : no msg frames!\n", | 3297 | dprintk((MYIOC_s_WARN_FMT "writeIOCPage4 : no msg frames!\n", |
3753 | ioc->name)); | 3298 | ioc->name)); |
3754 | return -EAGAIN; | 3299 | return -EAGAIN; |
@@ -3794,7 +3339,7 @@ mptscsih_writeIOCPage4(MPT_SCSI_HOST *hd, int target_id, int bus) | |||
3794 | "writeIOCPage4: MaxSEP=%d ActiveSEP=%d id=%d bus=%d\n", | 3339 | "writeIOCPage4: MaxSEP=%d ActiveSEP=%d id=%d bus=%d\n", |
3795 | ioc->name, IOCPage4Ptr->MaxSEP, IOCPage4Ptr->ActiveSEP, target_id, bus)); | 3340 | ioc->name, IOCPage4Ptr->MaxSEP, IOCPage4Ptr->ActiveSEP, target_id, bus)); |
3796 | 3341 | ||
3797 | mpt_put_msg_frame(ScsiDoneCtx, ioc, mf); | 3342 | mpt_put_msg_frame(ioc->DoneCtx, ioc, mf); |
3798 | 3343 | ||
3799 | return 0; | 3344 | return 0; |
3800 | } | 3345 | } |
@@ -3824,7 +3369,7 @@ mptscsih_writeIOCPage4(MPT_SCSI_HOST *hd, int target_id, int bus) | |||
3824 | * in the IOC member localReply structure. | 3369 | * in the IOC member localReply structure. |
3825 | * Used ONLY for DV and other internal commands. | 3370 | * Used ONLY for DV and other internal commands. |
3826 | */ | 3371 | */ |
3827 | static int | 3372 | int |
3828 | mptscsih_scandv_complete(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *mr) | 3373 | mptscsih_scandv_complete(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *mr) |
3829 | { | 3374 | { |
3830 | MPT_SCSI_HOST *hd; | 3375 | MPT_SCSI_HOST *hd; |
@@ -3832,6 +3377,8 @@ mptscsih_scandv_complete(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *mr) | |||
3832 | int completionCode; | 3377 | int completionCode; |
3833 | u16 req_idx; | 3378 | u16 req_idx; |
3834 | 3379 | ||
3380 | hd = (MPT_SCSI_HOST *) ioc->sh->hostdata; | ||
3381 | |||
3835 | if ((mf == NULL) || | 3382 | if ((mf == NULL) || |
3836 | (mf >= MPT_INDEX_2_MFPTR(ioc, ioc->req_depth))) { | 3383 | (mf >= MPT_INDEX_2_MFPTR(ioc, ioc->req_depth))) { |
3837 | printk(MYIOC_s_ERR_FMT | 3384 | printk(MYIOC_s_ERR_FMT |
@@ -3840,7 +3387,6 @@ mptscsih_scandv_complete(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *mr) | |||
3840 | goto wakeup; | 3387 | goto wakeup; |
3841 | } | 3388 | } |
3842 | 3389 | ||
3843 | hd = (MPT_SCSI_HOST *) ioc->sh->hostdata; | ||
3844 | del_timer(&hd->timer); | 3390 | del_timer(&hd->timer); |
3845 | req_idx = le16_to_cpu(mf->u.frame.hwhdr.msgctxu.fld.req_idx); | 3391 | req_idx = le16_to_cpu(mf->u.frame.hwhdr.msgctxu.fld.req_idx); |
3846 | hd->ScsiLookup[req_idx] = NULL; | 3392 | hd->ScsiLookup[req_idx] = NULL; |
@@ -3972,8 +3518,8 @@ wakeup: | |||
3972 | /* | 3518 | /* |
3973 | * Wake up the original calling thread | 3519 | * Wake up the original calling thread |
3974 | */ | 3520 | */ |
3975 | scandv_wait_done = 1; | 3521 | hd->scandv_wait_done = 1; |
3976 | wake_up(&scandv_waitq); | 3522 | wake_up(&hd->scandv_waitq); |
3977 | 3523 | ||
3978 | return 1; | 3524 | return 1; |
3979 | } | 3525 | } |
@@ -3984,7 +3530,8 @@ wakeup: | |||
3984 | * @data: Pointer to MPT_SCSI_HOST recast as an unsigned long | 3530 | * @data: Pointer to MPT_SCSI_HOST recast as an unsigned long |
3985 | * | 3531 | * |
3986 | */ | 3532 | */ |
3987 | static void mptscsih_timer_expired(unsigned long data) | 3533 | void |
3534 | mptscsih_timer_expired(unsigned long data) | ||
3988 | { | 3535 | { |
3989 | MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *) data; | 3536 | MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *) data; |
3990 | 3537 | ||
@@ -4051,7 +3598,7 @@ mptscsih_do_raid(MPT_SCSI_HOST *hd, u8 action, INTERNAL_CMD *io) | |||
4051 | 3598 | ||
4052 | /* Get and Populate a free Frame | 3599 | /* Get and Populate a free Frame |
4053 | */ | 3600 | */ |
4054 | if ((mf = mpt_get_msg_frame(ScsiScanDvCtx, hd->ioc)) == NULL) { | 3601 | if ((mf = mpt_get_msg_frame(hd->ioc->InternalCtx, hd->ioc)) == NULL) { |
4055 | ddvprintk((MYIOC_s_WARN_FMT "_do_raid: no msg frames!\n", | 3602 | ddvprintk((MYIOC_s_WARN_FMT "_do_raid: no msg frames!\n", |
4056 | hd->ioc->name)); | 3603 | hd->ioc->name)); |
4057 | return -EAGAIN; | 3604 | return -EAGAIN; |
@@ -4077,7 +3624,7 @@ mptscsih_do_raid(MPT_SCSI_HOST *hd, u8 action, INTERNAL_CMD *io) | |||
4077 | 3624 | ||
4078 | hd->pLocal = NULL; | 3625 | hd->pLocal = NULL; |
4079 | hd->timer.expires = jiffies + HZ*10; /* 10 second timeout */ | 3626 | hd->timer.expires = jiffies + HZ*10; /* 10 second timeout */ |
4080 | scandv_wait_done = 0; | 3627 | hd->scandv_wait_done = 0; |
4081 | 3628 | ||
4082 | /* Save cmd pointer, for resource free if timeout or | 3629 | /* Save cmd pointer, for resource free if timeout or |
4083 | * FW reload occurs | 3630 | * FW reload occurs |
@@ -4085,8 +3632,8 @@ mptscsih_do_raid(MPT_SCSI_HOST *hd, u8 action, INTERNAL_CMD *io) | |||
4085 | hd->cmdPtr = mf; | 3632 | hd->cmdPtr = mf; |
4086 | 3633 | ||
4087 | add_timer(&hd->timer); | 3634 | add_timer(&hd->timer); |
4088 | mpt_put_msg_frame(ScsiScanDvCtx, hd->ioc, mf); | 3635 | mpt_put_msg_frame(hd->ioc->InternalCtx, hd->ioc, mf); |
4089 | wait_event(scandv_waitq, scandv_wait_done); | 3636 | wait_event(hd->scandv_waitq, hd->scandv_wait_done); |
4090 | 3637 | ||
4091 | if ((hd->pLocal == NULL) || (hd->pLocal->completion != MPT_SCANDV_GOOD)) | 3638 | if ((hd->pLocal == NULL) || (hd->pLocal->completion != MPT_SCANDV_GOOD)) |
4092 | return -1; | 3639 | return -1; |
@@ -4232,7 +3779,7 @@ mptscsih_do_cmd(MPT_SCSI_HOST *hd, INTERNAL_CMD *io) | |||
4232 | 3779 | ||
4233 | /* Get and Populate a free Frame | 3780 | /* Get and Populate a free Frame |
4234 | */ | 3781 | */ |
4235 | if ((mf = mpt_get_msg_frame(ScsiScanDvCtx, hd->ioc)) == NULL) { | 3782 | if ((mf = mpt_get_msg_frame(hd->ioc->InternalCtx, hd->ioc)) == NULL) { |
4236 | ddvprintk((MYIOC_s_WARN_FMT "No msg frames!\n", | 3783 | ddvprintk((MYIOC_s_WARN_FMT "No msg frames!\n", |
4237 | hd->ioc->name)); | 3784 | hd->ioc->name)); |
4238 | return -EBUSY; | 3785 | return -EBUSY; |
@@ -4314,7 +3861,7 @@ mptscsih_do_cmd(MPT_SCSI_HOST *hd, INTERNAL_CMD *io) | |||
4314 | */ | 3861 | */ |
4315 | hd->pLocal = NULL; | 3862 | hd->pLocal = NULL; |
4316 | hd->timer.expires = jiffies + HZ*cmdTimeout; | 3863 | hd->timer.expires = jiffies + HZ*cmdTimeout; |
4317 | scandv_wait_done = 0; | 3864 | hd->scandv_wait_done = 0; |
4318 | 3865 | ||
4319 | /* Save cmd pointer, for resource free if timeout or | 3866 | /* Save cmd pointer, for resource free if timeout or |
4320 | * FW reload occurs | 3867 | * FW reload occurs |
@@ -4322,8 +3869,8 @@ mptscsih_do_cmd(MPT_SCSI_HOST *hd, INTERNAL_CMD *io) | |||
4322 | hd->cmdPtr = mf; | 3869 | hd->cmdPtr = mf; |
4323 | 3870 | ||
4324 | add_timer(&hd->timer); | 3871 | add_timer(&hd->timer); |
4325 | mpt_put_msg_frame(ScsiScanDvCtx, hd->ioc, mf); | 3872 | mpt_put_msg_frame(hd->ioc->InternalCtx, hd->ioc, mf); |
4326 | wait_event(scandv_waitq, scandv_wait_done); | 3873 | wait_event(hd->scandv_waitq, hd->scandv_wait_done); |
4327 | 3874 | ||
4328 | if (hd->pLocal) { | 3875 | if (hd->pLocal) { |
4329 | rc = hd->pLocal->completion; | 3876 | rc = hd->pLocal->completion; |
@@ -4640,7 +4187,8 @@ mptscsih_domainValidation(void *arg) | |||
4640 | 4187 | ||
4641 | /* Search IOC page 3 to determine if this is hidden physical disk | 4188 | /* Search IOC page 3 to determine if this is hidden physical disk |
4642 | */ | 4189 | */ |
4643 | static int mptscsih_is_phys_disk(MPT_ADAPTER *ioc, int id) | 4190 | static int |
4191 | mptscsih_is_phys_disk(MPT_ADAPTER *ioc, int id) | ||
4644 | { | 4192 | { |
4645 | if (ioc->spi_data.pIocPg3) { | 4193 | if (ioc->spi_data.pIocPg3) { |
4646 | Ioc3PhysDisk_t *pPDisk = ioc->spi_data.pIocPg3->PhysDisk; | 4194 | Ioc3PhysDisk_t *pPDisk = ioc->spi_data.pIocPg3->PhysDisk; |
@@ -4659,7 +4207,8 @@ static int mptscsih_is_phys_disk(MPT_ADAPTER *ioc, int id) | |||
4659 | 4207 | ||
4660 | /* Write SDP1 if no QAS has been enabled | 4208 | /* Write SDP1 if no QAS has been enabled |
4661 | */ | 4209 | */ |
4662 | static void mptscsih_qas_check(MPT_SCSI_HOST *hd, int id) | 4210 | static void |
4211 | mptscsih_qas_check(MPT_SCSI_HOST *hd, int id) | ||
4663 | { | 4212 | { |
4664 | VirtDevice *pTarget; | 4213 | VirtDevice *pTarget; |
4665 | int ii; | 4214 | int ii; |
@@ -5157,7 +4706,7 @@ mptscsih_doDv(MPT_SCSI_HOST *hd, int bus_number, int id) | |||
5157 | } | 4706 | } |
5158 | ddvprintk((MYIOC_s_NOTE_FMT "DV: Basic test on id=%d completed OK.\n", ioc->name, id)); | 4707 | ddvprintk((MYIOC_s_NOTE_FMT "DV: Basic test on id=%d completed OK.\n", ioc->name, id)); |
5159 | 4708 | ||
5160 | if (mpt_dv == 0) | 4709 | if (ioc->spi_data.mpt_dv == 0) |
5161 | goto target_done; | 4710 | goto target_done; |
5162 | 4711 | ||
5163 | inq0 = (*pbuf1) & 0x1F; | 4712 | inq0 = (*pbuf1) & 0x1F; |
@@ -6015,7 +5564,29 @@ mptscsih_fillbuf(char *buffer, int size, int index, int width) | |||
6015 | } | 5564 | } |
6016 | #endif /* ~MPTSCSIH_ENABLE_DOMAIN_VALIDATION */ | 5565 | #endif /* ~MPTSCSIH_ENABLE_DOMAIN_VALIDATION */ |
6017 | 5566 | ||
6018 | /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ | 5567 | EXPORT_SYMBOL(mptscsih_remove); |
5568 | EXPORT_SYMBOL(mptscsih_shutdown); | ||
5569 | #ifdef CONFIG_PM | ||
5570 | EXPORT_SYMBOL(mptscsih_suspend); | ||
5571 | EXPORT_SYMBOL(mptscsih_resume); | ||
5572 | #endif | ||
5573 | EXPORT_SYMBOL(mptscsih_proc_info); | ||
5574 | EXPORT_SYMBOL(mptscsih_info); | ||
5575 | EXPORT_SYMBOL(mptscsih_qcmd); | ||
5576 | EXPORT_SYMBOL(mptscsih_slave_alloc); | ||
5577 | EXPORT_SYMBOL(mptscsih_slave_destroy); | ||
5578 | EXPORT_SYMBOL(mptscsih_slave_configure); | ||
5579 | EXPORT_SYMBOL(mptscsih_abort); | ||
5580 | EXPORT_SYMBOL(mptscsih_dev_reset); | ||
5581 | EXPORT_SYMBOL(mptscsih_bus_reset); | ||
5582 | EXPORT_SYMBOL(mptscsih_host_reset); | ||
5583 | EXPORT_SYMBOL(mptscsih_bios_param); | ||
5584 | EXPORT_SYMBOL(mptscsih_io_done); | ||
5585 | EXPORT_SYMBOL(mptscsih_taskmgmt_complete); | ||
5586 | EXPORT_SYMBOL(mptscsih_scandv_complete); | ||
5587 | EXPORT_SYMBOL(mptscsih_event_process); | ||
5588 | EXPORT_SYMBOL(mptscsih_ioc_reset); | ||
5589 | EXPORT_SYMBOL(mptscsih_store_queue_depth); | ||
5590 | EXPORT_SYMBOL(mptscsih_timer_expired); | ||
6019 | 5591 | ||
6020 | module_init(mptscsih_init); | 5592 | /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ |
6021 | module_exit(mptscsih_exit); | ||