aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/isci/request.c
diff options
context:
space:
mode:
authorEdmund Nadolski <edmund.nadolski@intel.com>2011-06-01 20:10:43 -0400
committerDan Williams <dan.j.williams@intel.com>2011-07-03 07:04:50 -0400
commite301370ac553a9a0ac0d1d25e769b86cf60395b3 (patch)
tree58c00e0aeb21c3101df389d4b5e34f47e4b32119 /drivers/scsi/isci/request.c
parent8d2c65c09c9e0adc16070562e7944c1c3277f332 (diff)
isci: state machine cleanup
This cleans up several areas of the state machine mechanism: o Rename sci_base_state_machine_change_state to sci_change_state o Remove sci_base_state_machine_get_state function o Rename 'state_machine' struct member to 'sm' in client structs o Shorten the name of request states o Shorten state machine state names as follows: SCI_BASE_CONTROLLER_STATE_xxx to SCIC_xxx SCI_BASE_PHY_STATE_xxx to SCI_PHY_xxx SCIC_SDS_PHY_STARTING_SUBSTATE_xxx to SCI_PHY_SUB_xxx SCI_BASE_PORT_STATE_xxx to SCI_PORT_xxx and SCIC_SDS_PORT_READY_SUBSTATE_xxx to SCI_PORT_SUB_xxx SCI_BASE_REMOTE_DEVICE_STATE_xxx to SCI_DEV_xxx SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_xxx to SCI_STP_DEV_xxx SCIC_SDS_SMP_REMOTE_DEVICE_READY_SUBSTATE_xxx to SCI_SMP_DEV_xxx SCIC_SDS_REMOTE_NODE_CONTEXT_xxx_STATE to SCI_RNC_xxx Signed-off-by: Edmund Nadolski <edmund.nadolski@intel.com> Signed-off-by: Dave Jiang <dave.jiang@intel.com> 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.c582
1 files changed, 307 insertions, 275 deletions
diff --git a/drivers/scsi/isci/request.c b/drivers/scsi/isci/request.c
index 31c9b2c34259..89f0ab925c27 100644
--- a/drivers/scsi/isci/request.c
+++ b/drivers/scsi/isci/request.c
@@ -649,8 +649,7 @@ static enum sci_status scic_io_request_construct_basic_ssp(struct scic_sds_reque
649 649
650 scic_sds_io_request_build_ssp_command_iu(sci_req); 650 scic_sds_io_request_build_ssp_command_iu(sci_req);
651 651
652 sci_base_state_machine_change_state(&sci_req->state_machine, 652 sci_change_state(&sci_req->sm, SCI_REQ_CONSTRUCTED);
653 SCI_BASE_REQUEST_STATE_CONSTRUCTED);
654 653
655 return SCI_SUCCESS; 654 return SCI_SUCCESS;
656} 655}
@@ -664,8 +663,7 @@ enum sci_status scic_task_request_construct_ssp(
664 /* Fill in the SSP Task IU */ 663 /* Fill in the SSP Task IU */
665 scic_sds_task_request_build_ssp_task_iu(sci_req); 664 scic_sds_task_request_build_ssp_task_iu(sci_req);
666 665
667 sci_base_state_machine_change_state(&sci_req->state_machine, 666 sci_change_state(&sci_req->sm, SCI_REQ_CONSTRUCTED);
668 SCI_BASE_REQUEST_STATE_CONSTRUCTED);
669 667
670 return SCI_SUCCESS; 668 return SCI_SUCCESS;
671} 669}
@@ -687,8 +685,7 @@ static enum sci_status scic_io_request_construct_basic_sata(struct scic_sds_requ
687 copy); 685 copy);
688 686
689 if (status == SCI_SUCCESS) 687 if (status == SCI_SUCCESS)
690 sci_base_state_machine_change_state(&sci_req->state_machine, 688 sci_change_state(&sci_req->sm, SCI_REQ_CONSTRUCTED);
691 SCI_BASE_REQUEST_STATE_CONSTRUCTED);
692 689
693 return status; 690 return status;
694} 691}
@@ -718,8 +715,7 @@ enum sci_status scic_task_request_construct_sata(struct scic_sds_request *sci_re
718 715
719 if (status != SCI_SUCCESS) 716 if (status != SCI_SUCCESS)
720 return status; 717 return status;
721 sci_base_state_machine_change_state(&sci_req->state_machine, 718 sci_change_state(&sci_req->sm, SCI_REQ_CONSTRUCTED);
722 SCI_BASE_REQUEST_STATE_CONSTRUCTED);
723 719
724 return status; 720 return status;
725} 721}
@@ -761,8 +757,8 @@ enum sci_status scic_sds_request_start(struct scic_sds_request *sci_req)
761 scic_sds_remote_device_get_sequence(sci_req->target_device)) 757 scic_sds_remote_device_get_sequence(sci_req->target_device))
762 return SCI_FAILURE; 758 return SCI_FAILURE;
763 759
764 state = sci_req->state_machine.current_state_id; 760 state = sci_req->sm.current_state_id;
765 if (state != SCI_BASE_REQUEST_STATE_CONSTRUCTED) { 761 if (state != SCI_REQ_CONSTRUCTED) {
766 dev_warn(scic_to_dev(scic), 762 dev_warn(scic_to_dev(scic),
767 "%s: SCIC IO Request requested to start while in wrong " 763 "%s: SCIC IO Request requested to start while in wrong "
768 "state %d\n", __func__, state); 764 "state %d\n", __func__, state);
@@ -818,8 +814,7 @@ enum sci_status scic_sds_request_start(struct scic_sds_request *sci_req)
818 sci_req->post_context |= scic_sds_io_tag_get_index(sci_req->io_tag); 814 sci_req->post_context |= scic_sds_io_tag_get_index(sci_req->io_tag);
819 815
820 /* Everything is good go ahead and change state */ 816 /* Everything is good go ahead and change state */
821 sci_base_state_machine_change_state(&sci_req->state_machine, 817 sci_change_state(&sci_req->sm, SCI_REQ_STARTED);
822 SCI_BASE_REQUEST_STATE_STARTED);
823 818
824 return SCI_SUCCESS; 819 return SCI_SUCCESS;
825 } 820 }
@@ -832,52 +827,47 @@ scic_sds_io_request_terminate(struct scic_sds_request *sci_req)
832{ 827{
833 enum sci_base_request_states state; 828 enum sci_base_request_states state;
834 829
835 state = sci_req->state_machine.current_state_id; 830 state = sci_req->sm.current_state_id;
836 831
837 switch (state) { 832 switch (state) {
838 case SCI_BASE_REQUEST_STATE_CONSTRUCTED: 833 case SCI_REQ_CONSTRUCTED:
839 scic_sds_request_set_status(sci_req, 834 scic_sds_request_set_status(sci_req,
840 SCU_TASK_DONE_TASK_ABORT, 835 SCU_TASK_DONE_TASK_ABORT,
841 SCI_FAILURE_IO_TERMINATED); 836 SCI_FAILURE_IO_TERMINATED);
842 837
843 sci_base_state_machine_change_state(&sci_req->state_machine, 838 sci_change_state(&sci_req->sm, SCI_REQ_COMPLETED);
844 SCI_BASE_REQUEST_STATE_COMPLETED);
845 return SCI_SUCCESS; 839 return SCI_SUCCESS;
846 case SCI_BASE_REQUEST_STATE_STARTED: 840 case SCI_REQ_STARTED:
847 case SCIC_SDS_IO_REQUEST_STARTED_TASK_MGMT_SUBSTATE_AWAIT_TC_COMPLETION: 841 case SCI_REQ_TASK_WAIT_TC_COMP:
848 case SCIC_SDS_SMP_REQUEST_STARTED_SUBSTATE_AWAIT_RESPONSE: 842 case SCI_REQ_SMP_WAIT_RESP:
849 case SCIC_SDS_SMP_REQUEST_STARTED_SUBSTATE_AWAIT_TC_COMPLETION: 843 case SCI_REQ_SMP_WAIT_TC_COMP:
850 case SCIC_SDS_STP_REQUEST_STARTED_UDMA_AWAIT_TC_COMPLETION_SUBSTATE: 844 case SCI_REQ_STP_UDMA_WAIT_TC_COMP:
851 case SCIC_SDS_STP_REQUEST_STARTED_UDMA_AWAIT_D2H_REG_FIS_SUBSTATE: 845 case SCI_REQ_STP_UDMA_WAIT_D2H:
852 case SCIC_SDS_STP_REQUEST_STARTED_NON_DATA_AWAIT_H2D_COMPLETION_SUBSTATE: 846 case SCI_REQ_STP_NON_DATA_WAIT_H2D:
853 case SCIC_SDS_STP_REQUEST_STARTED_NON_DATA_AWAIT_D2H_SUBSTATE: 847 case SCI_REQ_STP_NON_DATA_WAIT_D2H:
854 case SCIC_SDS_STP_REQUEST_STARTED_PIO_AWAIT_H2D_COMPLETION_SUBSTATE: 848 case SCI_REQ_STP_PIO_WAIT_H2D:
855 case SCIC_SDS_STP_REQUEST_STARTED_PIO_AWAIT_FRAME_SUBSTATE: 849 case SCI_REQ_STP_PIO_WAIT_FRAME:
856 case SCIC_SDS_STP_REQUEST_STARTED_PIO_DATA_IN_AWAIT_DATA_SUBSTATE: 850 case SCI_REQ_STP_PIO_DATA_IN:
857 case SCIC_SDS_STP_REQUEST_STARTED_PIO_DATA_OUT_TRANSMIT_DATA_SUBSTATE: 851 case SCI_REQ_STP_PIO_DATA_OUT:
858 case SCIC_SDS_STP_REQUEST_STARTED_SOFT_RESET_AWAIT_H2D_ASSERTED_COMPLETION_SUBSTATE: 852 case SCI_REQ_STP_SOFT_RESET_WAIT_H2D_ASSERTED:
859 case SCIC_SDS_STP_REQUEST_STARTED_SOFT_RESET_AWAIT_H2D_DIAGNOSTIC_COMPLETION_SUBSTATE: 853 case SCI_REQ_STP_SOFT_RESET_WAIT_H2D_DIAG:
860 case SCIC_SDS_STP_REQUEST_STARTED_SOFT_RESET_AWAIT_D2H_RESPONSE_FRAME_SUBSTATE: 854 case SCI_REQ_STP_SOFT_RESET_WAIT_D2H:
861 sci_base_state_machine_change_state(&sci_req->state_machine, 855 sci_change_state(&sci_req->sm, SCI_REQ_ABORTING);
862 SCI_BASE_REQUEST_STATE_ABORTING);
863 return SCI_SUCCESS; 856 return SCI_SUCCESS;
864 case SCIC_SDS_IO_REQUEST_STARTED_TASK_MGMT_SUBSTATE_AWAIT_TC_RESPONSE: 857 case SCI_REQ_TASK_WAIT_TC_RESP:
865 sci_base_state_machine_change_state(&sci_req->state_machine, 858 sci_change_state(&sci_req->sm, SCI_REQ_ABORTING);
866 SCI_BASE_REQUEST_STATE_ABORTING); 859 sci_change_state(&sci_req->sm, SCI_REQ_COMPLETED);
867 sci_base_state_machine_change_state(&sci_req->state_machine,
868 SCI_BASE_REQUEST_STATE_COMPLETED);
869 return SCI_SUCCESS; 860 return SCI_SUCCESS;
870 case SCI_BASE_REQUEST_STATE_ABORTING: 861 case SCI_REQ_ABORTING:
871 sci_base_state_machine_change_state(&sci_req->state_machine, 862 sci_change_state(&sci_req->sm, SCI_REQ_COMPLETED);
872 SCI_BASE_REQUEST_STATE_COMPLETED);
873 return SCI_SUCCESS; 863 return SCI_SUCCESS;
874 case SCI_BASE_REQUEST_STATE_COMPLETED: 864 case SCI_REQ_COMPLETED:
875 default: 865 default:
876 dev_warn(scic_to_dev(sci_req->owning_controller), 866 dev_warn(scic_to_dev(sci_req->owning_controller),
877 "%s: SCIC IO Request requested to abort while in wrong " 867 "%s: SCIC IO Request requested to abort while in wrong "
878 "state %d\n", 868 "state %d\n",
879 __func__, 869 __func__,
880 sci_base_state_machine_get_state(&sci_req->state_machine)); 870 sci_req->sm.current_state_id);
881 break; 871 break;
882 } 872 }
883 873
@@ -889,8 +879,8 @@ enum sci_status scic_sds_request_complete(struct scic_sds_request *sci_req)
889 enum sci_base_request_states state; 879 enum sci_base_request_states state;
890 struct scic_sds_controller *scic = sci_req->owning_controller; 880 struct scic_sds_controller *scic = sci_req->owning_controller;
891 881
892 state = sci_req->state_machine.current_state_id; 882 state = sci_req->sm.current_state_id;
893 if (WARN_ONCE(state != SCI_BASE_REQUEST_STATE_COMPLETED, 883 if (WARN_ONCE(state != SCI_REQ_COMPLETED,
894 "isci: request completion from wrong state (%d)\n", state)) 884 "isci: request completion from wrong state (%d)\n", state))
895 return SCI_FAILURE_INVALID_STATE; 885 return SCI_FAILURE_INVALID_STATE;
896 886
@@ -902,8 +892,7 @@ enum sci_status scic_sds_request_complete(struct scic_sds_request *sci_req)
902 sci_req->saved_rx_frame_index); 892 sci_req->saved_rx_frame_index);
903 893
904 /* XXX can we just stop the machine and remove the 'final' state? */ 894 /* XXX can we just stop the machine and remove the 'final' state? */
905 sci_base_state_machine_change_state(&sci_req->state_machine, 895 sci_change_state(&sci_req->sm, SCI_REQ_FINAL);
906 SCI_BASE_REQUEST_STATE_FINAL);
907 return SCI_SUCCESS; 896 return SCI_SUCCESS;
908} 897}
909 898
@@ -913,9 +902,9 @@ enum sci_status scic_sds_io_request_event_handler(struct scic_sds_request *sci_r
913 enum sci_base_request_states state; 902 enum sci_base_request_states state;
914 struct scic_sds_controller *scic = sci_req->owning_controller; 903 struct scic_sds_controller *scic = sci_req->owning_controller;
915 904
916 state = sci_req->state_machine.current_state_id; 905 state = sci_req->sm.current_state_id;
917 906
918 if (state != SCIC_SDS_STP_REQUEST_STARTED_PIO_DATA_IN_AWAIT_DATA_SUBSTATE) { 907 if (state != SCI_REQ_STP_PIO_DATA_IN) {
919 dev_warn(scic_to_dev(scic), "%s: (%x) in wrong state %d\n", 908 dev_warn(scic_to_dev(scic), "%s: (%x) in wrong state %d\n",
920 __func__, event_code, state); 909 __func__, event_code, state);
921 910
@@ -927,8 +916,7 @@ enum sci_status scic_sds_io_request_event_handler(struct scic_sds_request *sci_r
927 /* We are waiting for data and the SCU has R_ERR the data frame. 916 /* We are waiting for data and the SCU has R_ERR the data frame.
928 * Go back to waiting for the D2H Register FIS 917 * Go back to waiting for the D2H Register FIS
929 */ 918 */
930 sci_base_state_machine_change_state(&sci_req->state_machine, 919 sci_change_state(&sci_req->sm, SCI_REQ_STP_PIO_WAIT_FRAME);
931 SCIC_SDS_STP_REQUEST_STARTED_PIO_AWAIT_FRAME_SUBSTATE);
932 return SCI_SUCCESS; 920 return SCI_SUCCESS;
933 default: 921 default:
934 dev_err(scic_to_dev(scic), 922 dev_err(scic_to_dev(scic),
@@ -967,8 +955,9 @@ static void scic_sds_io_request_copy_response(struct scic_sds_request *sci_req)
967 memcpy(resp_buf, ssp_response->resp_data, len); 955 memcpy(resp_buf, ssp_response->resp_data, len);
968} 956}
969 957
970static enum sci_status request_started_state_tc_event(struct scic_sds_request *sci_req, 958static enum sci_status
971 u32 completion_code) 959request_started_state_tc_event(struct scic_sds_request *sci_req,
960 u32 completion_code)
972{ 961{
973 struct ssp_response_iu *resp_iu; 962 struct ssp_response_iu *resp_iu;
974 u8 datapres; 963 u8 datapres;
@@ -1110,13 +1099,13 @@ static enum sci_status request_started_state_tc_event(struct scic_sds_request *s
1110 */ 1099 */
1111 1100
1112 /* In all cases we will treat this as the completion of the IO req. */ 1101 /* In all cases we will treat this as the completion of the IO req. */
1113 sci_base_state_machine_change_state(&sci_req->state_machine, 1102 sci_change_state(&sci_req->sm, SCI_REQ_COMPLETED);
1114 SCI_BASE_REQUEST_STATE_COMPLETED);
1115 return SCI_SUCCESS; 1103 return SCI_SUCCESS;
1116} 1104}
1117 1105
1118static enum sci_status request_aborting_state_tc_event(struct scic_sds_request *sci_req, 1106static enum sci_status
1119 u32 completion_code) 1107request_aborting_state_tc_event(struct scic_sds_request *sci_req,
1108 u32 completion_code)
1120{ 1109{
1121 switch (SCU_GET_COMPLETION_TL_STATUS(completion_code)) { 1110 switch (SCU_GET_COMPLETION_TL_STATUS(completion_code)) {
1122 case (SCU_TASK_DONE_GOOD << SCU_COMPLETION_TL_STATUS_SHIFT): 1111 case (SCU_TASK_DONE_GOOD << SCU_COMPLETION_TL_STATUS_SHIFT):
@@ -1124,8 +1113,7 @@ static enum sci_status request_aborting_state_tc_event(struct scic_sds_request *
1124 scic_sds_request_set_status(sci_req, SCU_TASK_DONE_TASK_ABORT, 1113 scic_sds_request_set_status(sci_req, SCU_TASK_DONE_TASK_ABORT,
1125 SCI_FAILURE_IO_TERMINATED); 1114 SCI_FAILURE_IO_TERMINATED);
1126 1115
1127 sci_base_state_machine_change_state(&sci_req->state_machine, 1116 sci_change_state(&sci_req->sm, SCI_REQ_COMPLETED);
1128 SCI_BASE_REQUEST_STATE_COMPLETED);
1129 break; 1117 break;
1130 1118
1131 default: 1119 default:
@@ -1146,8 +1134,7 @@ static enum sci_status ssp_task_request_await_tc_event(struct scic_sds_request *
1146 scic_sds_request_set_status(sci_req, SCU_TASK_DONE_GOOD, 1134 scic_sds_request_set_status(sci_req, SCU_TASK_DONE_GOOD,
1147 SCI_SUCCESS); 1135 SCI_SUCCESS);
1148 1136
1149 sci_base_state_machine_change_state(&sci_req->state_machine, 1137 sci_change_state(&sci_req->sm, SCI_REQ_TASK_WAIT_TC_RESP);
1150 SCIC_SDS_IO_REQUEST_STARTED_TASK_MGMT_SUBSTATE_AWAIT_TC_RESPONSE);
1151 break; 1138 break;
1152 case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_ACK_NAK_TO): 1139 case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_ACK_NAK_TO):
1153 /* Currently, the decision is to simply allow the task request 1140 /* Currently, the decision is to simply allow the task request
@@ -1160,27 +1147,28 @@ static enum sci_status ssp_task_request_await_tc_event(struct scic_sds_request *
1160 "ACK/NAK timeout\n", __func__, sci_req, 1147 "ACK/NAK timeout\n", __func__, sci_req,
1161 completion_code); 1148 completion_code);
1162 1149
1163 sci_base_state_machine_change_state(&sci_req->state_machine, 1150 sci_change_state(&sci_req->sm, SCI_REQ_TASK_WAIT_TC_RESP);
1164 SCIC_SDS_IO_REQUEST_STARTED_TASK_MGMT_SUBSTATE_AWAIT_TC_RESPONSE);
1165 break; 1151 break;
1166 default: 1152 default:
1167 /* All other completion status cause the IO to be complete. If a NAK 1153 /*
1168 * was received, then it is up to the user to retry the request. 1154 * All other completion status cause the IO to be complete.
1155 * If a NAK was received, then it is up to the user to retry
1156 * the request.
1169 */ 1157 */
1170 scic_sds_request_set_status(sci_req, 1158 scic_sds_request_set_status(sci_req,
1171 SCU_NORMALIZE_COMPLETION_STATUS(completion_code), 1159 SCU_NORMALIZE_COMPLETION_STATUS(completion_code),
1172 SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR); 1160 SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR);
1173 1161
1174 sci_base_state_machine_change_state(&sci_req->state_machine, 1162 sci_change_state(&sci_req->sm, SCI_REQ_COMPLETED);
1175 SCI_BASE_REQUEST_STATE_COMPLETED);
1176 break; 1163 break;
1177 } 1164 }
1178 1165
1179 return SCI_SUCCESS; 1166 return SCI_SUCCESS;
1180} 1167}
1181 1168
1182static enum sci_status smp_request_await_response_tc_event(struct scic_sds_request *sci_req, 1169static enum sci_status
1183 u32 completion_code) 1170smp_request_await_response_tc_event(struct scic_sds_request *sci_req,
1171 u32 completion_code)
1184{ 1172{
1185 switch (SCU_GET_COMPLETION_TL_STATUS(completion_code)) { 1173 switch (SCU_GET_COMPLETION_TL_STATUS(completion_code)) {
1186 case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_GOOD): 1174 case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_GOOD):
@@ -1191,8 +1179,7 @@ static enum sci_status smp_request_await_response_tc_event(struct scic_sds_reque
1191 scic_sds_request_set_status(sci_req, SCU_TASK_DONE_GOOD, 1179 scic_sds_request_set_status(sci_req, SCU_TASK_DONE_GOOD,
1192 SCI_SUCCESS); 1180 SCI_SUCCESS);
1193 1181
1194 sci_base_state_machine_change_state(&sci_req->state_machine, 1182 sci_change_state(&sci_req->sm, SCI_REQ_COMPLETED);
1195 SCI_BASE_REQUEST_STATE_COMPLETED);
1196 break; 1183 break;
1197 1184
1198 case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_SMP_RESP_TO_ERR): 1185 case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_SMP_RESP_TO_ERR):
@@ -1209,8 +1196,7 @@ static enum sci_status smp_request_await_response_tc_event(struct scic_sds_reque
1209 scic_sds_request_set_status(sci_req, SCU_TASK_DONE_SMP_RESP_TO_ERR, 1196 scic_sds_request_set_status(sci_req, SCU_TASK_DONE_SMP_RESP_TO_ERR,
1210 SCI_FAILURE_RETRY_REQUIRED); 1197 SCI_FAILURE_RETRY_REQUIRED);
1211 1198
1212 sci_base_state_machine_change_state(&sci_req->state_machine, 1199 sci_change_state(&sci_req->sm, SCI_REQ_COMPLETED);
1213 SCI_BASE_REQUEST_STATE_COMPLETED);
1214 break; 1200 break;
1215 1201
1216 default: 1202 default:
@@ -1221,24 +1207,23 @@ static enum sci_status smp_request_await_response_tc_event(struct scic_sds_reque
1221 SCU_NORMALIZE_COMPLETION_STATUS(completion_code), 1207 SCU_NORMALIZE_COMPLETION_STATUS(completion_code),
1222 SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR); 1208 SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR);
1223 1209
1224 sci_base_state_machine_change_state(&sci_req->state_machine, 1210 sci_change_state(&sci_req->sm, SCI_REQ_COMPLETED);
1225 SCI_BASE_REQUEST_STATE_COMPLETED);
1226 break; 1211 break;
1227 } 1212 }
1228 1213
1229 return SCI_SUCCESS; 1214 return SCI_SUCCESS;
1230} 1215}
1231 1216
1232static enum sci_status smp_request_await_tc_event(struct scic_sds_request *sci_req, 1217static enum sci_status
1233 u32 completion_code) 1218smp_request_await_tc_event(struct scic_sds_request *sci_req,
1219 u32 completion_code)
1234{ 1220{
1235 switch (SCU_GET_COMPLETION_TL_STATUS(completion_code)) { 1221 switch (SCU_GET_COMPLETION_TL_STATUS(completion_code)) {
1236 case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_GOOD): 1222 case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_GOOD):
1237 scic_sds_request_set_status(sci_req, SCU_TASK_DONE_GOOD, 1223 scic_sds_request_set_status(sci_req, SCU_TASK_DONE_GOOD,
1238 SCI_SUCCESS); 1224 SCI_SUCCESS);
1239 1225
1240 sci_base_state_machine_change_state(&sci_req->state_machine, 1226 sci_change_state(&sci_req->sm, SCI_REQ_COMPLETED);
1241 SCI_BASE_REQUEST_STATE_COMPLETED);
1242 break; 1227 break;
1243 default: 1228 default:
1244 /* All other completion status cause the IO to be 1229 /* All other completion status cause the IO to be
@@ -1249,8 +1234,7 @@ static enum sci_status smp_request_await_tc_event(struct scic_sds_request *sci_r
1249 SCU_NORMALIZE_COMPLETION_STATUS(completion_code), 1234 SCU_NORMALIZE_COMPLETION_STATUS(completion_code),
1250 SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR); 1235 SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR);
1251 1236
1252 sci_base_state_machine_change_state(&sci_req->state_machine, 1237 sci_change_state(&sci_req->sm, SCI_REQ_COMPLETED);
1253 SCI_BASE_REQUEST_STATE_COMPLETED);
1254 break; 1238 break;
1255 } 1239 }
1256 1240
@@ -1311,16 +1295,16 @@ static struct scu_sgl_element *scic_sds_stp_request_pio_get_next_sgl(struct scic
1311 return current_sgl; 1295 return current_sgl;
1312} 1296}
1313 1297
1314static enum sci_status stp_request_non_data_await_h2d_tc_event(struct scic_sds_request *sci_req, 1298static enum sci_status
1315 u32 completion_code) 1299stp_request_non_data_await_h2d_tc_event(struct scic_sds_request *sci_req,
1300 u32 completion_code)
1316{ 1301{
1317 switch (SCU_GET_COMPLETION_TL_STATUS(completion_code)) { 1302 switch (SCU_GET_COMPLETION_TL_STATUS(completion_code)) {
1318 case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_GOOD): 1303 case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_GOOD):
1319 scic_sds_request_set_status(sci_req, SCU_TASK_DONE_GOOD, 1304 scic_sds_request_set_status(sci_req, SCU_TASK_DONE_GOOD,
1320 SCI_SUCCESS); 1305 SCI_SUCCESS);
1321 1306
1322 sci_base_state_machine_change_state(&sci_req->state_machine, 1307 sci_change_state(&sci_req->sm, SCI_REQ_STP_NON_DATA_WAIT_D2H);
1323 SCIC_SDS_STP_REQUEST_STARTED_NON_DATA_AWAIT_D2H_SUBSTATE);
1324 break; 1308 break;
1325 1309
1326 default: 1310 default:
@@ -1332,8 +1316,7 @@ static enum sci_status stp_request_non_data_await_h2d_tc_event(struct scic_sds_r
1332 SCU_NORMALIZE_COMPLETION_STATUS(completion_code), 1316 SCU_NORMALIZE_COMPLETION_STATUS(completion_code),
1333 SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR); 1317 SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR);
1334 1318
1335 sci_base_state_machine_change_state(&sci_req->state_machine, 1319 sci_change_state(&sci_req->sm, SCI_REQ_COMPLETED);
1336 SCI_BASE_REQUEST_STATE_COMPLETED);
1337 break; 1320 break;
1338 } 1321 }
1339 1322
@@ -1509,17 +1492,19 @@ static enum sci_status scic_sds_stp_request_pio_data_in_copy_data(
1509 return status; 1492 return status;
1510} 1493}
1511 1494
1512static enum sci_status stp_request_pio_await_h2d_completion_tc_event(struct scic_sds_request *sci_req, 1495static enum sci_status
1513 u32 completion_code) 1496stp_request_pio_await_h2d_completion_tc_event(struct scic_sds_request *sci_req,
1497 u32 completion_code)
1514{ 1498{
1515 enum sci_status status = SCI_SUCCESS; 1499 enum sci_status status = SCI_SUCCESS;
1516 1500
1517 switch (SCU_GET_COMPLETION_TL_STATUS(completion_code)) { 1501 switch (SCU_GET_COMPLETION_TL_STATUS(completion_code)) {
1518 case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_GOOD): 1502 case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_GOOD):
1519 scic_sds_request_set_status(sci_req, SCU_TASK_DONE_GOOD, SCI_SUCCESS); 1503 scic_sds_request_set_status(sci_req,
1504 SCU_TASK_DONE_GOOD,
1505 SCI_SUCCESS);
1520 1506
1521 sci_base_state_machine_change_state(&sci_req->state_machine, 1507 sci_change_state(&sci_req->sm, SCI_REQ_STP_PIO_WAIT_FRAME);
1522 SCIC_SDS_STP_REQUEST_STARTED_PIO_AWAIT_FRAME_SUBSTATE);
1523 break; 1508 break;
1524 1509
1525 default: 1510 default:
@@ -1531,16 +1516,16 @@ static enum sci_status stp_request_pio_await_h2d_completion_tc_event(struct scic
1531 SCU_NORMALIZE_COMPLETION_STATUS(completion_code), 1516 SCU_NORMALIZE_COMPLETION_STATUS(completion_code),
1532 SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR); 1517 SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR);
1533 1518
1534 sci_base_state_machine_change_state(&sci_req->state_machine, 1519 sci_change_state(&sci_req->sm, SCI_REQ_COMPLETED);
1535 SCI_BASE_REQUEST_STATE_COMPLETED);
1536 break; 1520 break;
1537 } 1521 }
1538 1522
1539 return status; 1523 return status;
1540} 1524}
1541 1525
1542static enum sci_status pio_data_out_tx_done_tc_event(struct scic_sds_request *sci_req, 1526static enum sci_status
1543 u32 completion_code) 1527pio_data_out_tx_done_tc_event(struct scic_sds_request *sci_req,
1528 u32 completion_code)
1544{ 1529{
1545 enum sci_status status = SCI_SUCCESS; 1530 enum sci_status status = SCI_SUCCESS;
1546 bool all_frames_transferred = false; 1531 bool all_frames_transferred = false;
@@ -1566,28 +1551,24 @@ static enum sci_status pio_data_out_tx_done_tc_event(struct scic_sds_request *sc
1566 /* all data transferred. */ 1551 /* all data transferred. */
1567 if (all_frames_transferred) { 1552 if (all_frames_transferred) {
1568 /* 1553 /*
1569 * Change the state to SCIC_SDS_STP_REQUEST_STARTED_PIO_DATA_IN_AWAIT_FRAME_SUBSTATE 1554 * Change the state to SCI_REQ_STP_PIO_DATA_IN
1570 * and wait for PIO_SETUP fis / or D2H REg fis. */ 1555 * and wait for PIO_SETUP fis / or D2H REg fis. */
1571 sci_base_state_machine_change_state( 1556 sci_change_state(&sci_req->sm, SCI_REQ_STP_PIO_WAIT_FRAME);
1572 &sci_req->state_machine,
1573 SCIC_SDS_STP_REQUEST_STARTED_PIO_AWAIT_FRAME_SUBSTATE
1574 );
1575 } 1557 }
1576 break; 1558 break;
1559
1577 default: 1560 default:
1578 /* 1561 /*
1579 * All other completion status cause the IO to be complete. If a NAK 1562 * All other completion status cause the IO to be complete.
1580 * was received, then it is up to the user to retry the request. */ 1563 * If a NAK was received, then it is up to the user to retry
1564 * the request.
1565 */
1581 scic_sds_request_set_status( 1566 scic_sds_request_set_status(
1582 sci_req, 1567 sci_req,
1583 SCU_NORMALIZE_COMPLETION_STATUS(completion_code), 1568 SCU_NORMALIZE_COMPLETION_STATUS(completion_code),
1584 SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR 1569 SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR);
1585 );
1586 1570
1587 sci_base_state_machine_change_state( 1571 sci_change_state(&sci_req->sm, SCI_REQ_COMPLETED);
1588 &sci_req->state_machine,
1589 SCI_BASE_REQUEST_STATE_COMPLETED
1590 );
1591 break; 1572 break;
1592 } 1573 }
1593 1574
@@ -1600,8 +1581,7 @@ static void scic_sds_stp_request_udma_complete_request(
1600 enum sci_status sci_status) 1581 enum sci_status sci_status)
1601{ 1582{
1602 scic_sds_request_set_status(request, scu_status, sci_status); 1583 scic_sds_request_set_status(request, scu_status, sci_status);
1603 sci_base_state_machine_change_state(&request->state_machine, 1584 sci_change_state(&request->sm, SCI_REQ_COMPLETED);
1604 SCI_BASE_REQUEST_STATE_COMPLETED);
1605} 1585}
1606 1586
1607static enum sci_status scic_sds_stp_request_udma_general_frame_handler(struct scic_sds_request *sci_req, 1587static enum sci_status scic_sds_stp_request_udma_general_frame_handler(struct scic_sds_request *sci_req,
@@ -1632,8 +1612,9 @@ static enum sci_status scic_sds_stp_request_udma_general_frame_handler(struct sc
1632 return status; 1612 return status;
1633} 1613}
1634 1614
1635enum sci_status scic_sds_io_request_frame_handler(struct scic_sds_request *sci_req, 1615enum sci_status
1636 u32 frame_index) 1616scic_sds_io_request_frame_handler(struct scic_sds_request *sci_req,
1617 u32 frame_index)
1637{ 1618{
1638 struct scic_sds_controller *scic = sci_req->owning_controller; 1619 struct scic_sds_controller *scic = sci_req->owning_controller;
1639 struct scic_sds_stp_request *stp_req = &sci_req->stp.req; 1620 struct scic_sds_stp_request *stp_req = &sci_req->stp.req;
@@ -1641,9 +1622,9 @@ enum sci_status scic_sds_io_request_frame_handler(struct scic_sds_request *sci_r
1641 enum sci_status status; 1622 enum sci_status status;
1642 ssize_t word_cnt; 1623 ssize_t word_cnt;
1643 1624
1644 state = sci_req->state_machine.current_state_id; 1625 state = sci_req->sm.current_state_id;
1645 switch (state) { 1626 switch (state) {
1646 case SCI_BASE_REQUEST_STATE_STARTED: { 1627 case SCI_REQ_STARTED: {
1647 struct ssp_frame_hdr ssp_hdr; 1628 struct ssp_frame_hdr ssp_hdr;
1648 void *frame_header; 1629 void *frame_header;
1649 1630
@@ -1684,20 +1665,21 @@ enum sci_status scic_sds_io_request_frame_handler(struct scic_sds_request *sci_r
1684 } 1665 }
1685 1666
1686 /* 1667 /*
1687 * In any case we are done with this frame buffer return it to the 1668 * In any case we are done with this frame buffer return it to
1688 * controller 1669 * the controller
1689 */ 1670 */
1690 scic_sds_controller_release_frame(scic, frame_index); 1671 scic_sds_controller_release_frame(scic, frame_index);
1691 1672
1692 return SCI_SUCCESS; 1673 return SCI_SUCCESS;
1693 } 1674 }
1694 case SCIC_SDS_IO_REQUEST_STARTED_TASK_MGMT_SUBSTATE_AWAIT_TC_RESPONSE: 1675
1676 case SCI_REQ_TASK_WAIT_TC_RESP:
1695 scic_sds_io_request_copy_response(sci_req); 1677 scic_sds_io_request_copy_response(sci_req);
1696 sci_base_state_machine_change_state(&sci_req->state_machine, 1678 sci_change_state(&sci_req->sm, SCI_REQ_COMPLETED);
1697 SCI_BASE_REQUEST_STATE_COMPLETED);
1698 scic_sds_controller_release_frame(scic,frame_index); 1679 scic_sds_controller_release_frame(scic,frame_index);
1699 return SCI_SUCCESS; 1680 return SCI_SUCCESS;
1700 case SCIC_SDS_SMP_REQUEST_STARTED_SUBSTATE_AWAIT_RESPONSE: { 1681
1682 case SCI_REQ_SMP_WAIT_RESP: {
1701 struct smp_resp *rsp_hdr = &sci_req->smp.rsp; 1683 struct smp_resp *rsp_hdr = &sci_req->smp.rsp;
1702 void *frame_header; 1684 void *frame_header;
1703 1685
@@ -1725,32 +1707,40 @@ enum sci_status scic_sds_io_request_frame_handler(struct scic_sds_request *sci_r
1725 scic_sds_request_set_status(sci_req, SCU_TASK_DONE_GOOD, 1707 scic_sds_request_set_status(sci_req, SCU_TASK_DONE_GOOD,
1726 SCI_SUCCESS); 1708 SCI_SUCCESS);
1727 1709
1728 sci_base_state_machine_change_state(&sci_req->state_machine, 1710 sci_change_state(&sci_req->sm, SCI_REQ_SMP_WAIT_TC_COMP);
1729 SCIC_SDS_SMP_REQUEST_STARTED_SUBSTATE_AWAIT_TC_COMPLETION);
1730 } else { 1711 } else {
1731 /* This was not a response frame why did it get forwarded? */ 1712 /*
1713 * This was not a response frame why did it get
1714 * forwarded?
1715 */
1732 dev_err(scic_to_dev(scic), 1716 dev_err(scic_to_dev(scic),
1733 "%s: SCIC SMP Request 0x%p received unexpected frame " 1717 "%s: SCIC SMP Request 0x%p received unexpected "
1734 "%d type 0x%02x\n", __func__, sci_req, 1718 "frame %d type 0x%02x\n",
1735 frame_index, rsp_hdr->frame_type); 1719 __func__,
1720 sci_req,
1721 frame_index,
1722 rsp_hdr->frame_type);
1736 1723
1737 scic_sds_request_set_status(sci_req, 1724 scic_sds_request_set_status(sci_req,
1738 SCU_TASK_DONE_SMP_FRM_TYPE_ERR, 1725 SCU_TASK_DONE_SMP_FRM_TYPE_ERR,
1739 SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR); 1726 SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR);
1740 1727
1741 sci_base_state_machine_change_state(&sci_req->state_machine, 1728 sci_change_state(&sci_req->sm, SCI_REQ_COMPLETED);
1742 SCI_BASE_REQUEST_STATE_COMPLETED);
1743 } 1729 }
1744 1730
1745 scic_sds_controller_release_frame(scic, frame_index); 1731 scic_sds_controller_release_frame(scic, frame_index);
1746 1732
1747 return SCI_SUCCESS; 1733 return SCI_SUCCESS;
1748 } 1734 }
1749 case SCIC_SDS_STP_REQUEST_STARTED_UDMA_AWAIT_TC_COMPLETION_SUBSTATE: 1735
1750 return scic_sds_stp_request_udma_general_frame_handler(sci_req, frame_index); 1736 case SCI_REQ_STP_UDMA_WAIT_TC_COMP:
1751 case SCIC_SDS_STP_REQUEST_STARTED_UDMA_AWAIT_D2H_REG_FIS_SUBSTATE: 1737 return scic_sds_stp_request_udma_general_frame_handler(sci_req,
1738 frame_index);
1739
1740 case SCI_REQ_STP_UDMA_WAIT_D2H:
1752 /* Use the general frame handler to copy the resposne data */ 1741 /* Use the general frame handler to copy the resposne data */
1753 status = scic_sds_stp_request_udma_general_frame_handler(sci_req, frame_index); 1742 status = scic_sds_stp_request_udma_general_frame_handler(sci_req,
1743 frame_index);
1754 1744
1755 if (status != SCI_SUCCESS) 1745 if (status != SCI_SUCCESS)
1756 return status; 1746 return status;
@@ -1758,8 +1748,10 @@ enum sci_status scic_sds_io_request_frame_handler(struct scic_sds_request *sci_r
1758 scic_sds_stp_request_udma_complete_request(sci_req, 1748 scic_sds_stp_request_udma_complete_request(sci_req,
1759 SCU_TASK_DONE_CHECK_RESPONSE, 1749 SCU_TASK_DONE_CHECK_RESPONSE,
1760 SCI_FAILURE_IO_RESPONSE_VALID); 1750 SCI_FAILURE_IO_RESPONSE_VALID);
1751
1761 return SCI_SUCCESS; 1752 return SCI_SUCCESS;
1762 case SCIC_SDS_STP_REQUEST_STARTED_NON_DATA_AWAIT_D2H_SUBSTATE: { 1753
1754 case SCI_REQ_STP_NON_DATA_WAIT_D2H: {
1763 struct dev_to_host_fis *frame_header; 1755 struct dev_to_host_fis *frame_header;
1764 u32 *frame_buffer; 1756 u32 *frame_buffer;
1765 1757
@@ -1769,9 +1761,12 @@ enum sci_status scic_sds_io_request_frame_handler(struct scic_sds_request *sci_r
1769 1761
1770 if (status != SCI_SUCCESS) { 1762 if (status != SCI_SUCCESS) {
1771 dev_err(scic_to_dev(scic), 1763 dev_err(scic_to_dev(scic),
1772 "%s: SCIC IO Request 0x%p could not get frame header " 1764 "%s: SCIC IO Request 0x%p could not get frame "
1773 "for frame index %d, status %x\n", 1765 "header for frame index %d, status %x\n",
1774 __func__, stp_req, frame_index, status); 1766 __func__,
1767 stp_req,
1768 frame_index,
1769 status);
1775 1770
1776 return status; 1771 return status;
1777 } 1772 }
@@ -1802,15 +1797,15 @@ enum sci_status scic_sds_io_request_frame_handler(struct scic_sds_request *sci_r
1802 break; 1797 break;
1803 } 1798 }
1804 1799
1805 sci_base_state_machine_change_state(&sci_req->state_machine, 1800 sci_change_state(&sci_req->sm, SCI_REQ_COMPLETED);
1806 SCI_BASE_REQUEST_STATE_COMPLETED);
1807 1801
1808 /* Frame has been decoded return it to the controller */ 1802 /* Frame has been decoded return it to the controller */
1809 scic_sds_controller_release_frame(scic, frame_index); 1803 scic_sds_controller_release_frame(scic, frame_index);
1810 1804
1811 return status; 1805 return status;
1812 } 1806 }
1813 case SCIC_SDS_STP_REQUEST_STARTED_PIO_AWAIT_FRAME_SUBSTATE: { 1807
1808 case SCI_REQ_STP_PIO_WAIT_FRAME: {
1814 struct isci_request *ireq = sci_req_to_ireq(sci_req); 1809 struct isci_request *ireq = sci_req_to_ireq(sci_req);
1815 struct sas_task *task = isci_request_access_task(ireq); 1810 struct sas_task *task = isci_request_access_task(ireq);
1816 struct dev_to_host_fis *frame_header; 1811 struct dev_to_host_fis *frame_header;
@@ -1822,8 +1817,8 @@ enum sci_status scic_sds_io_request_frame_handler(struct scic_sds_request *sci_r
1822 1817
1823 if (status != SCI_SUCCESS) { 1818 if (status != SCI_SUCCESS) {
1824 dev_err(scic_to_dev(scic), 1819 dev_err(scic_to_dev(scic),
1825 "%s: SCIC IO Request 0x%p could not get frame header " 1820 "%s: SCIC IO Request 0x%p could not get frame "
1826 "for frame index %d, status %x\n", 1821 "header for frame index %d, status %x\n",
1827 __func__, stp_req, frame_index, status); 1822 __func__, stp_req, frame_index, status);
1828 return status; 1823 return status;
1829 } 1824 }
@@ -1835,9 +1830,10 @@ enum sci_status scic_sds_io_request_frame_handler(struct scic_sds_request *sci_r
1835 frame_index, 1830 frame_index,
1836 (void **)&frame_buffer); 1831 (void **)&frame_buffer);
1837 1832
1838 /* Get the data from the PIO Setup The SCU Hardware returns 1833 /* Get the data from the PIO Setup The SCU Hardware
1839 * first word in the frame_header and the rest of the data is in 1834 * returns first word in the frame_header and the rest
1840 * the frame buffer so we need to back up one dword 1835 * of the data is in the frame buffer so we need to
1836 * back up one dword
1841 */ 1837 */
1842 1838
1843 /* transfer_count: first 16bits in the 4th dword */ 1839 /* transfer_count: first 16bits in the 4th dword */
@@ -1856,31 +1852,33 @@ enum sci_status scic_sds_io_request_frame_handler(struct scic_sds_request *sci_r
1856 * request was PIO Data-in or Data out 1852 * request was PIO Data-in or Data out
1857 */ 1853 */
1858 if (task->data_dir == DMA_FROM_DEVICE) { 1854 if (task->data_dir == DMA_FROM_DEVICE) {
1859 sci_base_state_machine_change_state(&sci_req->state_machine, 1855 sci_change_state(&sci_req->sm, SCI_REQ_STP_PIO_DATA_IN);
1860 SCIC_SDS_STP_REQUEST_STARTED_PIO_DATA_IN_AWAIT_DATA_SUBSTATE);
1861 } else if (task->data_dir == DMA_TO_DEVICE) { 1856 } else if (task->data_dir == DMA_TO_DEVICE) {
1862 /* Transmit data */ 1857 /* Transmit data */
1863 status = scic_sds_stp_request_pio_data_out_transmit_data(sci_req); 1858 status = scic_sds_stp_request_pio_data_out_transmit_data(sci_req);
1864 if (status != SCI_SUCCESS) 1859 if (status != SCI_SUCCESS)
1865 break; 1860 break;
1866 sci_base_state_machine_change_state(&sci_req->state_machine, 1861 sci_change_state(&sci_req->sm, SCI_REQ_STP_PIO_DATA_OUT);
1867 SCIC_SDS_STP_REQUEST_STARTED_PIO_DATA_OUT_TRANSMIT_DATA_SUBSTATE);
1868 } 1862 }
1869 break; 1863 break;
1864
1870 case FIS_SETDEVBITS: 1865 case FIS_SETDEVBITS:
1871 sci_base_state_machine_change_state(&sci_req->state_machine, 1866 sci_change_state(&sci_req->sm, SCI_REQ_STP_PIO_WAIT_FRAME);
1872 SCIC_SDS_STP_REQUEST_STARTED_PIO_AWAIT_FRAME_SUBSTATE);
1873 break; 1867 break;
1868
1874 case FIS_REGD2H: 1869 case FIS_REGD2H:
1875 if (frame_header->status & ATA_BUSY) { 1870 if (frame_header->status & ATA_BUSY) {
1876 /* Now why is the drive sending a D2H Register FIS when 1871 /*
1877 * it is still busy? Do nothing since we are still in 1872 * Now why is the drive sending a D2H Register
1878 * the right state. 1873 * FIS when it is still busy? Do nothing since
1874 * we are still in the right state.
1879 */ 1875 */
1880 dev_dbg(scic_to_dev(scic), 1876 dev_dbg(scic_to_dev(scic),
1881 "%s: SCIC PIO Request 0x%p received " 1877 "%s: SCIC PIO Request 0x%p received "
1882 "D2H Register FIS with BSY status " 1878 "D2H Register FIS with BSY status "
1883 "0x%x\n", __func__, stp_req, 1879 "0x%x\n",
1880 __func__,
1881 stp_req,
1884 frame_header->status); 1882 frame_header->status);
1885 break; 1883 break;
1886 } 1884 }
@@ -1897,9 +1895,9 @@ enum sci_status scic_sds_io_request_frame_handler(struct scic_sds_request *sci_r
1897 SCU_TASK_DONE_CHECK_RESPONSE, 1895 SCU_TASK_DONE_CHECK_RESPONSE,
1898 SCI_FAILURE_IO_RESPONSE_VALID); 1896 SCI_FAILURE_IO_RESPONSE_VALID);
1899 1897
1900 sci_base_state_machine_change_state(&sci_req->state_machine, 1898 sci_change_state(&sci_req->sm, SCI_REQ_COMPLETED);
1901 SCI_BASE_REQUEST_STATE_COMPLETED);
1902 break; 1899 break;
1900
1903 default: 1901 default:
1904 /* FIXME: what do we do here? */ 1902 /* FIXME: what do we do here? */
1905 break; 1903 break;
@@ -1910,7 +1908,8 @@ enum sci_status scic_sds_io_request_frame_handler(struct scic_sds_request *sci_r
1910 1908
1911 return status; 1909 return status;
1912 } 1910 }
1913 case SCIC_SDS_STP_REQUEST_STARTED_PIO_DATA_IN_AWAIT_DATA_SUBSTATE: { 1911
1912 case SCI_REQ_STP_PIO_DATA_IN: {
1914 struct dev_to_host_fis *frame_header; 1913 struct dev_to_host_fis *frame_header;
1915 struct sata_fis_data *frame_buffer; 1914 struct sata_fis_data *frame_buffer;
1916 1915
@@ -1920,9 +1919,12 @@ enum sci_status scic_sds_io_request_frame_handler(struct scic_sds_request *sci_r
1920 1919
1921 if (status != SCI_SUCCESS) { 1920 if (status != SCI_SUCCESS) {
1922 dev_err(scic_to_dev(scic), 1921 dev_err(scic_to_dev(scic),
1923 "%s: SCIC IO Request 0x%p could not get frame header " 1922 "%s: SCIC IO Request 0x%p could not get frame "
1924 "for frame index %d, status %x\n", 1923 "header for frame index %d, status %x\n",
1925 __func__, stp_req, frame_index, status); 1924 __func__,
1925 stp_req,
1926 frame_index,
1927 status);
1926 return status; 1928 return status;
1927 } 1929 }
1928 1930
@@ -1930,15 +1932,17 @@ enum sci_status scic_sds_io_request_frame_handler(struct scic_sds_request *sci_r
1930 dev_err(scic_to_dev(scic), 1932 dev_err(scic_to_dev(scic),
1931 "%s: SCIC PIO Request 0x%p received frame %d " 1933 "%s: SCIC PIO Request 0x%p received frame %d "
1932 "with fis type 0x%02x when expecting a data " 1934 "with fis type 0x%02x when expecting a data "
1933 "fis.\n", __func__, stp_req, frame_index, 1935 "fis.\n",
1936 __func__,
1937 stp_req,
1938 frame_index,
1934 frame_header->fis_type); 1939 frame_header->fis_type);
1935 1940
1936 scic_sds_request_set_status(sci_req, 1941 scic_sds_request_set_status(sci_req,
1937 SCU_TASK_DONE_GOOD, 1942 SCU_TASK_DONE_GOOD,
1938 SCI_FAILURE_IO_REQUIRES_SCSI_ABORT); 1943 SCI_FAILURE_IO_REQUIRES_SCSI_ABORT);
1939 1944
1940 sci_base_state_machine_change_state(&sci_req->state_machine, 1945 sci_change_state(&sci_req->sm, SCI_REQ_COMPLETED);
1941 SCI_BASE_REQUEST_STATE_COMPLETED);
1942 1946
1943 /* Frame is decoded return it to the controller */ 1947 /* Frame is decoded return it to the controller */
1944 scic_sds_controller_release_frame(scic, frame_index); 1948 scic_sds_controller_release_frame(scic, frame_index);
@@ -1972,15 +1976,14 @@ enum sci_status scic_sds_io_request_frame_handler(struct scic_sds_request *sci_r
1972 SCU_TASK_DONE_CHECK_RESPONSE, 1976 SCU_TASK_DONE_CHECK_RESPONSE,
1973 SCI_FAILURE_IO_RESPONSE_VALID); 1977 SCI_FAILURE_IO_RESPONSE_VALID);
1974 1978
1975 sci_base_state_machine_change_state(&sci_req->state_machine, 1979 sci_change_state(&sci_req->sm, SCI_REQ_COMPLETED);
1976 SCI_BASE_REQUEST_STATE_COMPLETED);
1977 } else { 1980 } else {
1978 sci_base_state_machine_change_state(&sci_req->state_machine, 1981 sci_change_state(&sci_req->sm, SCI_REQ_STP_PIO_WAIT_FRAME);
1979 SCIC_SDS_STP_REQUEST_STARTED_PIO_AWAIT_FRAME_SUBSTATE);
1980 } 1982 }
1981 return status; 1983 return status;
1982 } 1984 }
1983 case SCIC_SDS_STP_REQUEST_STARTED_SOFT_RESET_AWAIT_D2H_RESPONSE_FRAME_SUBSTATE: { 1985
1986 case SCI_REQ_STP_SOFT_RESET_WAIT_D2H: {
1984 struct dev_to_host_fis *frame_header; 1987 struct dev_to_host_fis *frame_header;
1985 u32 *frame_buffer; 1988 u32 *frame_buffer;
1986 1989
@@ -1989,9 +1992,12 @@ enum sci_status scic_sds_io_request_frame_handler(struct scic_sds_request *sci_r
1989 (void **)&frame_header); 1992 (void **)&frame_header);
1990 if (status != SCI_SUCCESS) { 1993 if (status != SCI_SUCCESS) {
1991 dev_err(scic_to_dev(scic), 1994 dev_err(scic_to_dev(scic),
1992 "%s: SCIC IO Request 0x%p could not get frame header " 1995 "%s: SCIC IO Request 0x%p could not get frame "
1993 "for frame index %d, status %x\n", 1996 "header for frame index %d, status %x\n",
1994 __func__, stp_req, frame_index, status); 1997 __func__,
1998 stp_req,
1999 frame_index,
2000 status);
1995 return status; 2001 return status;
1996 } 2002 }
1997 2003
@@ -2010,35 +2016,43 @@ enum sci_status scic_sds_io_request_frame_handler(struct scic_sds_request *sci_r
2010 SCU_TASK_DONE_CHECK_RESPONSE, 2016 SCU_TASK_DONE_CHECK_RESPONSE,
2011 SCI_FAILURE_IO_RESPONSE_VALID); 2017 SCI_FAILURE_IO_RESPONSE_VALID);
2012 break; 2018 break;
2019
2013 default: 2020 default:
2014 dev_warn(scic_to_dev(scic), 2021 dev_warn(scic_to_dev(scic),
2015 "%s: IO Request:0x%p Frame Id:%d protocol " 2022 "%s: IO Request:0x%p Frame Id:%d protocol "
2016 "violation occurred\n", __func__, stp_req, 2023 "violation occurred\n",
2024 __func__,
2025 stp_req,
2017 frame_index); 2026 frame_index);
2018 2027
2019 scic_sds_request_set_status(sci_req, SCU_TASK_DONE_UNEXP_FIS, 2028 scic_sds_request_set_status(sci_req,
2029 SCU_TASK_DONE_UNEXP_FIS,
2020 SCI_FAILURE_PROTOCOL_VIOLATION); 2030 SCI_FAILURE_PROTOCOL_VIOLATION);
2021 break; 2031 break;
2022 } 2032 }
2023 2033
2024 sci_base_state_machine_change_state(&sci_req->state_machine, 2034 sci_change_state(&sci_req->sm, SCI_REQ_COMPLETED);
2025 SCI_BASE_REQUEST_STATE_COMPLETED);
2026 2035
2027 /* Frame has been decoded return it to the controller */ 2036 /* Frame has been decoded return it to the controller */
2028 scic_sds_controller_release_frame(scic, frame_index); 2037 scic_sds_controller_release_frame(scic, frame_index);
2029 2038
2030 return status; 2039 return status;
2031 } 2040 }
2032 case SCI_BASE_REQUEST_STATE_ABORTING: 2041 case SCI_REQ_ABORTING:
2033 /* TODO: Is it even possible to get an unsolicited frame in the 2042 /*
2043 * TODO: Is it even possible to get an unsolicited frame in the
2034 * aborting state? 2044 * aborting state?
2035 */ 2045 */
2036 scic_sds_controller_release_frame(scic, frame_index); 2046 scic_sds_controller_release_frame(scic, frame_index);
2037 return SCI_SUCCESS; 2047 return SCI_SUCCESS;
2048
2038 default: 2049 default:
2039 dev_warn(scic_to_dev(scic), 2050 dev_warn(scic_to_dev(scic),
2040 "%s: SCIC IO Request given unexpected frame %x while in " 2051 "%s: SCIC IO Request given unexpected frame %x while "
2041 "state %d\n", __func__, frame_index, state); 2052 "in state %d\n",
2053 __func__,
2054 frame_index,
2055 state);
2042 2056
2043 scic_sds_controller_release_frame(scic, frame_index); 2057 scic_sds_controller_release_frame(scic, frame_index);
2044 return SCI_FAILURE_INVALID_STATE; 2058 return SCI_FAILURE_INVALID_STATE;
@@ -2075,8 +2089,7 @@ static enum sci_status stp_request_udma_await_tc_event(struct scic_sds_request *
2075 * the device so we must change state to wait 2089 * the device so we must change state to wait
2076 * for it 2090 * for it
2077 */ 2091 */
2078 sci_base_state_machine_change_state(&sci_req->state_machine, 2092 sci_change_state(&sci_req->sm, SCI_REQ_STP_UDMA_WAIT_D2H);
2079 SCIC_SDS_STP_REQUEST_STARTED_UDMA_AWAIT_D2H_REG_FIS_SUBSTATE);
2080 } 2093 }
2081 break; 2094 break;
2082 2095
@@ -2105,45 +2118,45 @@ static enum sci_status stp_request_udma_await_tc_event(struct scic_sds_request *
2105 return status; 2118 return status;
2106} 2119}
2107 2120
2108static enum sci_status stp_request_soft_reset_await_h2d_asserted_tc_event(struct scic_sds_request *sci_req, 2121static enum sci_status
2109 u32 completion_code) 2122stp_request_soft_reset_await_h2d_asserted_tc_event(struct scic_sds_request *sci_req,
2123 u32 completion_code)
2110{ 2124{
2111 switch (SCU_GET_COMPLETION_TL_STATUS(completion_code)) { 2125 switch (SCU_GET_COMPLETION_TL_STATUS(completion_code)) {
2112 case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_GOOD): 2126 case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_GOOD):
2113 scic_sds_request_set_status(sci_req, SCU_TASK_DONE_GOOD, 2127 scic_sds_request_set_status(sci_req, SCU_TASK_DONE_GOOD,
2114 SCI_SUCCESS); 2128 SCI_SUCCESS);
2115 2129
2116 sci_base_state_machine_change_state(&sci_req->state_machine, 2130 sci_change_state(&sci_req->sm, SCI_REQ_STP_SOFT_RESET_WAIT_H2D_DIAG);
2117 SCIC_SDS_STP_REQUEST_STARTED_SOFT_RESET_AWAIT_H2D_DIAGNOSTIC_COMPLETION_SUBSTATE);
2118 break; 2131 break;
2119 2132
2120 default: 2133 default:
2121 /* 2134 /*
2122 * All other completion status cause the IO to be complete. If a NAK 2135 * All other completion status cause the IO to be complete.
2123 * was received, then it is up to the user to retry the request. */ 2136 * If a NAK was received, then it is up to the user to retry
2137 * the request.
2138 */
2124 scic_sds_request_set_status(sci_req, 2139 scic_sds_request_set_status(sci_req,
2125 SCU_NORMALIZE_COMPLETION_STATUS(completion_code), 2140 SCU_NORMALIZE_COMPLETION_STATUS(completion_code),
2126 SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR); 2141 SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR);
2127 2142
2128 sci_base_state_machine_change_state(&sci_req->state_machine, 2143 sci_change_state(&sci_req->sm, SCI_REQ_COMPLETED);
2129 SCI_BASE_REQUEST_STATE_COMPLETED);
2130 break; 2144 break;
2131 } 2145 }
2132 2146
2133 return SCI_SUCCESS; 2147 return SCI_SUCCESS;
2134} 2148}
2135 2149
2136static enum sci_status stp_request_soft_reset_await_h2d_diagnostic_tc_event( 2150static enum sci_status
2137 struct scic_sds_request *sci_req, 2151stp_request_soft_reset_await_h2d_diagnostic_tc_event(struct scic_sds_request *sci_req,
2138 u32 completion_code) 2152 u32 completion_code)
2139{ 2153{
2140 switch (SCU_GET_COMPLETION_TL_STATUS(completion_code)) { 2154 switch (SCU_GET_COMPLETION_TL_STATUS(completion_code)) {
2141 case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_GOOD): 2155 case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_GOOD):
2142 scic_sds_request_set_status(sci_req, SCU_TASK_DONE_GOOD, 2156 scic_sds_request_set_status(sci_req, SCU_TASK_DONE_GOOD,
2143 SCI_SUCCESS); 2157 SCI_SUCCESS);
2144 2158
2145 sci_base_state_machine_change_state(&sci_req->state_machine, 2159 sci_change_state(&sci_req->sm, SCI_REQ_STP_SOFT_RESET_WAIT_D2H);
2146 SCIC_SDS_STP_REQUEST_STARTED_SOFT_RESET_AWAIT_D2H_RESPONSE_FRAME_SUBSTATE);
2147 break; 2160 break;
2148 2161
2149 default: 2162 default:
@@ -2155,8 +2168,7 @@ static enum sci_status stp_request_soft_reset_await_h2d_diagnostic_tc_event(
2155 SCU_NORMALIZE_COMPLETION_STATUS(completion_code), 2168 SCU_NORMALIZE_COMPLETION_STATUS(completion_code),
2156 SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR); 2169 SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR);
2157 2170
2158 sci_base_state_machine_change_state(&sci_req->state_machine, 2171 sci_change_state(&sci_req->sm, SCI_REQ_COMPLETED);
2159 SCI_BASE_REQUEST_STATE_COMPLETED);
2160 break; 2172 break;
2161 } 2173 }
2162 2174
@@ -2164,42 +2176,64 @@ static enum sci_status stp_request_soft_reset_await_h2d_diagnostic_tc_event(
2164} 2176}
2165 2177
2166enum sci_status 2178enum sci_status
2167scic_sds_io_request_tc_completion(struct scic_sds_request *sci_req, u32 completion_code) 2179scic_sds_io_request_tc_completion(struct scic_sds_request *sci_req,
2180 u32 completion_code)
2168{ 2181{
2169 enum sci_base_request_states state; 2182 enum sci_base_request_states state;
2170 struct scic_sds_controller *scic = sci_req->owning_controller; 2183 struct scic_sds_controller *scic = sci_req->owning_controller;
2171 2184
2172 state = sci_req->state_machine.current_state_id; 2185 state = sci_req->sm.current_state_id;
2173 2186
2174 switch (state) { 2187 switch (state) {
2175 case SCI_BASE_REQUEST_STATE_STARTED: 2188 case SCI_REQ_STARTED:
2176 return request_started_state_tc_event(sci_req, completion_code); 2189 return request_started_state_tc_event(sci_req, completion_code);
2177 case SCIC_SDS_IO_REQUEST_STARTED_TASK_MGMT_SUBSTATE_AWAIT_TC_COMPLETION: 2190
2178 return ssp_task_request_await_tc_event(sci_req, completion_code); 2191 case SCI_REQ_TASK_WAIT_TC_COMP:
2179 case SCIC_SDS_SMP_REQUEST_STARTED_SUBSTATE_AWAIT_RESPONSE: 2192 return ssp_task_request_await_tc_event(sci_req,
2180 return smp_request_await_response_tc_event(sci_req, completion_code); 2193 completion_code);
2181 case SCIC_SDS_SMP_REQUEST_STARTED_SUBSTATE_AWAIT_TC_COMPLETION: 2194
2182 return smp_request_await_tc_event(sci_req, completion_code); 2195 case SCI_REQ_SMP_WAIT_RESP:
2183 case SCIC_SDS_STP_REQUEST_STARTED_UDMA_AWAIT_TC_COMPLETION_SUBSTATE: 2196 return smp_request_await_response_tc_event(sci_req,
2184 return stp_request_udma_await_tc_event(sci_req, completion_code); 2197 completion_code);
2185 case SCIC_SDS_STP_REQUEST_STARTED_NON_DATA_AWAIT_H2D_COMPLETION_SUBSTATE: 2198
2186 return stp_request_non_data_await_h2d_tc_event(sci_req, completion_code); 2199 case SCI_REQ_SMP_WAIT_TC_COMP:
2187 case SCIC_SDS_STP_REQUEST_STARTED_PIO_AWAIT_H2D_COMPLETION_SUBSTATE: 2200 return smp_request_await_tc_event(sci_req, completion_code);
2188 return stp_request_pio_await_h2d_completion_tc_event(sci_req, completion_code); 2201
2189 case SCIC_SDS_STP_REQUEST_STARTED_PIO_DATA_OUT_TRANSMIT_DATA_SUBSTATE: 2202 case SCI_REQ_STP_UDMA_WAIT_TC_COMP:
2190 return pio_data_out_tx_done_tc_event(sci_req, completion_code); 2203 return stp_request_udma_await_tc_event(sci_req,
2191 case SCIC_SDS_STP_REQUEST_STARTED_SOFT_RESET_AWAIT_H2D_ASSERTED_COMPLETION_SUBSTATE: 2204 completion_code);
2192 return stp_request_soft_reset_await_h2d_asserted_tc_event(sci_req, completion_code); 2205
2193 case SCIC_SDS_STP_REQUEST_STARTED_SOFT_RESET_AWAIT_H2D_DIAGNOSTIC_COMPLETION_SUBSTATE: 2206 case SCI_REQ_STP_NON_DATA_WAIT_H2D:
2194 return stp_request_soft_reset_await_h2d_diagnostic_tc_event(sci_req, completion_code); 2207 return stp_request_non_data_await_h2d_tc_event(sci_req,
2195 case SCI_BASE_REQUEST_STATE_ABORTING: 2208 completion_code);
2196 return request_aborting_state_tc_event(sci_req, completion_code); 2209
2197 default: 2210 case SCI_REQ_STP_PIO_WAIT_H2D:
2198 dev_warn(scic_to_dev(scic), 2211 return stp_request_pio_await_h2d_completion_tc_event(sci_req,
2199 "%s: SCIC IO Request given task completion notification %x " 2212 completion_code);
2200 "while in wrong state %d\n", __func__, completion_code, 2213
2201 state); 2214 case SCI_REQ_STP_PIO_DATA_OUT:
2202 return SCI_FAILURE_INVALID_STATE; 2215 return pio_data_out_tx_done_tc_event(sci_req, completion_code);
2216
2217 case SCI_REQ_STP_SOFT_RESET_WAIT_H2D_ASSERTED:
2218 return stp_request_soft_reset_await_h2d_asserted_tc_event(sci_req,
2219 completion_code);
2220
2221 case SCI_REQ_STP_SOFT_RESET_WAIT_H2D_DIAG:
2222 return stp_request_soft_reset_await_h2d_diagnostic_tc_event(sci_req,
2223 completion_code);
2224
2225 case SCI_REQ_ABORTING:
2226 return request_aborting_state_tc_event(sci_req,
2227 completion_code);
2228
2229 default:
2230 dev_warn(scic_to_dev(scic),
2231 "%s: SCIC IO Request given task completion "
2232 "notification %x while in wrong state %d\n",
2233 __func__,
2234 completion_code,
2235 state);
2236 return SCI_FAILURE_INVALID_STATE;
2203 } 2237 }
2204} 2238}
2205 2239
@@ -2896,7 +2930,7 @@ static void isci_request_io_request_complete(struct isci_host *isci_host,
2896 2930
2897static void scic_sds_request_started_state_enter(struct sci_base_state_machine *sm) 2931static void scic_sds_request_started_state_enter(struct sci_base_state_machine *sm)
2898{ 2932{
2899 struct scic_sds_request *sci_req = container_of(sm, typeof(*sci_req), state_machine); 2933 struct scic_sds_request *sci_req = container_of(sm, typeof(*sci_req), sm);
2900 struct isci_request *ireq = sci_req_to_ireq(sci_req); 2934 struct isci_request *ireq = sci_req_to_ireq(sci_req);
2901 struct domain_device *dev = sci_dev_to_domain(sci_req->target_device); 2935 struct domain_device *dev = sci_dev_to_domain(sci_req->target_device);
2902 struct sas_task *task; 2936 struct sas_task *task;
@@ -2910,34 +2944,31 @@ static void scic_sds_request_started_state_enter(struct sci_base_state_machine *
2910 * substates 2944 * substates
2911 */ 2945 */
2912 if (!task && dev->dev_type == SAS_END_DEV) { 2946 if (!task && dev->dev_type == SAS_END_DEV) {
2913 sci_base_state_machine_change_state(sm, 2947 sci_change_state(sm, SCI_REQ_TASK_WAIT_TC_COMP);
2914 SCIC_SDS_IO_REQUEST_STARTED_TASK_MGMT_SUBSTATE_AWAIT_TC_COMPLETION);
2915 } else if (!task && 2948 } else if (!task &&
2916 (isci_request_access_tmf(ireq)->tmf_code == isci_tmf_sata_srst_high || 2949 (isci_request_access_tmf(ireq)->tmf_code == isci_tmf_sata_srst_high ||
2917 isci_request_access_tmf(ireq)->tmf_code == isci_tmf_sata_srst_low)) { 2950 isci_request_access_tmf(ireq)->tmf_code == isci_tmf_sata_srst_low)) {
2918 sci_base_state_machine_change_state(sm, 2951 sci_change_state(sm, SCI_REQ_STP_SOFT_RESET_WAIT_H2D_ASSERTED);
2919 SCIC_SDS_STP_REQUEST_STARTED_SOFT_RESET_AWAIT_H2D_ASSERTED_COMPLETION_SUBSTATE);
2920 } else if (task && task->task_proto == SAS_PROTOCOL_SMP) { 2952 } else if (task && task->task_proto == SAS_PROTOCOL_SMP) {
2921 sci_base_state_machine_change_state(sm, 2953 sci_change_state(sm, SCI_REQ_SMP_WAIT_RESP);
2922 SCIC_SDS_SMP_REQUEST_STARTED_SUBSTATE_AWAIT_RESPONSE);
2923 } else if (task && sas_protocol_ata(task->task_proto) && 2954 } else if (task && sas_protocol_ata(task->task_proto) &&
2924 !task->ata_task.use_ncq) { 2955 !task->ata_task.use_ncq) {
2925 u32 state; 2956 u32 state;
2926 2957
2927 if (task->data_dir == DMA_NONE) 2958 if (task->data_dir == DMA_NONE)
2928 state = SCIC_SDS_STP_REQUEST_STARTED_NON_DATA_AWAIT_H2D_COMPLETION_SUBSTATE; 2959 state = SCI_REQ_STP_NON_DATA_WAIT_H2D;
2929 else if (task->ata_task.dma_xfer) 2960 else if (task->ata_task.dma_xfer)
2930 state = SCIC_SDS_STP_REQUEST_STARTED_UDMA_AWAIT_TC_COMPLETION_SUBSTATE; 2961 state = SCI_REQ_STP_UDMA_WAIT_TC_COMP;
2931 else /* PIO */ 2962 else /* PIO */
2932 state = SCIC_SDS_STP_REQUEST_STARTED_PIO_AWAIT_H2D_COMPLETION_SUBSTATE; 2963 state = SCI_REQ_STP_PIO_WAIT_H2D;
2933 2964
2934 sci_base_state_machine_change_state(sm, state); 2965 sci_change_state(sm, state);
2935 } 2966 }
2936} 2967}
2937 2968
2938static void scic_sds_request_completed_state_enter(struct sci_base_state_machine *sm) 2969static void scic_sds_request_completed_state_enter(struct sci_base_state_machine *sm)
2939{ 2970{
2940 struct scic_sds_request *sci_req = container_of(sm, typeof(*sci_req), state_machine); 2971 struct scic_sds_request *sci_req = container_of(sm, typeof(*sci_req), sm);
2941 struct scic_sds_controller *scic = sci_req->owning_controller; 2972 struct scic_sds_controller *scic = sci_req->owning_controller;
2942 struct isci_host *ihost = scic_to_ihost(scic); 2973 struct isci_host *ihost = scic_to_ihost(scic);
2943 struct isci_request *ireq = sci_req_to_ireq(sci_req); 2974 struct isci_request *ireq = sci_req_to_ireq(sci_req);
@@ -2952,7 +2983,7 @@ static void scic_sds_request_completed_state_enter(struct sci_base_state_machine
2952 2983
2953static void scic_sds_request_aborting_state_enter(struct sci_base_state_machine *sm) 2984static void scic_sds_request_aborting_state_enter(struct sci_base_state_machine *sm)
2954{ 2985{
2955 struct scic_sds_request *sci_req = container_of(sm, typeof(*sci_req), state_machine); 2986 struct scic_sds_request *sci_req = container_of(sm, typeof(*sci_req), sm);
2956 2987
2957 /* Setting the abort bit in the Task Context is required by the silicon. */ 2988 /* Setting the abort bit in the Task Context is required by the silicon. */
2958 sci_req->task_context_buffer->abort = 1; 2989 sci_req->task_context_buffer->abort = 1;
@@ -2960,7 +2991,7 @@ static void scic_sds_request_aborting_state_enter(struct sci_base_state_machine
2960 2991
2961static void scic_sds_stp_request_started_non_data_await_h2d_completion_enter(struct sci_base_state_machine *sm) 2992static void scic_sds_stp_request_started_non_data_await_h2d_completion_enter(struct sci_base_state_machine *sm)
2962{ 2993{
2963 struct scic_sds_request *sci_req = container_of(sm, typeof(*sci_req), state_machine); 2994 struct scic_sds_request *sci_req = container_of(sm, typeof(*sci_req), sm);
2964 2995
2965 scic_sds_remote_device_set_working_request(sci_req->target_device, 2996 scic_sds_remote_device_set_working_request(sci_req->target_device,
2966 sci_req); 2997 sci_req);
@@ -2968,7 +2999,7 @@ static void scic_sds_stp_request_started_non_data_await_h2d_completion_enter(str
2968 2999
2969static void scic_sds_stp_request_started_pio_await_h2d_completion_enter(struct sci_base_state_machine *sm) 3000static void scic_sds_stp_request_started_pio_await_h2d_completion_enter(struct sci_base_state_machine *sm)
2970{ 3001{
2971 struct scic_sds_request *sci_req = container_of(sm, typeof(*sci_req), state_machine); 3002 struct scic_sds_request *sci_req = container_of(sm, typeof(*sci_req), sm);
2972 3003
2973 scic_sds_remote_device_set_working_request(sci_req->target_device, 3004 scic_sds_remote_device_set_working_request(sci_req->target_device,
2974 sci_req); 3005 sci_req);
@@ -2976,7 +3007,7 @@ static void scic_sds_stp_request_started_pio_await_h2d_completion_enter(struct s
2976 3007
2977static void scic_sds_stp_request_started_soft_reset_await_h2d_asserted_completion_enter(struct sci_base_state_machine *sm) 3008static void scic_sds_stp_request_started_soft_reset_await_h2d_asserted_completion_enter(struct sci_base_state_machine *sm)
2978{ 3009{
2979 struct scic_sds_request *sci_req = container_of(sm, typeof(*sci_req), state_machine); 3010 struct scic_sds_request *sci_req = container_of(sm, typeof(*sci_req), sm);
2980 3011
2981 scic_sds_remote_device_set_working_request(sci_req->target_device, 3012 scic_sds_remote_device_set_working_request(sci_req->target_device,
2982 sci_req); 3013 sci_req);
@@ -2984,7 +3015,7 @@ static void scic_sds_stp_request_started_soft_reset_await_h2d_asserted_completio
2984 3015
2985static void scic_sds_stp_request_started_soft_reset_await_h2d_diagnostic_completion_enter(struct sci_base_state_machine *sm) 3016static void scic_sds_stp_request_started_soft_reset_await_h2d_diagnostic_completion_enter(struct sci_base_state_machine *sm)
2986{ 3017{
2987 struct scic_sds_request *sci_req = container_of(sm, typeof(*sci_req), state_machine); 3018 struct scic_sds_request *sci_req = container_of(sm, typeof(*sci_req), sm);
2988 struct scu_task_context *task_context; 3019 struct scu_task_context *task_context;
2989 struct host_to_dev_fis *h2d_fis; 3020 struct host_to_dev_fis *h2d_fis;
2990 enum sci_status status; 3021 enum sci_status status;
@@ -3003,51 +3034,53 @@ static void scic_sds_stp_request_started_soft_reset_await_h2d_diagnostic_complet
3003} 3034}
3004 3035
3005static const struct sci_base_state scic_sds_request_state_table[] = { 3036static const struct sci_base_state scic_sds_request_state_table[] = {
3006 [SCI_BASE_REQUEST_STATE_INITIAL] = { }, 3037 [SCI_REQ_INIT] = { },
3007 [SCI_BASE_REQUEST_STATE_CONSTRUCTED] = { }, 3038 [SCI_REQ_CONSTRUCTED] = { },
3008 [SCI_BASE_REQUEST_STATE_STARTED] = { 3039 [SCI_REQ_STARTED] = {
3009 .enter_state = scic_sds_request_started_state_enter, 3040 .enter_state = scic_sds_request_started_state_enter,
3010 }, 3041 },
3011 [SCIC_SDS_STP_REQUEST_STARTED_NON_DATA_AWAIT_H2D_COMPLETION_SUBSTATE] = { 3042 [SCI_REQ_STP_NON_DATA_WAIT_H2D] = {
3012 .enter_state = scic_sds_stp_request_started_non_data_await_h2d_completion_enter, 3043 .enter_state = scic_sds_stp_request_started_non_data_await_h2d_completion_enter,
3013 }, 3044 },
3014 [SCIC_SDS_STP_REQUEST_STARTED_NON_DATA_AWAIT_D2H_SUBSTATE] = { }, 3045 [SCI_REQ_STP_NON_DATA_WAIT_D2H] = { },
3015 [SCIC_SDS_STP_REQUEST_STARTED_PIO_AWAIT_H2D_COMPLETION_SUBSTATE] = { 3046 [SCI_REQ_STP_PIO_WAIT_H2D] = {
3016 .enter_state = scic_sds_stp_request_started_pio_await_h2d_completion_enter, 3047 .enter_state = scic_sds_stp_request_started_pio_await_h2d_completion_enter,
3017 }, 3048 },
3018 [SCIC_SDS_STP_REQUEST_STARTED_PIO_AWAIT_FRAME_SUBSTATE] = { }, 3049 [SCI_REQ_STP_PIO_WAIT_FRAME] = { },
3019 [SCIC_SDS_STP_REQUEST_STARTED_PIO_DATA_IN_AWAIT_DATA_SUBSTATE] = { }, 3050 [SCI_REQ_STP_PIO_DATA_IN] = { },
3020 [SCIC_SDS_STP_REQUEST_STARTED_PIO_DATA_OUT_TRANSMIT_DATA_SUBSTATE] = { }, 3051 [SCI_REQ_STP_PIO_DATA_OUT] = { },
3021 [SCIC_SDS_STP_REQUEST_STARTED_UDMA_AWAIT_TC_COMPLETION_SUBSTATE] = { }, 3052 [SCI_REQ_STP_UDMA_WAIT_TC_COMP] = { },
3022 [SCIC_SDS_STP_REQUEST_STARTED_UDMA_AWAIT_D2H_REG_FIS_SUBSTATE] = { }, 3053 [SCI_REQ_STP_UDMA_WAIT_D2H] = { },
3023 [SCIC_SDS_STP_REQUEST_STARTED_SOFT_RESET_AWAIT_H2D_ASSERTED_COMPLETION_SUBSTATE] = { 3054 [SCI_REQ_STP_SOFT_RESET_WAIT_H2D_ASSERTED] = {
3024 .enter_state = scic_sds_stp_request_started_soft_reset_await_h2d_asserted_completion_enter, 3055 .enter_state = scic_sds_stp_request_started_soft_reset_await_h2d_asserted_completion_enter,
3025 }, 3056 },
3026 [SCIC_SDS_STP_REQUEST_STARTED_SOFT_RESET_AWAIT_H2D_DIAGNOSTIC_COMPLETION_SUBSTATE] = { 3057 [SCI_REQ_STP_SOFT_RESET_WAIT_H2D_DIAG] = {
3027 .enter_state = scic_sds_stp_request_started_soft_reset_await_h2d_diagnostic_completion_enter, 3058 .enter_state = scic_sds_stp_request_started_soft_reset_await_h2d_diagnostic_completion_enter,
3028 }, 3059 },
3029 [SCIC_SDS_STP_REQUEST_STARTED_SOFT_RESET_AWAIT_D2H_RESPONSE_FRAME_SUBSTATE] = { }, 3060 [SCI_REQ_STP_SOFT_RESET_WAIT_D2H] = { },
3030 [SCIC_SDS_IO_REQUEST_STARTED_TASK_MGMT_SUBSTATE_AWAIT_TC_COMPLETION] = { }, 3061 [SCI_REQ_TASK_WAIT_TC_COMP] = { },
3031 [SCIC_SDS_IO_REQUEST_STARTED_TASK_MGMT_SUBSTATE_AWAIT_TC_RESPONSE] = { }, 3062 [SCI_REQ_TASK_WAIT_TC_RESP] = { },
3032 [SCIC_SDS_SMP_REQUEST_STARTED_SUBSTATE_AWAIT_RESPONSE] = { }, 3063 [SCI_REQ_SMP_WAIT_RESP] = { },
3033 [SCIC_SDS_SMP_REQUEST_STARTED_SUBSTATE_AWAIT_TC_COMPLETION] = { }, 3064 [SCI_REQ_SMP_WAIT_TC_COMP] = { },
3034 [SCI_BASE_REQUEST_STATE_COMPLETED] = { 3065 [SCI_REQ_COMPLETED] = {
3035 .enter_state = scic_sds_request_completed_state_enter, 3066 .enter_state = scic_sds_request_completed_state_enter,
3036 }, 3067 },
3037 [SCI_BASE_REQUEST_STATE_ABORTING] = { 3068 [SCI_REQ_ABORTING] = {
3038 .enter_state = scic_sds_request_aborting_state_enter, 3069 .enter_state = scic_sds_request_aborting_state_enter,
3039 }, 3070 },
3040 [SCI_BASE_REQUEST_STATE_FINAL] = { }, 3071 [SCI_REQ_FINAL] = { },
3041}; 3072};
3042 3073
3043static void scic_sds_general_request_construct(struct scic_sds_controller *scic, 3074static void
3044 struct scic_sds_remote_device *sci_dev, 3075scic_sds_general_request_construct(struct scic_sds_controller *scic,
3045 u16 io_tag, struct scic_sds_request *sci_req) 3076 struct scic_sds_remote_device *sci_dev,
3077 u16 io_tag,
3078 struct scic_sds_request *sci_req)
3046{ 3079{
3047 sci_base_state_machine_construct(&sci_req->state_machine, 3080 sci_base_state_machine_construct(&sci_req->sm,
3048 scic_sds_request_state_table, 3081 scic_sds_request_state_table,
3049 SCI_BASE_REQUEST_STATE_INITIAL); 3082 SCI_REQ_INIT);
3050 sci_base_state_machine_start(&sci_req->state_machine); 3083 sci_base_state_machine_start(&sci_req->sm);
3051 3084
3052 sci_req->io_tag = io_tag; 3085 sci_req->io_tag = io_tag;
3053 sci_req->owning_controller = scic; 3086 sci_req->owning_controller = scic;
@@ -3322,8 +3355,7 @@ scic_io_request_construct_smp(struct scic_sds_request *sci_req)
3322 3355
3323 scu_smp_request_construct_task_context(sci_req, smp_req->req_len); 3356 scu_smp_request_construct_task_context(sci_req, smp_req->req_len);
3324 3357
3325 sci_base_state_machine_change_state(&sci_req->state_machine, 3358 sci_change_state(&sci_req->sm, SCI_REQ_CONSTRUCTED);
3326 SCI_BASE_REQUEST_STATE_CONSTRUCTED);
3327 3359
3328 return SCI_SUCCESS; 3360 return SCI_SUCCESS;
3329} 3361}