diff options
author | Dan Williams <dan.j.williams@intel.com> | 2011-05-10 05:39:11 -0400 |
---|---|---|
committer | Dan Williams <dan.j.williams@intel.com> | 2011-07-03 07:04:48 -0400 |
commit | f00e6ba4996a34f098fe50c78077f0568fd838ec (patch) | |
tree | 02bbbc01b8c392ca99b26c194580fc7a0f4f854a /drivers/scsi/isci/request.c | |
parent | 5dec6f4e41340196d223caf922578c44dfe2295a (diff) |
isci: unify request abort handlers
Unify the implementation in scic_sds_io_request_terminate and kill the state
handler.
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.c | 146 |
1 files changed, 50 insertions, 96 deletions
diff --git a/drivers/scsi/isci/request.c b/drivers/scsi/isci/request.c index f503e3e18d8f..69688636347e 100644 --- a/drivers/scsi/isci/request.c +++ b/drivers/scsi/isci/request.c | |||
@@ -777,16 +777,58 @@ scic_sds_request_start(struct scic_sds_request *request) | |||
777 | } | 777 | } |
778 | 778 | ||
779 | enum sci_status | 779 | enum sci_status |
780 | scic_sds_io_request_terminate(struct scic_sds_request *request) | 780 | scic_sds_io_request_terminate(struct scic_sds_request *sci_req) |
781 | { | 781 | { |
782 | if (request->state_handlers->abort_handler) | 782 | enum sci_base_request_states state; |
783 | return request->state_handlers->abort_handler(request); | ||
784 | 783 | ||
785 | dev_warn(scic_to_dev(request->owning_controller), | 784 | state = sci_req->state_machine.current_state_id; |
786 | "%s: SCIC IO Request requested to abort while in wrong " | 785 | |
787 | "state %d\n", | 786 | switch (state) { |
788 | __func__, | 787 | case SCI_BASE_REQUEST_STATE_CONSTRUCTED: |
789 | sci_base_state_machine_get_state(&request->state_machine)); | 788 | scic_sds_request_set_status(sci_req, |
789 | SCU_TASK_DONE_TASK_ABORT, | ||
790 | SCI_FAILURE_IO_TERMINATED); | ||
791 | |||
792 | sci_base_state_machine_change_state(&sci_req->state_machine, | ||
793 | SCI_BASE_REQUEST_STATE_COMPLETED); | ||
794 | return SCI_SUCCESS; | ||
795 | case SCI_BASE_REQUEST_STATE_STARTED: | ||
796 | case SCIC_SDS_IO_REQUEST_STARTED_TASK_MGMT_SUBSTATE_AWAIT_TC_COMPLETION: | ||
797 | case SCIC_SDS_SMP_REQUEST_STARTED_SUBSTATE_AWAIT_RESPONSE: | ||
798 | case SCIC_SDS_SMP_REQUEST_STARTED_SUBSTATE_AWAIT_TC_COMPLETION: | ||
799 | case SCIC_SDS_STP_REQUEST_STARTED_UDMA_AWAIT_TC_COMPLETION_SUBSTATE: | ||
800 | case SCIC_SDS_STP_REQUEST_STARTED_UDMA_AWAIT_D2H_REG_FIS_SUBSTATE: | ||
801 | case SCIC_SDS_STP_REQUEST_STARTED_NON_DATA_AWAIT_H2D_COMPLETION_SUBSTATE: | ||
802 | case SCIC_SDS_STP_REQUEST_STARTED_NON_DATA_AWAIT_D2H_SUBSTATE: | ||
803 | case SCIC_SDS_STP_REQUEST_STARTED_PIO_AWAIT_H2D_COMPLETION_SUBSTATE: | ||
804 | case SCIC_SDS_STP_REQUEST_STARTED_PIO_AWAIT_FRAME_SUBSTATE: | ||
805 | case SCIC_SDS_STP_REQUEST_STARTED_PIO_DATA_IN_AWAIT_DATA_SUBSTATE: | ||
806 | case SCIC_SDS_STP_REQUEST_STARTED_PIO_DATA_OUT_TRANSMIT_DATA_SUBSTATE: | ||
807 | case SCIC_SDS_STP_REQUEST_STARTED_SOFT_RESET_AWAIT_H2D_ASSERTED_COMPLETION_SUBSTATE: | ||
808 | case SCIC_SDS_STP_REQUEST_STARTED_SOFT_RESET_AWAIT_H2D_DIAGNOSTIC_COMPLETION_SUBSTATE: | ||
809 | case SCIC_SDS_STP_REQUEST_STARTED_SOFT_RESET_AWAIT_D2H_RESPONSE_FRAME_SUBSTATE: | ||
810 | sci_base_state_machine_change_state(&sci_req->state_machine, | ||
811 | SCI_BASE_REQUEST_STATE_ABORTING); | ||
812 | return SCI_SUCCESS; | ||
813 | case SCIC_SDS_IO_REQUEST_STARTED_TASK_MGMT_SUBSTATE_AWAIT_TC_RESPONSE: | ||
814 | sci_base_state_machine_change_state(&sci_req->state_machine, | ||
815 | SCI_BASE_REQUEST_STATE_ABORTING); | ||
816 | sci_base_state_machine_change_state(&sci_req->state_machine, | ||
817 | SCI_BASE_REQUEST_STATE_COMPLETED); | ||
818 | return SCI_SUCCESS; | ||
819 | case SCI_BASE_REQUEST_STATE_ABORTING: | ||
820 | sci_base_state_machine_change_state(&sci_req->state_machine, | ||
821 | SCI_BASE_REQUEST_STATE_COMPLETED); | ||
822 | return SCI_SUCCESS; | ||
823 | case SCI_BASE_REQUEST_STATE_COMPLETED: | ||
824 | default: | ||
825 | dev_warn(scic_to_dev(sci_req->owning_controller), | ||
826 | "%s: SCIC IO Request requested to abort while in wrong " | ||
827 | "state %d\n", | ||
828 | __func__, | ||
829 | sci_base_state_machine_get_state(&sci_req->state_machine)); | ||
830 | break; | ||
831 | } | ||
790 | 832 | ||
791 | return SCI_FAILURE_INVALID_STATE; | 833 | return SCI_FAILURE_INVALID_STATE; |
792 | } | 834 | } |
@@ -931,34 +973,6 @@ static enum sci_status scic_sds_request_constructed_state_start_handler( | |||
931 | } | 973 | } |
932 | 974 | ||
933 | /* | 975 | /* |
934 | * This method implements the action to be taken when an SCIC_SDS_IO_REQUEST_T | ||
935 | * object receives a scic_sds_request_terminate() request. Since the request | ||
936 | * has not yet been posted to the hardware the request transitions to the | ||
937 | * completed state. enum sci_status SCI_SUCCESS | ||
938 | */ | ||
939 | static enum sci_status scic_sds_request_constructed_state_abort_handler( | ||
940 | struct scic_sds_request *request) | ||
941 | { | ||
942 | /* | ||
943 | * This request has been terminated by the user make sure that the correct | ||
944 | * status code is returned */ | ||
945 | scic_sds_request_set_status(request, | ||
946 | SCU_TASK_DONE_TASK_ABORT, | ||
947 | SCI_FAILURE_IO_TERMINATED); | ||
948 | |||
949 | sci_base_state_machine_change_state(&request->state_machine, | ||
950 | SCI_BASE_REQUEST_STATE_COMPLETED); | ||
951 | return SCI_SUCCESS; | ||
952 | } | ||
953 | |||
954 | static enum sci_status scic_sds_request_started_state_abort_handler(struct scic_sds_request *sci_req) | ||
955 | { | ||
956 | sci_base_state_machine_change_state(&sci_req->state_machine, | ||
957 | SCI_BASE_REQUEST_STATE_ABORTING); | ||
958 | return SCI_SUCCESS; | ||
959 | } | ||
960 | |||
961 | /* | ||
962 | * scic_sds_request_started_state_tc_completion_handler() - This method process | 976 | * scic_sds_request_started_state_tc_completion_handler() - This method process |
963 | * TC (task context) completions for normal IO request (i.e. Task/Abort | 977 | * TC (task context) completions for normal IO request (i.e. Task/Abort |
964 | * Completions of type 0). This method will update the | 978 | * Completions of type 0). This method will update the |
@@ -1248,26 +1262,6 @@ static enum sci_status scic_sds_request_completed_state_complete_handler( | |||
1248 | } | 1262 | } |
1249 | 1263 | ||
1250 | /* | 1264 | /* |
1251 | * ***************************************************************************** | ||
1252 | * * ABORTING STATE HANDLERS | ||
1253 | * ***************************************************************************** */ | ||
1254 | |||
1255 | /* | ||
1256 | * This method implements the action to be taken when an SCIC_SDS_IO_REQUEST_T | ||
1257 | * object receives a scic_sds_request_terminate() request. This method is the | ||
1258 | * io request aborting state abort handlers. On receipt of a multiple | ||
1259 | * terminate requests the io request will transition to the completed state. | ||
1260 | * This should not happen in normal operation. enum sci_status SCI_SUCCESS | ||
1261 | */ | ||
1262 | static enum sci_status scic_sds_request_aborting_state_abort_handler( | ||
1263 | struct scic_sds_request *request) | ||
1264 | { | ||
1265 | sci_base_state_machine_change_state(&request->state_machine, | ||
1266 | SCI_BASE_REQUEST_STATE_COMPLETED); | ||
1267 | return SCI_SUCCESS; | ||
1268 | } | ||
1269 | |||
1270 | /* | ||
1271 | * This method implements the action to be taken when an SCIC_SDS_IO_REQUEST_T | 1265 | * This method implements the action to be taken when an SCIC_SDS_IO_REQUEST_T |
1272 | * object receives a scic_sds_request_task_completion() request. This method | 1266 | * object receives a scic_sds_request_task_completion() request. This method |
1273 | * decodes the completion type waiting for the abort task complete | 1267 | * decodes the completion type waiting for the abort task complete |
@@ -1379,28 +1373,6 @@ static enum sci_status scic_sds_ssp_task_request_await_tc_completion_tc_completi | |||
1379 | } | 1373 | } |
1380 | 1374 | ||
1381 | /** | 1375 | /** |
1382 | * This method is responsible for processing a terminate/abort request for this | ||
1383 | * TC while the request is waiting for the task management response | ||
1384 | * unsolicited frame. | ||
1385 | * @sci_req: This parameter specifies the request for which the | ||
1386 | * termination was requested. | ||
1387 | * | ||
1388 | * This method returns an indication as to whether the abort request was | ||
1389 | * successfully handled. need to update to ensure the received UF doesn't cause | ||
1390 | * damage to subsequent requests (i.e. put the extended tag in a holding | ||
1391 | * pattern for this particular device). | ||
1392 | */ | ||
1393 | static enum sci_status scic_sds_ssp_task_request_await_tc_response_abort_handler( | ||
1394 | struct scic_sds_request *request) | ||
1395 | { | ||
1396 | sci_base_state_machine_change_state(&request->state_machine, | ||
1397 | SCI_BASE_REQUEST_STATE_ABORTING); | ||
1398 | sci_base_state_machine_change_state(&request->state_machine, | ||
1399 | SCI_BASE_REQUEST_STATE_COMPLETED); | ||
1400 | return SCI_SUCCESS; | ||
1401 | } | ||
1402 | |||
1403 | /** | ||
1404 | * This method processes an unsolicited frame while the task mgmt request is | 1376 | * This method processes an unsolicited frame while the task mgmt request is |
1405 | * waiting for a response frame. It will copy the response data, release | 1377 | * waiting for a response frame. It will copy the response data, release |
1406 | * the unsolicited frame, and transition the request to the | 1378 | * the unsolicited frame, and transition the request to the |
@@ -2560,81 +2532,63 @@ static const struct scic_sds_io_request_state_handler scic_sds_request_state_han | |||
2560 | [SCI_BASE_REQUEST_STATE_INITIAL] = { }, | 2532 | [SCI_BASE_REQUEST_STATE_INITIAL] = { }, |
2561 | [SCI_BASE_REQUEST_STATE_CONSTRUCTED] = { | 2533 | [SCI_BASE_REQUEST_STATE_CONSTRUCTED] = { |
2562 | .start_handler = scic_sds_request_constructed_state_start_handler, | 2534 | .start_handler = scic_sds_request_constructed_state_start_handler, |
2563 | .abort_handler = scic_sds_request_constructed_state_abort_handler, | ||
2564 | }, | 2535 | }, |
2565 | [SCI_BASE_REQUEST_STATE_STARTED] = { | 2536 | [SCI_BASE_REQUEST_STATE_STARTED] = { |
2566 | .abort_handler = scic_sds_request_started_state_abort_handler, | ||
2567 | .tc_completion_handler = scic_sds_request_started_state_tc_completion_handler, | 2537 | .tc_completion_handler = scic_sds_request_started_state_tc_completion_handler, |
2568 | .frame_handler = scic_sds_request_started_state_frame_handler, | 2538 | .frame_handler = scic_sds_request_started_state_frame_handler, |
2569 | }, | 2539 | }, |
2570 | [SCIC_SDS_IO_REQUEST_STARTED_TASK_MGMT_SUBSTATE_AWAIT_TC_COMPLETION] = { | 2540 | [SCIC_SDS_IO_REQUEST_STARTED_TASK_MGMT_SUBSTATE_AWAIT_TC_COMPLETION] = { |
2571 | .abort_handler = scic_sds_request_started_state_abort_handler, | ||
2572 | .tc_completion_handler = scic_sds_ssp_task_request_await_tc_completion_tc_completion_handler, | 2541 | .tc_completion_handler = scic_sds_ssp_task_request_await_tc_completion_tc_completion_handler, |
2573 | }, | 2542 | }, |
2574 | [SCIC_SDS_IO_REQUEST_STARTED_TASK_MGMT_SUBSTATE_AWAIT_TC_RESPONSE] = { | 2543 | [SCIC_SDS_IO_REQUEST_STARTED_TASK_MGMT_SUBSTATE_AWAIT_TC_RESPONSE] = { |
2575 | .abort_handler = scic_sds_ssp_task_request_await_tc_response_abort_handler, | ||
2576 | .frame_handler = scic_sds_ssp_task_request_await_tc_response_frame_handler, | 2544 | .frame_handler = scic_sds_ssp_task_request_await_tc_response_frame_handler, |
2577 | }, | 2545 | }, |
2578 | [SCIC_SDS_SMP_REQUEST_STARTED_SUBSTATE_AWAIT_RESPONSE] = { | 2546 | [SCIC_SDS_SMP_REQUEST_STARTED_SUBSTATE_AWAIT_RESPONSE] = { |
2579 | .abort_handler = scic_sds_request_started_state_abort_handler, | ||
2580 | .tc_completion_handler = scic_sds_smp_request_await_response_tc_completion_handler, | 2547 | .tc_completion_handler = scic_sds_smp_request_await_response_tc_completion_handler, |
2581 | .frame_handler = scic_sds_smp_request_await_response_frame_handler, | 2548 | .frame_handler = scic_sds_smp_request_await_response_frame_handler, |
2582 | }, | 2549 | }, |
2583 | [SCIC_SDS_SMP_REQUEST_STARTED_SUBSTATE_AWAIT_TC_COMPLETION] = { | 2550 | [SCIC_SDS_SMP_REQUEST_STARTED_SUBSTATE_AWAIT_TC_COMPLETION] = { |
2584 | .abort_handler = scic_sds_request_started_state_abort_handler, | ||
2585 | .tc_completion_handler = scic_sds_smp_request_await_tc_completion_tc_completion_handler, | 2551 | .tc_completion_handler = scic_sds_smp_request_await_tc_completion_tc_completion_handler, |
2586 | }, | 2552 | }, |
2587 | [SCIC_SDS_STP_REQUEST_STARTED_UDMA_AWAIT_TC_COMPLETION_SUBSTATE] = { | 2553 | [SCIC_SDS_STP_REQUEST_STARTED_UDMA_AWAIT_TC_COMPLETION_SUBSTATE] = { |
2588 | .abort_handler = scic_sds_request_started_state_abort_handler, | ||
2589 | .tc_completion_handler = scic_sds_stp_request_udma_await_tc_completion_tc_completion_handler, | 2554 | .tc_completion_handler = scic_sds_stp_request_udma_await_tc_completion_tc_completion_handler, |
2590 | .frame_handler = scic_sds_stp_request_udma_general_frame_handler, | 2555 | .frame_handler = scic_sds_stp_request_udma_general_frame_handler, |
2591 | }, | 2556 | }, |
2592 | [SCIC_SDS_STP_REQUEST_STARTED_UDMA_AWAIT_D2H_REG_FIS_SUBSTATE] = { | 2557 | [SCIC_SDS_STP_REQUEST_STARTED_UDMA_AWAIT_D2H_REG_FIS_SUBSTATE] = { |
2593 | .abort_handler = scic_sds_request_started_state_abort_handler, | ||
2594 | .frame_handler = scic_sds_stp_request_udma_await_d2h_reg_fis_frame_handler, | 2558 | .frame_handler = scic_sds_stp_request_udma_await_d2h_reg_fis_frame_handler, |
2595 | }, | 2559 | }, |
2596 | [SCIC_SDS_STP_REQUEST_STARTED_NON_DATA_AWAIT_H2D_COMPLETION_SUBSTATE] = { | 2560 | [SCIC_SDS_STP_REQUEST_STARTED_NON_DATA_AWAIT_H2D_COMPLETION_SUBSTATE] = { |
2597 | .abort_handler = scic_sds_request_started_state_abort_handler, | ||
2598 | .tc_completion_handler = scic_sds_stp_request_non_data_await_h2d_tc_completion_handler, | 2561 | .tc_completion_handler = scic_sds_stp_request_non_data_await_h2d_tc_completion_handler, |
2599 | }, | 2562 | }, |
2600 | [SCIC_SDS_STP_REQUEST_STARTED_NON_DATA_AWAIT_D2H_SUBSTATE] = { | 2563 | [SCIC_SDS_STP_REQUEST_STARTED_NON_DATA_AWAIT_D2H_SUBSTATE] = { |
2601 | .abort_handler = scic_sds_request_started_state_abort_handler, | ||
2602 | .frame_handler = scic_sds_stp_request_non_data_await_d2h_frame_handler, | 2564 | .frame_handler = scic_sds_stp_request_non_data_await_d2h_frame_handler, |
2603 | }, | 2565 | }, |
2604 | [SCIC_SDS_STP_REQUEST_STARTED_PIO_AWAIT_H2D_COMPLETION_SUBSTATE] = { | 2566 | [SCIC_SDS_STP_REQUEST_STARTED_PIO_AWAIT_H2D_COMPLETION_SUBSTATE] = { |
2605 | .abort_handler = scic_sds_request_started_state_abort_handler, | ||
2606 | .tc_completion_handler = scic_sds_stp_request_pio_await_h2d_completion_tc_completion_handler, | 2567 | .tc_completion_handler = scic_sds_stp_request_pio_await_h2d_completion_tc_completion_handler, |
2607 | }, | 2568 | }, |
2608 | [SCIC_SDS_STP_REQUEST_STARTED_PIO_AWAIT_FRAME_SUBSTATE] = { | 2569 | [SCIC_SDS_STP_REQUEST_STARTED_PIO_AWAIT_FRAME_SUBSTATE] = { |
2609 | .abort_handler = scic_sds_request_started_state_abort_handler, | ||
2610 | .frame_handler = scic_sds_stp_request_pio_await_frame_frame_handler | 2570 | .frame_handler = scic_sds_stp_request_pio_await_frame_frame_handler |
2611 | }, | 2571 | }, |
2612 | [SCIC_SDS_STP_REQUEST_STARTED_PIO_DATA_IN_AWAIT_DATA_SUBSTATE] = { | 2572 | [SCIC_SDS_STP_REQUEST_STARTED_PIO_DATA_IN_AWAIT_DATA_SUBSTATE] = { |
2613 | .abort_handler = scic_sds_request_started_state_abort_handler, | ||
2614 | .event_handler = scic_sds_stp_request_pio_data_in_await_data_event_handler, | 2573 | .event_handler = scic_sds_stp_request_pio_data_in_await_data_event_handler, |
2615 | .frame_handler = scic_sds_stp_request_pio_data_in_await_data_frame_handler | 2574 | .frame_handler = scic_sds_stp_request_pio_data_in_await_data_frame_handler |
2616 | }, | 2575 | }, |
2617 | [SCIC_SDS_STP_REQUEST_STARTED_PIO_DATA_OUT_TRANSMIT_DATA_SUBSTATE] = { | 2576 | [SCIC_SDS_STP_REQUEST_STARTED_PIO_DATA_OUT_TRANSMIT_DATA_SUBSTATE] = { |
2618 | .abort_handler = scic_sds_request_started_state_abort_handler, | ||
2619 | .tc_completion_handler = scic_sds_stp_request_pio_data_out_await_data_transmit_completion_tc_completion_handler, | 2577 | .tc_completion_handler = scic_sds_stp_request_pio_data_out_await_data_transmit_completion_tc_completion_handler, |
2620 | }, | 2578 | }, |
2621 | [SCIC_SDS_STP_REQUEST_STARTED_SOFT_RESET_AWAIT_H2D_ASSERTED_COMPLETION_SUBSTATE] = { | 2579 | [SCIC_SDS_STP_REQUEST_STARTED_SOFT_RESET_AWAIT_H2D_ASSERTED_COMPLETION_SUBSTATE] = { |
2622 | .abort_handler = scic_sds_request_started_state_abort_handler, | ||
2623 | .tc_completion_handler = scic_sds_stp_request_soft_reset_await_h2d_asserted_tc_completion_handler, | 2580 | .tc_completion_handler = scic_sds_stp_request_soft_reset_await_h2d_asserted_tc_completion_handler, |
2624 | }, | 2581 | }, |
2625 | [SCIC_SDS_STP_REQUEST_STARTED_SOFT_RESET_AWAIT_H2D_DIAGNOSTIC_COMPLETION_SUBSTATE] = { | 2582 | [SCIC_SDS_STP_REQUEST_STARTED_SOFT_RESET_AWAIT_H2D_DIAGNOSTIC_COMPLETION_SUBSTATE] = { |
2626 | .abort_handler = scic_sds_request_started_state_abort_handler, | ||
2627 | .tc_completion_handler = scic_sds_stp_request_soft_reset_await_h2d_diagnostic_tc_completion_handler, | 2583 | .tc_completion_handler = scic_sds_stp_request_soft_reset_await_h2d_diagnostic_tc_completion_handler, |
2628 | }, | 2584 | }, |
2629 | [SCIC_SDS_STP_REQUEST_STARTED_SOFT_RESET_AWAIT_D2H_RESPONSE_FRAME_SUBSTATE] = { | 2585 | [SCIC_SDS_STP_REQUEST_STARTED_SOFT_RESET_AWAIT_D2H_RESPONSE_FRAME_SUBSTATE] = { |
2630 | .abort_handler = scic_sds_request_started_state_abort_handler, | ||
2631 | .frame_handler = scic_sds_stp_request_soft_reset_await_d2h_frame_handler, | 2586 | .frame_handler = scic_sds_stp_request_soft_reset_await_d2h_frame_handler, |
2632 | }, | 2587 | }, |
2633 | [SCI_BASE_REQUEST_STATE_COMPLETED] = { | 2588 | [SCI_BASE_REQUEST_STATE_COMPLETED] = { |
2634 | .complete_handler = scic_sds_request_completed_state_complete_handler, | 2589 | .complete_handler = scic_sds_request_completed_state_complete_handler, |
2635 | }, | 2590 | }, |
2636 | [SCI_BASE_REQUEST_STATE_ABORTING] = { | 2591 | [SCI_BASE_REQUEST_STATE_ABORTING] = { |
2637 | .abort_handler = scic_sds_request_aborting_state_abort_handler, | ||
2638 | .tc_completion_handler = scic_sds_request_aborting_state_tc_completion_handler, | 2592 | .tc_completion_handler = scic_sds_request_aborting_state_tc_completion_handler, |
2639 | .frame_handler = scic_sds_request_aborting_state_frame_handler, | 2593 | .frame_handler = scic_sds_request_aborting_state_frame_handler, |
2640 | }, | 2594 | }, |