Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

+129 -258
+4 -5
drivers/scsi/isci/core/sci_util.c
··· 59 59 60 60 void *scic_request_get_virt_addr(struct scic_sds_request *sci_req, dma_addr_t phys_addr) 61 61 { 62 - struct isci_request *ireq = sci_req->ireq; 62 + struct isci_request *ireq = sci_req_to_ireq(sci_req); 63 63 dma_addr_t offset; 64 64 65 65 BUG_ON(phys_addr < ireq->request_daddr); 66 66 67 67 offset = phys_addr - ireq->request_daddr; 68 68 69 - BUG_ON(offset >= ireq->request_alloc_size); 69 + BUG_ON(offset >= sizeof(*ireq)); 70 70 71 71 return (char *)ireq + offset; 72 72 } ··· 74 74 dma_addr_t scic_io_request_get_dma_addr(struct scic_sds_request *sds_request, 75 75 void *virt_addr) 76 76 { 77 - struct isci_request *isci_request = sds_request->ireq; 77 + struct isci_request *isci_request = sci_req_to_ireq(sds_request); 78 78 79 79 char *requested_addr = (char *)virt_addr; 80 80 char *base_addr = (char *)isci_request; 81 81 82 82 BUG_ON(requested_addr < base_addr); 83 - BUG_ON((requested_addr - base_addr) >= 84 - isci_request->request_alloc_size); 83 + BUG_ON((requested_addr - base_addr) >= sizeof(*isci_request)); 85 84 86 85 return isci_request->request_daddr + (requested_addr - base_addr); 87 86 }
-3
drivers/scsi/isci/core/sci_util.h
··· 66 66 | ((char_buffer)[3]) \ 67 67 ) 68 68 69 - #define SCI_FIELD_OFFSET(type, field) ((unsigned long)&(((type *)0)->field)) 70 - 71 - 72 69 #define sci_cb_make_physical_address(physical_addr, addr_upper, addr_lower) \ 73 70 ((physical_addr) = (addr_lower) | ((u64)addr_upper) << 32) 74 71
+1 -32
drivers/scsi/isci/core/scic_io_request.h
··· 102 102 103 103 } SCIC_TRANSPORT_PROTOCOL; 104 104 105 - 106 - /** 107 - * scic_io_request_construct() - This method is called by the SCI user to 108 - * construct all SCI Core IO requests. Memory initialization and 109 - * functionality common to all IO request types is performed in this method. 110 - * @scic_controller: the handle to the core controller object for which to 111 - * build an IO request. 112 - * @scic_remote_device: the handle to the core remote device object for which 113 - * to build an IO request. 114 - * @io_tag: This parameter specifies the IO tag to be associated with this 115 - * request. If SCI_CONTROLLER_INVALID_IO_TAG is passed, then a copy of the 116 - * request is built internally. The request will be copied into the actual 117 - * controller request memory when the IO tag is allocated internally during 118 - * the scic_controller_start_io() method. 119 - * @user_io_request_object: This parameter specifies the user IO request to be 120 - * utilized during IO construction. This IO pointer will become the 121 - * associated object for the core IO request object. 122 - * @scic_io_request_memory: This parameter specifies the memory location to be 123 - * utilized when building the core request. 124 - * @new_scic_io_request_handle: This parameter specifies a pointer to the 125 - * handle the core will expect in further interactions with the core IO 126 - * request object. 127 - * 128 - * The SCI core implementation will create an association between the user IO 129 - * request object and the core IO request object. Indicate if the controller 130 - * successfully built the IO request. SCI_SUCCESS This value is returned if the 131 - * IO request was successfully built. 132 - */ 133 105 enum sci_status scic_io_request_construct( 134 106 struct scic_sds_controller *scic_controller, 135 107 struct scic_sds_remote_device *scic_remote_device, 136 - u16 io_tag, 137 - void *user_io_request_object, 138 - struct scic_sds_request *scic_io_request_memory, 139 - struct scic_sds_request **new_scic_io_request_handle); 108 + u16 io_tag, struct scic_sds_request *sci_req); 140 109 141 110 /** 142 111 * scic_io_request_construct_basic_ssp() - This method is called by the SCI
+1 -1
drivers/scsi/isci/core/scic_sds_controller.c
··· 1572 1572 1573 1573 memcpy(task_context_buffer, 1574 1574 sci_req->task_context_buffer, 1575 - SCI_FIELD_OFFSET(struct scu_task_context, sgl_snapshot_ac)); 1575 + offsetof(struct scu_task_context, sgl_snapshot_ac)); 1576 1576 1577 1577 /* 1578 1578 * Now that the soft copy of the TC has been copied into the TC
+17 -36
drivers/scsi/isci/core/scic_sds_request.c
··· 117 117 */ 118 118 void scic_sds_request_build_sgl(struct scic_sds_request *sds_request) 119 119 { 120 - struct isci_request *isci_request = sds_request->ireq; 120 + struct isci_request *isci_request = sci_req_to_ireq(sds_request); 121 121 struct isci_host *isci_host = isci_request->isci_host; 122 122 struct sas_task *task = isci_request_access_task(isci_request); 123 123 struct scatterlist *sg = NULL; ··· 190 190 static void scic_sds_io_request_build_ssp_command_iu(struct scic_sds_request *sci_req) 191 191 { 192 192 struct ssp_cmd_iu *cmd_iu; 193 - struct isci_request *ireq = sci_req->ireq; 193 + struct isci_request *ireq = sci_req_to_ireq(sci_req); 194 194 struct sas_task *task = isci_request_access_task(ireq); 195 195 196 196 cmd_iu = &sci_req->ssp.cmd; ··· 211 211 static void scic_sds_task_request_build_ssp_task_iu(struct scic_sds_request *sci_req) 212 212 { 213 213 struct ssp_task_iu *task_iu; 214 - struct isci_request *ireq = sci_req->ireq; 214 + struct isci_request *ireq = sci_req_to_ireq(sci_req); 215 215 struct sas_task *task = isci_request_access_task(ireq); 216 216 struct isci_tmf *isci_tmf = isci_request_access_tmf(ireq); 217 217 ··· 429 429 bool copy) 430 430 { 431 431 enum sci_status status = SCI_SUCCESS; 432 - struct isci_request *ireq = sci_req->ireq; 432 + struct isci_request *ireq = sci_req_to_ireq(sci_req); 433 433 struct sas_task *task = isci_request_access_task(ireq); 434 434 435 435 /* check for management protocols */ ··· 478 478 enum sci_status scic_io_request_construct_basic_ssp( 479 479 struct scic_sds_request *sci_req) 480 480 { 481 - struct isci_request *ireq = sci_req->ireq; 481 + struct isci_request *ireq = sci_req_to_ireq(sci_req); 482 482 struct sas_task *task = isci_request_access_task(ireq); 483 483 484 484 sci_req->protocol = SCIC_SSP_PROTOCOL; ··· 519 519 enum sci_status status; 520 520 struct scic_sds_stp_request *stp_req; 521 521 bool copy = false; 522 - struct isci_request *isci_request = sci_req->ireq; 522 + struct isci_request *isci_request = sci_req_to_ireq(sci_req); 523 523 struct sas_task *task = isci_request_access_task(isci_request); 524 524 525 525 stp_req = &sci_req->stp.req; ··· 540 540 } 541 541 542 542 543 - enum sci_status scic_task_request_construct_sata( 544 - struct scic_sds_request *sci_req) 543 + enum sci_status scic_task_request_construct_sata(struct scic_sds_request *sci_req) 545 544 { 546 545 enum sci_status status = SCI_SUCCESS; 547 - struct isci_request *ireq = sci_req->ireq; 546 + struct isci_request *ireq = sci_req_to_ireq(sci_req); 548 547 549 548 /* check for management protocols */ 550 549 if (ireq->ttype == tmf_task) { ··· 739 740 void *resp_buf; 740 741 u32 len; 741 742 struct ssp_response_iu *ssp_response; 742 - struct isci_request *ireq = sci_req->ireq; 743 + struct isci_request *ireq = sci_req_to_ireq(sci_req); 743 744 struct isci_tmf *isci_tmf = isci_request_access_tmf(ireq); 744 745 745 746 ssp_response = &sci_req->ssp.rsp; ··· 1341 1342 struct scic_sds_controller *scic = 1342 1343 scic_sds_request_get_controller(sci_req); 1343 1344 struct isci_host *ihost = scic_to_ihost(scic); 1344 - struct isci_request *ireq = sci_req->ireq; 1345 + struct isci_request *ireq = sci_req_to_ireq(sci_req); 1345 1346 1346 1347 SET_STATE_HANDLER(sci_req, 1347 1348 scic_sds_request_state_handler_table, ··· 1423 1424 1424 1425 static void scic_sds_general_request_construct(struct scic_sds_controller *scic, 1425 1426 struct scic_sds_remote_device *sci_dev, 1426 - u16 io_tag, 1427 - void *user_io_request_object, 1428 - struct scic_sds_request *sci_req) 1427 + u16 io_tag, struct scic_sds_request *sci_req) 1429 1428 { 1430 1429 sci_base_state_machine_construct(&sci_req->state_machine, sci_req, 1431 1430 scic_sds_request_state_table, SCI_BASE_REQUEST_STATE_INITIAL); 1432 1431 sci_base_state_machine_start(&sci_req->state_machine); 1433 1432 1434 1433 sci_req->io_tag = io_tag; 1435 - sci_req->user_request = user_io_request_object; 1436 1434 sci_req->owning_controller = scic; 1437 1435 sci_req->target_device = sci_dev; 1438 1436 sci_req->has_started_substate_machine = false; ··· 1457 1461 enum sci_status 1458 1462 scic_io_request_construct(struct scic_sds_controller *scic, 1459 1463 struct scic_sds_remote_device *sci_dev, 1460 - u16 io_tag, 1461 - void *user_req, 1462 - struct scic_sds_request *sci_req, 1463 - struct scic_sds_request **new_sci_req) 1464 + u16 io_tag, struct scic_sds_request *sci_req) 1464 1465 { 1465 1466 struct domain_device *dev = sci_dev_to_domain(sci_dev); 1466 1467 enum sci_status status = SCI_SUCCESS; 1467 1468 1468 1469 /* Build the common part of the request */ 1469 - scic_sds_general_request_construct(scic, 1470 - sci_dev, 1471 - io_tag, 1472 - user_req, 1473 - sci_req); 1470 + scic_sds_general_request_construct(scic, sci_dev, io_tag, sci_req); 1474 1471 1475 1472 if (sci_dev->rnc.remote_node_index == 1476 1473 SCIC_SDS_REMOTE_NODE_CONTEXT_INVALID_INDEX) ··· 1482 1493 status = SCI_FAILURE_UNSUPPORTED_PROTOCOL; 1483 1494 1484 1495 if (status == SCI_SUCCESS) { 1485 - memset(sci_req->task_context_buffer, 1486 - 0, 1487 - SCI_FIELD_OFFSET(struct scu_task_context, sgl_pair_ab)); 1488 - *new_sci_req = sci_req; 1496 + memset(sci_req->task_context_buffer, 0, 1497 + offsetof(struct scu_task_context, sgl_pair_ab)); 1489 1498 } 1490 1499 1491 1500 return status; ··· 1491 1504 1492 1505 enum sci_status scic_task_request_construct(struct scic_sds_controller *scic, 1493 1506 struct scic_sds_remote_device *sci_dev, 1494 - u16 io_tag, 1495 - void *user_io_request_object, 1496 - struct scic_sds_request *sci_req, 1497 - struct scic_sds_request **new_sci_req) 1507 + u16 io_tag, struct scic_sds_request *sci_req) 1498 1508 { 1499 1509 struct domain_device *dev = sci_dev_to_domain(sci_dev); 1500 1510 enum sci_status status = SCI_SUCCESS; 1501 1511 1502 1512 /* Build the common part of the request */ 1503 - scic_sds_general_request_construct(scic, sci_dev, io_tag, 1504 - user_io_request_object, 1505 - sci_req); 1513 + scic_sds_general_request_construct(scic, sci_dev, io_tag, sci_req); 1506 1514 1507 1515 if (dev->dev_type == SAS_END_DEV) { 1508 1516 scic_sds_ssp_task_request_assign_buffers(sci_req); ··· 1519 1537 if (status == SCI_SUCCESS) { 1520 1538 sci_req->is_task_management_request = true; 1521 1539 memset(sci_req->task_context_buffer, 0, sizeof(struct scu_task_context)); 1522 - *new_sci_req = sci_req; 1523 1540 } 1524 1541 1525 1542 return status;
-14
drivers/scsi/isci/core/scic_sds_request.h
··· 113 113 SCIC_SDS_SMP_REQUEST_STARTED_SUBSTATE_AWAIT_TC_COMPLETION, 114 114 }; 115 115 116 - struct isci_request; 117 - /** 118 - * struct scic_sds_request - This structure contains or references all of 119 - * the data necessary to process a task management or normal IO request. 120 - * 121 - * 122 - */ 123 116 struct scic_sds_request { 124 - /** 125 - * The field specifies that the peer object for the request object. 126 - */ 127 - struct isci_request *ireq; 128 - 129 117 /** 130 118 * This field contains the information for the base request state machine. 131 119 */ 132 120 struct sci_base_state_machine state_machine; 133 - 134 - void *user_request; 135 121 136 122 /** 137 123 * This field simply points to the controller to which this IO request
+2 -2
drivers/scsi/isci/core/scic_sds_stp_request.c
··· 627 627 int total_len = len; 628 628 629 629 sci_req = to_sci_req(stp_req); 630 - ireq = scic_sds_request_get_user_request(sci_req); 630 + ireq = sci_req_to_ireq(sci_req); 631 631 task = isci_request_access_task(ireq); 632 632 src_addr = data_buf; 633 633 ··· 737 737 { 738 738 struct scic_sds_controller *scic = sci_req->owning_controller; 739 739 struct scic_sds_stp_request *stp_req = &sci_req->stp.req; 740 - struct isci_request *ireq = sci_req->ireq; 740 + struct isci_request *ireq = sci_req_to_ireq(sci_req); 741 741 struct sas_task *task = isci_request_access_task(ireq); 742 742 struct dev_to_host_fis *frame_header; 743 743 enum sci_status status;
+1 -35
drivers/scsi/isci/core/scic_task_request.h
··· 72 72 struct scic_sds_controller; 73 73 74 74 75 - /** 76 - * scic_task_request_construct() - This method is called by the SCI user to 77 - * construct all SCI Core task management requests, regardless of protocol. 78 - * Memory initialization and functionality common to all task request types 79 - * is performed in this method. 80 - * @scic_controller: the handle to the core controller object for which to 81 - * build the task managmement request. 82 - * @scic_remote_device: the handle to the core remote device object for which 83 - * to build the task management request. passed, then a copy of the request 84 - * is built internally. The request will be copied into the actual 85 - * controller request memory when the task is allocated internally during 86 - * the scic_controller_start_task() method. 87 - * @io_tag: This parameter specifies the IO tag to be associated with this 88 - * request. If SCI_CONTROLLER_INVALID_IO_TAG is passed, then a copy of the 89 - * request is built internally. The request will be copied into the actual 90 - * controller request memory when the IO tag is allocated internally during 91 - * the scic_controller_start_io() method. 92 - * @user_task_request_object: This parameter specifies the user task request to 93 - * be utilized during construction. This task pointer will become the 94 - * associated object for the core task request object. 95 - * @scic_task_request_memory: This parameter specifies the memory location to 96 - * be utilized when building the core request. 97 - * @new_scic_task_request_handle: This parameter specifies a pointer to the 98 - * handle the core will expect in further interactions with the core task 99 - * request object. 100 - * 101 - * The SCI core implementation will create an association between the user task 102 - * request object and the core task request object. Indicate if the controller 103 - * successfully built the task request. SCI_SUCCESS This value is returned if 104 - * the task request was successfully built. 105 - */ 106 75 enum sci_status scic_task_request_construct( 107 76 struct scic_sds_controller *scic_controller, 108 77 struct scic_sds_remote_device *scic_remote_device, 109 - u16 io_tag, 110 - void *user_task_request_object, 111 - void *scic_task_request_memory, 112 - struct scic_sds_request **new_scic_task_request_handle); 78 + u16 io_tag, struct scic_sds_request *sci_req); 113 79 114 80 /** 115 81 * scic_task_request_construct_ssp() - This method is called by the SCI user to
+1 -7
drivers/scsi/isci/host.c
··· 428 428 if (err) 429 429 return err; 430 430 431 - /* 432 - * keep the pool alloc size around, will use it for a bounds checking 433 - * when trying to convert virtual addresses to physical addresses 434 - */ 435 - isci_host->dma_pool_alloc_size = sizeof(struct isci_request) + 436 - sizeof(struct scic_sds_request); 437 431 isci_host->dma_pool = dmam_pool_create(DRV_NAME, &isci_host->pdev->dev, 438 - isci_host->dma_pool_alloc_size, 432 + sizeof(struct isci_request), 439 433 SLAB_HWCACHE_ALIGN, 0); 440 434 441 435 if (!isci_host->dma_pool)
-1
drivers/scsi/isci/host.h
··· 82 82 struct list_head timers; 83 83 void *core_ctrl_memory; 84 84 struct dma_pool *dma_pool; 85 - unsigned int dma_pool_alloc_size; 86 85 struct isci_phy phys[SCI_MAX_PHYS]; 87 86 struct isci_port ports[SCI_MAX_PORTS + 1]; /* includes dummy port */ 88 87 struct sas_ha_struct sas_ha;
+1 -1
drivers/scsi/isci/remote_device.c
··· 473 473 struct sci_base_state_machine *sm = &sci_dev->state_machine; 474 474 enum scic_sds_remote_device_states state = sm->current_state_id; 475 475 struct scic_sds_port *sci_port = sci_dev->owning_port; 476 - struct isci_request *ireq = sci_req->ireq; 476 + struct isci_request *ireq = sci_req_to_ireq(sci_req); 477 477 enum sci_status status; 478 478 479 479 switch (state) {
+77 -93
drivers/scsi/isci/request.c
··· 73 73 "%s: request = %p\n", 74 74 __func__, 75 75 request); 76 - status = scic_io_request_construct_basic_ssp( 77 - request->sci_request_handle 78 - ); 76 + status = scic_io_request_construct_basic_ssp(&request->sci); 79 77 return status; 80 78 } 81 79 ··· 94 96 */ 95 97 register_fis = isci_sata_task_to_fis_copy(task); 96 98 97 - status = scic_io_request_construct_basic_sata( 98 - request->sci_request_handle 99 - ); 99 + status = scic_io_request_construct_basic_sata(&request->sci); 100 100 101 101 /* Set the ncq tag in the fis, from the queue 102 102 * command in the task. ··· 121 125 { 122 126 enum sci_status status = SCI_FAILURE; 123 127 struct sas_task *task = isci_request_access_task(ireq); 124 - struct scic_sds_request *sci_req = ireq->sci_request_handle; 128 + struct scic_sds_request *sci_req = &ireq->sci; 125 129 126 130 dev_dbg(&ireq->isci_host->pdev->dev, 127 131 "%s: request = %p\n", __func__, ireq); ··· 197 201 */ 198 202 status = scic_io_request_construct(&isci_host->sci, sci_device, 199 203 SCI_CONTROLLER_INVALID_IO_TAG, 200 - request, request->sci_req, 201 - &request->sci_request_handle); 204 + &request->sci); 202 205 203 206 if (status != SCI_SUCCESS) { 204 207 dev_warn(&isci_host->pdev->dev, ··· 205 210 __func__); 206 211 return SCI_FAILURE; 207 212 } 208 - 209 - request->sci_request_handle->ireq = request; 210 213 211 214 switch (task->task_proto) { 212 215 case SAS_PROTOCOL_SMP: ··· 269 276 request->isci_host = isci_host; 270 277 request->isci_device = isci_device; 271 278 request->io_request_completion = NULL; 279 + request->terminated = false; 272 280 273 - request->request_alloc_size = isci_host->dma_pool_alloc_size; 274 281 request->num_sg_entries = 0; 275 282 276 283 request->complete_in_target = false; ··· 374 381 goto out; 375 382 376 383 status = isci_io_request_build(isci_host, request, isci_device); 377 - if (status == SCI_SUCCESS) { 378 - 379 - spin_lock_irqsave(&isci_host->scic_lock, flags); 380 - 381 - /* send the request, let the core assign the IO TAG. */ 382 - status = scic_controller_start_io( 383 - &isci_host->sci, 384 - sci_device, 385 - request->sci_request_handle, 386 - SCI_CONTROLLER_INVALID_IO_TAG 387 - ); 388 - 389 - if (status == SCI_SUCCESS || 390 - status == SCI_FAILURE_REMOTE_DEVICE_RESET_REQUIRED) { 391 - 392 - /* Either I/O started OK, or the core has signaled that 393 - * the device needs a target reset. 394 - * 395 - * In either case, hold onto the I/O for later. 396 - * 397 - * Update it's status and add it to the list in the 398 - * remote device object. 399 - */ 400 - isci_request_change_state(request, started); 401 - list_add(&request->dev_node, 402 - &isci_device->reqs_in_process); 403 - 404 - if (status == SCI_SUCCESS) { 405 - /* Save the tag for possible task mgmt later. */ 406 - request->io_tag = scic_io_request_get_io_tag( 407 - request->sci_request_handle); 408 - } else { 409 - /* The request did not really start in the 410 - * hardware, so clear the request handle 411 - * here so no terminations will be done. 412 - */ 413 - request->sci_request_handle = NULL; 414 - } 415 - 416 - } else 417 - dev_warn(&isci_host->pdev->dev, 418 - "%s: failed request start (0x%x)\n", 419 - __func__, status); 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 - } 445 - 446 - } else 384 + if (status != SCI_SUCCESS) { 447 385 dev_warn(&isci_host->pdev->dev, 448 386 "%s: request_construct failed - status = 0x%x\n", 449 387 __func__, 450 388 status); 389 + goto out; 390 + } 391 + 392 + spin_lock_irqsave(&isci_host->scic_lock, flags); 393 + 394 + /* send the request, let the core assign the IO TAG. */ 395 + status = scic_controller_start_io(&isci_host->sci, sci_device, 396 + &request->sci, 397 + SCI_CONTROLLER_INVALID_IO_TAG); 398 + if (status != SCI_SUCCESS && 399 + status != SCI_FAILURE_REMOTE_DEVICE_RESET_REQUIRED) { 400 + dev_warn(&isci_host->pdev->dev, 401 + "%s: failed request start (0x%x)\n", 402 + __func__, status); 403 + spin_unlock_irqrestore(&isci_host->scic_lock, flags); 404 + goto out; 405 + } 406 + 407 + /* Either I/O started OK, or the core has signaled that 408 + * the device needs a target reset. 409 + * 410 + * In either case, hold onto the I/O for later. 411 + * 412 + * Update it's status and add it to the list in the 413 + * remote device object. 414 + */ 415 + isci_request_change_state(request, started); 416 + list_add(&request->dev_node, &isci_device->reqs_in_process); 417 + 418 + if (status == SCI_SUCCESS) { 419 + /* Save the tag for possible task mgmt later. */ 420 + request->io_tag = scic_io_request_get_io_tag(&request->sci); 421 + } else { 422 + /* The request did not really start in the 423 + * hardware, so clear the request handle 424 + * here so no terminations will be done. 425 + */ 426 + request->terminated = true; 427 + } 428 + spin_unlock_irqrestore(&isci_host->scic_lock, flags); 429 + 430 + if (status == 431 + SCI_FAILURE_REMOTE_DEVICE_RESET_REQUIRED) { 432 + /* Signal libsas that we need the SCSI error 433 + * handler thread to work on this I/O and that 434 + * we want a device reset. 435 + */ 436 + spin_lock_irqsave(&task->task_state_lock, flags); 437 + task->task_state_flags |= SAS_TASK_NEED_DEV_RESET; 438 + spin_unlock_irqrestore(&task->task_state_lock, flags); 439 + 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 + } 451 452 452 453 out: 453 454 if (status != SCI_SUCCESS) { ··· 541 554 { 542 555 unsigned int cstatus; 543 556 544 - cstatus = scic_request_get_controller_status( 545 - request->sci_request_handle 546 - ); 557 + cstatus = scic_request_get_controller_status(&request->sci); 547 558 548 559 dev_dbg(&request->isci_host->pdev->dev, 549 560 "%s: %p SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR " ··· 982 997 task); 983 998 984 999 if (sas_protocol_ata(task->task_proto)) { 985 - resp_buf = &request->sci_request_handle->stp.rsp; 1000 + resp_buf = &request->sci.stp.rsp; 986 1001 isci_request_process_stp_response(task, 987 1002 resp_buf); 988 1003 } else if (SAS_PROTOCOL_SSP == task->task_proto) { 989 1004 990 1005 /* crack the iu response buffer. */ 991 - resp_iu = &request->sci_request_handle->ssp.rsp; 1006 + resp_iu = &request->sci.ssp.rsp; 992 1007 isci_request_process_response_iu(task, resp_iu, 993 1008 &isci_host->pdev->dev); 994 1009 ··· 1019 1034 request->complete_in_target = true; 1020 1035 1021 1036 if (task->task_proto == SAS_PROTOCOL_SMP) { 1022 - void *rsp = &request->sci_request_handle->smp.rsp; 1037 + void *rsp = &request->sci.smp.rsp; 1023 1038 1024 1039 dev_dbg(&isci_host->pdev->dev, 1025 1040 "%s: SMP protocol completion\n", ··· 1036 1051 * the maximum was transferred. 1037 1052 */ 1038 1053 u32 transferred_length 1039 - = scic_io_request_get_number_of_bytes_transferred( 1040 - request->sci_request_handle); 1054 + = scic_io_request_get_number_of_bytes_transferred(&request->sci); 1041 1055 1042 1056 task->task_status.residual 1043 1057 = task->total_xfer_len - transferred_length; ··· 1149 1165 /* complete the io request to the core. */ 1150 1166 scic_controller_complete_io(&isci_host->sci, 1151 1167 &isci_device->sci, 1152 - request->sci_request_handle); 1153 - /* NULL the request handle so it cannot be completed or 1168 + &request->sci); 1169 + /* set terminated handle so it cannot be completed or 1154 1170 * terminated again, and to cause any calls into abort 1155 1171 * task to recognize the already completed case. 1156 1172 */ 1157 - request->sci_request_handle = NULL; 1173 + request->terminated = true; 1158 1174 1159 1175 isci_host_can_dequeue(isci_host, 1); 1160 1176 }
+9 -3
drivers/scsi/isci/request.h
··· 82 82 }; 83 83 84 84 struct isci_request { 85 - struct scic_sds_request *sci_request_handle; 86 85 enum isci_request_status status; 87 86 enum task_type ttype; 88 87 unsigned short io_tag; 89 88 bool complete_in_target; 89 + bool terminated; 90 90 91 91 union ttype_ptr_union { 92 92 struct sas_task *io_task_ptr; /* When ttype==io_task */ ··· 103 103 dma_addr_t zero_scatter_daddr; 104 104 105 105 unsigned int num_sg_entries; /* returned by pci_alloc_sg */ 106 - unsigned int request_alloc_size; /* size of block from dma_pool_alloc */ 107 106 108 107 /** Note: "io_request_completion" is completed in two different ways 109 108 * depending on whether this is a TMF or regular request. ··· 114 115 * TMF was aborting is guaranteed to have completed. 115 116 */ 116 117 struct completion *io_request_completion; 117 - struct scic_sds_request sci_req[0] ____cacheline_aligned; 118 + struct scic_sds_request sci; 118 119 }; 120 + 121 + static inline struct isci_request *sci_req_to_ireq(struct scic_sds_request *sci_req) 122 + { 123 + struct isci_request *ireq = container_of(sci_req, typeof(*ireq), sci); 124 + 125 + return ireq; 126 + } 119 127 120 128 /** 121 129 * This function gets the status of the request object.
+4 -6
drivers/scsi/isci/sata.c
··· 72 72 struct host_to_dev_fis *isci_sata_task_to_fis_copy(struct sas_task *task) 73 73 { 74 74 struct isci_request *ireq = task->lldd_task; 75 - struct host_to_dev_fis *fis = &ireq->sci_request_handle->stp.cmd; 75 + struct host_to_dev_fis *fis = &ireq->sci.stp.cmd; 76 76 77 77 memcpy(fis, &task->ata_task.fis, sizeof(struct host_to_dev_fis)); 78 78 ··· 118 118 struct isci_request *request = task->lldd_task; 119 119 120 120 register_fis->sector_count = qc->tag << 3; 121 - scic_stp_io_request_set_ncq_tag(request->sci_request_handle, qc->tag); 121 + scic_stp_io_request_set_ncq_tag(&request->sci, qc->tag); 122 122 } 123 123 124 124 /** ··· 156 156 157 157 enum sci_status isci_sata_management_task_request_build(struct isci_request *ireq) 158 158 { 159 - struct scic_sds_request *sci_req = ireq->sci_request_handle; 159 + struct scic_sds_request *sci_req = &ireq->sci; 160 160 struct isci_tmf *isci_tmf; 161 161 enum sci_status status; 162 162 ··· 190 190 /* core builds the protocol specific request 191 191 * based on the h2d fis. 192 192 */ 193 - status = scic_task_request_construct_sata( 194 - ireq->sci_request_handle 195 - ); 193 + status = scic_task_request_construct_sata(&ireq->sci); 196 194 197 195 return status; 198 196 }
+11 -19
drivers/scsi/isci/task.c
··· 300 300 /* let the core do it's construct. */ 301 301 status = scic_task_request_construct(&isci_host->sci, sci_device, 302 302 SCI_CONTROLLER_INVALID_IO_TAG, 303 - request, &request->sci_req, 304 - &request->sci_request_handle); 303 + &request->sci); 305 304 306 305 if (status != SCI_SUCCESS) { 307 306 dev_warn(&isci_host->pdev->dev, ··· 311 312 goto errout; 312 313 } 313 314 314 - request->sci_request_handle->ireq = request; 315 - 316 315 /* XXX convert to get this from task->tproto like other drivers */ 317 316 if (dev->dev_type == SAS_END_DEV) { 318 317 isci_tmf->proto = SAS_PROTOCOL_SSP; 319 - status = scic_task_request_construct_ssp( 320 - request->sci_request_handle 321 - ); 318 + status = scic_task_request_construct_ssp(&request->sci); 322 319 if (status != SCI_SUCCESS) 323 320 goto errout; 324 321 } ··· 371 376 status = scic_controller_terminate_request( 372 377 &request->isci_host->sci, 373 378 &request->isci_device->sci, 374 - request->sci_request_handle 375 - ); 379 + &request->sci); 376 380 377 381 dev_dbg(&request->isci_host->pdev->dev, 378 382 "%s: tmf_request = %p; tmf = %p; status = %d\n", ··· 461 467 status = scic_controller_start_task( 462 468 &isci_host->sci, 463 469 sci_device, 464 - request->sci_request_handle, 465 - SCI_CONTROLLER_INVALID_IO_TAG 466 - ); 470 + &request->sci, 471 + SCI_CONTROLLER_INVALID_IO_TAG); 467 472 468 473 if (status != SCI_TASK_SUCCESS) { 469 474 dev_warn(&isci_host->pdev->dev, ··· 757 764 * device condition (if the request handle is NULL, then the 758 765 * request completed but needed additional handling here). 759 766 */ 760 - if (isci_request->sci_request_handle != NULL) { 767 + if (!isci_request->terminated) { 761 768 was_terminated = true; 762 769 needs_cleanup_handling = true; 763 770 status = scic_controller_terminate_request( 764 771 &isci_host->sci, 765 772 &isci_device->sci, 766 - isci_request->sci_request_handle); 773 + &isci_request->sci); 767 774 } 768 775 spin_unlock_irqrestore(&isci_host->scic_lock, flags); 769 776 ··· 1423 1430 enum isci_request_status old_state; 1424 1431 struct isci_tmf *tmf = isci_request_access_tmf(ireq); 1425 1432 struct completion *tmf_complete; 1426 - struct scic_sds_request *sci_req = ireq->sci_request_handle; 1433 + struct scic_sds_request *sci_req = &ireq->sci; 1427 1434 1428 1435 dev_dbg(&ihost->pdev->dev, 1429 1436 "%s: request = %p, status=%d\n", ··· 1453 1460 /* PRINT_TMF( ((struct isci_tmf *)request->task)); */ 1454 1461 tmf_complete = tmf->complete; 1455 1462 1456 - scic_controller_complete_io(&ihost->sci, &idev->sci, 1457 - ireq->sci_request_handle); 1458 - /* NULL the request handle to make sure it cannot be terminated 1463 + scic_controller_complete_io(&ihost->sci, &idev->sci, &ireq->sci); 1464 + /* set the 'terminated' flag handle to make sure it cannot be terminated 1459 1465 * or completed again. 1460 1466 */ 1461 - ireq->sci_request_handle = NULL; 1467 + ireq->terminated = true;; 1462 1468 1463 1469 isci_request_change_state(ireq, unallocated); 1464 1470 list_del_init(&ireq->dev_node);