diff options
author | Kashyap, Desai <kashyap.desai@lsi.com> | 2009-05-29 07:16:50 -0400 |
---|---|---|
committer | James Bottomley <James.Bottomley@HansenPartnership.com> | 2009-06-09 18:29:45 -0400 |
commit | ea2a788de4ce5ebab09276e25443f55592af2335 (patch) | |
tree | 22f062d2cd47ec004ddfa7ef05ec548e7ada5f45 /drivers | |
parent | e7deff3374cc5951f914dcb3c66bc1b8de8a084e (diff) |
[SCSI] mpt fusion: rewrite of ioctl_cmds internal generated function
1) rewrite of ioctl_cmds internal generated function that issue commands to
firmware, porting them to be single threaded using the generic MPT_MGMT
struct. All wait Queues are replace by completion Queue.
2) added seperate callback handler for ioctl task managment
(mptctl_taskmgmt_reply), to handle command that timeout
3) rewrite mptctl_bus_reset
Signed-off-by: Kashyap Desai <kadesai@lsi.com>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/message/fusion/mptbase.h | 21 | ||||
-rw-r--r-- | drivers/message/fusion/mptctl.c | 650 | ||||
-rw-r--r-- | drivers/message/fusion/mptfc.c | 2 | ||||
-rw-r--r-- | drivers/message/fusion/mptsas.c | 37 | ||||
-rw-r--r-- | drivers/message/fusion/mptscsih.c | 2 | ||||
-rw-r--r-- | drivers/message/fusion/mptspi.c | 2 |
6 files changed, 394 insertions, 320 deletions
diff --git a/drivers/message/fusion/mptbase.h b/drivers/message/fusion/mptbase.h index a0bf7d88fcfc..24d60128bfe6 100644 --- a/drivers/message/fusion/mptbase.h +++ b/drivers/message/fusion/mptbase.h | |||
@@ -434,18 +434,6 @@ do { \ | |||
434 | 434 | ||
435 | #define MPTCTL_RESET_OK 0x01 /* Issue Bus Reset */ | 435 | #define MPTCTL_RESET_OK 0x01 /* Issue Bus Reset */ |
436 | 436 | ||
437 | typedef struct _MPT_IOCTL { | ||
438 | struct _MPT_ADAPTER *ioc; | ||
439 | u8 ReplyFrame[MPT_DEFAULT_FRAME_SIZE]; /* reply frame data */ | ||
440 | u8 sense[MPT_SENSE_BUFFER_ALLOC]; | ||
441 | int wait_done; /* wake-up value for this ioc */ | ||
442 | u8 rsvd; | ||
443 | u8 status; /* current command status */ | ||
444 | u8 reset; /* 1 if bus reset allowed */ | ||
445 | u8 id; /* target for reset */ | ||
446 | struct mutex ioctl_mutex; | ||
447 | } MPT_IOCTL; | ||
448 | |||
449 | #define MPT_MGMT_STATUS_RF_VALID 0x01 /* The Reply Frame is VALID */ | 437 | #define MPT_MGMT_STATUS_RF_VALID 0x01 /* The Reply Frame is VALID */ |
450 | #define MPT_MGMT_STATUS_COMMAND_GOOD 0x02 /* Command Status GOOD */ | 438 | #define MPT_MGMT_STATUS_COMMAND_GOOD 0x02 /* Command Status GOOD */ |
451 | #define MPT_MGMT_STATUS_PENDING 0x04 /* command is pending */ | 439 | #define MPT_MGMT_STATUS_PENDING 0x04 /* command is pending */ |
@@ -460,6 +448,10 @@ typedef struct _MPT_IOCTL { | |||
460 | status = MPT_MGMT_STATUS_PENDING; | 448 | status = MPT_MGMT_STATUS_PENDING; |
461 | #define CLEAR_MGMT_STATUS(status) \ | 449 | #define CLEAR_MGMT_STATUS(status) \ |
462 | status = 0; | 450 | status = 0; |
451 | #define CLEAR_MGMT_PENDING_STATUS(status) \ | ||
452 | status &= ~MPT_MGMT_STATUS_PENDING; | ||
453 | #define SET_MGMT_MSG_CONTEXT(msg_context, value) \ | ||
454 | msg_context = value; | ||
463 | 455 | ||
464 | typedef struct _MPT_MGMT { | 456 | typedef struct _MPT_MGMT { |
465 | struct mutex mutex; | 457 | struct mutex mutex; |
@@ -468,6 +460,7 @@ typedef struct _MPT_MGMT { | |||
468 | u8 sense[MPT_SENSE_BUFFER_ALLOC]; | 460 | u8 sense[MPT_SENSE_BUFFER_ALLOC]; |
469 | u8 status; /* current command status */ | 461 | u8 status; /* current command status */ |
470 | int completion_code; | 462 | int completion_code; |
463 | u32 msg_context; | ||
471 | } MPT_MGMT; | 464 | } MPT_MGMT; |
472 | 465 | ||
473 | /* | 466 | /* |
@@ -654,7 +647,6 @@ typedef struct _MPT_ADAPTER | |||
654 | RaidCfgData raid_data; /* Raid config. data */ | 647 | RaidCfgData raid_data; /* Raid config. data */ |
655 | SasCfgData sas_data; /* Sas config. data */ | 648 | SasCfgData sas_data; /* Sas config. data */ |
656 | FcCfgData fc_data; /* Fc config. data */ | 649 | FcCfgData fc_data; /* Fc config. data */ |
657 | MPT_IOCTL *ioctl; /* ioctl data pointer */ | ||
658 | struct proc_dir_entry *ioc_dentry; | 650 | struct proc_dir_entry *ioc_dentry; |
659 | struct _MPT_ADAPTER *alt_ioc; /* ptr to 929 bound adapter port */ | 651 | struct _MPT_ADAPTER *alt_ioc; /* ptr to 929 bound adapter port */ |
660 | u32 biosVersion; /* BIOS version from IO Unit Page 2 */ | 652 | u32 biosVersion; /* BIOS version from IO Unit Page 2 */ |
@@ -711,6 +703,7 @@ typedef struct _MPT_ADAPTER | |||
711 | MPT_MGMT mptbase_cmds; /* for sending config pages */ | 703 | MPT_MGMT mptbase_cmds; /* for sending config pages */ |
712 | MPT_MGMT internal_cmds; | 704 | MPT_MGMT internal_cmds; |
713 | MPT_MGMT taskmgmt_cmds; | 705 | MPT_MGMT taskmgmt_cmds; |
706 | MPT_MGMT ioctl_cmds; | ||
714 | spinlock_t taskmgmt_lock; /* diagnostic reset lock */ | 707 | spinlock_t taskmgmt_lock; /* diagnostic reset lock */ |
715 | int taskmgmt_in_progress; | 708 | int taskmgmt_in_progress; |
716 | u8 taskmgmt_quiesce_io; | 709 | u8 taskmgmt_quiesce_io; |
@@ -855,10 +848,8 @@ typedef struct _MPT_SCSI_HOST { | |||
855 | /* Pool of memory for holding SCpnts before doing | 848 | /* Pool of memory for holding SCpnts before doing |
856 | * OS callbacks. freeQ is the free pool. | 849 | * OS callbacks. freeQ is the free pool. |
857 | */ | 850 | */ |
858 | u8 tmPending; | ||
859 | u8 negoNvram; /* DV disabled, nego NVRAM */ | 851 | u8 negoNvram; /* DV disabled, nego NVRAM */ |
860 | u8 pad1; | 852 | u8 pad1; |
861 | u8 tmState; | ||
862 | u8 rsvd[2]; | 853 | u8 rsvd[2]; |
863 | MPT_FRAME_HDR *cmdPtr; /* Ptr to nonOS request */ | 854 | MPT_FRAME_HDR *cmdPtr; /* Ptr to nonOS request */ |
864 | struct scsi_cmnd *abortSCpnt; | 855 | struct scsi_cmnd *abortSCpnt; |
diff --git a/drivers/message/fusion/mptctl.c b/drivers/message/fusion/mptctl.c index 22b75cb647e8..ab620132d9a9 100644 --- a/drivers/message/fusion/mptctl.c +++ b/drivers/message/fusion/mptctl.c | |||
@@ -84,6 +84,7 @@ MODULE_VERSION(my_VERSION); | |||
84 | /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ | 84 | /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ |
85 | 85 | ||
86 | static u8 mptctl_id = MPT_MAX_PROTOCOL_DRIVERS; | 86 | static u8 mptctl_id = MPT_MAX_PROTOCOL_DRIVERS; |
87 | static u8 mptctl_taskmgmt_id = MPT_MAX_PROTOCOL_DRIVERS; | ||
87 | 88 | ||
88 | static DECLARE_WAIT_QUEUE_HEAD ( mptctl_wait ); | 89 | static DECLARE_WAIT_QUEUE_HEAD ( mptctl_wait ); |
89 | 90 | ||
@@ -127,10 +128,7 @@ static MptSge_t *kbuf_alloc_2_sgl(int bytes, u32 dir, int sge_offset, int *frags | |||
127 | struct buflist **blp, dma_addr_t *sglbuf_dma, MPT_ADAPTER *ioc); | 128 | struct buflist **blp, dma_addr_t *sglbuf_dma, MPT_ADAPTER *ioc); |
128 | static void kfree_sgl(MptSge_t *sgl, dma_addr_t sgl_dma, | 129 | static void kfree_sgl(MptSge_t *sgl, dma_addr_t sgl_dma, |
129 | struct buflist *buflist, MPT_ADAPTER *ioc); | 130 | struct buflist *buflist, MPT_ADAPTER *ioc); |
130 | static void mptctl_timeout_expired (MPT_IOCTL *ioctl); | 131 | static int mptctl_bus_reset(MPT_ADAPTER *ioc, u8 function); |
131 | static int mptctl_bus_reset(MPT_IOCTL *ioctl); | ||
132 | static int mptctl_set_tm_flags(MPT_SCSI_HOST *hd); | ||
133 | static void mptctl_free_tm_flags(MPT_ADAPTER *ioc); | ||
134 | 132 | ||
135 | /* | 133 | /* |
136 | * Reset Handler cleanup function | 134 | * Reset Handler cleanup function |
@@ -183,10 +181,10 @@ mptctl_syscall_down(MPT_ADAPTER *ioc, int nonblock) | |||
183 | int rc = 0; | 181 | int rc = 0; |
184 | 182 | ||
185 | if (nonblock) { | 183 | if (nonblock) { |
186 | if (!mutex_trylock(&ioc->ioctl->ioctl_mutex)) | 184 | if (!mutex_trylock(&ioc->ioctl_cmds.mutex)) |
187 | rc = -EAGAIN; | 185 | rc = -EAGAIN; |
188 | } else { | 186 | } else { |
189 | if (mutex_lock_interruptible(&ioc->ioctl->ioctl_mutex)) | 187 | if (mutex_lock_interruptible(&ioc->ioctl_cmds.mutex)) |
190 | rc = -ERESTARTSYS; | 188 | rc = -ERESTARTSYS; |
191 | } | 189 | } |
192 | return rc; | 190 | return rc; |
@@ -202,100 +200,78 @@ mptctl_syscall_down(MPT_ADAPTER *ioc, int nonblock) | |||
202 | static int | 200 | static int |
203 | mptctl_reply(MPT_ADAPTER *ioc, MPT_FRAME_HDR *req, MPT_FRAME_HDR *reply) | 201 | mptctl_reply(MPT_ADAPTER *ioc, MPT_FRAME_HDR *req, MPT_FRAME_HDR *reply) |
204 | { | 202 | { |
205 | char *sense_data; | 203 | char *sense_data; |
206 | int sz, req_index; | 204 | int req_index; |
207 | u16 iocStatus; | 205 | int sz; |
208 | u8 cmd; | ||
209 | 206 | ||
210 | if (req) | 207 | if (!req) |
211 | cmd = req->u.hdr.Function; | 208 | return 0; |
212 | else | ||
213 | return 1; | ||
214 | dctlprintk(ioc, printk(MYIOC_s_DEBUG_FMT "\tcompleting mpi function (0x%02X), req=%p, " | ||
215 | "reply=%p\n", ioc->name, req->u.hdr.Function, req, reply)); | ||
216 | |||
217 | if (ioc->ioctl) { | ||
218 | |||
219 | if (reply==NULL) { | ||
220 | |||
221 | dctlprintk(ioc, printk(MYIOC_s_DEBUG_FMT "mptctl_reply() NULL Reply " | ||
222 | "Function=%x!\n", ioc->name, cmd)); | ||
223 | 209 | ||
224 | ioc->ioctl->status |= MPT_MGMT_STATUS_COMMAND_GOOD; | 210 | dctlprintk(ioc, printk(MYIOC_s_DEBUG_FMT "completing mpi function " |
225 | ioc->ioctl->reset &= ~MPTCTL_RESET_OK; | 211 | "(0x%02X), req=%p, reply=%p\n", ioc->name, req->u.hdr.Function, |
212 | req, reply)); | ||
226 | 213 | ||
227 | /* We are done, issue wake up | 214 | /* |
228 | */ | 215 | * Handling continuation of the same reply. Processing the first |
229 | ioc->ioctl->wait_done = 1; | 216 | * reply, and eating the other replys that come later. |
230 | wake_up (&mptctl_wait); | 217 | */ |
231 | return 1; | 218 | if (ioc->ioctl_cmds.msg_context != req->u.hdr.MsgContext) |
219 | goto out_continuation; | ||
232 | 220 | ||
233 | } | 221 | ioc->ioctl_cmds.status |= MPT_MGMT_STATUS_COMMAND_GOOD; |
234 | 222 | ||
235 | /* Copy the reply frame (which much exist | 223 | if (!reply) |
236 | * for non-SCSI I/O) to the IOC structure. | 224 | goto out; |
237 | */ | ||
238 | memcpy(ioc->ioctl->ReplyFrame, reply, | ||
239 | min(ioc->reply_sz, 4*reply->u.reply.MsgLength)); | ||
240 | ioc->ioctl->status |= MPT_MGMT_STATUS_RF_VALID; | ||
241 | 225 | ||
242 | /* Set the command status to GOOD if IOC Status is GOOD | 226 | ioc->ioctl_cmds.status |= MPT_MGMT_STATUS_RF_VALID; |
243 | * OR if SCSI I/O cmd and data underrun or recovered error. | 227 | sz = min(ioc->reply_sz, 4*reply->u.reply.MsgLength); |
244 | */ | 228 | memcpy(ioc->ioctl_cmds.reply, reply, sz); |
245 | iocStatus = le16_to_cpu(reply->u.reply.IOCStatus) & MPI_IOCSTATUS_MASK; | ||
246 | if (iocStatus == MPI_IOCSTATUS_SUCCESS) | ||
247 | ioc->ioctl->status |= MPT_MGMT_STATUS_COMMAND_GOOD; | ||
248 | |||
249 | if (iocStatus || reply->u.reply.IOCLogInfo) | ||
250 | dctlprintk(ioc, printk(MYIOC_s_DEBUG_FMT "\tiocstatus (0x%04X), " | ||
251 | "loginfo (0x%08X)\n", ioc->name, | ||
252 | iocStatus, | ||
253 | le32_to_cpu(reply->u.reply.IOCLogInfo))); | ||
254 | |||
255 | if ((cmd == MPI_FUNCTION_SCSI_IO_REQUEST) || | ||
256 | (cmd == MPI_FUNCTION_RAID_SCSI_IO_PASSTHROUGH)) { | ||
257 | |||
258 | if (reply->u.sreply.SCSIStatus || reply->u.sreply.SCSIState) | ||
259 | dctlprintk(ioc, printk(MYIOC_s_DEBUG_FMT | ||
260 | "\tscsi_status (0x%02x), scsi_state (0x%02x), " | ||
261 | "tag = (0x%04x), transfer_count (0x%08x)\n", ioc->name, | ||
262 | reply->u.sreply.SCSIStatus, | ||
263 | reply->u.sreply.SCSIState, | ||
264 | le16_to_cpu(reply->u.sreply.TaskTag), | ||
265 | le32_to_cpu(reply->u.sreply.TransferCount))); | ||
266 | |||
267 | ioc->ioctl->reset &= ~MPTCTL_RESET_OK; | ||
268 | |||
269 | if ((iocStatus == MPI_IOCSTATUS_SCSI_DATA_UNDERRUN) || | ||
270 | (iocStatus == MPI_IOCSTATUS_SCSI_RECOVERED_ERROR)) { | ||
271 | ioc->ioctl->status |= | ||
272 | MPT_MGMT_STATUS_COMMAND_GOOD; | ||
273 | } | ||
274 | } | ||
275 | 229 | ||
276 | /* Copy the sense data - if present | 230 | if (reply->u.reply.IOCStatus || reply->u.reply.IOCLogInfo) |
277 | */ | 231 | dctlprintk(ioc, printk(MYIOC_s_DEBUG_FMT |
278 | if ((cmd == MPI_FUNCTION_SCSI_IO_REQUEST) && | 232 | "iocstatus (0x%04X), loginfo (0x%08X)\n", ioc->name, |
279 | (reply->u.sreply.SCSIState & | 233 | le16_to_cpu(reply->u.reply.IOCStatus), |
280 | MPI_SCSI_STATE_AUTOSENSE_VALID)){ | 234 | le32_to_cpu(reply->u.reply.IOCLogInfo))); |
235 | |||
236 | if ((req->u.hdr.Function == MPI_FUNCTION_SCSI_IO_REQUEST) || | ||
237 | (req->u.hdr.Function == | ||
238 | MPI_FUNCTION_RAID_SCSI_IO_PASSTHROUGH)) { | ||
239 | |||
240 | if (reply->u.sreply.SCSIStatus || reply->u.sreply.SCSIState) | ||
241 | dctlprintk(ioc, printk(MYIOC_s_DEBUG_FMT | ||
242 | "scsi_status (0x%02x), scsi_state (0x%02x), " | ||
243 | "tag = (0x%04x), transfer_count (0x%08x)\n", ioc->name, | ||
244 | reply->u.sreply.SCSIStatus, | ||
245 | reply->u.sreply.SCSIState, | ||
246 | le16_to_cpu(reply->u.sreply.TaskTag), | ||
247 | le32_to_cpu(reply->u.sreply.TransferCount))); | ||
248 | |||
249 | if (reply->u.sreply.SCSIState & | ||
250 | MPI_SCSI_STATE_AUTOSENSE_VALID) { | ||
281 | sz = req->u.scsireq.SenseBufferLength; | 251 | sz = req->u.scsireq.SenseBufferLength; |
282 | req_index = | 252 | req_index = |
283 | le16_to_cpu(req->u.frame.hwhdr.msgctxu.fld.req_idx); | 253 | le16_to_cpu(req->u.frame.hwhdr.msgctxu.fld.req_idx); |
284 | sense_data = | 254 | sense_data = ((u8 *)ioc->sense_buf_pool + |
285 | ((u8 *)ioc->sense_buf_pool + | ||
286 | (req_index * MPT_SENSE_BUFFER_ALLOC)); | 255 | (req_index * MPT_SENSE_BUFFER_ALLOC)); |
287 | memcpy(ioc->ioctl->sense, sense_data, sz); | 256 | memcpy(ioc->ioctl_cmds.sense, sense_data, sz); |
288 | ioc->ioctl->status |= MPT_MGMT_STATUS_SENSE_VALID; | 257 | ioc->ioctl_cmds.status |= MPT_MGMT_STATUS_SENSE_VALID; |
289 | } | 258 | } |
259 | } | ||
290 | 260 | ||
291 | if (cmd == MPI_FUNCTION_SCSI_TASK_MGMT) | 261 | out: |
292 | mptctl_free_tm_flags(ioc); | 262 | /* We are done, issue wake up |
293 | 263 | */ | |
294 | /* We are done, issue wake up | 264 | if (ioc->ioctl_cmds.status & MPT_MGMT_STATUS_PENDING) { |
295 | */ | 265 | if (req->u.hdr.Function == MPI_FUNCTION_SCSI_TASK_MGMT) |
296 | ioc->ioctl->wait_done = 1; | 266 | mpt_clear_taskmgmt_in_progress_flag(ioc); |
297 | wake_up (&mptctl_wait); | 267 | ioc->ioctl_cmds.status &= ~MPT_MGMT_STATUS_PENDING; |
268 | complete(&ioc->ioctl_cmds.done); | ||
298 | } | 269 | } |
270 | |||
271 | out_continuation: | ||
272 | if (reply && (reply->u.reply.MsgFlags & | ||
273 | MPI_MSGFLAGS_CONTINUATION_REPLY)) | ||
274 | return 0; | ||
299 | return 1; | 275 | return 1; |
300 | } | 276 | } |
301 | 277 | ||
@@ -305,30 +281,66 @@ mptctl_reply(MPT_ADAPTER *ioc, MPT_FRAME_HDR *req, MPT_FRAME_HDR *reply) | |||
305 | * Expecting an interrupt, however timed out. | 281 | * Expecting an interrupt, however timed out. |
306 | * | 282 | * |
307 | */ | 283 | */ |
308 | static void mptctl_timeout_expired (MPT_IOCTL *ioctl) | 284 | static void |
285 | mptctl_timeout_expired(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf) | ||
309 | { | 286 | { |
310 | int rc = 1; | 287 | unsigned long flags; |
311 | 288 | ||
312 | if (ioctl == NULL) | 289 | dtmprintk(ioc, printk(MYIOC_s_DEBUG_FMT ": %s\n", |
313 | return; | 290 | ioc->name, __func__)); |
314 | dctlprintk(ioctl->ioc, | ||
315 | printk(MYIOC_s_DEBUG_FMT ": Timeout Expired! Host %d\n", | ||
316 | ioctl->ioc->name, ioctl->ioc->id)); | ||
317 | 291 | ||
318 | ioctl->wait_done = 0; | 292 | if (mpt_fwfault_debug) |
319 | if (ioctl->reset & MPTCTL_RESET_OK) | 293 | mpt_halt_firmware(ioc); |
320 | rc = mptctl_bus_reset(ioctl); | ||
321 | 294 | ||
322 | if (rc) { | 295 | spin_lock_irqsave(&ioc->taskmgmt_lock, flags); |
323 | /* Issue a reset for this device. | 296 | if (ioc->ioc_reset_in_progress) { |
324 | * The IOC is not responding. | 297 | spin_unlock_irqrestore(&ioc->taskmgmt_lock, flags); |
325 | */ | 298 | CLEAR_MGMT_PENDING_STATUS(ioc->ioctl_cmds.status) |
326 | dctlprintk(ioctl->ioc, printk(MYIOC_s_DEBUG_FMT "Calling HardReset! \n", | 299 | mpt_free_msg_frame(ioc, mf); |
327 | ioctl->ioc->name)); | 300 | return; |
328 | mpt_HardResetHandler(ioctl->ioc, CAN_SLEEP); | ||
329 | } | 301 | } |
330 | return; | 302 | spin_unlock_irqrestore(&ioc->taskmgmt_lock, flags); |
303 | |||
331 | 304 | ||
305 | if (!mptctl_bus_reset(ioc, mf->u.hdr.Function)) | ||
306 | return; | ||
307 | |||
308 | /* Issue a reset for this device. | ||
309 | * The IOC is not responding. | ||
310 | */ | ||
311 | dtmprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Calling HardReset! \n", | ||
312 | ioc->name)); | ||
313 | CLEAR_MGMT_PENDING_STATUS(ioc->ioctl_cmds.status) | ||
314 | mpt_HardResetHandler(ioc, CAN_SLEEP); | ||
315 | mpt_free_msg_frame(ioc, mf); | ||
316 | } | ||
317 | |||
318 | static int | ||
319 | mptctl_taskmgmt_reply(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *mr) | ||
320 | { | ||
321 | if (!mf) | ||
322 | return 0; | ||
323 | |||
324 | dtmprintk(ioc, printk(MYIOC_s_DEBUG_FMT | ||
325 | "TaskMgmt completed (mf=%p, mr=%p)\n", | ||
326 | ioc->name, mf, mr)); | ||
327 | |||
328 | ioc->taskmgmt_cmds.status |= MPT_MGMT_STATUS_COMMAND_GOOD; | ||
329 | |||
330 | if (!mr) | ||
331 | goto out; | ||
332 | |||
333 | ioc->taskmgmt_cmds.status |= MPT_MGMT_STATUS_RF_VALID; | ||
334 | memcpy(ioc->taskmgmt_cmds.reply, mr, | ||
335 | min(MPT_DEFAULT_FRAME_SIZE, 4 * mr->u.reply.MsgLength)); | ||
336 | out: | ||
337 | if (ioc->taskmgmt_cmds.status & MPT_MGMT_STATUS_PENDING) { | ||
338 | mpt_clear_taskmgmt_in_progress_flag(ioc); | ||
339 | ioc->taskmgmt_cmds.status &= ~MPT_MGMT_STATUS_PENDING; | ||
340 | complete(&ioc->taskmgmt_cmds.done); | ||
341 | return 1; | ||
342 | } | ||
343 | return 0; | ||
332 | } | 344 | } |
333 | 345 | ||
334 | /* mptctl_bus_reset | 346 | /* mptctl_bus_reset |
@@ -336,133 +348,150 @@ static void mptctl_timeout_expired (MPT_IOCTL *ioctl) | |||
336 | * Bus reset code. | 348 | * Bus reset code. |
337 | * | 349 | * |
338 | */ | 350 | */ |
339 | static int mptctl_bus_reset(MPT_IOCTL *ioctl) | 351 | static int mptctl_bus_reset(MPT_ADAPTER *ioc, u8 function) |
340 | { | 352 | { |
341 | MPT_FRAME_HDR *mf; | 353 | MPT_FRAME_HDR *mf; |
342 | SCSITaskMgmt_t *pScsiTm; | 354 | SCSITaskMgmt_t *pScsiTm; |
343 | MPT_SCSI_HOST *hd; | 355 | SCSITaskMgmtReply_t *pScsiTmReply; |
344 | int ii; | 356 | int ii; |
345 | int retval=0; | 357 | int retval; |
346 | 358 | unsigned long timeout; | |
347 | 359 | unsigned long time_count; | |
348 | ioctl->reset &= ~MPTCTL_RESET_OK; | 360 | u16 iocstatus; |
349 | 361 | ||
350 | if (ioctl->ioc->sh == NULL) | 362 | /* bus reset is only good for SCSI IO, RAID PASSTHRU */ |
363 | if (!(function == MPI_FUNCTION_RAID_SCSI_IO_PASSTHROUGH) || | ||
364 | (function == MPI_FUNCTION_SCSI_IO_REQUEST)) { | ||
365 | dtmprintk(ioc, printk(MYIOC_s_WARN_FMT | ||
366 | "TaskMgmt, not SCSI_IO!!\n", ioc->name)); | ||
351 | return -EPERM; | 367 | return -EPERM; |
368 | } | ||
352 | 369 | ||
353 | hd = shost_priv(ioctl->ioc->sh); | 370 | mutex_lock(&ioc->taskmgmt_cmds.mutex); |
354 | if (hd == NULL) | 371 | if (mpt_set_taskmgmt_in_progress_flag(ioc) != 0) { |
372 | mutex_unlock(&ioc->taskmgmt_cmds.mutex); | ||
355 | return -EPERM; | 373 | return -EPERM; |
374 | } | ||
356 | 375 | ||
357 | /* Single threading .... | 376 | retval = 0; |
358 | */ | ||
359 | if (mptctl_set_tm_flags(hd) != 0) | ||
360 | return -EPERM; | ||
361 | 377 | ||
362 | /* Send request | 378 | /* Send request |
363 | */ | 379 | */ |
364 | if ((mf = mpt_get_msg_frame(mptctl_id, ioctl->ioc)) == NULL) { | 380 | mf = mpt_get_msg_frame(mptctl_taskmgmt_id, ioc); |
365 | dtmprintk(ioctl->ioc, printk(MYIOC_s_DEBUG_FMT "IssueTaskMgmt, no msg frames!!\n", | 381 | if (mf == NULL) { |
366 | ioctl->ioc->name)); | 382 | dtmprintk(ioc, printk(MYIOC_s_WARN_FMT |
367 | 383 | "TaskMgmt, no msg frames!!\n", ioc->name)); | |
368 | mptctl_free_tm_flags(ioctl->ioc); | 384 | mpt_clear_taskmgmt_in_progress_flag(ioc); |
369 | return -ENOMEM; | 385 | retval = -ENOMEM; |
386 | goto mptctl_bus_reset_done; | ||
370 | } | 387 | } |
371 | 388 | ||
372 | dtmprintk(ioctl->ioc, printk(MYIOC_s_DEBUG_FMT "IssueTaskMgmt request @ %p\n", | 389 | dtmprintk(ioc, printk(MYIOC_s_DEBUG_FMT "TaskMgmt request (mf=%p)\n", |
373 | ioctl->ioc->name, mf)); | 390 | ioc->name, mf)); |
374 | 391 | ||
375 | pScsiTm = (SCSITaskMgmt_t *) mf; | 392 | pScsiTm = (SCSITaskMgmt_t *) mf; |
376 | pScsiTm->TargetID = ioctl->id; | 393 | memset(pScsiTm, 0, sizeof(SCSITaskMgmt_t)); |
377 | pScsiTm->Bus = hd->port; /* 0 */ | ||
378 | pScsiTm->ChainOffset = 0; | ||
379 | pScsiTm->Function = MPI_FUNCTION_SCSI_TASK_MGMT; | 394 | pScsiTm->Function = MPI_FUNCTION_SCSI_TASK_MGMT; |
380 | pScsiTm->Reserved = 0; | ||
381 | pScsiTm->TaskType = MPI_SCSITASKMGMT_TASKTYPE_RESET_BUS; | 395 | pScsiTm->TaskType = MPI_SCSITASKMGMT_TASKTYPE_RESET_BUS; |
382 | pScsiTm->Reserved1 = 0; | ||
383 | pScsiTm->MsgFlags = MPI_SCSITASKMGMT_MSGFLAGS_LIPRESET_RESET_OPTION; | 396 | pScsiTm->MsgFlags = MPI_SCSITASKMGMT_MSGFLAGS_LIPRESET_RESET_OPTION; |
384 | 397 | pScsiTm->TargetID = 0; | |
398 | pScsiTm->Bus = 0; | ||
399 | pScsiTm->ChainOffset = 0; | ||
400 | pScsiTm->Reserved = 0; | ||
401 | pScsiTm->Reserved1 = 0; | ||
402 | pScsiTm->TaskMsgContext = 0; | ||
385 | for (ii= 0; ii < 8; ii++) | 403 | for (ii= 0; ii < 8; ii++) |
386 | pScsiTm->LUN[ii] = 0; | 404 | pScsiTm->LUN[ii] = 0; |
387 | |||
388 | for (ii=0; ii < 7; ii++) | 405 | for (ii=0; ii < 7; ii++) |
389 | pScsiTm->Reserved2[ii] = 0; | 406 | pScsiTm->Reserved2[ii] = 0; |
390 | 407 | ||
391 | pScsiTm->TaskMsgContext = 0; | 408 | switch (ioc->bus_type) { |
392 | dtmprintk(ioctl->ioc, printk(MYIOC_s_DEBUG_FMT | 409 | case FC: |
393 | "mptctl_bus_reset: issued.\n", ioctl->ioc->name)); | 410 | timeout = 40; |
394 | 411 | break; | |
395 | DBG_DUMP_TM_REQUEST_FRAME(ioctl->ioc, (u32 *)mf); | 412 | case SAS: |
413 | timeout = 30; | ||
414 | break; | ||
415 | case SPI: | ||
416 | default: | ||
417 | timeout = 2; | ||
418 | break; | ||
419 | } | ||
396 | 420 | ||
397 | ioctl->wait_done=0; | 421 | dtmprintk(ioc, printk(MYIOC_s_DEBUG_FMT |
422 | "TaskMgmt type=%d timeout=%ld\n", | ||
423 | ioc->name, MPI_SCSITASKMGMT_TASKTYPE_RESET_BUS, timeout)); | ||
398 | 424 | ||
399 | if ((ioctl->ioc->facts.IOCCapabilities & MPI_IOCFACTS_CAPABILITY_HIGH_PRI_Q) && | 425 | INITIALIZE_MGMT_STATUS(ioc->taskmgmt_cmds.status) |
400 | (ioctl->ioc->facts.MsgVersion >= MPI_VERSION_01_05)) | 426 | CLEAR_MGMT_STATUS(ioc->taskmgmt_cmds.status) |
401 | mpt_put_msg_frame_hi_pri(mptctl_id, ioctl->ioc, mf); | 427 | time_count = jiffies; |
428 | if ((ioc->facts.IOCCapabilities & MPI_IOCFACTS_CAPABILITY_HIGH_PRI_Q) && | ||
429 | (ioc->facts.MsgVersion >= MPI_VERSION_01_05)) | ||
430 | mpt_put_msg_frame_hi_pri(mptctl_taskmgmt_id, ioc, mf); | ||
402 | else { | 431 | else { |
403 | retval = mpt_send_handshake_request(mptctl_id, ioctl->ioc, | 432 | retval = mpt_send_handshake_request(mptctl_taskmgmt_id, ioc, |
404 | sizeof(SCSITaskMgmt_t), (u32*)pScsiTm, CAN_SLEEP); | 433 | sizeof(SCSITaskMgmt_t), (u32 *)pScsiTm, CAN_SLEEP); |
405 | if (retval != 0) { | 434 | if (retval != 0) { |
406 | dfailprintk(ioctl->ioc, printk(MYIOC_s_ERR_FMT "_send_handshake FAILED!" | 435 | dfailprintk(ioc, printk(MYIOC_s_ERR_FMT |
407 | " (hd %p, ioc %p, mf %p) \n", hd->ioc->name, hd, | 436 | "TaskMgmt send_handshake FAILED!" |
408 | hd->ioc, mf)); | 437 | " (ioc %p, mf %p, rc=%d) \n", ioc->name, |
438 | ioc, mf, retval)); | ||
439 | mpt_clear_taskmgmt_in_progress_flag(ioc); | ||
409 | goto mptctl_bus_reset_done; | 440 | goto mptctl_bus_reset_done; |
410 | } | 441 | } |
411 | } | 442 | } |
412 | 443 | ||
413 | /* Now wait for the command to complete */ | 444 | /* Now wait for the command to complete */ |
414 | ii = wait_event_timeout(mptctl_wait, | 445 | ii = wait_for_completion_timeout(&ioc->taskmgmt_cmds.done, timeout*HZ); |
415 | ioctl->wait_done == 1, | 446 | if (!(ioc->taskmgmt_cmds.status & MPT_MGMT_STATUS_COMMAND_GOOD)) { |
416 | HZ*5 /* 5 second timeout */); | 447 | dtmprintk(ioc, printk(MYIOC_s_DEBUG_FMT |
448 | "TaskMgmt failed\n", ioc->name)); | ||
449 | mpt_free_msg_frame(ioc, mf); | ||
450 | mpt_clear_taskmgmt_in_progress_flag(ioc); | ||
451 | if (ioc->taskmgmt_cmds.status & MPT_MGMT_STATUS_DID_IOCRESET) | ||
452 | retval = 0; | ||
453 | else | ||
454 | retval = -1; /* return failure */ | ||
455 | goto mptctl_bus_reset_done; | ||
456 | } | ||
417 | 457 | ||
418 | if(ii <=0 && (ioctl->wait_done != 1 )) { | 458 | if (!(ioc->taskmgmt_cmds.status & MPT_MGMT_STATUS_RF_VALID)) { |
419 | mpt_free_msg_frame(hd->ioc, mf); | 459 | dtmprintk(ioc, printk(MYIOC_s_DEBUG_FMT |
420 | ioctl->wait_done = 0; | 460 | "TaskMgmt failed\n", ioc->name)); |
461 | retval = -1; /* return failure */ | ||
462 | goto mptctl_bus_reset_done; | ||
463 | } | ||
464 | |||
465 | pScsiTmReply = (SCSITaskMgmtReply_t *) ioc->taskmgmt_cmds.reply; | ||
466 | dtmprintk(ioc, printk(MYIOC_s_DEBUG_FMT | ||
467 | "TaskMgmt fw_channel = %d, fw_id = %d, task_type=0x%02X, " | ||
468 | "iocstatus=0x%04X\n\tloginfo=0x%08X, response_code=0x%02X, " | ||
469 | "term_cmnds=%d\n", ioc->name, pScsiTmReply->Bus, | ||
470 | pScsiTmReply->TargetID, MPI_SCSITASKMGMT_TASKTYPE_RESET_BUS, | ||
471 | le16_to_cpu(pScsiTmReply->IOCStatus), | ||
472 | le32_to_cpu(pScsiTmReply->IOCLogInfo), | ||
473 | pScsiTmReply->ResponseCode, | ||
474 | le32_to_cpu(pScsiTmReply->TerminationCount))); | ||
475 | |||
476 | iocstatus = le16_to_cpu(pScsiTmReply->IOCStatus) & MPI_IOCSTATUS_MASK; | ||
477 | |||
478 | if (iocstatus == MPI_IOCSTATUS_SCSI_TASK_TERMINATED || | ||
479 | iocstatus == MPI_IOCSTATUS_SCSI_IOC_TERMINATED || | ||
480 | iocstatus == MPI_IOCSTATUS_SUCCESS) | ||
481 | retval = 0; | ||
482 | else { | ||
483 | dtmprintk(ioc, printk(MYIOC_s_DEBUG_FMT | ||
484 | "TaskMgmt failed\n", ioc->name)); | ||
421 | retval = -1; /* return failure */ | 485 | retval = -1; /* return failure */ |
422 | } | 486 | } |
423 | 487 | ||
424 | mptctl_bus_reset_done: | ||
425 | 488 | ||
426 | mptctl_free_tm_flags(ioctl->ioc); | 489 | mptctl_bus_reset_done: |
490 | mutex_unlock(&ioc->taskmgmt_cmds.mutex); | ||
491 | CLEAR_MGMT_STATUS(ioc->taskmgmt_cmds.status) | ||
427 | return retval; | 492 | return retval; |
428 | } | 493 | } |
429 | 494 | ||
430 | static int | ||
431 | mptctl_set_tm_flags(MPT_SCSI_HOST *hd) { | ||
432 | unsigned long flags; | ||
433 | |||
434 | spin_lock_irqsave(&hd->ioc->FreeQlock, flags); | ||
435 | |||
436 | if (hd->tmState == TM_STATE_NONE) { | ||
437 | hd->tmState = TM_STATE_IN_PROGRESS; | ||
438 | hd->tmPending = 1; | ||
439 | spin_unlock_irqrestore(&hd->ioc->FreeQlock, flags); | ||
440 | } else { | ||
441 | spin_unlock_irqrestore(&hd->ioc->FreeQlock, flags); | ||
442 | return -EBUSY; | ||
443 | } | ||
444 | |||
445 | return 0; | ||
446 | } | ||
447 | |||
448 | static void | ||
449 | mptctl_free_tm_flags(MPT_ADAPTER *ioc) | ||
450 | { | ||
451 | MPT_SCSI_HOST * hd; | ||
452 | unsigned long flags; | ||
453 | |||
454 | hd = shost_priv(ioc->sh); | ||
455 | if (hd == NULL) | ||
456 | return; | ||
457 | |||
458 | spin_lock_irqsave(&ioc->FreeQlock, flags); | ||
459 | |||
460 | hd->tmState = TM_STATE_NONE; | ||
461 | hd->tmPending = 0; | ||
462 | spin_unlock_irqrestore(&ioc->FreeQlock, flags); | ||
463 | |||
464 | return; | ||
465 | } | ||
466 | 495 | ||
467 | /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ | 496 | /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ |
468 | /* mptctl_ioc_reset | 497 | /* mptctl_ioc_reset |
@@ -474,22 +503,23 @@ mptctl_free_tm_flags(MPT_ADAPTER *ioc) | |||
474 | static int | 503 | static int |
475 | mptctl_ioc_reset(MPT_ADAPTER *ioc, int reset_phase) | 504 | mptctl_ioc_reset(MPT_ADAPTER *ioc, int reset_phase) |
476 | { | 505 | { |
477 | MPT_IOCTL *ioctl = ioc->ioctl; | ||
478 | dctlprintk(ioc, printk(MYIOC_s_DEBUG_FMT "IOC %s_reset routed to IOCTL driver!\n", ioc->name, | ||
479 | reset_phase==MPT_IOC_SETUP_RESET ? "setup" : ( | ||
480 | reset_phase==MPT_IOC_PRE_RESET ? "pre" : "post"))); | ||
481 | |||
482 | if(ioctl == NULL) | ||
483 | return 1; | ||
484 | |||
485 | switch(reset_phase) { | 506 | switch(reset_phase) { |
486 | case MPT_IOC_SETUP_RESET: | 507 | case MPT_IOC_SETUP_RESET: |
487 | ioctl->status |= MPT_MGMT_STATUS_DID_IOCRESET; | 508 | dtmprintk(ioc, printk(MYIOC_s_DEBUG_FMT |
509 | "%s: MPT_IOC_SETUP_RESET\n", ioc->name, __func__)); | ||
510 | break; | ||
511 | case MPT_IOC_PRE_RESET: | ||
512 | dtmprintk(ioc, printk(MYIOC_s_DEBUG_FMT | ||
513 | "%s: MPT_IOC_PRE_RESET\n", ioc->name, __func__)); | ||
488 | break; | 514 | break; |
489 | case MPT_IOC_POST_RESET: | 515 | case MPT_IOC_POST_RESET: |
490 | ioctl->status &= ~MPT_MGMT_STATUS_DID_IOCRESET; | 516 | dtmprintk(ioc, printk(MYIOC_s_DEBUG_FMT |
517 | "%s: MPT_IOC_POST_RESET\n", ioc->name, __func__)); | ||
518 | if (ioc->ioctl_cmds.status & MPT_MGMT_STATUS_PENDING) { | ||
519 | ioc->ioctl_cmds.status |= MPT_MGMT_STATUS_DID_IOCRESET; | ||
520 | complete(&ioc->ioctl_cmds.done); | ||
521 | } | ||
491 | break; | 522 | break; |
492 | case MPT_IOC_PRE_RESET: | ||
493 | default: | 523 | default: |
494 | break; | 524 | break; |
495 | } | 525 | } |
@@ -643,7 +673,7 @@ __mptctl_ioctl(struct file *file, unsigned int cmd, unsigned long arg) | |||
643 | else | 673 | else |
644 | ret = -EINVAL; | 674 | ret = -EINVAL; |
645 | 675 | ||
646 | mutex_unlock(&iocp->ioctl->ioctl_mutex); | 676 | mutex_unlock(&iocp->ioctl_cmds.mutex); |
647 | 677 | ||
648 | return ret; | 678 | return ret; |
649 | } | 679 | } |
@@ -759,6 +789,7 @@ mptctl_do_fw_download(int ioc, char __user *ufwbuf, size_t fwlen) | |||
759 | int sge_offset = 0; | 789 | int sge_offset = 0; |
760 | u16 iocstat; | 790 | u16 iocstat; |
761 | pFWDownloadReply_t ReplyMsg = NULL; | 791 | pFWDownloadReply_t ReplyMsg = NULL; |
792 | unsigned long timeleft; | ||
762 | 793 | ||
763 | if (mpt_verify_adapter(ioc, &iocp) < 0) { | 794 | if (mpt_verify_adapter(ioc, &iocp) < 0) { |
764 | printk(KERN_DEBUG MYNAM "ioctl_fwdl - ioc%d not found!\n", | 795 | printk(KERN_DEBUG MYNAM "ioctl_fwdl - ioc%d not found!\n", |
@@ -893,16 +924,30 @@ mptctl_do_fw_download(int ioc, char __user *ufwbuf, size_t fwlen) | |||
893 | * Finally, perform firmware download. | 924 | * Finally, perform firmware download. |
894 | */ | 925 | */ |
895 | ReplyMsg = NULL; | 926 | ReplyMsg = NULL; |
927 | SET_MGMT_MSG_CONTEXT(iocp->ioctl_cmds.msg_context, dlmsg->MsgContext); | ||
928 | INITIALIZE_MGMT_STATUS(iocp->ioctl_cmds.status) | ||
896 | mpt_put_msg_frame(mptctl_id, iocp, mf); | 929 | mpt_put_msg_frame(mptctl_id, iocp, mf); |
897 | 930 | ||
898 | /* Now wait for the command to complete */ | 931 | /* Now wait for the command to complete */ |
899 | ret = wait_event_timeout(mptctl_wait, | 932 | retry_wait: |
900 | iocp->ioctl->wait_done == 1, | 933 | timeleft = wait_for_completion_timeout(&iocp->ioctl_cmds.done, HZ*60); |
901 | HZ*60); | 934 | if (!(iocp->ioctl_cmds.status & MPT_MGMT_STATUS_COMMAND_GOOD)) { |
935 | ret = -ETIME; | ||
936 | printk(MYIOC_s_WARN_FMT "%s: failed\n", iocp->name, __func__); | ||
937 | if (iocp->ioctl_cmds.status & MPT_MGMT_STATUS_DID_IOCRESET) { | ||
938 | mpt_free_msg_frame(iocp, mf); | ||
939 | goto fwdl_out; | ||
940 | } | ||
941 | if (!timeleft) | ||
942 | mptctl_timeout_expired(iocp, mf); | ||
943 | else | ||
944 | goto retry_wait; | ||
945 | goto fwdl_out; | ||
946 | } | ||
902 | 947 | ||
903 | if(ret <=0 && (iocp->ioctl->wait_done != 1 )) { | 948 | if (!(iocp->ioctl_cmds.status & MPT_MGMT_STATUS_RF_VALID)) { |
904 | /* Now we need to reset the board */ | 949 | printk(MYIOC_s_WARN_FMT "%s: failed\n", iocp->name, __func__); |
905 | mptctl_timeout_expired(iocp->ioctl); | 950 | mpt_free_msg_frame(iocp, mf); |
906 | ret = -ENODATA; | 951 | ret = -ENODATA; |
907 | goto fwdl_out; | 952 | goto fwdl_out; |
908 | } | 953 | } |
@@ -910,7 +955,7 @@ mptctl_do_fw_download(int ioc, char __user *ufwbuf, size_t fwlen) | |||
910 | if (sgl) | 955 | if (sgl) |
911 | kfree_sgl(sgl, sgl_dma, buflist, iocp); | 956 | kfree_sgl(sgl, sgl_dma, buflist, iocp); |
912 | 957 | ||
913 | ReplyMsg = (pFWDownloadReply_t)iocp->ioctl->ReplyFrame; | 958 | ReplyMsg = (pFWDownloadReply_t)iocp->ioctl_cmds.reply; |
914 | iocstat = le16_to_cpu(ReplyMsg->IOCStatus) & MPI_IOCSTATUS_MASK; | 959 | iocstat = le16_to_cpu(ReplyMsg->IOCStatus) & MPI_IOCSTATUS_MASK; |
915 | if (iocstat == MPI_IOCSTATUS_SUCCESS) { | 960 | if (iocstat == MPI_IOCSTATUS_SUCCESS) { |
916 | printk(MYIOC_s_INFO_FMT "F/W update successfull!\n", iocp->name); | 961 | printk(MYIOC_s_INFO_FMT "F/W update successfull!\n", iocp->name); |
@@ -934,6 +979,9 @@ mptctl_do_fw_download(int ioc, char __user *ufwbuf, size_t fwlen) | |||
934 | return 0; | 979 | return 0; |
935 | 980 | ||
936 | fwdl_out: | 981 | fwdl_out: |
982 | |||
983 | CLEAR_MGMT_STATUS(iocp->ioctl_cmds.status); | ||
984 | SET_MGMT_MSG_CONTEXT(iocp->ioctl_cmds.msg_context, 0); | ||
937 | kfree_sgl(sgl, sgl_dma, buflist, iocp); | 985 | kfree_sgl(sgl, sgl_dma, buflist, iocp); |
938 | return ret; | 986 | return ret; |
939 | } | 987 | } |
@@ -1774,7 +1822,10 @@ mptctl_do_mpt_command (struct mpt_ioctl_command karg, void __user *mfPtr) | |||
1774 | int msgContext; | 1822 | int msgContext; |
1775 | u16 req_idx; | 1823 | u16 req_idx; |
1776 | ulong timeout; | 1824 | ulong timeout; |
1825 | unsigned long timeleft; | ||
1777 | struct scsi_device *sdev; | 1826 | struct scsi_device *sdev; |
1827 | unsigned long flags; | ||
1828 | u8 function; | ||
1778 | 1829 | ||
1779 | /* bufIn and bufOut are used for user to kernel space transfers | 1830 | /* bufIn and bufOut are used for user to kernel space transfers |
1780 | */ | 1831 | */ |
@@ -1787,16 +1838,15 @@ mptctl_do_mpt_command (struct mpt_ioctl_command karg, void __user *mfPtr) | |||
1787 | __FILE__, __LINE__, iocnum); | 1838 | __FILE__, __LINE__, iocnum); |
1788 | return -ENODEV; | 1839 | return -ENODEV; |
1789 | } | 1840 | } |
1790 | if (!ioc->ioctl) { | 1841 | |
1791 | printk(KERN_ERR MYNAM "%s@%d::mptctl_do_mpt_command - " | 1842 | spin_lock_irqsave(&ioc->taskmgmt_lock, flags); |
1792 | "No memory available during driver init.\n", | 1843 | if (ioc->ioc_reset_in_progress) { |
1793 | __FILE__, __LINE__); | 1844 | spin_unlock_irqrestore(&ioc->taskmgmt_lock, flags); |
1794 | return -ENOMEM; | ||
1795 | } else if (ioc->ioctl->status & MPT_MGMT_STATUS_DID_IOCRESET) { | ||
1796 | printk(KERN_ERR MYNAM "%s@%d::mptctl_do_mpt_command - " | 1845 | printk(KERN_ERR MYNAM "%s@%d::mptctl_do_mpt_command - " |
1797 | "Busy with IOC Reset \n", __FILE__, __LINE__); | 1846 | "Busy with diagnostic reset\n", __FILE__, __LINE__); |
1798 | return -EBUSY; | 1847 | return -EBUSY; |
1799 | } | 1848 | } |
1849 | spin_unlock_irqrestore(&ioc->taskmgmt_lock, flags); | ||
1800 | 1850 | ||
1801 | /* Verify that the final request frame will not be too large. | 1851 | /* Verify that the final request frame will not be too large. |
1802 | */ | 1852 | */ |
@@ -1830,10 +1880,12 @@ mptctl_do_mpt_command (struct mpt_ioctl_command karg, void __user *mfPtr) | |||
1830 | printk(MYIOC_s_ERR_FMT "%s@%d::mptctl_do_mpt_command - " | 1880 | printk(MYIOC_s_ERR_FMT "%s@%d::mptctl_do_mpt_command - " |
1831 | "Unable to read MF from mpt_ioctl_command struct @ %p\n", | 1881 | "Unable to read MF from mpt_ioctl_command struct @ %p\n", |
1832 | ioc->name, __FILE__, __LINE__, mfPtr); | 1882 | ioc->name, __FILE__, __LINE__, mfPtr); |
1883 | function = -1; | ||
1833 | rc = -EFAULT; | 1884 | rc = -EFAULT; |
1834 | goto done_free_mem; | 1885 | goto done_free_mem; |
1835 | } | 1886 | } |
1836 | hdr->MsgContext = cpu_to_le32(msgContext); | 1887 | hdr->MsgContext = cpu_to_le32(msgContext); |
1888 | function = hdr->Function; | ||
1837 | 1889 | ||
1838 | 1890 | ||
1839 | /* Verify that this request is allowed. | 1891 | /* Verify that this request is allowed. |
@@ -1841,7 +1893,7 @@ mptctl_do_mpt_command (struct mpt_ioctl_command karg, void __user *mfPtr) | |||
1841 | dctlprintk(ioc, printk(MYIOC_s_DEBUG_FMT "sending mpi function (0x%02X), req=%p\n", | 1893 | dctlprintk(ioc, printk(MYIOC_s_DEBUG_FMT "sending mpi function (0x%02X), req=%p\n", |
1842 | ioc->name, hdr->Function, mf)); | 1894 | ioc->name, hdr->Function, mf)); |
1843 | 1895 | ||
1844 | switch (hdr->Function) { | 1896 | switch (function) { |
1845 | case MPI_FUNCTION_IOC_FACTS: | 1897 | case MPI_FUNCTION_IOC_FACTS: |
1846 | case MPI_FUNCTION_PORT_FACTS: | 1898 | case MPI_FUNCTION_PORT_FACTS: |
1847 | karg.dataOutSize = karg.dataInSize = 0; | 1899 | karg.dataOutSize = karg.dataInSize = 0; |
@@ -1938,8 +1990,6 @@ mptctl_do_mpt_command (struct mpt_ioctl_command karg, void __user *mfPtr) | |||
1938 | pScsiReq->Control = cpu_to_le32(scsidir | qtag); | 1990 | pScsiReq->Control = cpu_to_le32(scsidir | qtag); |
1939 | pScsiReq->DataLength = cpu_to_le32(dataSize); | 1991 | pScsiReq->DataLength = cpu_to_le32(dataSize); |
1940 | 1992 | ||
1941 | ioc->ioctl->reset = MPTCTL_RESET_OK; | ||
1942 | ioc->ioctl->id = pScsiReq->TargetID; | ||
1943 | 1993 | ||
1944 | } else { | 1994 | } else { |
1945 | printk(MYIOC_s_ERR_FMT "%s@%d::mptctl_do_mpt_command - " | 1995 | printk(MYIOC_s_ERR_FMT "%s@%d::mptctl_do_mpt_command - " |
@@ -2017,8 +2067,6 @@ mptctl_do_mpt_command (struct mpt_ioctl_command karg, void __user *mfPtr) | |||
2017 | pScsiReq->Control = cpu_to_le32(scsidir | qtag); | 2067 | pScsiReq->Control = cpu_to_le32(scsidir | qtag); |
2018 | pScsiReq->DataLength = cpu_to_le32(dataSize); | 2068 | pScsiReq->DataLength = cpu_to_le32(dataSize); |
2019 | 2069 | ||
2020 | ioc->ioctl->reset = MPTCTL_RESET_OK; | ||
2021 | ioc->ioctl->id = pScsiReq->TargetID; | ||
2022 | } else { | 2070 | } else { |
2023 | printk(MYIOC_s_ERR_FMT "%s@%d::mptctl_do_mpt_command - " | 2071 | printk(MYIOC_s_ERR_FMT "%s@%d::mptctl_do_mpt_command - " |
2024 | "SCSI driver is not loaded. \n", | 2072 | "SCSI driver is not loaded. \n", |
@@ -2029,20 +2077,17 @@ mptctl_do_mpt_command (struct mpt_ioctl_command karg, void __user *mfPtr) | |||
2029 | break; | 2077 | break; |
2030 | 2078 | ||
2031 | case MPI_FUNCTION_SCSI_TASK_MGMT: | 2079 | case MPI_FUNCTION_SCSI_TASK_MGMT: |
2032 | { | 2080 | { |
2033 | MPT_SCSI_HOST *hd = NULL; | 2081 | SCSITaskMgmt_t *pScsiTm; |
2034 | if ((ioc->sh == NULL) || ((hd = shost_priv(ioc->sh)) == NULL)) { | 2082 | pScsiTm = (SCSITaskMgmt_t *)mf; |
2035 | printk(MYIOC_s_ERR_FMT "%s@%d::mptctl_do_mpt_command - " | 2083 | dctlprintk(ioc, printk(MYIOC_s_DEBUG_FMT |
2036 | "SCSI driver not loaded or SCSI host not found. \n", | 2084 | "\tTaskType=0x%x MsgFlags=0x%x " |
2037 | ioc->name, __FILE__, __LINE__); | 2085 | "TaskMsgContext=0x%x id=%d channel=%d\n", |
2038 | rc = -EFAULT; | 2086 | ioc->name, pScsiTm->TaskType, le32_to_cpu |
2039 | goto done_free_mem; | 2087 | (pScsiTm->TaskMsgContext), pScsiTm->MsgFlags, |
2040 | } else if (mptctl_set_tm_flags(hd) != 0) { | 2088 | pScsiTm->TargetID, pScsiTm->Bus)); |
2041 | rc = -EPERM; | ||
2042 | goto done_free_mem; | ||
2043 | } | ||
2044 | } | ||
2045 | break; | 2089 | break; |
2090 | } | ||
2046 | 2091 | ||
2047 | case MPI_FUNCTION_IOC_INIT: | 2092 | case MPI_FUNCTION_IOC_INIT: |
2048 | { | 2093 | { |
@@ -2186,9 +2231,16 @@ mptctl_do_mpt_command (struct mpt_ioctl_command karg, void __user *mfPtr) | |||
2186 | ioc->add_sge(psge, flagsLength, (dma_addr_t) -1); | 2231 | ioc->add_sge(psge, flagsLength, (dma_addr_t) -1); |
2187 | } | 2232 | } |
2188 | 2233 | ||
2189 | ioc->ioctl->wait_done = 0; | 2234 | SET_MGMT_MSG_CONTEXT(ioc->ioctl_cmds.msg_context, hdr->MsgContext); |
2235 | INITIALIZE_MGMT_STATUS(ioc->ioctl_cmds.status) | ||
2190 | if (hdr->Function == MPI_FUNCTION_SCSI_TASK_MGMT) { | 2236 | if (hdr->Function == MPI_FUNCTION_SCSI_TASK_MGMT) { |
2191 | 2237 | ||
2238 | mutex_lock(&ioc->taskmgmt_cmds.mutex); | ||
2239 | if (mpt_set_taskmgmt_in_progress_flag(ioc) != 0) { | ||
2240 | mutex_unlock(&ioc->taskmgmt_cmds.mutex); | ||
2241 | goto done_free_mem; | ||
2242 | } | ||
2243 | |||
2192 | DBG_DUMP_TM_REQUEST_FRAME(ioc, (u32 *)mf); | 2244 | DBG_DUMP_TM_REQUEST_FRAME(ioc, (u32 *)mf); |
2193 | 2245 | ||
2194 | if ((ioc->facts.IOCCapabilities & MPI_IOCFACTS_CAPABILITY_HIGH_PRI_Q) && | 2246 | if ((ioc->facts.IOCCapabilities & MPI_IOCFACTS_CAPABILITY_HIGH_PRI_Q) && |
@@ -2199,10 +2251,11 @@ mptctl_do_mpt_command (struct mpt_ioctl_command karg, void __user *mfPtr) | |||
2199 | sizeof(SCSITaskMgmt_t), (u32*)mf, CAN_SLEEP); | 2251 | sizeof(SCSITaskMgmt_t), (u32*)mf, CAN_SLEEP); |
2200 | if (rc != 0) { | 2252 | if (rc != 0) { |
2201 | dfailprintk(ioc, printk(MYIOC_s_ERR_FMT | 2253 | dfailprintk(ioc, printk(MYIOC_s_ERR_FMT |
2202 | "_send_handshake FAILED! (ioc %p, mf %p)\n", | 2254 | "send_handshake FAILED! (ioc %p, mf %p)\n", |
2203 | ioc->name, ioc, mf)); | 2255 | ioc->name, ioc, mf)); |
2204 | mptctl_free_tm_flags(ioc); | 2256 | mpt_clear_taskmgmt_in_progress_flag(ioc); |
2205 | rc = -ENODATA; | 2257 | rc = -ENODATA; |
2258 | mutex_unlock(&ioc->taskmgmt_cmds.mutex); | ||
2206 | goto done_free_mem; | 2259 | goto done_free_mem; |
2207 | } | 2260 | } |
2208 | } | 2261 | } |
@@ -2212,36 +2265,47 @@ mptctl_do_mpt_command (struct mpt_ioctl_command karg, void __user *mfPtr) | |||
2212 | 2265 | ||
2213 | /* Now wait for the command to complete */ | 2266 | /* Now wait for the command to complete */ |
2214 | timeout = (karg.timeout > 0) ? karg.timeout : MPT_IOCTL_DEFAULT_TIMEOUT; | 2267 | timeout = (karg.timeout > 0) ? karg.timeout : MPT_IOCTL_DEFAULT_TIMEOUT; |
2215 | timeout = wait_event_timeout(mptctl_wait, | 2268 | retry_wait: |
2216 | ioc->ioctl->wait_done == 1, | 2269 | timeleft = wait_for_completion_timeout(&ioc->ioctl_cmds.done, |
2217 | HZ*timeout); | 2270 | HZ*timeout); |
2218 | 2271 | if (!(ioc->ioctl_cmds.status & MPT_MGMT_STATUS_COMMAND_GOOD)) { | |
2219 | if(timeout <=0 && (ioc->ioctl->wait_done != 1 )) { | 2272 | rc = -ETIME; |
2220 | /* Now we need to reset the board */ | 2273 | dfailprintk(ioc, printk(MYIOC_s_ERR_FMT "%s: TIMED OUT!\n", |
2221 | 2274 | ioc->name, __func__)); | |
2222 | if (hdr->Function == MPI_FUNCTION_SCSI_TASK_MGMT) | 2275 | if (ioc->ioctl_cmds.status & MPT_MGMT_STATUS_DID_IOCRESET) { |
2223 | mptctl_free_tm_flags(ioc); | 2276 | if (function == MPI_FUNCTION_SCSI_TASK_MGMT) |
2224 | 2277 | mutex_unlock(&ioc->taskmgmt_cmds.mutex); | |
2225 | mptctl_timeout_expired(ioc->ioctl); | 2278 | goto done_free_mem; |
2226 | rc = -ENODATA; | 2279 | } |
2280 | if (!timeleft) { | ||
2281 | if (function == MPI_FUNCTION_SCSI_TASK_MGMT) | ||
2282 | mutex_unlock(&ioc->taskmgmt_cmds.mutex); | ||
2283 | mptctl_timeout_expired(ioc, mf); | ||
2284 | mf = NULL; | ||
2285 | } else | ||
2286 | goto retry_wait; | ||
2227 | goto done_free_mem; | 2287 | goto done_free_mem; |
2228 | } | 2288 | } |
2229 | 2289 | ||
2290 | if (function == MPI_FUNCTION_SCSI_TASK_MGMT) | ||
2291 | mutex_unlock(&ioc->taskmgmt_cmds.mutex); | ||
2292 | |||
2293 | |||
2230 | mf = NULL; | 2294 | mf = NULL; |
2231 | 2295 | ||
2232 | /* If a valid reply frame, copy to the user. | 2296 | /* If a valid reply frame, copy to the user. |
2233 | * Offset 2: reply length in U32's | 2297 | * Offset 2: reply length in U32's |
2234 | */ | 2298 | */ |
2235 | if (ioc->ioctl->status & MPT_MGMT_STATUS_RF_VALID) { | 2299 | if (ioc->ioctl_cmds.status & MPT_MGMT_STATUS_RF_VALID) { |
2236 | if (karg.maxReplyBytes < ioc->reply_sz) { | 2300 | if (karg.maxReplyBytes < ioc->reply_sz) { |
2237 | sz = min(karg.maxReplyBytes, 4*ioc->ioctl->ReplyFrame[2]); | 2301 | sz = min(karg.maxReplyBytes, |
2302 | 4*ioc->ioctl_cmds.reply[2]); | ||
2238 | } else { | 2303 | } else { |
2239 | sz = min(ioc->reply_sz, 4*ioc->ioctl->ReplyFrame[2]); | 2304 | sz = min(ioc->reply_sz, 4*ioc->ioctl_cmds.reply[2]); |
2240 | } | 2305 | } |
2241 | |||
2242 | if (sz > 0) { | 2306 | if (sz > 0) { |
2243 | if (copy_to_user(karg.replyFrameBufPtr, | 2307 | if (copy_to_user(karg.replyFrameBufPtr, |
2244 | &ioc->ioctl->ReplyFrame, sz)){ | 2308 | ioc->ioctl_cmds.reply, sz)){ |
2245 | printk(MYIOC_s_ERR_FMT | 2309 | printk(MYIOC_s_ERR_FMT |
2246 | "%s@%d::mptctl_do_mpt_command - " | 2310 | "%s@%d::mptctl_do_mpt_command - " |
2247 | "Unable to write out reply frame %p\n", | 2311 | "Unable to write out reply frame %p\n", |
@@ -2254,10 +2318,11 @@ mptctl_do_mpt_command (struct mpt_ioctl_command karg, void __user *mfPtr) | |||
2254 | 2318 | ||
2255 | /* If valid sense data, copy to user. | 2319 | /* If valid sense data, copy to user. |
2256 | */ | 2320 | */ |
2257 | if (ioc->ioctl->status & MPT_MGMT_STATUS_SENSE_VALID) { | 2321 | if (ioc->ioctl_cmds.status & MPT_MGMT_STATUS_SENSE_VALID) { |
2258 | sz = min(karg.maxSenseBytes, MPT_SENSE_BUFFER_SIZE); | 2322 | sz = min(karg.maxSenseBytes, MPT_SENSE_BUFFER_SIZE); |
2259 | if (sz > 0) { | 2323 | if (sz > 0) { |
2260 | if (copy_to_user(karg.senseDataPtr, ioc->ioctl->sense, sz)) { | 2324 | if (copy_to_user(karg.senseDataPtr, |
2325 | ioc->ioctl_cmds.sense, sz)) { | ||
2261 | printk(MYIOC_s_ERR_FMT "%s@%d::mptctl_do_mpt_command - " | 2326 | printk(MYIOC_s_ERR_FMT "%s@%d::mptctl_do_mpt_command - " |
2262 | "Unable to write sense data to user %p\n", | 2327 | "Unable to write sense data to user %p\n", |
2263 | ioc->name, __FILE__, __LINE__, | 2328 | ioc->name, __FILE__, __LINE__, |
@@ -2271,7 +2336,7 @@ mptctl_do_mpt_command (struct mpt_ioctl_command karg, void __user *mfPtr) | |||
2271 | /* If the overall status is _GOOD and data in, copy data | 2336 | /* If the overall status is _GOOD and data in, copy data |
2272 | * to user. | 2337 | * to user. |
2273 | */ | 2338 | */ |
2274 | if ((ioc->ioctl->status & MPT_MGMT_STATUS_COMMAND_GOOD) && | 2339 | if ((ioc->ioctl_cmds.status & MPT_MGMT_STATUS_COMMAND_GOOD) && |
2275 | (karg.dataInSize > 0) && (bufIn.kptr)) { | 2340 | (karg.dataInSize > 0) && (bufIn.kptr)) { |
2276 | 2341 | ||
2277 | if (copy_to_user(karg.dataInBufPtr, | 2342 | if (copy_to_user(karg.dataInBufPtr, |
@@ -2286,9 +2351,8 @@ mptctl_do_mpt_command (struct mpt_ioctl_command karg, void __user *mfPtr) | |||
2286 | 2351 | ||
2287 | done_free_mem: | 2352 | done_free_mem: |
2288 | 2353 | ||
2289 | ioc->ioctl->status &= ~(MPT_MGMT_STATUS_COMMAND_GOOD | | 2354 | CLEAR_MGMT_STATUS(ioc->ioctl_cmds.status) |
2290 | MPT_MGMT_STATUS_SENSE_VALID | | 2355 | SET_MGMT_MSG_CONTEXT(ioc->ioctl_cmds.msg_context, 0); |
2291 | MPT_MGMT_STATUS_RF_VALID); | ||
2292 | 2356 | ||
2293 | /* Free the allocated memory. | 2357 | /* Free the allocated memory. |
2294 | */ | 2358 | */ |
@@ -2338,6 +2402,8 @@ mptctl_hp_hostinfo(unsigned long arg, unsigned int data_size) | |||
2338 | ToolboxIstwiReadWriteRequest_t *IstwiRWRequest; | 2402 | ToolboxIstwiReadWriteRequest_t *IstwiRWRequest; |
2339 | MPT_FRAME_HDR *mf = NULL; | 2403 | MPT_FRAME_HDR *mf = NULL; |
2340 | MPIHeader_t *mpi_hdr; | 2404 | MPIHeader_t *mpi_hdr; |
2405 | unsigned long timeleft; | ||
2406 | int retval; | ||
2341 | 2407 | ||
2342 | /* Reset long to int. Should affect IA64 and SPARC only | 2408 | /* Reset long to int. Should affect IA64 and SPARC only |
2343 | */ | 2409 | */ |
@@ -2478,8 +2544,8 @@ mptctl_hp_hostinfo(unsigned long arg, unsigned int data_size) | |||
2478 | * Gather ISTWI(Industry Standard Two Wire Interface) Data | 2544 | * Gather ISTWI(Industry Standard Two Wire Interface) Data |
2479 | */ | 2545 | */ |
2480 | if ((mf = mpt_get_msg_frame(mptctl_id, ioc)) == NULL) { | 2546 | if ((mf = mpt_get_msg_frame(mptctl_id, ioc)) == NULL) { |
2481 | dfailprintk(ioc, printk(MYIOC_s_WARN_FMT "%s, no msg frames!!\n", | 2547 | dfailprintk(ioc, printk(MYIOC_s_WARN_FMT |
2482 | ioc->name,__func__)); | 2548 | "%s, no msg frames!!\n", ioc->name, __func__)); |
2483 | goto out; | 2549 | goto out; |
2484 | } | 2550 | } |
2485 | 2551 | ||
@@ -2503,19 +2569,26 @@ mptctl_hp_hostinfo(unsigned long arg, unsigned int data_size) | |||
2503 | ioc->add_sge((char *)&IstwiRWRequest->SGL, | 2569 | ioc->add_sge((char *)&IstwiRWRequest->SGL, |
2504 | (MPT_SGE_FLAGS_SSIMPLE_READ|4), buf_dma); | 2570 | (MPT_SGE_FLAGS_SSIMPLE_READ|4), buf_dma); |
2505 | 2571 | ||
2506 | ioc->ioctl->wait_done = 0; | 2572 | retval = 0; |
2573 | SET_MGMT_MSG_CONTEXT(ioc->ioctl_cmds.msg_context, | ||
2574 | IstwiRWRequest->MsgContext); | ||
2575 | INITIALIZE_MGMT_STATUS(ioc->ioctl_cmds.status) | ||
2507 | mpt_put_msg_frame(mptctl_id, ioc, mf); | 2576 | mpt_put_msg_frame(mptctl_id, ioc, mf); |
2508 | 2577 | ||
2509 | rc = wait_event_timeout(mptctl_wait, | 2578 | retry_wait: |
2510 | ioc->ioctl->wait_done == 1, | 2579 | timeleft = wait_for_completion_timeout(&ioc->ioctl_cmds.done, |
2511 | HZ*MPT_IOCTL_DEFAULT_TIMEOUT /* 10 sec */); | 2580 | HZ*MPT_IOCTL_DEFAULT_TIMEOUT); |
2512 | 2581 | if (!(ioc->ioctl_cmds.status & MPT_MGMT_STATUS_COMMAND_GOOD)) { | |
2513 | if(rc <=0 && (ioc->ioctl->wait_done != 1 )) { | 2582 | retval = -ETIME; |
2514 | /* | 2583 | printk(MYIOC_s_WARN_FMT "%s: failed\n", ioc->name, __func__); |
2515 | * Now we need to reset the board | 2584 | if (ioc->ioctl_cmds.status & MPT_MGMT_STATUS_DID_IOCRESET) { |
2516 | */ | 2585 | mpt_free_msg_frame(ioc, mf); |
2517 | mpt_free_msg_frame(ioc, mf); | 2586 | goto out; |
2518 | mptctl_timeout_expired(ioc->ioctl); | 2587 | } |
2588 | if (!timeleft) | ||
2589 | mptctl_timeout_expired(ioc, mf); | ||
2590 | else | ||
2591 | goto retry_wait; | ||
2519 | goto out; | 2592 | goto out; |
2520 | } | 2593 | } |
2521 | 2594 | ||
@@ -2528,10 +2601,13 @@ mptctl_hp_hostinfo(unsigned long arg, unsigned int data_size) | |||
2528 | * bays have drives in them | 2601 | * bays have drives in them |
2529 | * pbuf[3] = Checksum (0x100 = (byte0 + byte2 + byte3) | 2602 | * pbuf[3] = Checksum (0x100 = (byte0 + byte2 + byte3) |
2530 | */ | 2603 | */ |
2531 | if (ioc->ioctl->status & MPT_MGMT_STATUS_RF_VALID) | 2604 | if (ioc->ioctl_cmds.status & MPT_MGMT_STATUS_RF_VALID) |
2532 | karg.rsvd = *(u32 *)pbuf; | 2605 | karg.rsvd = *(u32 *)pbuf; |
2533 | 2606 | ||
2534 | out: | 2607 | out: |
2608 | CLEAR_MGMT_STATUS(ioc->ioctl_cmds.status) | ||
2609 | SET_MGMT_MSG_CONTEXT(ioc->ioctl_cmds.msg_context, 0); | ||
2610 | |||
2535 | if (pbuf) | 2611 | if (pbuf) |
2536 | pci_free_consistent(ioc->pcidev, 4, pbuf, buf_dma); | 2612 | pci_free_consistent(ioc->pcidev, 4, pbuf, buf_dma); |
2537 | 2613 | ||
@@ -2755,7 +2831,7 @@ compat_mptfwxfer_ioctl(struct file *filp, unsigned int cmd, | |||
2755 | 2831 | ||
2756 | ret = mptctl_do_fw_download(kfw.iocnum, kfw.bufp, kfw.fwlen); | 2832 | ret = mptctl_do_fw_download(kfw.iocnum, kfw.bufp, kfw.fwlen); |
2757 | 2833 | ||
2758 | mutex_unlock(&iocp->ioctl->ioctl_mutex); | 2834 | mutex_unlock(&iocp->ioctl_cmds.mutex); |
2759 | 2835 | ||
2760 | return ret; | 2836 | return ret; |
2761 | } | 2837 | } |
@@ -2809,7 +2885,7 @@ compat_mpt_command(struct file *filp, unsigned int cmd, | |||
2809 | */ | 2885 | */ |
2810 | ret = mptctl_do_mpt_command (karg, &uarg->MF); | 2886 | ret = mptctl_do_mpt_command (karg, &uarg->MF); |
2811 | 2887 | ||
2812 | mutex_unlock(&iocp->ioctl->ioctl_mutex); | 2888 | mutex_unlock(&iocp->ioctl_cmds.mutex); |
2813 | 2889 | ||
2814 | return ret; | 2890 | return ret; |
2815 | } | 2891 | } |
@@ -2861,21 +2937,10 @@ static long compat_mpctl_ioctl(struct file *f, unsigned int cmd, unsigned long a | |||
2861 | static int | 2937 | static int |
2862 | mptctl_probe(struct pci_dev *pdev, const struct pci_device_id *id) | 2938 | mptctl_probe(struct pci_dev *pdev, const struct pci_device_id *id) |
2863 | { | 2939 | { |
2864 | MPT_IOCTL *mem; | ||
2865 | MPT_ADAPTER *ioc = pci_get_drvdata(pdev); | 2940 | MPT_ADAPTER *ioc = pci_get_drvdata(pdev); |
2866 | 2941 | ||
2867 | /* | 2942 | mutex_init(&ioc->ioctl_cmds.mutex); |
2868 | * Allocate and inite a MPT_IOCTL structure | 2943 | init_completion(&ioc->ioctl_cmds.done); |
2869 | */ | ||
2870 | mem = kzalloc(sizeof(MPT_IOCTL), GFP_KERNEL); | ||
2871 | if (!mem) { | ||
2872 | mptctl_remove(pdev); | ||
2873 | return -ENOMEM; | ||
2874 | } | ||
2875 | |||
2876 | ioc->ioctl = mem; | ||
2877 | ioc->ioctl->ioc = ioc; | ||
2878 | mutex_init(&ioc->ioctl->ioctl_mutex); | ||
2879 | return 0; | 2944 | return 0; |
2880 | } | 2945 | } |
2881 | 2946 | ||
@@ -2889,9 +2954,6 @@ mptctl_probe(struct pci_dev *pdev, const struct pci_device_id *id) | |||
2889 | static void | 2954 | static void |
2890 | mptctl_remove(struct pci_dev *pdev) | 2955 | mptctl_remove(struct pci_dev *pdev) |
2891 | { | 2956 | { |
2892 | MPT_ADAPTER *ioc = pci_get_drvdata(pdev); | ||
2893 | |||
2894 | kfree ( ioc->ioctl ); | ||
2895 | } | 2957 | } |
2896 | 2958 | ||
2897 | static struct mpt_pci_driver mptctl_driver = { | 2959 | static struct mpt_pci_driver mptctl_driver = { |
@@ -2931,6 +2993,7 @@ static int __init mptctl_init(void) | |||
2931 | goto out_fail; | 2993 | goto out_fail; |
2932 | } | 2994 | } |
2933 | 2995 | ||
2996 | mptctl_taskmgmt_id = mpt_register(mptctl_taskmgmt_reply, MPTCTL_DRIVER); | ||
2934 | mpt_reset_register(mptctl_id, mptctl_ioc_reset); | 2997 | mpt_reset_register(mptctl_id, mptctl_ioc_reset); |
2935 | mpt_event_register(mptctl_id, mptctl_event_process); | 2998 | mpt_event_register(mptctl_id, mptctl_event_process); |
2936 | 2999 | ||
@@ -2955,6 +3018,7 @@ static void mptctl_exit(void) | |||
2955 | 3018 | ||
2956 | /* De-register callback handler from base module */ | 3019 | /* De-register callback handler from base module */ |
2957 | mpt_deregister(mptctl_id); | 3020 | mpt_deregister(mptctl_id); |
3021 | mpt_reset_deregister(mptctl_taskmgmt_id); | ||
2958 | 3022 | ||
2959 | mpt_device_driver_deregister(MPTCTL_DRIVER); | 3023 | mpt_device_driver_deregister(MPTCTL_DRIVER); |
2960 | 3024 | ||
diff --git a/drivers/message/fusion/mptfc.c b/drivers/message/fusion/mptfc.c index a53b33214cde..e61df133a59e 100644 --- a/drivers/message/fusion/mptfc.c +++ b/drivers/message/fusion/mptfc.c | |||
@@ -1290,8 +1290,6 @@ mptfc_probe(struct pci_dev *pdev, const struct pci_device_id *id) | |||
1290 | 1290 | ||
1291 | /* Clear the TM flags | 1291 | /* Clear the TM flags |
1292 | */ | 1292 | */ |
1293 | hd->tmPending = 0; | ||
1294 | hd->tmState = TM_STATE_NONE; | ||
1295 | hd->abortSCpnt = NULL; | 1293 | hd->abortSCpnt = NULL; |
1296 | 1294 | ||
1297 | /* Clear the pointer used to store | 1295 | /* Clear the pointer used to store |
diff --git a/drivers/message/fusion/mptsas.c b/drivers/message/fusion/mptsas.c index 3efa728fc590..eb6b10eb11d2 100644 --- a/drivers/message/fusion/mptsas.c +++ b/drivers/message/fusion/mptsas.c | |||
@@ -553,15 +553,21 @@ mptsas_target_reset(MPT_ADAPTER *ioc, u8 channel, u8 id) | |||
553 | { | 553 | { |
554 | MPT_FRAME_HDR *mf; | 554 | MPT_FRAME_HDR *mf; |
555 | SCSITaskMgmt_t *pScsiTm; | 555 | SCSITaskMgmt_t *pScsiTm; |
556 | if (mpt_set_taskmgmt_in_progress_flag(ioc) != 0) | ||
557 | return 0; | ||
558 | |||
556 | 559 | ||
557 | mf = mpt_get_msg_frame(mptsasDeviceResetCtx, ioc); | 560 | mf = mpt_get_msg_frame(mptsasDeviceResetCtx, ioc); |
558 | if (mf == NULL) { | 561 | if (mf == NULL) { |
559 | dfailprintk(ioc, printk(MYIOC_s_WARN_FMT | 562 | dfailprintk(ioc, printk(MYIOC_s_WARN_FMT |
560 | "%s, no msg frames @%d!!\n", | 563 | "%s, no msg frames @%d!!\n", ioc->name, |
561 | ioc->name, __func__, __LINE__)); | 564 | __func__, __LINE__)); |
562 | return 0; | 565 | goto out_fail; |
563 | } | 566 | } |
564 | 567 | ||
568 | dtmprintk(ioc, printk(MYIOC_s_DEBUG_FMT "TaskMgmt request (mf=%p)\n", | ||
569 | ioc->name, mf)); | ||
570 | |||
565 | /* Format the Request | 571 | /* Format the Request |
566 | */ | 572 | */ |
567 | pScsiTm = (SCSITaskMgmt_t *) mf; | 573 | pScsiTm = (SCSITaskMgmt_t *) mf; |
@@ -574,9 +580,18 @@ mptsas_target_reset(MPT_ADAPTER *ioc, u8 channel, u8 id) | |||
574 | 580 | ||
575 | DBG_DUMP_TM_REQUEST_FRAME(ioc, (u32 *)mf); | 581 | DBG_DUMP_TM_REQUEST_FRAME(ioc, (u32 *)mf); |
576 | 582 | ||
583 | dtmprintk(ioc, printk(MYIOC_s_DEBUG_FMT | ||
584 | "TaskMgmt type=%d (sas device delete) fw_channel = %d fw_id = %d)\n", | ||
585 | ioc->name, MPI_SCSITASKMGMT_TASKTYPE_TARGET_RESET, channel, id)); | ||
586 | |||
577 | mpt_put_msg_frame_hi_pri(mptsasDeviceResetCtx, ioc, mf); | 587 | mpt_put_msg_frame_hi_pri(mptsasDeviceResetCtx, ioc, mf); |
578 | 588 | ||
579 | return 1; | 589 | return 1; |
590 | |||
591 | out_fail: | ||
592 | |||
593 | mpt_clear_taskmgmt_in_progress_flag(ioc); | ||
594 | return 0; | ||
580 | } | 595 | } |
581 | 596 | ||
582 | /** | 597 | /** |
@@ -719,9 +734,12 @@ mptsas_taskmgmt_complete(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *mr) | |||
719 | if (!ev) { | 734 | if (!ev) { |
720 | dfailprintk(ioc, printk(MYIOC_s_WARN_FMT "%s, failed to allocate mem @%d..!!\n", | 735 | dfailprintk(ioc, printk(MYIOC_s_WARN_FMT "%s, failed to allocate mem @%d..!!\n", |
721 | ioc->name,__func__, __LINE__)); | 736 | ioc->name,__func__, __LINE__)); |
722 | return 0; | 737 | goto out_fail; |
723 | } | 738 | } |
724 | 739 | ||
740 | dtmprintk(ioc, printk(MYIOC_s_DEBUG_FMT "TaskMgmt request (mf=%p)\n", | ||
741 | ioc->name, mf)); | ||
742 | |||
725 | INIT_WORK(&ev->work, mptsas_hotplug_work); | 743 | INIT_WORK(&ev->work, mptsas_hotplug_work); |
726 | ev->ioc = ioc; | 744 | ev->ioc = ioc; |
727 | ev->handle = le16_to_cpu(sas_event_data->DevHandle); | 745 | ev->handle = le16_to_cpu(sas_event_data->DevHandle); |
@@ -734,10 +752,19 @@ mptsas_taskmgmt_complete(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *mr) | |||
734 | sizeof(__le64)); | 752 | sizeof(__le64)); |
735 | ev->sas_address = le64_to_cpu(sas_address); | 753 | ev->sas_address = le64_to_cpu(sas_address); |
736 | ev->device_info = le32_to_cpu(sas_event_data->DeviceInfo); | 754 | ev->device_info = le32_to_cpu(sas_event_data->DeviceInfo); |
755 | dtmprintk(ioc, printk(MYIOC_s_DEBUG_FMT | ||
756 | "TaskMgmt type=%d (sas device delete) fw_channel = %d fw_id = %d)\n", | ||
757 | ioc->name, MPI_SCSITASKMGMT_TASKTYPE_TARGET_RESET, channel, id)); | ||
758 | |||
737 | ev->event_type = MPTSAS_DEL_DEVICE; | 759 | ev->event_type = MPTSAS_DEL_DEVICE; |
738 | schedule_work(&ev->work); | 760 | schedule_work(&ev->work); |
739 | kfree(target_reset_list); | 761 | kfree(target_reset_list); |
740 | 762 | ||
763 | out_fail: | ||
764 | |||
765 | mpt_clear_taskmgmt_in_progress_flag(ioc); | ||
766 | return 0; | ||
767 | |||
741 | 768 | ||
742 | /* | 769 | /* |
743 | * issue target reset to next device in the queue | 770 | * issue target reset to next device in the queue |
@@ -3291,8 +3318,6 @@ mptsas_probe(struct pci_dev *pdev, const struct pci_device_id *id) | |||
3291 | 3318 | ||
3292 | /* Clear the TM flags | 3319 | /* Clear the TM flags |
3293 | */ | 3320 | */ |
3294 | hd->tmPending = 0; | ||
3295 | hd->tmState = TM_STATE_NONE; | ||
3296 | hd->abortSCpnt = NULL; | 3321 | hd->abortSCpnt = NULL; |
3297 | 3322 | ||
3298 | /* Clear the pointer used to store | 3323 | /* Clear the pointer used to store |
diff --git a/drivers/message/fusion/mptscsih.c b/drivers/message/fusion/mptscsih.c index a6a2bbda2f18..477f6f8251e5 100644 --- a/drivers/message/fusion/mptscsih.c +++ b/drivers/message/fusion/mptscsih.c | |||
@@ -1895,8 +1895,6 @@ mptscsih_host_reset(struct scsi_cmnd *SCpnt) | |||
1895 | * NONE. | 1895 | * NONE. |
1896 | */ | 1896 | */ |
1897 | retval = 0; | 1897 | retval = 0; |
1898 | hd->tmPending = 0; | ||
1899 | hd->tmState = TM_STATE_NONE; | ||
1900 | } | 1898 | } |
1901 | 1899 | ||
1902 | printk(MYIOC_s_INFO_FMT "host reset: %s (sc=%p)\n", | 1900 | printk(MYIOC_s_INFO_FMT "host reset: %s (sc=%p)\n", |
diff --git a/drivers/message/fusion/mptspi.c b/drivers/message/fusion/mptspi.c index 8b940740292e..c5b808fd55ba 100644 --- a/drivers/message/fusion/mptspi.c +++ b/drivers/message/fusion/mptspi.c | |||
@@ -1474,8 +1474,6 @@ mptspi_probe(struct pci_dev *pdev, const struct pci_device_id *id) | |||
1474 | 1474 | ||
1475 | /* Clear the TM flags | 1475 | /* Clear the TM flags |
1476 | */ | 1476 | */ |
1477 | hd->tmPending = 0; | ||
1478 | hd->tmState = TM_STATE_NONE; | ||
1479 | hd->abortSCpnt = NULL; | 1477 | hd->abortSCpnt = NULL; |
1480 | 1478 | ||
1481 | /* Clear the pointer used to store | 1479 | /* Clear the pointer used to store |