aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorDan Williams <dan.j.williams@intel.com>2011-06-13 03:51:30 -0400
committerDan Williams <dan.j.williams@intel.com>2011-07-03 07:04:51 -0400
commit0d0cf14c9bd2943ed5afd15df459f564d85eacde (patch)
treeb996109708782750f7f3d58fea957b5cf19f0fa6 /drivers
parent994a9303d33f8238d57f58c26067b6d4ac9af222 (diff)
isci: cleanup request allocation
Rather than return an error code and update a pointer that was passed by reference just return the request object directly (or null if allocation failed). Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/scsi/isci/request.c197
-rw-r--r--drivers/scsi/isci/request.h11
-rw-r--r--drivers/scsi/isci/task.c136
3 files changed, 121 insertions, 223 deletions
diff --git a/drivers/scsi/isci/request.c b/drivers/scsi/isci/request.c
index 9d7531ad9a74..f0813d076c50 100644
--- a/drivers/scsi/isci/request.c
+++ b/drivers/scsi/isci/request.c
@@ -3510,172 +3510,110 @@ static enum sci_status isci_io_request_build(
3510 return SCI_SUCCESS; 3510 return SCI_SUCCESS;
3511} 3511}
3512 3512
3513/** 3513static struct isci_request *isci_request_alloc_core(struct isci_host *ihost,
3514 * isci_request_alloc_core() - This function gets the request object from the 3514 struct isci_remote_device *idev,
3515 * isci_host dma cache. 3515 gfp_t gfp_flags)
3516 * @isci_host: This parameter specifies the ISCI host object
3517 * @isci_request: This parameter will contain the pointer to the new
3518 * isci_request object.
3519 * @isci_device: This parameter is the pointer to the isci remote device object
3520 * that is the destination for this request.
3521 * @gfp_flags: This parameter specifies the os allocation flags.
3522 *
3523 * SCI_SUCCESS on successfull completion, or specific failure code.
3524 */
3525static int isci_request_alloc_core(
3526 struct isci_host *isci_host,
3527 struct isci_request **isci_request,
3528 struct isci_remote_device *isci_device,
3529 gfp_t gfp_flags)
3530{ 3516{
3531 int ret = 0;
3532 dma_addr_t handle; 3517 dma_addr_t handle;
3533 struct isci_request *request; 3518 struct isci_request *ireq;
3534
3535 3519
3536 /* get pointer to dma memory. This actually points 3520 ireq = dma_pool_alloc(ihost->dma_pool, gfp_flags, &handle);
3537 * to both the isci_remote_device object and the 3521 if (!ireq) {
3538 * sci object. The isci object is at the beginning 3522 dev_warn(&ihost->pdev->dev,
3539 * of the memory allocated here.
3540 */
3541 request = dma_pool_alloc(isci_host->dma_pool, gfp_flags, &handle);
3542 if (!request) {
3543 dev_warn(&isci_host->pdev->dev,
3544 "%s: dma_pool_alloc returned NULL\n", __func__); 3523 "%s: dma_pool_alloc returned NULL\n", __func__);
3545 return -ENOMEM; 3524 return NULL;
3546 } 3525 }
3547 3526
3548 /* initialize the request object. */ 3527 /* initialize the request object. */
3549 spin_lock_init(&request->state_lock); 3528 spin_lock_init(&ireq->state_lock);
3550 request->request_daddr = handle; 3529 ireq->request_daddr = handle;
3551 request->isci_host = isci_host; 3530 ireq->isci_host = ihost;
3552 request->isci_device = isci_device; 3531 ireq->isci_device = idev;
3553 request->io_request_completion = NULL; 3532 ireq->io_request_completion = NULL;
3554 request->terminated = false; 3533 ireq->terminated = false;
3555 3534
3556 request->num_sg_entries = 0; 3535 ireq->num_sg_entries = 0;
3557 3536
3558 request->complete_in_target = false; 3537 ireq->complete_in_target = false;
3559 3538
3560 INIT_LIST_HEAD(&request->completed_node); 3539 INIT_LIST_HEAD(&ireq->completed_node);
3561 INIT_LIST_HEAD(&request->dev_node); 3540 INIT_LIST_HEAD(&ireq->dev_node);
3562 3541
3563 *isci_request = request; 3542 isci_request_change_state(ireq, allocated);
3564 isci_request_change_state(request, allocated);
3565 3543
3566 return ret; 3544 return ireq;
3567} 3545}
3568 3546
3569static int isci_request_alloc_io( 3547static struct isci_request *isci_request_alloc_io(struct isci_host *ihost,
3570 struct isci_host *isci_host, 3548 struct sas_task *task,
3571 struct sas_task *task, 3549 struct isci_remote_device *idev,
3572 struct isci_request **isci_request, 3550 gfp_t gfp_flags)
3573 struct isci_remote_device *isci_device,
3574 gfp_t gfp_flags)
3575{ 3551{
3576 int retval = isci_request_alloc_core(isci_host, isci_request, 3552 struct isci_request *ireq;
3577 isci_device, gfp_flags);
3578
3579 if (!retval) {
3580 (*isci_request)->ttype_ptr.io_task_ptr = task;
3581 (*isci_request)->ttype = io_task;
3582 3553
3583 task->lldd_task = *isci_request; 3554 ireq = isci_request_alloc_core(ihost, idev, gfp_flags);
3555 if (ireq) {
3556 ireq->ttype_ptr.io_task_ptr = task;
3557 ireq->ttype = io_task;
3558 task->lldd_task = ireq;
3584 } 3559 }
3585 return retval; 3560 return ireq;
3586} 3561}
3587 3562
3588/** 3563struct isci_request *isci_request_alloc_tmf(struct isci_host *ihost,
3589 * isci_request_alloc_tmf() - This function gets the request object from the 3564 struct isci_tmf *isci_tmf,
3590 * isci_host dma cache and initializes the relevant fields as a sas_task. 3565 struct isci_remote_device *idev,
3591 * @isci_host: This parameter specifies the ISCI host object 3566 gfp_t gfp_flags)
3592 * @sas_task: This parameter is the task struct from the upper layer driver.
3593 * @isci_request: This parameter will contain the pointer to the new
3594 * isci_request object.
3595 * @isci_device: This parameter is the pointer to the isci remote device object
3596 * that is the destination for this request.
3597 * @gfp_flags: This parameter specifies the os allocation flags.
3598 *
3599 * SCI_SUCCESS on successfull completion, or specific failure code.
3600 */
3601int isci_request_alloc_tmf(
3602 struct isci_host *isci_host,
3603 struct isci_tmf *isci_tmf,
3604 struct isci_request **isci_request,
3605 struct isci_remote_device *isci_device,
3606 gfp_t gfp_flags)
3607{ 3567{
3608 int retval = isci_request_alloc_core(isci_host, isci_request, 3568 struct isci_request *ireq;
3609 isci_device, gfp_flags);
3610
3611 if (!retval) {
3612 3569
3613 (*isci_request)->ttype_ptr.tmf_task_ptr = isci_tmf; 3570 ireq = isci_request_alloc_core(ihost, idev, gfp_flags);
3614 (*isci_request)->ttype = tmf_task; 3571 if (ireq) {
3572 ireq->ttype_ptr.tmf_task_ptr = isci_tmf;
3573 ireq->ttype = tmf_task;
3615 } 3574 }
3616 return retval; 3575 return ireq;
3617} 3576}
3618 3577
3619/** 3578int isci_request_execute(struct isci_host *ihost, struct sas_task *task,
3620 * isci_request_execute() - This function allocates the isci_request object, 3579 gfp_t gfp_flags)
3621 * all fills in some common fields.
3622 * @isci_host: This parameter specifies the ISCI host object
3623 * @sas_task: This parameter is the task struct from the upper layer driver.
3624 * @isci_request: This parameter will contain the pointer to the new
3625 * isci_request object.
3626 * @gfp_flags: This parameter specifies the os allocation flags.
3627 *
3628 * SCI_SUCCESS on successfull completion, or specific failure code.
3629 */
3630int isci_request_execute(
3631 struct isci_host *isci_host,
3632 struct sas_task *task,
3633 struct isci_request **isci_request,
3634 gfp_t gfp_flags)
3635{ 3580{
3636 int ret = 0;
3637 struct scic_sds_remote_device *sci_device;
3638 enum sci_status status = SCI_FAILURE_UNSUPPORTED_PROTOCOL; 3581 enum sci_status status = SCI_FAILURE_UNSUPPORTED_PROTOCOL;
3639 struct isci_remote_device *isci_device; 3582 struct scic_sds_remote_device *sci_dev;
3640 struct isci_request *request; 3583 struct isci_remote_device *idev;
3584 struct isci_request *ireq;
3641 unsigned long flags; 3585 unsigned long flags;
3586 int ret = 0;
3642 3587
3643 isci_device = task->dev->lldd_dev; 3588 idev = task->dev->lldd_dev;
3644 sci_device = &isci_device->sci; 3589 sci_dev = &idev->sci;
3645 3590
3646 /* do common allocation and init of request object. */ 3591 /* do common allocation and init of request object. */
3647 ret = isci_request_alloc_io( 3592 ireq = isci_request_alloc_io(ihost, task, idev, gfp_flags);
3648 isci_host, 3593 if (!ireq)
3649 task,
3650 &request,
3651 isci_device,
3652 gfp_flags
3653 );
3654
3655 if (ret)
3656 goto out; 3594 goto out;
3657 3595
3658 status = isci_io_request_build(isci_host, request, isci_device); 3596 status = isci_io_request_build(ihost, ireq, idev);
3659 if (status != SCI_SUCCESS) { 3597 if (status != SCI_SUCCESS) {
3660 dev_warn(&isci_host->pdev->dev, 3598 dev_warn(&ihost->pdev->dev,
3661 "%s: request_construct failed - status = 0x%x\n", 3599 "%s: request_construct failed - status = 0x%x\n",
3662 __func__, 3600 __func__,
3663 status); 3601 status);
3664 goto out; 3602 goto out;
3665 } 3603 }
3666 3604
3667 spin_lock_irqsave(&isci_host->scic_lock, flags); 3605 spin_lock_irqsave(&ihost->scic_lock, flags);
3668 3606
3669 /* send the request, let the core assign the IO TAG. */ 3607 /* send the request, let the core assign the IO TAG. */
3670 status = scic_controller_start_io(&isci_host->sci, sci_device, 3608 status = scic_controller_start_io(&ihost->sci, sci_dev,
3671 &request->sci, 3609 &ireq->sci,
3672 SCI_CONTROLLER_INVALID_IO_TAG); 3610 SCI_CONTROLLER_INVALID_IO_TAG);
3673 if (status != SCI_SUCCESS && 3611 if (status != SCI_SUCCESS &&
3674 status != SCI_FAILURE_REMOTE_DEVICE_RESET_REQUIRED) { 3612 status != SCI_FAILURE_REMOTE_DEVICE_RESET_REQUIRED) {
3675 dev_warn(&isci_host->pdev->dev, 3613 dev_warn(&ihost->pdev->dev,
3676 "%s: failed request start (0x%x)\n", 3614 "%s: failed request start (0x%x)\n",
3677 __func__, status); 3615 __func__, status);
3678 spin_unlock_irqrestore(&isci_host->scic_lock, flags); 3616 spin_unlock_irqrestore(&ihost->scic_lock, flags);
3679 goto out; 3617 goto out;
3680 } 3618 }
3681 3619
@@ -3687,21 +3625,21 @@ int isci_request_execute(
3687 * Update it's status and add it to the list in the 3625 * Update it's status and add it to the list in the
3688 * remote device object. 3626 * remote device object.
3689 */ 3627 */
3690 list_add(&request->dev_node, &isci_device->reqs_in_process); 3628 list_add(&ireq->dev_node, &idev->reqs_in_process);
3691 3629
3692 if (status == SCI_SUCCESS) { 3630 if (status == SCI_SUCCESS) {
3693 /* Save the tag for possible task mgmt later. */ 3631 /* Save the tag for possible task mgmt later. */
3694 request->io_tag = request->sci.io_tag; 3632 ireq->io_tag = ireq->sci.io_tag;
3695 isci_request_change_state(request, started); 3633 isci_request_change_state(ireq, started);
3696 } else { 3634 } else {
3697 /* The request did not really start in the 3635 /* The request did not really start in the
3698 * hardware, so clear the request handle 3636 * hardware, so clear the request handle
3699 * here so no terminations will be done. 3637 * here so no terminations will be done.
3700 */ 3638 */
3701 request->terminated = true; 3639 ireq->terminated = true;
3702 isci_request_change_state(request, completed); 3640 isci_request_change_state(ireq, completed);
3703 } 3641 }
3704 spin_unlock_irqrestore(&isci_host->scic_lock, flags); 3642 spin_unlock_irqrestore(&ihost->scic_lock, flags);
3705 3643
3706 if (status == 3644 if (status ==
3707 SCI_FAILURE_REMOTE_DEVICE_RESET_REQUIRED) { 3645 SCI_FAILURE_REMOTE_DEVICE_RESET_REQUIRED) {
@@ -3716,7 +3654,7 @@ int isci_request_execute(
3716 /* Cause this task to be scheduled in the SCSI error 3654 /* Cause this task to be scheduled in the SCSI error
3717 * handler thread. 3655 * handler thread.
3718 */ 3656 */
3719 isci_execpath_callback(isci_host, task, 3657 isci_execpath_callback(ihost, task,
3720 sas_task_abort); 3658 sas_task_abort);
3721 3659
3722 /* Change the status, since we are holding 3660 /* Change the status, since we are holding
@@ -3729,11 +3667,10 @@ int isci_request_execute(
3729 out: 3667 out:
3730 if (status != SCI_SUCCESS) { 3668 if (status != SCI_SUCCESS) {
3731 /* release dma memory on failure. */ 3669 /* release dma memory on failure. */
3732 isci_request_free(isci_host, request); 3670 isci_request_free(ihost, ireq);
3733 request = NULL; 3671 ireq = NULL;
3734 ret = SCI_FAILURE; 3672 ret = SCI_FAILURE;
3735 } 3673 }
3736 3674
3737 *isci_request = request;
3738 return ret; 3675 return ret;
3739} 3676}
diff --git a/drivers/scsi/isci/request.h b/drivers/scsi/isci/request.h
index ac9368c5a6b5..8de2542f081f 100644
--- a/drivers/scsi/isci/request.h
+++ b/drivers/scsi/isci/request.h
@@ -679,16 +679,13 @@ static inline void isci_request_free(struct isci_host *isci_host,
679 679
680#define isci_request_access_tmf(req) ((req)->ttype_ptr.tmf_task_ptr) 680#define isci_request_access_tmf(req) ((req)->ttype_ptr.tmf_task_ptr)
681 681
682int isci_request_alloc_tmf(struct isci_host *isci_host, 682struct isci_request *isci_request_alloc_tmf(struct isci_host *ihost,
683 struct isci_tmf *isci_tmf, 683 struct isci_tmf *isci_tmf,
684 struct isci_request **isci_request, 684 struct isci_remote_device *idev,
685 struct isci_remote_device *isci_device, 685 gfp_t gfp_flags);
686 gfp_t gfp_flags);
687
688 686
689int isci_request_execute(struct isci_host *isci_host, 687int isci_request_execute(struct isci_host *isci_host,
690 struct sas_task *task, 688 struct sas_task *task,
691 struct isci_request **request,
692 gfp_t gfp_flags); 689 gfp_t gfp_flags);
693 690
694/** 691/**
diff --git a/drivers/scsi/isci/task.c b/drivers/scsi/isci/task.c
index 01032dc2c116..ded81cd1a781 100644
--- a/drivers/scsi/isci/task.c
+++ b/drivers/scsi/isci/task.c
@@ -146,7 +146,6 @@ static void isci_task_refuse(struct isci_host *ihost, struct sas_task *task,
146int isci_task_execute_task(struct sas_task *task, int num, gfp_t gfp_flags) 146int isci_task_execute_task(struct sas_task *task, int num, gfp_t gfp_flags)
147{ 147{
148 struct isci_host *ihost = dev_to_ihost(task->dev); 148 struct isci_host *ihost = dev_to_ihost(task->dev);
149 struct isci_request *request = NULL;
150 struct isci_remote_device *device; 149 struct isci_remote_device *device;
151 unsigned long flags; 150 unsigned long flags;
152 int ret; 151 int ret;
@@ -226,8 +225,7 @@ int isci_task_execute_task(struct sas_task *task, int num, gfp_t gfp_flags)
226 spin_unlock_irqrestore(&task->task_state_lock, flags); 225 spin_unlock_irqrestore(&task->task_state_lock, flags);
227 226
228 /* build and send the request. */ 227 /* build and send the request. */
229 status = isci_request_execute(ihost, task, &request, 228 status = isci_request_execute(ihost, task, gfp_flags);
230 gfp_flags);
231 229
232 if (status != SCI_SUCCESS) { 230 if (status != SCI_SUCCESS) {
233 231
@@ -254,54 +252,34 @@ int isci_task_execute_task(struct sas_task *task, int num, gfp_t gfp_flags)
254 return 0; 252 return 0;
255} 253}
256 254
257 255static struct isci_request *isci_task_request_build(struct isci_host *ihost,
258 256 struct isci_tmf *isci_tmf)
259/**
260 * isci_task_request_build() - This function builds the task request object.
261 * @isci_host: This parameter specifies the ISCI host object
262 * @request: This parameter points to the isci_request object allocated in the
263 * request construct function.
264 * @tmf: This parameter is the task management struct to be built
265 *
266 * SCI_SUCCESS on successfull completion, or specific failure code.
267 */
268static enum sci_status isci_task_request_build(
269 struct isci_host *isci_host,
270 struct isci_request **isci_request,
271 struct isci_tmf *isci_tmf)
272{ 257{
273 struct scic_sds_remote_device *sci_device; 258 struct scic_sds_remote_device *sci_dev;
274 enum sci_status status = SCI_FAILURE; 259 enum sci_status status = SCI_FAILURE;
275 struct isci_request *request = NULL; 260 struct isci_request *ireq = NULL;
276 struct isci_remote_device *isci_device; 261 struct isci_remote_device *idev;
277 struct domain_device *dev; 262 struct domain_device *dev;
278 263
279 dev_dbg(&isci_host->pdev->dev, 264 dev_dbg(&ihost->pdev->dev,
280 "%s: isci_tmf = %p\n", __func__, isci_tmf); 265 "%s: isci_tmf = %p\n", __func__, isci_tmf);
281 266
282 isci_device = isci_tmf->device; 267 idev = isci_tmf->device;
283 sci_device = &isci_device->sci; 268 sci_dev = &idev->sci;
284 dev = isci_device->domain_dev; 269 dev = idev->domain_dev;
285 270
286 /* do common allocation and init of request object. */ 271 /* do common allocation and init of request object. */
287 status = isci_request_alloc_tmf( 272 ireq = isci_request_alloc_tmf(ihost, isci_tmf, idev, GFP_ATOMIC);
288 isci_host, 273 if (!ireq)
289 isci_tmf, 274 return NULL;
290 &request,
291 isci_device,
292 GFP_ATOMIC
293 );
294
295 if (status != SCI_SUCCESS)
296 goto out;
297 275
298 /* let the core do it's construct. */ 276 /* let the core do it's construct. */
299 status = scic_task_request_construct(&isci_host->sci, sci_device, 277 status = scic_task_request_construct(&ihost->sci, sci_dev,
300 SCI_CONTROLLER_INVALID_IO_TAG, 278 SCI_CONTROLLER_INVALID_IO_TAG,
301 &request->sci); 279 &ireq->sci);
302 280
303 if (status != SCI_SUCCESS) { 281 if (status != SCI_SUCCESS) {
304 dev_warn(&isci_host->pdev->dev, 282 dev_warn(&ihost->pdev->dev,
305 "%s: scic_task_request_construct failed - " 283 "%s: scic_task_request_construct failed - "
306 "status = 0x%x\n", 284 "status = 0x%x\n",
307 __func__, 285 __func__,
@@ -312,30 +290,23 @@ static enum sci_status isci_task_request_build(
312 /* XXX convert to get this from task->tproto like other drivers */ 290 /* XXX convert to get this from task->tproto like other drivers */
313 if (dev->dev_type == SAS_END_DEV) { 291 if (dev->dev_type == SAS_END_DEV) {
314 isci_tmf->proto = SAS_PROTOCOL_SSP; 292 isci_tmf->proto = SAS_PROTOCOL_SSP;
315 status = scic_task_request_construct_ssp(&request->sci); 293 status = scic_task_request_construct_ssp(&ireq->sci);
316 if (status != SCI_SUCCESS) 294 if (status != SCI_SUCCESS)
317 goto errout; 295 goto errout;
318 } 296 }
319 297
320 if (dev->dev_type == SATA_DEV || (dev->tproto & SAS_PROTOCOL_STP)) { 298 if (dev->dev_type == SATA_DEV || (dev->tproto & SAS_PROTOCOL_STP)) {
321 isci_tmf->proto = SAS_PROTOCOL_SATA; 299 isci_tmf->proto = SAS_PROTOCOL_SATA;
322 status = isci_sata_management_task_request_build(request); 300 status = isci_sata_management_task_request_build(ireq);
323 301
324 if (status != SCI_SUCCESS) 302 if (status != SCI_SUCCESS)
325 goto errout; 303 goto errout;
326 } 304 }
327 305 return ireq;
328 goto out;
329
330 errout: 306 errout:
331 307 isci_request_free(ihost, ireq);
332 /* release the dma memory if we fail. */ 308 ireq = NULL;
333 isci_request_free(isci_host, request); 309 return ireq;
334 request = NULL;
335
336 out:
337 *isci_request = request;
338 return status;
339} 310}
340 311
341/** 312/**
@@ -350,16 +321,14 @@ static enum sci_status isci_task_request_build(
350 * TMF_RESP_FUNC_COMPLETE on successful completion of the TMF (this includes 321 * TMF_RESP_FUNC_COMPLETE on successful completion of the TMF (this includes
351 * error conditions reported in the IU status), or TMF_RESP_FUNC_FAILED. 322 * error conditions reported in the IU status), or TMF_RESP_FUNC_FAILED.
352 */ 323 */
353int isci_task_execute_tmf( 324int isci_task_execute_tmf(struct isci_host *ihost, struct isci_tmf *tmf,
354 struct isci_host *isci_host, 325 unsigned long timeout_ms)
355 struct isci_tmf *tmf,
356 unsigned long timeout_ms)
357{ 326{
358 DECLARE_COMPLETION_ONSTACK(completion); 327 DECLARE_COMPLETION_ONSTACK(completion);
359 enum sci_task_status status = SCI_TASK_FAILURE; 328 enum sci_task_status status = SCI_TASK_FAILURE;
360 struct scic_sds_remote_device *sci_device; 329 struct scic_sds_remote_device *sci_device;
361 struct isci_remote_device *isci_device = tmf->device; 330 struct isci_remote_device *isci_device = tmf->device;
362 struct isci_request *request; 331 struct isci_request *ireq;
363 int ret = TMF_RESP_FUNC_FAILED; 332 int ret = TMF_RESP_FUNC_FAILED;
364 unsigned long flags; 333 unsigned long flags;
365 unsigned long timeleft; 334 unsigned long timeleft;
@@ -368,13 +337,13 @@ int isci_task_execute_tmf(
368 * if the device is not there and ready. 337 * if the device is not there and ready.
369 */ 338 */
370 if (!isci_device || isci_device->status != isci_ready_for_io) { 339 if (!isci_device || isci_device->status != isci_ready_for_io) {
371 dev_dbg(&isci_host->pdev->dev, 340 dev_dbg(&ihost->pdev->dev,
372 "%s: isci_device = %p not ready (%d)\n", 341 "%s: isci_device = %p not ready (%d)\n",
373 __func__, 342 __func__,
374 isci_device, isci_device->status); 343 isci_device, isci_device->status);
375 return TMF_RESP_FUNC_FAILED; 344 return TMF_RESP_FUNC_FAILED;
376 } else 345 } else
377 dev_dbg(&isci_host->pdev->dev, 346 dev_dbg(&ihost->pdev->dev,
378 "%s: isci_device = %p\n", 347 "%s: isci_device = %p\n",
379 __func__, isci_device); 348 __func__, isci_device);
380 349
@@ -383,64 +352,59 @@ int isci_task_execute_tmf(
383 /* Assign the pointer to the TMF's completion kernel wait structure. */ 352 /* Assign the pointer to the TMF's completion kernel wait structure. */
384 tmf->complete = &completion; 353 tmf->complete = &completion;
385 354
386 isci_task_request_build( 355 ireq = isci_task_request_build(ihost, tmf);
387 isci_host, 356 if (!ireq) {
388 &request, 357 dev_warn(&ihost->pdev->dev,
389 tmf
390 );
391
392 if (!request) {
393 dev_warn(&isci_host->pdev->dev,
394 "%s: isci_task_request_build failed\n", 358 "%s: isci_task_request_build failed\n",
395 __func__); 359 __func__);
396 return TMF_RESP_FUNC_FAILED; 360 return TMF_RESP_FUNC_FAILED;
397 } 361 }
398 362
399 spin_lock_irqsave(&isci_host->scic_lock, flags); 363 spin_lock_irqsave(&ihost->scic_lock, flags);
400 364
401 /* start the TMF io. */ 365 /* start the TMF io. */
402 status = scic_controller_start_task( 366 status = scic_controller_start_task(
403 &isci_host->sci, 367 &ihost->sci,
404 sci_device, 368 sci_device,
405 &request->sci, 369 &ireq->sci,
406 SCI_CONTROLLER_INVALID_IO_TAG); 370 SCI_CONTROLLER_INVALID_IO_TAG);
407 371
408 if (status != SCI_TASK_SUCCESS) { 372 if (status != SCI_TASK_SUCCESS) {
409 dev_warn(&isci_host->pdev->dev, 373 dev_warn(&ihost->pdev->dev,
410 "%s: start_io failed - status = 0x%x, request = %p\n", 374 "%s: start_io failed - status = 0x%x, request = %p\n",
411 __func__, 375 __func__,
412 status, 376 status,
413 request); 377 ireq);
414 spin_unlock_irqrestore(&isci_host->scic_lock, flags); 378 spin_unlock_irqrestore(&ihost->scic_lock, flags);
415 goto cleanup_request; 379 goto cleanup_request;
416 } 380 }
417 381
418 if (tmf->cb_state_func != NULL) 382 if (tmf->cb_state_func != NULL)
419 tmf->cb_state_func(isci_tmf_started, tmf, tmf->cb_data); 383 tmf->cb_state_func(isci_tmf_started, tmf, tmf->cb_data);
420 384
421 isci_request_change_state(request, started); 385 isci_request_change_state(ireq, started);
422 386
423 /* add the request to the remote device request list. */ 387 /* add the request to the remote device request list. */
424 list_add(&request->dev_node, &isci_device->reqs_in_process); 388 list_add(&ireq->dev_node, &isci_device->reqs_in_process);
425 389
426 spin_unlock_irqrestore(&isci_host->scic_lock, flags); 390 spin_unlock_irqrestore(&ihost->scic_lock, flags);
427 391
428 /* Wait for the TMF to complete, or a timeout. */ 392 /* Wait for the TMF to complete, or a timeout. */
429 timeleft = wait_for_completion_timeout(&completion, 393 timeleft = wait_for_completion_timeout(&completion,
430 jiffies + msecs_to_jiffies(timeout_ms)); 394 jiffies + msecs_to_jiffies(timeout_ms));
431 395
432 if (timeleft == 0) { 396 if (timeleft == 0) {
433 spin_lock_irqsave(&isci_host->scic_lock, flags); 397 spin_lock_irqsave(&ihost->scic_lock, flags);
434 398
435 if (tmf->cb_state_func != NULL) 399 if (tmf->cb_state_func != NULL)
436 tmf->cb_state_func(isci_tmf_timed_out, tmf, tmf->cb_data); 400 tmf->cb_state_func(isci_tmf_timed_out, tmf, tmf->cb_data);
437 401
438 status = scic_controller_terminate_request( 402 status = scic_controller_terminate_request(
439 &request->isci_host->sci, 403 &ireq->isci_host->sci,
440 &request->isci_device->sci, 404 &ireq->isci_device->sci,
441 &request->sci); 405 &ireq->sci);
442 406
443 spin_unlock_irqrestore(&isci_host->scic_lock, flags); 407 spin_unlock_irqrestore(&ihost->scic_lock, flags);
444 } 408 }
445 409
446 isci_print_tmf(tmf); 410 isci_print_tmf(tmf);
@@ -448,7 +412,7 @@ int isci_task_execute_tmf(
448 if (tmf->status == SCI_SUCCESS) 412 if (tmf->status == SCI_SUCCESS)
449 ret = TMF_RESP_FUNC_COMPLETE; 413 ret = TMF_RESP_FUNC_COMPLETE;
450 else if (tmf->status == SCI_FAILURE_IO_RESPONSE_VALID) { 414 else if (tmf->status == SCI_FAILURE_IO_RESPONSE_VALID) {
451 dev_dbg(&isci_host->pdev->dev, 415 dev_dbg(&ihost->pdev->dev,
452 "%s: tmf.status == " 416 "%s: tmf.status == "
453 "SCI_FAILURE_IO_RESPONSE_VALID\n", 417 "SCI_FAILURE_IO_RESPONSE_VALID\n",
454 __func__); 418 __func__);
@@ -456,18 +420,18 @@ int isci_task_execute_tmf(
456 } 420 }
457 /* Else - leave the default "failed" status alone. */ 421 /* Else - leave the default "failed" status alone. */
458 422
459 dev_dbg(&isci_host->pdev->dev, 423 dev_dbg(&ihost->pdev->dev,
460 "%s: completed request = %p\n", 424 "%s: completed request = %p\n",
461 __func__, 425 __func__,
462 request); 426 ireq);
463 427
464 if (request->io_request_completion != NULL) { 428 if (ireq->io_request_completion != NULL) {
465 /* A thread is waiting for this TMF to finish. */ 429 /* A thread is waiting for this TMF to finish. */
466 complete(request->io_request_completion); 430 complete(ireq->io_request_completion);
467 } 431 }
468 432
469 cleanup_request: 433 cleanup_request:
470 isci_request_free(isci_host, request); 434 isci_request_free(ihost, ireq);
471 return ret; 435 return ret;
472} 436}
473 437