aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/isci/phy.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/scsi/isci/phy.c')
-rw-r--r--drivers/scsi/isci/phy.c574
1 files changed, 83 insertions, 491 deletions
diff --git a/drivers/scsi/isci/phy.c b/drivers/scsi/isci/phy.c
index 0ffb5d5a860e..9a5ec375f767 100644
--- a/drivers/scsi/isci/phy.c
+++ b/drivers/scsi/isci/phy.c
@@ -505,16 +505,53 @@ enum sci_status scic_sds_phy_reset(struct scic_sds_phy *sci_phy)
505 return SCI_SUCCESS; 505 return SCI_SUCCESS;
506} 506}
507 507
508/** 508enum sci_status scic_sds_phy_consume_power_handler(struct scic_sds_phy *sci_phy)
509 * This method will give the phy permission to consume power
510 * @sci_phy:
511 *
512 * enum sci_status
513 */
514enum sci_status scic_sds_phy_consume_power_handler(
515 struct scic_sds_phy *sci_phy)
516{ 509{
517 return sci_phy->state_handlers->consume_power_handler(sci_phy); 510 enum scic_sds_phy_states state = sci_phy->state_machine.current_state_id;
511
512 switch (state) {
513 case SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SAS_POWER: {
514 u32 enable_spinup;
515
516 enable_spinup = readl(&sci_phy->link_layer_registers->notify_enable_spinup_control);
517 enable_spinup |= SCU_ENSPINUP_GEN_BIT(ENABLE);
518 writel(enable_spinup, &sci_phy->link_layer_registers->notify_enable_spinup_control);
519
520 /* Change state to the final state this substate machine has run to completion */
521 sci_base_state_machine_change_state(&sci_phy->state_machine,
522 SCIC_SDS_PHY_STARTING_SUBSTATE_FINAL);
523
524 return SCI_SUCCESS;
525 }
526 case SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_POWER: {
527 u32 scu_sas_pcfg_value;
528
529 /* Release the spinup hold state and reset the OOB state machine */
530 scu_sas_pcfg_value =
531 readl(&sci_phy->link_layer_registers->phy_configuration);
532 scu_sas_pcfg_value &=
533 ~(SCU_SAS_PCFG_GEN_BIT(SATA_SPINUP_HOLD) | SCU_SAS_PCFG_GEN_BIT(OOB_ENABLE));
534 scu_sas_pcfg_value |= SCU_SAS_PCFG_GEN_BIT(OOB_RESET);
535 writel(scu_sas_pcfg_value,
536 &sci_phy->link_layer_registers->phy_configuration);
537
538 /* Now restart the OOB operation */
539 scu_sas_pcfg_value &= ~SCU_SAS_PCFG_GEN_BIT(OOB_RESET);
540 scu_sas_pcfg_value |= SCU_SAS_PCFG_GEN_BIT(OOB_ENABLE);
541 writel(scu_sas_pcfg_value,
542 &sci_phy->link_layer_registers->phy_configuration);
543
544 /* Change state to the final state this substate machine has run to completion */
545 sci_base_state_machine_change_state(&sci_phy->state_machine,
546 SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_PHY_EN);
547
548 return SCI_SUCCESS;
549 }
550 default:
551 dev_dbg(sciphy_to_dev(sci_phy),
552 "%s: in wrong state: %d\n", __func__, state);
553 return SCI_FAILURE_INVALID_STATE;
554 }
518} 555}
519 556
520/* 557/*
@@ -592,76 +629,6 @@ static void scic_sds_phy_complete_link_training(
592 next_state); 629 next_state);
593} 630}
594 631
595/*
596 * This method is called by the struct scic_sds_controller when the phy object is
597 * granted power. - The notify enable spinups are turned on for this phy object
598 * - The phy state machine is transitioned to the
599 * SCIC_SDS_PHY_STARTING_SUBSTATE_FINAL. enum sci_status SCI_SUCCESS
600 */
601static enum sci_status scic_sds_phy_starting_substate_await_sas_power_consume_power_handler(
602 struct scic_sds_phy *sci_phy)
603{
604 u32 enable_spinup;
605
606 enable_spinup = readl(&sci_phy->link_layer_registers->notify_enable_spinup_control);
607 enable_spinup |= SCU_ENSPINUP_GEN_BIT(ENABLE);
608 writel(enable_spinup, &sci_phy->link_layer_registers->notify_enable_spinup_control);
609
610 /* Change state to the final state this substate machine has run to completion */
611 sci_base_state_machine_change_state(&sci_phy->state_machine,
612 SCIC_SDS_PHY_STARTING_SUBSTATE_FINAL);
613
614 return SCI_SUCCESS;
615}
616
617/*
618 * This method is called by the struct scic_sds_controller when the phy object is
619 * granted power. - The phy state machine is transitioned to the
620 * SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_PHY_EN. enum sci_status SCI_SUCCESS
621 */
622static enum sci_status scic_sds_phy_starting_substate_await_sata_power_consume_power_handler(
623 struct scic_sds_phy *sci_phy)
624{
625 u32 scu_sas_pcfg_value;
626
627 /* Release the spinup hold state and reset the OOB state machine */
628 scu_sas_pcfg_value =
629 readl(&sci_phy->link_layer_registers->phy_configuration);
630 scu_sas_pcfg_value &=
631 ~(SCU_SAS_PCFG_GEN_BIT(SATA_SPINUP_HOLD) | SCU_SAS_PCFG_GEN_BIT(OOB_ENABLE));
632 scu_sas_pcfg_value |= SCU_SAS_PCFG_GEN_BIT(OOB_RESET);
633 writel(scu_sas_pcfg_value,
634 &sci_phy->link_layer_registers->phy_configuration);
635
636 /* Now restart the OOB operation */
637 scu_sas_pcfg_value &= ~SCU_SAS_PCFG_GEN_BIT(OOB_RESET);
638 scu_sas_pcfg_value |= SCU_SAS_PCFG_GEN_BIT(OOB_ENABLE);
639 writel(scu_sas_pcfg_value,
640 &sci_phy->link_layer_registers->phy_configuration);
641
642 /* Change state to the final state this substate machine has run to completion */
643 sci_base_state_machine_change_state(&sci_phy->state_machine,
644 SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_PHY_EN);
645
646 return SCI_SUCCESS;
647}
648
649static enum sci_status default_phy_handler(struct scic_sds_phy *sci_phy,
650 const char *func)
651{
652 dev_dbg(sciphy_to_dev(sci_phy),
653 "%s: in wrong state: %d\n", func,
654 sci_base_state_machine_get_state(&sci_phy->state_machine));
655 return SCI_FAILURE_INVALID_STATE;
656}
657
658static enum sci_status
659scic_sds_phy_default_consume_power_handler(struct scic_sds_phy *sci_phy)
660{
661 return default_phy_handler(sci_phy, __func__);
662}
663
664
665enum sci_status scic_sds_phy_event_handler(struct scic_sds_phy *sci_phy, 632enum sci_status scic_sds_phy_event_handler(struct scic_sds_phy *sci_phy,
666 u32 event_code) 633 u32 event_code)
667{ 634{
@@ -1059,287 +1026,71 @@ enum sci_status scic_sds_phy_frame_handler(struct scic_sds_phy *sci_phy,
1059 1026
1060} 1027}
1061 1028
1062
1063
1064/* --------------------------------------------------------------------------- */
1065
1066static const struct scic_sds_phy_state_handler scic_sds_phy_state_handler_table[] = {
1067 [SCI_BASE_PHY_STATE_INITIAL] = {
1068 .consume_power_handler = scic_sds_phy_default_consume_power_handler
1069 },
1070 [SCI_BASE_PHY_STATE_STOPPED] = {
1071 .consume_power_handler = scic_sds_phy_default_consume_power_handler
1072 },
1073 [SCI_BASE_PHY_STATE_STARTING] = {
1074 .consume_power_handler = scic_sds_phy_default_consume_power_handler
1075 },
1076 [SCIC_SDS_PHY_STARTING_SUBSTATE_INITIAL] = {
1077 .consume_power_handler = scic_sds_phy_default_consume_power_handler
1078 },
1079 [SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_OSSP_EN] = {
1080 .consume_power_handler = scic_sds_phy_default_consume_power_handler
1081 },
1082 [SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SAS_SPEED_EN] = {
1083 .consume_power_handler = scic_sds_phy_default_consume_power_handler
1084 },
1085 [SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_IAF_UF] = {
1086 .consume_power_handler = scic_sds_phy_default_consume_power_handler
1087 },
1088 [SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SAS_POWER] = {
1089 .consume_power_handler = scic_sds_phy_starting_substate_await_sas_power_consume_power_handler
1090 },
1091 [SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_POWER] = {
1092 .consume_power_handler = scic_sds_phy_starting_substate_await_sata_power_consume_power_handler
1093 },
1094 [SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_PHY_EN] = {
1095 .consume_power_handler = scic_sds_phy_default_consume_power_handler
1096 },
1097 [SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_SPEED_EN] = {
1098 .consume_power_handler = scic_sds_phy_default_consume_power_handler
1099 },
1100 [SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SIG_FIS_UF] = {
1101 .consume_power_handler = scic_sds_phy_default_consume_power_handler
1102 },
1103 [SCIC_SDS_PHY_STARTING_SUBSTATE_FINAL] = {
1104 .consume_power_handler = scic_sds_phy_default_consume_power_handler
1105 },
1106 [SCI_BASE_PHY_STATE_READY] = {
1107 .consume_power_handler = scic_sds_phy_default_consume_power_handler
1108 },
1109 [SCI_BASE_PHY_STATE_RESETTING] = {
1110 .consume_power_handler = scic_sds_phy_default_consume_power_handler
1111 },
1112 [SCI_BASE_PHY_STATE_FINAL] = {
1113 .consume_power_handler = scic_sds_phy_default_consume_power_handler
1114 }
1115};
1116
1117/*
1118 * ****************************************************************************
1119 * * PHY STARTING SUBSTATE METHODS
1120 * **************************************************************************** */
1121
1122/**
1123 * scic_sds_phy_starting_initial_substate_enter -
1124 * @object: This is the object which is cast to a struct scic_sds_phy object.
1125 *
1126 * This method will perform the actions required by the struct scic_sds_phy on
1127 * entering the SCIC_SDS_PHY_STARTING_SUBSTATE_INITIAL. - The initial state
1128 * handlers are put in place for the struct scic_sds_phy object. - The state is
1129 * changed to the wait phy type event notification. none
1130 */
1131static void scic_sds_phy_starting_initial_substate_enter(void *object) 1029static void scic_sds_phy_starting_initial_substate_enter(void *object)
1132{ 1030{
1133 struct scic_sds_phy *sci_phy = object; 1031 struct scic_sds_phy *sci_phy = object;
1134 1032
1135 scic_sds_phy_set_base_state_handlers(
1136 sci_phy, SCIC_SDS_PHY_STARTING_SUBSTATE_INITIAL);
1137
1138 /* This is just an temporary state go off to the starting state */ 1033 /* This is just an temporary state go off to the starting state */
1139 sci_base_state_machine_change_state(&sci_phy->state_machine, 1034 sci_base_state_machine_change_state(&sci_phy->state_machine,
1140 SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_OSSP_EN); 1035 SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_OSSP_EN);
1141} 1036}
1142 1037
1143/**
1144 *
1145 * @object: This is the object which is cast to a struct scic_sds_phy object.
1146 *
1147 * This method will perform the actions required by the struct scic_sds_phy on
1148 * entering the SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_PHY_TYPE_EN. - Set the
1149 * struct scic_sds_phy object state handlers for this state. none
1150 */
1151static void scic_sds_phy_starting_await_ossp_en_substate_enter(void *object)
1152{
1153 struct scic_sds_phy *sci_phy = object;
1154
1155 scic_sds_phy_set_base_state_handlers(
1156 sci_phy, SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_OSSP_EN
1157 );
1158}
1159
1160/**
1161 *
1162 * @object: This is the object which is cast to a struct scic_sds_phy object.
1163 *
1164 * This method will perform the actions required by the struct scic_sds_phy on
1165 * entering the SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SPEED_EN. - Set the
1166 * struct scic_sds_phy object state handlers for this state. none
1167 */
1168static void scic_sds_phy_starting_await_sas_speed_en_substate_enter(
1169 void *object)
1170{
1171 struct scic_sds_phy *sci_phy = object;
1172
1173 scic_sds_phy_set_base_state_handlers(
1174 sci_phy, SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SAS_SPEED_EN
1175 );
1176}
1177
1178/**
1179 *
1180 * @object: This is the object which is cast to a struct scic_sds_phy object.
1181 *
1182 * This method will perform the actions required by the struct scic_sds_phy on
1183 * entering the SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_IAF_UF. - Set the
1184 * struct scic_sds_phy object state handlers for this state. none
1185 */
1186static void scic_sds_phy_starting_await_iaf_uf_substate_enter(void *object)
1187{
1188 struct scic_sds_phy *sci_phy = object;
1189
1190 scic_sds_phy_set_base_state_handlers(
1191 sci_phy, SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_IAF_UF
1192 );
1193}
1194
1195/**
1196 *
1197 * @object: This is the object which is cast to a struct scic_sds_phy object.
1198 *
1199 * This method will perform the actions required by the struct scic_sds_phy on
1200 * entering the SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SAS_POWER. - Set the
1201 * struct scic_sds_phy object state handlers for this state. - Add this phy object to
1202 * the power control queue none
1203 */
1204static void scic_sds_phy_starting_await_sas_power_substate_enter(void *object) 1038static void scic_sds_phy_starting_await_sas_power_substate_enter(void *object)
1205{ 1039{
1206 struct scic_sds_phy *sci_phy = object; 1040 struct scic_sds_phy *sci_phy = object;
1041 struct scic_sds_controller *scic = sci_phy->owning_port->owning_controller;
1207 1042
1208 scic_sds_phy_set_base_state_handlers( 1043 scic_sds_controller_power_control_queue_insert(scic, sci_phy);
1209 sci_phy, SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SAS_POWER
1210 );
1211
1212 scic_sds_controller_power_control_queue_insert(
1213 scic_sds_phy_get_controller(sci_phy),
1214 sci_phy
1215 );
1216} 1044}
1217 1045
1218/**
1219 *
1220 * @object: This is the object which is cast to a struct scic_sds_phy object.
1221 *
1222 * This method will perform the actions required by the struct scic_sds_phy on exiting
1223 * the SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SAS_POWER. - Remove the
1224 * struct scic_sds_phy object from the power control queue. none
1225 */
1226static void scic_sds_phy_starting_await_sas_power_substate_exit(void *object) 1046static void scic_sds_phy_starting_await_sas_power_substate_exit(void *object)
1227{ 1047{
1228 struct scic_sds_phy *sci_phy = object; 1048 struct scic_sds_phy *sci_phy = object;
1049 struct scic_sds_controller *scic = sci_phy->owning_port->owning_controller;
1229 1050
1230 scic_sds_controller_power_control_queue_remove( 1051 scic_sds_controller_power_control_queue_remove(scic, sci_phy);
1231 scic_sds_phy_get_controller(sci_phy), sci_phy
1232 );
1233} 1052}
1234 1053
1235/**
1236 *
1237 * @object: This is the object which is cast to a struct scic_sds_phy object.
1238 *
1239 * This method will perform the actions required by the struct scic_sds_phy on
1240 * entering the SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_POWER. - Set the
1241 * struct scic_sds_phy object state handlers for this state. - Add this phy object to
1242 * the power control queue none
1243 */
1244static void scic_sds_phy_starting_await_sata_power_substate_enter(void *object) 1054static void scic_sds_phy_starting_await_sata_power_substate_enter(void *object)
1245{ 1055{
1246 struct scic_sds_phy *sci_phy = object; 1056 struct scic_sds_phy *sci_phy = object;
1057 struct scic_sds_controller *scic = sci_phy->owning_port->owning_controller;
1247 1058
1248 scic_sds_phy_set_base_state_handlers( 1059 scic_sds_controller_power_control_queue_insert(scic, sci_phy);
1249 sci_phy, SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_POWER
1250 );
1251
1252 scic_sds_controller_power_control_queue_insert(
1253 scic_sds_phy_get_controller(sci_phy),
1254 sci_phy
1255 );
1256} 1060}
1257 1061
1258/**
1259 *
1260 * @object: This is the object which is cast to a struct scic_sds_phy object.
1261 *
1262 * This method will perform the actions required by the struct scic_sds_phy on exiting
1263 * the SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_POWER. - Remove the
1264 * struct scic_sds_phy object from the power control queue. none
1265 */
1266static void scic_sds_phy_starting_await_sata_power_substate_exit(void *object) 1062static void scic_sds_phy_starting_await_sata_power_substate_exit(void *object)
1267{ 1063{
1268 struct scic_sds_phy *sci_phy = object; 1064 struct scic_sds_phy *sci_phy = object;
1065 struct scic_sds_controller *scic = sci_phy->owning_port->owning_controller;
1269 1066
1270 scic_sds_controller_power_control_queue_remove( 1067 scic_sds_controller_power_control_queue_remove(scic, sci_phy);
1271 scic_sds_phy_get_controller(sci_phy),
1272 sci_phy
1273 );
1274} 1068}
1275 1069
1276/**
1277 *
1278 * @object: This is the object which is cast to a struct scic_sds_phy object.
1279 *
1280 * This function will perform the actions required by the struct scic_sds_phy on
1281 * entering the SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_PHY_EN. - Set the
1282 * struct scic_sds_phy object state handlers for this state. none
1283 */
1284static void scic_sds_phy_starting_await_sata_phy_substate_enter(void *object) 1070static void scic_sds_phy_starting_await_sata_phy_substate_enter(void *object)
1285{ 1071{
1286 struct scic_sds_phy *sci_phy = object; 1072 struct scic_sds_phy *sci_phy = object;
1287 1073
1288 scic_sds_phy_set_base_state_handlers(
1289 sci_phy,
1290 SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_PHY_EN);
1291
1292 isci_timer_start(sci_phy->sata_timeout_timer, 1074 isci_timer_start(sci_phy->sata_timeout_timer,
1293 SCIC_SDS_SATA_LINK_TRAINING_TIMEOUT); 1075 SCIC_SDS_SATA_LINK_TRAINING_TIMEOUT);
1294} 1076}
1295 1077
1296/** 1078static void scic_sds_phy_starting_await_sata_phy_substate_exit(void *object)
1297 *
1298 * @object: This is the object which is cast to a struct scic_sds_phy object.
1299 *
1300 * This method will perform the actions required by the struct scic_sds_phy
1301 * on exiting
1302 * the SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_SPEED_EN. - stop the timer
1303 * that was started on entry to await sata phy event notification none
1304 */
1305static inline void scic_sds_phy_starting_await_sata_phy_substate_exit(
1306 void *object)
1307{ 1079{
1308 struct scic_sds_phy *sci_phy = object; 1080 struct scic_sds_phy *sci_phy = object;
1309 1081
1310 isci_timer_stop(sci_phy->sata_timeout_timer); 1082 isci_timer_stop(sci_phy->sata_timeout_timer);
1311} 1083}
1312 1084
1313/**
1314 *
1315 * @object: This is the object which is cast to a struct scic_sds_phy object.
1316 *
1317 * This method will perform the actions required by the struct scic_sds_phy on
1318 * entering the SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_SPEED_EN. - Set the
1319 * struct scic_sds_phy object state handlers for this state. none
1320 */
1321static void scic_sds_phy_starting_await_sata_speed_substate_enter(void *object) 1085static void scic_sds_phy_starting_await_sata_speed_substate_enter(void *object)
1322{ 1086{
1323 struct scic_sds_phy *sci_phy = object; 1087 struct scic_sds_phy *sci_phy = object;
1324 1088
1325 scic_sds_phy_set_base_state_handlers(
1326 sci_phy,
1327 SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_SPEED_EN);
1328
1329 isci_timer_start(sci_phy->sata_timeout_timer, 1089 isci_timer_start(sci_phy->sata_timeout_timer,
1330 SCIC_SDS_SATA_LINK_TRAINING_TIMEOUT); 1090 SCIC_SDS_SATA_LINK_TRAINING_TIMEOUT);
1331} 1091}
1332 1092
1333/** 1093static void scic_sds_phy_starting_await_sata_speed_substate_exit(
1334 *
1335 * @object: This is the object which is cast to a struct scic_sds_phy object.
1336 *
1337 * This function will perform the actions required by the
1338 * struct scic_sds_phy on exiting
1339 * the SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_SPEED_EN. - stop the timer
1340 * that was started on entry to await sata phy event notification none
1341 */
1342static inline void scic_sds_phy_starting_await_sata_speed_substate_exit(
1343 void *object) 1094 void *object)
1344{ 1095{
1345 struct scic_sds_phy *sci_phy = object; 1096 struct scic_sds_phy *sci_phy = object;
@@ -1347,30 +1098,12 @@ static inline void scic_sds_phy_starting_await_sata_speed_substate_exit(
1347 isci_timer_stop(sci_phy->sata_timeout_timer); 1098 isci_timer_stop(sci_phy->sata_timeout_timer);
1348} 1099}
1349 1100
1350/**
1351 *
1352 * @object: This is the object which is cast to a struct scic_sds_phy object.
1353 *
1354 * This function will perform the actions required by the struct scic_sds_phy on
1355 * entering the SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SIG_FIS_UF. - Set the
1356 * struct scic_sds_phy object state handlers for this state.
1357 * - Start the SIGNATURE FIS
1358 * timeout timer none
1359 */
1360static void scic_sds_phy_starting_await_sig_fis_uf_substate_enter(void *object) 1101static void scic_sds_phy_starting_await_sig_fis_uf_substate_enter(void *object)
1361{ 1102{
1362 bool continue_to_ready_state;
1363 struct scic_sds_phy *sci_phy = object; 1103 struct scic_sds_phy *sci_phy = object;
1364 1104
1365 scic_sds_phy_set_base_state_handlers( 1105 if (scic_sds_port_link_detected(sci_phy->owning_port, sci_phy)) {
1366 sci_phy,
1367 SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SIG_FIS_UF);
1368
1369 continue_to_ready_state = scic_sds_port_link_detected(
1370 sci_phy->owning_port,
1371 sci_phy);
1372 1106
1373 if (continue_to_ready_state) {
1374 /* 1107 /*
1375 * Clear the PE suspend condition so we can actually 1108 * Clear the PE suspend condition so we can actually
1376 * receive SIG FIS 1109 * receive SIG FIS
@@ -1385,39 +1118,17 @@ static void scic_sds_phy_starting_await_sig_fis_uf_substate_enter(void *object)
1385 sci_phy->is_in_link_training = false; 1118 sci_phy->is_in_link_training = false;
1386} 1119}
1387 1120
1388/** 1121static void scic_sds_phy_starting_await_sig_fis_uf_substate_exit(void *object)
1389 *
1390 * @object: This is the object which is cast to a struct scic_sds_phy object.
1391 *
1392 * This function will perform the actions required by the
1393 * struct scic_sds_phy on exiting
1394 * the SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SIG_FIS_UF. - Stop the SIGNATURE
1395 * FIS timeout timer. none
1396 */
1397static inline void scic_sds_phy_starting_await_sig_fis_uf_substate_exit(
1398 void *object)
1399{ 1122{
1400 struct scic_sds_phy *sci_phy = object; 1123 struct scic_sds_phy *sci_phy = object;
1401 1124
1402 isci_timer_stop(sci_phy->sata_timeout_timer); 1125 isci_timer_stop(sci_phy->sata_timeout_timer);
1403} 1126}
1404 1127
1405/**
1406 *
1407 * @object: This is the object which is cast to a struct scic_sds_phy object.
1408 *
1409 * This method will perform the actions required by the struct scic_sds_phy on
1410 * entering the SCIC_SDS_PHY_STARTING_SUBSTATE_FINAL. - Set the struct scic_sds_phy
1411 * object state handlers for this state. - Change base state machine to the
1412 * ready state. none
1413 */
1414static void scic_sds_phy_starting_final_substate_enter(void *object) 1128static void scic_sds_phy_starting_final_substate_enter(void *object)
1415{ 1129{
1416 struct scic_sds_phy *sci_phy = object; 1130 struct scic_sds_phy *sci_phy = object;
1417 1131
1418 scic_sds_phy_set_base_state_handlers(sci_phy,
1419 SCIC_SDS_PHY_STARTING_SUBSTATE_FINAL);
1420
1421 /* State machine has run to completion so exit out and change 1132 /* State machine has run to completion so exit out and change
1422 * the base state machine to the ready state 1133 * the base state machine to the ready state
1423 */ 1134 */
@@ -1425,11 +1136,6 @@ static void scic_sds_phy_starting_final_substate_enter(void *object)
1425 SCI_BASE_PHY_STATE_READY); 1136 SCI_BASE_PHY_STATE_READY);
1426} 1137}
1427 1138
1428/*
1429 * ****************************************************************************
1430 * * PHY STATE PRIVATE METHODS
1431 * **************************************************************************** */
1432
1433/** 1139/**
1434 * 1140 *
1435 * @sci_phy: This is the struct scic_sds_phy object to stop. 1141 * @sci_phy: This is the struct scic_sds_phy object to stop.
@@ -1511,49 +1217,17 @@ static void scu_link_layer_tx_hard_reset(
1511 &sci_phy->link_layer_registers->phy_configuration); 1217 &sci_phy->link_layer_registers->phy_configuration);
1512} 1218}
1513 1219
1514/*
1515 * ****************************************************************************
1516 * * PHY BASE STATE METHODS
1517 * **************************************************************************** */
1518
1519/**
1520 *
1521 * @object: This is the object which is cast to a struct scic_sds_phy object.
1522 *
1523 * This method will perform the actions required by the struct scic_sds_phy on
1524 * entering the SCI_BASE_PHY_STATE_INITIAL. - This function sets the state
1525 * handlers for the phy object base state machine initial state. none
1526 */
1527static void scic_sds_phy_initial_state_enter(void *object)
1528{
1529 struct scic_sds_phy *sci_phy = object;
1530
1531 scic_sds_phy_set_base_state_handlers(sci_phy, SCI_BASE_PHY_STATE_INITIAL);
1532}
1533
1534/**
1535 *
1536 * @object: This is the object which is cast to a struct scic_sds_phy object.
1537 *
1538 * This function will perform the actions required by the struct scic_sds_phy on
1539 * entering the SCI_BASE_PHY_STATE_INITIAL. - This function sets the state
1540 * handlers for the phy object base state machine initial state. - The SCU
1541 * hardware is requested to stop the protocol engine. none
1542 */
1543static void scic_sds_phy_stopped_state_enter(void *object) 1220static void scic_sds_phy_stopped_state_enter(void *object)
1544{ 1221{
1545 struct scic_sds_phy *sci_phy = object; 1222 struct scic_sds_phy *sci_phy = object;
1546 struct scic_sds_controller *scic = scic_sds_phy_get_controller(sci_phy); 1223 struct scic_sds_port *sci_port = sci_phy->owning_port;
1224 struct scic_sds_controller *scic = sci_port->owning_controller;
1547 struct isci_host *ihost = scic_to_ihost(scic); 1225 struct isci_host *ihost = scic_to_ihost(scic);
1548 1226
1549 /* 1227 /*
1550 * @todo We need to get to the controller to place this PE in a 1228 * @todo We need to get to the controller to place this PE in a
1551 * reset state 1229 * reset state
1552 */ 1230 */
1553
1554 scic_sds_phy_set_base_state_handlers(sci_phy,
1555 SCI_BASE_PHY_STATE_STOPPED);
1556
1557 if (sci_phy->sata_timeout_timer != NULL) { 1231 if (sci_phy->sata_timeout_timer != NULL) {
1558 isci_del_timer(ihost, sci_phy->sata_timeout_timer); 1232 isci_del_timer(ihost, sci_phy->sata_timeout_timer);
1559 1233
@@ -1562,32 +1236,16 @@ static void scic_sds_phy_stopped_state_enter(void *object)
1562 1236
1563 scu_link_layer_stop_protocol_engine(sci_phy); 1237 scu_link_layer_stop_protocol_engine(sci_phy);
1564 1238
1565 if (sci_phy->state_machine.previous_state_id != 1239 if (sci_phy->state_machine.previous_state_id != SCI_BASE_PHY_STATE_INITIAL)
1566 SCI_BASE_PHY_STATE_INITIAL) 1240 scic_sds_controller_link_down(scic_sds_phy_get_controller(sci_phy),
1567 scic_sds_controller_link_down( 1241 scic_sds_phy_get_port(sci_phy),
1568 scic_sds_phy_get_controller(sci_phy), 1242 sci_phy);
1569 scic_sds_phy_get_port(sci_phy),
1570 sci_phy);
1571} 1243}
1572 1244
1573/**
1574 *
1575 * @object: This is the object which is cast to a struct scic_sds_phy object.
1576 *
1577 * This method will perform the actions required by the struct scic_sds_phy on
1578 * entering the SCI_BASE_PHY_STATE_STARTING. - This function sets the state
1579 * handlers for the phy object base state machine starting state. - The SCU
1580 * hardware is requested to start OOB/SN on this protocl engine. - The phy
1581 * starting substate machine is started. - If the previous state was the ready
1582 * state then the struct scic_sds_controller is informed that the phy has gone link
1583 * down. none
1584 */
1585static void scic_sds_phy_starting_state_enter(void *object) 1245static void scic_sds_phy_starting_state_enter(void *object)
1586{ 1246{
1587 struct scic_sds_phy *sci_phy = object; 1247 struct scic_sds_phy *sci_phy = object;
1588 1248
1589 scic_sds_phy_set_base_state_handlers(sci_phy, SCI_BASE_PHY_STATE_STARTING);
1590
1591 scu_link_layer_stop_protocol_engine(sci_phy); 1249 scu_link_layer_stop_protocol_engine(sci_phy);
1592 scu_link_layer_start_oob(sci_phy); 1250 scu_link_layer_start_oob(sci_phy);
1593 1251
@@ -1595,50 +1253,25 @@ static void scic_sds_phy_starting_state_enter(void *object)
1595 sci_phy->protocol = SCIC_SDS_PHY_PROTOCOL_UNKNOWN; 1253 sci_phy->protocol = SCIC_SDS_PHY_PROTOCOL_UNKNOWN;
1596 sci_phy->bcn_received_while_port_unassigned = false; 1254 sci_phy->bcn_received_while_port_unassigned = false;
1597 1255
1598 if (sci_phy->state_machine.previous_state_id 1256 if (sci_phy->state_machine.previous_state_id == SCI_BASE_PHY_STATE_READY)
1599 == SCI_BASE_PHY_STATE_READY) { 1257 scic_sds_controller_link_down(scic_sds_phy_get_controller(sci_phy),
1600 scic_sds_controller_link_down( 1258 scic_sds_phy_get_port(sci_phy),
1601 scic_sds_phy_get_controller(sci_phy), 1259 sci_phy);
1602 scic_sds_phy_get_port(sci_phy),
1603 sci_phy
1604 );
1605 }
1606 1260
1607 sci_base_state_machine_change_state(&sci_phy->state_machine, 1261 sci_base_state_machine_change_state(&sci_phy->state_machine,
1608 SCIC_SDS_PHY_STARTING_SUBSTATE_INITIAL); 1262 SCIC_SDS_PHY_STARTING_SUBSTATE_INITIAL);
1609} 1263}
1610 1264
1611/**
1612 *
1613 * @object: This is the object which is cast to a struct scic_sds_phy object.
1614 *
1615 * This method will perform the actions required by the struct scic_sds_phy on
1616 * entering the SCI_BASE_PHY_STATE_READY. - This function sets the state
1617 * handlers for the phy object base state machine ready state. - The SCU
1618 * hardware protocol engine is resumed. - The struct scic_sds_controller is informed
1619 * that the phy object has gone link up. none
1620 */
1621static void scic_sds_phy_ready_state_enter(void *object) 1265static void scic_sds_phy_ready_state_enter(void *object)
1622{ 1266{
1623 struct scic_sds_phy *sci_phy = object; 1267 struct scic_sds_phy *sci_phy = object;
1624 1268
1625 scic_sds_phy_set_base_state_handlers(sci_phy, SCI_BASE_PHY_STATE_READY); 1269 scic_sds_controller_link_up(scic_sds_phy_get_controller(sci_phy),
1270 scic_sds_phy_get_port(sci_phy),
1271 sci_phy);
1626 1272
1627 scic_sds_controller_link_up(
1628 scic_sds_phy_get_controller(sci_phy),
1629 scic_sds_phy_get_port(sci_phy),
1630 sci_phy
1631 );
1632} 1273}
1633 1274
1634/**
1635 *
1636 * @object: This is the object which is cast to a struct scic_sds_phy object.
1637 *
1638 * This method will perform the actions required by the struct scic_sds_phy on exiting
1639 * the SCI_BASE_PHY_STATE_INITIAL. This function suspends the SCU hardware
1640 * protocol engine represented by this struct scic_sds_phy object. none
1641 */
1642static void scic_sds_phy_ready_state_exit(void *object) 1275static void scic_sds_phy_ready_state_exit(void *object)
1643{ 1276{
1644 struct scic_sds_phy *sci_phy = object; 1277 struct scic_sds_phy *sci_phy = object;
@@ -1646,62 +1279,29 @@ static void scic_sds_phy_ready_state_exit(void *object)
1646 scic_sds_phy_suspend(sci_phy); 1279 scic_sds_phy_suspend(sci_phy);
1647} 1280}
1648 1281
1649/**
1650 *
1651 * @object: This is the object which is cast to a struct scic_sds_phy object.
1652 *
1653 * This method will perform the actions required by the struct scic_sds_phy on
1654 * entering the SCI_BASE_PHY_STATE_RESETTING. - This function sets the state
1655 * handlers for the phy object base state machine resetting state. none
1656 */
1657static void scic_sds_phy_resetting_state_enter(void *object) 1282static void scic_sds_phy_resetting_state_enter(void *object)
1658{ 1283{
1659 struct scic_sds_phy *sci_phy = object; 1284 struct scic_sds_phy *sci_phy = object;
1660 1285
1661 scic_sds_phy_set_base_state_handlers(sci_phy, SCI_BASE_PHY_STATE_RESETTING); 1286 /* The phy is being reset, therefore deactivate it from the port. In
1662 1287 * the resetting state we don't notify the user regarding link up and
1663 /* 1288 * link down notifications
1664 * The phy is being reset, therefore deactivate it from the port. 1289 */
1665 * In the resetting state we don't notify the user regarding
1666 * link up and link down notifications. */
1667 scic_sds_port_deactivate_phy(sci_phy->owning_port, sci_phy, false); 1290 scic_sds_port_deactivate_phy(sci_phy->owning_port, sci_phy, false);
1668 1291
1669 if (sci_phy->protocol == SCIC_SDS_PHY_PROTOCOL_SAS) { 1292 if (sci_phy->protocol == SCIC_SDS_PHY_PROTOCOL_SAS) {
1670 scu_link_layer_tx_hard_reset(sci_phy); 1293 scu_link_layer_tx_hard_reset(sci_phy);
1671 } else { 1294 } else {
1672 /* 1295 /* The SCU does not need to have a discrete reset state so
1673 * The SCU does not need to have a discrete reset state so
1674 * just go back to the starting state. 1296 * just go back to the starting state.
1675 */ 1297 */
1676 sci_base_state_machine_change_state( 1298 sci_base_state_machine_change_state(&sci_phy->state_machine,
1677 &sci_phy->state_machine, 1299 SCI_BASE_PHY_STATE_STARTING);
1678 SCI_BASE_PHY_STATE_STARTING);
1679 } 1300 }
1680} 1301}
1681 1302
1682/**
1683 *
1684 * @object: This is the object which is cast to a struct scic_sds_phy object.
1685 *
1686 * This method will perform the actions required by the struct scic_sds_phy on
1687 * entering the SCI_BASE_PHY_STATE_FINAL. - This function sets the state
1688 * handlers for the phy object base state machine final state. none
1689 */
1690static void scic_sds_phy_final_state_enter(void *object)
1691{
1692 struct scic_sds_phy *sci_phy = object;
1693
1694 scic_sds_phy_set_base_state_handlers(sci_phy, SCI_BASE_PHY_STATE_FINAL);
1695
1696 /* Nothing to do here */
1697}
1698
1699/* --------------------------------------------------------------------------- */
1700
1701static const struct sci_base_state scic_sds_phy_state_table[] = { 1303static const struct sci_base_state scic_sds_phy_state_table[] = {
1702 [SCI_BASE_PHY_STATE_INITIAL] = { 1304 [SCI_BASE_PHY_STATE_INITIAL] = { },
1703 .enter_state = scic_sds_phy_initial_state_enter,
1704 },
1705 [SCI_BASE_PHY_STATE_STOPPED] = { 1305 [SCI_BASE_PHY_STATE_STOPPED] = {
1706 .enter_state = scic_sds_phy_stopped_state_enter, 1306 .enter_state = scic_sds_phy_stopped_state_enter,
1707 }, 1307 },
@@ -1711,15 +1311,9 @@ static const struct sci_base_state scic_sds_phy_state_table[] = {
1711 [SCIC_SDS_PHY_STARTING_SUBSTATE_INITIAL] = { 1311 [SCIC_SDS_PHY_STARTING_SUBSTATE_INITIAL] = {
1712 .enter_state = scic_sds_phy_starting_initial_substate_enter, 1312 .enter_state = scic_sds_phy_starting_initial_substate_enter,
1713 }, 1313 },
1714 [SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_OSSP_EN] = { 1314 [SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_OSSP_EN] = { },
1715 .enter_state = scic_sds_phy_starting_await_ossp_en_substate_enter, 1315 [SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SAS_SPEED_EN] = { },
1716 }, 1316 [SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_IAF_UF] = { },
1717 [SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SAS_SPEED_EN] = {
1718 .enter_state = scic_sds_phy_starting_await_sas_speed_en_substate_enter,
1719 },
1720 [SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_IAF_UF] = {
1721 .enter_state = scic_sds_phy_starting_await_iaf_uf_substate_enter,
1722 },
1723 [SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SAS_POWER] = { 1317 [SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SAS_POWER] = {
1724 .enter_state = scic_sds_phy_starting_await_sas_power_substate_enter, 1318 .enter_state = scic_sds_phy_starting_await_sas_power_substate_enter,
1725 .exit_state = scic_sds_phy_starting_await_sas_power_substate_exit, 1319 .exit_state = scic_sds_phy_starting_await_sas_power_substate_exit,
@@ -1750,9 +1344,7 @@ static const struct sci_base_state scic_sds_phy_state_table[] = {
1750 [SCI_BASE_PHY_STATE_RESETTING] = { 1344 [SCI_BASE_PHY_STATE_RESETTING] = {
1751 .enter_state = scic_sds_phy_resetting_state_enter, 1345 .enter_state = scic_sds_phy_resetting_state_enter,
1752 }, 1346 },
1753 [SCI_BASE_PHY_STATE_FINAL] = { 1347 [SCI_BASE_PHY_STATE_FINAL] = { },
1754 .enter_state = scic_sds_phy_final_state_enter,
1755 },
1756}; 1348};
1757 1349
1758void scic_sds_phy_construct(struct scic_sds_phy *sci_phy, 1350void scic_sds_phy_construct(struct scic_sds_phy *sci_phy,