aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/isci/request.c
diff options
context:
space:
mode:
authorDan Williams <dan.j.williams@intel.com>2011-05-08 14:47:15 -0400
committerDan Williams <dan.j.williams@intel.com>2011-07-03 07:04:47 -0400
commit67ea838d17acdad3331aeae848683c768df96aaa (patch)
tree30a80c95a1add14babf985a108973cc9c3caac83 /drivers/scsi/isci/request.c
parentb7645818cff1536038c0b21407eefb6b9d5755e6 (diff)
isci: unify request data structures
Make scic_sds_request a proper member of isci_request. Also let's us get rid of the dma pool object size tracking since we now know that all requests are sizeof(isci_request). While cleaning up the construct routine incidentally replaced SCI_FIELD_OFFSET with offsetof. Reported-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Diffstat (limited to 'drivers/scsi/isci/request.c')
-rw-r--r--drivers/scsi/isci/request.c168
1 files changed, 76 insertions, 92 deletions
diff --git a/drivers/scsi/isci/request.c b/drivers/scsi/isci/request.c
index a5b9b22d3b3a..4961ee347091 100644
--- a/drivers/scsi/isci/request.c
+++ b/drivers/scsi/isci/request.c
@@ -73,9 +73,7 @@ static enum sci_status isci_request_ssp_request_construct(
73 "%s: request = %p\n", 73 "%s: request = %p\n",
74 __func__, 74 __func__,
75 request); 75 request);
76 status = scic_io_request_construct_basic_ssp( 76 status = scic_io_request_construct_basic_ssp(&request->sci);
77 request->sci_request_handle
78 );
79 return status; 77 return status;
80} 78}
81 79
@@ -96,9 +94,7 @@ static enum sci_status isci_request_stp_request_construct(
96 */ 94 */
97 register_fis = isci_sata_task_to_fis_copy(task); 95 register_fis = isci_sata_task_to_fis_copy(task);
98 96
99 status = scic_io_request_construct_basic_sata( 97 status = scic_io_request_construct_basic_sata(&request->sci);
100 request->sci_request_handle
101 );
102 98
103 /* Set the ncq tag in the fis, from the queue 99 /* Set the ncq tag in the fis, from the queue
104 * command in the task. 100 * command in the task.
@@ -125,7 +121,7 @@ static enum sci_status isci_smp_request_build(struct isci_request *ireq)
125{ 121{
126 enum sci_status status = SCI_FAILURE; 122 enum sci_status status = SCI_FAILURE;
127 struct sas_task *task = isci_request_access_task(ireq); 123 struct sas_task *task = isci_request_access_task(ireq);
128 struct scic_sds_request *sci_req = ireq->sci_request_handle; 124 struct scic_sds_request *sci_req = &ireq->sci;
129 125
130 dev_dbg(&ireq->isci_host->pdev->dev, 126 dev_dbg(&ireq->isci_host->pdev->dev,
131 "%s: request = %p\n", __func__, ireq); 127 "%s: request = %p\n", __func__, ireq);
@@ -201,8 +197,7 @@ static enum sci_status isci_io_request_build(
201 */ 197 */
202 status = scic_io_request_construct(&isci_host->sci, sci_device, 198 status = scic_io_request_construct(&isci_host->sci, sci_device,
203 SCI_CONTROLLER_INVALID_IO_TAG, 199 SCI_CONTROLLER_INVALID_IO_TAG,
204 request, request->sci_req, 200 &request->sci);
205 &request->sci_request_handle);
206 201
207 if (status != SCI_SUCCESS) { 202 if (status != SCI_SUCCESS) {
208 dev_warn(&isci_host->pdev->dev, 203 dev_warn(&isci_host->pdev->dev,
@@ -211,8 +206,6 @@ static enum sci_status isci_io_request_build(
211 return SCI_FAILURE; 206 return SCI_FAILURE;
212 } 207 }
213 208
214 request->sci_request_handle->ireq = request;
215
216 switch (task->task_proto) { 209 switch (task->task_proto) {
217 case SAS_PROTOCOL_SMP: 210 case SAS_PROTOCOL_SMP:
218 status = isci_smp_request_build(request); 211 status = isci_smp_request_build(request);
@@ -276,8 +269,8 @@ static int isci_request_alloc_core(
276 request->isci_host = isci_host; 269 request->isci_host = isci_host;
277 request->isci_device = isci_device; 270 request->isci_device = isci_device;
278 request->io_request_completion = NULL; 271 request->io_request_completion = NULL;
272 request->terminated = false;
279 273
280 request->request_alloc_size = isci_host->dma_pool_alloc_size;
281 request->num_sg_entries = 0; 274 request->num_sg_entries = 0;
282 275
283 request->complete_in_target = false; 276 request->complete_in_target = false;
@@ -381,80 +374,74 @@ int isci_request_execute(
381 goto out; 374 goto out;
382 375
383 status = isci_io_request_build(isci_host, request, isci_device); 376 status = isci_io_request_build(isci_host, request, isci_device);
384 if (status == SCI_SUCCESS) { 377 if (status != SCI_SUCCESS) {
385 378 dev_warn(&isci_host->pdev->dev,
386 spin_lock_irqsave(&isci_host->scic_lock, flags); 379 "%s: request_construct failed - status = 0x%x\n",
387 380 __func__,
388 /* send the request, let the core assign the IO TAG. */ 381 status);
389 status = scic_controller_start_io( 382 goto out;
390 &isci_host->sci, 383 }
391 sci_device,
392 request->sci_request_handle,
393 SCI_CONTROLLER_INVALID_IO_TAG
394 );
395
396 if (status == SCI_SUCCESS ||
397 status == SCI_FAILURE_REMOTE_DEVICE_RESET_REQUIRED) {
398
399 /* Either I/O started OK, or the core has signaled that
400 * the device needs a target reset.
401 *
402 * In either case, hold onto the I/O for later.
403 *
404 * Update it's status and add it to the list in the
405 * remote device object.
406 */
407 isci_request_change_state(request, started);
408 list_add(&request->dev_node,
409 &isci_device->reqs_in_process);
410
411 if (status == SCI_SUCCESS) {
412 /* Save the tag for possible task mgmt later. */
413 request->io_tag = scic_io_request_get_io_tag(
414 request->sci_request_handle);
415 } else {
416 /* The request did not really start in the
417 * hardware, so clear the request handle
418 * here so no terminations will be done.
419 */
420 request->sci_request_handle = NULL;
421 }
422 384
423 } else 385 spin_lock_irqsave(&isci_host->scic_lock, flags);
424 dev_warn(&isci_host->pdev->dev,
425 "%s: failed request start (0x%x)\n",
426 __func__, status);
427 386
387 /* send the request, let the core assign the IO TAG. */
388 status = scic_controller_start_io(&isci_host->sci, sci_device,
389 &request->sci,
390 SCI_CONTROLLER_INVALID_IO_TAG);
391 if (status != SCI_SUCCESS &&
392 status != SCI_FAILURE_REMOTE_DEVICE_RESET_REQUIRED) {
393 dev_warn(&isci_host->pdev->dev,
394 "%s: failed request start (0x%x)\n",
395 __func__, status);
428 spin_unlock_irqrestore(&isci_host->scic_lock, flags); 396 spin_unlock_irqrestore(&isci_host->scic_lock, flags);
397 goto out;
398 }
429 399
430 if (status == 400 /* Either I/O started OK, or the core has signaled that
431 SCI_FAILURE_REMOTE_DEVICE_RESET_REQUIRED) { 401 * the device needs a target reset.
432 /* Signal libsas that we need the SCSI error 402 *
433 * handler thread to work on this I/O and that 403 * In either case, hold onto the I/O for later.
434 * we want a device reset. 404 *
435 */ 405 * Update it's status and add it to the list in the
436 spin_lock_irqsave(&task->task_state_lock, flags); 406 * remote device object.
437 task->task_state_flags |= SAS_TASK_NEED_DEV_RESET; 407 */
438 spin_unlock_irqrestore(&task->task_state_lock, flags); 408 isci_request_change_state(request, started);
439 409 list_add(&request->dev_node, &isci_device->reqs_in_process);
440 /* Cause this task to be scheduled in the SCSI error
441 * handler thread.
442 */
443 isci_execpath_callback(isci_host, task,
444 sas_task_abort);
445
446 /* Change the status, since we are holding
447 * the I/O until it is managed by the SCSI
448 * error handler.
449 */
450 status = SCI_SUCCESS;
451 }
452 410
453 } else 411 if (status == SCI_SUCCESS) {
454 dev_warn(&isci_host->pdev->dev, 412 /* Save the tag for possible task mgmt later. */
455 "%s: request_construct failed - status = 0x%x\n", 413 request->io_tag = scic_io_request_get_io_tag(&request->sci);
456 __func__, 414 } else {
457 status); 415 /* The request did not really start in the
416 * hardware, so clear the request handle
417 * here so no terminations will be done.
418 */
419 request->terminated = true;
420 }
421 spin_unlock_irqrestore(&isci_host->scic_lock, flags);
422
423 if (status ==
424 SCI_FAILURE_REMOTE_DEVICE_RESET_REQUIRED) {
425 /* Signal libsas that we need the SCSI error
426 * handler thread to work on this I/O and that
427 * we want a device reset.
428 */
429 spin_lock_irqsave(&task->task_state_lock, flags);
430 task->task_state_flags |= SAS_TASK_NEED_DEV_RESET;
431 spin_unlock_irqrestore(&task->task_state_lock, flags);
432
433 /* Cause this task to be scheduled in the SCSI error
434 * handler thread.
435 */
436 isci_execpath_callback(isci_host, task,
437 sas_task_abort);
438
439 /* Change the status, since we are holding
440 * the I/O until it is managed by the SCSI
441 * error handler.
442 */
443 status = SCI_SUCCESS;
444 }
458 445
459 out: 446 out:
460 if (status != SCI_SUCCESS) { 447 if (status != SCI_SUCCESS) {
@@ -554,9 +541,7 @@ static void isci_request_handle_controller_specific_errors(
554{ 541{
555 unsigned int cstatus; 542 unsigned int cstatus;
556 543
557 cstatus = scic_request_get_controller_status( 544 cstatus = scic_request_get_controller_status(&request->sci);
558 request->sci_request_handle
559 );
560 545
561 dev_dbg(&request->isci_host->pdev->dev, 546 dev_dbg(&request->isci_host->pdev->dev,
562 "%s: %p SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR " 547 "%s: %p SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR "
@@ -997,13 +982,13 @@ void isci_request_io_request_complete(
997 task); 982 task);
998 983
999 if (sas_protocol_ata(task->task_proto)) { 984 if (sas_protocol_ata(task->task_proto)) {
1000 resp_buf = &request->sci_request_handle->stp.rsp; 985 resp_buf = &request->sci.stp.rsp;
1001 isci_request_process_stp_response(task, 986 isci_request_process_stp_response(task,
1002 resp_buf); 987 resp_buf);
1003 } else if (SAS_PROTOCOL_SSP == task->task_proto) { 988 } else if (SAS_PROTOCOL_SSP == task->task_proto) {
1004 989
1005 /* crack the iu response buffer. */ 990 /* crack the iu response buffer. */
1006 resp_iu = &request->sci_request_handle->ssp.rsp; 991 resp_iu = &request->sci.ssp.rsp;
1007 isci_request_process_response_iu(task, resp_iu, 992 isci_request_process_response_iu(task, resp_iu,
1008 &isci_host->pdev->dev); 993 &isci_host->pdev->dev);
1009 994
@@ -1034,7 +1019,7 @@ void isci_request_io_request_complete(
1034 request->complete_in_target = true; 1019 request->complete_in_target = true;
1035 1020
1036 if (task->task_proto == SAS_PROTOCOL_SMP) { 1021 if (task->task_proto == SAS_PROTOCOL_SMP) {
1037 void *rsp = &request->sci_request_handle->smp.rsp; 1022 void *rsp = &request->sci.smp.rsp;
1038 1023
1039 dev_dbg(&isci_host->pdev->dev, 1024 dev_dbg(&isci_host->pdev->dev,
1040 "%s: SMP protocol completion\n", 1025 "%s: SMP protocol completion\n",
@@ -1051,8 +1036,7 @@ void isci_request_io_request_complete(
1051 * the maximum was transferred. 1036 * the maximum was transferred.
1052 */ 1037 */
1053 u32 transferred_length 1038 u32 transferred_length
1054 = scic_io_request_get_number_of_bytes_transferred( 1039 = scic_io_request_get_number_of_bytes_transferred(&request->sci);
1055 request->sci_request_handle);
1056 1040
1057 task->task_status.residual 1041 task->task_status.residual
1058 = task->total_xfer_len - transferred_length; 1042 = task->total_xfer_len - transferred_length;
@@ -1165,12 +1149,12 @@ void isci_request_io_request_complete(
1165 /* complete the io request to the core. */ 1149 /* complete the io request to the core. */
1166 scic_controller_complete_io(&isci_host->sci, 1150 scic_controller_complete_io(&isci_host->sci,
1167 &isci_device->sci, 1151 &isci_device->sci,
1168 request->sci_request_handle); 1152 &request->sci);
1169 /* NULL the request handle so it cannot be completed or 1153 /* set terminated handle so it cannot be completed or
1170 * terminated again, and to cause any calls into abort 1154 * terminated again, and to cause any calls into abort
1171 * task to recognize the already completed case. 1155 * task to recognize the already completed case.
1172 */ 1156 */
1173 request->sci_request_handle = NULL; 1157 request->terminated = true;
1174 1158
1175 isci_host_can_dequeue(isci_host, 1); 1159 isci_host_can_dequeue(isci_host, 1);
1176} 1160}