diff options
author | Piotr Sawicki <piotr.sawicki@intel.com> | 2011-05-10 19:50:32 -0400 |
---|---|---|
committer | Dan Williams <dan.j.williams@intel.com> | 2011-07-03 07:04:48 -0400 |
commit | f4636a7b2ab8288466b83a8459d47c43143a70dc (patch) | |
tree | 4b8c8c425b7348c9b2a3ae1cf9a4c353adb3cc06 | |
parent | f00e6ba4996a34f098fe50c78077f0568fd838ec (diff) |
isci: unify request start handlers
Unify the implementation in scic_sds_request_start and kill the state
handler.
Reported-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Piotr Sawicki <piotr.sawicki@intel.com>
[remove scic_sds_request_constructed_state_start_handler]
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
-rw-r--r-- | drivers/scsi/isci/remote_device.c | 6 | ||||
-rw-r--r-- | drivers/scsi/isci/request.c | 156 | ||||
-rw-r--r-- | drivers/scsi/isci/request.h | 6 |
3 files changed, 74 insertions, 94 deletions
diff --git a/drivers/scsi/isci/remote_device.c b/drivers/scsi/isci/remote_device.c index 0bb639dfbada..606ee2be154e 100644 --- a/drivers/scsi/isci/remote_device.c +++ b/drivers/scsi/isci/remote_device.c | |||
@@ -515,7 +515,7 @@ enum sci_status scic_sds_remote_device_start_io(struct scic_sds_controller *scic | |||
515 | if (status != SCI_SUCCESS) | 515 | if (status != SCI_SUCCESS) |
516 | break; | 516 | break; |
517 | 517 | ||
518 | status = sci_req->state_handlers->start_handler(sci_req); | 518 | status = scic_sds_request_start(sci_req); |
519 | if (status != SCI_SUCCESS) | 519 | if (status != SCI_SUCCESS) |
520 | break; | 520 | break; |
521 | 521 | ||
@@ -540,7 +540,7 @@ enum sci_status scic_sds_remote_device_start_io(struct scic_sds_controller *scic | |||
540 | if (status != SCI_SUCCESS) | 540 | if (status != SCI_SUCCESS) |
541 | break; | 541 | break; |
542 | 542 | ||
543 | status = sci_req->state_handlers->start_handler(sci_req); | 543 | status = scic_sds_request_start(sci_req); |
544 | } else | 544 | } else |
545 | return SCI_FAILURE_INVALID_STATE; | 545 | return SCI_FAILURE_INVALID_STATE; |
546 | break; | 546 | break; |
@@ -709,7 +709,7 @@ enum sci_status scic_sds_remote_device_start_task(struct scic_sds_controller *sc | |||
709 | if (status != SCI_SUCCESS) | 709 | if (status != SCI_SUCCESS) |
710 | goto out; | 710 | goto out; |
711 | 711 | ||
712 | status = sci_req->state_handlers->start_handler(sci_req); | 712 | status = scic_sds_request_start(sci_req); |
713 | if (status != SCI_SUCCESS) | 713 | if (status != SCI_SUCCESS) |
714 | goto out; | 714 | goto out; |
715 | 715 | ||
diff --git a/drivers/scsi/isci/request.c b/drivers/scsi/isci/request.c index 69688636347e..41a418d8b337 100644 --- a/drivers/scsi/isci/request.c +++ b/drivers/scsi/isci/request.c | |||
@@ -757,23 +757,80 @@ static u32 sci_req_tx_bytes(struct scic_sds_request *sci_req) | |||
757 | return ret_val; | 757 | return ret_val; |
758 | } | 758 | } |
759 | 759 | ||
760 | enum sci_status | 760 | enum sci_status scic_sds_request_start(struct scic_sds_request *sci_req) |
761 | scic_sds_request_start(struct scic_sds_request *request) | ||
762 | { | 761 | { |
763 | if (request->device_sequence != | 762 | struct scic_sds_controller *scic = sci_req->owning_controller; |
764 | scic_sds_remote_device_get_sequence(request->target_device)) | 763 | struct scu_task_context *task_context; |
764 | enum sci_base_request_states state; | ||
765 | |||
766 | if (sci_req->device_sequence != | ||
767 | scic_sds_remote_device_get_sequence(sci_req->target_device)) | ||
765 | return SCI_FAILURE; | 768 | return SCI_FAILURE; |
766 | 769 | ||
767 | if (request->state_handlers->start_handler) | 770 | state = sci_req->state_machine.current_state_id; |
768 | return request->state_handlers->start_handler(request); | 771 | if (state != SCI_BASE_REQUEST_STATE_CONSTRUCTED) { |
772 | dev_warn(scic_to_dev(scic), | ||
773 | "%s: SCIC IO Request requested to start while in wrong " | ||
774 | "state %d\n", __func__, state); | ||
775 | return SCI_FAILURE_INVALID_STATE; | ||
776 | } | ||
769 | 777 | ||
770 | dev_warn(scic_to_dev(request->owning_controller), | 778 | /* if necessary, allocate a TCi for the io request object and then will, |
771 | "%s: SCIC IO Request requested to start while in wrong " | 779 | * if necessary, copy the constructed TC data into the actual TC buffer. |
772 | "state %d\n", | 780 | * If everything is successful the post context field is updated with |
773 | __func__, | 781 | * the TCi so the controller can post the request to the hardware. |
774 | sci_base_state_machine_get_state(&request->state_machine)); | 782 | */ |
783 | if (sci_req->io_tag == SCI_CONTROLLER_INVALID_IO_TAG) | ||
784 | sci_req->io_tag = scic_controller_allocate_io_tag(scic); | ||
775 | 785 | ||
776 | return SCI_FAILURE_INVALID_STATE; | 786 | /* Record the IO Tag in the request */ |
787 | if (sci_req->io_tag != SCI_CONTROLLER_INVALID_IO_TAG) { | ||
788 | task_context = sci_req->task_context_buffer; | ||
789 | |||
790 | task_context->task_index = scic_sds_io_tag_get_index(sci_req->io_tag); | ||
791 | |||
792 | switch (task_context->protocol_type) { | ||
793 | case SCU_TASK_CONTEXT_PROTOCOL_SMP: | ||
794 | case SCU_TASK_CONTEXT_PROTOCOL_SSP: | ||
795 | /* SSP/SMP Frame */ | ||
796 | task_context->type.ssp.tag = sci_req->io_tag; | ||
797 | task_context->type.ssp.target_port_transfer_tag = | ||
798 | 0xFFFF; | ||
799 | break; | ||
800 | |||
801 | case SCU_TASK_CONTEXT_PROTOCOL_STP: | ||
802 | /* STP/SATA Frame | ||
803 | * task_context->type.stp.ncq_tag = sci_req->ncq_tag; | ||
804 | */ | ||
805 | break; | ||
806 | |||
807 | case SCU_TASK_CONTEXT_PROTOCOL_NONE: | ||
808 | /* / @todo When do we set no protocol type? */ | ||
809 | break; | ||
810 | |||
811 | default: | ||
812 | /* This should never happen since we build the IO | ||
813 | * requests */ | ||
814 | break; | ||
815 | } | ||
816 | |||
817 | /* | ||
818 | * Check to see if we need to copy the task context buffer | ||
819 | * or have been building into the task context buffer */ | ||
820 | if (sci_req->was_tag_assigned_by_user == false) | ||
821 | scic_sds_controller_copy_task_context(scic, sci_req); | ||
822 | |||
823 | /* Add to the post_context the io tag value */ | ||
824 | sci_req->post_context |= scic_sds_io_tag_get_index(sci_req->io_tag); | ||
825 | |||
826 | /* Everything is good go ahead and change state */ | ||
827 | sci_base_state_machine_change_state(&sci_req->state_machine, | ||
828 | SCI_BASE_REQUEST_STATE_STARTED); | ||
829 | |||
830 | return SCI_SUCCESS; | ||
831 | } | ||
832 | |||
833 | return SCI_FAILURE_INSUFFICIENT_RESOURCES; | ||
777 | } | 834 | } |
778 | 835 | ||
779 | enum sci_status | 836 | enum sci_status |
@@ -904,75 +961,6 @@ static void scic_sds_io_request_copy_response(struct scic_sds_request *sci_req) | |||
904 | } | 961 | } |
905 | 962 | ||
906 | /* | 963 | /* |
907 | * This method implements the action taken when a constructed | ||
908 | * SCIC_SDS_IO_REQUEST_T object receives a scic_sds_request_start() request. | ||
909 | * This method will, if necessary, allocate a TCi for the io request object and | ||
910 | * then will, if necessary, copy the constructed TC data into the actual TC | ||
911 | * buffer. If everything is successful the post context field is updated with | ||
912 | * the TCi so the controller can post the request to the hardware. enum sci_status | ||
913 | * SCI_SUCCESS SCI_FAILURE_INSUFFICIENT_RESOURCES | ||
914 | */ | ||
915 | static enum sci_status scic_sds_request_constructed_state_start_handler( | ||
916 | struct scic_sds_request *request) | ||
917 | { | ||
918 | struct scu_task_context *task_context; | ||
919 | |||
920 | if (request->io_tag == SCI_CONTROLLER_INVALID_IO_TAG) { | ||
921 | request->io_tag = | ||
922 | scic_controller_allocate_io_tag(request->owning_controller); | ||
923 | } | ||
924 | |||
925 | /* Record the IO Tag in the request */ | ||
926 | if (request->io_tag != SCI_CONTROLLER_INVALID_IO_TAG) { | ||
927 | task_context = request->task_context_buffer; | ||
928 | |||
929 | task_context->task_index = scic_sds_io_tag_get_index(request->io_tag); | ||
930 | |||
931 | switch (task_context->protocol_type) { | ||
932 | case SCU_TASK_CONTEXT_PROTOCOL_SMP: | ||
933 | case SCU_TASK_CONTEXT_PROTOCOL_SSP: | ||
934 | /* SSP/SMP Frame */ | ||
935 | task_context->type.ssp.tag = request->io_tag; | ||
936 | task_context->type.ssp.target_port_transfer_tag = 0xFFFF; | ||
937 | break; | ||
938 | |||
939 | case SCU_TASK_CONTEXT_PROTOCOL_STP: | ||
940 | /* | ||
941 | * STP/SATA Frame | ||
942 | * task_context->type.stp.ncq_tag = request->ncq_tag; */ | ||
943 | break; | ||
944 | |||
945 | case SCU_TASK_CONTEXT_PROTOCOL_NONE: | ||
946 | /* / @todo When do we set no protocol type? */ | ||
947 | break; | ||
948 | |||
949 | default: | ||
950 | /* This should never happen since we build the IO requests */ | ||
951 | break; | ||
952 | } | ||
953 | |||
954 | /* | ||
955 | * Check to see if we need to copy the task context buffer | ||
956 | * or have been building into the task context buffer */ | ||
957 | if (request->was_tag_assigned_by_user == false) { | ||
958 | scic_sds_controller_copy_task_context( | ||
959 | request->owning_controller, request); | ||
960 | } | ||
961 | |||
962 | /* Add to the post_context the io tag value */ | ||
963 | request->post_context |= scic_sds_io_tag_get_index(request->io_tag); | ||
964 | |||
965 | /* Everything is good go ahead and change state */ | ||
966 | sci_base_state_machine_change_state(&request->state_machine, | ||
967 | SCI_BASE_REQUEST_STATE_STARTED); | ||
968 | |||
969 | return SCI_SUCCESS; | ||
970 | } | ||
971 | |||
972 | return SCI_FAILURE_INSUFFICIENT_RESOURCES; | ||
973 | } | ||
974 | |||
975 | /* | ||
976 | * scic_sds_request_started_state_tc_completion_handler() - This method process | 964 | * scic_sds_request_started_state_tc_completion_handler() - This method process |
977 | * TC (task context) completions for normal IO request (i.e. Task/Abort | 965 | * TC (task context) completions for normal IO request (i.e. Task/Abort |
978 | * Completions of type 0). This method will update the | 966 | * Completions of type 0). This method will update the |
@@ -2529,10 +2517,8 @@ static enum sci_status scic_sds_stp_request_soft_reset_await_d2h_frame_handler( | |||
2529 | } | 2517 | } |
2530 | 2518 | ||
2531 | static const struct scic_sds_io_request_state_handler scic_sds_request_state_handler_table[] = { | 2519 | static const struct scic_sds_io_request_state_handler scic_sds_request_state_handler_table[] = { |
2532 | [SCI_BASE_REQUEST_STATE_INITIAL] = { }, | 2520 | [SCI_BASE_REQUEST_STATE_INITIAL] = {}, |
2533 | [SCI_BASE_REQUEST_STATE_CONSTRUCTED] = { | 2521 | [SCI_BASE_REQUEST_STATE_CONSTRUCTED] = {}, |
2534 | .start_handler = scic_sds_request_constructed_state_start_handler, | ||
2535 | }, | ||
2536 | [SCI_BASE_REQUEST_STATE_STARTED] = { | 2522 | [SCI_BASE_REQUEST_STATE_STARTED] = { |
2537 | .tc_completion_handler = scic_sds_request_started_state_tc_completion_handler, | 2523 | .tc_completion_handler = scic_sds_request_started_state_tc_completion_handler, |
2538 | .frame_handler = scic_sds_request_started_state_frame_handler, | 2524 | .frame_handler = scic_sds_request_started_state_frame_handler, |
diff --git a/drivers/scsi/isci/request.h b/drivers/scsi/isci/request.h index b17336952314..bf8ac1860850 100644 --- a/drivers/scsi/isci/request.h +++ b/drivers/scsi/isci/request.h | |||
@@ -439,12 +439,6 @@ typedef enum sci_status (*scic_sds_io_request_task_completion_handler_t) | |||
439 | */ | 439 | */ |
440 | struct scic_sds_io_request_state_handler { | 440 | struct scic_sds_io_request_state_handler { |
441 | /** | 441 | /** |
442 | * The start_handler specifies the method invoked when a user attempts to | ||
443 | * start a request. | ||
444 | */ | ||
445 | scic_sds_io_request_handler_t start_handler; | ||
446 | |||
447 | /** | ||
448 | * The complete_handler specifies the method invoked when a user attempts to | 442 | * The complete_handler specifies the method invoked when a user attempts to |
449 | * complete a request. | 443 | * complete a request. |
450 | */ | 444 | */ |