aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/isci/task.c
diff options
context:
space:
mode:
authorEdmund Nadolski <edmund.nadolski@intel.com>2011-05-19 08:00:15 -0400
committerDan Williams <dan.j.williams@intel.com>2011-07-03 07:04:50 -0400
commitfd18388bc5820b3e7807302ac18e8e7de83c9f4c (patch)
tree475c99244c3bcac1f51defec870bb307b74bafe3 /drivers/scsi/isci/task.c
parentbb3dbdf6c835a145e46119ed18a920a774694583 (diff)
isci: Remove tmf timeout_timer
Replace the timeout_timer in the isci_tmf with a call to wait_for_completion_timeout Signed-off-by: Edmund Nadolski <edmund.nadolski@intel.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Diffstat (limited to 'drivers/scsi/isci/task.c')
-rw-r--r--drivers/scsi/isci/task.c105
1 files changed, 20 insertions, 85 deletions
diff --git a/drivers/scsi/isci/task.c b/drivers/scsi/isci/task.c
index 078e2ee4f4be..60b687b77d56 100644
--- a/drivers/scsi/isci/task.c
+++ b/drivers/scsi/isci/task.c
@@ -339,54 +339,6 @@ static enum sci_status isci_task_request_build(
339} 339}
340 340
341/** 341/**
342 * isci_tmf_timeout_cb() - This function is called as a kernel callback when
343 * the timeout period for the TMF has expired.
344 *
345 *
346 */
347static void isci_tmf_timeout_cb(void *tmf_request_arg)
348{
349 struct isci_request *request = (struct isci_request *)tmf_request_arg;
350 struct isci_tmf *tmf = isci_request_access_tmf(request);
351 enum sci_status status;
352
353 /* This task management request has timed-out. Terminate the request
354 * so that the request eventually completes to the requestor in the
355 * request completion callback path.
356 */
357 /* Note - the timer callback function itself has provided spinlock
358 * exclusion from the start and completion paths. No need to take
359 * the request->isci_host->scic_lock here.
360 */
361
362 if (tmf->timeout_timer != NULL) {
363 /* Call the users callback, if any. */
364 if (tmf->cb_state_func != NULL)
365 tmf->cb_state_func(isci_tmf_timed_out, tmf,
366 tmf->cb_data);
367
368 /* Terminate the TMF transmit request. */
369 status = scic_controller_terminate_request(
370 &request->isci_host->sci,
371 &request->isci_device->sci,
372 &request->sci);
373
374 dev_dbg(&request->isci_host->pdev->dev,
375 "%s: tmf_request = %p; tmf = %p; status = %d\n",
376 __func__, request, tmf, status);
377 } else
378 dev_dbg(&request->isci_host->pdev->dev,
379 "%s: timer already canceled! "
380 "tmf_request = %p; tmf = %p\n",
381 __func__, request, tmf);
382
383 /* No need to unlock since the caller to this callback is doing it for
384 * us.
385 * request->isci_host->scic_lock
386 */
387}
388
389/**
390 * isci_task_execute_tmf() - This function builds and sends a task request, 342 * isci_task_execute_tmf() - This function builds and sends a task request,
391 * then waits for the completion. 343 * then waits for the completion.
392 * @isci_host: This parameter specifies the ISCI host object 344 * @isci_host: This parameter specifies the ISCI host object
@@ -410,6 +362,7 @@ int isci_task_execute_tmf(
410 struct isci_request *request; 362 struct isci_request *request;
411 int ret = TMF_RESP_FUNC_FAILED; 363 int ret = TMF_RESP_FUNC_FAILED;
412 unsigned long flags; 364 unsigned long flags;
365 unsigned long timeleft;
413 366
414 /* sanity check, return TMF_RESP_FUNC_FAILED 367 /* sanity check, return TMF_RESP_FUNC_FAILED
415 * if the device is not there and ready. 368 * if the device is not there and ready.
@@ -443,17 +396,7 @@ int isci_task_execute_tmf(
443 return TMF_RESP_FUNC_FAILED; 396 return TMF_RESP_FUNC_FAILED;
444 } 397 }
445 398
446 /* Allocate the TMF timeout timer. */
447 spin_lock_irqsave(&isci_host->scic_lock, flags); 399 spin_lock_irqsave(&isci_host->scic_lock, flags);
448 tmf->timeout_timer = isci_timer_create(isci_host, request, isci_tmf_timeout_cb);
449
450 /* Start the timer. */
451 if (tmf->timeout_timer)
452 isci_timer_start(tmf->timeout_timer, timeout_ms);
453 else
454 dev_warn(&isci_host->pdev->dev,
455 "%s: isci_timer_create failed!!!!\n",
456 __func__);
457 400
458 /* start the TMF io. */ 401 /* start the TMF io. */
459 status = scic_controller_start_task( 402 status = scic_controller_start_task(
@@ -468,14 +411,13 @@ int isci_task_execute_tmf(
468 __func__, 411 __func__,
469 status, 412 status,
470 request); 413 request);
414 spin_unlock_irqrestore(&isci_host->scic_lock, flags);
471 goto cleanup_request; 415 goto cleanup_request;
472 } 416 }
473 417
474 /* Call the users callback, if any. */
475 if (tmf->cb_state_func != NULL) 418 if (tmf->cb_state_func != NULL)
476 tmf->cb_state_func(isci_tmf_started, tmf, tmf->cb_data); 419 tmf->cb_state_func(isci_tmf_started, tmf, tmf->cb_data);
477 420
478 /* Change the state of the TMF-bearing request to "started". */
479 isci_request_change_state(request, started); 421 isci_request_change_state(request, started);
480 422
481 /* add the request to the remote device request list. */ 423 /* add the request to the remote device request list. */
@@ -484,7 +426,22 @@ int isci_task_execute_tmf(
484 spin_unlock_irqrestore(&isci_host->scic_lock, flags); 426 spin_unlock_irqrestore(&isci_host->scic_lock, flags);
485 427
486 /* Wait for the TMF to complete, or a timeout. */ 428 /* Wait for the TMF to complete, or a timeout. */
487 wait_for_completion(&completion); 429 timeleft = wait_for_completion_timeout(&completion,
430 jiffies + msecs_to_jiffies(timeout_ms));
431
432 if (timeleft == 0) {
433 spin_lock_irqsave(&isci_host->scic_lock, flags);
434
435 if (tmf->cb_state_func != NULL)
436 tmf->cb_state_func(isci_tmf_timed_out, tmf, tmf->cb_data);
437
438 status = scic_controller_terminate_request(
439 &request->isci_host->sci,
440 &request->isci_device->sci,
441 &request->sci);
442
443 spin_unlock_irqrestore(&isci_host->scic_lock, flags);
444 }
488 445
489 isci_print_tmf(tmf); 446 isci_print_tmf(tmf);
490 447
@@ -505,28 +462,12 @@ int isci_task_execute_tmf(
505 request); 462 request);
506 463
507 if (request->io_request_completion != NULL) { 464 if (request->io_request_completion != NULL) {
508 465 /* A thread is waiting for this TMF to finish. */
509 /* The fact that this is non-NULL for a TMF request
510 * means there is a thread waiting for this TMF to
511 * finish.
512 */
513 complete(request->io_request_completion); 466 complete(request->io_request_completion);
514 } 467 }
515 468
516 spin_lock_irqsave(&isci_host->scic_lock, flags);
517
518 cleanup_request: 469 cleanup_request:
519
520 /* Clean up the timer if needed. */
521 if (tmf->timeout_timer) {
522 isci_del_timer(isci_host, tmf->timeout_timer);
523 tmf->timeout_timer = NULL;
524 }
525
526 spin_unlock_irqrestore(&isci_host->scic_lock, flags);
527
528 isci_request_free(isci_host, request); 470 isci_request_free(isci_host, request);
529
530 return ret; 471 return ret;
531} 472}
532 473
@@ -546,7 +487,7 @@ void isci_task_build_tmf(
546 487
547 tmf->device = isci_device; 488 tmf->device = isci_device;
548 tmf->tmf_code = code; 489 tmf->tmf_code = code;
549 tmf->timeout_timer = NULL; 490
550 tmf->cb_state_func = tmf_sent_cb; 491 tmf->cb_state_func = tmf_sent_cb;
551 tmf->cb_data = cb_data; 492 tmf->cb_data = cb_data;
552} 493}
@@ -1442,12 +1383,6 @@ isci_task_request_complete(struct isci_host *ihost,
1442 sizeof(struct dev_to_host_fis)); 1383 sizeof(struct dev_to_host_fis));
1443 } 1384 }
1444 1385
1445 /* Manage the timer if it is still running. */
1446 if (tmf->timeout_timer) {
1447 isci_del_timer(ihost, tmf->timeout_timer);
1448 tmf->timeout_timer = NULL;
1449 }
1450
1451 /* PRINT_TMF( ((struct isci_tmf *)request->task)); */ 1386 /* PRINT_TMF( ((struct isci_tmf *)request->task)); */
1452 tmf_complete = tmf->complete; 1387 tmf_complete = tmf->complete;
1453 1388