diff options
author | Adam Gruchala <adam.gruchala@intel.com> | 2011-05-10 19:54:23 -0400 |
---|---|---|
committer | Dan Williams <dan.j.williams@intel.com> | 2011-07-03 07:04:48 -0400 |
commit | 4a33c525f0e94b57602abd1e43644cbf6f5418f4 (patch) | |
tree | 4f42dccac26c36af150322c6b7e152d31efe4aa1 /drivers/scsi/isci | |
parent | 79e2b6b27699c916e3c7cda18a26d47fea6017fb (diff) |
isci: merge phy substates
Merged states and substates into one state machine, as we always
unconditionally transitioned to the substate machine it was straightforward to
enter that substate from the starting state.
Reported-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Adam Gruchala <adam.gruchala@intel.com>
[fixed construction, starting_state_enter, and starting check]
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Diffstat (limited to 'drivers/scsi/isci')
-rw-r--r-- | drivers/scsi/isci/host.c | 24 | ||||
-rw-r--r-- | drivers/scsi/isci/phy.c | 500 | ||||
-rw-r--r-- | drivers/scsi/isci/phy.h | 51 |
3 files changed, 276 insertions, 299 deletions
diff --git a/drivers/scsi/isci/host.c b/drivers/scsi/isci/host.c index 2bb9f1073e73..675eddd3963e 100644 --- a/drivers/scsi/isci/host.c +++ b/drivers/scsi/isci/host.c | |||
@@ -932,6 +932,28 @@ static void scic_sds_controller_phy_timer_start(struct scic_sds_controller *scic | |||
932 | scic->phy_startup_timer_pending = true; | 932 | scic->phy_startup_timer_pending = true; |
933 | } | 933 | } |
934 | 934 | ||
935 | static bool is_phy_starting(struct scic_sds_phy *sci_phy) | ||
936 | { | ||
937 | enum scic_sds_phy_states state; | ||
938 | |||
939 | state = sci_phy->state_machine.current_state_id; | ||
940 | switch (state) { | ||
941 | case SCI_BASE_PHY_STATE_STARTING: | ||
942 | case SCIC_SDS_PHY_STARTING_SUBSTATE_INITIAL: | ||
943 | case SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SAS_SPEED_EN: | ||
944 | case SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_IAF_UF: | ||
945 | case SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SAS_POWER: | ||
946 | case SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_POWER: | ||
947 | case SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_PHY_EN: | ||
948 | case SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_SPEED_EN: | ||
949 | case SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SIG_FIS_UF: | ||
950 | case SCIC_SDS_PHY_STARTING_SUBSTATE_FINAL: | ||
951 | return true; | ||
952 | default: | ||
953 | return false; | ||
954 | } | ||
955 | } | ||
956 | |||
935 | /** | 957 | /** |
936 | * scic_sds_controller_start_next_phy - start phy | 958 | * scic_sds_controller_start_next_phy - start phy |
937 | * @scic: controller | 959 | * @scic: controller |
@@ -975,7 +997,7 @@ static enum sci_status scic_sds_controller_start_next_phy(struct scic_sds_contro | |||
975 | (sci_phy->is_in_link_training == false && | 997 | (sci_phy->is_in_link_training == false && |
976 | state == SCI_BASE_PHY_STATE_STOPPED) || | 998 | state == SCI_BASE_PHY_STATE_STOPPED) || |
977 | (sci_phy->is_in_link_training == true && | 999 | (sci_phy->is_in_link_training == true && |
978 | state == SCI_BASE_PHY_STATE_STARTING)) { | 1000 | is_phy_starting(sci_phy))) { |
979 | is_controller_start_complete = false; | 1001 | is_controller_start_complete = false; |
980 | break; | 1002 | break; |
981 | } | 1003 | } |
diff --git a/drivers/scsi/isci/phy.c b/drivers/scsi/isci/phy.c index 0f64605200ff..e5ae676926f2 100644 --- a/drivers/scsi/isci/phy.c +++ b/drivers/scsi/isci/phy.c | |||
@@ -271,8 +271,6 @@ static void scic_sds_phy_sata_timeout(void *phy) | |||
271 | __func__, | 271 | __func__, |
272 | sci_phy); | 272 | sci_phy); |
273 | 273 | ||
274 | sci_base_state_machine_stop(&sci_phy->starting_substate_machine); | ||
275 | |||
276 | sci_base_state_machine_change_state(&sci_phy->state_machine, | 274 | sci_base_state_machine_change_state(&sci_phy->state_machine, |
277 | SCI_BASE_PHY_STATE_STARTING); | 275 | SCI_BASE_PHY_STATE_STARTING); |
278 | } | 276 | } |
@@ -546,7 +544,7 @@ static void scic_sds_phy_start_sas_link_training( | |||
546 | &sci_phy->link_layer_registers->phy_configuration); | 544 | &sci_phy->link_layer_registers->phy_configuration); |
547 | 545 | ||
548 | sci_base_state_machine_change_state( | 546 | sci_base_state_machine_change_state( |
549 | &sci_phy->starting_substate_machine, | 547 | &sci_phy->state_machine, |
550 | SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SAS_SPEED_EN | 548 | SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SAS_SPEED_EN |
551 | ); | 549 | ); |
552 | 550 | ||
@@ -565,7 +563,7 @@ static void scic_sds_phy_start_sata_link_training( | |||
565 | struct scic_sds_phy *sci_phy) | 563 | struct scic_sds_phy *sci_phy) |
566 | { | 564 | { |
567 | sci_base_state_machine_change_state( | 565 | sci_base_state_machine_change_state( |
568 | &sci_phy->starting_substate_machine, | 566 | &sci_phy->state_machine, |
569 | SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_POWER | 567 | SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_POWER |
570 | ); | 568 | ); |
571 | 569 | ||
@@ -590,16 +588,13 @@ static void scic_sds_phy_complete_link_training( | |||
590 | { | 588 | { |
591 | sci_phy->max_negotiated_speed = max_link_rate; | 589 | sci_phy->max_negotiated_speed = max_link_rate; |
592 | 590 | ||
593 | sci_base_state_machine_change_state(&sci_phy->starting_substate_machine, | 591 | sci_base_state_machine_change_state(&sci_phy->state_machine, |
594 | next_state); | 592 | next_state); |
595 | } | 593 | } |
596 | 594 | ||
597 | static void scic_sds_phy_restart_starting_state( | 595 | static void scic_sds_phy_restart_starting_state( |
598 | struct scic_sds_phy *sci_phy) | 596 | struct scic_sds_phy *sci_phy) |
599 | { | 597 | { |
600 | /* Stop the current substate machine */ | ||
601 | sci_base_state_machine_stop(&sci_phy->starting_substate_machine); | ||
602 | |||
603 | /* Re-enter the base state machine starting state */ | 598 | /* Re-enter the base state machine starting state */ |
604 | sci_base_state_machine_change_state(&sci_phy->state_machine, | 599 | sci_base_state_machine_change_state(&sci_phy->state_machine, |
605 | SCI_BASE_PHY_STATE_STARTING); | 600 | SCI_BASE_PHY_STATE_STARTING); |
@@ -611,8 +606,6 @@ static void scic_sds_phy_restart_starting_state( | |||
611 | static enum sci_status scic_sds_phy_starting_substate_general_stop_handler( | 606 | static enum sci_status scic_sds_phy_starting_substate_general_stop_handler( |
612 | struct scic_sds_phy *phy) | 607 | struct scic_sds_phy *phy) |
613 | { | 608 | { |
614 | sci_base_state_machine_stop(&phy->starting_substate_machine); | ||
615 | |||
616 | sci_base_state_machine_change_state(&phy->state_machine, | 609 | sci_base_state_machine_change_state(&phy->state_machine, |
617 | SCI_BASE_PHY_STATE_STOPPED); | 610 | SCI_BASE_PHY_STATE_STOPPED); |
618 | 611 | ||
@@ -919,7 +912,7 @@ static enum sci_status scic_sds_phy_starting_substate_await_sata_phy_event_handl | |||
919 | sci_phy->protocol = SCIC_SDS_PHY_PROTOCOL_SATA; | 912 | sci_phy->protocol = SCIC_SDS_PHY_PROTOCOL_SATA; |
920 | 913 | ||
921 | /* We have received the SATA PHY notification change state */ | 914 | /* We have received the SATA PHY notification change state */ |
922 | sci_base_state_machine_change_state(&sci_phy->starting_substate_machine, | 915 | sci_base_state_machine_change_state(&sci_phy->state_machine, |
923 | SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_SPEED_EN); | 916 | SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_SPEED_EN); |
924 | break; | 917 | break; |
925 | 918 | ||
@@ -1042,7 +1035,7 @@ static enum sci_status scic_sds_phy_starting_substate_await_sig_fis_event_handle | |||
1042 | switch (scu_get_event_code(event_code)) { | 1035 | switch (scu_get_event_code(event_code)) { |
1043 | case SCU_EVENT_SATA_PHY_DETECTED: | 1036 | case SCU_EVENT_SATA_PHY_DETECTED: |
1044 | /* Backup the state machine */ | 1037 | /* Backup the state machine */ |
1045 | sci_base_state_machine_change_state(&sci_phy->starting_substate_machine, | 1038 | sci_base_state_machine_change_state(&sci_phy->state_machine, |
1046 | SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_SPEED_EN); | 1039 | SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_SPEED_EN); |
1047 | break; | 1040 | break; |
1048 | 1041 | ||
@@ -1118,7 +1111,7 @@ static enum sci_status scic_sds_phy_starting_substate_await_iaf_uf_frame_handler | |||
1118 | state = SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SAS_POWER; | 1111 | state = SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SAS_POWER; |
1119 | } | 1112 | } |
1120 | sci_base_state_machine_change_state( | 1113 | sci_base_state_machine_change_state( |
1121 | &sci_phy->starting_substate_machine, | 1114 | &sci_phy->state_machine, |
1122 | state); | 1115 | state); |
1123 | result = SCI_SUCCESS; | 1116 | result = SCI_SUCCESS; |
1124 | } else | 1117 | } else |
@@ -1177,7 +1170,7 @@ static enum sci_status scic_sds_phy_starting_substate_await_sig_fis_frame_handle | |||
1177 | fis_frame_data); | 1170 | fis_frame_data); |
1178 | 1171 | ||
1179 | /* got IAF we can now go to the await spinup semaphore state */ | 1172 | /* got IAF we can now go to the await spinup semaphore state */ |
1180 | sci_base_state_machine_change_state(&sci_phy->starting_substate_machine, | 1173 | sci_base_state_machine_change_state(&sci_phy->state_machine, |
1181 | SCIC_SDS_PHY_STARTING_SUBSTATE_FINAL); | 1174 | SCIC_SDS_PHY_STARTING_SUBSTATE_FINAL); |
1182 | 1175 | ||
1183 | result = SCI_SUCCESS; | 1176 | result = SCI_SUCCESS; |
@@ -1216,7 +1209,7 @@ static enum sci_status scic_sds_phy_starting_substate_await_sas_power_consume_po | |||
1216 | writel(enable_spinup, &sci_phy->link_layer_registers->notify_enable_spinup_control); | 1209 | writel(enable_spinup, &sci_phy->link_layer_registers->notify_enable_spinup_control); |
1217 | 1210 | ||
1218 | /* Change state to the final state this substate machine has run to completion */ | 1211 | /* Change state to the final state this substate machine has run to completion */ |
1219 | sci_base_state_machine_change_state(&sci_phy->starting_substate_machine, | 1212 | sci_base_state_machine_change_state(&sci_phy->state_machine, |
1220 | SCIC_SDS_PHY_STARTING_SUBSTATE_FINAL); | 1213 | SCIC_SDS_PHY_STARTING_SUBSTATE_FINAL); |
1221 | 1214 | ||
1222 | return SCI_SUCCESS; | 1215 | return SCI_SUCCESS; |
@@ -1248,7 +1241,7 @@ static enum sci_status scic_sds_phy_starting_substate_await_sata_power_consume_p | |||
1248 | &sci_phy->link_layer_registers->phy_configuration); | 1241 | &sci_phy->link_layer_registers->phy_configuration); |
1249 | 1242 | ||
1250 | /* Change state to the final state this substate machine has run to completion */ | 1243 | /* Change state to the final state this substate machine has run to completion */ |
1251 | sci_base_state_machine_change_state(&sci_phy->starting_substate_machine, | 1244 | sci_base_state_machine_change_state(&sci_phy->state_machine, |
1252 | SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_PHY_EN); | 1245 | SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_PHY_EN); |
1253 | 1246 | ||
1254 | return SCI_SUCCESS; | 1247 | return SCI_SUCCESS; |
@@ -1312,9 +1305,156 @@ scic_sds_phy_default_consume_power_handler(struct scic_sds_phy *sci_phy) | |||
1312 | return default_phy_handler(sci_phy, __func__); | 1305 | return default_phy_handler(sci_phy, __func__); |
1313 | } | 1306 | } |
1314 | 1307 | ||
1308 | /* | ||
1309 | * This method takes the struct scic_sds_phy from a stopped state and | ||
1310 | * attempts to start it. - The phy state machine is transitioned to the | ||
1311 | * SCI_BASE_PHY_STATE_STARTING. enum sci_status SCI_SUCCESS | ||
1312 | */ | ||
1313 | static enum sci_status | ||
1314 | scic_sds_phy_stopped_state_start_handler(struct scic_sds_phy *sci_phy) | ||
1315 | { | ||
1316 | struct isci_host *ihost; | ||
1317 | struct scic_sds_controller *scic; | ||
1318 | |||
1319 | scic = scic_sds_phy_get_controller(sci_phy), | ||
1320 | ihost = scic_to_ihost(scic); | ||
1315 | 1321 | ||
1322 | /* Create the SIGNATURE FIS Timeout timer for this phy */ | ||
1323 | sci_phy->sata_timeout_timer = isci_timer_create(ihost, sci_phy, | ||
1324 | scic_sds_phy_sata_timeout); | ||
1325 | |||
1326 | if (sci_phy->sata_timeout_timer) | ||
1327 | sci_base_state_machine_change_state(&sci_phy->state_machine, | ||
1328 | SCI_BASE_PHY_STATE_STARTING); | ||
1329 | |||
1330 | return SCI_SUCCESS; | ||
1331 | } | ||
1332 | |||
1333 | static enum sci_status | ||
1334 | scic_sds_phy_stopped_state_destroy_handler(struct scic_sds_phy *sci_phy) | ||
1335 | { | ||
1336 | return SCI_SUCCESS; | ||
1337 | } | ||
1338 | |||
1339 | static enum sci_status | ||
1340 | scic_sds_phy_ready_state_stop_handler(struct scic_sds_phy *sci_phy) | ||
1341 | { | ||
1342 | sci_base_state_machine_change_state(&sci_phy->state_machine, | ||
1343 | SCI_BASE_PHY_STATE_STOPPED); | ||
1344 | |||
1345 | return SCI_SUCCESS; | ||
1346 | } | ||
1347 | |||
1348 | static enum sci_status | ||
1349 | scic_sds_phy_ready_state_reset_handler(struct scic_sds_phy *sci_phy) | ||
1350 | { | ||
1351 | sci_base_state_machine_change_state(&sci_phy->state_machine, | ||
1352 | SCI_BASE_PHY_STATE_RESETTING); | ||
1353 | |||
1354 | return SCI_SUCCESS; | ||
1355 | } | ||
1316 | 1356 | ||
1317 | static const struct scic_sds_phy_state_handler scic_sds_phy_starting_substate_handler_table[] = { | 1357 | /** |
1358 | * scic_sds_phy_ready_state_event_handler - | ||
1359 | * @phy: This is the struct scic_sds_phy object which has received the event. | ||
1360 | * | ||
1361 | * This method request the struct scic_sds_phy handle the received event. The only | ||
1362 | * event that we are interested in while in the ready state is the link failure | ||
1363 | * event. - decoded event is a link failure - transition the struct scic_sds_phy back | ||
1364 | * to the SCI_BASE_PHY_STATE_STARTING state. - any other event received will | ||
1365 | * report a warning message enum sci_status SCI_SUCCESS if the event received is a | ||
1366 | * link failure SCI_FAILURE_INVALID_STATE for any other event received. | ||
1367 | */ | ||
1368 | static enum sci_status scic_sds_phy_ready_state_event_handler(struct scic_sds_phy *sci_phy, | ||
1369 | u32 event_code) | ||
1370 | { | ||
1371 | enum sci_status result = SCI_FAILURE; | ||
1372 | |||
1373 | switch (scu_get_event_code(event_code)) { | ||
1374 | case SCU_EVENT_LINK_FAILURE: | ||
1375 | /* Link failure change state back to the starting state */ | ||
1376 | sci_base_state_machine_change_state(&sci_phy->state_machine, | ||
1377 | SCI_BASE_PHY_STATE_STARTING); | ||
1378 | result = SCI_SUCCESS; | ||
1379 | break; | ||
1380 | |||
1381 | case SCU_EVENT_BROADCAST_CHANGE: | ||
1382 | /* Broadcast change received. Notify the port. */ | ||
1383 | if (scic_sds_phy_get_port(sci_phy) != NULL) | ||
1384 | scic_sds_port_broadcast_change_received(sci_phy->owning_port, sci_phy); | ||
1385 | else | ||
1386 | sci_phy->bcn_received_while_port_unassigned = true; | ||
1387 | break; | ||
1388 | |||
1389 | default: | ||
1390 | dev_warn(sciphy_to_dev(sci_phy), | ||
1391 | "%sP SCIC PHY 0x%p ready state machine received " | ||
1392 | "unexpected event_code %x\n", | ||
1393 | __func__, sci_phy, event_code); | ||
1394 | |||
1395 | result = SCI_FAILURE_INVALID_STATE; | ||
1396 | break; | ||
1397 | } | ||
1398 | |||
1399 | return result; | ||
1400 | } | ||
1401 | |||
1402 | static enum sci_status scic_sds_phy_resetting_state_event_handler(struct scic_sds_phy *sci_phy, | ||
1403 | u32 event_code) | ||
1404 | { | ||
1405 | enum sci_status result = SCI_FAILURE; | ||
1406 | |||
1407 | switch (scu_get_event_code(event_code)) { | ||
1408 | case SCU_EVENT_HARD_RESET_TRANSMITTED: | ||
1409 | /* Link failure change state back to the starting state */ | ||
1410 | sci_base_state_machine_change_state(&sci_phy->state_machine, | ||
1411 | SCI_BASE_PHY_STATE_STARTING); | ||
1412 | result = SCI_SUCCESS; | ||
1413 | break; | ||
1414 | |||
1415 | default: | ||
1416 | dev_warn(sciphy_to_dev(sci_phy), | ||
1417 | "%s: SCIC PHY 0x%p resetting state machine received " | ||
1418 | "unexpected event_code %x\n", | ||
1419 | __func__, sci_phy, event_code); | ||
1420 | |||
1421 | result = SCI_FAILURE_INVALID_STATE; | ||
1422 | break; | ||
1423 | } | ||
1424 | |||
1425 | return result; | ||
1426 | } | ||
1427 | |||
1428 | /* --------------------------------------------------------------------------- */ | ||
1429 | |||
1430 | static const struct scic_sds_phy_state_handler scic_sds_phy_state_handler_table[] = { | ||
1431 | [SCI_BASE_PHY_STATE_INITIAL] = { | ||
1432 | .start_handler = scic_sds_phy_default_start_handler, | ||
1433 | .stop_handler = scic_sds_phy_default_stop_handler, | ||
1434 | .reset_handler = scic_sds_phy_default_reset_handler, | ||
1435 | .destruct_handler = scic_sds_phy_default_destroy_handler, | ||
1436 | .frame_handler = scic_sds_phy_default_frame_handler, | ||
1437 | .event_handler = scic_sds_phy_default_event_handler, | ||
1438 | .consume_power_handler = scic_sds_phy_default_consume_power_handler | ||
1439 | }, | ||
1440 | [SCI_BASE_PHY_STATE_STOPPED] = { | ||
1441 | .start_handler = scic_sds_phy_stopped_state_start_handler, | ||
1442 | .stop_handler = scic_sds_phy_default_stop_handler, | ||
1443 | .reset_handler = scic_sds_phy_default_reset_handler, | ||
1444 | .destruct_handler = scic_sds_phy_stopped_state_destroy_handler, | ||
1445 | .frame_handler = scic_sds_phy_default_frame_handler, | ||
1446 | .event_handler = scic_sds_phy_default_event_handler, | ||
1447 | .consume_power_handler = scic_sds_phy_default_consume_power_handler | ||
1448 | }, | ||
1449 | [SCI_BASE_PHY_STATE_STARTING] = { | ||
1450 | .start_handler = scic_sds_phy_default_start_handler, | ||
1451 | .stop_handler = scic_sds_phy_default_stop_handler, | ||
1452 | .reset_handler = scic_sds_phy_default_reset_handler, | ||
1453 | .destruct_handler = scic_sds_phy_default_destroy_handler, | ||
1454 | .frame_handler = scic_sds_phy_default_frame_handler, | ||
1455 | .event_handler = scic_sds_phy_default_event_handler, | ||
1456 | .consume_power_handler = scic_sds_phy_default_consume_power_handler | ||
1457 | }, | ||
1318 | [SCIC_SDS_PHY_STARTING_SUBSTATE_INITIAL] = { | 1458 | [SCIC_SDS_PHY_STARTING_SUBSTATE_INITIAL] = { |
1319 | .start_handler = scic_sds_phy_default_start_handler, | 1459 | .start_handler = scic_sds_phy_default_start_handler, |
1320 | .stop_handler = scic_sds_phy_starting_substate_general_stop_handler, | 1460 | .stop_handler = scic_sds_phy_starting_substate_general_stop_handler, |
@@ -1404,20 +1544,36 @@ static const struct scic_sds_phy_state_handler scic_sds_phy_starting_substate_ha | |||
1404 | .frame_handler = scic_sds_phy_default_frame_handler, | 1544 | .frame_handler = scic_sds_phy_default_frame_handler, |
1405 | .event_handler = scic_sds_phy_default_event_handler, | 1545 | .event_handler = scic_sds_phy_default_event_handler, |
1406 | .consume_power_handler = scic_sds_phy_default_consume_power_handler | 1546 | .consume_power_handler = scic_sds_phy_default_consume_power_handler |
1547 | }, | ||
1548 | [SCI_BASE_PHY_STATE_READY] = { | ||
1549 | .start_handler = scic_sds_phy_default_start_handler, | ||
1550 | .stop_handler = scic_sds_phy_ready_state_stop_handler, | ||
1551 | .reset_handler = scic_sds_phy_ready_state_reset_handler, | ||
1552 | .destruct_handler = scic_sds_phy_default_destroy_handler, | ||
1553 | .frame_handler = scic_sds_phy_default_frame_handler, | ||
1554 | .event_handler = scic_sds_phy_ready_state_event_handler, | ||
1555 | .consume_power_handler = scic_sds_phy_default_consume_power_handler | ||
1556 | }, | ||
1557 | [SCI_BASE_PHY_STATE_RESETTING] = { | ||
1558 | .start_handler = scic_sds_phy_default_start_handler, | ||
1559 | .stop_handler = scic_sds_phy_default_stop_handler, | ||
1560 | .reset_handler = scic_sds_phy_default_reset_handler, | ||
1561 | .destruct_handler = scic_sds_phy_default_destroy_handler, | ||
1562 | .frame_handler = scic_sds_phy_default_frame_handler, | ||
1563 | .event_handler = scic_sds_phy_resetting_state_event_handler, | ||
1564 | .consume_power_handler = scic_sds_phy_default_consume_power_handler | ||
1565 | }, | ||
1566 | [SCI_BASE_PHY_STATE_FINAL] = { | ||
1567 | .start_handler = scic_sds_phy_default_start_handler, | ||
1568 | .stop_handler = scic_sds_phy_default_stop_handler, | ||
1569 | .reset_handler = scic_sds_phy_default_reset_handler, | ||
1570 | .destruct_handler = scic_sds_phy_default_destroy_handler, | ||
1571 | .frame_handler = scic_sds_phy_default_frame_handler, | ||
1572 | .event_handler = scic_sds_phy_default_event_handler, | ||
1573 | .consume_power_handler = scic_sds_phy_default_consume_power_handler | ||
1407 | } | 1574 | } |
1408 | }; | 1575 | }; |
1409 | 1576 | ||
1410 | /** | ||
1411 | * scic_sds_phy_set_starting_substate_handlers() - | ||
1412 | * | ||
1413 | * This macro sets the starting substate handlers by state_id | ||
1414 | */ | ||
1415 | #define scic_sds_phy_set_starting_substate_handlers(phy, state_id) \ | ||
1416 | scic_sds_phy_set_state_handlers(\ | ||
1417 | (phy), \ | ||
1418 | &scic_sds_phy_starting_substate_handler_table[(state_id)] \ | ||
1419 | ) | ||
1420 | |||
1421 | /* | 1577 | /* |
1422 | * **************************************************************************** | 1578 | * **************************************************************************** |
1423 | * * PHY STARTING SUBSTATE METHODS | 1579 | * * PHY STARTING SUBSTATE METHODS |
@@ -1436,11 +1592,11 @@ static void scic_sds_phy_starting_initial_substate_enter(void *object) | |||
1436 | { | 1592 | { |
1437 | struct scic_sds_phy *sci_phy = object; | 1593 | struct scic_sds_phy *sci_phy = object; |
1438 | 1594 | ||
1439 | scic_sds_phy_set_starting_substate_handlers( | 1595 | scic_sds_phy_set_base_state_handlers( |
1440 | sci_phy, SCIC_SDS_PHY_STARTING_SUBSTATE_INITIAL); | 1596 | sci_phy, SCIC_SDS_PHY_STARTING_SUBSTATE_INITIAL); |
1441 | 1597 | ||
1442 | /* This is just an temporary state go off to the starting state */ | 1598 | /* This is just an temporary state go off to the starting state */ |
1443 | sci_base_state_machine_change_state(&sci_phy->starting_substate_machine, | 1599 | sci_base_state_machine_change_state(&sci_phy->state_machine, |
1444 | SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_OSSP_EN); | 1600 | SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_OSSP_EN); |
1445 | } | 1601 | } |
1446 | 1602 | ||
@@ -1456,7 +1612,7 @@ static void scic_sds_phy_starting_await_ossp_en_substate_enter(void *object) | |||
1456 | { | 1612 | { |
1457 | struct scic_sds_phy *sci_phy = object; | 1613 | struct scic_sds_phy *sci_phy = object; |
1458 | 1614 | ||
1459 | scic_sds_phy_set_starting_substate_handlers( | 1615 | scic_sds_phy_set_base_state_handlers( |
1460 | sci_phy, SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_OSSP_EN | 1616 | sci_phy, SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_OSSP_EN |
1461 | ); | 1617 | ); |
1462 | } | 1618 | } |
@@ -1474,7 +1630,7 @@ static void scic_sds_phy_starting_await_sas_speed_en_substate_enter( | |||
1474 | { | 1630 | { |
1475 | struct scic_sds_phy *sci_phy = object; | 1631 | struct scic_sds_phy *sci_phy = object; |
1476 | 1632 | ||
1477 | scic_sds_phy_set_starting_substate_handlers( | 1633 | scic_sds_phy_set_base_state_handlers( |
1478 | sci_phy, SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SAS_SPEED_EN | 1634 | sci_phy, SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SAS_SPEED_EN |
1479 | ); | 1635 | ); |
1480 | } | 1636 | } |
@@ -1491,7 +1647,7 @@ static void scic_sds_phy_starting_await_iaf_uf_substate_enter(void *object) | |||
1491 | { | 1647 | { |
1492 | struct scic_sds_phy *sci_phy = object; | 1648 | struct scic_sds_phy *sci_phy = object; |
1493 | 1649 | ||
1494 | scic_sds_phy_set_starting_substate_handlers( | 1650 | scic_sds_phy_set_base_state_handlers( |
1495 | sci_phy, SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_IAF_UF | 1651 | sci_phy, SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_IAF_UF |
1496 | ); | 1652 | ); |
1497 | } | 1653 | } |
@@ -1509,7 +1665,7 @@ static void scic_sds_phy_starting_await_sas_power_substate_enter(void *object) | |||
1509 | { | 1665 | { |
1510 | struct scic_sds_phy *sci_phy = object; | 1666 | struct scic_sds_phy *sci_phy = object; |
1511 | 1667 | ||
1512 | scic_sds_phy_set_starting_substate_handlers( | 1668 | scic_sds_phy_set_base_state_handlers( |
1513 | sci_phy, SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SAS_POWER | 1669 | sci_phy, SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SAS_POWER |
1514 | ); | 1670 | ); |
1515 | 1671 | ||
@@ -1549,7 +1705,7 @@ static void scic_sds_phy_starting_await_sata_power_substate_enter(void *object) | |||
1549 | { | 1705 | { |
1550 | struct scic_sds_phy *sci_phy = object; | 1706 | struct scic_sds_phy *sci_phy = object; |
1551 | 1707 | ||
1552 | scic_sds_phy_set_starting_substate_handlers( | 1708 | scic_sds_phy_set_base_state_handlers( |
1553 | sci_phy, SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_POWER | 1709 | sci_phy, SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_POWER |
1554 | ); | 1710 | ); |
1555 | 1711 | ||
@@ -1589,7 +1745,7 @@ static void scic_sds_phy_starting_await_sata_phy_substate_enter(void *object) | |||
1589 | { | 1745 | { |
1590 | struct scic_sds_phy *sci_phy = object; | 1746 | struct scic_sds_phy *sci_phy = object; |
1591 | 1747 | ||
1592 | scic_sds_phy_set_starting_substate_handlers( | 1748 | scic_sds_phy_set_base_state_handlers( |
1593 | sci_phy, | 1749 | sci_phy, |
1594 | SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_PHY_EN); | 1750 | SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_PHY_EN); |
1595 | 1751 | ||
@@ -1626,7 +1782,7 @@ static void scic_sds_phy_starting_await_sata_speed_substate_enter(void *object) | |||
1626 | { | 1782 | { |
1627 | struct scic_sds_phy *sci_phy = object; | 1783 | struct scic_sds_phy *sci_phy = object; |
1628 | 1784 | ||
1629 | scic_sds_phy_set_starting_substate_handlers( | 1785 | scic_sds_phy_set_base_state_handlers( |
1630 | sci_phy, | 1786 | sci_phy, |
1631 | SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_SPEED_EN); | 1787 | SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_SPEED_EN); |
1632 | 1788 | ||
@@ -1666,7 +1822,7 @@ static void scic_sds_phy_starting_await_sig_fis_uf_substate_enter(void *object) | |||
1666 | bool continue_to_ready_state; | 1822 | bool continue_to_ready_state; |
1667 | struct scic_sds_phy *sci_phy = object; | 1823 | struct scic_sds_phy *sci_phy = object; |
1668 | 1824 | ||
1669 | scic_sds_phy_set_starting_substate_handlers( | 1825 | scic_sds_phy_set_base_state_handlers( |
1670 | sci_phy, | 1826 | sci_phy, |
1671 | SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SIG_FIS_UF); | 1827 | SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SIG_FIS_UF); |
1672 | 1828 | ||
@@ -1719,7 +1875,7 @@ static void scic_sds_phy_starting_final_substate_enter(void *object) | |||
1719 | { | 1875 | { |
1720 | struct scic_sds_phy *sci_phy = object; | 1876 | struct scic_sds_phy *sci_phy = object; |
1721 | 1877 | ||
1722 | scic_sds_phy_set_starting_substate_handlers(sci_phy, | 1878 | scic_sds_phy_set_base_state_handlers(sci_phy, |
1723 | SCIC_SDS_PHY_STARTING_SUBSTATE_FINAL); | 1879 | SCIC_SDS_PHY_STARTING_SUBSTATE_FINAL); |
1724 | 1880 | ||
1725 | /* State machine has run to completion so exit out and change | 1881 | /* State machine has run to completion so exit out and change |
@@ -1729,225 +1885,6 @@ static void scic_sds_phy_starting_final_substate_enter(void *object) | |||
1729 | SCI_BASE_PHY_STATE_READY); | 1885 | SCI_BASE_PHY_STATE_READY); |
1730 | } | 1886 | } |
1731 | 1887 | ||
1732 | /* --------------------------------------------------------------------------- */ | ||
1733 | |||
1734 | static const struct sci_base_state scic_sds_phy_starting_substates[] = { | ||
1735 | [SCIC_SDS_PHY_STARTING_SUBSTATE_INITIAL] = { | ||
1736 | .enter_state = scic_sds_phy_starting_initial_substate_enter, | ||
1737 | }, | ||
1738 | [SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_OSSP_EN] = { | ||
1739 | .enter_state = scic_sds_phy_starting_await_ossp_en_substate_enter, | ||
1740 | }, | ||
1741 | [SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SAS_SPEED_EN] = { | ||
1742 | .enter_state = scic_sds_phy_starting_await_sas_speed_en_substate_enter, | ||
1743 | }, | ||
1744 | [SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_IAF_UF] = { | ||
1745 | .enter_state = scic_sds_phy_starting_await_iaf_uf_substate_enter, | ||
1746 | }, | ||
1747 | [SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SAS_POWER] = { | ||
1748 | .enter_state = scic_sds_phy_starting_await_sas_power_substate_enter, | ||
1749 | .exit_state = scic_sds_phy_starting_await_sas_power_substate_exit, | ||
1750 | }, | ||
1751 | [SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_POWER] = { | ||
1752 | .enter_state = scic_sds_phy_starting_await_sata_power_substate_enter, | ||
1753 | .exit_state = scic_sds_phy_starting_await_sata_power_substate_exit | ||
1754 | }, | ||
1755 | [SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_PHY_EN] = { | ||
1756 | .enter_state = scic_sds_phy_starting_await_sata_phy_substate_enter, | ||
1757 | .exit_state = scic_sds_phy_starting_await_sata_phy_substate_exit | ||
1758 | }, | ||
1759 | [SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_SPEED_EN] = { | ||
1760 | .enter_state = scic_sds_phy_starting_await_sata_speed_substate_enter, | ||
1761 | .exit_state = scic_sds_phy_starting_await_sata_speed_substate_exit | ||
1762 | }, | ||
1763 | [SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SIG_FIS_UF] = { | ||
1764 | .enter_state = scic_sds_phy_starting_await_sig_fis_uf_substate_enter, | ||
1765 | .exit_state = scic_sds_phy_starting_await_sig_fis_uf_substate_exit | ||
1766 | }, | ||
1767 | [SCIC_SDS_PHY_STARTING_SUBSTATE_FINAL] = { | ||
1768 | .enter_state = scic_sds_phy_starting_final_substate_enter, | ||
1769 | } | ||
1770 | }; | ||
1771 | |||
1772 | /* | ||
1773 | * This method takes the struct scic_sds_phy from a stopped state and | ||
1774 | * attempts to start it. - The phy state machine is transitioned to the | ||
1775 | * SCI_BASE_PHY_STATE_STARTING. enum sci_status SCI_SUCCESS | ||
1776 | */ | ||
1777 | static enum sci_status | ||
1778 | scic_sds_phy_stopped_state_start_handler(struct scic_sds_phy *sci_phy) | ||
1779 | { | ||
1780 | struct isci_host *ihost; | ||
1781 | struct scic_sds_controller *scic; | ||
1782 | |||
1783 | scic = scic_sds_phy_get_controller(sci_phy), | ||
1784 | ihost = scic_to_ihost(scic); | ||
1785 | |||
1786 | /* Create the SIGNATURE FIS Timeout timer for this phy */ | ||
1787 | sci_phy->sata_timeout_timer = isci_timer_create(ihost, sci_phy, | ||
1788 | scic_sds_phy_sata_timeout); | ||
1789 | |||
1790 | if (sci_phy->sata_timeout_timer) | ||
1791 | sci_base_state_machine_change_state(&sci_phy->state_machine, | ||
1792 | SCI_BASE_PHY_STATE_STARTING); | ||
1793 | |||
1794 | return SCI_SUCCESS; | ||
1795 | } | ||
1796 | |||
1797 | static enum sci_status | ||
1798 | scic_sds_phy_stopped_state_destroy_handler(struct scic_sds_phy *sci_phy) | ||
1799 | { | ||
1800 | return SCI_SUCCESS; | ||
1801 | } | ||
1802 | |||
1803 | static enum sci_status | ||
1804 | scic_sds_phy_ready_state_stop_handler(struct scic_sds_phy *sci_phy) | ||
1805 | { | ||
1806 | sci_base_state_machine_change_state(&sci_phy->state_machine, | ||
1807 | SCI_BASE_PHY_STATE_STOPPED); | ||
1808 | |||
1809 | return SCI_SUCCESS; | ||
1810 | } | ||
1811 | |||
1812 | static enum sci_status | ||
1813 | scic_sds_phy_ready_state_reset_handler(struct scic_sds_phy *sci_phy) | ||
1814 | { | ||
1815 | sci_base_state_machine_change_state(&sci_phy->state_machine, | ||
1816 | SCI_BASE_PHY_STATE_RESETTING); | ||
1817 | |||
1818 | return SCI_SUCCESS; | ||
1819 | } | ||
1820 | |||
1821 | /** | ||
1822 | * scic_sds_phy_ready_state_event_handler - | ||
1823 | * @phy: This is the struct scic_sds_phy object which has received the event. | ||
1824 | * | ||
1825 | * This method request the struct scic_sds_phy handle the received event. The only | ||
1826 | * event that we are interested in while in the ready state is the link failure | ||
1827 | * event. - decoded event is a link failure - transition the struct scic_sds_phy back | ||
1828 | * to the SCI_BASE_PHY_STATE_STARTING state. - any other event received will | ||
1829 | * report a warning message enum sci_status SCI_SUCCESS if the event received is a | ||
1830 | * link failure SCI_FAILURE_INVALID_STATE for any other event received. | ||
1831 | */ | ||
1832 | static enum sci_status scic_sds_phy_ready_state_event_handler(struct scic_sds_phy *sci_phy, | ||
1833 | u32 event_code) | ||
1834 | { | ||
1835 | enum sci_status result = SCI_FAILURE; | ||
1836 | |||
1837 | switch (scu_get_event_code(event_code)) { | ||
1838 | case SCU_EVENT_LINK_FAILURE: | ||
1839 | /* Link failure change state back to the starting state */ | ||
1840 | sci_base_state_machine_change_state(&sci_phy->state_machine, | ||
1841 | SCI_BASE_PHY_STATE_STARTING); | ||
1842 | result = SCI_SUCCESS; | ||
1843 | break; | ||
1844 | |||
1845 | case SCU_EVENT_BROADCAST_CHANGE: | ||
1846 | /* Broadcast change received. Notify the port. */ | ||
1847 | if (scic_sds_phy_get_port(sci_phy) != NULL) | ||
1848 | scic_sds_port_broadcast_change_received(sci_phy->owning_port, sci_phy); | ||
1849 | else | ||
1850 | sci_phy->bcn_received_while_port_unassigned = true; | ||
1851 | break; | ||
1852 | |||
1853 | default: | ||
1854 | dev_warn(sciphy_to_dev(sci_phy), | ||
1855 | "%sP SCIC PHY 0x%p ready state machine received " | ||
1856 | "unexpected event_code %x\n", | ||
1857 | __func__, sci_phy, event_code); | ||
1858 | |||
1859 | result = SCI_FAILURE_INVALID_STATE; | ||
1860 | break; | ||
1861 | } | ||
1862 | |||
1863 | return result; | ||
1864 | } | ||
1865 | |||
1866 | static enum sci_status scic_sds_phy_resetting_state_event_handler(struct scic_sds_phy *sci_phy, | ||
1867 | u32 event_code) | ||
1868 | { | ||
1869 | enum sci_status result = SCI_FAILURE; | ||
1870 | |||
1871 | switch (scu_get_event_code(event_code)) { | ||
1872 | case SCU_EVENT_HARD_RESET_TRANSMITTED: | ||
1873 | /* Link failure change state back to the starting state */ | ||
1874 | sci_base_state_machine_change_state(&sci_phy->state_machine, | ||
1875 | SCI_BASE_PHY_STATE_STARTING); | ||
1876 | result = SCI_SUCCESS; | ||
1877 | break; | ||
1878 | |||
1879 | default: | ||
1880 | dev_warn(sciphy_to_dev(sci_phy), | ||
1881 | "%s: SCIC PHY 0x%p resetting state machine received " | ||
1882 | "unexpected event_code %x\n", | ||
1883 | __func__, sci_phy, event_code); | ||
1884 | |||
1885 | result = SCI_FAILURE_INVALID_STATE; | ||
1886 | break; | ||
1887 | } | ||
1888 | |||
1889 | return result; | ||
1890 | } | ||
1891 | |||
1892 | /* --------------------------------------------------------------------------- */ | ||
1893 | |||
1894 | static const struct scic_sds_phy_state_handler scic_sds_phy_state_handler_table[] = { | ||
1895 | [SCI_BASE_PHY_STATE_INITIAL] = { | ||
1896 | .start_handler = scic_sds_phy_default_start_handler, | ||
1897 | .stop_handler = scic_sds_phy_default_stop_handler, | ||
1898 | .reset_handler = scic_sds_phy_default_reset_handler, | ||
1899 | .destruct_handler = scic_sds_phy_default_destroy_handler, | ||
1900 | .frame_handler = scic_sds_phy_default_frame_handler, | ||
1901 | .event_handler = scic_sds_phy_default_event_handler, | ||
1902 | .consume_power_handler = scic_sds_phy_default_consume_power_handler | ||
1903 | }, | ||
1904 | [SCI_BASE_PHY_STATE_STOPPED] = { | ||
1905 | .start_handler = scic_sds_phy_stopped_state_start_handler, | ||
1906 | .stop_handler = scic_sds_phy_default_stop_handler, | ||
1907 | .reset_handler = scic_sds_phy_default_reset_handler, | ||
1908 | .destruct_handler = scic_sds_phy_stopped_state_destroy_handler, | ||
1909 | .frame_handler = scic_sds_phy_default_frame_handler, | ||
1910 | .event_handler = scic_sds_phy_default_event_handler, | ||
1911 | .consume_power_handler = scic_sds_phy_default_consume_power_handler | ||
1912 | }, | ||
1913 | [SCI_BASE_PHY_STATE_STARTING] = { | ||
1914 | .start_handler = scic_sds_phy_default_start_handler, | ||
1915 | .stop_handler = scic_sds_phy_default_stop_handler, | ||
1916 | .reset_handler = scic_sds_phy_default_reset_handler, | ||
1917 | .destruct_handler = scic_sds_phy_default_destroy_handler, | ||
1918 | .frame_handler = scic_sds_phy_default_frame_handler, | ||
1919 | .event_handler = scic_sds_phy_default_event_handler, | ||
1920 | .consume_power_handler = scic_sds_phy_default_consume_power_handler | ||
1921 | }, | ||
1922 | [SCI_BASE_PHY_STATE_READY] = { | ||
1923 | .start_handler = scic_sds_phy_default_start_handler, | ||
1924 | .stop_handler = scic_sds_phy_ready_state_stop_handler, | ||
1925 | .reset_handler = scic_sds_phy_ready_state_reset_handler, | ||
1926 | .destruct_handler = scic_sds_phy_default_destroy_handler, | ||
1927 | .frame_handler = scic_sds_phy_default_frame_handler, | ||
1928 | .event_handler = scic_sds_phy_ready_state_event_handler, | ||
1929 | .consume_power_handler = scic_sds_phy_default_consume_power_handler | ||
1930 | }, | ||
1931 | [SCI_BASE_PHY_STATE_RESETTING] = { | ||
1932 | .start_handler = scic_sds_phy_default_start_handler, | ||
1933 | .stop_handler = scic_sds_phy_default_stop_handler, | ||
1934 | .reset_handler = scic_sds_phy_default_reset_handler, | ||
1935 | .destruct_handler = scic_sds_phy_default_destroy_handler, | ||
1936 | .frame_handler = scic_sds_phy_default_frame_handler, | ||
1937 | .event_handler = scic_sds_phy_resetting_state_event_handler, | ||
1938 | .consume_power_handler = scic_sds_phy_default_consume_power_handler | ||
1939 | }, | ||
1940 | [SCI_BASE_PHY_STATE_FINAL] = { | ||
1941 | .start_handler = scic_sds_phy_default_start_handler, | ||
1942 | .stop_handler = scic_sds_phy_default_stop_handler, | ||
1943 | .reset_handler = scic_sds_phy_default_reset_handler, | ||
1944 | .destruct_handler = scic_sds_phy_default_destroy_handler, | ||
1945 | .frame_handler = scic_sds_phy_default_frame_handler, | ||
1946 | .event_handler = scic_sds_phy_default_event_handler, | ||
1947 | .consume_power_handler = scic_sds_phy_default_consume_power_handler | ||
1948 | } | ||
1949 | }; | ||
1950 | |||
1951 | /* | 1888 | /* |
1952 | * **************************************************************************** | 1889 | * **************************************************************************** |
1953 | * * PHY STATE PRIVATE METHODS | 1890 | * * PHY STATE PRIVATE METHODS |
@@ -2118,9 +2055,6 @@ static void scic_sds_phy_starting_state_enter(void *object) | |||
2118 | sci_phy->protocol = SCIC_SDS_PHY_PROTOCOL_UNKNOWN; | 2055 | sci_phy->protocol = SCIC_SDS_PHY_PROTOCOL_UNKNOWN; |
2119 | sci_phy->bcn_received_while_port_unassigned = false; | 2056 | sci_phy->bcn_received_while_port_unassigned = false; |
2120 | 2057 | ||
2121 | /* Change over to the starting substate machine to continue */ | ||
2122 | sci_base_state_machine_start(&sci_phy->starting_substate_machine); | ||
2123 | |||
2124 | if (sci_phy->state_machine.previous_state_id | 2058 | if (sci_phy->state_machine.previous_state_id |
2125 | == SCI_BASE_PHY_STATE_READY) { | 2059 | == SCI_BASE_PHY_STATE_READY) { |
2126 | scic_sds_controller_link_down( | 2060 | scic_sds_controller_link_down( |
@@ -2129,6 +2063,9 @@ static void scic_sds_phy_starting_state_enter(void *object) | |||
2129 | sci_phy | 2063 | sci_phy |
2130 | ); | 2064 | ); |
2131 | } | 2065 | } |
2066 | |||
2067 | sci_base_state_machine_change_state(&sci_phy->state_machine, | ||
2068 | SCIC_SDS_PHY_STARTING_SUBSTATE_INITIAL); | ||
2132 | } | 2069 | } |
2133 | 2070 | ||
2134 | /** | 2071 | /** |
@@ -2231,6 +2168,41 @@ static const struct sci_base_state scic_sds_phy_state_table[] = { | |||
2231 | [SCI_BASE_PHY_STATE_STARTING] = { | 2168 | [SCI_BASE_PHY_STATE_STARTING] = { |
2232 | .enter_state = scic_sds_phy_starting_state_enter, | 2169 | .enter_state = scic_sds_phy_starting_state_enter, |
2233 | }, | 2170 | }, |
2171 | [SCIC_SDS_PHY_STARTING_SUBSTATE_INITIAL] = { | ||
2172 | .enter_state = scic_sds_phy_starting_initial_substate_enter, | ||
2173 | }, | ||
2174 | [SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_OSSP_EN] = { | ||
2175 | .enter_state = scic_sds_phy_starting_await_ossp_en_substate_enter, | ||
2176 | }, | ||
2177 | [SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SAS_SPEED_EN] = { | ||
2178 | .enter_state = scic_sds_phy_starting_await_sas_speed_en_substate_enter, | ||
2179 | }, | ||
2180 | [SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_IAF_UF] = { | ||
2181 | .enter_state = scic_sds_phy_starting_await_iaf_uf_substate_enter, | ||
2182 | }, | ||
2183 | [SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SAS_POWER] = { | ||
2184 | .enter_state = scic_sds_phy_starting_await_sas_power_substate_enter, | ||
2185 | .exit_state = scic_sds_phy_starting_await_sas_power_substate_exit, | ||
2186 | }, | ||
2187 | [SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_POWER] = { | ||
2188 | .enter_state = scic_sds_phy_starting_await_sata_power_substate_enter, | ||
2189 | .exit_state = scic_sds_phy_starting_await_sata_power_substate_exit | ||
2190 | }, | ||
2191 | [SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_PHY_EN] = { | ||
2192 | .enter_state = scic_sds_phy_starting_await_sata_phy_substate_enter, | ||
2193 | .exit_state = scic_sds_phy_starting_await_sata_phy_substate_exit | ||
2194 | }, | ||
2195 | [SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_SPEED_EN] = { | ||
2196 | .enter_state = scic_sds_phy_starting_await_sata_speed_substate_enter, | ||
2197 | .exit_state = scic_sds_phy_starting_await_sata_speed_substate_exit | ||
2198 | }, | ||
2199 | [SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SIG_FIS_UF] = { | ||
2200 | .enter_state = scic_sds_phy_starting_await_sig_fis_uf_substate_enter, | ||
2201 | .exit_state = scic_sds_phy_starting_await_sig_fis_uf_substate_exit | ||
2202 | }, | ||
2203 | [SCIC_SDS_PHY_STARTING_SUBSTATE_FINAL] = { | ||
2204 | .enter_state = scic_sds_phy_starting_final_substate_enter, | ||
2205 | }, | ||
2234 | [SCI_BASE_PHY_STATE_READY] = { | 2206 | [SCI_BASE_PHY_STATE_READY] = { |
2235 | .enter_state = scic_sds_phy_ready_state_enter, | 2207 | .enter_state = scic_sds_phy_ready_state_enter, |
2236 | .exit_state = scic_sds_phy_ready_state_exit, | 2208 | .exit_state = scic_sds_phy_ready_state_exit, |
@@ -2261,12 +2233,6 @@ void scic_sds_phy_construct(struct scic_sds_phy *sci_phy, | |||
2261 | sci_phy->link_layer_registers = NULL; | 2233 | sci_phy->link_layer_registers = NULL; |
2262 | sci_phy->max_negotiated_speed = SAS_LINK_RATE_UNKNOWN; | 2234 | sci_phy->max_negotiated_speed = SAS_LINK_RATE_UNKNOWN; |
2263 | sci_phy->sata_timeout_timer = NULL; | 2235 | sci_phy->sata_timeout_timer = NULL; |
2264 | |||
2265 | /* Initialize the the substate machines */ | ||
2266 | sci_base_state_machine_construct(&sci_phy->starting_substate_machine, | ||
2267 | sci_phy, | ||
2268 | scic_sds_phy_starting_substates, | ||
2269 | SCIC_SDS_PHY_STARTING_SUBSTATE_INITIAL); | ||
2270 | } | 2236 | } |
2271 | 2237 | ||
2272 | void isci_phy_init(struct isci_phy *iphy, struct isci_host *ihost, int index) | 2238 | void isci_phy_init(struct isci_phy *iphy, struct isci_host *ihost, int index) |
diff --git a/drivers/scsi/isci/phy.h b/drivers/scsi/isci/phy.h index f1800368eda5..bf0296463c80 100644 --- a/drivers/scsi/isci/phy.h +++ b/drivers/scsi/isci/phy.h | |||
@@ -142,8 +142,6 @@ struct scic_sds_phy { | |||
142 | 142 | ||
143 | const struct scic_sds_phy_state_handler *state_handlers; | 143 | const struct scic_sds_phy_state_handler *state_handlers; |
144 | 144 | ||
145 | struct sci_base_state_machine starting_substate_machine; | ||
146 | |||
147 | /** | 145 | /** |
148 | * This field is the pointer to the transport layer register for the SCU | 146 | * This field is the pointer to the transport layer register for the SCU |
149 | * hardware. | 147 | * hardware. |
@@ -436,34 +434,6 @@ enum scic_sds_phy_states { | |||
436 | SCI_BASE_PHY_STATE_STARTING, | 434 | SCI_BASE_PHY_STATE_STARTING, |
437 | 435 | ||
438 | /** | 436 | /** |
439 | * This state indicates the the phy is now ready. Thus, the user | ||
440 | * is able to perform IO operations utilizing this phy as long as it | ||
441 | * is currently part of a valid port. | ||
442 | * This state is entered from the STARTING state. | ||
443 | */ | ||
444 | SCI_BASE_PHY_STATE_READY, | ||
445 | |||
446 | /** | ||
447 | * This state indicates that the phy is in the process of being reset. | ||
448 | * In this state no new IO operations are permitted on this phy. | ||
449 | * This state is entered from the READY state. | ||
450 | */ | ||
451 | SCI_BASE_PHY_STATE_RESETTING, | ||
452 | |||
453 | /** | ||
454 | * Simply the final state for the base phy state machine. | ||
455 | */ | ||
456 | SCI_BASE_PHY_STATE_FINAL, | ||
457 | }; | ||
458 | |||
459 | |||
460 | /** | ||
461 | * enum scic_sds_phy_starting_substates - | ||
462 | * | ||
463 | * | ||
464 | */ | ||
465 | enum scic_sds_phy_starting_substates { | ||
466 | /** | ||
467 | * Initial state | 437 | * Initial state |
468 | */ | 438 | */ |
469 | SCIC_SDS_PHY_STARTING_SUBSTATE_INITIAL, | 439 | SCIC_SDS_PHY_STARTING_SUBSTATE_INITIAL, |
@@ -512,8 +482,27 @@ enum scic_sds_phy_starting_substates { | |||
512 | * Exit state for this state machine | 482 | * Exit state for this state machine |
513 | */ | 483 | */ |
514 | SCIC_SDS_PHY_STARTING_SUBSTATE_FINAL, | 484 | SCIC_SDS_PHY_STARTING_SUBSTATE_FINAL, |
515 | }; | ||
516 | 485 | ||
486 | /** | ||
487 | * This state indicates the the phy is now ready. Thus, the user | ||
488 | * is able to perform IO operations utilizing this phy as long as it | ||
489 | * is currently part of a valid port. | ||
490 | * This state is entered from the STARTING state. | ||
491 | */ | ||
492 | SCI_BASE_PHY_STATE_READY, | ||
493 | |||
494 | /** | ||
495 | * This state indicates that the phy is in the process of being reset. | ||
496 | * In this state no new IO operations are permitted on this phy. | ||
497 | * This state is entered from the READY state. | ||
498 | */ | ||
499 | SCI_BASE_PHY_STATE_RESETTING, | ||
500 | |||
501 | /** | ||
502 | * Simply the final state for the base phy state machine. | ||
503 | */ | ||
504 | SCI_BASE_PHY_STATE_FINAL, | ||
505 | }; | ||
517 | 506 | ||
518 | 507 | ||
519 | typedef enum sci_status (*scic_sds_phy_handler_t)(struct scic_sds_phy *); | 508 | typedef enum sci_status (*scic_sds_phy_handler_t)(struct scic_sds_phy *); |