aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/scsi/isci/request.c48
-rw-r--r--drivers/scsi/isci/request.h12
-rw-r--r--drivers/scsi/isci/task.c23
3 files changed, 36 insertions, 47 deletions
diff --git a/drivers/scsi/isci/request.c b/drivers/scsi/isci/request.c
index 55859d5331b1..27376ba22483 100644
--- a/drivers/scsi/isci/request.c
+++ b/drivers/scsi/isci/request.c
@@ -2183,7 +2183,7 @@ static void isci_request_set_open_reject_status(
2183 enum sas_open_rej_reason open_rej_reason) 2183 enum sas_open_rej_reason open_rej_reason)
2184{ 2184{
2185 /* Task in the target is done. */ 2185 /* Task in the target is done. */
2186 request->complete_in_target = true; 2186 set_bit(IREQ_COMPLETE_IN_TARGET, &request->flags);
2187 *response_ptr = SAS_TASK_UNDELIVERED; 2187 *response_ptr = SAS_TASK_UNDELIVERED;
2188 *status_ptr = SAS_OPEN_REJECT; 2188 *status_ptr = SAS_OPEN_REJECT;
2189 *complete_to_host_ptr = isci_perform_normal_io_completion; 2189 *complete_to_host_ptr = isci_perform_normal_io_completion;
@@ -2248,7 +2248,7 @@ static void isci_request_handle_controller_specific_errors(
2248 else 2248 else
2249 *status_ptr = SAS_ABORTED_TASK; 2249 *status_ptr = SAS_ABORTED_TASK;
2250 2250
2251 request->complete_in_target = true; 2251 set_bit(IREQ_COMPLETE_IN_TARGET, &request->flags);
2252 2252
2253 *complete_to_host_ptr = 2253 *complete_to_host_ptr =
2254 isci_perform_normal_io_completion; 2254 isci_perform_normal_io_completion;
@@ -2261,7 +2261,7 @@ static void isci_request_handle_controller_specific_errors(
2261 else 2261 else
2262 *status_ptr = SAM_STAT_TASK_ABORTED; 2262 *status_ptr = SAM_STAT_TASK_ABORTED;
2263 2263
2264 request->complete_in_target = false; 2264 clear_bit(IREQ_COMPLETE_IN_TARGET, &request->flags);
2265 2265
2266 *complete_to_host_ptr = 2266 *complete_to_host_ptr =
2267 isci_perform_error_io_completion; 2267 isci_perform_error_io_completion;
@@ -2292,7 +2292,7 @@ static void isci_request_handle_controller_specific_errors(
2292 else 2292 else
2293 *status_ptr = SAS_ABORTED_TASK; 2293 *status_ptr = SAS_ABORTED_TASK;
2294 2294
2295 request->complete_in_target = true; 2295 set_bit(IREQ_COMPLETE_IN_TARGET, &request->flags);
2296 2296
2297 *complete_to_host_ptr = isci_perform_normal_io_completion; 2297 *complete_to_host_ptr = isci_perform_normal_io_completion;
2298 break; 2298 break;
@@ -2397,11 +2397,11 @@ static void isci_request_handle_controller_specific_errors(
2397 *status_ptr = SAM_STAT_TASK_ABORTED; 2397 *status_ptr = SAM_STAT_TASK_ABORTED;
2398 2398
2399 if (task->task_proto == SAS_PROTOCOL_SMP) { 2399 if (task->task_proto == SAS_PROTOCOL_SMP) {
2400 request->complete_in_target = true; 2400 set_bit(IREQ_COMPLETE_IN_TARGET, &request->flags);
2401 2401
2402 *complete_to_host_ptr = isci_perform_normal_io_completion; 2402 *complete_to_host_ptr = isci_perform_normal_io_completion;
2403 } else { 2403 } else {
2404 request->complete_in_target = false; 2404 clear_bit(IREQ_COMPLETE_IN_TARGET, &request->flags);
2405 2405
2406 *complete_to_host_ptr = isci_perform_error_io_completion; 2406 *complete_to_host_ptr = isci_perform_error_io_completion;
2407 } 2407 }
@@ -2552,7 +2552,7 @@ static void isci_request_io_request_complete(struct isci_host *isci_host,
2552 * 2552 *
2553 * The target is still there (since the TMF was successful). 2553 * The target is still there (since the TMF was successful).
2554 */ 2554 */
2555 request->complete_in_target = true; 2555 set_bit(IREQ_COMPLETE_IN_TARGET, &request->flags);
2556 response = SAS_TASK_COMPLETE; 2556 response = SAS_TASK_COMPLETE;
2557 2557
2558 /* See if the device has been/is being stopped. Note 2558 /* See if the device has been/is being stopped. Note
@@ -2579,7 +2579,7 @@ static void isci_request_io_request_complete(struct isci_host *isci_host,
2579 * Aborting also means an external thread is explicitly managing 2579 * Aborting also means an external thread is explicitly managing
2580 * this request, so that we do not complete it up the stack. 2580 * this request, so that we do not complete it up the stack.
2581 */ 2581 */
2582 request->complete_in_target = true; 2582 set_bit(IREQ_COMPLETE_IN_TARGET, &request->flags);
2583 response = SAS_TASK_UNDELIVERED; 2583 response = SAS_TASK_UNDELIVERED;
2584 2584
2585 if (!idev) 2585 if (!idev)
@@ -2605,7 +2605,7 @@ static void isci_request_io_request_complete(struct isci_host *isci_host,
2605 * the device (reset, tear down, etc.), and the I/O needs 2605 * the device (reset, tear down, etc.), and the I/O needs
2606 * to be completed up the stack. 2606 * to be completed up the stack.
2607 */ 2607 */
2608 request->complete_in_target = true; 2608 set_bit(IREQ_COMPLETE_IN_TARGET, &request->flags);
2609 response = SAS_TASK_UNDELIVERED; 2609 response = SAS_TASK_UNDELIVERED;
2610 2610
2611 /* See if the device has been/is being stopped. Note 2611 /* See if the device has been/is being stopped. Note
@@ -2675,7 +2675,7 @@ static void isci_request_io_request_complete(struct isci_host *isci_host,
2675 /* use the task status set in the task struct by the 2675 /* use the task status set in the task struct by the
2676 * isci_request_process_response_iu call. 2676 * isci_request_process_response_iu call.
2677 */ 2677 */
2678 request->complete_in_target = true; 2678 set_bit(IREQ_COMPLETE_IN_TARGET, &request->flags);
2679 response = task->task_status.resp; 2679 response = task->task_status.resp;
2680 status = task->task_status.stat; 2680 status = task->task_status.stat;
2681 break; 2681 break;
@@ -2685,7 +2685,7 @@ static void isci_request_io_request_complete(struct isci_host *isci_host,
2685 2685
2686 response = SAS_TASK_COMPLETE; 2686 response = SAS_TASK_COMPLETE;
2687 status = SAM_STAT_GOOD; 2687 status = SAM_STAT_GOOD;
2688 request->complete_in_target = true; 2688 set_bit(IREQ_COMPLETE_IN_TARGET, &request->flags);
2689 2689
2690 if (task->task_proto == SAS_PROTOCOL_SMP) { 2690 if (task->task_proto == SAS_PROTOCOL_SMP) {
2691 void *rsp = &request->sci.smp.rsp; 2691 void *rsp = &request->sci.smp.rsp;
@@ -2737,7 +2737,7 @@ static void isci_request_io_request_complete(struct isci_host *isci_host,
2737 /* The request was terminated explicitly. No handling 2737 /* The request was terminated explicitly. No handling
2738 * is needed in the SCSI error handler path. 2738 * is needed in the SCSI error handler path.
2739 */ 2739 */
2740 request->complete_in_target = true; 2740 set_bit(IREQ_COMPLETE_IN_TARGET, &request->flags);
2741 response = SAS_TASK_UNDELIVERED; 2741 response = SAS_TASK_UNDELIVERED;
2742 2742
2743 /* See if the device has been/is being stopped. Note 2743 /* See if the device has been/is being stopped. Note
@@ -2777,7 +2777,7 @@ static void isci_request_io_request_complete(struct isci_host *isci_host,
2777 status = SAM_STAT_TASK_ABORTED; 2777 status = SAM_STAT_TASK_ABORTED;
2778 2778
2779 complete_to_host = isci_perform_error_io_completion; 2779 complete_to_host = isci_perform_error_io_completion;
2780 request->complete_in_target = false; 2780 clear_bit(IREQ_COMPLETE_IN_TARGET, &request->flags);
2781 break; 2781 break;
2782 2782
2783 case SCI_FAILURE_RETRY_REQUIRED: 2783 case SCI_FAILURE_RETRY_REQUIRED:
@@ -2790,7 +2790,7 @@ static void isci_request_io_request_complete(struct isci_host *isci_host,
2790 status = SAS_ABORTED_TASK; 2790 status = SAS_ABORTED_TASK;
2791 2791
2792 complete_to_host = isci_perform_normal_io_completion; 2792 complete_to_host = isci_perform_normal_io_completion;
2793 request->complete_in_target = true; 2793 set_bit(IREQ_COMPLETE_IN_TARGET, &request->flags);
2794 break; 2794 break;
2795 2795
2796 2796
@@ -2813,10 +2813,10 @@ static void isci_request_io_request_complete(struct isci_host *isci_host,
2813 status = SAS_ABORTED_TASK; 2813 status = SAS_ABORTED_TASK;
2814 2814
2815 if (SAS_PROTOCOL_SMP == task->task_proto) { 2815 if (SAS_PROTOCOL_SMP == task->task_proto) {
2816 request->complete_in_target = true; 2816 set_bit(IREQ_COMPLETE_IN_TARGET, &request->flags);
2817 complete_to_host = isci_perform_normal_io_completion; 2817 complete_to_host = isci_perform_normal_io_completion;
2818 } else { 2818 } else {
2819 request->complete_in_target = false; 2819 clear_bit(IREQ_COMPLETE_IN_TARGET, &request->flags);
2820 complete_to_host = isci_perform_error_io_completion; 2820 complete_to_host = isci_perform_error_io_completion;
2821 } 2821 }
2822 break; 2822 break;
@@ -2870,7 +2870,7 @@ static void isci_request_io_request_complete(struct isci_host *isci_host,
2870 * terminated again, and to cause any calls into abort 2870 * terminated again, and to cause any calls into abort
2871 * task to recognize the already completed case. 2871 * task to recognize the already completed case.
2872 */ 2872 */
2873 request->terminated = true; 2873 set_bit(IREQ_TERMINATED, &request->flags);
2874} 2874}
2875 2875
2876static void scic_sds_request_started_state_enter(struct sci_base_state_machine *sm) 2876static void scic_sds_request_started_state_enter(struct sci_base_state_machine *sm)
@@ -2919,7 +2919,7 @@ static void scic_sds_request_completed_state_enter(struct sci_base_state_machine
2919 struct isci_request *ireq = sci_req_to_ireq(sci_req); 2919 struct isci_request *ireq = sci_req_to_ireq(sci_req);
2920 2920
2921 /* Tell the SCI_USER that the IO request is complete */ 2921 /* Tell the SCI_USER that the IO request is complete */
2922 if (sci_req->is_task_management_request == false) 2922 if (!test_bit(IREQ_TMF, &ireq->flags))
2923 isci_request_io_request_complete(ihost, ireq, 2923 isci_request_io_request_complete(ihost, ireq,
2924 sci_req->sci_status); 2924 sci_req->sci_status);
2925 else 2925 else
@@ -3032,8 +3032,6 @@ scic_sds_general_request_construct(struct scic_sds_controller *scic,
3032 sci_req->scu_status = 0; 3032 sci_req->scu_status = 0;
3033 sci_req->post_context = 0xFFFFFFFF; 3033 sci_req->post_context = 0xFFFFFFFF;
3034 sci_req->tc = &scic->task_context_table[ISCI_TAG_TCI(io_tag)]; 3034 sci_req->tc = &scic->task_context_table[ISCI_TAG_TCI(io_tag)];
3035
3036 sci_req->is_task_management_request = false;
3037 WARN_ONCE(io_tag == SCI_CONTROLLER_INVALID_IO_TAG, "straggling invalid tag usage\n"); 3035 WARN_ONCE(io_tag == SCI_CONTROLLER_INVALID_IO_TAG, "straggling invalid tag usage\n");
3038} 3036}
3039 3037
@@ -3077,7 +3075,7 @@ enum sci_status scic_task_request_construct(struct scic_sds_controller *scic,
3077 3075
3078 if (dev->dev_type == SAS_END_DEV || 3076 if (dev->dev_type == SAS_END_DEV ||
3079 dev->dev_type == SATA_DEV || (dev->tproto & SAS_PROTOCOL_STP)) { 3077 dev->dev_type == SATA_DEV || (dev->tproto & SAS_PROTOCOL_STP)) {
3080 sci_req->is_task_management_request = true; 3078 set_bit(IREQ_TMF, &sci_req_to_ireq(sci_req)->flags);
3081 memset(sci_req->tc, 0, sizeof(struct scu_task_context)); 3079 memset(sci_req->tc, 0, sizeof(struct scu_task_context));
3082 } else 3080 } else
3083 status = SCI_FAILURE_UNSUPPORTED_PROTOCOL; 3081 status = SCI_FAILURE_UNSUPPORTED_PROTOCOL;
@@ -3379,12 +3377,8 @@ static struct isci_request *isci_request_alloc_core(struct isci_host *ihost,
3379 ireq->request_daddr = handle; 3377 ireq->request_daddr = handle;
3380 ireq->isci_host = ihost; 3378 ireq->isci_host = ihost;
3381 ireq->io_request_completion = NULL; 3379 ireq->io_request_completion = NULL;
3382 ireq->terminated = false; 3380 ireq->flags = 0;
3383
3384 ireq->num_sg_entries = 0; 3381 ireq->num_sg_entries = 0;
3385
3386 ireq->complete_in_target = false;
3387
3388 INIT_LIST_HEAD(&ireq->completed_node); 3382 INIT_LIST_HEAD(&ireq->completed_node);
3389 INIT_LIST_HEAD(&ireq->dev_node); 3383 INIT_LIST_HEAD(&ireq->dev_node);
3390 3384
@@ -3496,7 +3490,7 @@ int isci_request_execute(struct isci_host *ihost, struct isci_remote_device *ide
3496 * hardware, so clear the request handle 3490 * hardware, so clear the request handle
3497 * here so no terminations will be done. 3491 * here so no terminations will be done.
3498 */ 3492 */
3499 ireq->terminated = true; 3493 set_bit(IREQ_TERMINATED, &ireq->flags);
3500 isci_request_change_state(ireq, completed); 3494 isci_request_change_state(ireq, completed);
3501 } 3495 }
3502 spin_unlock_irqrestore(&ihost->scic_lock, flags); 3496 spin_unlock_irqrestore(&ihost->scic_lock, flags);
diff --git a/drivers/scsi/isci/request.h b/drivers/scsi/isci/request.h
index 8c77c4cbe04a..f440e421ea0e 100644
--- a/drivers/scsi/isci/request.h
+++ b/drivers/scsi/isci/request.h
@@ -210,12 +210,6 @@ struct scic_sds_request {
210 struct scu_sgl_element_pair sg_table[SCU_SGL_SIZE] __attribute__ ((aligned(32))); 210 struct scu_sgl_element_pair sg_table[SCU_SGL_SIZE] __attribute__ ((aligned(32)));
211 211
212 /* 212 /*
213 * This field indicates if this request is a task management request or
214 * normal IO request.
215 */
216 bool is_task_management_request;
217
218 /*
219 * This field is a pointer to the stored rx frame data. It is used in 213 * This field is a pointer to the stored rx frame data. It is used in
220 * STP internal requests and SMP response frames. If this field is 214 * STP internal requests and SMP response frames. If this field is
221 * non-NULL the saved frame must be released on IO request completion. 215 * non-NULL the saved frame must be released on IO request completion.
@@ -260,8 +254,10 @@ struct isci_request {
260 enum isci_request_status status; 254 enum isci_request_status status;
261 enum task_type ttype; 255 enum task_type ttype;
262 unsigned short io_tag; 256 unsigned short io_tag;
263 bool complete_in_target; 257 #define IREQ_COMPLETE_IN_TARGET 0
264 bool terminated; 258 #define IREQ_TERMINATED 1
259 #define IREQ_TMF 2
260 unsigned long flags;
265 261
266 union ttype_ptr_union { 262 union ttype_ptr_union {
267 struct sas_task *io_task_ptr; /* When ttype==io_task */ 263 struct sas_task *io_task_ptr; /* When ttype==io_task */
diff --git a/drivers/scsi/isci/task.c b/drivers/scsi/isci/task.c
index 22f6fe171111..d1a46710f4a7 100644
--- a/drivers/scsi/isci/task.c
+++ b/drivers/scsi/isci/task.c
@@ -558,15 +558,15 @@ static void isci_terminate_request_core(
558 : NULL; 558 : NULL;
559 559
560 /* Note that we are not going to control 560 /* Note that we are not going to control
561 * the target to abort the request. 561 * the target to abort the request.
562 */ 562 */
563 isci_request->complete_in_target = true; 563 set_bit(IREQ_COMPLETE_IN_TARGET, &isci_request->flags);
564 564
565 /* Make sure the request wasn't just sitting around signalling 565 /* Make sure the request wasn't just sitting around signalling
566 * device condition (if the request handle is NULL, then the 566 * device condition (if the request handle is NULL, then the
567 * request completed but needed additional handling here). 567 * request completed but needed additional handling here).
568 */ 568 */
569 if (!isci_request->terminated) { 569 if (!test_bit(IREQ_TERMINATED, &isci_request->flags)) {
570 was_terminated = true; 570 was_terminated = true;
571 needs_cleanup_handling = true; 571 needs_cleanup_handling = true;
572 status = scic_controller_terminate_request( 572 status = scic_controller_terminate_request(
@@ -609,7 +609,7 @@ static void isci_terminate_request_core(
609 flags); 609 flags);
610 610
611 /* Check for state changes. */ 611 /* Check for state changes. */
612 if (!isci_request->terminated) { 612 if (!test_bit(IREQ_TERMINATED, &isci_request->flags)) {
613 613
614 /* The best we can do is to have the 614 /* The best we can do is to have the
615 * request die a silent death if it 615 * request die a silent death if it
@@ -1098,9 +1098,8 @@ int isci_task_abort_task(struct sas_task *task)
1098 ret = TMF_RESP_FUNC_COMPLETE; 1098 ret = TMF_RESP_FUNC_COMPLETE;
1099 goto out; 1099 goto out;
1100 } 1100 }
1101 if ((task->task_proto == SAS_PROTOCOL_SMP) 1101 if (task->task_proto == SAS_PROTOCOL_SMP ||
1102 || old_request->complete_in_target 1102 test_bit(IREQ_COMPLETE_IN_TARGET, &old_request->flags)) {
1103 ) {
1104 1103
1105 spin_unlock_irqrestore(&isci_host->scic_lock, flags); 1104 spin_unlock_irqrestore(&isci_host->scic_lock, flags);
1106 1105
@@ -1108,7 +1107,7 @@ int isci_task_abort_task(struct sas_task *task)
1108 "%s: SMP request (%d)" 1107 "%s: SMP request (%d)"
1109 " or complete_in_target (%d), thus no TMF\n", 1108 " or complete_in_target (%d), thus no TMF\n",
1110 __func__, (task->task_proto == SAS_PROTOCOL_SMP), 1109 __func__, (task->task_proto == SAS_PROTOCOL_SMP),
1111 old_request->complete_in_target); 1110 test_bit(IREQ_COMPLETE_IN_TARGET, &old_request->flags));
1112 1111
1113 /* Set the state on the task. */ 1112 /* Set the state on the task. */
1114 isci_task_all_done(task); 1113 isci_task_all_done(task);
@@ -1136,7 +1135,7 @@ int isci_task_abort_task(struct sas_task *task)
1136 __func__); 1135 __func__);
1137 } 1136 }
1138 if (ret == TMF_RESP_FUNC_COMPLETE) { 1137 if (ret == TMF_RESP_FUNC_COMPLETE) {
1139 old_request->complete_in_target = true; 1138 set_bit(IREQ_COMPLETE_IN_TARGET, &old_request->flags);
1140 1139
1141 /* Clean up the request on our side, and wait for the aborted 1140 /* Clean up the request on our side, and wait for the aborted
1142 * I/O to complete. 1141 * I/O to complete.
@@ -1252,7 +1251,7 @@ isci_task_request_complete(struct isci_host *ihost,
1252 isci_request_change_state(ireq, completed); 1251 isci_request_change_state(ireq, completed);
1253 1252
1254 tmf->status = completion_status; 1253 tmf->status = completion_status;
1255 ireq->complete_in_target = true; 1254 set_bit(IREQ_COMPLETE_IN_TARGET, &ireq->flags);
1256 1255
1257 if (tmf->proto == SAS_PROTOCOL_SSP) { 1256 if (tmf->proto == SAS_PROTOCOL_SSP) {
1258 memcpy(&tmf->resp.resp_iu, 1257 memcpy(&tmf->resp.resp_iu,
@@ -1271,7 +1270,7 @@ isci_task_request_complete(struct isci_host *ihost,
1271 /* set the 'terminated' flag handle to make sure it cannot be terminated 1270 /* set the 'terminated' flag handle to make sure it cannot be terminated
1272 * or completed again. 1271 * or completed again.
1273 */ 1272 */
1274 ireq->terminated = true;; 1273 set_bit(IREQ_TERMINATED, &ireq->flags);
1275 1274
1276 isci_request_change_state(ireq, unallocated); 1275 isci_request_change_state(ireq, unallocated);
1277 list_del_init(&ireq->dev_node); 1276 list_del_init(&ireq->dev_node);